Skip to content

feat(inspector): coverage inside the request, fix Context hide bugs - #383

Merged
hydall merged 1 commit into
nightlyfrom
claude/prompt-inspector-coverage-context-20d4c3
Sep 3, 2026
Merged

feat(inspector): coverage inside the request, fix Context hide bugs#383
hydall merged 1 commit into
nightlyfrom
claude/prompt-inspector-coverage-context-20d4c3

Conversation

@hydall

@hydall hydall commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Prompt Inspector — coverage moves into the request

  • Drop the Coverage sub-tab and its tab strip from the Requests tab (requests_tab.dart, coverage_sub_tab.dart, past_turn_coverage_view.dart and the per-turn rows in coverage_rows.dart are gone). Reading a turn's coverage no longer means a second list and a second navigation.
  • Add RequestCoverageBlock, a collapsed block at the top of the opened request, carrying the memory selection stored on the turn's message and the lorebook entries from its manifest (turnCoverageProvider). Nothing is recomputed — a re-scan would answer what would fire now, which is the next request's question.
  • The block is the first item in all three views (Messages / Params / JSON): coverage belongs to the request, not to one of its representations. The manifest is read only when the block is expanded; the collapsed summary uses the counts already on the message, so opening a request touches no DB.
  • A request bound to no turn (a background job) keeps the block but renders it non-expandable with requests_coverage_none, instead of inventing coverage for it.
  • Keep the one coverage no captured request owns — the next request's live dry-run — as a row under the preview row in the timeline. The context card's coverage deep link opens straight on it (RequestTimelineView.initialCoverage).
  • RequestTimelineView absorbs the sub-tab shell's top inset and is what PromptInspectorSheet mounts directly.
  • New keys requests_coverage_title / requests_coverage_none in both locales; requests_sub_* and coverage_past_turns / coverage_no_past_turns removed.

Context screen — hide

  • Fix a crash. hideCount was clamped to an empty range (clamp(1, 0)) whenever a chat had one visible message or none, which throws ArgumentError inside build and took the whole Context tab down. The hide tile now renders in the disabled state the code already had but could never reach.
  • Stop over-promising freed tokens. The estimate spread historyTokens over every visible message and multiplied by hideCount, ignoring TokenBreakdown.cutoffIndex — messages the history budget already dropped are not in the prompt, so hiding them frees nothing. It now divides by the in-prompt messages and counts only the ones past the cutoff. The near-limit banner is suppressed when there is nothing to hide (it would otherwise read "hide 0 messages").
  • Invalidate the token-breakdown caches when hidden-ness changes (toggleMessageHidden, hideTopMessages, unhideAllMessages in ChatMessageOpsController), the way the edit path already does. Without it the Context screen served the last generation's breakdown — its own hash cache misses, but the Riverpod copy in cachedTokenBreakdownProvider was returned unchecked — and kept counting messages the user had just hidden.
  • Read the hide percent and history-fill threshold from settings on every build, with the sliders as local overrides. Reading them once in initState froze the defaults when the sheet opened before appSettingsProvider had loaded, and the next save wrote those defaults back over the stored values.
  • Count visible messages with HistoryAssembler's predicate (skip isTyping), so the count matches what the prompt carries, and guard _calculate with a mounted check — its callers await a write first, so the sheet can be gone by then.

Docs

  • docs/ARCHITECTURE.md: the lorebook-coverage and Requests-tab sections now describe the block inside the request and the two next-request rows.

Verification

  • flutter analyze and flutter test were not run: the agent environment has no Flutter SDK, and flutter run is unavailable to it. CI is the gate for both.
  • What was checked by hand instead: no dangling imports or references to the three deleted files; every .tr() key used under lib/ resolves in en.json; EN and RU key sets are identical (the requests_ / coverage_ prefixes are also covered by test/agent_ops_localization_contract_test.dart); the deleted keys had no other call sites.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Szte1QvDC7vC2ZJyHaCtPC


Generated by Claude Code

Prompt Inspector — Requests tab:
- Drop the Coverage sub-tab and its strip. Coverage of a past request is now a
  collapsed block at the top of the opened request (RequestCoverageBlock),
  carrying the turn's memory selection and its stored lorebook manifest, so
  reading it no longer means a second list and a second navigation.
- Keep the one coverage no captured request owns — the next request's live
  dry-run — as a row under the preview row in the timeline. The context card's
  `coverage` deep link opens straight on it.
- RequestTimelineView absorbs the sub-tab shell's top inset and is what the
  inspector mounts directly; requests_tab.dart, coverage_sub_tab.dart and
  past_turn_coverage_view.dart are gone, along with the per-turn coverage rows.

Context screen (tokenizer) — hide:
- Fix the crash: `hideCount` clamped to an empty range (`clamp(1, 0)`) in a
  chat with one visible message, which threw ArgumentError and took the whole
  tab down. The hide tile now renders in its disabled state instead.
- Stop over-promising freed tokens: messages the history budget already cut are
  not in the prompt, so hiding them frees nothing. The estimate now spreads
  `historyTokens` over the in-prompt messages and counts only the ones past the
  cutoff; the near-limit banner is suppressed when there is nothing to hide.
- Invalidate the token-breakdown caches when hidden-ness changes (toggle, hide
  top N, unhide all), the way the edit path already does. Without it the
  Context screen served the last generation's breakdown — its hash cache misses
  but the Riverpod copy was returned unchecked — and counted hidden messages.
- Read the hide percent and history-fill threshold from settings on every
  build, with the sliders as local overrides. Reading them once in initState
  froze the defaults when the sheet opened before settings loaded, and the next
  save wrote those defaults back over the stored values.
- Count visible messages with HistoryAssembler's predicate (skip isTyping), and
  guard `_calculate` with a mounted check — its callers await a write first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Szte1QvDC7vC2ZJyHaCtPC
@hydall
hydall merged commit 4ccc178 into nightly Sep 3, 2026
3 checks passed
@hydall
hydall deleted the claude/prompt-inspector-coverage-context-20d4c3 branch September 6, 2026 16:19
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.

2 participants