Skip to content

refactor(usage): consolidate duplicate formatProviderName into shared helper#3316

Open
oldschoola wants to merge 2 commits into
can1357:mainfrom
oldschoola:refactor/consolidate-formatProviderName
Open

refactor(usage): consolidate duplicate formatProviderName into shared helper#3316
oldschoola wants to merge 2 commits into
can1357:mainfrom
oldschoola:refactor/consolidate-formatProviderName

Conversation

@oldschoola

Copy link
Copy Markdown
Contributor

Problem

The formatProviderName function (title-casing a provider id like opencode-goOpencode Go) was duplicated identically across three rendering paths:

  • command-controller.ts (TUI)
  • usage-cli.ts (CLI)
  • usage-report.ts (ACP)

Changes

  • Moved the single implementation to the shared slash-commands/helpers/format.ts (already home to formatDuration and renderAsciiBar)
  • Updated all three call sites to import from there
  • Net: -22 lines, +11 lines

Tests

  • bun check passes
  • All usage rendering tests pass (18/18)

@github-actions github-actions Bot added the vouched Passed the vouch gate label Jun 23, 2026
… helper

The formatProviderName function (title-casing a provider id like
'opencode-go' → 'Opencode Go') was duplicated identically across
three files:
- command-controller.ts (TUI rendering path)
- usage-cli.ts (CLI rendering path)
- usage-report.ts (ACP rendering path)

Moved the single implementation to the shared format.ts helper
(already home to formatDuration and renderAsciiBar), and updated
all three call sites to import from there.
@oldschoola oldschoola force-pushed the refactor/consolidate-formatProviderName branch from 317723a to 8241790 Compare June 23, 2026 13:57
@roboomp roboomp added cli CLI commands and arguments refactor review:p1 triaged tui Terminal UI rendering and display labels Jun 23, 2026

@roboomp roboomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1: scoped refactor is mechanically sound and typechecks; the only merge touch I found is repo convention coverage.
Finding: missing packages/coding-agent/CHANGELOG.md ## [Unreleased] entry for the usage-rendering change.
Verification: bun run check:types passed in packages/coding-agent; bun test test/usage-cli.test.ts is blocked in this checkout by missing src/export/html/tool-views.generated.js.
Thanks for the tidy dedupe.

import { theme as currentTheme, type Theme } from "../../modes/theme/theme";

/** Title-case a provider id for display (e.g. "opencode-go" → "Opencode Go"). */
export function formatProviderName(provider: string): string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should-fix: this touches packages/coding-agent user-facing usage rendering, but the PR does not add an ## [Unreleased] entry in packages/coding-agent/CHANGELOG.md. Repo convention requires a changelog entry for each touched package before merge.

@oldschoola

Copy link
Copy Markdown
Contributor Author

Added the missing CHANGELOG entry in the latest push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI commands and arguments refactor review:p1 triaged tui Terminal UI rendering and display vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants