Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions docs/bridge-cockpit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,8 @@ click starts one item; there is no start of several at once.

**A tab asks.** The card shows the question the tab poll read (`asks.py`) and
its answers as buttons, the same as everywhere a tab is answered: a dialog's
options (`tab_option`), yes and no, go on, a field for an answer of your own.
options (`tab_option`), yes and no, go on, a field for an answer of your own,
or, when the tab's input line holds an answer ready, only that answer (`tab_accept`).
With the decision guide on, its steps stand under them. Every answer names
the question it answers, so nothing reaches a tab that moved on; once sent,
the card leaves the queue until the tab asks anew. The right column offers no
Expand Down Expand Up @@ -3339,14 +3340,30 @@ A tab that waits shows what it asks, read off its screen, so it can be answered
- **A tab that waits** with a yes or no question (its last words end with `?`)
shows Yes and No, which type those words. Every waiting tab offers "Go on"
(not when its result is filed) and a field to type an answer, behind one click
in the sidebar.
in the sidebar. The question is the agent's last block of words (from its
last `⏺` line), never Claude Code's own lines around it: the turn's status
line (`✻ Baked for 3s`), the session recap (`※ recap: ...` with its wrapped
lines) and the hints at the right edge (`/clear to save ...`, `Update
installed · /restart to apply`).
- **A tab whose input line holds text** has an answer ready: Claude Code's own
grey suggestion for the next prompt, or words typed there; the screen cannot
tell the two apart. Its first button is that answer, labelled with its words
in quotes (`Send "yes, try the contact again"`, de: `„ja, Kontakt nochmal
versuchen“ senden`), and it presses Enter alone (`tab_accept`, with the
question's hash and the line's words: nothing goes out once either changed
on the screen read fresh). A line says so ("The tab already has an answer
ready in its input line"). Nothing that types words is offered beside it (Yes
and No as words, "Go on", the field), since the server refuses typed words
while the line holds text. Without the driver's key right, or with a line that
holds no word (`❯ #`), no button stands there; "Open tab" goes to it.
- **What a tab asks** is read by the tab poll through the driver's optional verb
`screen`: only for the tabs that wait or need you, again only when a tab's
state, last line or since-time changed or its question is a minute old, at
most four screens and three seconds per poll, the tabs that need you first. A
poll without such a tab asks the driver nothing. The question goes out with
the tabs (`tabs.tabs[].ask`: text, options, a hash, whether it reads as yes or
no, whether something is typed in the tab) and never rebuilds the briefing.
no, whether something is typed in the tab, and that text as the suggested
answer) and never rebuilds the briefing.
- **After an answer** the row stays where it stood for one more poll, greyed,
with what was answered, or "Moved on" when the tab went on by itself, so a
click never lands on the row that slid up into its place. The tab's pane on
Expand Down Expand Up @@ -3805,7 +3822,10 @@ nothing a stranger could trigger:
also refused when something is already typed in the tab's prompt, so your
words never land on half a sentence; that screen read happens for every text
answer the page sends when the driver serves `screen`, also to a tab with no
question read (a filed one). A text answer never goes into a dialog, which
question read (a filed one), and for "Go on" from a tab's own controls. The
answer a tab holds ready (`tab_accept`) types nothing: it presses Enter only
while the question of its hash and the very words of the input line still
stand on the fresh screen. A text answer never goes into a dialog, which
takes only its options (a typed digit would pick one past that check). A
refusal sends nothing and says so
("The tab moved on before the answer, nothing was sent.");
Expand Down
21 changes: 17 additions & 4 deletions docs/cockpit-demo/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,8 @@ export function tabNextStep(tab, can, settled = false) {
const closes = tabCloses(tab, can, settled)
if (tab.state === 'needs-you' && can('key')) return ['yes', 'no']
if (tab.state === 'waiting' && own && finished && closes) return ['close']
if (tab.state === 'waiting' && own && !tab.filed_by) return closes ? ['go_on', 'close'] : ['go_on']
// go on types words, which the server refuses while the input line holds text (tab_draft)
if (tab.state === 'waiting' && own && !tab.filed_by && !tab.ask?.draft) return closes ? ['go_on', 'close'] : ['go_on']
const way = can('focus') ? ['jump'] : can('screen') ? ['view'] : []
return closes ? [...way, 'close'] : way
}
Expand Down Expand Up @@ -2941,7 +2942,10 @@ export function replySend(tab, text) {
* label}], textBox }. A dialog (needs-you) gets one button per option it shows, never free text and never
* a bare yes for a choice; one that could not be read gets the tab and today's yes and no. A waiting tab
* gets yes and no as words only when it asks a yes or no question, go on unless its result is filed, and
* the text box. The control session answers through its own box. Each control needs its driver right */
* the text box. A waiting tab whose input line holds text (Claude Code's own suggestion or typed words, the
* screen cannot tell) gets only that answer, sent with Enter alone (tab_accept, with the question's hash):
* the server refuses typed words while the line holds text (tab_draft), so nothing that types is offered.
* The control session answers through its own box. Each control needs its driver right */
export function replyOptions(tab, s, t = TABLES.en) {
const none = { buttons: [], textBox: false }
if (!tab) return none
Expand All @@ -2964,7 +2968,15 @@ export function replyOptions(tab, s, t = TABLES.en) {
}
return { buttons, textBox: false }
}
if (tab.state !== 'waiting' || tab.is_control || !send) return none
if (tab.state !== 'waiting' || tab.is_control) return none
if (ask?.draft) {
const ready = typeof ask.suggestion === 'string' ? ask.suggestion.trim() : ''
if (ready && ask.hash && key) {
buttons.push({ id: 'accept', verb: 'tab_accept', label: r.accept(short(ready, 60)), args: { tab_ref: tab.ref, text: ask.suggestion, ...replyGuard(tab) } })
}
return { buttons, textBox: false }
}
if (!send) return none
if (ask?.yes_no) {
buttons.push({ id: 'yes', ...replySend(tab, r.yesText), label: r.yes })
buttons.push({ id: 'no', ...replySend(tab, r.noText), label: r.no })
Expand Down Expand Up @@ -3009,7 +3021,8 @@ export function guideChoices(tab, entry, s) {
id: `guide-${o.n}`, verb: 'tab_option', args: { tab_ref: tab.ref, n: o.n, ...replyGuard(tab) },
label: o.label, why: o.why ?? '', send: null, n: o.n, risky: !!o.risky, picked: entry.pick === i }))
}
if (!canTab(s, 'send')) return []
// typed words are refused while the input line holds text (tab_draft): the guide's answers type words
if (!canTab(s, 'send') || tab.ask?.draft) return []
return options.map((o, i) => ({ o, i })).filter(({ o }) => typeof o.send === 'string' && o.send).map(({ o, i }) => ({
id: `guide-${i}`, ...replySend(tab, o.send), label: o.label, why: o.why ?? '', send: o.send, n: null,
risky: !!o.risky, picked: entry.pick === i }))
Expand Down
8 changes: 6 additions & 2 deletions docs/cockpit-demo/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2808,19 +2808,23 @@ export function createMockTransport(opts = {}) {
}
// an answer to a tab: refused like the server when the question it names is no longer on screen
// (the third option of the dialog stands for that here) or a draft is typed in the tab
if (['tab_send', 'tab_option', 'tab_yes', 'tab_no', 'tab_go_on'].includes(verb)) {
if (['tab_send', 'tab_option', 'tab_yes', 'tab_no', 'tab_go_on', 'tab_accept'].includes(verb)) {
const tab = state.tabs.tabs.find(t => t.ref === args.tab_ref)
if (!tab || (args.seen && args.seen !== tab.ask?.hash) || (verb === 'tab_option' && args.n === 3)) {
return fail(409, 'tab_moved', 'The tab moved on before the answer, nothing was sent.')
}
if ((verb === 'tab_send' || verb === 'tab_go_on') && tab.ask?.draft) {
return fail(409, 'tab_draft', 'Something is typed in that tab, nothing was sent.')
}
// the answer the input line holds goes out only while that very line stands (actions_tabs.py v_tab_accept)
if (verb === 'tab_accept' && (tab.state !== 'waiting' || args.text !== tab.ask?.suggestion)) {
return fail(409, 'tab_moved', 'The tab moved on before the answer, nothing was sent.')
}
// a dialog takes its options, never typed words (actions.py v_tab_send)
if (verb === 'tab_send' && tab.state === 'needs-you' && (args.seen || args.expect || args.name)) {
return fail(409, 'not_applicable', 'A dialog takes its options, not text.')
}
const said = verb === 'tab_option' ? tab.ask?.options.find(o => o.n === args.n)?.label : verb === 'tab_send' ? args.text : verb
const said = verb === 'tab_option' ? tab.ask?.options.find(o => o.n === args.n)?.label : verb === 'tab_send' || verb === 'tab_accept' ? args.text : verb
result.note = `Mock: ${tab.name}: ${said}`
}
// a start from the chat answers with its inbox item and the launch outcome (actions.py v_chat_tab)
Expand Down
8 changes: 6 additions & 2 deletions docs/cockpit-demo/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,9 @@ const en = {
answeredWord: 'answered',
unreadable: 'It waits, its question cannot be read here',
openTab: 'Open tab',
draft: 'Something is typed in that tab',
draft: 'The tab already has an answer ready in its input line',
typed: 'Something is typed in that tab',
accept: s => `Send "${s}"`,
},
hints: {
button: 'Explain',
Expand Down Expand Up @@ -2889,7 +2891,9 @@ const de = {
answeredWord: 'beantwortet',
unreadable: 'Er wartet, die Frage ist hier nicht lesbar',
openTab: 'Tab öffnen',
draft: 'Im Tab steht ein Entwurf',
draft: 'Im Tab steht schon eine vorgeschlagene Antwort bereit',
typed: 'Im Tab ist schon etwas eingetippt',
accept: s => `„${s}“ senden`,
},
hints: {
button: 'Erklären',
Expand Down
2 changes: 1 addition & 1 deletion docs/cockpit-demo/views/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export function TabControls({ tab, s, c, compact = false, slim = false }) {
${tab.state === 'needs-you' && canTab(s, 'key') ? html`
<${Btn} size="xs" variant="primary" busy=${busy} onClick=${() => c.act('tab_yes', { tab_ref: tab.ref })}>${t.btnYes}<//>
<${Btn} size="xs" variant="secondary" busy=${busy} onClick=${() => c.act('tab_no', { tab_ref: tab.ref })}>${t.btnNo}<//>` : null}
${tab.state === 'waiting' && !tab.filed_by && !settled && !tab.is_control ? html`<${Btn} size="xs" variant="secondary" busy=${busy}
${tab.state === 'waiting' && !tab.filed_by && !settled && !tab.is_control && !tab.ask?.draft ? html`<${Btn} size="xs" variant="secondary" busy=${busy}
onClick=${() => c.act('tab_go_on', { tab_ref: tab.ref })}>${t.btnGoOn}<//>` : null}
<${TabClose} tab=${tab} s=${s} c=${c} strong />
${canTab(s, 'focus') ? html`<${Btn} size="xs" variant="ghost" busy=${busy} onClick=${() => c.act('tab_jump', { tab_ref: tab.ref })}>${t.btnToTab}<//>` : null}
Expand Down
5 changes: 3 additions & 2 deletions docs/cockpit-demo/views/reply.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: MIT
// The cockpit, what a waiting tab asks and the answers to it from the page: the question as the tab
// poll read it off the tab's screen (asks.py), and one button per option of a dialog, yes and no for a
// yes or no question, go on and a text field. Every answer names the question it answers, the tab's name
// yes or no question, go on and a text field; a tab whose input line holds an answer ready gets that answer
// alone, sent with Enter (tab_accept). Every answer names the question it answers, the tab's name
// and its state, and the server sends nothing once the tab moved on (actions.py guard_fresh).
// The rules every component keeps stand at the head of components.js.

Expand Down Expand Up @@ -61,7 +62,7 @@ export function TabReply({ tab, s, c, compact = false, bare = false, noJump = fa
const opener = withText && !open ? html`<button type="button" class="btn btn-ghost btn-xs" aria-expanded="false" aria-controls=${id}
onClick=${() => { focus.current = true; setOpen(true) }}><span class="btn-label">${t.reply.placeholder}</span></button>` : null
return html`<div class="reply">
${tab.ask?.draft ? html`<p class="reply-draft muted small">${t.reply.draft}</p>` : null}
${tab.ask?.draft ? html`<p class="reply-draft muted small">${tab.ask.suggestion ? t.reply.draft : t.reply.typed}</p>` : null}
${shown.length || opener ? html`<div class="btn-row reply-btns">
${shown.map((b, i) => html`<${Btn} key=${b.id} size="xs" variant=${b.verb === 'tab_jump' ? 'ghost' : i === 0 ? 'primary' : 'secondary'}
busy=${busy} title=${b.label} onClick=${() => answer(b.verb, b.args, b.label)}>${b.label}<//>`)}
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/bridge_cockpit/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
launch_settings launch_settings_reset organize_apply organize_propose pin quick_forget quick_handoff
seen_focus seen_read seen_unread
return_analyse return_forget return_read return_task return_task_undo return_unread row_action row_undo run_seen runs_on session_link session_resume session_unlink shelve snapshot
snapshot_list start_agent start_control tab_close tab_done tab_go_on tab_jump tab_keys tab_move tab_new tab_no
snapshot_list start_agent start_control tab_accept tab_close tab_done tab_go_on tab_jump tab_keys tab_move tab_new tab_no
tab_option tab_rename tab_send tab_yes task_keep task_reopen task_review task_running task_unmerge team_role
ticker_edit ticker_profile ticker_refresh ticker_settings ticker_settings_reset timeline_ask to_task
to_task_undo tour_done tour_reset unhide worker_advise workspace_active workspace_close workspace_delete
Expand Down
5 changes: 4 additions & 1 deletion scripts/lib/bridge_cockpit/actions_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"tab_send": {"tab_ref": ("tab_ref", True), "text": ("text", True), "seen": ("ask_hash", False),
"expect": ("tab_state", False), "name": ("tab_name", False)},
"tab_go_on": {"tab_ref": ("tab_ref", True), "seen": ("ask_hash", False), "name": ("tab_name", False)},
# the answer a waiting tab holds ready in its input line goes out with Enter alone, only while that very line
# (text) and the question (seen) stand on its screen read now
"tab_accept": {"tab_ref": ("tab_ref", True), "seen": ("ask_hash", True), "text": ("text", True), "name": ("tab_name", False)},
"tab_close": {"tab_ref": ("tab_ref", True)},
# the task and the inbox item behind a tab end as Done does (settle), then the tab closes (actions_tabs.py)
"tab_done": {"tab_ref": ("tab_ref", True), "by": ("by", False)},
Expand Down Expand Up @@ -311,7 +314,7 @@
LAYOUT_VERBS = frozenset({"snapshot"})
# saving the layout is cmux's own feature; steering a tab goes through the terminal driver and needs its verb
CMUX_VERBS = frozenset({"snapshot", "snapshot_list"})
NEEDS_CAP = {"tab_yes": "key", "tab_no": "key", "tab_option": "key", "tab_keys": "keys", "tab_jump": "focus", "tab_close": "close", "tab_done": "close",
NEEDS_CAP = {"tab_yes": "key", "tab_accept": "key", "tab_no": "key", "tab_option": "key", "tab_keys": "keys", "tab_jump": "focus", "tab_close": "close", "tab_done": "close",
"tab_rename": "rename", "workspace_rename": "rename_workspace", "tab_move": "move_tab", "tab_new": "new_tab",
"workspace_new": "new_workspace", "workspace_close": "close_workspace"}

Expand Down
25 changes: 22 additions & 3 deletions scripts/lib/bridge_cockpit/actions_tabs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: MIT
"""Verbs on agent tabs through the terminal driver: adopt, press, answer an option, send, jump, close, done and close
"""Verbs on agent tabs through the terminal driver: adopt, press, answer an option, accept the answer a tab holds ready,
send, jump, close, done and close
(what stands behind the tab ends as Done does, then the tab closes), rename a
tab or a workspace, a new tab, a new workspace and a workspace closed, organize with AI, the control tab, the layout
snapshot, and a relay question handed to the control tab.
Expand Down Expand Up @@ -158,10 +159,28 @@ def v_tab_go_on(self, ctx: Ctx, tab_ref: str, seen: str | None = None, name: str
tab = self.tab(tab_ref)
if tab["state"] != "waiting" or m.filed_by(tab, self.app.collector.view) is not None:
raise self.not_applicable("go on is for waiting tabs without a filed result", "tab_ref")
if seen is not None or name is not None:
tab, _ = self.guard_fresh(ctx, tab_ref, "waiting", seen, name, True)
# always guarded: go on types words, which would land on a draft in the input line (TabControls sends no seen)
tab, _ = self.guard_fresh(ctx, tab_ref, "waiting", seen, name, True)
self.send_to(ctx, tab, self.tx["go_on"])

def v_tab_accept(self, ctx: Ctx, tab_ref: str, seen: str, text: str, name: str | None = None) -> None:
"""The answer a waiting tab holds ready in its input line (Claude Code's own suggestion, or words typed
there; the screen cannot tell them apart): Enter alone, nothing typed. Only while the question of `seen`
and that very line stand on the screen read now (guard_fresh, asks.question_of suggestion)."""
tab = self.tab(tab_ref)
if tab["state"] != "waiting" or not m.is_live(tab) or tab_ref == self.app.tabs.control_ref():
raise self.not_applicable("only a waiting agent tab holds an answer ready", "tab_ref")
tab, fresh = self.guard_fresh(ctx, tab_ref, "waiting", seen, name, False)
if not fresh or fresh.get("suggestion") != text:
raise ActionError(409, "tab_moved", self.tx["tab_moved"], None)
said = self.tx["said_accept"].format(text=m.short(text, 60))
run = ctx.call("workplace.key", tab_ref, self.app.workplace("key", tab_ref, "enter"), CMUX_TIMEOUT)
if run.ok:
ctx.note(self.tx["key_sent"].format(name=m.short(tab["name"], 30), said=said), go={"kind": "tab", "ref": tab_ref})
else:
ctx.note(self.tx["key_failed"].format(err=m.short((run.err or run.out).strip(), 100)), bad=True)
ctx.tabs_after(3)

def closable(self, tab_ref: str) -> dict:
"""The tab, when it may close: it neither works nor asks (waiting at its prompt with no question, options or
draft read off its screen, model.asks_something, or back at its shell; a settled one asks nothing any more, as the quiet rule has it, model.py is_idle)
Expand Down
Loading
Loading