Skip to content

feat: propagate title_callback in TUI gateway for real-time title updates - #44810

Closed
MP329COde wants to merge 1 commit into
NousResearch:mainfrom
MP329COde:feat/auto-title-callback-propagation
Closed

feat: propagate title_callback in TUI gateway for real-time title updates#44810
MP329COde wants to merge 1 commit into
NousResearch:mainfrom
MP329COde:feat/auto-title-callback-propagation

Conversation

@MP329COde

Copy link
Copy Markdown

Summary

When a conversation title is auto-generated after the first assistant response, the TUI gateway now emits a session.info event to notify connected clients (WebUI, Desktop app) of the new title in real time.

Problem

Previously, the TUI gateway called maybe_auto_title() without a title_callback or main_runtime, so:

  • Connected clients never saw the title update until a page refresh
  • The title generator could not use the session's model/provider for generation, falling back to defaults

Solution

  • Added a _title_generated callback that emits session.info via _emit() when a title is generated
  • Passed main_runtime with the agent's model/provider/base_url/api_key/api_mode so the title generator can use the same provider as the session
  • Aligns the TUI gateway with the main gateway behavior (which already propagates title callbacks for Telegram topic renames)

Testing

  • Verified the patch applies cleanly and passes existing linting
  • The change is minimal and defensive (wrapped in try/except like the existing gateway pattern)

…ates

When a conversation title is auto-generated after the first assistant
response, the TUI gateway now emits a session.info event to notify
connected clients (WebUI, Desktop app) of the new title in real time.

Previously, the TUI gateway called maybe_auto_title() without a
title_callback or main_runtime, so:
- Connected clients never saw the title update until a page refresh
- The title generator could not use the session's model/provider for
  generation, falling back to defaults

This aligns the TUI gateway with the main gateway behavior (which
already propagates title callbacks for Telegram topic renames).
@alt-glitch alt-glitch added type/feature New feature or request comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have labels Jun 12, 2026

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

Code Review Summary

Verdict: Approved

Overview

Propagates the title_callback through the TUI gateway to enable real-time title updates when maybe_auto_title generates a title. Also passes main_runtime dict (model, provider, base_url, api_key, api_mode) to maybe_auto_title for context-aware title generation.

Assessment

  • Correctness: Correct closure-based callback (_title_generated) with session-key captured via default argument to avoid late-binding issues. agent attributes accessed defensively with getattr(..., None).
  • Code Quality: Clean, focused. The callback is properly scoped to emit session.info to connected clients when a title is auto-generated.
  • Security: No security concerns — only exposes metadata to the session info stream.

Looks Good

  • Proper closure: _sid=_effective_sid default arg captures current session key
  • Defensive getattr for optional agent attributes
  • Graceful exception handling in the callback (swallows exceptions silently)

Reviewed by Hermes Agent

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the missing runtime handoff. The diagnosis remains partly valid on current main: tui_gateway/server.py:9260-9272 still calls maybe_auto_title() without main_runtime.

Problems

  • The live-update part has since been implemented differently. Commit 4e023f5bc990ac430d38a220c74162bbe92293f9 added the current session.title callback at tui_gateway/server.py:9266-9271; Desktop consumes it at apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts:358-367. The PR's older session.info callback should not be restored.
  • No regression test covers runtime forwarding; the present TUI test at tests/test_tui_gateway_server.py:6193-6228 checks only positional arguments.

Suggested changes

  • Re-scope the salvage to pass _main_runtime_from_agent(agent) (tui_gateway/server.py:6272-6288) into the current title call, preserving the existing session.title event.
  • Add focused assertions for the runtime payload and callback event.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution. Closing as superseded — both halves are now on main:

The gap you identified was real on both counts; the fixes just arrived through fresher branches.

@teknium1 teknium1 closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants