Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto-destruct behavior on Windows when window is closed #944

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Yashashwini2003
Copy link
Contributor

@Yashashwini2003 Yashashwini2003 commented Dec 12, 2024

Windows: The application now terminates the process by std::process::exit(0) when the window is closed similar to that the app behaves to macOS where the process exits when the window is closed.

Closes #926
/claim #926

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
screenpipe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2024 2:50pm

Copy link

request-info bot commented Dec 12, 2024

hey! thanks for the contribution. would you mind adding more details about: - what problem you're trying to solve - why this change is needed - any relevant context or screenshots
this helps us review and merge faster! 🚀

Copy link

algora-pbc bot commented Dec 12, 2024

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe.

@louis030195
Copy link
Collaborator

this is wrong

the cli should kill itself, not the app, the app cannot kill the cli if it's not alive

@Yashashwini2003
Copy link
Contributor Author

Got it! Just followed with the closed issue of same and got context of it

@varshith257
Copy link
Contributor

varshith257 commented Dec 12, 2024

@Yashashwini2003 I think we need auto_destructor in the sidecar.rs . Something like this, sidecar process monitors the app's lifecycle and terminate(auto destruct) itself when the app is no longer running.

@Yashashwini2003
Copy link
Contributor Author

Yashashwini2003 commented Dec 12, 2024

I have observed --auto-destruct-pid in sidecar.rs but it seems it never used while this flag implemented. Now, I think the auto_destruct_monitor function added need to actively monitor the parent process, the sidecar exits cleanly if the parent process is no longer alive. Need to tweak some with parsing the flag from spawn_sidecar and invoke auto_destruct_monitor.

Will update on it

@Yashashwini2003
Copy link
Contributor Author

Yashashwini2003 commented Dec 12, 2024

@louis030195 let me know if my thought process is on right way. If yes, I will update with it or else any suggestions on your mind?

@louis030195
Copy link
Collaborator

it works on macos

if let Some(pid) = cli.auto_destruct_pid {

@Yashashwini2003
Copy link
Contributor Author

Yashashwini2003 commented Dec 13, 2024

@louis030195 That makes sense. Replaced tasklist with OpenProcess on Windows for PID monitoring. tasklist was error-prone due to output parsing and unnecessary process name checks and also some needless permissions results it error prone. The new implementation directly queries the Windows API to verify if the process is alive which should perfectly align behavior with macOS's ps-based monitoring.

@louis030195
Copy link
Collaborator

@Yashashwini2003 nice!

any chance you can share a screen recording to confirm it works - i cannot test myself

eg show task manager, run app without dev mode, start screenpipe recording, close app, and we should see in task manager that the CLI is stopped

then can merge

@Yashashwini2003
Copy link
Contributor Author

Yashashwini2003 commented Dec 13, 2024

@louis030195 My desktop have got into service , will be return in 3 days. Meanwhile I will ask anyone to test it from context of 368. If not I will test it and post video once my desktop is back

I am using codespaces for now :(

@Yashashwini2003
Copy link
Contributor Author

I will tag @meltiso or @varshith257 anyone can test this PR

@louis030195
Copy link
Collaborator

any update

@Yashashwini2003
Copy link
Contributor Author

@meltiso Are you able to test this?

@louis030195
Copy link
Collaborator

i mean just send a video screen recording

@louis030195
Copy link
Collaborator

@Neptune650 any chance you can test this? eg

  1. start app non dev mode
  2. make sure backend is running
  3. close app
  4. backend should have been closed too

@louis030195
Copy link
Collaborator

@Yashashwini2003 can you do this:

  • stop the app using the new method
  • fallback to old method

(for windows)

and then ill merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bounty] fix auto destruct on windows
3 participants