Repository navigation
feat(chat): queue prompts sent while compaction runs - #1426
Merged
Merged
Conversation
pi's SDK rejects prompts during compaction ("Cannot submit a prompt while
compaction is in progress"), so every submission bounced back to the
composer with an error and the input read as dead. Park the submissions in
the wrapper and flush them FIFO at compaction end, as pi's TUI's
compactionQueuedMessages does. This is the compaction-queueing part of
agegr#812, the focused follow-up its closing comment asked for.
- Parking happens on the SDK's rejection, never before inner.prompt(), so
an extension command typed during compaction still runs: the SDK
executes commands before it refuses.
- A parked prompt keeps its admission's pendingPromptCount outstanding
until delivery or recall, so isRunning(), the idle shutdown and the
reload/clone refusals all see it.
- The flush is the TUI's flushCompactionQueue() in the wrapper: every
delivery carries a streamingBehavior (a plain parked prompt as followUp),
so AgentSession.prompt() queues it into a run still finishing the
compaction or starts one when idle, never "Agent is already processing".
A delivery that started the run emits its prompt_done, one that queued
into another run rides that run's, and a failed delivery goes back to the
queue with prompt_error and waits for Recall or the next compaction end.
- get_state.queuedMessages and every queue_update merge pi's queue with the
parked ones; clear_queue returns both, and Recall puts the text back in
the composer.
- The composer stays editable while compacting: the placeholder says
messages queue, and the status line shows "Compacting... - N queued",
for a manual compaction too (agentRunning alone left it unlabeled).
Tests: lib/rpc-manager-compaction-queue.test.mjs (park, FIFO flush,
recall, merge, failed flush, images), the queued-count case in
chat-phase-label, the editable-composer case in ChatInput. tsc, eslint and
the touched areas' 246 tests pass; the 66 suite failures on this Windows
machine are identical with and without the change.
…mpts out of the transcript
Two bugs from manual testing of the compaction queueing.
1. /compact disabled the composer for the whole compaction. The builtin
slash handler awaited the blocking compact POST, and runBuiltinCommand
holds the composer's <fieldset disabled> until the command resolves: the
input box took no text until the session was switched away and back (a
remount resets builtinCommandPending). The command now completes at once
and runs the compaction detached through handleCompact, the Compact
button's path, which reports itself (Compacting status, Stop compaction,
result banner, error); its result is the silent action: "compact".
handleCompact takes the optional custom instructions and promotes the
session after its reload, as the inline path did.
2. A parked prompt rendered as a sent message. handleSend's optimistic
bubble stayed in the transcript while the message waited in the queue.
A queued submission is now acked { queued: true } (parked, or the SDK's
"queued" disposition) and the client drops the bubble: the queue rows
show it, and the transcript shows it when the flush delivers it.
Tests: hooks/compact-command.test.mjs pins the detached /compact against a
compact POST that never resolves; lib/rpc-manager-compaction-queue.test.mjs
pins the queued ack (and the extension command still answering null).
tsc, eslint and the touched areas' 258 tests pass.
28 test files fixed, test and fixture code only (plus one fixture server).
No product change. Root causes, by cluster:
- 8.3 temp paths: %TEMP% resolves to C:\Users\LINWEI~1\... while git,
the SDK and $HOME report expanded names. Node's realpathSync keeps short
names (only realpathSync.native expands them), so fixtures compared
unequal paths and ancestor walks reached the real ~/.agents/skills from
the scratch dir. Fixture roots now canonicalize with realpathSync.native.
- CRLF checkouts: source-reading tests sliced on ";\n" and regexes ended
at \n before \r, so they extracted nothing. Repo convention
.replace(/\r\n/g, "\n") applied at the read sites.
- chmod on Windows: 0o500/0o400 do not make directories unwritable and
stat reports 0o666 regardless. Unwritable tests now lock the file too
(same refusal path, different syscall); mode assertions keep POSIX.
- ESM absolute paths: hooks fixtures imported a raw G:\... path, which
Node's ESM loader rejects (protocol 'g:'), and drive-letter-case drift
would load a second shim instance. They now take the shim through
jiti.import("react"), the alias route the hooks resolve react by.
- ConPTY: node-pty reports pid 0 until its worker connects and arms a 5s
watchdog; tests now wait for the connection before asserting or ticking
mock timers.
- EBUSY teardown: fixture MCP servers held cwd open while rm ran (Windows
refuses); shutdown is awaited first and removal retries. A fixture's
!touch marker wrote into the repo root (unquoted backslashes in bash -c);
markers are quoted with forward slashes. Grandchild processes of the
MCP fixture now exit with their parent.
- PATH assertions joined with the host delimiter for a case that tests
another platform; PTY and skills-walk tests reached the developer's real
home on Windows (temp under the profile): hermetic .git marker added.
npm test now passes end to end here (2880 tests, 2859 pass, 21 skipped,
0 fail) and exits without --test-force-exit; it used to hang on leaked
fixture processes and fail 66.
This reverts commit 63924a8. The Windows test fixes are unrelated to compaction queueing, and most of them (14 of 29 files) overlap the open Windows test PRs agegr#1364-agegr#1368. They belong in a PR of their own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The flush called inner.prompt() for every parked prompt at once, so an `input` handler that took longer on the first one let the second start the run: [slow, fast] went out as [fast, slow]. Each delivery now goes through the prompt admission chain, one submission at a time, so a prompt sent after compaction_end also queues behind them. - Stop (`abort`) ends the compaction, and its compaction_end sent the parked prompts: Stop started a run, under forceShutdownOnIdle. Stop now recalls them first and returns their texts for the composer, as the TUI's abort restores queued messages to the editor. Stop compaction still flushes them, as Esc during compaction does in the TUI. - A delivery that failed after it was accepted was parked again and would have been sent twice; a refused one kept its admission count, so the session stayed running until Recall. Now only a refused delivery goes back to the queue, with its admission settled; settle() is the admission's idempotent finishPrompt, so Recall never settles twice. - Recall and Stop send prompt_done for a recalled plain prompt (its client waits for one); the delivery that started the run sends it whatever its streamingBehavior. - Park only on the SDK's refusal before preflight: `inner.isCompacting` alone parked unrelated errors during auto-compaction. `queued: true` is the parked ack only, and auto_compaction_end (no pi 1.4 event) is gone. lib/rpc-manager-compaction-queue.integration.test.mjs plays both bugs against a real AgentSession and fails on the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omposer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e flush - The SDK's refusal reaches the wrapper's handler a microtask later, so compaction_end could flush before the prompt was parked: it stayed a queue row and the session read running for good. The handler now flushes itself when the compaction is already over. - flushParkedPrompts() emptied the queue at once while each delivery waited for admission: during the first one's preflight, Recall returned nothing and Stop could not take the rest back, which were sent anyway. An entry now stays listed until its delivery holds admission; Recall and Stop take it, and the delivery skips an entry that is gone. - A plain parked prompt is a steer, as the TUI parks Enter during compaction: as a followUp it was listed (and recalled) after the steers sent after it, so "A" then "B" came back as "B", "A". Delivery stays FIFO. - Recall and Stop return the parked prompts' images beside their texts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recall and Stop put the images of prompts parked behind a compaction back in the composer with their texts (restoreSubmission, as a refused prompt had them before). A /compact <instructions> whose compaction fails gives the command back to the composer, where the awaited command left it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks. This is the follow-up I asked for in #812, and the TUI parity is right. I checked it against pi 1.4.0's I pushed fixes on top:
I also reverted "test: run the suite green on Windows". It is unrelated to this change, and about half of it overlaps the open #1364–#1368, so please send the rest as its own PR. I merged main (pi 1.4.0) as well. tsc, lint and |
agegr
added a commit
to tossp/tsgw-agent
that referenced
this pull request
Oct 29, 2026
The event handler flushes agegr#1426's parked prompts on compaction_end and still marks agent_settled with subagentsActive; the subagent-runtime import takes agegr#1386's getLiveSubagentStatus beside hasUnsettledSubagentRun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agegr
added a commit
to wowayou/pi-web
that referenced
this pull request
Oct 29, 2026
Both sides added a ChatInput test at the same place (agegr#1426's compacting composer); both are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
windli2018
added a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 1, 2026
…0.13 integration) - upstream v0.13.0: Debug panel, prompt parking during compaction (agegr#1426), unconfirmed-send recovery (agegr#1432), live-session rename (agegr#1451), spacer sidebar rhythm, code fence line wrap (agegr#1360/agegr#1369), svg fence preview, display-math copy, binary notice, pi packages 1.4.0 - fork features carried: event-bus convergence, ticket file channel, conn-guard, queue mirror w/ attachment flags, draft-keeper contract, lazy Prism chunk, stream-parse throttle, own toolbar/mobile composer - fixes from post-merge inheritance testing: code fence wrap on the lazy highlighter path (agegr#1369), Debug panel entry re-homed + basePath-aware fetch, online reconcile bypass, wrapper registration order, TS6 test harness adaptation
windli2018
added a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…0.13 integration) - upstream v0.13.0: Debug panel, prompt parking during compaction (agegr#1426), unconfirmed-send recovery (agegr#1432), live-session rename (agegr#1451), spacer sidebar rhythm, code fence line wrap (agegr#1360/agegr#1369), svg fence preview, display-math copy, binary notice, pi packages 1.4.0 - fork features carried: event-bus convergence, ticket file channel, conn-guard, queue mirror w/ attachment flags, draft-keeper contract, lazy Prism chunk, stream-parse throttle, own toolbar/mobile composer - fixes from post-merge inheritance testing: code fence wrap on the lazy highlighter path (agegr#1369), Debug panel entry re-homed + basePath-aware fetch, online reconcile bypass, wrapper registration order, TS6 test harness adaptation
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
* feat(chat): queue prompts sent while compaction runs
pi's SDK rejects prompts during compaction ("Cannot submit a prompt while
compaction is in progress"), so every submission bounced back to the
composer with an error and the input read as dead. Park the submissions in
the wrapper and flush them FIFO at compaction end, as pi's TUI's
compactionQueuedMessages does. This is the compaction-queueing part of
agegr#812, the focused follow-up its closing comment asked for.
- Parking happens on the SDK's rejection, never before inner.prompt(), so
an extension command typed during compaction still runs: the SDK
executes commands before it refuses.
- A parked prompt keeps its admission's pendingPromptCount outstanding
until delivery or recall, so isRunning(), the idle shutdown and the
reload/clone refusals all see it.
- The flush is the TUI's flushCompactionQueue() in the wrapper: every
delivery carries a streamingBehavior (a plain parked prompt as followUp),
so AgentSession.prompt() queues it into a run still finishing the
compaction or starts one when idle, never "Agent is already processing".
A delivery that started the run emits its prompt_done, one that queued
into another run rides that run's, and a failed delivery goes back to the
queue with prompt_error and waits for Recall or the next compaction end.
- get_state.queuedMessages and every queue_update merge pi's queue with the
parked ones; clear_queue returns both, and Recall puts the text back in
the composer.
- The composer stays editable while compacting: the placeholder says
messages queue, and the status line shows "Compacting... - N queued",
for a manual compaction too (agentRunning alone left it unlabeled).
Tests: lib/rpc-manager-compaction-queue.test.mjs (park, FIFO flush,
recall, merge, failed flush, images), the queued-count case in
chat-phase-label, the editable-composer case in ChatInput. tsc, eslint and
the touched areas' 246 tests pass; the 66 suite failures on this Windows
machine are identical with and without the change.
* fix(chat): keep the composer usable during compaction, and queued prompts out of the transcript
Two bugs from manual testing of the compaction queueing.
1. /compact disabled the composer for the whole compaction. The builtin
slash handler awaited the blocking compact POST, and runBuiltinCommand
holds the composer's <fieldset disabled> until the command resolves: the
input box took no text until the session was switched away and back (a
remount resets builtinCommandPending). The command now completes at once
and runs the compaction detached through handleCompact, the Compact
button's path, which reports itself (Compacting status, Stop compaction,
result banner, error); its result is the silent action: "compact".
handleCompact takes the optional custom instructions and promotes the
session after its reload, as the inline path did.
2. A parked prompt rendered as a sent message. handleSend's optimistic
bubble stayed in the transcript while the message waited in the queue.
A queued submission is now acked { queued: true } (parked, or the SDK's
"queued" disposition) and the client drops the bubble: the queue rows
show it, and the transcript shows it when the flush delivers it.
Tests: hooks/compact-command.test.mjs pins the detached /compact against a
compact POST that never resolves; lib/rpc-manager-compaction-queue.test.mjs
pins the queued ack (and the extension command still answering null).
tsc, eslint and the touched areas' 258 tests pass.
* test: run the suite green on Windows
28 test files fixed, test and fixture code only (plus one fixture server).
No product change. Root causes, by cluster:
- 8.3 temp paths: %TEMP% resolves to C:\Users\LINWEI~1\... while git,
the SDK and $HOME report expanded names. Node's realpathSync keeps short
names (only realpathSync.native expands them), so fixtures compared
unequal paths and ancestor walks reached the real ~/.agents/skills from
the scratch dir. Fixture roots now canonicalize with realpathSync.native.
- CRLF checkouts: source-reading tests sliced on ";\n" and regexes ended
at \n before \r, so they extracted nothing. Repo convention
.replace(/\r\n/g, "\n") applied at the read sites.
- chmod on Windows: 0o500/0o400 do not make directories unwritable and
stat reports 0o666 regardless. Unwritable tests now lock the file too
(same refusal path, different syscall); mode assertions keep POSIX.
- ESM absolute paths: hooks fixtures imported a raw G:\... path, which
Node's ESM loader rejects (protocol 'g:'), and drive-letter-case drift
would load a second shim instance. They now take the shim through
jiti.import("react"), the alias route the hooks resolve react by.
- ConPTY: node-pty reports pid 0 until its worker connects and arms a 5s
watchdog; tests now wait for the connection before asserting or ticking
mock timers.
- EBUSY teardown: fixture MCP servers held cwd open while rm ran (Windows
refuses); shutdown is awaited first and removal retries. A fixture's
!touch marker wrote into the repo root (unquoted backslashes in bash -c);
markers are quoted with forward slashes. Grandchild processes of the
MCP fixture now exit with their parent.
- PATH assertions joined with the host delimiter for a case that tests
another platform; PTY and skills-walk tests reached the developer's real
home on Windows (temp under the profile): hermetic .git marker added.
npm test now passes end to end here (2880 tests, 2859 pass, 21 skipped,
0 fail) and exits without --test-force-exit; it used to hang on leaked
fixture processes and fail 66.
* Revert "test: run the suite green on Windows"
This reverts commit 63924a8. The Windows test fixes are unrelated to
compaction queueing, and most of them (14 of 29 files) overlap the open
Windows test PRs agegr#1364-agegr#1368. They belong in a PR of their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): flush parked prompts in order and keep them on Stop
- The flush called inner.prompt() for every parked prompt at once, so an
`input` handler that took longer on the first one let the second start
the run: [slow, fast] went out as [fast, slow]. Each delivery now goes
through the prompt admission chain, one submission at a time, so a
prompt sent after compaction_end also queues behind them.
- Stop (`abort`) ends the compaction, and its compaction_end sent the
parked prompts: Stop started a run, under forceShutdownOnIdle. Stop now
recalls them first and returns their texts for the composer, as the
TUI's abort restores queued messages to the editor. Stop compaction
still flushes them, as Esc during compaction does in the TUI.
- A delivery that failed after it was accepted was parked again and
would have been sent twice; a refused one kept its admission count, so
the session stayed running until Recall. Now only a refused delivery
goes back to the queue, with its admission settled; settle() is the
admission's idempotent finishPrompt, so Recall never settles twice.
- Recall and Stop send prompt_done for a recalled plain prompt (its client
waits for one); the delivery that started the run sends it whatever its
streamingBehavior.
- Park only on the SDK's refusal before preflight: `inner.isCompacting`
alone parked unrelated errors during auto-compaction. `queued: true` is
the parked ack only, and auto_compaction_end (no pi 1.4 event) is gone.
lib/rpc-manager-compaction-queue.integration.test.mjs plays both bugs
against a real AgentSession and fails on the previous commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): Stop puts prompts parked behind a compaction back in the composer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): parked prompts survive a late refusal and Recall during the flush
- The SDK's refusal reaches the wrapper's handler a microtask later, so
compaction_end could flush before the prompt was parked: it stayed a
queue row and the session read running for good. The handler now
flushes itself when the compaction is already over.
- flushParkedPrompts() emptied the queue at once while each delivery
waited for admission: during the first one's preflight, Recall returned
nothing and Stop could not take the rest back, which were sent anyway.
An entry now stays listed until its delivery holds admission; Recall
and Stop take it, and the delivery skips an entry that is gone.
- A plain parked prompt is a steer, as the TUI parks Enter during
compaction: as a followUp it was listed (and recalled) after the steers
sent after it, so "A" then "B" came back as "B", "A". Delivery stays FIFO.
- Recall and Stop return the parked prompts' images beside their texts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): restore recalled images, and /compact instructions on failure
Recall and Stop put the images of prompts parked behind a compaction back
in the composer with their texts (restoreSubmission, as a refused prompt
had them before). A /compact <instructions> whose compaction fails gives
the command back to the composer, where the awaited command left it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: qiyu <linweiguang@shangyoo.com>
Co-authored-by: Alex Yang <agegcn@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
windli2018
added a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…0.13 integration) - upstream v0.13.0: Debug panel, prompt parking during compaction (agegr#1426), unconfirmed-send recovery (agegr#1432), live-session rename (agegr#1451), spacer sidebar rhythm, code fence line wrap (agegr#1360/agegr#1369), svg fence preview, display-math copy, binary notice, pi packages 1.4.0 - fork features carried: event-bus convergence, ticket file channel, conn-guard, queue mirror w/ attachment flags, draft-keeper contract, lazy Prism chunk, stream-parse throttle, own toolbar/mobile composer - fixes from post-merge inheritance testing: code fence wrap on the lazy highlighter path (agegr#1369), Debug panel entry re-homed + basePath-aware fetch, online reconcile bypass, wrapper registration order, TS6 test harness adaptation
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
* feat(chat): queue prompts sent while compaction runs
pi's SDK rejects prompts during compaction ("Cannot submit a prompt while
compaction is in progress"), so every submission bounced back to the
composer with an error and the input read as dead. Park the submissions in
the wrapper and flush them FIFO at compaction end, as pi's TUI's
compactionQueuedMessages does. This is the compaction-queueing part of
agegr#812, the focused follow-up its closing comment asked for.
- Parking happens on the SDK's rejection, never before inner.prompt(), so
an extension command typed during compaction still runs: the SDK
executes commands before it refuses.
- A parked prompt keeps its admission's pendingPromptCount outstanding
until delivery or recall, so isRunning(), the idle shutdown and the
reload/clone refusals all see it.
- The flush is the TUI's flushCompactionQueue() in the wrapper: every
delivery carries a streamingBehavior (a plain parked prompt as followUp),
so AgentSession.prompt() queues it into a run still finishing the
compaction or starts one when idle, never "Agent is already processing".
A delivery that started the run emits its prompt_done, one that queued
into another run rides that run's, and a failed delivery goes back to the
queue with prompt_error and waits for Recall or the next compaction end.
- get_state.queuedMessages and every queue_update merge pi's queue with the
parked ones; clear_queue returns both, and Recall puts the text back in
the composer.
- The composer stays editable while compacting: the placeholder says
messages queue, and the status line shows "Compacting... - N queued",
for a manual compaction too (agentRunning alone left it unlabeled).
Tests: lib/rpc-manager-compaction-queue.test.mjs (park, FIFO flush,
recall, merge, failed flush, images), the queued-count case in
chat-phase-label, the editable-composer case in ChatInput. tsc, eslint and
the touched areas' 246 tests pass; the 66 suite failures on this Windows
machine are identical with and without the change.
* fix(chat): keep the composer usable during compaction, and queued prompts out of the transcript
Two bugs from manual testing of the compaction queueing.
1. /compact disabled the composer for the whole compaction. The builtin
slash handler awaited the blocking compact POST, and runBuiltinCommand
holds the composer's <fieldset disabled> until the command resolves: the
input box took no text until the session was switched away and back (a
remount resets builtinCommandPending). The command now completes at once
and runs the compaction detached through handleCompact, the Compact
button's path, which reports itself (Compacting status, Stop compaction,
result banner, error); its result is the silent action: "compact".
handleCompact takes the optional custom instructions and promotes the
session after its reload, as the inline path did.
2. A parked prompt rendered as a sent message. handleSend's optimistic
bubble stayed in the transcript while the message waited in the queue.
A queued submission is now acked { queued: true } (parked, or the SDK's
"queued" disposition) and the client drops the bubble: the queue rows
show it, and the transcript shows it when the flush delivers it.
Tests: hooks/compact-command.test.mjs pins the detached /compact against a
compact POST that never resolves; lib/rpc-manager-compaction-queue.test.mjs
pins the queued ack (and the extension command still answering null).
tsc, eslint and the touched areas' 258 tests pass.
* test: run the suite green on Windows
28 test files fixed, test and fixture code only (plus one fixture server).
No product change. Root causes, by cluster:
- 8.3 temp paths: %TEMP% resolves to C:\Users\LINWEI~1\... while git,
the SDK and $HOME report expanded names. Node's realpathSync keeps short
names (only realpathSync.native expands them), so fixtures compared
unequal paths and ancestor walks reached the real ~/.agents/skills from
the scratch dir. Fixture roots now canonicalize with realpathSync.native.
- CRLF checkouts: source-reading tests sliced on ";\n" and regexes ended
at \n before \r, so they extracted nothing. Repo convention
.replace(/\r\n/g, "\n") applied at the read sites.
- chmod on Windows: 0o500/0o400 do not make directories unwritable and
stat reports 0o666 regardless. Unwritable tests now lock the file too
(same refusal path, different syscall); mode assertions keep POSIX.
- ESM absolute paths: hooks fixtures imported a raw G:\... path, which
Node's ESM loader rejects (protocol 'g:'), and drive-letter-case drift
would load a second shim instance. They now take the shim through
jiti.import("react"), the alias route the hooks resolve react by.
- ConPTY: node-pty reports pid 0 until its worker connects and arms a 5s
watchdog; tests now wait for the connection before asserting or ticking
mock timers.
- EBUSY teardown: fixture MCP servers held cwd open while rm ran (Windows
refuses); shutdown is awaited first and removal retries. A fixture's
!touch marker wrote into the repo root (unquoted backslashes in bash -c);
markers are quoted with forward slashes. Grandchild processes of the
MCP fixture now exit with their parent.
- PATH assertions joined with the host delimiter for a case that tests
another platform; PTY and skills-walk tests reached the developer's real
home on Windows (temp under the profile): hermetic .git marker added.
npm test now passes end to end here (2880 tests, 2859 pass, 21 skipped,
0 fail) and exits without --test-force-exit; it used to hang on leaked
fixture processes and fail 66.
* Revert "test: run the suite green on Windows"
This reverts commit 63924a8. The Windows test fixes are unrelated to
compaction queueing, and most of them (14 of 29 files) overlap the open
Windows test PRs agegr#1364-agegr#1368. They belong in a PR of their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): flush parked prompts in order and keep them on Stop
- The flush called inner.prompt() for every parked prompt at once, so an
`input` handler that took longer on the first one let the second start
the run: [slow, fast] went out as [fast, slow]. Each delivery now goes
through the prompt admission chain, one submission at a time, so a
prompt sent after compaction_end also queues behind them.
- Stop (`abort`) ends the compaction, and its compaction_end sent the
parked prompts: Stop started a run, under forceShutdownOnIdle. Stop now
recalls them first and returns their texts for the composer, as the
TUI's abort restores queued messages to the editor. Stop compaction
still flushes them, as Esc during compaction does in the TUI.
- A delivery that failed after it was accepted was parked again and
would have been sent twice; a refused one kept its admission count, so
the session stayed running until Recall. Now only a refused delivery
goes back to the queue, with its admission settled; settle() is the
admission's idempotent finishPrompt, so Recall never settles twice.
- Recall and Stop send prompt_done for a recalled plain prompt (its client
waits for one); the delivery that started the run sends it whatever its
streamingBehavior.
- Park only on the SDK's refusal before preflight: `inner.isCompacting`
alone parked unrelated errors during auto-compaction. `queued: true` is
the parked ack only, and auto_compaction_end (no pi 1.4 event) is gone.
lib/rpc-manager-compaction-queue.integration.test.mjs plays both bugs
against a real AgentSession and fails on the previous commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): Stop puts prompts parked behind a compaction back in the composer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): parked prompts survive a late refusal and Recall during the flush
- The SDK's refusal reaches the wrapper's handler a microtask later, so
compaction_end could flush before the prompt was parked: it stayed a
queue row and the session read running for good. The handler now
flushes itself when the compaction is already over.
- flushParkedPrompts() emptied the queue at once while each delivery
waited for admission: during the first one's preflight, Recall returned
nothing and Stop could not take the rest back, which were sent anyway.
An entry now stays listed until its delivery holds admission; Recall
and Stop take it, and the delivery skips an entry that is gone.
- A plain parked prompt is a steer, as the TUI parks Enter during
compaction: as a followUp it was listed (and recalled) after the steers
sent after it, so "A" then "B" came back as "B", "A". Delivery stays FIFO.
- Recall and Stop return the parked prompts' images beside their texts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): restore recalled images, and /compact instructions on failure
Recall and Stop put the images of prompts parked behind a compaction back
in the composer with their texts (restoreSubmission, as a refused prompt
had them before). A /compact <instructions> whose compaction fails gives
the command back to the composer, where the awaited command left it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: qiyu <linweiguang@shangyoo.com>
Co-authored-by: Alex Yang <agegcn@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
* feat(chat): queue prompts sent while compaction runs
pi's SDK rejects prompts during compaction ("Cannot submit a prompt while
compaction is in progress"), so every submission bounced back to the
composer with an error and the input read as dead. Park the submissions in
the wrapper and flush them FIFO at compaction end, as pi's TUI's
compactionQueuedMessages does. This is the compaction-queueing part of
agegr#812, the focused follow-up its closing comment asked for.
- Parking happens on the SDK's rejection, never before inner.prompt(), so
an extension command typed during compaction still runs: the SDK
executes commands before it refuses.
- A parked prompt keeps its admission's pendingPromptCount outstanding
until delivery or recall, so isRunning(), the idle shutdown and the
reload/clone refusals all see it.
- The flush is the TUI's flushCompactionQueue() in the wrapper: every
delivery carries a streamingBehavior (a plain parked prompt as followUp),
so AgentSession.prompt() queues it into a run still finishing the
compaction or starts one when idle, never "Agent is already processing".
A delivery that started the run emits its prompt_done, one that queued
into another run rides that run's, and a failed delivery goes back to the
queue with prompt_error and waits for Recall or the next compaction end.
- get_state.queuedMessages and every queue_update merge pi's queue with the
parked ones; clear_queue returns both, and Recall puts the text back in
the composer.
- The composer stays editable while compacting: the placeholder says
messages queue, and the status line shows "Compacting... - N queued",
for a manual compaction too (agentRunning alone left it unlabeled).
Tests: lib/rpc-manager-compaction-queue.test.mjs (park, FIFO flush,
recall, merge, failed flush, images), the queued-count case in
chat-phase-label, the editable-composer case in ChatInput. tsc, eslint and
the touched areas' 246 tests pass; the 66 suite failures on this Windows
machine are identical with and without the change.
* fix(chat): keep the composer usable during compaction, and queued prompts out of the transcript
Two bugs from manual testing of the compaction queueing.
1. /compact disabled the composer for the whole compaction. The builtin
slash handler awaited the blocking compact POST, and runBuiltinCommand
holds the composer's <fieldset disabled> until the command resolves: the
input box took no text until the session was switched away and back (a
remount resets builtinCommandPending). The command now completes at once
and runs the compaction detached through handleCompact, the Compact
button's path, which reports itself (Compacting status, Stop compaction,
result banner, error); its result is the silent action: "compact".
handleCompact takes the optional custom instructions and promotes the
session after its reload, as the inline path did.
2. A parked prompt rendered as a sent message. handleSend's optimistic
bubble stayed in the transcript while the message waited in the queue.
A queued submission is now acked { queued: true } (parked, or the SDK's
"queued" disposition) and the client drops the bubble: the queue rows
show it, and the transcript shows it when the flush delivers it.
Tests: hooks/compact-command.test.mjs pins the detached /compact against a
compact POST that never resolves; lib/rpc-manager-compaction-queue.test.mjs
pins the queued ack (and the extension command still answering null).
tsc, eslint and the touched areas' 258 tests pass.
* test: run the suite green on Windows
28 test files fixed, test and fixture code only (plus one fixture server).
No product change. Root causes, by cluster:
- 8.3 temp paths: %TEMP% resolves to C:\Users\LINWEI~1\... while git,
the SDK and $HOME report expanded names. Node's realpathSync keeps short
names (only realpathSync.native expands them), so fixtures compared
unequal paths and ancestor walks reached the real ~/.agents/skills from
the scratch dir. Fixture roots now canonicalize with realpathSync.native.
- CRLF checkouts: source-reading tests sliced on ";\n" and regexes ended
at \n before \r, so they extracted nothing. Repo convention
.replace(/\r\n/g, "\n") applied at the read sites.
- chmod on Windows: 0o500/0o400 do not make directories unwritable and
stat reports 0o666 regardless. Unwritable tests now lock the file too
(same refusal path, different syscall); mode assertions keep POSIX.
- ESM absolute paths: hooks fixtures imported a raw G:\... path, which
Node's ESM loader rejects (protocol 'g:'), and drive-letter-case drift
would load a second shim instance. They now take the shim through
jiti.import("react"), the alias route the hooks resolve react by.
- ConPTY: node-pty reports pid 0 until its worker connects and arms a 5s
watchdog; tests now wait for the connection before asserting or ticking
mock timers.
- EBUSY teardown: fixture MCP servers held cwd open while rm ran (Windows
refuses); shutdown is awaited first and removal retries. A fixture's
!touch marker wrote into the repo root (unquoted backslashes in bash -c);
markers are quoted with forward slashes. Grandchild processes of the
MCP fixture now exit with their parent.
- PATH assertions joined with the host delimiter for a case that tests
another platform; PTY and skills-walk tests reached the developer's real
home on Windows (temp under the profile): hermetic .git marker added.
npm test now passes end to end here (2880 tests, 2859 pass, 21 skipped,
0 fail) and exits without --test-force-exit; it used to hang on leaked
fixture processes and fail 66.
* Revert "test: run the suite green on Windows"
This reverts commit 63924a8. The Windows test fixes are unrelated to
compaction queueing, and most of them (14 of 29 files) overlap the open
Windows test PRs agegr#1364-agegr#1368. They belong in a PR of their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): flush parked prompts in order and keep them on Stop
- The flush called inner.prompt() for every parked prompt at once, so an
`input` handler that took longer on the first one let the second start
the run: [slow, fast] went out as [fast, slow]. Each delivery now goes
through the prompt admission chain, one submission at a time, so a
prompt sent after compaction_end also queues behind them.
- Stop (`abort`) ends the compaction, and its compaction_end sent the
parked prompts: Stop started a run, under forceShutdownOnIdle. Stop now
recalls them first and returns their texts for the composer, as the
TUI's abort restores queued messages to the editor. Stop compaction
still flushes them, as Esc during compaction does in the TUI.
- A delivery that failed after it was accepted was parked again and
would have been sent twice; a refused one kept its admission count, so
the session stayed running until Recall. Now only a refused delivery
goes back to the queue, with its admission settled; settle() is the
admission's idempotent finishPrompt, so Recall never settles twice.
- Recall and Stop send prompt_done for a recalled plain prompt (its client
waits for one); the delivery that started the run sends it whatever its
streamingBehavior.
- Park only on the SDK's refusal before preflight: `inner.isCompacting`
alone parked unrelated errors during auto-compaction. `queued: true` is
the parked ack only, and auto_compaction_end (no pi 1.4 event) is gone.
lib/rpc-manager-compaction-queue.integration.test.mjs plays both bugs
against a real AgentSession and fails on the previous commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): Stop puts prompts parked behind a compaction back in the composer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): parked prompts survive a late refusal and Recall during the flush
- The SDK's refusal reaches the wrapper's handler a microtask later, so
compaction_end could flush before the prompt was parked: it stayed a
queue row and the session read running for good. The handler now
flushes itself when the compaction is already over.
- flushParkedPrompts() emptied the queue at once while each delivery
waited for admission: during the first one's preflight, Recall returned
nothing and Stop could not take the rest back, which were sent anyway.
An entry now stays listed until its delivery holds admission; Recall
and Stop take it, and the delivery skips an entry that is gone.
- A plain parked prompt is a steer, as the TUI parks Enter during
compaction: as a followUp it was listed (and recalled) after the steers
sent after it, so "A" then "B" came back as "B", "A". Delivery stays FIFO.
- Recall and Stop return the parked prompts' images beside their texts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(chat): restore recalled images, and /compact instructions on failure
Recall and Stop put the images of prompts parked behind a compaction back
in the composer with their texts (restoreSubmission, as a refused prompt
had them before). A /compact <instructions> whose compaction fails gives
the command back to the composer, where the awaited command left it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: qiyu <linweiguang@shangyoo.com>
Co-authored-by: Alex Yang <agegcn@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pi's SDK refuses prompts while compaction runs ("Cannot submit a prompt while
compaction is in progress"), so nothing typed into a compacting session could reach
the agent. The wrapper now parks those submissions and flushes them when the
compaction ends, as pi's TUI's
compactionQueuedMessagesdoes. This is thecompaction-queueing part of #812, the focused follow-up its closing comment asked for.
Shipped alongside, a pre-existing composer bug this feature cannot ship without: the
/compactbuiltin awaited its blocking compact POST whilerunBuiltinCommandholdsthe composer's
<fieldset disabled>, so the input box took no text for the wholecompaction and came back only after a remount.
inner.prompt(), so an extensioncommand typed during compaction still runs (the SDK executes commands before it refuses).
pendingPromptCountoutstanding until delivery orrecall, so
isRunning(), the idle shutdown and thereload/clonerefusals see it.streamingBehavior, soAgentSession.prompt()queues into arun still finishing the compaction or starts one when idle. It never hits
"Agent is already processing".
get_state.queuedMessagesand everyqueue_updatemerge pi's queue with the parkedones;
clear_queuereturns both, and Recall puts the text back in the composer.reads "Compacting… · N queued" for a manual compaction too, where
agentRunningaloneleft it unlabeled.
Evidence
Before: a prompt sent during compaction bounced with "Cannot submit a prompt while
compaction is in progress." and the text returned to the composer; with
/compactthecomposer was dead for the compaction's duration. Neither queued-message path worked.
After: the message is accepted, appears in the queued-messages panel, and is
delivered FIFO when the compaction ends.
New tests:
Plus the queued-count case in
lib/chat-phase-label.test.mjsand aneditable-while-compacting case in
components/ChatInput.test.mjs.Checks:
tsc --noEmitclean,npm run lintclean,npm testgreen end to end(2880 tests, 2859 pass, 21 skipped, 0 fail).
The branch also carries one separable commit,
test: run the suite green on Windows(28 test files, test and fixture code only): 8.3 temp-path canonicalization, CRLF
normalization at source reads, chmod semantics, ESM absolute-path imports in the hooks
fixtures, ConPTY pid timing, and EBUSY teardown of fixture MCP servers.
npm testused to fail 66 here and hang without
--test-force-exit; it now exits clean. Happy tosplit it into its own PR if you prefer.
Merge Danger
Door: Two-way. A revert restores today's behavior on both paths, and there is no
schema, session-file or extension-API surface change.
Blast Radius: Prompt dispatch while a compaction runs, and the
/compactbuiltincommand. Idle sessions, runs, steer/follow-up queueing outside compaction and other
slash commands are untouched.
the flush drops it. The queue panel and Recall are the user's recourse while it is
parked, and
isRunning()keeps the wrapper alive meanwhile.Recall, and reports
prompt_erroreither way.isPromptRunningreads true while a prompt is parked. Intended ("a prompt is pending"),but it is a new state the status polling can observe.
/compactno longer answers "Command completed"; the compaction's own status line,result banner and error banner report it. Anyone keying on that toast will notice.