Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into ethie/pm-clean

ethernet5739bd22f610
diff --cc apps/desktop/electron/main.ts
index 9d2e85f91f0,78f4966791c..2e94ed26edb
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@@ -6584,8 -7477,21 +6583,10 @@@ function installPreviewShortcut(window
// Always claim ⌘W here (the File>Close item deliberately has no
// accelerator, so nothing else does). The renderer decides tab-vs-window
// — no `previewShortcutActive` gate, so it works for every closeable tab.
- if (isCloseTabShortcut) {
+ // keyUp is not a claim: a chord that started in another app can deliver
+ // its leftover keyup when this window inherits focus (#105498).
+ if (action === 'close-tab') {
event.preventDefault()
-
- // ⌘W in the HUD is "leave HUD mode", not "close a tab in the app
- // window". Routing it to the main renderer closed the app's tab out
- // from under the user while the HUD stayed put; routing it through the
- // HUD's own close path hands the session back like the exit button.
- if (hudWindow && !hudWindow.isDestroyed() && window === hudWindow) {
- closeHudWindow()
-
- return
- }
-
sendClosePreviewRequested()
return
diff --cc tests/tools/test_oneshot_completion_linger.py
index 0b8548ead6b,ebf0813fb58..39e7cce3530
--- a/tests/tools/test_oneshot_completion_linger.py
+++ b/tests/tools/test_oneshot_completion_linger.py
@@@ -136,9 -146,14 +136,13 @@@ def test_timeout_zero_disables_linger(r
result = registry.wait_for_pending_completions(timeout=0)
assert result == {"waited": [], "completed": [], "timed_out": []}
-
def test_task_id_filter_scopes_the_wait(registry):
- mine = _make_session(sid="proc_mine", task_id="task_a")
- other = _make_session(sid="proc_other", task_id="task_b")
+ # The terminal tool stores the container key in task_id and the spawning turn in
+ # owner_task_id; the filter must match ownership, not the shared container key.
+ mine = _make_session(sid="proc_mine", task_id="session:shared")
+ mine.owner_task_id = "task_a"
+ other = _make_session(sid="proc_other", task_id="session:shared")
+ other.owner_task_id = "task_b"
with registry._lock:
registry._running[mine.id] = mine
registry._running[other.id] = other
diff --cc tools/process_registry.py
index 37b70df92cc,7d20736a642..ed2781a194f
--- a/tools/process_registry.py
+++ b/tools/process_registry.py
@@@ -574,10 -559,14 +574,16 @@@ class ProcessSession
_completion_event: threading.Event = field(default_factory=threading.Event, repr=False)
_lock: threading.Lock = field(default_factory=threading.Lock)
_reader_thread: Optional[threading.Thread] = field(default=None, repr=False)
+ _reader_finish_requested: threading.Event = field(default_factory=threading.Event, repr=False)
+ _reader_selectable: bool = field(default=False, repr=False)
_pty: Any = field(default=None, repr=False) # ptyprocess handle (use_pty=True)
+ def __post_init__(self):
+ # A session built without an explicit owner is owned by its own task, so ownership checks compare
+ # ``owner_task_id`` alone instead of repeating an ``or task_id`` fallback at every call site.
+ if not self.owner_task_id:
+ self.owner_task_id = self.task_id
+
def append_output(self, text: str) -> None:
"""Append to the rolling output buffer under the session lock, keeping the tail."""
with self._lock: