Skip to content

refactor(session): centralize fallback title policy - #39890

Merged
kitlangton merged 1 commit into
v2from
session-title-fallback
Jul 31, 2026
Merged

refactor(session): centralize fallback title policy#39890
kitlangton merged 1 commit into
v2from
session-title-fallback

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Centralize session-title fallback policy in the browser-safe @opencode-ai/util package so App, ACP, Core, Enterprise, and TUI no longer maintain subtly different constructors and recognizers.

This keeps four existing behaviors explicit and separate:

  • timestamped compatibility titles for consumers that require a string
  • compact labels for human-facing App surfaces
  • broad recognition of absent or historical timestamped fallback titles
  • exact root-session fallback recognition for title-generation retries

How

  • Add session-title-fallback.ts with focused tests covering root, child, empty, historical, generated, and exact-match cases.
  • Replace duplicated timestamp constructors in App normalization, ACP, Enterprise sharing, and TUI surfaces.
  • Move App display-label normalization and TUI fallback recognition to the shared policy.
  • Keep Core retry eligibility exact to the root session's creation timestamp.
  • Remove the ambiguous App and TUI sessionTitle helpers.
flowchart LR
  S[Session info] --> P{Consumer policy}
  P -->|String required| T[withTimestampedFallback]
  P -->|Human label| D[displayLabel]
  P -->|Terminal or splash| H[isFallbackTitle]
  P -->|Core title retry| E[isExactRootFallback]
Loading

Scope

  • No protocol, schema, or generated-client changes.
  • No persisted-data migration; historical fallback titles remain recognized.
  • No visible title behavior changes.

Testing

  • packages/util: bun run test, bun typecheck, bun run build
  • packages/app: bun typecheck, focused src/utils/session.test.ts
  • packages/cli: bun typecheck
  • packages/core: bun typecheck, focused test/session-title.test.ts
  • packages/enterprise: bun typecheck
  • packages/tui: bun typecheck, focused test/util/session.test.ts
  • Targeted Oxlint: 0 errors
  • App display formatter benchmark, 10,000,000 calls: 184.14 ms before, 190.95 ms after, identical consumed output

@kitlangton
kitlangton merged commit 7aaf4e7 into v2 Jul 31, 2026
11 of 13 checks passed
@kitlangton
kitlangton deleted the session-title-fallback branch July 31, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant