Skip to content

fix(web): unify session header display labels - #1158

Open
techotaku39 wants to merge 4 commits into
tiann:mainfrom
techotaku39:fix/session-header-display-labels
Open

fix(web): unify session header display labels#1158
techotaku39 wants to merge 4 commits into
tiann:mainfrom
techotaku39:fix/session-header-display-labels

Conversation

@techotaku39

Copy link
Copy Markdown
Contributor

Summary

  • render known session agent flavors with the shared user-facing labels used by the new-session UI
  • resolve active Codex models through the model catalog so the header uses each model's advertised display name
  • format known gpt-* model IDs when the catalog is unavailable, including inactive sessions, while preserving unknown model IDs
  • keep unknown agent flavors visible as their original values instead of replacing them with Unknown

Problem

The session header rendered raw metadata identifiers such as codex and gpt-5.6-sol, while the new-session and settings UIs rendered the same values as Codex and GPT-5.6-Sol. This made the product naming inconsistent, especially on mobile.

Testing

  • bun typecheck
  • NODE_OPTIONS=--max-old-space-size=8192 bun run test:web (165 files, 1396 tests)
  • manual verification on the mobile web UI for active and inactive Codex sessions

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
None.

Questions
None.

Summary
Review mode: initial
No issues found in the modified lines. Residual risk: I did not run tests in this review environment; the PR adds helper-level coverage for agent labels, catalog display names, Codex fallback formatting, and unknown IDs, but there is no component-level test around the SessionHeader catalog-backed display path.

Testing
Not run (automation).

HAPI Bot

@techotaku39
techotaku39 force-pushed the fix/session-header-display-labels branch from 7497512 to 7a498c8 Compare July 28, 2026 01:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Minor] Codex model catalog query still runs when the header renders nothing in Telegram — the new enabled expression can be true for active Codex sessions before the existing Telegram early return, so Telegram views can still hit /codex-models for UI that is not rendered. That RPC opens a Codex app-server client and calls listModels, so this adds avoidable runner work. Evidence web/src/components/SessionHeader.tsx:117; context web/src/components/SessionHeader.tsx:217, cli/src/modules/common/codexModels.ts:87.
    Suggested fix:
    const telegramApp = isTelegramApp()
    const codexModelsState = useCodexModels({
        api,
        machineId: session.metadata?.machineId ?? null,
        enabled: !telegramApp
            && agentFlavor === 'codex'
            && session.active
            && session.agentState?.controlledByUser !== true
    })
    
    // ...
    
    if (telegramApp) {
        return null
    }

Questions
None.

Summary
Review mode: follow-up after new commits
Found one minor performance regression in the latest diff. Prior HAPI Bot review had no findings; latest PR diff reviewed in full, with the compare diff used only as follow-up context.

Testing
Not run (automation). PR reports bun typecheck and NODE_OPTIONS=--max-old-space-size=8192 bun run test:web.

HAPI Bot

Comment thread web/src/components/SessionHeader.tsx Outdated
const codexModelsState = useCodexModels({
api,
machineId: session.metadata?.machineId ?? null,
enabled: agentFlavor === 'codex' && session.active && session.agentState?.controlledByUser !== true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MINOR] Disable this query when the header is hidden in Telegram. SessionHeader still calls useCodexModels before the existing isTelegramApp() early return, so this can be enabled for active Codex sessions even though the component returns null. The endpoint opens a Codex app-server client and calls listModels, making this avoidable runner work for UI that is not rendered.

Suggested fix:

const telegramApp = isTelegramApp()
const codexModelsState = useCodexModels({
    api,
    machineId: session.metadata?.machineId ?? null,
    enabled: !telegramApp
        && agentFlavor === 'codex'
        && session.active
        && session.agentState?.controlledByUser !== true
})

// ...

if (telegramApp) {
    return null
}

swear01 added a commit to swear01/hapi that referenced this pull request Jul 29, 2026
@techotaku39
techotaku39 force-pushed the fix/session-header-display-labels branch from 7a498c8 to 304f2e4 Compare August 3, 2026 16:20

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Minor] The Telegram-only Codex model catalog request reported in the prior bot review remains on the current head. See the inline comment at web/src/components/SessionHeader.tsx:144.

Questions
None.

Summary
Review mode: follow-up after new commits
One previously reported minor performance issue remains. The latest PR diff was reviewed in full; no additional findings met the 80% confidence threshold. Residual testing gap: there is no component test confirming that Telegram rendering suppresses the catalog request.

Testing
Not run (automation; PR content was not executed). PR reports bun typecheck and NODE_OPTIONS=--max-old-space-size=8192 bun run test:web.

HAPI Bot

Comment thread web/src/components/SessionHeader.tsx Outdated
const codexModelsState = useCodexModels({
api,
machineId: session.metadata?.machineId ?? null,
enabled: agentFlavor === 'codex' && session.active && session.agentState?.controlledByUser !== true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MINOR] Gate this query on Telegram visibility. It is enabled before the isTelegramApp() early return at line 288, so an active Codex session in Telegram still requests /machines/:id/codex-models even though SessionHeader renders nothing. That endpoint opens a Codex app-server client and calls listModels, adding avoidable runner work.

Suggested fix:

const telegramApp = isTelegramApp()
const codexModelsState = useCodexModels({
    api,
    machineId: session.metadata?.machineId ?? null,
    enabled: !telegramApp
        && agentFlavor === 'codex'
        && session.active
        && session.agentState?.controlledByUser !== true
})

// ...
if (telegramApp) {
    return null
}

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
None.

Questions
None.

Summary
Review mode: follow-up after new commits
The prior Telegram-only header catalog-query issue is resolved at web/src/components/SessionHeader.tsx:144, with regression coverage at web/src/components/SessionHeader.test.tsx:94. The latest PR diff was reviewed in full; no remaining correctness, security, regression, data-loss, performance, or maintainability issue met the 80% confidence threshold. Residual testing gap: no component-level test verifies that a loaded catalog display name is rendered in the header; the label helper is unit-covered.

Testing
Not run (automation; PR content was not executed). GitHub checks were pending at review time.

HAPI Bot

@techotaku39
techotaku39 force-pushed the fix/session-header-display-labels branch from ff14e91 to 8148ce4 Compare August 4, 2026 04:33

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
None.

Questions
None.

Summary
Review mode: follow-up after new commits
The latest PR diff was reviewed in full. No correctness, security, regression, data-loss, performance, or maintainability issue introduced or directly triggered by the diff met the 80% confidence threshold. Residual testing gap: web/src/components/SessionHeader.test.tsx verifies that Telegram disables the catalog query, but no component-level test verifies that a loaded catalog display name is rendered; the label helper is unit-covered.

Testing
Not run (automation; PR content was not executed). The current GitHub test check failed during bun typecheck at web/src/router.tsx:773 because deliveryMode is missing from a RawSendError; that file is unchanged by this PR, so the failure is not attributed to this diff. Web tests were not reached.

HAPI Bot

@techotaku39
techotaku39 force-pushed the fix/session-header-display-labels branch from 8148ce4 to 0b50893 Compare August 5, 2026 05:39

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Minor] Avoid starting a Codex catalog lookup when its result cannot be rendered — the new query is enabled for every active remote Codex session, but the result is unused when the model metadata preference is off, and getSessionModelLabel also discards the catalog display name when session.model is empty. The endpoint dispatches a machine RPC that starts a Codex app-server client, so opening a header can perform expensive work with no UI consumer. Evidence: web/src/components/SessionHeader.tsx:171; related context: web/src/lib/sessionModelLabel.ts:43, cli/src/modules/common/codexModels.ts:83.
    Suggested fix:
    const explicitModel = typeof session.model === "string" && session.model.trim() !== ""
    
    enabled: !telegramApp
        && headerMetadata.model
        && explicitModel
        && agentFlavor === "codex"
        && session.active
        && session.agentState?.controlledByUser !== true

Questions
None.

Summary
Review mode: follow-up after new commits
One Minor performance issue found in the full current diff. The new Telegram guard resolves the prior environment-specific query path, but unused model-catalog lookups remain possible outside Telegram.

Testing
Not run (automation; PR-authored code was not executed). Add a SessionHeader test that disables model metadata or supplies model: null and asserts the catalog query is disabled; retain a component-level case proving an explicit model uses the catalog display name.

HAPI Bot

const codexModelsState = useCodexModels({
api,
machineId: session.metadata?.machineId ?? null,
enabled: !telegramApp

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MINOR] Avoid an unused Codex catalog RPC

This condition still enables the catalog query when model metadata is disabled or session.model is null/blank. In both cases this component cannot render the response: the preference removes the model row, and getSessionModelLabel returns null without an explicit model. Since the endpoint performs a machine RPC and initializes a Codex app-server client, gate the query on both conditions.

Suggested fix:

const explicitModel = typeof session.model === "string" && session.model.trim() !== ""

enabled: !telegramApp
    && headerMetadata.model
    && explicitModel
    && agentFlavor === "codex"
    && session.active
    && session.agentState?.controlledByUser !== true

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
No findings.

Questions
None.

Summary
Review mode: follow-up after new commits
No issues found in the latest full diff. The prior Minor catalog-RPC finding is resolved by requiring both visible model metadata and a nonblank session model before enabling the query. Residual risk is limited to the pending repository test workflow.

Testing
Not run (automation; PR-authored code was not executed). Static review covered the added query guards, catalog display-name resolution, Codex fallback formatting, agent labels, and their unit/component tests. GitHub's test check was still in progress when reviewed.

HAPI Bot

@techotaku39
techotaku39 force-pushed the fix/session-header-display-labels branch from c8e679b to 9323174 Compare August 6, 2026 14:04

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
No findings.

Questions
None.

Summary
Review mode: follow-up after new commits
No issues found in the latest full diff. The prior catalog-RPC finding remains resolved: lookups require a visible, nonblank Codex model row and are disabled in Telegram, inactive/local sessions, and sessions without a usable machine/API target. Residual risk is limited to the pending repository test workflow.

Testing
Not run (automation; PR-authored code was not executed). Static review covered the query guards, catalog display-name resolution, Codex fallback formatting, agent-label mapping, surrounding consumers, and the added unit/component tests.

HAPI Bot

…splay-labels

# Conflicts:
#	web/src/components/SessionHeader.test.tsx

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings
No findings.

Questions
None.

Summary
Review mode: follow-up after new commits
No issues found in the latest full diff. The new head only merges current main; the four-file PR diff still preserves the prior query guards and label-resolution behavior. Residual risk: the repository test workflow was still running at review time.

Testing
Not run (automation; PR-authored code was not executed). Static review covered the full diff, prior bot review, changes since that review, and surrounding catalog/flavor/query implementations.

HAPI Bot

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.

1 participant