fix(agent): 修正上下文整理会话完成态【已审核 PR】 - #1738
Merged
ErlichLiu merged 2 commits intoAug 19, 2026
Merged
Conversation
ErlichLiu
force-pushed
the
fix/context-compaction-completion-status-202608181520
branch
from
August 19, 2026 08:49
855b186 to
a44b646
Compare
仅当主 Agent 已成功结束且无需自动续跑时,才将上下文整理阶段显示为 completed;运行中压缩、CompactContext 续跑和异常结束保持 running。 Made-with: Proma
Remove the PR-specific test file and test cases as requested. Made-with: Proma
ErlichLiu
force-pushed
the
fix/context-compaction-completion-status-202608181520
branch
from
August 19, 2026 08:50
a44b646 to
bcef7b3
Compare
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.
概述
修复 Agent 会话在主任务已经正常结束、仅进行上下文整理时的左侧状态显示。此前所有仍处于流状态的压缩阶段都会被统一标记为 running,导致用户无法区分“任务仍在执行”和“任务已完成、只是在整理上下文”。本 PR 只将无需自动续跑的成功主任务压缩标记为 completed;运行中压缩、CompactContext 触发的自动续跑以及异常结束仍保持 running。
改动
apps/electron/src/main/lib/adapters/pi-agent-adapter.ts— 根据成功agent_end、是否需要原任务续跑,给后续compaction_start传递afterCompletedTurn标记。apps/electron/src/main/lib/adapters/pi-agent-adapter.test.ts— 覆盖正常完成、CompactContext 续跑和异常结束三种判定路径。packages/shared/src/types/agent.ts— 扩展压缩事件和 SDK system message 的显式类型契约。apps/electron/src/renderer/hooks/useGlobalAgentListeners.ts— 将跨进程压缩标记转换为 renderer AgentEvent。apps/electron/src/renderer/atoms/agent-atoms.ts— 仅对带完成标记的压缩显示 completed/绿色状态。apps/electron/src/renderer/atoms/agent-atoms.test.ts— 覆盖任务执行中压缩保持 running、任务成功结束后压缩显示 completed。apps/electron/package.json、packages/shared/package.json— 递增受影响包版本。测试方法
bun test apps/electron/src/main/lib/adapters/pi-agent-adapter.test.ts apps/electron/src/renderer/atoms/agent-atoms.test.tsbun run typecheckbun run --filter='@proma/electron' build:maingit diff --check以上验证均已在基于 upstream 最新
main(3d69bd9)的快照上通过,聚焦测试结果为 26/26。备注
CompactContext续跑不会被标记为完成,避免出现任务尚未结束却显示绿色的情况。Made with Proma · GitHub