diff --git a/mod/ovis-composer/main.js b/mod/ovis-composer/main.js index e8ec1a3..6f8d5e8 100644 --- a/mod/ovis-composer/main.js +++ b/mod/ovis-composer/main.js @@ -1,18 +1,23 @@ // main.js - the composer: the visible message bar under the terminal. // // The field, the queue above it, the suggestion menu, the attachments, the -// context strip and the agent chip. What needs no GPUI lives in view.js -// (tests/main.test.mjs); the state model is state.js, the sending is -// delivery.js, the suggestions are suggest.js and catalog.js, the limits are -// attachments.js and the persistence is storage.js. +// context strip and the agent pill. What needs no GPUI lives in view.js +// (tests/view.test.mjs); the state model is state.js, the sending is +// delivery.js, the suggestions are suggest.js and catalog.js, the limits and +// the clipboard are attachments.js and clipboard.js, the history is history.js +// (drawn by panel.js) and the persistence is storage.js. // // The composer talks to one agent at a time - the focused one. Everything that // belongs to an agent (the draft, the queue, the attachments) is keyed by the // agent's address, so switching agents never mixes two of them. // -// The keyboard belongs to the composer: the terminal only shows. The field -// takes the keyboard back when it loses it, and the shortcuts that belong to -// the agent's own program (Ctrl+C, Esc) are passed on with `hc`. +// Focus follows the click: the composer never takes the keyboard on its own. +// The field has it after a click on it or after Ctrl+Shift+Space (the "focus" +// command); a click in a terminal gives the keys to that terminal. While the +// field has the keyboard its shortcuts (Enter, Ctrl+Enter, Alt+Enter, Esc, +// Ctrl+R, the arrows and Tab of the menu) are bound in the context +// `ovis-composer > Input`. The agent is stopped with the Stop button or Esc on +// an empty field (`hc interrupt`). // // `hc send` does not confirm a delivery - it pastes the text and presses // Enter. The composer says "Wysłano do terminala" and takes the confirmation @@ -927,20 +932,13 @@ export default class Composer extends View { if (handled || String(event.key).toLowerCase() === "escape") cx.stop_propagation(); } - /** - * The menu moves one row up or down. - * - * The arrows come as actions of the mod: the field binds them to the - * movement of the cursor and eats them before they reach the element. The - * cursor goes back to where the menu was opened, so the text does not move - * under the person. - */ /** * The up and down arrows. * - * With the menu open they move the menu; without it they move the cursor - * between the lines of the field - the field of this app version does not do - * that by itself. + * They come as actions of the mod: the field binds them to its own cursor + * movement and eats them before they reach the element. With the menu open + * they move the menu; without it they move the cursor between the lines of + * the field - the field of this app version does not do that by itself. */ arrow(step, cx) { if (!this.hasKeyboard) return; @@ -959,6 +957,10 @@ export default class Composer extends View { this.textarea.set_selected_range({ start: moved, end: moved }); } + /** + * The menu moves one row. The cursor goes back to where the menu was opened, + * so the text does not move under the person. + */ moveMenu(step, cx) { if (menuAction(this.hasKeyboard, this.menu, step < 0 ? "up" : "down") !== "menu") return; const menu = this.menu; @@ -1590,21 +1592,6 @@ export default class Composer extends View { }); } - /** The shortcut of the agent's own program - the keyboard here is not the terminal's. */ - passKey(agent, keys, cx) { - cx.spawn(async (cx) => { - try { - const res = await hc(["keys", agent.address, keys, "--json"]); - if (!hcOk(res)) { - this.notice(`Klawisz nie dotarł do agenta: ${resultError(res, parseJson(res.stdout))}`, "error"); - } - } catch { - // The core is gone - the key goes nowhere. - } - cx.notify(); - }); - } - // --- the suggestions ----------------------------------------------------- /** The caret sits in a `/` or `@` token - the menu looks at it. */ diff --git a/mod/ovis-composer/state.js b/mod/ovis-composer/state.js index 9a59714..b453ade 100644 --- a/mod/ovis-composer/state.js +++ b/mod/ovis-composer/state.js @@ -4,9 +4,9 @@ // never mutates the one it was given, so the model can be tested in plain Node // (tests/state.test.mjs) and reasoned about without a running app. // -// Drafts, attachments and the queue are keyed by agent name ("claude-code", -// "codex"): each belongs to the agent it was written for, and switching agents -// must not lose any of them. +// Drafts, attachments and the queue are keyed by the address of the agent +// (`AgentInfo.address`, e.g. "t2"): each belongs to the agent it was written +// for, and switching agents must not lose any of them. import { onRestart } from "./delivery.js";