3.9 KiB
3.9 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec | |
|---|---|---|---|---|---|---|---|
| 02-context-hover-ui | Show compactions in context hover | done | 2 |
|
plan.md | ../../specs/context-compaction-count/spec.md |
Task 02: Show compactions in context hover
Intent
Carry the persisted count through live and hydrated frontend state, then show it with an accessible, translated accuracy disclosure in the existing context hover on every viewport.
Acceptance
- Live session patches and page hydration populate
ContextWindowEntry.compactionCount, treating absent, invalid, or negative legacy values as zero. - The existing context hover shows zero and non-zero counts and explains that Kandev infers them from token drops, so missing samples or provider resets can make the value approximate.
- The shared inline help remains accessible by pointer, keyboard, and touch without nesting another tooltip or changing the existing desktop/mobile composition.
TDD sequence
- Add parser, live-handler, hydration-hook, and rendered-hover cases; run them and confirm count expectations fail.
- Add English i18n keys, regenerate the pseudo locale, and implement the smallest state/hook/UI changes.
- Rerun the exact tests, typecheck, and i18n checks; refactor only where needed to keep the component within repository limits.
Files likely touched
apps/web/lib/state/slices/session-runtime/types.tsapps/web/lib/state/slices/session-runtime/context-window.tsapps/web/lib/state/slices/session-runtime/context-window.test.tsapps/web/lib/ws/handlers/agent-session.tsapps/web/lib/ws/handlers/agent-session.test.tsapps/web/hooks/domains/session/use-session-context-window.tsapps/web/hooks/domains/session/use-session-context-window.test.tsapps/web/components/task/chat/token-usage-display.tsxapps/web/components/task/chat/token-usage-display.test.tsxapps/web/src/locales/en/common.jsonapps/web/src/locales/pseudo/common.json
Dependencies
Task 01, which defines the persisted and live metadata field.
Parallelism
sequential — the UI consumes the backend metadata contract and shares its state/parser files with all hover behavior.
Verification
cd apps && pnpm install --frozen-lockfilecd apps && pnpm --filter @kandev/web test -- --run lib/state/slices/session-runtime/context-window.test.ts lib/ws/handlers/agent-session.test.ts hooks/domains/session/use-session-context-window.test.ts components/task/chat/token-usage-display.test.tsxcd apps/web && pnpm run typecheckcd apps && pnpm --filter @kandev/web run i18n:check
Inputs
- Spec
What,API surface, and the final scenario. - Frontend state flow and i18n rules in
apps/web/AGENTS.md. - Mobile content-only guidance in
.agents/skills/mobile-parity/SKILL.md. - Existing source disclosure and pinnable parent hover in
apps/web/components/task/chat/token-usage-display.tsx.
Output contract
Report the result, actual files changed, exact tests and counts, translated keys, rendered-check status, blockers, risks, and synchronized task/plan status in this conversation.
Results
- RED: the rendered-hover case failed before the count row existed; parser/live-handler tests also established the missing-field baseline.
- GREEN:
cd apps && pnpm --filter @kandev/web test -- --run lib/state/slices/session-runtime/context-window.test.ts lib/ws/handlers/agent-session.test.ts hooks/domains/session/use-session-context-window.test.ts components/task/chat/token-usage-display.test.tsx— 4 files passed, 68 tests passed. cd apps/web && pnpm run typecheck— passed.cd apps && pnpm --filter @kandev/web run i18n:check— passed; English and pseudo locale contain the three new keys.cd apps && pnpm --filter @kandev/web run i18n:ratchet— passed.- Public docs impact: updated
docs/public/sessions-and-review.mdwith the inferred-count limitation; public-doc validation passed.