feat(widget): label tok/ctx% as substrate vs work (#32 tail) - #56
Merged
Conversation
The fleet widget's tok/ctx% segment is a context-occupancy metric dominated by the armory substrate (~59% from turn 1, barely moving across turns). On substrate-dominated runs it reads as "frozen / same every session," indistinguishable from a stuck run. Capture a substrateBaseline = contextTokens at the end of turn 1 (the first assistant message_end) on RunRecord, then classify the segment once past turn 1: "substrate" when growth is ≤5% of the baseline (flat overhead), "work" when tool results are growing the context. Before turn 2 (or when no baseline was captured) no label is shown — there's nothing to compare against yet. - src/engine/run-registry.ts: RunRecord.substrateBaseline (live-only) - src/engine/spawnSubagent.ts: capture once at turn-1 message_end - src/panel/widget-rows.ts: SUBSTRATE_GROWTH_THRESHOLD + label in widgetLine - tests: 6 widget cases (substrate/work/threshold/turn-1/no-baseline/bg) + 2 spawn cases (baseline captured / not captured)
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.
What
The fleet widget's
tok/ctx%segment is a context-occupancy metric dominated by the armory substrate (~59% from turn 1, barely moving across turns — see #32). On substrate-dominated runs it reads as "frozen / same every session," indistinguishable from a stuck run.This adds a substrate vs work label to the widget's foreground run line: capture a
substrateBaseline=contextTokensat the end of turn 1 (first assistantmessage_end), then once past turn 1 label the segmentsubstratewhen growth is ≤5% of the baseline (flat overhead) orworkwhen tool results are growing the context.Before turn 2 (or when no baseline was captured — e.g. turn 1 produced no assistant message) no label is shown: there's nothing to compare against yet.
Scope (intentional)
src/panel/widget-rows.ts) — enhancement: armory substrate consumes ~59% of subagent context window before work begins #32's pain is the live glance surface ("is it frozen or working?"). The Runs-tab (runs-rows.ts) is the navigable detail surface and is intentionally left unchanged; symmetric labeling there is a possible follow-up, not a blocker.substrateBaseline(noturnCount, different lifecycle) and never get the label.substrateBaselineis a transient display heuristic, not journaled to the RunLog (same as feat: surface liveness progress for long foreground subagent runs #23'sturnCount/lastEventClass).Changes
src/engine/run-registry.ts—RunRecord.substrateBaseline?: number(live-only, documented).src/engine/spawnSubagent.ts— capture once at the turn-1 first assistantmessage_end(turnIdx === 0); threaded into therunRegistry.updatepatch.src/panel/widget-rows.ts—SUBSTRATE_GROWTH_THRESHOLD = 0.05+substrateBaselineonWidgetRun/toWidgetRun+ the label inwidgetLine(afterctx%, beforecost).Verification
pnpm typecheckclean.pnpm test:run→ 677/677 pass (669 existing + 8 new).Closes part of #32 (direction 4 — widget UX). The other two #32 directions (memory-scope trim, prompt compaction) need a substrate measurement and ship as separate PRs.