Skip to content

move Applications End Task off the UI thread - #42

Merged
JamesLinYJ merged 2 commits into
mainfrom
cursor/applications-end-task-off-ui
Nov 9, 2026
Merged

JamesLinYJ merged 2 commits into
mainfrom
cursor/applications-end-task-off-ui

Conversation

@JamesLinYJ

@JamesLinYJ JamesLinYJ commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Applications → End Task no longer calls EndTask on the UI thread. The click captures the selected window identities and the Ctrl force flag, then submits that batch to a persistent SingleFlightWorker created once beside the snapshot and icon workers.

If another End Task is already running, each later click is appended and run in submission order. An accepted command is not replaced by a newer selection. The worker re-checks each window immediately before EndTask: the HWND still exists, the thread id still matches, and ProcIdentity (pid + creation time) still matches. A window that fails any check is skipped and is not treated as success. Ctrl+force stays with the command that captured it. When several windows are selected, each one runs, and only the first real EndTask failure is shown with the existing warning dialog.

The page wakes through the existing PWM_TASK_WORKER_COMPLETE message and drains this worker in the existing completion handler. Destroying the page drops the worker without joining it on the UI thread, so a blocked EndTask cannot stall teardown and a late result is discarded.

Test plan

  • Select one responding application and choose End Task. The window closes, and the UI stays responsive while it does.
  • Hold Ctrl and choose End Task. The force flag is still passed through.
  • Select several windows, including one that cannot be closed. Each selected window is attempted, and the warning dialog reports only the first real failure.
  • While the first End Task is still running, submit two more selections. All three commands run, in the order they were accepted.
  • Leave the Applications page while End Task is still running. The page tears down without waiting on that call, and no warning appears afterward.
Open in Web Open in Cursor 

EndTask can block in the target window's queue. Submit the selected
window identities and the Ctrl force flag to a persistent single-flight
worker, re-check the window before the call, and report only the first
real failure on the existing completion path.

Co-authored-by: jameslincn <jameslincn@outlook.sg>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T04:44:44.892143Z 5626afc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5626afc40f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pages/applications/mod.rs Resolved
A second End Task click while one is running was merged with replace_pending,
so the earlier selection never ran. Append each accepted command and run the
queue in order, still re-checking the window before every EndTask.

Co-authored-by: jameslincn <jameslincn@outlook.sg>
@JamesLinYJ
JamesLinYJ merged commit 5e6339f into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants