Skip to content

The agent that grows with you

style(hud): tighten the surface-note comments and test helper

Brooklyn Nicholson0665cd4b5b55
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index 81f9816e468..304437170bd 100644
--- a/agent/prompt_builder.py
+++ b/agent/prompt_builder.py
@@ -706,8 +706,8 @@ def hud_surface_note(valid_tool_names: "set[str] | None" = None) -> str:
a surface of our own. Left to itself the model answers from its own
browser and panes, which is the wrong half of the screen.
- It is a per-turn fact, not a platform: one desktop session can be driven
- from the app window on one turn and the HUD on the next. So it rides the
+ It is a per-turn fact, not a platform — one desktop session can be driven
+ from the app window on one turn and the HUD on the next — so it rides the
model-bound message beside the reaction / speech-interrupted notes rather
than the system prompt, which has to stay byte-stable for a conversation's
whole life.
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx
index 8af22a06e83..69e3d76e0c1 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx
@@ -324,18 +324,18 @@ function renderedSeedTexts(seeds: Record<string, unknown>[]): string[] {
})
}
+// The HUD floats over the app the user is really working in, so the gateway
+// turns this flag into a per-turn hint: read the window underneath and work in
+// it, rather than reaching for Hermes's own browser and panes.
describe('usePromptActions HUD surface', () => {
- // The HUD floats over the app the user is really working in, so the gateway
- // turns this flag into a per-turn hint: look at the window underneath before
- // reaching for Hermes's own browser and panes.
afterEach(() => {
cleanup()
$hudMode.set(false)
vi.restoreAllMocks()
})
- async function submitFromHud(hud: boolean) {
- $hudMode.set(hud)
+ async function submitFrom(window: 'app' | 'hud') {
+ $hudMode.set(window === 'hud')
const submitted: (Record<string, unknown> | undefined)[] = []
@@ -358,11 +358,11 @@ describe('usePromptActions HUD surface', () => {
}
it('tags a message typed into the HUD', async () => {
- expect(await submitFromHud(true)).toMatchObject({ surface: 'hud' })
+ expect(await submitFrom('hud')).toMatchObject({ surface: 'hud' })
})
it('says nothing about the surface from the app window', async () => {
- expect(await submitFromHud(false)).not.toHaveProperty('surface')
+ expect(await submitFrom('app')).not.toHaveProperty('surface')
})
})
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
index f5712e8aea9..be6264748ea 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts
@@ -620,10 +620,9 @@ export function useSubmitPrompt(deps: SubmitPromptDeps) {
session_id: targetId,
text,
...(interrupted && { interrupted }),
- // Typed into the floating HUD, which means the user is looking at
- // another app rather than at Hermes. The gateway turns this into a
- // per-turn hint so the agent reads the window underneath and works
- // in it, instead of reaching for its own browser and panes.
+ // Typed into the floating HUD, so the user is looking at another app
+ // rather than at Hermes. The gateway turns this into a per-turn hint
+ // to read the window underneath and work in it.
...($hudMode.get() && { surface: 'hud' }),
// A queue drain is a "run after" message, never a live-turn
// correction. The flag tells the gateway's busy path to hold it for
diff --git a/tui_gateway/methods_prompt.py b/tui_gateway/methods_prompt.py
index 3344a0c1506..f76e2f65b23 100644
--- a/tui_gateway/methods_prompt.py
+++ b/tui_gateway/methods_prompt.py
@@ -113,10 +113,10 @@ def _(rid, params: dict) -> dict:
return err
if (limit_message := _ensure_active_session_slot(sid, session)) is not None:
return _err(rid, 4090, limit_message)
- # Which desktop window this message was typed into. One session can be
- # driven from the app window and the HUD in turn, so it is rewritten on
- # every submit — a HUD message must not leave the next app-window message
- # claiming the user is still floating over another app.
+ # Which desktop window this message was typed into. Rewritten on every
+ # submit, because one session can be driven from the app window and the HUD
+ # in turn: a stale "hud" would tell the model the user is still floating
+ # over another app when they are back in Hermes.
session["client_surface"] = "hud" if params.get("surface") == "hud" else ""
if truncate_user_ordinal is not None and isinstance(text, str):
# A rewind/regenerate replays a turn from what the transcript shows. A