Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Feature] 显示当前会话的上下文窗口占用

Open
#828 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
tauri, typescript
Domain
ai, desktop, frontend

Research direction

Start with the usage_update branch in windows/tauri/src/features/ai/services/acp-stream-handler.ts and the AcpUsageUpdate definition in windows/tauri/src/features/ai/types/acp.types.ts. Then read ai-chat-state.ts and chat-header.tsx to follow the existing session state and PaneChip patterns. Done means the current session shows used/size context usage, warns at the chosen threshold, and clears the value when the session ends or changes.

Written by the indexing model from the issue text.

Description

enhancement review: medium

要解决的问题

使用 AI 会话时,无法知道当前上下文窗口已经用了多少、还剩多少。只能在 agent 自己提示「上下文将满」时才发现,此时往往已经触发压缩或截断,之前的对话内容可能已经丢失。

Lithe 其实已经能拿到这个数据,只是把它丢弃了 —— windows/tauri/src/features/ai/services/acp-stream-handler.ts:382-383:

case "usage_update":
  break;

事件载荷 AcpUsageUpdate { used: number; size: number }(windows/tauri/src/features/ai/types/acp.types.ts:132-135)从未进入状态。

建议方案

1. 消费事件
在 acp-stream-handler.ts 的 usage_update 分支中消费事件,把 used / size 写入 AI 状态。

2. 状态放置
建议放在 windows/tauri/src/features/ai/stores/ai-chat/ai-chat-state.ts 中与 acpStatus、sessionModeState 并列。这两个字段已经是「当前活动 agent 会话的运行时状态」,上下文占用属于同一类,跟随现有模式即可。

3. 展示位置:agent 面板的头部
windows/tauri/src/features/ai/components/chat/chat-header.tsx

选择面板头部而不是全局状态栏的理由:

  • AI 会话本身是一个 pane,带自己的 sessionId(windows/tauri/src/features/panes/types/pane-content.types.ts:93-96 的 AgentContent { type: "agent"; sessionId: string }),并且可以多开。放在 pane 头部能天然跟随对应会话,不会串到别的会话。
  • 全局 footer 是单例,当前承载文件编码、内存占用、Git 分支、调试器状态。多开 agent 面板时,footer 无法表达「这是哪个会话的占用」,会引入歧义。
  • chat-header.tsx 已经在用 PaneChip / paneHeaderClassName(features/panes/components/pane-chrome),加一个 chip 就能融入现有模式,基本不需要新的 UI 结构。

4. 展示形式
紧凑的百分比 chip;悬浮或展开时显示 used / size 的实际数值。占用超过阈值(例如 80%)时变色提示,让用户在触发压缩前主动收敛话题或开新会话。

5. 生命周期
会话结束或切换时清理该状态,避免残留到另一个会话。

目标平台

Windows

模块

AI

优先级

P1 / 尽快处理:使用体验大幅下降,但通常仍可继续使用

已考虑的替代方案

  • 依赖 agent 自己输出的提示文本:无法量化剩余空间,且提示出现时往往已经太晚。
  • 放在全局状态栏 footer:多开 agent 面板时无法区分是哪个会话,见上文理由。

补充信息

  • 被丢弃的位置:windows/tauri/src/features/ai/services/acp-stream-handler.ts:382-383
  • 事件类型定义:windows/tauri/src/features/ai/types/acp.types.ts:132-135、:253-257
  • 同位置的 session_info_update(:385)同样被 break 丢弃,但会话标题已经由 ui_action.set_chat_title(:465-472)处理,本次不需要一并改动,避免扩大范围。
  • 分层:本改动全部落在 windows/tauri/src/features/ai/,不涉及平台层与 rust/lithe-core/。若后续 macOS 端需要对齐,再考虑把窗口归一化逻辑下沉到 rust/lithe-core/ 并补 shared/contracts/ fixture。
  • 该事件仅提供上下文占用,不包含历史 Token 汇总与费用统计,后者如需做应另开 issue。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
7h 51m
Merged PRs (30d)
351

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.