Skip to content

The agent that grows with you

fix(tui): Enter before the session binds is queued, and gateway tool events carry the client contract

teknium1f2d93094f079
diff --git a/gateway/run_turn_progress.py b/gateway/run_turn_progress.py
index eaac20fa5ac..df31f31634f 100644
--- a/gateway/run_turn_progress.py
+++ b/gateway/run_turn_progress.py
@@ -29,6 +29,19 @@ if TYPE_CHECKING: # string annotations only; never imported at runtime (cycle)
logger = logging.getLogger("gateway.run")
+def _tool_lifecycle_payload(call_id, tool_name, args) -> dict:
+ """The ``ToolStartPayload`` contract every client reads (``tool_id``/``name``/``context``),
+ plus the ``tool_call_id``/``tool_name`` the gateway's own consumers were built on."""
+ from agent.display import build_tool_preview, tool_labels_for_call
+ name = str(tool_name or "tool")
+ args = args if isinstance(args, dict) else {}
+ payload = {"tool_id": str(call_id or ""), "name": name, "context": build_tool_preview(name, args, max_len=80) or "",
+ "tool_call_id": str(call_id or ""), "tool_name": name, "args": args}
+ if labels := [label.as_payload() for label in tool_labels_for_call(name, args)]:
+ payload["labels"] = labels
+ return payload
+
+
class GatewayTurnProgressMixin:
# ── shared thread→loop plumbing ─────────────────────────────────────────────────────────
@@ -764,9 +777,7 @@ class GatewayTurnProgressMixin:
def combined_tool_start_callback(self, call_id, tool_name, args):
"""Compose the voice ack + native task-card start consumers."""
- self._publish_execution("tool.start", {
- "tool_call_id": str(call_id or ""), "tool_name": str(tool_name or "tool"),
- "args": args if isinstance(args, dict) else {}})
+ self._publish_execution("tool.start", _tool_lifecycle_payload(call_id, tool_name, args))
self._publish_api_tool("tool.start", call_id, tool_name, args)
if self._ctx._voice_ack_guild[0] is not None:
self.voice_ack_callback(call_id, tool_name, args)
@@ -777,8 +788,7 @@ class GatewayTurnProgressMixin:
from agent.display import _detect_tool_failure
is_error, _ = _detect_tool_failure(tool_name, result)
self._publish_execution("tool.complete", {
- "tool_call_id": str(call_id or ""), "tool_name": str(tool_name or "tool"),
- "is_error": bool(is_error), "args": args if isinstance(args, dict) else {},
+ **_tool_lifecycle_payload(call_id, tool_name, args), "is_error": bool(is_error),
"result": result if isinstance(result, str) else str(result)})
self._publish_api_tool("tool.complete", call_id, tool_name, args, result)
if self._ctx._native_slack_task_cards:
diff --git a/hermes_cli/gateway_chat_view.py b/hermes_cli/gateway_chat_view.py
index ebdb6b4c576..c83d661a861 100644
--- a/hermes_cli/gateway_chat_view.py
+++ b/hermes_cli/gateway_chat_view.py
@@ -236,6 +236,9 @@ class GatewayChatView:
return 0 if outcome == "completed" else 1
from prompt_toolkit import PromptSession
from prompt_toolkit.patch_stdout import patch_stdout
+ from hermes_cli.skin_engine import get_active_skin
+ welcome = "Welcome to Hermes Agent! Type your message or /help for commands."
+ print(get_active_skin().get_branding("welcome", welcome), flush=True)
prompt = PromptSession()
with patch_stdout():
while not self.failure:
diff --git a/ui-tui/src/__tests__/busyQueueAdmission.test.tsx b/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
index ed370d9472d..cfaf6d5a865 100644
--- a/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
+++ b/ui-tui/src/__tests__/busyQueueAdmission.test.tsx
@@ -156,13 +156,13 @@ it('retains disconnected input durably on its old destination without dispatchin
} finally { h.cleanup() }
})
-it('refuses unbound Enter without clearing the draft or claiming a queued input', () => {
+it('queues an unbound Enter locally without claiming a gateway admission', () => {
const h = mount()
try {
patchUiState({ sid: null })
h.submission.dispatchSubmission('unbound draft')
- expect(h.queue.queueRef.current).toEqual([])
+ expect(h.queue.queueRef.current.map(item => item.text)).toEqual(['unbound draft'])
expect(h.calls).toEqual([])
} finally { h.cleanup() }
})
diff --git a/ui-tui/src/app/useSubmission.ts b/ui-tui/src/app/useSubmission.ts
index c79b425043e..6f84f3ae36d 100644
--- a/ui-tui/src/app/useSubmission.ts
+++ b/ui-tui/src/app/useSubmission.ts
@@ -366,7 +366,11 @@ export function useSubmission(opts: UseSubmissionOptions) {
const live = getUiState()
- if (!live.sid) { return sys('session not ready — draft kept; reconnect or choose a session') }
+ // No session yet (boot, or the socket is down): the input joins the local queue and the
+ // sid/connected drain effect sends it once the session is bound. On an attached gateway
+ // the first session.create lands seconds after the composer accepts input, so an Enter
+ // in that window must not be refused.
+ const unbound = !live.sid || live.gatewayConnected === false
// The composer is the only copy of a draft until the pending-input
// journal holds it, so it is cleared after that first durable write and
@@ -385,7 +389,7 @@ export function useSubmission(opts: UseSubmissionOptions) {
}
}
- if (live.gatewayConnected === false) {
+ if (unbound) {
composerActions.pushHistory(toHistory)
journaled(() => {
const retained = composerActions.enqueue(submission.text, submission.display, destination)