Skip to content

feat(agent-gui): 上下文用量环与手动上下文压缩 - #358

Open
ushaio wants to merge 1 commit into
Stack-Cairn:mainfrom
ushaio:feat/context-usage-ring
Open

feat(agent-gui): 上下文用量环与手动上下文压缩#358
ushaio wants to merge 1 commit into
Stack-Cairn:mainfrom
ushaio:feat/context-usage-ring

Conversation

@ushaio

@ushaio ushaio commented Aug 2, 2026

Copy link
Copy Markdown

Linked issue

Closes #359

Summary

为输入框新增上下文用量环(GUI 与 WebUI),并支持手动上下文压缩:

  • 用量环根据最近一条 assistant 回合的 usage 相对模型上下文窗口计算占用百分比,>70% 变黄、>90% 变红;
  • 点击用量环(占用 > 50% 时可用)在其上方弹出"手动压缩上下文?"确认框;
  • 确认后通过新增的 CompactionController.compactNow()manual 触发、强制模式)复用现有压缩流程,空闲时即可手动压缩;
  • 压缩完成后会话摘要为检查点,释放上下文空间。

Change scope

  • 模块:agent-gui(桌面 GUI)、agent-gateway/web(WebUI 仅展示用量环)
  • 关键路径:
    • crates/agent-gui/src/lib/chat/compaction/controller.ts / types.ts
    • crates/agent-gui/src/pages/chat/components/ChatComposerBar.tsx
    • crates/agent-gui/src/pages/ChatPage.tsx
    • crates/agent-gui/src/components/ui/confirm-action-popover.tsx
    • crates/agent-gui/src/i18n/config.ts
    • crates/agent-gateway/web/src/app/GatewayApp.tsx / pages/chat/ChatComposerBar.tsx

Screenshots / preview

待补充(UI 改动,截图稍后追加)。

Verification

  • pnpm build(agent-gui,tsc + vite build):通过
  • cargo check --manifest-path crates/agent-gui/src-tauri/Cargo.toml --tests:通过
  • tsc --noEmit:通过
  • biome:无新增诊断,LF 格式与 biome 完全一致
  • node scripts/check-mirror.mjs:通过(119 个镜像文件)
  • git diff --check:通过
  • dev 模式 HMR 无编译错误

Pre-submit checklist

  • 已关联 issue [Feature] 会话支持显示上下文占比 #359
  • 与目标分支同步、无冲突
  • 截图待补充(补充后勾选)
  • 改动聚焦,无无关修改
  • 无密钥/令牌/个人数据
  • 行为/配置相关文档已更新(新增 i18n 文案)

- Show a context usage ring in the composer based on the latest assistant
  round usage relative to the model context window (GUI + WebUI)
- Clicking the ring (usage > 50%) opens a confirm popover to manually
  compact the current conversation
- CompactionController gains compactNow() with a force mode and a
  "manual" trigger, reusing the existing compaction flow while idle
- ConfirmActionPopover description is now optional
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR governance checks failed.

  • UI change without screenshots: this PR modifies frontend code. Please add before/after screenshots or a recording under "Screenshots / preview" in the PR body.

Fix the items above — pushing new commits or editing the PR body will re-run the checks.

@ushaio ushaio changed the title feat(agent-gui): context usage ring with manual compaction feat(agent-gui): 上下文用量环与手动上下文压缩 Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 会话支持显示上下文占比

1 participant