Repository navigation
fix(chat): report compaction instead of "waiting for model" during auto-compaction - #1008
Merged
Merged
Conversation
…to-compaction
Auto-compaction can hold a turn for a while before the next token arrives.
While it runs, the chat UI reported "Waiting for model..." and offered only a
generic Stop button, which reads as a hang and gives the user the wrong control.
## What was wrong
`agentPhase` is set once when the prompt is sent (handleSend sets
`waiting_model`) and nobody updated it when compaction began. `phaseLabel()`
only looked at the phase, so it kept reporting the stale `waiting_model`.
The compaction control was worse. It is guarded by:
{!isStreaming && onCompact && ( ... )}
Manual compaction starts from an idle session, so the button is already
rendered and simply flips to "Stop compaction" when `isCompacting` turns true.
Auto-compaction starts *mid-turn*, where `sessionBusy` is already true, so the
button never rendered at all and only the generic Stop remained. That guard
also contradicted the button's own `disabled={isStreaming && !isCompacting}`,
which only makes sense if the button is meant to be reachable while streaming.
Manual compaction therefore looked correct and auto-compaction did not, which
is why this went unnoticed.
## What changed
`phaseLabel()` takes `isCompacting` and returns the compaction label ahead of
the phase, so the status names the activity that is actually blocking the turn.
The render condition accepts a missing phase while compacting.
The compaction control guard becomes `(!isStreaming || isCompacting)`, so the
control is reachable mid-turn. Both actions stay available: "Stop compaction"
sends `abort_compaction` and skips the compaction so the turn continues, while
Stop sends `abort` and drops the whole turn. The now-unreachable
"streaming but not compacting" branches (disabled, dimmed opacity, not-allowed
cursor, the hover early-return) are removed rather than left as dead code.
`phaseLabel()` moved to lib/chat-phase-label.ts so it can be unit tested;
importing ChatWindow.tsx in a test pulls in next/image and the whole component
tree, so it cannot be loaded in node.
## Result
| | before | after |
|---|---|---|
| auto-compaction status | Waiting for model... | Compacting… |
| auto-compaction control | Stop | Stop compaction (+ Stop) |
| idle / manual | unchanged | unchanged |
## Verification
- tsc: 0 errors from this change (the 2 remaining are pre-existing SDK drift)
- lint: clean
- tests: 1308 pass / 4 fail — the same 4 fail on upstream main
- 5 new tests: phase label per phase, compaction precedence, and the control
guard reaching mid-turn
The demo resolves @/lib against demo/lib, which has no chat-phase-label module, so importing it there breaks the Pages build. The demo keeps its own copies and is synced separately (demo/README.md). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ
This was referenced Sep 30, 2026
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…#907 agegr#941 agegr#946 agegr#961 agegr#968 agegr#969 agegr#1007 agegr#1008 agegr#1009 agegr#1010) 上游已把我们提前摘取的 agegr#884 / agegr#871 / agegr#996 / agegr#961 原样合并(agegr#961 逐字节相同), agegr#967 与 agegr#963 由上游的 agegr#1009 / agegr#1008 接管。 冲突解决: - demo/ 对齐上游 fe288c0,撤销 agegr#963 对 demo 的两处改动(`@/lib/chat-phase-label` 在 demo/lib 下不存在,会打断 Pages 构建)。 - AGENTS.md:保留我们的 default-project 条目,open-folder 换成上游的 open-in-explorer。 - MessageView.tsx / SessionSidebar.tsx / FileExplorer.tsx:以上游为准, DismissButton 采用上游的独立文件,保留我们的思考卡片与文件管理改动。 - SessionSidebar 移除引用已删函数的旧 agegr#951 工作区按钮(agegr#951 的其他入口另行收尾)。
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
agegr#967 / agegr#963 已由上游的 agegr#1009 / agegr#1008 落地,agegr#961 上游原样合并(逐字节相同), agegr#951 已收敛到上游的 agegr#907,agegr#960 上下游都拒绝——这些都与上游一致,按台账规则删行。 agegr#899 上游关闭但本地保留,状态注明为永久分叉。
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…to-compaction (agegr#1008) * fix(chat): report compaction instead of "waiting for model" during auto-compaction Auto-compaction can hold a turn for a while before the next token arrives. While it runs, the chat UI reported "Waiting for model..." and offered only a generic Stop button, which reads as a hang and gives the user the wrong control. ## What was wrong `agentPhase` is set once when the prompt is sent (handleSend sets `waiting_model`) and nobody updated it when compaction began. `phaseLabel()` only looked at the phase, so it kept reporting the stale `waiting_model`. The compaction control was worse. It is guarded by: {!isStreaming && onCompact && ( ... )} Manual compaction starts from an idle session, so the button is already rendered and simply flips to "Stop compaction" when `isCompacting` turns true. Auto-compaction starts *mid-turn*, where `sessionBusy` is already true, so the button never rendered at all and only the generic Stop remained. That guard also contradicted the button's own `disabled={isStreaming && !isCompacting}`, which only makes sense if the button is meant to be reachable while streaming. Manual compaction therefore looked correct and auto-compaction did not, which is why this went unnoticed. ## What changed `phaseLabel()` takes `isCompacting` and returns the compaction label ahead of the phase, so the status names the activity that is actually blocking the turn. The render condition accepts a missing phase while compacting. The compaction control guard becomes `(!isStreaming || isCompacting)`, so the control is reachable mid-turn. Both actions stay available: "Stop compaction" sends `abort_compaction` and skips the compaction so the turn continues, while Stop sends `abort` and drops the whole turn. The now-unreachable "streaming but not compacting" branches (disabled, dimmed opacity, not-allowed cursor, the hover early-return) are removed rather than left as dead code. `phaseLabel()` moved to lib/chat-phase-label.ts so it can be unit tested; importing ChatWindow.tsx in a test pulls in next/image and the whole component tree, so it cannot be loaded in node. ## Result | | before | after | |---|---|---| | auto-compaction status | Waiting for model... | Compacting… | | auto-compaction control | Stop | Stop compaction (+ Stop) | | idle / manual | unchanged | unchanged | ## Verification - tsc: 0 errors from this change (the 2 remaining are pre-existing SDK drift) - lint: clean - tests: 1308 pass / 4 fail — the same 4 fail on upstream main - 5 new tests: phase label per phase, compaction precedence, and the control guard reaching mid-turn * fix(demo): leave the demo copies of ChatInput/ChatWindow untouched The demo resolves @/lib against demo/lib, which has no chat-phase-label module, so importing it there breaks the Pages build. The demo keeps its own copies and is synced separately (demo/README.md). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ --------- Co-authored-by: jokin <[email protected]> Co-authored-by: Claude <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…to-compaction (agegr#1008) * fix(chat): report compaction instead of "waiting for model" during auto-compaction Auto-compaction can hold a turn for a while before the next token arrives. While it runs, the chat UI reported "Waiting for model..." and offered only a generic Stop button, which reads as a hang and gives the user the wrong control. ## What was wrong `agentPhase` is set once when the prompt is sent (handleSend sets `waiting_model`) and nobody updated it when compaction began. `phaseLabel()` only looked at the phase, so it kept reporting the stale `waiting_model`. The compaction control was worse. It is guarded by: {!isStreaming && onCompact && ( ... )} Manual compaction starts from an idle session, so the button is already rendered and simply flips to "Stop compaction" when `isCompacting` turns true. Auto-compaction starts *mid-turn*, where `sessionBusy` is already true, so the button never rendered at all and only the generic Stop remained. That guard also contradicted the button's own `disabled={isStreaming && !isCompacting}`, which only makes sense if the button is meant to be reachable while streaming. Manual compaction therefore looked correct and auto-compaction did not, which is why this went unnoticed. ## What changed `phaseLabel()` takes `isCompacting` and returns the compaction label ahead of the phase, so the status names the activity that is actually blocking the turn. The render condition accepts a missing phase while compacting. The compaction control guard becomes `(!isStreaming || isCompacting)`, so the control is reachable mid-turn. Both actions stay available: "Stop compaction" sends `abort_compaction` and skips the compaction so the turn continues, while Stop sends `abort` and drops the whole turn. The now-unreachable "streaming but not compacting" branches (disabled, dimmed opacity, not-allowed cursor, the hover early-return) are removed rather than left as dead code. `phaseLabel()` moved to lib/chat-phase-label.ts so it can be unit tested; importing ChatWindow.tsx in a test pulls in next/image and the whole component tree, so it cannot be loaded in node. ## Result | | before | after | |---|---|---| | auto-compaction status | Waiting for model... | Compacting… | | auto-compaction control | Stop | Stop compaction (+ Stop) | | idle / manual | unchanged | unchanged | ## Verification - tsc: 0 errors from this change (the 2 remaining are pre-existing SDK drift) - lint: clean - tests: 1308 pass / 4 fail — the same 4 fail on upstream main - 5 new tests: phase label per phase, compaction precedence, and the control guard reaching mid-turn * fix(demo): leave the demo copies of ChatInput/ChatWindow untouched The demo resolves @/lib against demo/lib, which has no chat-phase-label module, so importing it there breaks the Pages build. The demo keeps its own copies and is synced separately (demo/README.md). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ --------- Co-authored-by: jokin <[email protected]> Co-authored-by: Claude <[email protected]>
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.
Replaces #963 by @jokinas. Their commit is kept as is. This branch adds one review fix on top and merges current
main.What
Auto-compaction starts in the middle of a turn, so two things went wrong while it ran:
phaseLabel()only looked at the stalewaiting_modelphase.!isStreaming, so it never rendered. The user only had the generic Stop, which drops the whole turn.Changes
phaseLabel()moves tolib/chat-phase-label.tsand reports "Compacting…" whileisCompactingis true.!isStreaming || isCompacting, so Stop compaction (abort_compaction, which also aborts auto-compaction in the SDK) is reachable mid-turn.demo/components/ChatInput.tsxanddemo/components/ChatWindow.tsx. The demo resolves@/libagainstdemo/lib, which has nochat-phase-labelmodule, so those edits would break the Pages build onmain. The demo is synced separately (demo/README.md).Verification
tsc --noEmit,eslint, and the full unit suite (1328/1328) pass on this branch.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ
Generated by Claude Code