Review fixes: a refused call is announced over ACP; dictation keeps a placeholder
ci / check (push) Canceled after 0s
ci / check (push) Canceled after 0s
A denied call was sent as a tool_call_update of an id no plain ACP client had been given (the approval card carries its own), which a client drops: it is one tool_call, failed, with its title, arguments and reason, and _meta.lembas.denied. acp.md says so. Dictated text is inserted at the end of the box instead of setting its whole text, which dropped every paste placeholder. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
6 files changed
+46
-10
No files matched your search
@@ -66,6 +66,10 @@ Harness spec 3.7.0: one display in every client.
|
||||
- **Completing an `@file` or moving through the prompt box now counts columns as the box does**:
|
||||
with a wide character (CJK, an emoji) before the cursor, the `@` list could replace the wrong
|
||||
part of the line.
|
||||
- **A refused tool call reaches a plain ACP client** (an editor): it was sent as an update of a
|
||||
call the client had never been told about, which a client drops; it is now announced as a failed
|
||||
call, with its title and the reason.
|
||||
- **Dictating into a box that holds a paste placeholder** keeps the placeholder.
|
||||
- **Plainer refusals when a terminal or a folder cannot be used**: each says what to do —
|
||||
`lembas remote terminal on`, `lembas remote add <dir>`, close one of the open terminals.
|
||||
|
||||
|
||||
+3
-2
@@ -223,8 +223,9 @@ Params: `{ sessionId }`. Stops the running turn.
|
||||
|
||||
From spec 3.7.0 a `tool_call`'s `title` is **the call's short title** (`display.md` §1) — the
|
||||
tool's name where the call has none — and no `tool_call_update` changes it: `completed` is the
|
||||
state `done`, `failed` is `failed`, and a call that was refused is `failed` with
|
||||
`_meta.lembas.denied: true` and the reason as its content (the state `denied`). The same title is
|
||||
state `done`, `failed` is `failed`, and a call that was refused — it never started, so nothing
|
||||
announced it — is one `tool_call` with status `failed`, `_meta.lembas.denied: true` and the reason
|
||||
as its content (the state `denied`). The same title is
|
||||
`title` on the `tool_start` event of `_lembas/event` and `what` of `running_tool`; `tool_end`
|
||||
carries `ms`, the call's duration, and `tool_denied` its `reason`. A client of `_lembas/event`
|
||||
that is given no `title` (a device before 3.7.0) makes it from `args` by the same rule.
|
||||
|
||||
+7
-2
@@ -1455,11 +1455,16 @@ export class AcpAgent {
|
||||
case "tool_denied":
|
||||
// Refused, not run: `failed` to a plain ACP client, `denied` to one that reads _meta.lembas.
|
||||
// Refused, not run: `failed` to a plain ACP client, `denied` to one that reads _meta.lembas.
|
||||
// A refused call never started, so no tool_call announced it (the approval card, if one
|
||||
// was shown, has an id of its own): this is the call's first and only update, and an
|
||||
// update of an id nobody knows would be dropped.
|
||||
return this.update(s, {
|
||||
sessionUpdate: "tool_call_update",
|
||||
sessionUpdate: "tool_call",
|
||||
toolCallId: e.id,
|
||||
title: e.title ?? e.name,
|
||||
kind: toolKind(e.name),
|
||||
status: "failed",
|
||||
...(e.title ? { title: e.title } : {}),
|
||||
...(e.args !== undefined ? { rawInput: e.args } : {}),
|
||||
content: [{ type: "content", content: { type: "text", text: e.reason } }],
|
||||
_meta: { lembas: { denied: true } },
|
||||
})
|
||||
|
||||
+6
-3
@@ -217,9 +217,12 @@ export function Root(p: { app: Runtime; view: View; theme: Theme; onQuit: () =>
|
||||
// Sent as words, never as a command: a transcript that starts with "/" or "!" is still speech.
|
||||
if (voiceCfg?.submit === "send" && app.turns.steer(text)) return
|
||||
if (voiceCfg?.submit === "send" && !busy()) return void send(text)
|
||||
const now = input?.plainText ?? ""
|
||||
input?.setText(now.trim() ? `${now.replace(/\s+$/, "")} ${text}` : text)
|
||||
input?.gotoBufferEnd()
|
||||
if (!input) return
|
||||
// Added at the end, not by setting the whole text: that would turn a paste placeholder in
|
||||
// the box into its bare label and lose what it stands for.
|
||||
const now = input.plainText
|
||||
input.gotoBufferEnd()
|
||||
input.insertText(now.trim() && !/\s$/.test(now) ? ` ${text}` : text)
|
||||
},
|
||||
notice: (m, warn) => view.info(m, warn ? "warn" : undefined),
|
||||
})
|
||||
|
||||
+6
-3
@@ -126,7 +126,7 @@ test("an approval is asked of the client, and its answer decides", async () => {
|
||||
expect(done.status).toBe("completed")
|
||||
expect(done.content[0].content.text).toContain("approved-run")
|
||||
await c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "again" }] })
|
||||
const refused = updates.find((u) => u.sessionUpdate === "tool_call_update" && u.toolCallId === "t2")
|
||||
const refused = updates.find((u) => u.sessionUpdate === "tool_call" && u.toolCallId === "t2")
|
||||
expect(refused.status).toBe("failed")
|
||||
expect(asked).toBe(2)
|
||||
})
|
||||
@@ -330,9 +330,12 @@ test("an approval nobody answers is a denial", async () => {
|
||||
const { c, updates } = await client({ roots: [root], maxMode: "manual", approvalTimeoutMs: 50, requireTrust: true }, () => new Promise(() => {}))
|
||||
const s: any = await c.request("session/new", { cwd: root })
|
||||
await c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "x" }] })
|
||||
const u = updates.find((x) => x.sessionUpdate === "tool_call_update" && x.toolCallId === "t1")
|
||||
// Refused, not run (spec 3.7.0 display.md): the call is announced once, failed and marked
|
||||
// denied, under its one title — not as an update of a call no client was told about.
|
||||
expect(updates.some((x) => x.sessionUpdate === "tool_call_update" && x.toolCallId === "t1")).toBe(false)
|
||||
const u = updates.find((x) => x.sessionUpdate === "tool_call" && x.toolCallId === "t1")
|
||||
expect(u.status).toBe("failed")
|
||||
// Refused, not run (spec 3.7.0 display.md): marked denied, under the call's one title.
|
||||
expect(u.rawInput).toEqual({ command: "echo never", description: "x" })
|
||||
expect(u._meta.lembas.denied).toBe(true)
|
||||
expect(u.title).toBe("echo never")
|
||||
expect(fake.requests[1].messages.at(-1).content).toContain("Nobody answered")
|
||||
|
||||
@@ -309,3 +309,23 @@ test("over SSH in kitty: ctrl+v asks the terminal for its clipboard, and the ima
|
||||
expect(asked.length).toBe(2)
|
||||
})
|
||||
})
|
||||
|
||||
test("what is dictated is added after a placeholder, which still stands for its text", async () => {
|
||||
const stt = Bun.serve({ port: 0, fetch: () => Response.json({ text: "Explain this." }) })
|
||||
const mic = join(import.meta.dir, "..", "fixtures", "voice", "mic.ts")
|
||||
try {
|
||||
t = await tui([{ chunks: [delta({ content: "Explained." }), usage(100, 5)] }], { width: 100, height: 30 }, `voice:\n stt: { base_url: "http://127.0.0.1:${stt.port}/v1" }\n recorder_command: ["${process.execPath}", "${mic}", "1"]\n silence_seconds: 0.4\n`)
|
||||
const a = box(t.setup.renderer.root)
|
||||
await t.input.pasteBracketedText(LONG)
|
||||
await t.settle()
|
||||
t.input.pressKey("t", { ctrl: true })
|
||||
const end = Date.now() + 8000
|
||||
while (Date.now() < end && !a.plainText.includes("Explain this.")) await t.settle(40)
|
||||
expect(a.plainText).toBe("[Pasted text 4 lines] Explain this.")
|
||||
t.input.pressEnter()
|
||||
expect(await t.until("Explained.")).toBe(true)
|
||||
expect(sent()).toContain("first line\\nsecond line\\nthird line\\nfourth line Explain this.")
|
||||
} finally {
|
||||
void stt.stop(true)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user