Skip to content

Comments

feat: add token usage display + structured client logging#64

Closed
bradfeld wants to merge 3 commits intodanshapiro:mainfrom
bradfeld:feature/FRE-18-add-usage-limits-display
Closed

feat: add token usage display + structured client logging#64
bradfeld wants to merge 3 commits intodanshapiro:mainfrom
bradfeld:feature/FRE-18-add-usage-limits-display

Conversation

@bradfeld
Copy link
Contributor

@bradfeld bradfeld commented Feb 16, 2026

Summary

  • FRE-18: Add token usage display (input/output/cached/context) to coding CLI pane headers with a compact UsageBar component
  • FRE-36: Replace 44 raw console.log/warn/error calls across 14 client source files with a structured createLogger(component) factory

FRE-36: Client Logger Details

Adds a level-filtered, component-prefixed createLogger(component) factory to client-logger.ts. Each component gets a tagged logger (e.g. [App], [Store], [EditorPane]) with debug/info/warn/error methods that respect a global log level (debug in development, warn in production).

Files converted

  • src/App.tsx — 12 console calls → [App] logger
  • src/store/store.ts — 4 calls → [Store] logger
  • src/store/storage-migration.ts — 4 calls → [StorageMigration] logger
  • src/store/tabsSlice.ts — 2 calls → [TabsSlice] logger
  • src/store/panesSlice.ts — 3 calls → [PanesSlice] logger
  • src/store/persistMiddleware.ts — 1 call → [PersistMiddleware] logger
  • src/lib/ws-client.ts — 2 calls → [WsClient] logger
  • src/components/TerminalView.tsx — 9 calls → [TerminalView] logger
  • src/components/SettingsView.tsx — 2 calls → [SettingsView] logger
  • src/components/Sidebar.tsx — 1 call → [Sidebar] logger
  • src/components/panes/EditorPane.tsx — 10 calls → [EditorPane] logger
  • src/components/panes/PaneContainer.tsx — 1 call → [PaneContainer] logger
  • src/components/terminal/useChunkedAttach.ts — 3 calls → [ChunkedAttach] logger

Test plan

  • npm test passes (14 pre-existing server-side SDK timeouts unrelated)
  • 3 test files updated for [Component] prefix in spy assertions
  • Manual verification in browser console

🤖 Generated with Claude Code

bradfeld and others added 2 commits February 15, 2026 15:10
Part of PLA-525 Phase 1 — declarative project profiles for unified
ticket pipeline. All 6 projects now have Workflow Profile sections.

Refs PLA-525

Co-Authored-By: Claude <noreply@anthropic.com>
- Add UsageBar component with color-coded progress (green/yellow/red)
- Add formatTokenUsageSummary() for detailed token breakdown in tooltips
- Thread tokenUsage prop through PaneContainer → Pane → PaneHeader
- Show input/output/cached/context tokens in tooltip hover
- Capitalize Branch label, add blank-line separator in tooltip

Refs FRE-18
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71bcc171d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +29 to +32
import { createLogger } from '@/lib/client-logger'


const log = createLogger('PaneContainer')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Import the existing client logger API

PaneContainer now imports createLogger from @/lib/client-logger, but that module only exports createClientLogger; there is no named export called createLogger. In ESM builds this causes a module-load failure (does not provide an export named ...) as soon as PaneContainer is evaluated, which breaks rendering of panes in production/dev runtime.

Useful? React with 👍 / 👎.

@danshapiro
Copy link
Owner

danshapiro commented Feb 16, 2026 via email

Add a level-filtered, component-prefixed createLogger(component) factory
to client-logger.ts and convert all client-side console.log/warn/error
calls to use it. Each component gets a tagged logger (e.g. [App], [Store],
[EditorPane]) with debug/info/warn/error methods that respect a global
log level (debug in dev, warn in production).

- 14 source files converted to structured logging
- 3 test files updated for [Component] prefix in assertions
- Remove scattered import.meta.env.MODE guards (logger handles levels)
- Existing createClientLogger (remote log collection) unchanged

Refs FRE-36
@bradfeld bradfeld changed the title feat: add token usage display to coding CLI pane headers feat: add token usage display + structured client logging Feb 16, 2026
@danshapiro
Copy link
Owner

Thanks @bradfeld — the createLogger refactor is a nice improvement over raw console calls. Level-filtered, clean API, good pattern.

Two things we noticed when testing:

  • The UsageBar in pane headers doesn't appear to have a data source that populates tokenUsage for any current session type.
  • The remote log collector (createClientLogger().installConsoleCapture()) monkey-patches all console.* methods at startup and POSTs to /api/logs/client, but that server endpoint doesn't exist — it silently retries against a 404 every 2 seconds.

We've consolidated this with the related PRs (#67, #72, #75) into #83 for tracking. The createLogger piece could potentially land independently — would be interested in your thoughts in the tracking issue.

Closing in favor of #83.

— Claude Code

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