Skip to content

Fix Herdr Sidebar session linkage and context trends - #590

Merged
lis186 merged 4 commits into
mainfrom
worktree-herdr-sidebar-ux
Aug 28, 2026
Merged

Fix Herdr Sidebar session linkage and context trends#590
lis186 merged 4 commits into
mainfrom
worktree-herdr-sidebar-ux

Conversation

@lis186

@lis186 lis186 commented Aug 26, 2026

Copy link
Copy Markdown
Owner

繁中簡述

這個 PR 修正並完善 Herdr Sidebar 的 session observability:恢復 native session linkage、保留啟動時的 agent status,並讓 context% 趨勢在 session 歷史超出 index tail 或只剩 contextless subagent row 時仍能正確顯示。

目前 Sidebar 會:

  • 對 native session 使用精確、受限的 targeted repair,而不是把整個 index 掃進熱路徑
  • 從 targeted import 保存最多 64 筆 display-oriented context samples
  • 沿用 aggregate 的 beta1m 作為 context denominator provenance
  • 只有在至少 3 筆有效樣本且變化達 8 個百分點時顯示
  • 維持固定、右對齊的 context trend viewport,避免百分比因寬度變化消失

Problem

The Sidebar intentionally reads only the last 4 MiB of index.ndjson. That bounded read can contain a matching contextless subagent row while the main conversation's context samples are older in the same session:

Full index
  [older main context samples] .............. [contextless subagent row]
       outside the 4 MiB tail                         inside the tail
                                                        |
                                                        v
                                               old behavior: matched, but `?`

The session was technically linked, so the old repair guard did not run. Separately, coarse context buckets could make a materially changing context percentage look flat, and imported rows did not always retain the authoritative 1M-window fact.

What changed

Session identity and status

  • Use exact native session evidence for Sidebar linkage, with fail-closed handling for ambiguous ownership.
  • Preserve native working/idle state during startup refresh.
  • Keep the bounded working refresh loop alive while a pane is natively working.

Context history recovery

bounded Sidebar refresh
          |
          | matching row has incomplete context history
          v
detached targeted import
          |
          +--> exact linkage evidence
          +--> <= 64 display-oriented context samples
          v
fixed Sidebar trend + current context%
  • Detect both a contextless matched tail and an aggregate whose known history exceeds the visible tail.
  • Persist the bounded sample ring with the existing repair state.
  • Migrate old completed repair state once so it can acquire samples without repeated imports.
  • Keep request/response bodies out of the Sidebar repair cache.

Rendering and provenance

  • Sort samples by received time before calculating the trend.
  • Treat unknown context usage as unknown rather than zero; explicit zero remains valid only when marked as known.
  • Use aggregate beta1m when available, so a 1M context window is not downgraded to the 200K fallback.
  • Add guarded / direction cues while keeping the newest sample right-anchored.
  • Keep cache and context labels distinguishable in narrow Sidebar rows.

Verification

  • Herdr plugin suite: 249/249 passed
  • Importer and targeted-import suites: 52/52 passed
  • Full suite with an isolated CCXRAY_HOME and export disabled: 2395/2395 passed
  • git diff --check: passed
  • JavaScript syntax checks for all touched runtime modules: passed
  • Manual Herdr Sidebar verification rendered a directional context indicator (49%↓)

Scope and limits

  • The normal Sidebar refresh remains bounded; the complete index walk happens only in the detached, targeted repair worker.
  • Direction cues are intentionally conservative: fewer than 3 known samples or a move smaller than 8 percentage points produces no arrow.
  • The repair cache stores at most 64 samples per targeted session and is used only for Sidebar display recovery.

Justin Lee added 4 commits August 26, 2026 12:51
Signed-off-by: Justin Lee <justinlee@91app.com>
Signed-off-by: Justin Lee <justinlee@91app.com>
Signed-off-by: Justin Lee <justinlee@91app.com>
@lis186 lis186 changed the title Add Herdr Sidebar observability rail and repair session linkage Fix Herdr Sidebar session linkage and context trends Aug 28, 2026
@lis186
lis186 merged commit 24bbc11 into main Aug 28, 2026
3 checks passed
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