@dudko.dev/agent-web-react 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -845,7 +845,7 @@ use them standalone. The full guide: [docs/chat.md](docs/chat.md).
845
845
  | Component | Purpose |
846
846
  | --- | --- |
847
847
  | `<AgentChat>` | Full panel: transcript with per-answer activity + composer + optional history and files panels. Reads a `controller` prop or the `<AgentProvider>` context. Says when the conversation runs in another tab of the site, waits for an answer there, or waits for it (`showOtherTabs`). |
848
- | `<AgentComposer>` | The input and its toolbar: attachments, commands, timer, agents, model/thinking, consent, mic, send/stop. |
848
+ | `<AgentComposer>` | The input and its toolbar: attachments, commands, timer, agents, model/thinking, consent, mic, send/stop. The model menu takes `section` per option (a heading over each run of options, e.g. one per provider); both chip menus work from the keyboard (arrows, Home / End, Escape) - see [docs/chat.md](docs/chat.md#the-model-menu-sections-and-keys). |
849
849
  | `<MessageList>` | The transcript; each answer with its steps, tool calls, thoughts, usage. |
850
850
  | `<StepList>` / `<ToolCallRow>` | Execution steps / one tool call with its cost and images. With model tiers: the tier / model badge, the escalation line, the earlier attempt's calls (`showTiers`); a replanner failure as a warning (`showReplanFailed`); the decision model's note (`showDecisions`); the subagent tree under its step (`showSubagents`); a `web_search` call's results as plain text and safe links (`showSearchResults`). |
851
851
  | `<SubagentTree>` / `<SubagentRow>` | The run's subagents - static ones and the helpers the model started - as an indented tree: status, model, tokens, time and a Stop button per node (`onStop`, `showUsage`, `showTools`, `renderSubagent`). |
@@ -948,7 +948,8 @@ The state is made of plain, exported view types you can render with your own com
948
948
  `StepView` (a step and its `ToolCallView`s; `StepEscalationView` for its escalations), `ApprovalView`, `ElicitationView` (a question an MCP server put to the user in the middle of a tool call - `state.elicitations`, see below), `SubagentView`, `UserNoteView` /
949
949
  `QueuedMessageView` (steering), `LessonView` / `FetchView` (the notebook and the pages fetched),
950
950
  `BudgetView`, `CompactionView`, `AttachmentView`, `ChatMessage` (a transcript entry that keeps its
951
- own steps, usage and duration). Outside `<AgentChat>`, `useAgentContext()` returns the controller of
951
+ own steps, usage and duration; `stopped` on an answer whose run was stopped - with no text, the chat
952
+ shows the `answerStopped` label: the state holds no UI text). Outside `<AgentChat>`, `useAgentContext()` returns the controller of
952
953
  the enclosing `<AgentProvider>` (it throws outside one; `useOptionalAgentContext()` returns
953
954
  `undefined` instead), and `useLabels()` the labels in effect.
954
955
 
@@ -981,14 +982,19 @@ the hooks keep them in step, with nothing to configure beyond a shared `memory`
981
982
  chat is read again from what that tab saved. `watch: false` switches this off.
982
983
  - **One run per conversation.** A run started here while the conversation runs elsewhere waits
983
984
  for it (`sessionBusy`, "Waiting for the other tab to finish this conversation…", the goal shown
984
- queued) and then goes, with that turn in the agent's memory; a saved chat keeps both turns, in
985
- order (`saveChat`: one transaction, merged by message identity).
985
+ queued - "waiting for the other tab to finish", `queuedForSession`, its `queued` entry marked
986
+ `session`, while the wait lasts) and then goes, with that turn in the agent's memory; a saved chat
987
+ keeps both turns, in order (`saveChat`: one transaction, merged by message identity).
988
+ - **Another tab deletes or upgrades the database** ("delete everything", a newer copy of the site):
989
+ `ChatHistoryStore` closes its connection on `versionchange`, like the core's stores, so that tab is
990
+ not held up; the next use opens a new, empty database (after an upgrade by a newer copy, an error
991
+ until a reload).
986
992
  - **What another tab changed appears here without a reload:** a key in the vault
987
993
  (`useCredentials().version`), the files (`useVirtualFiles`), the saved chats (`useChatHistory`),
988
994
  the agent's notebook (`learned`, through `agent.reloadLearnedSkills()`).
989
995
 
990
996
  `<AgentChat>` shows the notes above the composer (`showOtherTabs`; labels `remoteRunning`,
991
- `remoteWaitingConsent`, `remoteGone`, `sessionBusy`, `fromAnotherTab`). Details: [docs/chat.md](docs/chat.md#several-tabs).
997
+ `remoteWaitingConsent`, `remoteGone`, `sessionBusy`, `queuedForSession`, `fromAnotherTab`). Details: [docs/chat.md](docs/chat.md#several-tabs).
992
998
 
993
999
  ## How it fits together
994
1000
 
@@ -1,4 +1,4 @@
1
- import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
1
+ import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent } from '@dudko.dev/agent-web';
2
2
 
3
3
  /**
4
4
  * MCP Apps, the host's side: the security core of `<McpAppFrame>`, as pure code - no React, no
@@ -918,6 +918,13 @@ interface ChatMessage {
918
918
  apps?: AppView[];
919
919
  /** Assistant turn ended with an error. */
920
920
  error?: boolean;
921
+ /**
922
+ * Assistant turn: the run was stopped (by the user, here or in another tab) before it was done.
923
+ * `content` is what it had written by then - `''` when nothing: the chat shows the
924
+ * `answerStopped` label in its place (the reducer keeps no UI text). A chat saved before this
925
+ * existed has the old `'Stopped.'` as its content, and shows that.
926
+ */
927
+ stopped?: true;
921
928
  }
922
929
  /** A single tool call as it appears in a step, streamed then finalized. */
923
930
  interface ToolCallView {
@@ -1208,6 +1215,13 @@ interface QueuedMessageView {
1208
1215
  text: string;
1209
1216
  /** Another tab of the site sent it to this run (the core's session relay). */
1210
1217
  origin?: 'another-tab';
1218
+ /**
1219
+ * What the user sent waits with a run of this tab's that waits for the SESSION (`sessionBusy`):
1220
+ * the other run of the conversation holds it - in another tab, or in this one. The entry is
1221
+ * there only while that wait lasts (the run then starts with it); the chat shows
1222
+ * `queuedForSession` for it, not `queuedWaiting`.
1223
+ */
1224
+ session?: SessionHolder;
1211
1225
  }
1212
1226
  /**
1213
1227
  * A message the user sent while the run was going, after it reached the agent.
@@ -1,4 +1,4 @@
1
- import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
1
+ import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent } from '@dudko.dev/agent-web';
2
2
 
3
3
  /**
4
4
  * MCP Apps, the host's side: the security core of `<McpAppFrame>`, as pure code - no React, no
@@ -918,6 +918,13 @@ interface ChatMessage {
918
918
  apps?: AppView[];
919
919
  /** Assistant turn ended with an error. */
920
920
  error?: boolean;
921
+ /**
922
+ * Assistant turn: the run was stopped (by the user, here or in another tab) before it was done.
923
+ * `content` is what it had written by then - `''` when nothing: the chat shows the
924
+ * `answerStopped` label in its place (the reducer keeps no UI text). A chat saved before this
925
+ * existed has the old `'Stopped.'` as its content, and shows that.
926
+ */
927
+ stopped?: true;
921
928
  }
922
929
  /** A single tool call as it appears in a step, streamed then finalized. */
923
930
  interface ToolCallView {
@@ -1208,6 +1215,13 @@ interface QueuedMessageView {
1208
1215
  text: string;
1209
1216
  /** Another tab of the site sent it to this run (the core's session relay). */
1210
1217
  origin?: 'another-tab';
1218
+ /**
1219
+ * What the user sent waits with a run of this tab's that waits for the SESSION (`sessionBusy`):
1220
+ * the other run of the conversation holds it - in another tab, or in this one. The entry is
1221
+ * there only while that wait lasts (the run then starts with it); the chat shows
1222
+ * `queuedForSession` for it, not `queuedWaiting`.
1223
+ */
1224
+ session?: SessionHolder;
1211
1225
  }
1212
1226
  /**
1213
1227
  * A message the user sent while the run was going, after it reached the agent.
package/dist/index.cjs CHANGED
@@ -176,6 +176,8 @@ __export(src_exports, {
176
176
  mcpAppSandboxShellCsp: () => mcpAppSandboxShellCsp,
177
177
  mcpAppSandboxTarget: () => mcpAppSandboxTarget,
178
178
  mediaFamilyOf: () => mediaFamilyOf,
179
+ menuKeyTarget: () => menuKeyTarget,
180
+ menuSections: () => menuSections,
179
181
  mergeChatRecord: () => mergeChatRecord,
180
182
  mergeLabels: () => mergeLabels,
181
183
  newChatId: () => newChatId,
@@ -1394,7 +1396,7 @@ var applyEvent = (state, event, ctx) => {
1394
1396
  ...ctx.goal ? {
1395
1397
  queued: [
1396
1398
  ...state.queued.filter((q) => q.id !== WAITING_ID),
1397
- { id: WAITING_ID, text: ctx.goal }
1399
+ { id: WAITING_ID, text: ctx.goal, session: event.heldBy }
1398
1400
  ]
1399
1401
  } : {}
1400
1402
  };
@@ -1422,11 +1424,11 @@ var applyEvent = (state, event, ctx) => {
1422
1424
  (q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
1423
1425
  )
1424
1426
  } : {},
1425
- messages: finalizeAssistant(
1426
- state.messages,
1427
- state.finalText || "Stopped.",
1428
- runDuration(state, ctx.at)
1429
- )
1427
+ // What it had written, or nothing - the chat says "stopped" through its labels.
1428
+ messages: finalizeAssistant(state.messages, state.finalText, {
1429
+ ...runDuration(state, ctx.at),
1430
+ stopped: true
1431
+ })
1430
1432
  };
1431
1433
  case "error":
1432
1434
  if (event.phase === "replan") {
@@ -2042,21 +2044,43 @@ var ChatHistoryStore = class {
2042
2044
  if (opts.memory || typeof indexedDB === "undefined") this.memory = /* @__PURE__ */ new Map();
2043
2045
  this.dbName = this.memory ? void 0 : this.name;
2044
2046
  }
2047
+ /**
2048
+ * The store's connection, opened on first use. Never in another tab's way: when another
2049
+ * connection asks to delete or upgrade the database (`versionchange` - another tab's
2050
+ * `indexedDB.deleteDatabase`, a newer copy of this package), it is closed at once, so that
2051
+ * request goes ahead instead of waiting for this tab to close; one the browser closed by itself
2052
+ * (site data cleared) is let go too. The next use opens the database again - after a deletion a
2053
+ * new, empty one (no chats: `list()` is empty, a save starts it again); after an upgrade by a
2054
+ * newer copy, the open fails until the page is reloaded with that copy.
2055
+ */
2045
2056
  open() {
2046
- this.db ??= new Promise((resolve, reject) => {
2057
+ if (this.db) return this.db;
2058
+ const opening = new Promise((resolve, reject) => {
2047
2059
  const r = indexedDB.open(this.name, DB_VERSION);
2048
2060
  r.onupgradeneeded = () => {
2049
2061
  if (!r.result.objectStoreNames.contains(this.storeName)) {
2050
2062
  r.result.createObjectStore(this.storeName, { keyPath: "id" });
2051
2063
  }
2052
2064
  };
2053
- r.onsuccess = () => resolve(r.result);
2065
+ r.onsuccess = () => {
2066
+ const db = r.result;
2067
+ const forget = () => {
2068
+ if (this.db === opening) this.db = void 0;
2069
+ };
2070
+ db.addEventListener("versionchange", () => {
2071
+ forget();
2072
+ db.close();
2073
+ });
2074
+ db.addEventListener("close", forget);
2075
+ resolve(db);
2076
+ };
2054
2077
  r.onerror = () => reject(r.error);
2055
2078
  }).catch((err) => {
2056
- this.db = void 0;
2079
+ if (this.db === opening) this.db = void 0;
2057
2080
  throw err;
2058
2081
  });
2059
- return this.db;
2082
+ this.db = opening;
2083
+ return opening;
2060
2084
  }
2061
2085
  async tx(mode) {
2062
2086
  const db = await this.open();
@@ -2699,6 +2723,31 @@ var attachmentRefusal = (kind, caps, canConvertPdf = false) => {
2699
2723
  }
2700
2724
  return void 0;
2701
2725
  };
2726
+ var menuSections = (options) => {
2727
+ const out = [];
2728
+ for (const option of options) {
2729
+ const section = option.section || void 0;
2730
+ const last = out[out.length - 1];
2731
+ if (last && last.section === section) last.options.push(option);
2732
+ else out.push({ ...section ? { section } : {}, options: [option] });
2733
+ }
2734
+ return out;
2735
+ };
2736
+ var menuKeyTarget = (key, index, count) => {
2737
+ if (count <= 0) return void 0;
2738
+ switch (key) {
2739
+ case "ArrowDown":
2740
+ return index < 0 ? 0 : (index + 1) % count;
2741
+ case "ArrowUp":
2742
+ return index < 0 ? count - 1 : (index - 1 + count) % count;
2743
+ case "Home":
2744
+ return 0;
2745
+ case "End":
2746
+ return count - 1;
2747
+ default:
2748
+ return void 0;
2749
+ }
2750
+ };
2702
2751
  var formatElapsed = (ms) => {
2703
2752
  const s = Math.max(0, Math.floor(ms / 1e3));
2704
2753
  if (s < 60) return `${s}s`;
@@ -2769,6 +2818,7 @@ var defaultLabels = {
2769
2818
  fetches: (n) => plural(n, "web request", "web requests"),
2770
2819
  fetchRefused: (reason) => `refused: ${reason}`,
2771
2820
  answerThoughts: "Thinking about the answer",
2821
+ answerStopped: "Stopped.",
2772
2822
  stepThoughts: "Thoughts",
2773
2823
  usageTitle: "Tokens this answer spent, by kind",
2774
2824
  attachments: "Attachments",
@@ -2859,6 +2909,7 @@ var defaultLabels = {
2859
2909
  steer: "Send to the agent",
2860
2910
  noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
2861
2911
  queuedWaiting: "waiting for the agent\u2019s next step",
2912
+ queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
2862
2913
  noteAt: {
2863
2914
  round: "you said, between tool calls",
2864
2915
  step: "you said, after this step",
@@ -5509,6 +5560,34 @@ var thinkingDefaults = (l) => [
5509
5560
  ];
5510
5561
  var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
5511
5562
  var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EyeIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ShieldIcon, { size: 14 });
5563
+ var useMenuKeys = (open, menuRef, chipRef, close) => {
5564
+ (0, import_react12.useEffect)(() => {
5565
+ if (!open) return;
5566
+ const menu = menuRef.current;
5567
+ const rows = menu ? [...menu.querySelectorAll('[role^="menuitem"]')] : [];
5568
+ (rows.find((r) => r.getAttribute("aria-checked") === "true") ?? rows[0])?.focus();
5569
+ }, [open, menuRef]);
5570
+ return (e) => {
5571
+ const menu = menuRef.current;
5572
+ if (!menu) return;
5573
+ if (e.key === "Escape") {
5574
+ e.preventDefault();
5575
+ close();
5576
+ chipRef.current?.focus();
5577
+ return;
5578
+ }
5579
+ const rows = [...menu.querySelectorAll('[role^="menuitem"]')];
5580
+ const to = menuKeyTarget(
5581
+ e.key,
5582
+ rows.indexOf(document.activeElement),
5583
+ rows.length
5584
+ );
5585
+ if (to === void 0) return;
5586
+ e.preventDefault();
5587
+ rows[to].focus();
5588
+ };
5589
+ };
5590
+ var opensMenu = (key) => key === "ArrowDown" || key === "ArrowUp";
5512
5591
  var attachSeq = 0;
5513
5592
  var useIsoLayoutEffect3 = typeof window === "undefined" ? import_react12.useEffect : import_react12.useLayoutEffect;
5514
5593
  var useMenuPlacement = (open, anchor, align) => {
@@ -5600,6 +5679,10 @@ var AgentComposer = ({
5600
5679
  const rootRef = (0, import_react12.useRef)(null);
5601
5680
  const modelRef = (0, import_react12.useRef)(null);
5602
5681
  const modeRef = (0, import_react12.useRef)(null);
5682
+ const modelChipRef = (0, import_react12.useRef)(null);
5683
+ const modeChipRef = (0, import_react12.useRef)(null);
5684
+ const modelMenuRef = (0, import_react12.useRef)(null);
5685
+ const modeMenuRef = (0, import_react12.useRef)(null);
5603
5686
  const [dropRect, setDropRect] = (0, import_react12.useState)();
5604
5687
  const [compactBar, setCompactBar] = (0, import_react12.useState)(false);
5605
5688
  (0, import_react12.useEffect)(() => {
@@ -5728,6 +5811,9 @@ ${draftText}` : draftText);
5728
5811
  const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
5729
5812
  const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
5730
5813
  const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
5814
+ const closeMenu = () => setMenu(void 0);
5815
+ const modelMenuKeys = useMenuKeys(menu === "model", modelMenuRef, modelChipRef, closeMenu);
5816
+ const modeMenuKeys = useMenuKeys(menu === "mode", modeMenuRef, modeChipRef, closeMenu);
5731
5817
  (0, import_react12.useEffect)(() => setActive(0), [text2, menu]);
5732
5818
  (0, import_react12.useEffect)(() => {
5733
5819
  if (!menu) return;
@@ -6006,7 +6092,7 @@ ${draftText}` : draftText);
6006
6092
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClockIcon, { size: 13, className: "awr-queued__icon" }),
6007
6093
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__text", title: q.text, children: q.text }),
6008
6094
  q.origin === "another-tab" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
6009
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: L.queuedWaiting })
6095
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
6010
6096
  ] }, q.id)),
6011
6097
  agent.undelivered.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
6012
6098
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AlertIcon, { size: 13, className: "awr-queued__icon" }),
@@ -6185,8 +6271,15 @@ ${draftText}` : draftText);
6185
6271
  "button",
6186
6272
  {
6187
6273
  type: "button",
6274
+ ref: modelChipRef,
6188
6275
  className: "awr-tchip awr-tchip--btn",
6189
6276
  onClick: () => setMenu(menu === "model" ? void 0 : "model"),
6277
+ onKeyDown: (e) => {
6278
+ if (menu !== "model" && opensMenu(e.key)) {
6279
+ e.preventDefault();
6280
+ setMenu("model");
6281
+ }
6282
+ },
6190
6283
  "aria-haspopup": "menu",
6191
6284
  "aria-expanded": menu === "model",
6192
6285
  title: [model?.label, thinkingLabel].filter(Boolean).join(" \xB7 "),
@@ -6196,47 +6289,81 @@ ${draftText}` : draftText);
6196
6289
  ]
6197
6290
  }
6198
6291
  ),
6199
- menu === "model" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-menu awr-menu--pop", style: modelStyle, role: "menu", children: [
6200
- thinking && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6201
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.thinking }),
6202
- thinkingOptions.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6203
- "button",
6204
- {
6205
- type: "button",
6206
- role: "menuitemradio",
6207
- "aria-checked": thinking.value === o.id,
6208
- className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
6209
- onClick: () => {
6210
- thinking.onChange(o.id);
6211
- setMenu(void 0);
6212
- },
6213
- children: o.label
6214
- },
6215
- o.id
6216
- ))
6217
- ] }),
6218
- model?.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6219
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.model }),
6220
- model.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6221
- "button",
6222
- {
6223
- type: "button",
6224
- role: "menuitemradio",
6225
- "aria-checked": model.value === o.id,
6226
- className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
6227
- onClick: () => {
6228
- model.onSelect?.(o.id);
6229
- setMenu(void 0);
6230
- },
6231
- children: [
6232
- o.label,
6233
- o.group && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__group", children: o.group })
6234
- ]
6235
- },
6236
- o.id
6237
- ))
6238
- ] }) : null
6239
- ] })
6292
+ menu === "model" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6293
+ "div",
6294
+ {
6295
+ className: "awr-menu awr-menu--pop",
6296
+ style: modelStyle,
6297
+ role: "menu",
6298
+ ref: modelMenuRef,
6299
+ onKeyDown: modelMenuKeys,
6300
+ children: [
6301
+ thinking && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6302
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.thinking }),
6303
+ thinkingOptions.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6304
+ "button",
6305
+ {
6306
+ type: "button",
6307
+ role: "menuitemradio",
6308
+ "aria-checked": thinking.value === o.id,
6309
+ className: `awr-menu__item${thinking.value === o.id ? " is-active" : ""}`,
6310
+ onClick: () => {
6311
+ thinking.onChange(o.id);
6312
+ setMenu(void 0);
6313
+ },
6314
+ children: o.label
6315
+ },
6316
+ o.id
6317
+ ))
6318
+ ] }),
6319
+ model?.options?.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
6320
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.model }),
6321
+ menuSections(model.options).map((run, i, runs) => {
6322
+ const rows = run.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6323
+ "button",
6324
+ {
6325
+ type: "button",
6326
+ role: "menuitemradio",
6327
+ "aria-checked": model.value === o.id,
6328
+ className: `awr-menu__item${model.value === o.id ? " is-active" : ""}`,
6329
+ onClick: () => {
6330
+ model.onSelect?.(o.id);
6331
+ setMenu(void 0);
6332
+ },
6333
+ children: [
6334
+ o.label,
6335
+ o.group && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__group", children: o.group })
6336
+ ]
6337
+ },
6338
+ o.id
6339
+ ));
6340
+ if (run.section)
6341
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6342
+ "div",
6343
+ {
6344
+ role: "group",
6345
+ "aria-label": run.section,
6346
+ className: "awr-menu__section",
6347
+ children: [
6348
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6349
+ "div",
6350
+ {
6351
+ className: "awr-menu__head awr-menu__sectionhead",
6352
+ "aria-hidden": "true",
6353
+ children: run.section
6354
+ }
6355
+ ),
6356
+ rows
6357
+ ]
6358
+ },
6359
+ `s${i}`
6360
+ );
6361
+ return runs[i - 1]?.section ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__section awr-menu__section--plain", children: rows }, `s${i}`) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react12.Fragment, { children: rows }, `s${i}`);
6362
+ })
6363
+ ] }) : null
6364
+ ]
6365
+ }
6366
+ )
6240
6367
  ] }),
6241
6368
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-toolbar__spacer" }),
6242
6369
  toolbarEnd,
@@ -6245,9 +6372,16 @@ ${draftText}` : draftText);
6245
6372
  "button",
6246
6373
  {
6247
6374
  type: "button",
6375
+ ref: modeChipRef,
6248
6376
  className: `awr-tchip awr-tchip--btn awr-mode awr-mode--${agent.approvalMode}`,
6249
6377
  title: MODE_CHIP[agent.approvalMode].hint,
6250
6378
  onClick: () => setMenu(menu === "mode" ? void 0 : "mode"),
6379
+ onKeyDown: (e) => {
6380
+ if (menu !== "mode" && opensMenu(e.key)) {
6381
+ e.preventDefault();
6382
+ setMenu("mode");
6383
+ }
6384
+ },
6251
6385
  "aria-haspopup": "menu",
6252
6386
  "aria-expanded": menu === "mode",
6253
6387
  "aria-label": `${L.toolConsent}: ${MODE_CHIP[agent.approvalMode].label}`,
@@ -6257,29 +6391,39 @@ ${draftText}` : draftText);
6257
6391
  ]
6258
6392
  }
6259
6393
  ),
6260
- menu === "mode" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-menu awr-menu--pop", style: modeStyle, role: "menu", children: [
6261
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.toolConsent }),
6262
- MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6263
- "button",
6264
- {
6265
- type: "button",
6266
- role: "menuitemradio",
6267
- "aria-checked": agent.approvalMode === m,
6268
- className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
6269
- onClick: () => {
6270
- agent.setApprovalMode(m);
6271
- setMenu(void 0);
6272
- },
6273
- children: [
6274
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModeIcon, { mode: m }),
6275
- " ",
6276
- MODE_CHIP[m].label,
6277
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
6278
- ]
6279
- },
6280
- m
6281
- ))
6282
- ] })
6394
+ menu === "mode" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6395
+ "div",
6396
+ {
6397
+ className: "awr-menu awr-menu--pop",
6398
+ style: modeStyle,
6399
+ role: "menu",
6400
+ ref: modeMenuRef,
6401
+ onKeyDown: modeMenuKeys,
6402
+ children: [
6403
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "awr-menu__head", children: L.toolConsent }),
6404
+ MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
6405
+ "button",
6406
+ {
6407
+ type: "button",
6408
+ role: "menuitemradio",
6409
+ "aria-checked": agent.approvalMode === m,
6410
+ className: `awr-menu__item${agent.approvalMode === m ? " is-active" : ""}`,
6411
+ onClick: () => {
6412
+ agent.setApprovalMode(m);
6413
+ setMenu(void 0);
6414
+ },
6415
+ children: [
6416
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ModeIcon, { mode: m }),
6417
+ " ",
6418
+ MODE_CHIP[m].label,
6419
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-menu__desc", children: MODE_CHIP[m].hint })
6420
+ ]
6421
+ },
6422
+ m
6423
+ ))
6424
+ ]
6425
+ }
6426
+ )
6283
6427
  ] }),
6284
6428
  canSteer && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "awr-sendbtn", onClick: submit, "aria-label": L.steer, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SendIcon, { size: 16 }) }),
6285
6429
  busy ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -8303,7 +8447,7 @@ var MessageList = ({
8303
8447
  showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
8304
8448
  showMedia && m.transcripts?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
8305
8449
  (m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__bubble", children: [
8306
- m.content ? renderContent ? renderContent(m) : m.content : null,
8450
+ m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
8307
8451
  m.pending && !m.content && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
8308
8452
  ] }),
8309
8453
  showMedia && m.media?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
@@ -9725,6 +9869,8 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9725
9869
  mcpAppSandboxShellCsp,
9726
9870
  mcpAppSandboxTarget,
9727
9871
  mediaFamilyOf,
9872
+ menuKeyTarget,
9873
+ menuSections,
9728
9874
  mergeChatRecord,
9729
9875
  mergeLabels,
9730
9876
  newChatId,