Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(live-activity): carry the "You: <prompt>" line to the phone

enesa6769a1d913e
diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.ts
index 536adebfe..bd3857190 100644
--- a/src/core/agent-status-mirror.ts
+++ b/src/core/agent-status-mirror.ts
@@ -203,6 +203,8 @@ export function buildMirrorUsage(
export const INBOX_EVENTS_CAP = 50
export const INBOX_TITLE_MAX = 120
export const INBOX_DETAIL_MAX = 240
+/** Cap for the `You: …` prompt line carried on a working start edge (Live Activity + notch). */
+export const PROMPT_MAX = 120
export const INBOX_ACTIVITY_MAX = 80
// Question options (spec: interactive-push-live-activities): first question only, ≤4 choices,
// each label clipped to 60 chars.
@@ -257,6 +259,10 @@ export interface InboxNodeNow {
tool?: string
/** Context-window fill 0–100 (from context-tail), when known. */
contextPercent?: number
+ /** ≤PROMPT_MAX — the first line of the user prompt that opened the CURRENT turn ("You: …").
+ * Set on a new turn, cleared with `activity` when the turn ends, so a phone poll (which has no
+ * access to the push edges) can render the same line the push carries and the notch shows. */
+ prompt?: string
updatedAt: number
}
export interface MirrorInbox {
@@ -517,6 +523,11 @@ export interface NodeStateChange {
/** approval needsYou only: the deterministic hook-reply ticket from the just-produced approval
* event, letting an intent answer the held hook. Absent otherwise. */
pendingId?: string
+ /** working START edge only: the first line of the user prompt that opened this turn ("You: …"),
+ * ≤PROMPT_MAX. The one line that says WHAT a session is working on — the notch capsule shows it,
+ * and it rides the Live Activity so the phone reads the same thing. Absent when the turn started
+ * without a prompt we saw (a resumed session, a tool-driven working edge). */
+ prompt?: string
/** done only: this 'end' was produced by the stale-working SWEEP, not by the session itself —
* nobody heard from a `working` node for `WORKING_STALE_MS`, so it is presumed gone (see
* shared/agents/stale.ts). Like `interrupted`, it must never be celebrated as a completion. */
@@ -1053,7 +1064,19 @@ function produceInboxFromState(
// done-holdoff means a held-off late working keeps `nextState === 'done'`, so it never reaches
// here — no spurious 'start'.
if (nextState === 'working' && prevState !== 'working') {
- fireNodeStateChange({ ...stateBase, event: 'start', state: 'working' })
+ // A genuine new turn carries the user's prompt — the "You: …" line every surface shows.
+ const prompt = ev.newTurn ? firstLine(ev.task, PROMPT_MAX) : ''
+ if (prompt) {
+ // Persist it too, so the phone's POLL path (which never sees push edges) reads the same line.
+ const cur = inboxNodes.get(nodeId)
+ inboxNodes.set(nodeId, { ...cur, prompt, updatedAt: now })
+ }
+ fireNodeStateChange({
+ ...stateBase,
+ event: 'start',
+ state: 'working',
+ ...(prompt ? { prompt } : {})
+ })
}
// approval/question dedup is TITLE-based (not edge-based): a re-asserted needs-you with the SAME
// ask is a no-op, but a genuinely different ask still lands — so the guard can't be a plain
@@ -1164,7 +1187,8 @@ function produceInboxFromState(
/** Clear a node's live activity (keep any contextPercent). Idempotent; no-op if nothing set. */
function clearActivity(nodeId: string, now: number): void {
const n = inboxNodes.get(nodeId)
- if (!n || n.activity === undefined) return
+ if (!n || (n.activity === undefined && n.prompt === undefined)) return
+ // The turn is over: both the tool line AND the "You: …" prompt describe work in progress.
inboxNodes.set(nodeId, { contextPercent: n.contextPercent, updatedAt: now })
}
@@ -1202,7 +1226,13 @@ export function recordRawToolEvent(nodeId: string, payload: Record<string, unkno
const activity = toolActivity(toolName, toolInput)
const cur = inboxNodes.get(nodeId)
if (cur?.activity === activity && cur?.tool === toolName) return // no change
- inboxNodes.set(nodeId, { activity, tool: toolName, contextPercent: cur?.contextPercent, updatedAt: now })
+ inboxNodes.set(nodeId, {
+ activity,
+ tool: toolName,
+ contextPercent: cur?.contextPercent,
+ prompt: cur?.prompt,
+ updatedAt: now
+ })
fireNodeNowChange({ nodeId, activity, contextPercent: cur?.contextPercent, ts: now })
scheduleWrite()
} else if (hook === 'PermissionRequest') {
@@ -1242,7 +1272,13 @@ export function recordContextUsage(nodeId: string, percent: number): void {
const cur = inboxNodes.get(nodeId)
if (cur?.contextPercent === clamped) return
const now = Date.now()
- inboxNodes.set(nodeId, { activity: cur?.activity, tool: cur?.tool, contextPercent: clamped, updatedAt: now })
+ inboxNodes.set(nodeId, {
+ activity: cur?.activity,
+ tool: cur?.tool,
+ contextPercent: clamped,
+ prompt: cur?.prompt,
+ updatedAt: now
+ })
fireNodeNowChange({ nodeId, activity: cur?.activity, contextPercent: clamped, ts: now })
scheduleWrite()
}
diff --git a/src/core/push-notify.test.ts b/src/core/push-notify.test.ts
index ba753120c..6c9750df5 100644
--- a/src/core/push-notify.test.ts
+++ b/src/core/push-notify.test.ts
@@ -1137,3 +1137,35 @@ describe('createLiveUpdatePush', () => {
expect(fetchMock).not.toHaveBeenCalled()
})
})
+
+
+describe('live-update: the You: prompt line', () => {
+ it('rides the working start edge only', async () => {
+ const posts: any[] = []
+ let emit: ((c: any) => void) | null = null
+ const h = createLiveUpdatePush({
+ subscribeStateChange: (cb) => {
+ emit = cb
+ return () => {}
+ },
+ subscribeNowChange: () => () => {},
+ getHostIdentity: () => ({ hostDeviceId: 'h', hostToken: 't', hasPairedPhone: true }) as never,
+ mobilePushEnabled: () => true,
+ mobileLiveActivities: () => true,
+ isPackaged: () => true,
+ apiBase: 'https://example.invalid',
+ fetchImpl: (async (_u: string, init: any) => {
+ posts.push(JSON.parse(init.body))
+ return { ok: true, status: 200, json: async () => ({}) } as never
+ }) as never
+ })
+ emit!({ nodeId: 'n1', event: 'start', state: 'working', prompt: 'fix the login bug', ts: 1 })
+ emit!({ nodeId: 'n1', event: 'end', state: 'done', prompt: 'should be dropped', ts: 2 })
+ await h._flushNow()
+ const items = posts.flatMap((p) => p.updates)
+ expect(items.find((i: any) => i.state === 'working')?.prompt).toBe('fix the login bug')
+ // An end edge never carries a stale You: line.
+ expect(items.find((i: any) => i.state === 'done')?.prompt).toBeUndefined()
+ h.stop()
+ })
+})
diff --git a/src/core/push-notify.ts b/src/core/push-notify.ts
index ee3090e25..75bc998f8 100644
--- a/src/core/push-notify.ts
+++ b/src/core/push-notify.ts
@@ -352,6 +352,9 @@ const MAX_UPDATES_PER_CALL = 20
// Live-activity field caps (Apple content-state stays small).
const LIVE_ACTIVITY_MAX = 80
const LIVE_MESSAGE_MAX = 120
+// The `You: …` line. Same cap the mirror already applied — clipped again here because the field
+// crosses a process/network boundary and the backend caps independently.
+const LIVE_PROMPT_MAX = 120
/** One entry of the `/v1/push/live-update` `updates[]` array (backend contract). */
export interface LiveUpdateItem {
@@ -363,6 +366,9 @@ export interface LiveUpdateItem {
activity?: string
contextPercent?: number
message?: string
+ /** working START edge only: the first line of the user prompt that opened the turn — rendered as
+ * `You: …`, the same line the notch capsule shows. Omitted on every other event. */
+ prompt?: string
/** needsYou only (spec: interactive-push-live-activities addendum): 'approval' | 'question'.
* Omitted otherwise — the backend also forces null on non-needsYou content-state. */
kind?: 'approval' | 'question'
@@ -489,6 +495,9 @@ export function createLiveUpdatePush(deps: LiveUpdateDeps): LiveUpdateHandle {
// ticks' 5). The now-tick sender (emitNow) deliberately omits this.
edge: true,
...(c.message ? { message: c.message.slice(0, LIVE_MESSAGE_MAX) } : {}),
+ // The prompt rides the working start edge only (the mirror sets it there), so a needs-you or
+ // an end never carries a stale "You:" line.
+ ...(c.state === 'working' && c.prompt ? { prompt: c.prompt.slice(0, LIVE_PROMPT_MAX) } : {}),
...(needsYou && c.kind ? { kind: c.kind } : {}),
...(needsYou && c.options && c.options.length > 0 ? { options: c.options } : {}),
...(needsYou && c.multiSelect ? { multiSelect: true } : {}),