Repository navigation
Conversation
…nning Ctrl+Z sends SIGSTOP to the whole foreground process group, so a running turn and the in-process subagents freeze until `fg`, while commands in their own sessions keep running with nobody reading them. With a turn, a running subagent or a background job, the first press now shows what is running and a second press within 3 seconds suspends. With nothing running, Ctrl+Z suspends at once as before.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
roboomp
left a comment
There was a problem hiding this comment.
Rank P2. The diff is tight and correct: #runningWork gates handleCtrlZ, the idle path is unchanged, and the tests cover the hold, the confirm and the window expiry. But it changes what Ctrl+Z does by default (POSIX convention: suspend at once) with no setting to turn it off, so it needs a maintainer to sign off.
- should-fix: the CHANGELOG entry has no PR/author attribution, though the checklist says it does.
- should-fix: the background-job count copies
#syncHudPills, andstatus-line.tscounts jobs a different way. Extract one shared helper.
Maintainer question: should a busy session hold back Ctrl+Z by default, or should this sit behind a setting? A stopped job resumes intact onfg, so the harm is stalled detached children and forgotten stopped processes, not lost work.
Thanks @itskaism for the careful repro and the red/green evidence.
|
|
||
| ### Fixed | ||
|
|
||
| - Ctrl+Z no longer suspends omp at once while a turn, subagents or background jobs are running. The first press names what is running, and a second press within 3 seconds suspends. |
There was a problem hiding this comment.
should-fix — the entry has no attribution, but the PR checklist marks it done. AGENTS.md § Changelog says external contributions end with ([#21139](https://github.com/can1357/oh-my-pi/pull/21139) by [@itskaism](https://github.com/itskaism)). Also cut it to one user-facing line, e.g. Ctrl+Z now asks for a second press before suspending while a turn, subagents or background jobs are running.
| if (agents > 0) work.push(`${agents} ${agents === 1 ? "subagent" : "subagents"}`); | ||
| // A job that runs a subagent counts as that subagent, as in the HUD pills. | ||
| let jobs = 0; | ||
| for (const job of this.ctx.session.getAsyncJobSnapshot()?.running ?? []) if (job.agentId === undefined) jobs++; |
There was a problem hiding this comment.
should-fix — this is the third copy of "count running async jobs that aren't a subagent's", and the copies disagree:
interactive-mode.ts:919-921(#syncHudPills) countsjob.agentId === undefined, the same rule as here.status-line.ts:208-210(#jobs) also countstype === "task"jobs whoseagentIdis not in the running-subagent set.
So the Ctrl+Z line can report a different job count from the status-line segment the user can see. AGENTS.md § Central Utilities: extract one helper (next to getRunningSubagentBadgeAgentIds in running-subagent-badge.ts, or on the session) and call it from all three places, or at least from the pill and here. The same goes for the subagent count: InteractiveMode already keeps #runningSubagentCount (interactive-mode.ts:3709-3716). Exposing it on InteractiveModeContext would stop this from walking the registry a second time.
There was a problem hiding this comment.
Done in 9418389. getBackgroundJobs(running, runningSubagentIds) sits next to getRunningSubagentBadgeAgentIds in running-subagent-badge.ts. The HUD jobs pill, the status line, Ctrl+Z and /pause call it; pauseWorkStatus in builtin-control.ts held a fourth copy, with the status line's rule.
The helper keeps the status line's rule. A task job counts as its subagent only while that subagent is in the running set, so a task job queued before its subagent starts counts as a background job. Under the pill's agentId === undefined rule that job showed in neither pill, and Ctrl+Z suspended at once while it ran. The pill now counts it for that window, so the changelog has a line for it. status-line-background-jobs.test.ts already asserted the status line's rule and is unchanged. New tests: the helper's cases, counts a task job queued before its agent runs as a background job for the pill, and holds the first press for a task job queued before its subagent runs for Ctrl+Z; both fail with the source before 9418389. The pill test for an agent's own job now registers that agent as running.
Ctrl+Z still reads AgentRegistry.global() for subagents instead of InteractiveMode's count. On a collab guest that count comes from the guest's mirror of the host's agents, which keep running when the guest's process stops; the walk runs once per key press. InteractiveMode now keeps the running ids (#runningSubagentIds) instead of their count, because the pill passes them to the helper.
…equest Cut the entry to one line and added the PR and author attribution the changelog rules ask of external contributions.
…ll, status line, Ctrl+Z and /pause The HUD jobs pill and the Ctrl+Z guard counted every job without an agentId. The status line and /pause also counted a task job whose subagent the running-subagents badge does not count, such as a job queued before its subagent starts. That job showed in neither HUD pill, and Ctrl+Z suspended at once with it running. getBackgroundJobs, next to getRunningSubagentBadgeAgentIds, keeps the status line's rule, and all four places call it. Ctrl+Z still reads this process's registry rather than a collab guest's mirror of the host, since SIGSTOP stops only this process.
|
On the default: the guard changes Ctrl+Z only while a turn, a subagent or a background job is running. Then the first press shows what is running and leaves omp running; a second press within 3 s suspends as before. With nothing running, the first press suspends at once, as on main, and Windows is unchanged. A stopped omp does resume intact on |
# Conflicts: # packages/coding-agent/src/modes/controllers/input-controller.ts
What
Ctrl+Z now asks before suspending when work is running. With a turn streaming, a running subagent or a background job, the first press shows a status line that names them, for example
Still running: a turn, 2 subagents, 1 background job · press <key> again to suspend anyway, and does not stop the process. A second press within 3 seconds suspends as before. With nothing running, the first press suspends at once, as on main. Windows is unchanged (suspend is still unsupported there).handleCtrlZ(modes/controllers/input-controller.ts) counts the work with the sources the HUD already uses:session.isStreamingfor the turn,getRunningSubagentBadgeAgentIds(AgentRegistry.global())for subagents (the running-subagents badge), andgetBackgroundJobsover the running jobs ofsession.getAsyncJobSnapshot()for background jobs (the task job of a running subagent counts as that subagent).getBackgroundJobs(modes/view-model/overlays/running-subagent-badge.ts) is the one rule for background jobs; the HUD jobs pill, the status line, Ctrl+Z and/pausecall it. A task job counts as its subagent only while that subagent is in the running set, so a task job queued before its subagent starts is a background job, as the status line and/pausealready counted it. The jobs pill counted only jobs without anagentId, so it now shows such a job too.SUSPEND_CONFIRM_WINDOW_MS(3 s). It is longer than the 500 ms of the Ctrl+C and Esc double presses because the first press shows a line to read before deciding. A press after the window asks again. No setting is added.Why
Reproduction
The interactive TUI on a pty whose session leader is an interactive
bashwith job control, omp as its job (Linux x64 under WSL2, mainf6b51e293afrom source, a scripted local model). Ctrl+Z (0x1a) moves omp fromSl+toTl, and bash prints[1]+ Stopped. omp shows no warning and asks nothing. Its worker child, in its own session, stays inSsland keeps running beside the stopped parent untilfg.One terminal held four stopped omp processes.
Cause, at main
b28a3d938dpackages/coding-agent/src/modes/controllers/input-controller.ts:559sendsapp.suspendstraight tohandleCtrlZ(:1864), whose only check is the Windows one. It callsctx.suspend(...)andprocess.kill(0, "SIGSTOP")(:1918) on the first press. The whole foreground process group stops: the turn and the in-process subagents freeze, while children in their own sessions (MCP stdio servers, the commands the embedded shell runs) keep running with nobody reading them.Testing
packages/coding-agent/test/input-controller-suspend.test.ts. Itssetupnow gives the fake context asession(streaming flag and job snapshot) and stubsAgentRegistry.global().list(); the three existing cases run with nothing running. New cases:holds the first press while work runs, naming it, and suspends on a second press: a streaming turn, 2 running subagents, one background job and one job that runs a subagent. The first press does not callsuspendorprocess.killand showsStill running: a turn, 2 subagents, 1 background job · press … again to suspend anyway. The second press sendsSIGSTOPto the process group, andSIGCONTtakes the terminal back.asks again when the second press comes after the confirm window: withDate.nowstubbed, a second press 3 s after the first shows the line again and does not suspend.holds the first press for a task job queued before its subagent runs: a task job whose subagent is not running yet holds the first press as one background job.packages/coding-agent/test/running-subagent-background-jobs.test.ts(new):getBackgroundJobskeeps bash and eval jobs, drops the task job of a running subagent, and keeps a task job queued before its subagent runs and a task job without an agent.packages/coding-agent/test/interactive-mode-hud-job-widgets.test.ts: newcounts a task job queued before its agent runs as a background job(the jobs pill reads1 job running); the existingcounts and lists background jobs only, never a job that runs an agentnow registers that agent as running.The existing
SIGSTOPs the foreground process group ...case covers the idle path: the first press suspends.Results on Linux x64 (WSL2), bun 1.4.4:
b28a3d938d'spackages/coding-agent/srcwith the first commit's tests: 3 pass, 2 fail. Both guard cases fail atexpect(t.ctx.suspend).not.toHaveBeenCalled()(1 call, and 2 calls for the window case): main suspends on every press.getBackgroundJobscommit with this branch's tests:holds the first press for a task job queued before its subagent runsfails (1 call tosuspend),counts a task job queued before its agent runs as a background jobfails (no jobs segment), and the helper test does not load (Export named 'getBackgroundJobs' not found).test/input-controller-escape.test.ts,test/input-controller-hard-abort-terminal.test.ts,test/collab/guest-subagent-badge.test.tsandtest/modes/interactive-mode-live-settings.test.ts: 43 pass, 0 fail.oxlintandoxfmt --checkon the changed files: clean.bun run check:typesinpackages/coding-agent: no type errors in 5,878 files.bash, the scripted model runningsleep 600through the bash tool. The first Ctrl+Z left omp running (stateS) and the driver found theStill running ... again to suspend anywaytext on the screen; a second press within 3 s stopped it (stateT). With main'spackages/coding-agent/srcin the same tree, the first press stopped it./pausetest. Its job count now callsgetBackgroundJobswith the rule it had before.bun check, so the first box below stays open.Not covered
--continueskips that session and resumes an older one, and--resume <id>saves to a new file. Neither says that the holder is stopped or names its pid. That is a separate change.bun checkpasses