Skip to content

refactor(chat): replace IIFE-in-JSX with flat-precompute idiom in PaneContextUsage - #131

Merged
mhersson merged 1 commit into
mainfrom
ctxmax-601/follow-up-paneheader-cost-glyph-iife-in-jsx-breaks
May 22, 2026
Merged

refactor(chat): replace IIFE-in-JSX with flat-precompute idiom in PaneContextUsage#131
mhersson merged 1 commit into
mainfrom
ctxmax-601/follow-up-paneheader-cost-glyph-iife-in-jsx-breaks

Conversation

@contextmatrix-runner

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the IIFE-in-JSX pattern ({(() => { ... })()}) in PaneContextUsage with flat precomputed locals (cost, showCost, costTooltip) and a {showCost && <span />} conditional block
  • Matches the existing idiom used by the model pill and .chat-pane-pct block in the same function
  • Performance invariant preserved: formatCostTooltip is still not called when the cost glyph is hidden (ternary short-circuits)
  • title={costTooltip || undefined} replaces the prior conditional-spread, letting React omit the attribute when empty

Test plan

  • All 667 frontend tests pass (npm test in web/)
  • No IIFE remains in PaneHeader.tsx
  • Cost glyph still renders with correct value, aria-label, and tooltip when estimatedCostUsd > 0
  • Cost glyph absent when estimatedCostUsd is null, undefined, or zero

…eContextUsage

- Extract cost, showCost, costTooltip as precomputed locals before return
- Replace {(() => { ... })()} with {showCost && <span ... />} conditional block
- Use ternary for costTooltip to preserve the perf guard (formatCostTooltip
  not called when glyph is hidden)
- Use title={costTooltip || undefined} instead of conditional spread
@mhersson
mhersson merged commit 925ce0d into main May 22, 2026
7 checks passed
@mhersson
mhersson deleted the ctxmax-601/follow-up-paneheader-cost-glyph-iife-in-jsx-breaks branch May 22, 2026 21:57
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