Skip to content

feat(web-react): live reasoning timer + humanized tool-call titles#149

Merged
Tjemmmic merged 2 commits into
mainfrom
feat/chat-thinking-timer-and-tool-titles
Jun 26, 2026
Merged

feat(web-react): live reasoning timer + humanized tool-call titles#149
Tjemmmic merged 2 commits into
mainfrom
feat/chat-thinking-timer-and-tool-titles

Conversation

@Tjemmmic

Copy link
Copy Markdown
Contributor

Problem

Two gaps in ChatMessages: the reasoning panel showed a static "Thinking…" while the model reasoned (the duration was measured but only revealed afterward as "Thought for Ns"), and any tool the host doesn't explicitly map rendered with its raw snake_case name (get_credit_balance, invoke_integration, …) as the chip title.

Changes

  • Live reasoning timer: a shared useThinkingSeconds(active) hook drives a ticking "Thinking · Ns" counter in the reasoning panel while the model reasons before its answer, matching the existing pre-first-token ThinkingRow (which now uses the same hook). The post-answer "Thought for Ns" summary is unchanged.
  • Humanized tool titles: friendlyToolTitle's fallback now sentence-cases unmapped tool names (get_credit_balance → "Get credit balance"). The transformation is domain-agnostic — it splits on separators and camelCase only — so it improves every host's tool chips without this shared renderer knowing any host's tool taxonomy. Explicitly mapped tools (proposals, sandbox actions) are unchanged.

Validation

tsc --noEmit clean. 18 web-react tests pass, including a new test asserting the humanized title renders and the raw slug never leaks; existing segment tests updated to locate chips by their rendered titles.

@Tjemmmic

Copy link
Copy Markdown
Contributor Author

🤖 AI Code Review (ensemble)

Summary

PR adds a live reasoning timer and humanizes unmapped tool-call names. All reviewers agree on one P2 issue: the new useThinkingSeconds hook never resets its counter when active transitions back to true, so reused message components would display stale elapsed time. Reviewer C also flags the timer behavior as having no test coverage.

Issues Found

3 total — 0 P1 (blocking) · 2 P2 (should fix) · 1 P3 (nice to have)

⚠️ P2 — useThinkingSeconds does not reset to zero on reactivation

  • File: src/web-react/index.tsx:L971-L982
  • Problem: The interval is torn down and rebuilt when active changes, but the seconds state is never reset, so a reused component instance resuming thinking (e.g. when active toggles false -> true during streaming) would display stale elapsed time instead of starting from 0.
  • Fix: Reset state to 0 when active turns true:
useEffect(() => {
  if (!active) return
  setSeconds(0)
  const id = setInterval(() => setSeconds((s) => s + 1), 1000)
  return () => clearInterval(id)
}, [active])

⚠️ P2 — Live thinking timer behavior lacks test coverage

  • File: src/web-react/chat-messages-segments.test.tsx
  • Problem: Tests only cover the humanized tool name path. There are no fake-timer tests for the new live thinking timer behavior, leaving regressions (stale counters, missing cleanup, incorrect threshold text) uncovered.
  • Fix: Add fake-timer tests rendering a streaming assistant message with reasoning, advance timers past the 3s threshold, assert Thinking · 3s appears, then rerender inactive/active to verify cleanup and reset.

ℹ️ P3 — humanizeToolName collapses repeated separators into single space

  • File: src/web-react/index.tsx:L373-L380
  • Problem: replace(/[_-]+/g, ' ') collapses runs of separators (e.g. foo__bar -> 'Foo bar' with single space). Likely intended behavior and tests pass, but it's an undocumented normalization.
  • Fix: No change required if single-space collapse is desired. If preservation matters, use /[_-]/g instead of /[_-]+/g.

❌ CHANGES REQUESTED

There are two P2 issues: a concrete stale-state bug in the new timer hook that could display misleading elapsed time, and no test coverage for the timer behavior. Reviewer B and C both requested changes on these grounds. While just under the 3-P2 threshold for CHANGES_REQUESTED, the combination of a user-visible correctness bug and missing tests for significant new logic warrants another pass before merge.

Quick Reference

  • P2: useThinkingSeconds does not reset to zero on reactivation
  • P2: Live thinking timer behavior lacks test coverage
  • P3: humanizeToolName collapses repeated separators into single space

Synthesized by Sokuza AI from multiple independent reviewers

@Tjemmmic

Tjemmmic commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

🤖 AI Code Review (ensemble)

Summary

The PR introduces a live reasoning timer and humanized fallback titles for unmapped tool calls. Both additions are functionally sound, well-tested, and correctly handle cleanup and edge cases. Reviewer A's flagged issues are not supported by the diff: useThinkingSeconds is properly exported via the export keyword in index.tsx, and the reset-on-reactivation behavior is intentional and explicitly documented in the hook's JSDoc.

No Issues Found

✅ APPROVE

The code is clean, interval lifecycles are correctly managed, and new behaviors are covered by focused tests. The humanization logic provides a sensible fallback without altering existing specific tool titles. The useThinkingSeconds hook is properly exported and its state-resetting behavior is intentional, addressing stale timer concerns during reused renders.


Synthesized by Sokuza AI from multiple independent reviewers

@Tjemmmic Tjemmmic marked this pull request as ready for review June 26, 2026 19:38

@tangletools tangletools 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.

✅ Auto-approved PR — e9239484

Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-26T19:39:05Z

@Tjemmmic Tjemmmic merged commit 503dffd into main Jun 26, 2026
1 check passed
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