Skip to content

fix: keep widget live icon steady while AI is running - #340

Merged
attson merged 1 commit into
mainfrom
fix/widget-live-icon-flicker
Aug 14, 2026
Merged

fix: keep widget live icon steady while AI is running#340
attson merged 1 commit into
mainfrom
fix/widget-live-icon-flicker

Conversation

@attson

@attson attson commented Aug 14, 2026

Copy link
Copy Markdown
Owner

问题

挂件(desk widget)里的时间状态图标在 AI 持续工作时会反复在 livenow 之间抖动。

根因:formatLastOutput 判定 live 的条件是「running 且距上次输出 ≤ 5 秒」。AI 的输出是间歇成块的——每次静默超过 5 秒图标就掉回 now,下一块输出又跳回 live。会话状态一直是 running,但图标在持续工作期间来回翻转。

修复

live 改为纯由 task state 驱动:后端仍报 running 的会话即为 live,与「距上次输出多久」解耦。非 running 会话保留相对时间标签(now/Nm/Nh/Nd),且永不显示 live。

  • 删除 LAST_OUTPUT_LIVE_WINDOW_MS(5s 窗口常量),无残留引用。
  • 缺失/无效时间戳仍返回 null(不渲染图标),行为不变。

取舍

纯 running 即 live 意味着 AI 卡死 / 等网络 / 被限流时(状态仍 running)图标也会一直亮 live。这是「绝不抖动」换来的代价;若日后「假活跃」碍事,可增量加一个较长静默阈值降级,不影响本版。

验证

  • vue-tsc --noEmit:0 错误
  • lastOutput.test.ts + 全部 components 测试:642 passed

🤖 Generated with Claude Code

The last-output indicator promoted a session to "live" only within a 5s
window of its last output chunk, then fell back to "now". An AI session
emits output in bursts with quiet gaps between them, so the icon flipped
live→now→live every time the model paused — visible churn while the
session was continuously working.

Drive "live" purely off task state: a session the backend still reports
as `running` is live regardless of the gap since its last byte. Non-running
sessions keep the relative-time labels (now/Nm/Nh/Nd) and never show live.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@attson
attson merged commit ef821bd into main Aug 14, 2026
7 checks passed
@attson
attson deleted the fix/widget-live-icon-flicker branch August 14, 2026 08:37
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.

1 participant