zidane-gui 7.0.17 → 7.0.18

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.
@@ -15562,11 +15562,7 @@ const SETTINGS_TOGGLES = [
15562
15562
  description: `discover MCP servers, skills + instructions from .ruler/ (project) and ~/.config/ruler (user) — read-only, zidane's own configs win collisions; stdio servers additionally need "Import configurations from other agents" (they execute local commands)`
15563
15563
  },
15564
15564
  { key: "showThrobber", label: "Throbber", description: "animated indicator while the agent is working" },
15565
- {
15566
- key: "artifacts",
15567
- label: "Artifacts",
15568
- description: "track what a session produces — pull requests, branches, commits, recorded files — in the artifacts rail (⌃⇧A), the header chip and #pr completion; off = nothing is detected, recorded or shown"
15569
- },
15565
+ { key: "artifacts", label: "Artifacts", description: "track pull requests, branches, commits and recorded files per session" },
15570
15566
  {
15571
15567
  key: "showTodoIndicator",
15572
15568
  label: "Todo indicator",
@@ -17703,7 +17699,15 @@ function SelectTurnProvider({ children }) {
17703
17699
  });
17704
17700
  }, []);
17705
17701
  const exit2 = reactExports.useCallback(() => setState(null), []);
17706
- const value = reactExports.useMemo(() => ({ state, enter: enter2, set: set2, exit: exit2 }), [state, enter2, set2, exit2]);
17702
+ const visible = reactExports.useRef(/* @__PURE__ */ new Map());
17703
+ const publishVisible = reactExports.useCallback((sessionId, turnIds) => {
17704
+ visible.current.set(sessionId, turnIds);
17705
+ }, []);
17706
+ const visibleIds = reactExports.useCallback((sessionId) => visible.current.get(sessionId) ?? null, []);
17707
+ const value = reactExports.useMemo(
17708
+ () => ({ state, enter: enter2, set: set2, exit: exit2, publishVisible, visibleIds }),
17709
+ [state, enter2, set2, exit2, publishVisible, visibleIds]
17710
+ );
17707
17711
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTurnContext.Provider, { value, children });
17708
17712
  }
17709
17713
  function useSelectTurn() {
@@ -43054,6 +43058,17 @@ function AskUserModal({ request }) {
43054
43058
  modal.close();
43055
43059
  }
43056
43060
  }, [busy, modal]);
43061
+ const dismissQuestion = async () => {
43062
+ setBusy(true);
43063
+ setError(null);
43064
+ try {
43065
+ await interactions.cancel(request.id, "dismissed by user");
43066
+ modal.close();
43067
+ } catch (err) {
43068
+ setError(err.message ?? String(err));
43069
+ setBusy(false);
43070
+ }
43071
+ };
43057
43072
  const setAnswer = (id, value) => {
43058
43073
  setAnswers((prev) => ({ ...prev, [id]: value }));
43059
43074
  };
@@ -43064,8 +43079,19 @@ function AskUserModal({ request }) {
43064
43079
  description: `The agent paused to ask ${payload.questions.length === 1 ? "1 question" : `${payload.questions.length} questions`}.`,
43065
43080
  onClose: dismiss,
43066
43081
  size: "xlarge",
43067
- footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-3", children: [
43068
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-text-muted)]", children: error ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { role: "alert", className: "text-[var(--zg-error)]", children: error }) : canSubmit ? "Ready to continue." : "Complete the required fields to continue." }),
43082
+ footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-2", children: [
43083
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { role: "alert", className: "mr-auto text-xs text-[var(--zg-error)]", children: error }),
43084
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43085
+ "button",
43086
+ {
43087
+ type: "button",
43088
+ onClick: () => busy ? null : void dismissQuestion(),
43089
+ disabled: busy,
43090
+ title: "Continue without answering",
43091
+ className: "zg-press h-9 px-3 rounded-md text-[13px] text-[var(--zg-text-muted)] bg-transparent border-0 cursor-pointer transition-colors duration-150 hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] disabled:opacity-40 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)]",
43092
+ children: "Dismiss"
43093
+ }
43094
+ ),
43069
43095
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
43070
43096
  "button",
43071
43097
  {
@@ -72839,11 +72865,392 @@ function filterModelCatalog(catalog, query) {
72839
72865
  }
72840
72866
  return catalog.filter((entry) => entry.searchCorpus.includes(q2));
72841
72867
  }
72842
- function indexOfEntry(catalog, target) {
72843
- return catalog.findIndex(
72844
- (entry) => entry.providerKey === target.providerKey && entry.modelId === target.modelId
72868
+ function SelectionDot({ active }) {
72869
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
72870
+ "span",
72871
+ {
72872
+ "aria-hidden": true,
72873
+ className: "inline-block w-2 h-2 rounded-full shrink-0 transition-[background-color,border-color] duration-150",
72874
+ style: {
72875
+ background: active ? "var(--zg-accent)" : "transparent",
72876
+ border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
72877
+ }
72878
+ }
72879
+ );
72880
+ }
72881
+ function ToggleBox({ active }) {
72882
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
72883
+ "span",
72884
+ {
72885
+ "aria-hidden": true,
72886
+ className: "inline-block w-2 h-2 rounded-[3px] shrink-0 transition-[background-color,border-color] duration-150",
72887
+ style: {
72888
+ background: active ? "var(--zg-accent)" : "transparent",
72889
+ border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
72890
+ }
72891
+ }
72845
72892
  );
72846
72893
  }
72894
+ const PINNED_HUE = {
72895
+ anthropic: 24,
72896
+ // warm clay
72897
+ openai: 160,
72898
+ // teal-green
72899
+ google: 210,
72900
+ // blue
72901
+ gemini: 210,
72902
+ xai: 0,
72903
+ // red (used desaturated below)
72904
+ mistral: 30,
72905
+ // orange
72906
+ groq: 300,
72907
+ // magenta
72908
+ openrouter: 265,
72909
+ // violet
72910
+ deepseek: 230,
72911
+ // indigo
72912
+ ollama: 120,
72913
+ // green
72914
+ local: 120,
72915
+ together: 190,
72916
+ fireworks: 12,
72917
+ bedrock: 40,
72918
+ azure: 205,
72919
+ vertex: 215
72920
+ };
72921
+ function hashHue(key2) {
72922
+ let h2 = 2166136261;
72923
+ for (let i = 0; i < key2.length; i++) {
72924
+ h2 ^= key2.charCodeAt(i);
72925
+ h2 = Math.imul(h2, 16777619);
72926
+ }
72927
+ return Math.abs(h2) % 360;
72928
+ }
72929
+ function providerHue(providerKey) {
72930
+ const k2 = providerKey.toLowerCase();
72931
+ const pinned = Object.entries(PINNED_HUE).find(([name2]) => k2.startsWith(name2));
72932
+ return pinned ? pinned[1] : hashHue(k2);
72933
+ }
72934
+ function providerColor(providerKey) {
72935
+ const hue = providerHue(providerKey);
72936
+ const sat = hue < 15 || hue > 345 ? 55 : 62;
72937
+ return `hsl(${hue} ${sat}% 66%)`;
72938
+ }
72939
+ function providerTint(providerKey, percent = 16) {
72940
+ return `color-mix(in srgb, ${providerColor(providerKey)} ${percent}%, transparent)`;
72941
+ }
72942
+ function refKey(entry) {
72943
+ return `${entry.providerKey}\0${entry.modelId}`;
72944
+ }
72945
+ function uniqueProviders(catalog) {
72946
+ const seen2 = /* @__PURE__ */ new Map();
72947
+ for (const entry of catalog) {
72948
+ if (!seen2.has(entry.providerKey)) seen2.set(entry.providerKey, entry.providerLabel);
72949
+ }
72950
+ return [...seen2].map(([key2, label]) => ({ key: key2, label }));
72951
+ }
72952
+ function offCatalogRow(catalog, query, currentProviderKey) {
72953
+ const custom = parseCustomModelQuery(query, uniqueProviders(catalog), currentProviderKey);
72954
+ if (!custom) return null;
72955
+ return {
72956
+ providerKey: custom.providerKey,
72957
+ providerLabel: custom.providerLabel,
72958
+ modelId: custom.modelId,
72959
+ modelName: custom.modelId,
72960
+ contextWindow: null,
72961
+ supportsReasoning: false,
72962
+ options: [],
72963
+ searchCorpus: "",
72964
+ offCatalog: true
72965
+ };
72966
+ }
72967
+ function selectedRowsFirst(entries, chain) {
72968
+ if (chain.length === 0) return [...entries];
72969
+ const byKey = new Map(entries.map((entry) => [refKey(entry), entry]));
72970
+ const selected = [];
72971
+ const promoted = /* @__PURE__ */ new Set();
72972
+ for (const pick of chain) {
72973
+ const key2 = refKey(pick);
72974
+ const entry = byKey.get(key2);
72975
+ if (!entry || promoted.has(key2)) continue;
72976
+ selected.push(entry);
72977
+ promoted.add(key2);
72978
+ }
72979
+ return [...selected, ...entries.filter((entry) => !promoted.has(refKey(entry)))];
72980
+ }
72981
+ function ModelChainPicker({
72982
+ initialChain,
72983
+ catalog: outerCatalog = null,
72984
+ cwd: cwd2,
72985
+ onChainChange,
72986
+ onQuickPick,
72987
+ dense = false,
72988
+ className = ""
72989
+ }) {
72990
+ const { settings } = useSettings();
72991
+ const [catalog, setCatalog] = reactExports.useState(outerCatalog);
72992
+ const [loadError, setLoadError] = reactExports.useState(null);
72993
+ const [query, setQuery] = reactExports.useState("");
72994
+ const [cursor, setCursor] = reactExports.useState(0);
72995
+ const [chain, setChain] = reactExports.useState(() => [...initialChain]);
72996
+ const inputRef = reactExports.useRef(null);
72997
+ const listRef = reactExports.useRef(null);
72998
+ const extensionKey = settings.enabledExtensions?.join("") ?? "*";
72999
+ const currentProviderKey = chain[0]?.providerKey ?? null;
73000
+ reactExports.useEffect(() => {
73001
+ onChainChange(chain);
73002
+ }, [chain]);
73003
+ reactExports.useEffect(() => {
73004
+ if (outerCatalog) {
73005
+ setCatalog(outerCatalog);
73006
+ return void 0;
73007
+ }
73008
+ let cancelled = false;
73009
+ window.api.sessions.listModels(cwd2).then((entries) => {
73010
+ if (!cancelled) setCatalog(entries);
73011
+ }).catch((err) => {
73012
+ if (!cancelled) setLoadError(err.message ?? String(err));
73013
+ });
73014
+ return () => {
73015
+ cancelled = true;
73016
+ };
73017
+ }, [outerCatalog, cwd2, extensionKey]);
73018
+ reactExports.useEffect(() => {
73019
+ inputRef.current?.focus({ preventScroll: true });
73020
+ }, []);
73021
+ const filtered = reactExports.useMemo(() => {
73022
+ if (!catalog) return [];
73023
+ const matches2 = filterModelCatalog(catalog, query);
73024
+ if (matches2.length > 0) return query.trim() ? matches2 : selectedRowsFirst(matches2, chain);
73025
+ const row = offCatalogRow(catalog, query, currentProviderKey);
73026
+ return row ? [row] : [];
73027
+ }, [catalog, query, chain, currentProviderKey]);
73028
+ reactExports.useEffect(() => {
73029
+ if (filtered.length === 0) {
73030
+ setCursor(0);
73031
+ return;
73032
+ }
73033
+ setCursor((c) => Math.min(c, filtered.length - 1));
73034
+ }, [filtered.length]);
73035
+ const cursorSource = reactExports.useRef("key");
73036
+ reactExports.useEffect(() => {
73037
+ if (cursorSource.current !== "key") return;
73038
+ const list2 = listRef.current;
73039
+ const row = list2?.querySelector(`[data-row="${cursor}"]`);
73040
+ if (!list2 || !row) return;
73041
+ const listRect = list2.getBoundingClientRect();
73042
+ const rowRect = row.getBoundingClientRect();
73043
+ const top2 = rowRect.top - listRect.top + list2.scrollTop;
73044
+ const bottom2 = top2 + rowRect.height;
73045
+ if (top2 < list2.scrollTop) list2.scrollTop = top2;
73046
+ else if (bottom2 > list2.scrollTop + list2.clientHeight) list2.scrollTop = bottom2 - list2.clientHeight;
73047
+ }, [cursor]);
73048
+ const setCursorFromKey = (update) => {
73049
+ cursorSource.current = "key";
73050
+ setCursor(update);
73051
+ };
73052
+ const setCursorFromMouse = (idx) => {
73053
+ cursorSource.current = "mouse";
73054
+ setCursor(idx);
73055
+ };
73056
+ const pick = (entry) => {
73057
+ const ref = { providerKey: entry.providerKey, modelId: entry.modelId };
73058
+ const next = pickPrimaryKeyed(chain, ref, refKey);
73059
+ setChain(next);
73060
+ if (chain.length <= 1) onQuickPick?.(next);
73061
+ };
73062
+ const toggle = (entry) => {
73063
+ setChain((prev) => toggleKeyed(prev, { providerKey: entry.providerKey, modelId: entry.modelId }, refKey));
73064
+ };
73065
+ reactExports.useEffect(() => {
73066
+ const onKey = (e) => {
73067
+ if (e.ctrlKey && e.shiftKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
73068
+ e.preventDefault();
73069
+ const row = filtered[cursor];
73070
+ if (!row) return;
73071
+ const key2 = refKey(row);
73072
+ const delta = e.key === "ArrowUp" ? -1 : 1;
73073
+ setChain((prev) => {
73074
+ const reordered = reorderKeyed(prev, key2, delta, refKey);
73075
+ if (reordered !== prev && !query.trim()) {
73076
+ const served = new Set((catalog ?? []).map(refKey));
73077
+ const next = reordered.filter((entry) => served.has(refKey(entry))).findIndex((entry) => refKey(entry) === key2);
73078
+ if (next >= 0) setCursorFromKey(() => next);
73079
+ }
73080
+ return reordered === prev ? prev : [...reordered];
73081
+ });
73082
+ return;
73083
+ }
73084
+ if (e.key === "ArrowDown") {
73085
+ e.preventDefault();
73086
+ setCursorFromKey((c) => Math.min(Math.max(0, filtered.length - 1), c + 1));
73087
+ } else if (e.key === "ArrowUp") {
73088
+ e.preventDefault();
73089
+ setCursorFromKey((c) => Math.max(0, c - 1));
73090
+ } else if (e.key === "Tab" || e.key === "Enter" && e.shiftKey) {
73091
+ e.preventDefault();
73092
+ const entry = filtered[cursor];
73093
+ if (entry) toggle(entry);
73094
+ } else if (e.key === "Enter") {
73095
+ e.preventDefault();
73096
+ const entry = filtered[cursor];
73097
+ if (entry) pick(entry);
73098
+ }
73099
+ };
73100
+ document.addEventListener("keydown", onKey);
73101
+ return () => document.removeEventListener("keydown", onKey);
73102
+ }, [cursor, filtered, query, catalog, chain]);
73103
+ const multi = chain.length > 1;
73104
+ const pad = dense ? "px-3 pt-3 pb-2" : "px-4 pt-3 pb-2";
73105
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `flex flex-col min-h-0 ${className}`, children: [
73106
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${pad} border-b border-[var(--zg-border)]`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
73107
+ "input",
73108
+ {
73109
+ ref: inputRef,
73110
+ value: query,
73111
+ onChange: (e) => setQuery(e.target.value),
73112
+ placeholder: "Search models…",
73113
+ className: "w-full h-8 text-sm bg-[var(--zg-bg)] border border-[var(--zg-border)] rounded-md px-3 text-[var(--zg-text)] outline-none focus:border-[var(--zg-accent)] focus:ring-2 focus:ring-[var(--zg-accent)]/20",
73114
+ spellCheck: false,
73115
+ autoCorrect: "off"
73116
+ }
73117
+ ) }),
73118
+ catalog === null && !loadError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: "Loading…" }),
73119
+ loadError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-6 text-xs text-[#ef4444]", children: [
73120
+ "Failed to load models: ",
73121
+ loadError
73122
+ ] }),
73123
+ catalog !== null && filtered.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: catalog.length === 0 ? "No authenticated providers. Sign in under Settings → Authentication." : 'Type a model id to use it anyway; prefix with a provider to target one (e.g. "xai grok-9").' }),
73124
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: listRef, className: "flex-1 overflow-y-auto list-none m-0 p-2 flex flex-col gap-0.5", children: filtered.map((entry, idx) => {
73125
+ const position2 = positionKeyed(chain, refKey(entry), refKey);
73126
+ const isCursor = idx === cursor;
73127
+ const color2 = providerColor(entry.providerKey);
73128
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "group relative", children: [
73129
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
73130
+ "button",
73131
+ {
73132
+ type: "button",
73133
+ "data-row": idx,
73134
+ onMouseEnter: () => setCursorFromMouse(idx),
73135
+ onClick: (e) => e.shiftKey ? toggle(entry) : pick(entry),
73136
+ className: `zg-press-subtle relative w-full text-left flex items-start gap-3 rounded-lg border-0 cursor-pointer transition-colors duration-150 ${dense ? "px-2.5 py-1.5" : "px-3 py-2"} ${isCursor ? "bg-[var(--zg-bg-hover)]" : "bg-transparent hover:bg-[var(--zg-bg-hover)]/60"}`,
73137
+ children: [
73138
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 h-5 shrink-0 flex items-center justify-center", children: multi && position2 !== null ? /* @__PURE__ */ jsxRuntimeExports.jsx(
73139
+ "span",
73140
+ {
73141
+ className: `text-[11px] font-semibold tabular-nums ${position2 === 1 ? "text-[var(--zg-accent)]" : "text-[var(--zg-text)]"}`,
73142
+ title: position2 === 1 ? "Primary model" : `Fallback #${position2 - 1}`,
73143
+ children: position2 > 9 ? "+" : position2
73144
+ }
73145
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionDot, { active: position2 !== null }) }),
73146
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex-1 min-w-0 flex flex-col gap-1", children: [
73147
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `flex items-baseline gap-2 min-w-0 ${position2 !== null ? "pr-6" : ""}`, children: [
73148
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[13px] text-[var(--zg-text)]", children: entry.modelId }),
73149
+ entry.modelName !== entry.modelId && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-xs text-[var(--zg-text-muted)]", children: entry.modelName })
73150
+ ] }),
73151
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1.5 text-[10px] leading-none", children: [
73152
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
73153
+ "span",
73154
+ {
73155
+ className: "inline-flex items-center h-[18px] gap-1 rounded-md px-1.5",
73156
+ style: { color: color2, background: providerTint(entry.providerKey) },
73157
+ children: [
73158
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "w-1.5 h-1.5 rounded-full", style: { background: color2 } }),
73159
+ entry.providerLabel
73160
+ ]
73161
+ }
73162
+ ),
73163
+ entry.offCatalog ? /* @__PURE__ */ jsxRuntimeExports.jsx(
73164
+ "span",
73165
+ {
73166
+ className: "inline-flex items-center h-[18px] rounded-md px-1.5 text-[#f59e0b]",
73167
+ style: { background: "color-mix(in srgb, #f59e0b 14%, transparent)" },
73168
+ title: "Used as typed; no metadata is known for this id",
73169
+ children: "not in catalog"
73170
+ }
73171
+ ) : entry.contextWindow !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs(
73172
+ "span",
73173
+ {
73174
+ className: "inline-flex items-center h-[18px] rounded-md px-1.5 tabular-nums text-[var(--zg-text-muted)] bg-[var(--zg-bg-elevated)]",
73175
+ title: "Context window",
73176
+ children: [
73177
+ formatWindow(entry.contextWindow),
73178
+ " ctx"
73179
+ ]
73180
+ }
73181
+ ),
73182
+ entry.supportsReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx(
73183
+ "span",
73184
+ {
73185
+ className: "inline-flex items-center h-[18px] rounded-md px-1.5",
73186
+ style: {
73187
+ color: "hsl(265 60% 72%)",
73188
+ background: "color-mix(in srgb, hsl(265 60% 72%) 14%, transparent)"
73189
+ },
73190
+ title: "Supports reasoning effort (Ctrl+L)",
73191
+ children: "reasoning"
73192
+ }
73193
+ )
73194
+ ] })
73195
+ ] })
73196
+ ]
73197
+ }
73198
+ ),
73199
+ position2 !== null && /* @__PURE__ */ jsxRuntimeExports.jsx(
73200
+ "button",
73201
+ {
73202
+ type: "button",
73203
+ "aria-label": position2 === 1 ? "Remove primary model" : `Remove fallback #${position2 - 1}`,
73204
+ title: "Remove from chain",
73205
+ onClick: () => toggle(entry),
73206
+ className: `zg-press absolute right-2 top-2 inline-flex items-center justify-center w-5 h-5 rounded-md border-0 cursor-pointer bg-transparent text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg)] transition-opacity duration-150 ${isCursor ? "opacity-100" : "opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,
73207
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "i-heroicons-x-mark text-[12px]" })
73208
+ }
73209
+ )
73210
+ ] }, refKey(entry));
73211
+ }) }),
73212
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
73213
+ "div",
73214
+ {
73215
+ className: `${dense ? "px-3" : "px-4"} py-2 border-t border-[var(--zg-border)] flex items-center gap-3 text-[11px] text-[var(--zg-text-muted)]`,
73216
+ children: [
73217
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1.5 whitespace-nowrap", children: [
73218
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Kbd, { size: "sm", children: "↵" }),
73219
+ "primary"
73220
+ ] }),
73221
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
73222
+ "span",
73223
+ {
73224
+ className: "inline-flex items-center gap-1.5 whitespace-nowrap",
73225
+ title: "Tab, or shift+click, adds / removes a fallback",
73226
+ children: [
73227
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Kbd, { size: "sm", children: "⇥" }),
73228
+ "fallback"
73229
+ ]
73230
+ }
73231
+ ),
73232
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
73233
+ "span",
73234
+ {
73235
+ className: "ml-auto whitespace-nowrap text-[var(--zg-accent)]",
73236
+ "data-testid": "model-chain-count",
73237
+ title: multi ? "Order = fallback priority. ctrl+shift+↑↓ reorders the highlighted row." : void 0,
73238
+ children: [
73239
+ chain.length,
73240
+ " selected"
73241
+ ]
73242
+ }
73243
+ )
73244
+ ]
73245
+ }
73246
+ )
73247
+ ] });
73248
+ }
73249
+ function formatWindow(tokens) {
73250
+ if (tokens >= 1e6) return `${(tokens / 1e6).toFixed(2)}M`;
73251
+ if (tokens >= 1e3) return `${Math.round(tokens / 1e3)}k`;
73252
+ return `${tokens}`;
73253
+ }
72847
73254
  const DEFAULT_DIFF = {
72848
73255
  addBg: "#0e2218",
72849
73256
  removeBg: "#2a1414",
@@ -73556,32 +73963,6 @@ function AgentSelector({ activeSession, defaultAgentId, onDefaultAgentChange })
73556
73963
  )
73557
73964
  ] });
73558
73965
  }
73559
- function SelectionDot({ active }) {
73560
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
73561
- "span",
73562
- {
73563
- "aria-hidden": true,
73564
- className: "inline-block w-2 h-2 rounded-full shrink-0 transition-[background-color,border-color] duration-150",
73565
- style: {
73566
- background: active ? "var(--zg-accent)" : "transparent",
73567
- border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
73568
- }
73569
- }
73570
- );
73571
- }
73572
- function ToggleBox({ active }) {
73573
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
73574
- "span",
73575
- {
73576
- "aria-hidden": true,
73577
- className: "inline-block w-2 h-2 rounded-[3px] shrink-0 transition-[background-color,border-color] duration-150",
73578
- style: {
73579
- background: active ? "var(--zg-accent)" : "transparent",
73580
- border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
73581
- }
73582
- }
73583
- );
73584
- }
73585
73966
  function ChatboxControls({
73586
73967
  activeSession,
73587
73968
  defaultAgentId,
@@ -73592,7 +73973,29 @@ function ChatboxControls({
73592
73973
  activeModelOptions,
73593
73974
  activeEnabledOptions
73594
73975
  }) {
73595
- const { defaultFolder, defaultProviderKey, defaultModelId, setDefaultModel } = useSessions();
73976
+ const {
73977
+ defaultFolder,
73978
+ defaultProviderKey,
73979
+ defaultModelId,
73980
+ setDefaultModel,
73981
+ refresh: refreshSessions
73982
+ } = useSessions();
73983
+ const modelDraftRef = reactExports.useRef(null);
73984
+ const commitModelDraft = async () => {
73985
+ const draft = modelDraftRef.current;
73986
+ modelDraftRef.current = null;
73987
+ if (!draft) return;
73988
+ const primary = draft.chain[0];
73989
+ if (!primary || chainsEqualKeyed(draft.chain, draft.initial, refKey)) return;
73990
+ if (activeSession) {
73991
+ await window.api.sessions.setModel(activeSession.id, primary.providerKey, primary.modelId, draft.chain.slice(1));
73992
+ }
73993
+ setDefaultModel(primary.providerKey, primary.modelId);
73994
+ await window.api.state.set({
73995
+ lastModelChain: draft.chain.map((e) => ({ provider: e.providerKey, model: e.modelId }))
73996
+ });
73997
+ await refreshSessions();
73998
+ };
73596
73999
  const { settings } = useSettings();
73597
74000
  const catalogCwd = activeSession?.cwd ?? defaultFolder ?? void 0;
73598
74001
  const extensionKey = settings.enabledExtensions?.join("") ?? "*";
@@ -73658,7 +74061,8 @@ function ChatboxControls({
73658
74061
  }
73659
74062
  ),
73660
74063
  ariaLabel: activeSession ? "Switch model" : "Pick default model",
73661
- width: 420,
74064
+ width: 440,
74065
+ onDismiss: () => void commitModelDraft(),
73662
74066
  render: (close2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
73663
74067
  ModelMenu,
73664
74068
  {
@@ -73668,7 +74072,8 @@ function ChatboxControls({
73668
74072
  catalog,
73669
74073
  cwd: catalogCwd,
73670
74074
  onClose: close2,
73671
- onPickDefault: setDefaultModel
74075
+ onPickDefault: setDefaultModel,
74076
+ draftRef: modelDraftRef
73672
74077
  }
73673
74078
  )
73674
74079
  }
@@ -73885,22 +74290,29 @@ function Popover({
73885
74290
  render: render2,
73886
74291
  ariaLabel,
73887
74292
  width,
73888
- align = "left"
74293
+ align = "left",
74294
+ onDismiss
73889
74295
  }) {
73890
74296
  const [open, setOpen] = reactExports.useState(false);
73891
74297
  const wrapperRef = reactExports.useRef(null);
74298
+ const dismissRef = reactExports.useRef(onDismiss);
74299
+ dismissRef.current = onDismiss;
73892
74300
  reactExports.useEffect(() => {
73893
74301
  if (!open) {
73894
74302
  return void 0;
73895
74303
  }
74304
+ const dismiss = () => {
74305
+ setOpen(false);
74306
+ dismissRef.current?.();
74307
+ };
73896
74308
  const onDown = (e) => {
73897
74309
  if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
73898
- setOpen(false);
74310
+ dismiss();
73899
74311
  }
73900
74312
  };
73901
74313
  const onKey = (e) => {
73902
74314
  if (e.key === "Escape") {
73903
- setOpen(false);
74315
+ dismiss();
73904
74316
  }
73905
74317
  };
73906
74318
  document.addEventListener("mousedown", onDown);
@@ -73911,7 +74323,12 @@ function Popover({
73911
74323
  };
73912
74324
  }, [open]);
73913
74325
  const close2 = reactExports.useCallback(() => setOpen(false), []);
73914
- const toggle = reactExports.useCallback(() => setOpen((v2) => !v2), []);
74326
+ const toggle = reactExports.useCallback(() => {
74327
+ setOpen((v2) => {
74328
+ if (v2) dismissRef.current?.();
74329
+ return !v2;
74330
+ });
74331
+ }, []);
73915
74332
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: wrapperRef, className: "relative inline-flex items-center", children: [
73916
74333
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73917
74334
  "button",
@@ -73963,134 +74380,43 @@ function ModelMenu({
73963
74380
  session,
73964
74381
  currentModelId,
73965
74382
  currentProviderKey,
73966
- catalog: outerCatalog,
74383
+ catalog,
73967
74384
  cwd: cwd2,
73968
74385
  onClose,
73969
- onPickDefault
74386
+ onPickDefault,
74387
+ draftRef
73970
74388
  }) {
73971
74389
  const { refresh } = useSessions();
73972
- const { settings } = useSettings();
73973
- const [catalog, setCatalog] = reactExports.useState(outerCatalog);
73974
- const [loadError, setLoadError] = reactExports.useState(null);
73975
- const [query, setQuery] = reactExports.useState("");
73976
- const [cursor, setCursor] = reactExports.useState(0);
73977
- const inputRef = reactExports.useRef(null);
73978
- const listRef = reactExports.useRef(null);
73979
- const extensionKey = settings.enabledExtensions?.join("") ?? "*";
73980
- reactExports.useEffect(() => {
73981
- if (outerCatalog) {
73982
- setCatalog(outerCatalog);
73983
- if (currentProviderKey && currentModelId) {
73984
- const idx = indexOfEntry(outerCatalog, { providerKey: currentProviderKey, modelId: currentModelId });
73985
- if (idx >= 0) setCursor(idx);
73986
- }
73987
- return void 0;
73988
- }
73989
- let cancelled = false;
73990
- window.api.sessions.listModels(cwd2).then((entries) => {
73991
- if (cancelled) return;
73992
- setCatalog(entries);
73993
- if (currentProviderKey && currentModelId) {
73994
- const idx = indexOfEntry(entries, { providerKey: currentProviderKey, modelId: currentModelId });
73995
- if (idx >= 0) setCursor(idx);
73996
- }
73997
- }).catch((err) => {
73998
- if (!cancelled) setLoadError(err.message ?? String(err));
73999
- });
74000
- return () => {
74001
- cancelled = true;
74002
- };
74003
- }, [outerCatalog, currentProviderKey, currentModelId, cwd2, extensionKey]);
74004
- reactExports.useEffect(() => {
74005
- inputRef.current?.focus();
74006
- }, []);
74007
- const filtered = reactExports.useMemo(() => catalog ? filterModelCatalog(catalog, query) : [], [catalog, query]);
74008
- reactExports.useEffect(() => {
74009
- if (filtered.length === 0) {
74010
- setCursor(0);
74011
- return;
74012
- }
74013
- setCursor((c) => Math.min(c, filtered.length - 1));
74014
- }, [filtered.length]);
74015
- reactExports.useEffect(() => {
74016
- const row = listRef.current?.querySelector(`[data-row="${cursor}"]`);
74017
- row?.scrollIntoView({ block: "nearest" });
74018
- }, [cursor]);
74019
- const apply2 = async (entry) => {
74390
+ const [initialChain] = reactExports.useState(
74391
+ () => currentProviderKey && currentModelId ? [{ providerKey: currentProviderKey, modelId: currentModelId }, ...session?.modelFallbacks ?? []] : []
74392
+ );
74393
+ const quickPick = async (chain) => {
74394
+ const primary = chain[0];
74395
+ if (!primary) return;
74396
+ draftRef.current = null;
74020
74397
  if (session) {
74021
- await window.api.sessions.setModel(session.id, entry.providerKey, entry.modelId);
74022
- onPickDefault(entry.providerKey, entry.modelId);
74398
+ await window.api.sessions.setModel(session.id, primary.providerKey, primary.modelId, chain.slice(1));
74399
+ onPickDefault(primary.providerKey, primary.modelId);
74023
74400
  await refresh();
74024
74401
  } else {
74025
- onPickDefault(entry.providerKey, entry.modelId);
74402
+ onPickDefault(primary.providerKey, primary.modelId);
74026
74403
  }
74027
74404
  onClose();
74028
74405
  };
74029
- reactExports.useEffect(() => {
74030
- const onKey = (e) => {
74031
- if (e.key === "ArrowDown") {
74032
- e.preventDefault();
74033
- setCursor((c) => Math.min(Math.max(0, filtered.length - 1), c + 1));
74034
- } else if (e.key === "ArrowUp") {
74035
- e.preventDefault();
74036
- setCursor((c) => Math.max(0, c - 1));
74037
- } else if (e.key === "Enter") {
74038
- e.preventDefault();
74039
- const entry = filtered[cursor];
74040
- if (entry) void apply2(entry);
74041
- }
74042
- };
74043
- document.addEventListener("keydown", onKey);
74044
- return () => document.removeEventListener("keydown", onKey);
74045
- }, [cursor, filtered]);
74046
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col max-h-[min(60vh,420px)]", children: [
74047
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-3 pt-3 pb-2 border-b border-[var(--zg-border)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
74048
- "input",
74049
- {
74050
- ref: inputRef,
74051
- value: query,
74052
- onChange: (e) => setQuery(e.target.value),
74053
- placeholder: "Search models…",
74054
- className: "w-full h-8 text-sm bg-[var(--zg-bg)] border border-[var(--zg-border)] rounded-md px-3 text-[var(--zg-text)] outline-none focus:border-[var(--zg-accent)] focus:ring-2 focus:ring-[var(--zg-accent)]/20",
74055
- spellCheck: false,
74056
- autoCorrect: "off"
74057
- }
74058
- ) }),
74059
- catalog === null && !loadError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: "Loading…" }),
74060
- loadError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-6 text-xs text-[#ef4444]", children: [
74061
- "Failed to load models: ",
74062
- loadError
74063
- ] }),
74064
- catalog !== null && filtered.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: catalog.length === 0 ? "No authenticated providers — open Settings → Authentication to sign in." : "No models match this query." }),
74065
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: listRef, className: "flex-1 overflow-y-auto list-none m-0 p-2 flex flex-col gap-0.5", children: filtered.map((entry, idx) => {
74066
- const isCurrent = entry.providerKey === currentProviderKey && entry.modelId === currentModelId;
74067
- const isCursor = idx === cursor;
74068
- return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
74069
- "button",
74070
- {
74071
- type: "button",
74072
- "data-row": idx,
74073
- onMouseEnter: () => setCursor(idx),
74074
- onClick: () => void apply2(entry),
74075
- className: `zg-press-subtle w-full text-left flex items-center gap-2 px-2 py-1.5 rounded-md border-0 cursor-pointer transition-colors duration-150 ${isCursor ? "bg-[var(--zg-bg-hover)] text-[var(--zg-text)]" : "bg-transparent text-[var(--zg-text-muted)] hover:text-[var(--zg-text)]"}`,
74076
- children: [
74077
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 shrink-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionDot, { active: isCurrent }) }),
74078
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1 min-w-0 truncate text-[13px] text-[var(--zg-text)]", children: entry.modelId }),
74079
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 flex items-center gap-1.5 text-[var(--zg-text-muted)]", children: [
74080
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-11 text-right text-[11px] tabular-nums", children: entry.contextWindow !== null ? formatWindow$1(entry.contextWindow) : "" }),
74081
- entry.supportsReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center h-[18px] rounded-md border border-[var(--zg-border)] px-1.5 text-[10px]", children: "reason" }),
74082
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center h-[18px] rounded-md border border-[var(--zg-border)] px-1.5 text-[10px]", children: entry.providerLabel })
74083
- ] })
74084
- ]
74085
- }
74086
- ) }, `${entry.providerKey}:${entry.modelId}`);
74087
- }) })
74088
- ] });
74089
- }
74090
- function formatWindow$1(tokens) {
74091
- if (tokens >= 1e6) return `${(tokens / 1e6).toFixed(2)}M`;
74092
- if (tokens >= 1e3) return `${Math.round(tokens / 1e3)}k`;
74093
- return `${tokens}`;
74406
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
74407
+ ModelChainPicker,
74408
+ {
74409
+ dense: true,
74410
+ initialChain,
74411
+ catalog,
74412
+ cwd: cwd2,
74413
+ onChainChange: (chain) => {
74414
+ draftRef.current = { initial: initialChain, chain };
74415
+ },
74416
+ onQuickPick: (chain) => void quickPick(chain),
74417
+ className: "max-h-[min(60vh,460px)]"
74418
+ }
74419
+ );
74094
74420
  }
74095
74421
  function ContextOrb({
74096
74422
  status,
@@ -74174,17 +74500,24 @@ function ContextOrb({
74174
74500
  /* @__PURE__ */ jsxRuntimeExports.jsx(ContextBreakdownSection, { sessionId, fallbackPct: pct, fallbackColor: color2 }),
74175
74501
  cost?.label && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between text-[11px]", children: [
74176
74502
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)]", children: "Session cost" }),
74177
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "tabular-nums", style: { color: cost.estimated ? "var(--zg-text-muted)" : "var(--zg-money)" }, children: [
74178
- cost.estimated ? "~" : "",
74179
- cost.label,
74180
- cost.runCount !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[var(--zg-text-muted)]", children: [
74181
- " ",
74182
- "· ",
74183
- cost.runCount,
74184
- " run",
74185
- cost.runCount === 1 ? "" : "s"
74186
- ] })
74187
- ] })
74503
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
74504
+ "span",
74505
+ {
74506
+ className: "tabular-nums",
74507
+ style: { color: cost.estimated ? "var(--zg-text-muted)" : "var(--zg-money)" },
74508
+ children: [
74509
+ cost.estimated ? "~" : "",
74510
+ cost.label,
74511
+ cost.runCount !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[var(--zg-text-muted)]", children: [
74512
+ " ",
74513
+ "· ",
74514
+ cost.runCount,
74515
+ " run",
74516
+ cost.runCount === 1 ? "" : "s"
74517
+ ] })
74518
+ ]
74519
+ }
74520
+ )
74188
74521
  ] })
74189
74522
  ] })
74190
74523
  }
@@ -74840,18 +75173,28 @@ function SegmentSpinner({ size: size2 = "sm", tone = "inherit", label = "Working
74840
75173
  function Tooltip$1({ label, side = "bottom", align = "center", children, className = "" }) {
74841
75174
  const y2 = side === "bottom" ? "top-full mt-1.5" : "bottom-full mb-1.5";
74842
75175
  const x2 = align === "end" ? "right-0" : "left-1/2 -translate-x-1/2";
74843
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `zg-tooltip-host relative inline-flex ${className}`, children: [
74844
- children,
74845
- /* @__PURE__ */ jsxRuntimeExports.jsx(
74846
- "span",
74847
- {
74848
- role: "tooltip",
74849
- "aria-hidden": true,
74850
- className: `zg-tooltip pointer-events-none absolute z-30 whitespace-nowrap ${y2} ${x2} px-2 py-1 rounded-md text-[11px] leading-4 text-[var(--zg-text)] bg-[var(--zg-bg-elevated)] border border-[var(--zg-border)] shadow-[0_4px_12px_-4px_rgba(0,0,0,0.5)]`,
74851
- children: label
74852
- }
74853
- )
74854
- ] });
75176
+ const [suppressed, setSuppressed] = reactExports.useState(false);
75177
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
75178
+ "span",
75179
+ {
75180
+ className: `zg-tooltip-host relative inline-flex ${className}`,
75181
+ onClick: () => setSuppressed(true),
75182
+ onMouseLeave: () => setSuppressed(false),
75183
+ ...suppressed ? { "data-tooltip-suppressed": "" } : {},
75184
+ children: [
75185
+ children,
75186
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
75187
+ "span",
75188
+ {
75189
+ role: "tooltip",
75190
+ "aria-hidden": true,
75191
+ className: `zg-tooltip pointer-events-none absolute z-30 whitespace-nowrap ${y2} ${x2} px-2 py-1 rounded-md text-[11px] leading-4 text-[var(--zg-text)] bg-[var(--zg-bg-elevated)] border border-[var(--zg-border)] shadow-[0_4px_12px_-4px_rgba(0,0,0,0.5)]`,
75192
+ children: label
75193
+ }
75194
+ )
75195
+ ]
75196
+ }
75197
+ );
74855
75198
  }
74856
75199
  function SessionHeader({
74857
75200
  session,
@@ -75888,7 +76231,6 @@ function StackedChart({
75888
76231
  );
75889
76232
  }
75890
76233
  const ARTIFACTS_PANEL_WIDTH = 288;
75891
- const ICON_BTN = "zg-press inline-flex items-center justify-center w-6 h-6 rounded-md border-0 bg-transparent cursor-pointer text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] transition-colors duration-150 p-0";
75892
76234
  function ArtifactsPanel({ sessionId }) {
75893
76235
  const cached = useArtifactsFor(sessionId);
75894
76236
  const fetchSession = useArtifactsFetcher();
@@ -75899,11 +76241,14 @@ function ArtifactsPanel({ sessionId }) {
75899
76241
  const groups = cached;
75900
76242
  const total = countArtifacts(groups);
75901
76243
  const refreshed = reactExports.useRef(/* @__PURE__ */ new Set());
75902
- const refresh = reactExports.useCallback((row) => {
76244
+ const refresh = reactExports.useCallback((row, force = false) => {
75903
76245
  if (refreshed.current.has(row.artifact.id)) return;
75904
76246
  refreshed.current.add(row.artifact.id);
75905
- void window.api.artifacts.refresh(row.artifact).catch(() => void 0);
76247
+ void window.api.artifacts.refresh(row.artifact, force ? { force: true } : void 0).catch(() => void 0);
75906
76248
  }, []);
76249
+ reactExports.useEffect(() => {
76250
+ for (const group of groups ?? []) for (const row of group.rows) refresh(row, true);
76251
+ }, [groups, refresh]);
75907
76252
  const remove = reactExports.useCallback((row) => {
75908
76253
  setError(null);
75909
76254
  void window.api.artifacts.delete(row.artifact.sessionId, row.artifact.id).then((ok2) => {
@@ -75946,21 +76291,39 @@ function ArtifactRow({ row, onFocus, onRemove }) {
75946
76291
  const href = view.href;
75947
76292
  const isUrl2 = href !== void 0 && /^https?:\/\//.test(href);
75948
76293
  const subtitle = view.subtitle && view.subtitle !== view.title ? view.subtitle : void 0;
76294
+ const [menu, setMenu] = reactExports.useState(null);
76295
+ const menuItems = reactExports.useMemo(
76296
+ () => [
76297
+ {
76298
+ id: "copy",
76299
+ label: isUrl2 ? "Copy link" : "Copy path",
76300
+ shortcut: "c",
76301
+ onSelect: () => void navigator.clipboard.writeText(href ?? artifact.uri)
76302
+ },
76303
+ ...href && !isUrl2 ? [
76304
+ {
76305
+ id: "reveal",
76306
+ label: "Reveal in Finder",
76307
+ shortcut: "f",
76308
+ onSelect: () => void window.api.system.revealPath(href)
76309
+ }
76310
+ ] : [],
76311
+ { id: "remove", label: "Remove from session", shortcut: "r", destructive: true, onSelect: onRemove }
76312
+ ],
76313
+ [isUrl2, href, artifact.uri, onRemove]
76314
+ );
75949
76315
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
75950
76316
  "li",
75951
76317
  {
75952
- className: "group relative flex items-start gap-2 -mx-2 px-2 py-1.5 rounded-md hover:bg-[var(--zg-bg-hover)] transition-colors duration-150",
76318
+ className: "relative flex items-start gap-2 -mx-2 px-2 py-1.5 rounded-md hover:bg-[var(--zg-bg-hover)] transition-colors duration-150",
75953
76319
  onMouseEnter: onFocus,
75954
76320
  onFocus,
76321
+ onContextMenu: (e) => {
76322
+ e.preventDefault();
76323
+ setMenu({ x: e.clientX, y: e.clientY });
76324
+ },
75955
76325
  children: [
75956
- /* @__PURE__ */ jsxRuntimeExports.jsx(
75957
- "span",
75958
- {
75959
- "aria-hidden": true,
75960
- className: "mt-[7px] w-1 h-1 rounded-full shrink-0",
75961
- style: { background: statusColor(view.status) }
75962
- }
75963
- ),
76326
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StatusGlyph, { status: view.status, kind: artifact.kind }),
75964
76327
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0 flex flex-col", children: [
75965
76328
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 min-w-0", children: [
75966
76329
  isUrl2 ? (
@@ -75976,39 +76339,66 @@ function ArtifactRow({ row, onFocus, onRemove }) {
75976
76339
  children: view.title
75977
76340
  }
75978
76341
  )
75979
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[13px] text-[var(--zg-text)]", title: href ?? artifact.uri, children: view.title }),
75980
- view.status && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 text-[10px] leading-4 px-1.5 rounded-full bg-[var(--zg-bg-elevated)] text-[var(--zg-text-muted)]", children: view.status })
76342
+ ) : href ? (
76343
+ // Local path → reveal in Finder / Explorer (file selected in its
76344
+ // folder, directory opened). Rendered as a button, not a link.
76345
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76346
+ "button",
76347
+ {
76348
+ type: "button",
76349
+ onClick: () => void window.api.system.revealPath(href),
76350
+ className: "truncate text-left text-[13px] text-[var(--zg-text)] bg-transparent border-0 p-0 cursor-pointer hover:underline",
76351
+ title: `Reveal ${href}`,
76352
+ children: view.title
76353
+ }
76354
+ )
76355
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[13px] text-[var(--zg-text)]", title: artifact.uri, children: view.title }),
76356
+ view.status && /* @__PURE__ */ jsxRuntimeExports.jsx(
76357
+ "span",
76358
+ {
76359
+ className: "shrink-0 text-[10px] leading-4 px-1.5 rounded-full bg-[var(--zg-bg-elevated)] whitespace-nowrap",
76360
+ style: { color: statusColor(view.status) },
76361
+ children: view.status
76362
+ }
76363
+ )
75981
76364
  ] }),
75982
- subtitle && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[11px] text-[var(--zg-text-muted)] font-mono", title: subtitle, children: subtitle })
76365
+ subtitle && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-[11px] text-[var(--zg-text-muted)] font-mono", title: subtitle, children: subtitle }),
76366
+ view.badges && view.badges.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 flex flex-wrap items-center gap-1.5 text-[10px] leading-4 tabular-nums", children: view.badges.map(
76367
+ (badge) => badge.tone === "diff" ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffBadge, { text: badge.text, title: badge.title }, badge.text) : /* @__PURE__ */ jsxRuntimeExports.jsx(
76368
+ "span",
76369
+ {
76370
+ className: "px-1.5 rounded bg-[var(--zg-bg-elevated)]",
76371
+ style: { color: badgeColor(badge.tone) },
76372
+ title: badge.title,
76373
+ children: badge.text
76374
+ },
76375
+ badge.text
76376
+ )
76377
+ ) })
75983
76378
  ] }),
75984
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute right-1 top-1 hidden group-hover:flex group-focus-within:flex items-center gap-0.5 rounded-md bg-[var(--zg-bg-hover)]", children: [
75985
- /* @__PURE__ */ jsxRuntimeExports.jsx(
75986
- "button",
75987
- {
75988
- type: "button",
75989
- "aria-label": "Copy locator",
75990
- title: "Copy",
75991
- onClick: () => void navigator.clipboard.writeText(href ?? artifact.uri),
75992
- className: ICON_BTN,
75993
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "i-heroicons-clipboard text-[12px]" })
75994
- }
75995
- ),
75996
- /* @__PURE__ */ jsxRuntimeExports.jsx(
75997
- "button",
75998
- {
75999
- type: "button",
76000
- "aria-label": "Remove artifact",
76001
- title: "Remove from this session",
76002
- onClick: onRemove,
76003
- className: `${ICON_BTN} hover:!text-[var(--zg-danger)]`,
76004
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "i-heroicons-x-mark text-[12px]" })
76005
- }
76006
- )
76007
- ] })
76379
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76380
+ RowActionsMenu,
76381
+ {
76382
+ open: menu !== null,
76383
+ position: menu ?? void 0,
76384
+ onClose: () => setMenu(null),
76385
+ items: menuItems
76386
+ }
76387
+ )
76008
76388
  ]
76009
76389
  }
76010
76390
  );
76011
76391
  }
76392
+ function badgeColor(tone) {
76393
+ switch (tone) {
76394
+ case "success":
76395
+ return "var(--zg-success)";
76396
+ case "warn":
76397
+ return "var(--zg-warn)";
76398
+ default:
76399
+ return "var(--zg-text-muted)";
76400
+ }
76401
+ }
76012
76402
  function EmptyState() {
76013
76403
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-2 py-10 px-4 text-center", children: [
76014
76404
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -76023,14 +76413,56 @@ function EmptyState() {
76023
76413
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-[11px] leading-relaxed text-[var(--zg-text-muted)]", children: "Pull requests, branches and commits land here as the agent produces them; files only when recorded on purpose." })
76024
76414
  ] });
76025
76415
  }
76416
+ function StatusGlyph({ status, kind }) {
76417
+ if (kind !== "pull_request" || !status) {
76418
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
76419
+ "span",
76420
+ {
76421
+ "aria-hidden": true,
76422
+ className: "mt-[7px] w-1 h-1 rounded-full shrink-0",
76423
+ style: { background: statusColor(status) }
76424
+ }
76425
+ );
76426
+ }
76427
+ const icon = status === "merged" ? "i-heroicons-arrow-path-rounded-square" : status === "closed" ? "i-heroicons-x-circle" : status === "draft" ? "i-heroicons-pencil-square" : status === "approved" ? "i-heroicons-check-circle" : status === "changes requested" ? "i-heroicons-exclamation-circle" : "i-heroicons-arrow-up-circle";
76428
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
76429
+ "span",
76430
+ {
76431
+ "aria-hidden": true,
76432
+ className: `${icon} mt-[3px] text-[13px] shrink-0`,
76433
+ style: { color: statusColor(status) },
76434
+ title: status
76435
+ }
76436
+ );
76437
+ }
76438
+ function DiffBadge({ text: text2, title }) {
76439
+ const m2 = /^\+(\d+) −(\d+)$/.exec(text2);
76440
+ if (!m2) {
76441
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-1.5 rounded bg-[var(--zg-bg-elevated)] text-[var(--zg-text-muted)]", title, children: text2 });
76442
+ }
76443
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "px-1.5 rounded bg-[var(--zg-bg-elevated)] inline-flex items-center gap-1", title, children: [
76444
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[var(--zg-success)]", children: [
76445
+ "+",
76446
+ m2[1]
76447
+ ] }),
76448
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[var(--zg-danger)]", children: [
76449
+ "−",
76450
+ m2[2]
76451
+ ] })
76452
+ ] });
76453
+ }
76026
76454
  function statusColor(status) {
76027
76455
  switch (status) {
76028
76456
  case "merged":
76029
- return "var(--zg-success)";
76457
+ return "hsl(265 60% 72%)";
76030
76458
  case "closed":
76031
76459
  return "var(--zg-danger)";
76032
76460
  case "draft":
76033
76461
  return "var(--zg-text-muted)";
76462
+ case "approved":
76463
+ return "var(--zg-success)";
76464
+ case "changes requested":
76465
+ return "var(--zg-warn)";
76034
76466
  case "open":
76035
76467
  return "var(--zg-accent)";
76036
76468
  default:
@@ -80163,8 +80595,7 @@ function useTranscriptSelectionCopy(containerRef) {
80163
80595
  }
80164
80596
  const USER_PROMPT_BUBBLE_STYLE = { background: "var(--zg-accent-soft-strong)" };
80165
80597
  const SELECTION_RING_STYLE = {
80166
- background: "rgba(20, 136, 252, 0.08)",
80167
- boxShadow: "inset 2px 0 0 0 var(--zg-accent)"
80598
+ background: "var(--zg-accent-soft-strong)"
80168
80599
  };
80169
80600
  const GUTTER_STEP_PX = 28;
80170
80601
  const SPINE_ACTIVE_STYLE = {
@@ -80219,12 +80650,41 @@ const Timeline = reactExports.memo(({ events, isStreaming, sessionId }) => {
80219
80650
  visibleRows.forEach((row, idx) => map3.set(row, idx));
80220
80651
  return map3;
80221
80652
  }, [visibleRows]);
80653
+ const rowTurnIds = (row) => {
80654
+ const ids = [];
80655
+ if ("turnId" in row && row.turnId) ids.push(row.turnId);
80656
+ if (row.kind === "tool-batch") {
80657
+ for (const t of row.tools) if (t.turnId) ids.push(t.turnId);
80658
+ }
80659
+ if (row.kind === "thinking-batch") {
80660
+ for (const t of row.thoughts) if (t.turnId) ids.push(t.turnId);
80661
+ }
80662
+ return ids;
80663
+ };
80664
+ const isRowHidden = (row) => (row.kind === "thinking" || row.kind === "thinking-batch") && !showThinking;
80665
+ const isRowHighlighted = (row) => selectedTurnId !== null && ownership !== null && rowTurnIds(row).some((turnId) => isTurnHighlighted({ turnId }, selectedTurnId, ownership));
80666
+ reactExports.useEffect(() => {
80667
+ if (selectedTurnId === null || !sessionId) return;
80668
+ const own2 = ownership ?? turnSelectionOwnership(events);
80669
+ const seen2 = /* @__PURE__ */ new Set();
80670
+ const ordered = [];
80671
+ for (const cluster of clusters) {
80672
+ if (cluster.kind !== "single" || isRowHidden(cluster.row)) continue;
80673
+ for (const raw2 of rowTurnIds(cluster.row)) {
80674
+ const turnId = own2.get(raw2) ?? raw2;
80675
+ if (seen2.has(turnId)) continue;
80676
+ seen2.add(turnId);
80677
+ ordered.push(turnId);
80678
+ }
80679
+ }
80680
+ selectTurn.publishVisible(sessionId, ordered);
80681
+ }, [clusters, ownership, selectedTurnId, sessionId, showThinking]);
80222
80682
  const renderRow = (row, idx) => {
80223
80683
  const showCaret = idx === lastStreamingIdx;
80224
80684
  if ((row.kind === "thinking" || row.kind === "thinking-batch") && !showThinking) {
80225
80685
  return null;
80226
80686
  }
80227
- const highlighted = selectedTurnId !== null && ownership !== null && "turnId" in row ? isTurnHighlighted({ turnId: row.turnId }, selectedTurnId, ownership) : false;
80687
+ const highlighted = false;
80228
80688
  if (row.kind === "user-prompt") {
80229
80689
  const attachments = row.attachments ?? [];
80230
80690
  const hasRefs = (row.refs?.length ?? 0) > 0;
@@ -80306,33 +80766,55 @@ const Timeline = reactExports.memo(({ events, isStreaming, sessionId }) => {
80306
80766
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: containerRef, children: [
80307
80767
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-timeline relative pl-2 pr-1 py-1", children: [
80308
80768
  /* @__PURE__ */ jsxRuntimeExports.jsx(Spine, { active: isStreaming }),
80309
- clusters.map((cluster, ci) => {
80310
- if (cluster.kind === "single") {
80311
- if ((cluster.row.kind === "thinking" || cluster.row.kind === "thinking-batch") && !showThinking) {
80312
- return null;
80769
+ (() => {
80770
+ const out = [];
80771
+ let run3 = [];
80772
+ let runKey = null;
80773
+ const flush = () => {
80774
+ if (run3.length === 0) return;
80775
+ out.push(
80776
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionRing, { highlighted: true, children: run3 }, `sel-${runKey}`)
80777
+ );
80778
+ run3 = [];
80779
+ runKey = null;
80780
+ };
80781
+ clusters.forEach((cluster, ci) => {
80782
+ if (cluster.kind === "single") {
80783
+ if (isRowHidden(cluster.row)) return;
80784
+ const idx = rowIndex.get(cluster.row) ?? -1;
80785
+ const node2 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(cluster.row), children: renderRow(cluster.row, idx) }, cluster.row.id);
80786
+ if (isRowHighlighted(cluster.row)) {
80787
+ runKey ??= cluster.row.id;
80788
+ run3.push(node2);
80789
+ } else {
80790
+ flush();
80791
+ out.push(node2);
80792
+ }
80793
+ return;
80313
80794
  }
80314
- const idx = rowIndex.get(cluster.row) ?? -1;
80315
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(cluster.row), children: renderRow(cluster.row, idx) }, cluster.row.id);
80316
- }
80317
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
80318
- SubagentBlock,
80319
- {
80320
- childId: cluster.childId,
80321
- depth: cluster.depth,
80322
- rows: cluster.rows,
80323
- defaultCollapsed: collapseSubagents,
80324
- streaming: isStreaming,
80325
- children: cluster.rows.map((row) => {
80326
- if ((row.kind === "thinking" || row.kind === "thinking-batch") && !showThinking) {
80327
- return null;
80328
- }
80329
- const idx = rowIndex.get(row) ?? -1;
80330
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(row), children: renderRow(row, idx) }, row.id);
80331
- })
80332
- },
80333
- `group-${ci}-${cluster.childId}`
80334
- );
80335
- })
80795
+ flush();
80796
+ out.push(
80797
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
80798
+ SubagentBlock,
80799
+ {
80800
+ childId: cluster.childId,
80801
+ depth: cluster.depth,
80802
+ rows: cluster.rows,
80803
+ defaultCollapsed: collapseSubagents,
80804
+ streaming: isStreaming,
80805
+ children: cluster.rows.map((row) => {
80806
+ if (isRowHidden(row)) return null;
80807
+ const idx = rowIndex.get(row) ?? -1;
80808
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(row), children: renderRow(row, idx) }, row.id);
80809
+ })
80810
+ },
80811
+ `group-${ci}-${cluster.childId}`
80812
+ )
80813
+ );
80814
+ });
80815
+ flush();
80816
+ return out;
80817
+ })()
80336
80818
  ] }),
80337
80819
  /* @__PURE__ */ jsxRuntimeExports.jsx(TimelineKeyframes, {})
80338
80820
  ] });
@@ -80627,7 +81109,7 @@ function SelectionRing({ highlighted, children }) {
80627
81109
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
80628
81110
  "div",
80629
81111
  {
80630
- className: "relative rounded-md transition-colors duration-150",
81112
+ className: "relative -mx-2 px-2 pt-2 rounded-xl transition-colors duration-150",
80631
81113
  style: SELECTION_RING_STYLE,
80632
81114
  "data-select-cursor": "true",
80633
81115
  children
@@ -87853,293 +88335,51 @@ function RowItem({ row, merged }) {
87853
88335
  /* @__PURE__ */ jsxRuntimeExports.jsx(KeyHint, { spec })
87854
88336
  ] });
87855
88337
  }
87856
- function refKey(entry) {
87857
- return `${entry.providerKey}\0${entry.modelId}`;
87858
- }
87859
- function uniqueProviders(catalog) {
87860
- const seen2 = /* @__PURE__ */ new Map();
87861
- for (const entry of catalog) {
87862
- if (!seen2.has(entry.providerKey)) seen2.set(entry.providerKey, entry.providerLabel);
87863
- }
87864
- return [...seen2].map(([key2, label]) => ({ key: key2, label }));
87865
- }
87866
- function offCatalogRow(catalog, query, currentProviderKey) {
87867
- const custom = parseCustomModelQuery(query, uniqueProviders(catalog), currentProviderKey);
87868
- if (!custom) {
87869
- return null;
87870
- }
87871
- return {
87872
- providerKey: custom.providerKey,
87873
- providerLabel: custom.providerLabel,
87874
- modelId: custom.modelId,
87875
- modelName: custom.modelId,
87876
- contextWindow: null,
87877
- supportsReasoning: false,
87878
- options: [],
87879
- searchCorpus: "",
87880
- offCatalog: true
87881
- };
87882
- }
87883
- function selectedRowsFirst(entries, chain) {
87884
- if (chain.length === 0) {
87885
- return [...entries];
87886
- }
87887
- const byKey = new Map(entries.map((entry) => [`${entry.providerKey}\0${entry.modelId}`, entry]));
87888
- const selected = [];
87889
- const promoted = /* @__PURE__ */ new Set();
87890
- for (const pick of chain) {
87891
- const key2 = refKey(pick);
87892
- const entry = byKey.get(key2);
87893
- if (!entry || promoted.has(key2)) {
87894
- continue;
87895
- }
87896
- selected.push(entry);
87897
- promoted.add(key2);
87898
- }
87899
- return [...selected, ...entries.filter((entry) => !promoted.has(`${entry.providerKey}\0${entry.modelId}`))];
87900
- }
87901
88338
  function ModelPickerModal({ session, currentModelId, currentProviderKey }) {
87902
88339
  const modal = useModal();
87903
88340
  const { refresh: refreshSessions, setDefaultModel } = useSessions();
87904
- const { settings } = useSettings();
87905
- const [catalog, setCatalog] = reactExports.useState(null);
87906
- const [loadError, setLoadError] = reactExports.useState(null);
87907
- const [query, setQuery] = reactExports.useState("");
87908
- const [cursor, setCursor] = reactExports.useState(0);
87909
- const inputRef = reactExports.useRef(null);
87910
- const listRef = reactExports.useRef(null);
87911
- const extensionKey = settings.enabledExtensions?.join("") ?? "*";
87912
88341
  const [initialChain] = reactExports.useState(
87913
88342
  () => currentProviderKey && currentModelId ? [{ providerKey: currentProviderKey, modelId: currentModelId }, ...session.modelFallbacks ?? []] : []
87914
88343
  );
87915
- const [chainState, setChainState] = reactExports.useState(initialChain);
87916
- reactExports.useEffect(() => {
87917
- let cancelled = false;
87918
- window.api.sessions.listModels(session.cwd).then((entries) => {
87919
- if (cancelled) {
87920
- return;
87921
- }
87922
- setCatalog(entries);
87923
- if (currentProviderKey && currentModelId) {
87924
- const idx = indexOfEntry(entries, {
87925
- providerKey: currentProviderKey,
87926
- modelId: currentModelId
87927
- });
87928
- if (idx >= 0) {
87929
- setCursor(idx);
87930
- }
87931
- }
87932
- }).catch((err) => {
87933
- if (!cancelled) {
87934
- setLoadError(err.message ?? String(err));
87935
- }
87936
- });
87937
- return () => {
87938
- cancelled = true;
87939
- };
87940
- }, [currentProviderKey, currentModelId, session.cwd, extensionKey]);
87941
- reactExports.useEffect(() => {
87942
- inputRef.current?.focus();
87943
- }, []);
87944
- const filtered = reactExports.useMemo(() => {
87945
- if (!catalog) {
87946
- return [];
87947
- }
87948
- const matches2 = filterModelCatalog(catalog, query);
87949
- if (matches2.length > 0) {
87950
- return query.trim() ? matches2 : selectedRowsFirst(matches2, chainState);
87951
- }
87952
- const row = offCatalogRow(catalog, query, currentProviderKey);
87953
- return row ? [row] : [];
87954
- }, [catalog, query, chainState, currentProviderKey]);
87955
- reactExports.useEffect(() => {
87956
- if (filtered.length === 0) {
87957
- setCursor(0);
87958
- return;
87959
- }
87960
- setCursor((c) => Math.min(c, filtered.length - 1));
87961
- }, [filtered.length]);
87962
- reactExports.useEffect(() => {
87963
- const list2 = listRef.current;
87964
- if (!list2) {
87965
- return;
87966
- }
87967
- const row = list2.querySelector(`[data-row="${cursor}"]`);
87968
- row?.scrollIntoView({ block: "nearest" });
87969
- }, [cursor]);
87970
- const pick = (entry) => {
87971
- setChainState((prev) => pickPrimaryKeyed(prev, { providerKey: entry.providerKey, modelId: entry.modelId }, refKey));
87972
- };
87973
- const toggle = (entry) => {
87974
- setChainState((prev) => toggleKeyed(prev, { providerKey: entry.providerKey, modelId: entry.modelId }, refKey));
87975
- };
88344
+ const draft = reactExports.useRef(initialChain);
87976
88345
  const handleClose = () => {
87977
- const primary = chainState[0];
87978
- if (!primary || chainsEqualKeyed(chainState, initialChain, refKey)) {
88346
+ const chain = draft.current;
88347
+ const primary = chain[0];
88348
+ if (!primary || chainsEqualKeyed(chain, initialChain, refKey)) {
87979
88349
  modal.close();
87980
88350
  return;
87981
88351
  }
87982
- const fallbacks = chainState.slice(1);
87983
88352
  void (async () => {
87984
- await window.api.sessions.setModel(session.id, primary.providerKey, primary.modelId, fallbacks);
88353
+ await window.api.sessions.setModel(session.id, primary.providerKey, primary.modelId, chain.slice(1));
87985
88354
  setDefaultModel(primary.providerKey, primary.modelId);
87986
88355
  await window.api.state.set({
87987
- lastModelChain: chainState.map((e) => ({ provider: e.providerKey, model: e.modelId }))
88356
+ lastModelChain: chain.map((e) => ({ provider: e.providerKey, model: e.modelId }))
87988
88357
  });
87989
88358
  await refreshSessions();
87990
88359
  modal.close();
87991
88360
  })();
87992
88361
  };
87993
- reactExports.useEffect(() => {
87994
- const onKey = (e) => {
87995
- if (e.ctrlKey && e.shiftKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
87996
- e.preventDefault();
87997
- const row = filtered[cursor];
87998
- if (!row) {
87999
- return;
88000
- }
88001
- const key2 = `${row.providerKey}\0${row.modelId}`;
88002
- const delta = e.key === "ArrowUp" ? -1 : 1;
88003
- setChainState((prev) => {
88004
- const reordered = reorderKeyed(prev, key2, delta, refKey);
88005
- if (reordered !== prev && !query.trim()) {
88006
- const served = new Set((catalog ?? []).map((entry) => `${entry.providerKey}\0${entry.modelId}`));
88007
- const next = reordered.filter((entry) => served.has(refKey(entry))).findIndex((entry) => refKey(entry) === key2);
88008
- if (next >= 0) {
88009
- setCursor(next);
88010
- }
88011
- }
88012
- return reordered === prev ? prev : [...reordered];
88013
- });
88014
- return;
88015
- }
88016
- if (e.key === "ArrowDown") {
88017
- e.preventDefault();
88018
- setCursor((c) => Math.min(Math.max(0, filtered.length - 1), c + 1));
88019
- } else if (e.key === "ArrowUp") {
88020
- e.preventDefault();
88021
- setCursor((c) => Math.max(0, c - 1));
88022
- } else if (e.key === "Tab" || e.key === "Enter" && e.shiftKey) {
88023
- e.preventDefault();
88024
- const entry = filtered[cursor];
88025
- if (entry) toggle(entry);
88026
- } else if (e.key === "Enter") {
88027
- e.preventDefault();
88028
- const entry = filtered[cursor];
88029
- if (entry) {
88030
- pick(entry);
88031
- }
88032
- }
88033
- };
88034
- document.addEventListener("keydown", onKey);
88035
- return () => document.removeEventListener("keydown", onKey);
88036
- }, [cursor, filtered, query, catalog]);
88037
- const multi = chainState.length > 1;
88038
88362
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
88039
88363
  ModalShell,
88040
88364
  {
88041
88365
  title: "Model",
88042
- description: `Pick the model used by "${session.title}" — add more to build a fallback chain.`,
88366
+ description: `Pick the model used by "${session.title}"; add more to build a fallback chain.`,
88043
88367
  onClose: handleClose,
88044
88368
  size: "large",
88045
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col min-h-0 max-h-[min(70vh,560px)]", children: [
88046
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 pt-3 pb-2 border-b border-[var(--zg-border)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
88047
- "input",
88048
- {
88049
- ref: inputRef,
88050
- value: query,
88051
- onChange: (e) => setQuery(e.target.value),
88052
- placeholder: "Search models — try `claude opus` or `gpt mini`…",
88053
- className: "w-full h-8 text-sm bg-[var(--zg-bg)] border border-[var(--zg-border)] rounded-md px-3 text-[var(--zg-text)] outline-none focus:border-[var(--zg-accent)] focus:ring-2 focus:ring-[var(--zg-accent)]/20",
88054
- spellCheck: false,
88055
- autoCorrect: "off"
88056
- }
88057
- ) }),
88058
- catalog === null && !loadError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: "Loading…" }),
88059
- loadError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-6 text-xs text-[#ef4444]", children: [
88060
- "Failed to load models: ",
88061
- loadError
88062
- ] }),
88063
- catalog !== null && filtered.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: catalog.length === 0 ? "No authenticated providers — open Settings → Authentication to sign in." : 'Type a model id to use it anyway — prefix with a provider name to target one (e.g. "xai grok-9").' }),
88064
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: listRef, className: "flex-1 overflow-y-auto list-none m-0 p-2 flex flex-col gap-0.5", children: filtered.map((entry, idx) => {
88065
- const position2 = positionKeyed(
88066
- chainState,
88067
- refKey({ providerKey: entry.providerKey, modelId: entry.modelId }),
88068
- refKey
88069
- );
88070
- const isCursor = idx === cursor;
88071
- return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
88072
- "button",
88073
- {
88074
- type: "button",
88075
- "data-row": idx,
88076
- onMouseEnter: () => setCursor(idx),
88077
- onClick: (e) => e.shiftKey ? toggle(entry) : pick(entry),
88078
- className: `zg-press-subtle w-full text-left flex items-center gap-3 px-3 py-2 rounded-lg border-0 cursor-pointer transition-colors duration-150 ${isCursor ? "bg-[var(--zg-bg-hover)] text-[var(--zg-text)]" : "bg-transparent text-[var(--zg-text-muted)] hover:text-[var(--zg-text)]"}`,
88079
- children: [
88080
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 shrink-0 flex items-center justify-center", children: multi && position2 !== null ? /* @__PURE__ */ jsxRuntimeExports.jsx(
88081
- "span",
88082
- {
88083
- className: "text-[11px] font-semibold tabular-nums text-[var(--zg-accent)]",
88084
- title: position2 === 1 ? "Primary model" : `Fallback #${position2 - 1}`,
88085
- children: position2 > 9 ? "+" : position2
88086
- }
88087
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionDot, { active: position2 !== null }) }),
88088
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex-1 min-w-0 truncate", children: [
88089
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[13px] text-[var(--zg-text)]", children: entry.modelId }),
88090
- entry.modelName !== entry.modelId && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-xs text-[var(--zg-text-muted)]", children: entry.modelName })
88091
- ] }),
88092
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 flex items-center gap-1.5 text-[var(--zg-text-muted)]", children: [
88093
- entry.offCatalog ? (
88094
- // A stub has no capability metadata — say why rather than
88095
- // print an empty window column. Same wording as the TUI.
88096
- /* @__PURE__ */ jsxRuntimeExports.jsx(
88097
- "span",
88098
- {
88099
- className: "text-[11px] text-[#f59e0b]",
88100
- title: "Used as typed; no metadata is known for this id",
88101
- children: "not in catalog"
88102
- }
88103
- )
88104
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-11 text-right text-[11px] tabular-nums", title: "Context window", children: entry.contextWindow !== null ? formatWindow(entry.contextWindow) : "" }),
88105
- entry.supportsReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx(
88106
- "span",
88107
- {
88108
- className: "inline-flex items-center h-[18px] rounded-md border border-[var(--zg-border)] px-1.5 text-[10px]",
88109
- title: "Supports reasoning effort (Ctrl+L)",
88110
- children: "reason"
88111
- }
88112
- ),
88113
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex items-center h-[18px] rounded-md border border-[var(--zg-border)] px-1.5 text-[10px]", children: entry.providerLabel })
88114
- ] })
88115
- ]
88116
- }
88117
- ) }, `${entry.providerKey}:${entry.modelId}`);
88118
- }) }),
88119
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-2 border-t border-[var(--zg-border)] flex items-center gap-3 text-[11px] text-[var(--zg-text-muted)]", children: [
88120
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "↵ use as primary" }),
88121
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "⇥ add/remove fallback" }),
88122
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "ctrl+shift+↑↓ reorder" }),
88123
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "esc applies" }),
88124
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-auto text-[var(--zg-accent)]", "data-testid": "model-chain-count", children: [
88125
- chainState.length,
88126
- " selected",
88127
- multi ? " — order = fallback priority" : ""
88128
- ] })
88129
- ] })
88130
- ] })
88369
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
88370
+ ModelChainPicker,
88371
+ {
88372
+ initialChain,
88373
+ cwd: session.cwd,
88374
+ onChainChange: (chain) => {
88375
+ draft.current = chain;
88376
+ },
88377
+ className: "max-h-[min(70vh,560px)]"
88378
+ }
88379
+ )
88131
88380
  }
88132
88381
  );
88133
88382
  }
88134
- function formatWindow(tokens) {
88135
- if (tokens >= 1e6) {
88136
- return `${(tokens / 1e6).toFixed(2)}M`;
88137
- }
88138
- if (tokens >= 1e3) {
88139
- return `${Math.round(tokens / 1e3)}k`;
88140
- }
88141
- return `${tokens}`;
88142
- }
88143
88383
  function SafelistPanel({ onClose, onBack }) {
88144
88384
  const [groups, setGroups] = reactExports.useState(null);
88145
88385
  const [error, setError] = reactExports.useState(null);
@@ -89016,15 +89256,15 @@ function CredentialSources({
89016
89256
  }
89017
89257
  ),
89018
89258
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-mono ${method.active ? "text-[var(--zg-accent)]" : "text-[var(--zg-text)]"}`, children: method.source }),
89019
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] truncate min-w-0", title: method.detail, children: method.detail }),
89020
- method.active && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)]", children: "(in use)" }),
89259
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] truncate min-w-0 shrink", title: method.detail, children: method.detail }),
89260
+ method.active && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] shrink-0", children: "(in use)" }),
89021
89261
  selectable && /* @__PURE__ */ jsxRuntimeExports.jsx(
89022
89262
  "button",
89023
89263
  {
89024
89264
  type: "button",
89025
89265
  disabled: busy !== null,
89026
89266
  onClick: () => void use(method.source),
89027
- className: "zg-press ml-auto h-6 px-2 rounded text-xs text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border border-[var(--zg-border)] bg-transparent cursor-pointer disabled:opacity-40",
89267
+ className: "zg-press ml-1 h-5 px-1.5 shrink-0 rounded text-[11px] leading-none text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border border-[var(--zg-border)] bg-transparent cursor-pointer disabled:opacity-40",
89028
89268
  title: `Make the ${method.source} credential the one zidane uses for ${status.label}`,
89029
89269
  children: busy === method.source ? "Switching…" : "Use"
89030
89270
  }
@@ -90884,7 +91124,14 @@ function ModelListPicker({
90884
91124
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-mono text-sm text-[var(--zg-text)]", children: entry.modelId }),
90885
91125
  entry.modelName !== entry.modelId && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-xs text-[var(--zg-text-muted)]", children: entry.modelName })
90886
91126
  ] }),
90887
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 rounded-md bg-[var(--zg-bg)] border border-[var(--zg-border)] px-1.5 py-0.5 text-[10px] text-[var(--zg-text-muted)]", children: entry.providerLabel })
91127
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
91128
+ "span",
91129
+ {
91130
+ className: "shrink-0 rounded-md px-1.5 py-0.5 text-[10px]",
91131
+ style: { color: providerColor(entry.providerKey), background: providerTint(entry.providerKey) },
91132
+ children: entry.providerLabel
91133
+ }
91134
+ )
90888
91135
  ]
90889
91136
  }
90890
91137
  ) }, `${entry.providerKey}:${entry.modelId}`);
@@ -92878,7 +93125,7 @@ function AppShell() {
92878
93125
  selectTurnRef.current.exit();
92879
93126
  return;
92880
93127
  }
92881
- const ids = selectableTurnIds(peekEvents(session.id), settingsRef.current);
93128
+ const ids = selectTurnRef.current.visibleIds(session.id) ?? selectableTurnIds(peekEvents(session.id), settingsRef.current);
92882
93129
  if (ids.length === 0) {
92883
93130
  return;
92884
93131
  }