feat(narratives): stopped-turn UX, reasoning polish, token-usage readout#425
Open
ddebasmita-lab wants to merge 3 commits into
Open
feat(narratives): stopped-turn UX, reasoning polish, token-usage readout#425ddebasmita-lab wants to merge 3 commits into
ddebasmita-lab wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances the chat interface by styling the reasoning block with a continuous left bar, adding section navigation to the mobile drawer, introducing a temporary token-usage readout in the header, and handling stopped turns gracefully. The reviewer identified a critical issue where stopped turns are not filtered from the chat history, potentially causing Gemini API crashes due to consecutive user messages. Additionally, feedback was provided regarding visual bugs with nested list borders in the reasoning block and the anti-pattern of evaluating window.location at module load time for the token debug flag.
…e readout Brings the narratives UI in line with the downstream app: - Stopped-turn handling: when the user hits Stop, replace the half-finished reasoning/answer with a "Stopped per your request" note (data_agent, block_reasoning). - Reasoning-aside styling polish and mobile drawer nav refinements (block_reasoning, drawer_session). - Optional per-query Gemini token-usage readout in the header, gated behind ?debug=tokens (off by default; reads a `usage` SSE event). Temporary cost instrumentation for measuring query cost.
ddebasmita-lab
force-pushed
the
narratives-reasoning-token-usage
branch
from
July 24, 2026 14:26
52fd22b to
a58c936
Compare
…ug flag Address review feedback on PR: - useSseChat: only include completed turns (not stopped/errored/empty) when building the Gemini history, so an aborted turn can't produce consecutive user messages (400 from the API). - header: evaluate the ?debug=tokens flag per render via isTokenDebugEnabled() instead of once at module load (testable, SPA-reactive, SSR-safe).
Rewrite a change-narrative comment (referenced the removed ThoughtsPanel) to describe present behavior, per the review convention that comments state what the code does rather than what it used to do.
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.
Overview
Follow-up UI chunk for the narratives Data Agent, bringing the remaining
front-end refinements into the repo. No backend/build-config changes.
Changes made
reasoning/answer is replaced with a "Stopped per your request" note instead
of leaving truncated chrome (
data_agent.tsx,block_reasoning.tsx).a left bar; heading styling and spacing refined (
block_reasoning.tsx).drawer_session.tsx).Tokens IN / OUT / Totalblock in theheader, shown only when the page is opened with
?debug=tokens. It readsan optional
usageSSE event; off by default and invisible to normal users.Temporary instrumentation for gauging per-query cost (
header.tsx,use_sse_chat.ts).Testing done
npm run lint(tsc --noEmit, strict) — clean.npm run build(vite) — clean.npm test(vitest) — passing.