zidane-gui 7.0.16 → 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.
@@ -12478,6 +12478,22 @@ function requireClient() {
12478
12478
  }
12479
12479
  var clientExports = requireClient();
12480
12480
  const ReactDOM$1 = /* @__PURE__ */ getDefaultExportFromCjs(clientExports);
12481
+ function formatSessionCostLabel(usd) {
12482
+ return usd > 0 ? `$${usd.toFixed(3)}` : null;
12483
+ }
12484
+ function composeLiveCost(fetched, accrued, progress) {
12485
+ const live = progress?.estCostUsd ?? 0;
12486
+ const total = (fetched?.totalCost ?? 0) + accrued + live;
12487
+ if (total <= 0) {
12488
+ return null;
12489
+ }
12490
+ return {
12491
+ totalCost: total,
12492
+ runCount: fetched?.runCount ?? 0,
12493
+ label: formatSessionCostLabel(total),
12494
+ estimated: live > 0
12495
+ };
12496
+ }
12481
12497
  function utf8ByteLength(text2) {
12482
12498
  let bytes = 0;
12483
12499
  for (let i = 0; i < text2.length; i++) {
@@ -14589,6 +14605,13 @@ function retryLabel(info) {
14589
14605
  const suffix = info.source === "parent" ? "" : ` · ${info.source}`;
14590
14606
  return `retrying ${info.attempt}/${info.max}${suffix}`;
14591
14607
  }
14608
+ function streamingLabel(progress, opts = {}) {
14609
+ if (!progress || progress.outputTokens <= 0) return "";
14610
+ const count2 = `↓${progress.estimated ? "~" : ""}${fmtTokens(progress.outputTokens)}`;
14611
+ if (opts.rate === false || progress.elapsedMs < 2e3) return count2;
14612
+ const perSecond = Math.round(progress.outputTokens / (progress.elapsedMs / 1e3));
14613
+ return perSecond > 0 ? `${count2} · ${perSecond} tok/s` : count2;
14614
+ }
14592
14615
  function compactingLabel(estTokens, startedAt, now = Date.now()) {
14593
14616
  const base2 = "Compacting...";
14594
14617
  const elapsedMs = typeof startedAt === "number" ? now - startedAt : 0;
@@ -15383,6 +15406,12 @@ const DEFAULT_SETTINGS = {
15383
15406
  * default this off to keep the transcript calm.
15384
15407
  */
15385
15408
  showThrobber: false,
15409
+ /**
15410
+ * Session artifacts — what a session produced (PRs, branches, commits,
15411
+ * recorded files). Canonical default on; off hides the rail, header chip
15412
+ * and `#pr` completion and stops detection + the `record_artifact` tool.
15413
+ */
15414
+ artifacts: true,
15386
15415
  /**
15387
15416
  * Toggle the active-todos summary above the chatbox (5.4). The
15388
15417
  * `BUILD_AGENT` preset wires `todowrite` / `todoread` so the model writes
@@ -15533,6 +15562,7 @@ const SETTINGS_TOGGLES = [
15533
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)`
15534
15563
  },
15535
15564
  { key: "showThrobber", label: "Throbber", description: "animated indicator while the agent is working" },
15565
+ { key: "artifacts", label: "Artifacts", description: "track pull requests, branches, commits and recorded files per session" },
15536
15566
  {
15537
15567
  key: "showTodoIndicator",
15538
15568
  label: "Todo indicator",
@@ -15773,6 +15803,42 @@ function useSettings() {
15773
15803
  }
15774
15804
  return ctx;
15775
15805
  }
15806
+ function readPersisted(key2, parse2) {
15807
+ try {
15808
+ const raw2 = localStorage.getItem(key2);
15809
+ return raw2 === null ? void 0 : parse2(raw2);
15810
+ } catch {
15811
+ return void 0;
15812
+ }
15813
+ }
15814
+ function writePersisted(key2, value) {
15815
+ try {
15816
+ if (value === null || value === void 0) {
15817
+ localStorage.removeItem(key2);
15818
+ } else {
15819
+ localStorage.setItem(key2, value);
15820
+ }
15821
+ } catch {
15822
+ }
15823
+ }
15824
+ function usePersistedState(key2, fallback, parse2, serialize2 = (v2) => v2 === null || v2 === void 0 ? null : String(v2)) {
15825
+ const [value, setValue] = reactExports.useState(() => readPersisted(key2, parse2) ?? fallback);
15826
+ const set2 = reactExports.useCallback(
15827
+ (next) => {
15828
+ setValue((prev) => {
15829
+ const resolved = typeof next === "function" ? next(prev) : next;
15830
+ writePersisted(key2, serialize2(resolved));
15831
+ return resolved;
15832
+ });
15833
+ },
15834
+ [key2, serialize2]
15835
+ );
15836
+ return [value, set2];
15837
+ }
15838
+ function oneOf(members) {
15839
+ return (raw2) => members.includes(raw2) ? raw2 : void 0;
15840
+ }
15841
+ const parseBoolean = (raw2) => raw2 === "true" ? true : raw2 === "false" ? false : void 0;
15776
15842
  const SMOOTH_BASE_CPS = 200;
15777
15843
  const SMOOTH_BURST_CPS = 600;
15778
15844
  const SMOOTH_BURST_THRESHOLD = 100;
@@ -16971,20 +17037,31 @@ function SessionsProvider({ children }) {
16971
17037
  const rawSessionsRef = reactExports.useRef(rawSessions);
16972
17038
  rawSessionsRef.current = rawSessions;
16973
17039
  const [activeSessionId, setActiveSessionIdState] = reactExports.useState(null);
16974
- const [archiveFilter, setArchiveFilterState] = reactExports.useState("active");
16975
- const [projectFilter, setProjectFilterState] = reactExports.useState(null);
16976
- const [activityFilter, setActivityFilterState] = reactExports.useState("all");
16977
- const [groupBy, setGroupByState] = reactExports.useState(() => {
16978
- try {
16979
- const stored = localStorage.getItem("zg-sidebar-group-by");
16980
- if (stored === "none" || stored === "date" || stored === "state" || stored === "project") {
16981
- return stored;
16982
- }
16983
- } catch {
16984
- }
16985
- return "project";
16986
- });
16987
- const [sortBy, setSortByState] = reactExports.useState("recency");
17040
+ const [archiveFilter, setArchiveFilterState] = usePersistedState(
17041
+ "zg-sidebar-archive-filter",
17042
+ "active",
17043
+ oneOf(["active", "archived", "all"])
17044
+ );
17045
+ const [projectFilter, setProjectFilterState] = usePersistedState(
17046
+ "zg-sidebar-project-filter",
17047
+ null,
17048
+ (raw2) => raw2.length > 0 ? raw2 : void 0
17049
+ );
17050
+ const [activityFilter, setActivityFilterState] = usePersistedState(
17051
+ "zg-sidebar-activity-filter",
17052
+ "all",
17053
+ oneOf(["all", "1d", "3d", "7d", "30d"])
17054
+ );
17055
+ const [groupBy, setGroupByState] = usePersistedState(
17056
+ "zg-sidebar-group-by",
17057
+ "project",
17058
+ oneOf(["none", "date", "state", "project"])
17059
+ );
17060
+ const [sortBy, setSortByState] = usePersistedState(
17061
+ "zg-sidebar-sort-by",
17062
+ "recency",
17063
+ oneOf(["recency", "createdTime", "alphabetical"])
17064
+ );
16988
17065
  const [defaultFolder, setDefaultFolderState] = reactExports.useState(null);
16989
17066
  const [defaultAgentId, setDefaultAgentIdState] = reactExports.useState("build");
16990
17067
  const [defaultProviderKey, setDefaultProviderKeyState] = reactExports.useState(null);
@@ -16995,9 +17072,6 @@ function SessionsProvider({ children }) {
16995
17072
  if (cancelled || !s2) {
16996
17073
  return;
16997
17074
  }
16998
- if (typeof s2.lastAgent === "string" && s2.lastAgent.length > 0) {
16999
- setDefaultAgentIdState(s2.lastAgent);
17000
- }
17001
17075
  const lastProvider = typeof s2.lastProvider === "string" ? s2.lastProvider : null;
17002
17076
  const lastModel = lastProvider && s2.lastModelByProvider && typeof s2.lastModelByProvider === "object" ? s2.lastModelByProvider[lastProvider] ?? null : null;
17003
17077
  if (lastProvider && lastModel) {
@@ -17011,7 +17085,6 @@ function SessionsProvider({ children }) {
17011
17085
  }, []);
17012
17086
  const setDefaultAgentId = reactExports.useCallback((id) => {
17013
17087
  setDefaultAgentIdState(id);
17014
- void window.api.state.set({ lastAgent: id });
17015
17088
  }, []);
17016
17089
  const setDefaultModel = reactExports.useCallback((providerKey, modelId) => {
17017
17090
  setDefaultProviderKeyState(providerKey);
@@ -17308,10 +17381,6 @@ function SessionsProvider({ children }) {
17308
17381
  }, []);
17309
17382
  const setGroupBy = reactExports.useCallback((next) => {
17310
17383
  setGroupByState(next);
17311
- try {
17312
- localStorage.setItem("zg-sidebar-group-by", next);
17313
- } catch {
17314
- }
17315
17384
  }, []);
17316
17385
  const setSortBy = reactExports.useCallback((next) => {
17317
17386
  setSortByState(next);
@@ -17630,7 +17699,15 @@ function SelectTurnProvider({ children }) {
17630
17699
  });
17631
17700
  }, []);
17632
17701
  const exit2 = reactExports.useCallback(() => setState(null), []);
17633
- 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
+ );
17634
17711
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTurnContext.Provider, { value, children });
17635
17712
  }
17636
17713
  function useSelectTurn() {
@@ -42981,6 +43058,17 @@ function AskUserModal({ request }) {
42981
43058
  modal.close();
42982
43059
  }
42983
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
+ };
42984
43072
  const setAnswer = (id, value) => {
42985
43073
  setAnswers((prev) => ({ ...prev, [id]: value }));
42986
43074
  };
@@ -42991,8 +43079,19 @@ function AskUserModal({ request }) {
42991
43079
  description: `The agent paused to ask ${payload.questions.length === 1 ? "1 question" : `${payload.questions.length} questions`}.`,
42992
43080
  onClose: dismiss,
42993
43081
  size: "xlarge",
42994
- footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-3", children: [
42995
- /* @__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
+ ),
42996
43095
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
42997
43096
  "button",
42998
43097
  {
@@ -72710,6 +72809,55 @@ function createMentionRenderer(activeRef, kind, options) {
72710
72809
  }
72711
72810
  };
72712
72811
  }
72812
+ const SWAP_OUT_MS = 140;
72813
+ function Presence$1({ show, children, className = "", display = "inline" }) {
72814
+ const [mounted, setMounted] = reactExports.useState(show);
72815
+ const timer = reactExports.useRef(null);
72816
+ reactExports.useEffect(() => {
72817
+ if (show) {
72818
+ if (timer.current) clearTimeout(timer.current);
72819
+ timer.current = null;
72820
+ setMounted(true);
72821
+ return;
72822
+ }
72823
+ if (!mounted) return;
72824
+ timer.current = setTimeout(() => {
72825
+ timer.current = null;
72826
+ setMounted(false);
72827
+ }, SWAP_OUT_MS);
72828
+ return () => {
72829
+ if (timer.current) clearTimeout(timer.current);
72830
+ };
72831
+ }, [show, mounted]);
72832
+ if (!mounted) return null;
72833
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
72834
+ "span",
72835
+ {
72836
+ className: `zg-presence ${display === "block" ? "block" : "inline-flex items-center"} ${className}`,
72837
+ "data-state": show ? "enter" : "exit",
72838
+ children
72839
+ }
72840
+ );
72841
+ }
72842
+ function Crossfade({ activeKey, children, className = "" }) {
72843
+ const [previous2, setPrevious] = reactExports.useState(null);
72844
+ const lastRef = reactExports.useRef({ key: activeKey, node: children });
72845
+ reactExports.useEffect(() => {
72846
+ const last = lastRef.current;
72847
+ if (last.key === activeKey) {
72848
+ lastRef.current = { key: activeKey, node: children };
72849
+ return;
72850
+ }
72851
+ setPrevious(last);
72852
+ lastRef.current = { key: activeKey, node: children };
72853
+ const timer = setTimeout(() => setPrevious(null), SWAP_OUT_MS);
72854
+ return () => clearTimeout(timer);
72855
+ }, [activeKey, children]);
72856
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `zg-crossfade ${className}`, children: [
72857
+ previous2 && previous2.key !== activeKey && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-crossfade-item", "data-state": "exit", "aria-hidden": true, children: previous2.node }, `out-${String(previous2.key)}`),
72858
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-crossfade-item", "data-state": "enter", children }, `in-${String(activeKey)}`)
72859
+ ] });
72860
+ }
72713
72861
  function filterModelCatalog(catalog, query) {
72714
72862
  const q2 = query.trim().toLowerCase();
72715
72863
  if (q2.length === 0) {
@@ -72717,11 +72865,392 @@ function filterModelCatalog(catalog, query) {
72717
72865
  }
72718
72866
  return catalog.filter((entry) => entry.searchCorpus.includes(q2));
72719
72867
  }
72720
- function indexOfEntry(catalog, target) {
72721
- return catalog.findIndex(
72722
- (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
+ }
72723
72879
  );
72724
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
+ }
72892
+ );
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
+ }
72725
73254
  const DEFAULT_DIFF = {
72726
73255
  addBg: "#0e2218",
72727
73256
  removeBg: "#2a1414",
@@ -73434,32 +73963,6 @@ function AgentSelector({ activeSession, defaultAgentId, onDefaultAgentChange })
73434
73963
  )
73435
73964
  ] });
73436
73965
  }
73437
- function SelectionDot({ active }) {
73438
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
73439
- "span",
73440
- {
73441
- "aria-hidden": true,
73442
- className: "inline-block w-2 h-2 rounded-full shrink-0 transition-[background-color,border-color] duration-150",
73443
- style: {
73444
- background: active ? "var(--zg-accent)" : "transparent",
73445
- border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
73446
- }
73447
- }
73448
- );
73449
- }
73450
- function ToggleBox({ active }) {
73451
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
73452
- "span",
73453
- {
73454
- "aria-hidden": true,
73455
- className: "inline-block w-2 h-2 rounded-[3px] shrink-0 transition-[background-color,border-color] duration-150",
73456
- style: {
73457
- background: active ? "var(--zg-accent)" : "transparent",
73458
- border: active ? "1px solid var(--zg-accent)" : "1px solid var(--zg-border)"
73459
- }
73460
- }
73461
- );
73462
- }
73463
73966
  function ChatboxControls({
73464
73967
  activeSession,
73465
73968
  defaultAgentId,
@@ -73470,7 +73973,29 @@ function ChatboxControls({
73470
73973
  activeModelOptions,
73471
73974
  activeEnabledOptions
73472
73975
  }) {
73473
- 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
+ };
73474
73999
  const { settings } = useSettings();
73475
74000
  const catalogCwd = activeSession?.cwd ?? defaultFolder ?? void 0;
73476
74001
  const extensionKey = settings.enabledExtensions?.join("") ?? "*";
@@ -73536,7 +74061,8 @@ function ChatboxControls({
73536
74061
  }
73537
74062
  ),
73538
74063
  ariaLabel: activeSession ? "Switch model" : "Pick default model",
73539
- width: 420,
74064
+ width: 440,
74065
+ onDismiss: () => void commitModelDraft(),
73540
74066
  render: (close2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
73541
74067
  ModelMenu,
73542
74068
  {
@@ -73546,7 +74072,8 @@ function ChatboxControls({
73546
74072
  catalog,
73547
74073
  cwd: catalogCwd,
73548
74074
  onClose: close2,
73549
- onPickDefault: setDefaultModel
74075
+ onPickDefault: setDefaultModel,
74076
+ draftRef: modelDraftRef
73550
74077
  }
73551
74078
  )
73552
74079
  }
@@ -73662,16 +74189,18 @@ function ChatboxStatusPills({
73662
74189
  activeSession,
73663
74190
  contextStatus,
73664
74191
  costStatus,
74192
+ streaming = null,
73665
74193
  runningWorkCount = 0,
73666
74194
  onOpenRunningWork
73667
74195
  }) {
73668
74196
  if (!activeSession) {
73669
74197
  return null;
73670
74198
  }
73671
- if (!contextStatus && !costStatus?.label && runningWorkCount === 0) {
74199
+ if (!contextStatus && !costStatus?.label && runningWorkCount === 0 && !streaming) {
73672
74200
  return null;
73673
74201
  }
73674
74202
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-chatbox-status flex items-center gap-2 min-w-0", children: [
74203
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StreamingChip, { progress: streaming, cost: costStatus }),
73675
74204
  runningWorkCount > 0 && onOpenRunningWork && /* @__PURE__ */ jsxRuntimeExports.jsxs(
73676
74205
  "button",
73677
74206
  {
@@ -73688,27 +74217,102 @@ function ChatboxStatusPills({
73688
74217
  contextStatus && /* @__PURE__ */ jsxRuntimeExports.jsx(ContextOrb, { status: contextStatus, cost: costStatus, sessionId: activeSession.id })
73689
74218
  ] });
73690
74219
  }
74220
+ function useTweenedCount(target) {
74221
+ const [shown, setShown] = reactExports.useState(target);
74222
+ const shownRef = reactExports.useRef(target);
74223
+ const frame = reactExports.useRef(null);
74224
+ reactExports.useEffect(() => {
74225
+ const reduce = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
74226
+ if (reduce || target < shownRef.current) {
74227
+ shownRef.current = target;
74228
+ setShown(target);
74229
+ return;
74230
+ }
74231
+ const from2 = shownRef.current;
74232
+ const delta = target - from2;
74233
+ if (delta === 0) {
74234
+ return;
74235
+ }
74236
+ const started = performance.now();
74237
+ const DURATION_MS = 300;
74238
+ const step = (now) => {
74239
+ const t = Math.min(1, (now - started) / DURATION_MS);
74240
+ const eased = 1 - (1 - t) * (1 - t);
74241
+ const value = Math.round(from2 + delta * eased);
74242
+ shownRef.current = value;
74243
+ setShown(value);
74244
+ if (t < 1) {
74245
+ frame.current = requestAnimationFrame(step);
74246
+ } else {
74247
+ frame.current = null;
74248
+ }
74249
+ };
74250
+ if (frame.current !== null) {
74251
+ cancelAnimationFrame(frame.current);
74252
+ }
74253
+ frame.current = requestAnimationFrame(step);
74254
+ return () => {
74255
+ if (frame.current !== null) {
74256
+ cancelAnimationFrame(frame.current);
74257
+ frame.current = null;
74258
+ }
74259
+ };
74260
+ }, [target]);
74261
+ return shown;
74262
+ }
74263
+ function StreamingChip({ progress, cost }) {
74264
+ const lastProgress = reactExports.useRef(null);
74265
+ if (progress !== null) {
74266
+ lastProgress.current = progress;
74267
+ }
74268
+ const shown = progress ?? lastProgress.current;
74269
+ const tweened = useTweenedCount(shown?.outputTokens ?? 0);
74270
+ const show = progress !== null && progress.outputTokens > 0;
74271
+ const label = shown ? streamingLabel({ ...shown, outputTokens: tweened }) : "";
74272
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show, className: "shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
74273
+ "span",
74274
+ {
74275
+ className: "inline-flex items-center gap-1.5 h-6 px-2 rounded-full bg-[var(--zg-bg-hover)] border border-[var(--zg-border)] text-[11px] tabular-nums text-[var(--zg-text-muted)] whitespace-nowrap",
74276
+ title: shown?.estimated ? "Tokens estimated from streamed text; settles at turn end" : "Tokens counted by the provider",
74277
+ "aria-live": "off",
74278
+ children: [
74279
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-accent)]", children: label }),
74280
+ cost?.label && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { style: { color: cost.estimated ? "var(--zg-text-muted)" : "var(--zg-money)" }, children: [
74281
+ cost.estimated ? "~" : "",
74282
+ cost.label
74283
+ ] })
74284
+ ]
74285
+ }
74286
+ ) });
74287
+ }
73691
74288
  function Popover({
73692
74289
  trigger,
73693
74290
  render: render2,
73694
74291
  ariaLabel,
73695
74292
  width,
73696
- align = "left"
74293
+ align = "left",
74294
+ onDismiss
73697
74295
  }) {
73698
74296
  const [open, setOpen] = reactExports.useState(false);
73699
74297
  const wrapperRef = reactExports.useRef(null);
74298
+ const dismissRef = reactExports.useRef(onDismiss);
74299
+ dismissRef.current = onDismiss;
73700
74300
  reactExports.useEffect(() => {
73701
74301
  if (!open) {
73702
74302
  return void 0;
73703
74303
  }
74304
+ const dismiss = () => {
74305
+ setOpen(false);
74306
+ dismissRef.current?.();
74307
+ };
73704
74308
  const onDown = (e) => {
73705
74309
  if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
73706
- setOpen(false);
74310
+ dismiss();
73707
74311
  }
73708
74312
  };
73709
74313
  const onKey = (e) => {
73710
74314
  if (e.key === "Escape") {
73711
- setOpen(false);
74315
+ dismiss();
73712
74316
  }
73713
74317
  };
73714
74318
  document.addEventListener("mousedown", onDown);
@@ -73719,7 +74323,12 @@ function Popover({
73719
74323
  };
73720
74324
  }, [open]);
73721
74325
  const close2 = reactExports.useCallback(() => setOpen(false), []);
73722
- 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
+ }, []);
73723
74332
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: wrapperRef, className: "relative inline-flex items-center", children: [
73724
74333
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73725
74334
  "button",
@@ -73771,134 +74380,43 @@ function ModelMenu({
73771
74380
  session,
73772
74381
  currentModelId,
73773
74382
  currentProviderKey,
73774
- catalog: outerCatalog,
74383
+ catalog,
73775
74384
  cwd: cwd2,
73776
74385
  onClose,
73777
- onPickDefault
74386
+ onPickDefault,
74387
+ draftRef
73778
74388
  }) {
73779
74389
  const { refresh } = useSessions();
73780
- const { settings } = useSettings();
73781
- const [catalog, setCatalog] = reactExports.useState(outerCatalog);
73782
- const [loadError, setLoadError] = reactExports.useState(null);
73783
- const [query, setQuery] = reactExports.useState("");
73784
- const [cursor, setCursor] = reactExports.useState(0);
73785
- const inputRef = reactExports.useRef(null);
73786
- const listRef = reactExports.useRef(null);
73787
- const extensionKey = settings.enabledExtensions?.join("") ?? "*";
73788
- reactExports.useEffect(() => {
73789
- if (outerCatalog) {
73790
- setCatalog(outerCatalog);
73791
- if (currentProviderKey && currentModelId) {
73792
- const idx = indexOfEntry(outerCatalog, { providerKey: currentProviderKey, modelId: currentModelId });
73793
- if (idx >= 0) setCursor(idx);
73794
- }
73795
- return void 0;
73796
- }
73797
- let cancelled = false;
73798
- window.api.sessions.listModels(cwd2).then((entries) => {
73799
- if (cancelled) return;
73800
- setCatalog(entries);
73801
- if (currentProviderKey && currentModelId) {
73802
- const idx = indexOfEntry(entries, { providerKey: currentProviderKey, modelId: currentModelId });
73803
- if (idx >= 0) setCursor(idx);
73804
- }
73805
- }).catch((err) => {
73806
- if (!cancelled) setLoadError(err.message ?? String(err));
73807
- });
73808
- return () => {
73809
- cancelled = true;
73810
- };
73811
- }, [outerCatalog, currentProviderKey, currentModelId, cwd2, extensionKey]);
73812
- reactExports.useEffect(() => {
73813
- inputRef.current?.focus();
73814
- }, []);
73815
- const filtered = reactExports.useMemo(() => catalog ? filterModelCatalog(catalog, query) : [], [catalog, query]);
73816
- reactExports.useEffect(() => {
73817
- if (filtered.length === 0) {
73818
- setCursor(0);
73819
- return;
73820
- }
73821
- setCursor((c) => Math.min(c, filtered.length - 1));
73822
- }, [filtered.length]);
73823
- reactExports.useEffect(() => {
73824
- const row = listRef.current?.querySelector(`[data-row="${cursor}"]`);
73825
- row?.scrollIntoView({ block: "nearest" });
73826
- }, [cursor]);
73827
- 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;
73828
74397
  if (session) {
73829
- await window.api.sessions.setModel(session.id, entry.providerKey, entry.modelId);
73830
- 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);
73831
74400
  await refresh();
73832
74401
  } else {
73833
- onPickDefault(entry.providerKey, entry.modelId);
74402
+ onPickDefault(primary.providerKey, primary.modelId);
73834
74403
  }
73835
74404
  onClose();
73836
74405
  };
73837
- reactExports.useEffect(() => {
73838
- const onKey = (e) => {
73839
- if (e.key === "ArrowDown") {
73840
- e.preventDefault();
73841
- setCursor((c) => Math.min(Math.max(0, filtered.length - 1), c + 1));
73842
- } else if (e.key === "ArrowUp") {
73843
- e.preventDefault();
73844
- setCursor((c) => Math.max(0, c - 1));
73845
- } else if (e.key === "Enter") {
73846
- e.preventDefault();
73847
- const entry = filtered[cursor];
73848
- if (entry) void apply2(entry);
73849
- }
73850
- };
73851
- document.addEventListener("keydown", onKey);
73852
- return () => document.removeEventListener("keydown", onKey);
73853
- }, [cursor, filtered]);
73854
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col max-h-[min(60vh,420px)]", children: [
73855
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-3 pt-3 pb-2 border-b border-[var(--zg-border)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
73856
- "input",
73857
- {
73858
- ref: inputRef,
73859
- value: query,
73860
- onChange: (e) => setQuery(e.target.value),
73861
- placeholder: "Search models…",
73862
- 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",
73863
- spellCheck: false,
73864
- autoCorrect: "off"
73865
- }
73866
- ) }),
73867
- catalog === null && !loadError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: "Loading…" }),
73868
- loadError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-6 text-xs text-[#ef4444]", children: [
73869
- "Failed to load models: ",
73870
- loadError
73871
- ] }),
73872
- 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." }),
73873
- /* @__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) => {
73874
- const isCurrent = entry.providerKey === currentProviderKey && entry.modelId === currentModelId;
73875
- const isCursor = idx === cursor;
73876
- return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
73877
- "button",
73878
- {
73879
- type: "button",
73880
- "data-row": idx,
73881
- onMouseEnter: () => setCursor(idx),
73882
- onClick: () => void apply2(entry),
73883
- 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)]"}`,
73884
- children: [
73885
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 shrink-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionDot, { active: isCurrent }) }),
73886
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1 min-w-0 truncate text-[13px] text-[var(--zg-text)]", children: entry.modelId }),
73887
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 flex items-center gap-1.5 text-[var(--zg-text-muted)]", children: [
73888
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-11 text-right text-[11px] tabular-nums", children: entry.contextWindow !== null ? formatWindow$1(entry.contextWindow) : "" }),
73889
- 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" }),
73890
- /* @__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 })
73891
- ] })
73892
- ]
73893
- }
73894
- ) }, `${entry.providerKey}:${entry.modelId}`);
73895
- }) })
73896
- ] });
73897
- }
73898
- function formatWindow$1(tokens) {
73899
- if (tokens >= 1e6) return `${(tokens / 1e6).toFixed(2)}M`;
73900
- if (tokens >= 1e3) return `${Math.round(tokens / 1e3)}k`;
73901
- 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
+ );
73902
74420
  }
73903
74421
  function ContextOrb({
73904
74422
  status,
@@ -73982,16 +74500,24 @@ function ContextOrb({
73982
74500
  /* @__PURE__ */ jsxRuntimeExports.jsx(ContextBreakdownSection, { sessionId, fallbackPct: pct, fallbackColor: color2 }),
73983
74501
  cost?.label && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between text-[11px]", children: [
73984
74502
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)]", children: "Session cost" }),
73985
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "tabular-nums", style: { color: "var(--zg-money)" }, children: [
73986
- cost.label,
73987
- cost.runCount !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-[var(--zg-text-muted)]", children: [
73988
- " ",
73989
- "· ",
73990
- cost.runCount,
73991
- " run",
73992
- cost.runCount === 1 ? "" : "s"
73993
- ] })
73994
- ] })
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
+ )
73995
74521
  ] })
73996
74522
  ] })
73997
74523
  }
@@ -74425,6 +74951,50 @@ function QueueEditArea({ value, onChange, onCommit, onCancel }) {
74425
74951
  }
74426
74952
  );
74427
74953
  }
74954
+ const ArtifactsContext = reactExports.createContext(null);
74955
+ function ArtifactsProvider({ children }) {
74956
+ const [byId, setById] = reactExports.useState(() => /* @__PURE__ */ new Map());
74957
+ const pending = reactExports.useRef(/* @__PURE__ */ new Set());
74958
+ const fetch = reactExports.useCallback(async (sessionId) => {
74959
+ const groups = await window.api.artifacts.list({ sessionId });
74960
+ setById((prev) => {
74961
+ const next = new Map(prev);
74962
+ next.set(sessionId, groups);
74963
+ return next;
74964
+ });
74965
+ }, []);
74966
+ reactExports.useEffect(() => {
74967
+ return window.api.chat.onStreamSignal((signal) => {
74968
+ if (signal.kind !== "artifact:recorded" && signal.kind !== "artifact:changed") return;
74969
+ const { sessionId } = signal;
74970
+ if (pending.current.has(sessionId)) return;
74971
+ pending.current.add(sessionId);
74972
+ queueMicrotask(() => {
74973
+ pending.current.delete(sessionId);
74974
+ void fetch(sessionId).catch(() => void 0);
74975
+ });
74976
+ });
74977
+ }, [fetch]);
74978
+ const groupsFor = reactExports.useCallback(
74979
+ (sessionId) => sessionId ? byId.get(sessionId) ?? null : null,
74980
+ [byId]
74981
+ );
74982
+ const value = reactExports.useMemo(() => ({ groupsFor, fetch }), [groupsFor, fetch]);
74983
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ArtifactsContext.Provider, { value, children });
74984
+ }
74985
+ function useArtifactsFor(sessionId) {
74986
+ const ctx = reactExports.useContext(ArtifactsContext);
74987
+ if (!ctx) throw new Error("useArtifactsFor must be used within ArtifactsProvider");
74988
+ return ctx.groupsFor(sessionId);
74989
+ }
74990
+ function useArtifactsFetcher() {
74991
+ const ctx = reactExports.useContext(ArtifactsContext);
74992
+ if (!ctx) throw new Error("useArtifactsFetcher must be used within ArtifactsProvider");
74993
+ return ctx.fetch;
74994
+ }
74995
+ function countArtifacts(groups) {
74996
+ return groups ? groups.reduce((n, g) => n + g.rows.length, 0) : 0;
74997
+ }
74428
74998
  const EXIT_MS = 120;
74429
74999
  function RowActionsMenu({ open, anchorRef, position: position2, onClose, items }) {
74430
75000
  const [rendered, setRendered] = reactExports.useState(open);
@@ -74600,8 +75170,49 @@ function SegmentSpinner({ size: size2 = "sm", tone = "inherit", label = "Working
74600
75170
  }
74601
75171
  );
74602
75172
  }
74603
- function SessionHeader({ session, onOpenDetails, lightsInCenter = false }) {
75173
+ function Tooltip$1({ label, side = "bottom", align = "center", children, className = "" }) {
75174
+ const y2 = side === "bottom" ? "top-full mt-1.5" : "bottom-full mb-1.5";
75175
+ const x2 = align === "end" ? "right-0" : "left-1/2 -translate-x-1/2";
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
+ );
75198
+ }
75199
+ function SessionHeader({
75200
+ session,
75201
+ onOpenDetails,
75202
+ lightsInCenter = false,
75203
+ artifactsOpen = false,
75204
+ onToggleArtifacts
75205
+ }) {
74604
75206
  const { setDefaultFolder, refresh: refreshSessions } = useSessions();
75207
+ const artifactCount = countArtifacts(useArtifactsFor(session.id));
75208
+ const fetchArtifacts = useArtifactsFetcher();
75209
+ const artifactsShown = onToggleArtifacts !== void 0;
75210
+ reactExports.useEffect(() => {
75211
+ if (!artifactsShown) {
75212
+ return;
75213
+ }
75214
+ void fetchArtifacts(session.id).catch(() => void 0);
75215
+ }, [artifactsShown, fetchArtifacts, session.id]);
74605
75216
  const folderless = !session.cwd;
74606
75217
  const folderName = folderless ? "Chat" : basename$2(session.cwd);
74607
75218
  const [menuOpen, setMenuOpen] = reactExports.useState(false);
@@ -74620,6 +75231,13 @@ function SessionHeader({ session, onOpenDetails, lightsInCenter = false }) {
74620
75231
  };
74621
75232
  const menuItems = reactExports.useMemo(
74622
75233
  () => [
75234
+ ...onToggleArtifacts ? [
75235
+ {
75236
+ id: "artifacts",
75237
+ label: artifactsOpen ? "Hide artifacts" : "Show artifacts",
75238
+ onSelect: onToggleArtifacts
75239
+ }
75240
+ ] : [],
74623
75241
  {
74624
75242
  id: "compact",
74625
75243
  label: compacting ? "Compacting…" : "Compact conversation",
@@ -74628,7 +75246,7 @@ function SessionHeader({ session, onOpenDetails, lightsInCenter = false }) {
74628
75246
  }
74629
75247
  ],
74630
75248
  // eslint-disable-next-line react-hooks/exhaustive-deps -- compactNow reads only stable refs + session.id
74631
- [compacting, session.id]
75249
+ [compacting, session.id, artifactsOpen, onToggleArtifacts]
74632
75250
  );
74633
75251
  const pickFolder = async () => {
74634
75252
  const picked = await window.api.folder.pick();
@@ -74728,6 +75346,38 @@ function SessionHeader({ session, onOpenDetails, lightsInCenter = false }) {
74728
75346
  }
74729
75347
  ),
74730
75348
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1" }),
75349
+ onToggleArtifacts && /* @__PURE__ */ jsxRuntimeExports.jsx(
75350
+ Tooltip$1,
75351
+ {
75352
+ align: "end",
75353
+ label: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
75354
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Artifacts" }),
75355
+ artifactCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "tabular-nums px-1 rounded bg-[var(--zg-bg-hover)] text-[var(--zg-text-muted)]", children: artifactCount }),
75356
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)]", children: "⌃⇧A" })
75357
+ ] }),
75358
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
75359
+ "button",
75360
+ {
75361
+ type: "button",
75362
+ onClick: onToggleArtifacts,
75363
+ "aria-pressed": artifactsOpen,
75364
+ "aria-label": `Artifacts${artifactCount > 0 ? `, ${artifactCount}` : ""}`,
75365
+ className: `zg-press-soft relative inline-flex items-center justify-center w-7 h-7 shrink-0 rounded-md border-0 cursor-pointer transition-colors duration-150 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)] ${artifactsOpen ? "bg-[var(--zg-bg-hover)] text-[var(--zg-text)]" : "bg-transparent text-[var(--zg-text-muted)] hover:bg-[var(--zg-bg-hover)] hover:text-[var(--zg-text)]"}`,
75366
+ children: [
75367
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "i-heroicons-cube text-[14px]" }),
75368
+ artifactCount > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
75369
+ "span",
75370
+ {
75371
+ "aria-hidden": true,
75372
+ className: "absolute -top-0.5 -right-0.5 min-w-[14px] h-[14px] px-[3px] rounded-full bg-[var(--zg-accent)] text-[var(--zg-bg)] text-[9px] leading-[14px] font-medium tabular-nums text-center",
75373
+ children: artifactCount > 99 ? "99+" : artifactCount
75374
+ }
75375
+ )
75376
+ ]
75377
+ }
75378
+ )
75379
+ }
75380
+ ),
74731
75381
  /* @__PURE__ */ jsxRuntimeExports.jsx(
74732
75382
  "button",
74733
75383
  {
@@ -74739,7 +75389,7 @@ function SessionHeader({ session, onOpenDetails, lightsInCenter = false }) {
74739
75389
  "aria-expanded": menuOpen,
74740
75390
  onClick: () => setMenuOpen((open) => !open),
74741
75391
  className: "zg-press-soft zg-hit-extend relative inline-flex items-center justify-center w-7 h-7 shrink-0 rounded-md bg-transparent hover:bg-[var(--zg-bg-hover)] text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] border-0 cursor-pointer p-0 transition-colors duration-150 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)]",
74742
- children: compacting ? /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs", tone: "warn", label: "Compacting" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-ellipsis-horizontal text-sm", "aria-hidden": true })
75392
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Crossfade, { activeKey: compacting ? "compacting" : "menu", children: compacting ? /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs", tone: "warn", label: "Compacting" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-ellipsis-horizontal text-sm", "aria-hidden": true }) })
74743
75393
  }
74744
75394
  ),
74745
75395
  /* @__PURE__ */ jsxRuntimeExports.jsx(RowActionsMenu, { open: menuOpen, anchorRef: menuTriggerRef, onClose: () => setMenuOpen(false), items: menuItems })
@@ -74793,7 +75443,7 @@ const TODO_STATUS_GLYPHS = {
74793
75443
  cancelled: "☒"
74794
75444
  };
74795
75445
  const INPUT_CLS = "flex-1 min-w-0 font-mono text-sm bg-[var(--zg-bg)] border border-[var(--zg-border)] rounded-md px-3 py-1.5 text-[var(--zg-text)] outline-none focus:border-[var(--zg-accent)] focus:ring-2 focus:ring-[var(--zg-accent)]/20";
74796
- const GHOST_BTN$2 = "zg-press h-7 px-2 rounded-md text-xs text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border-0 bg-transparent cursor-pointer transition-colors duration-150 disabled:opacity-40 disabled:cursor-not-allowed";
75446
+ const GHOST_BTN$1 = "zg-press h-7 px-2 rounded-md text-xs text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border-0 bg-transparent cursor-pointer transition-colors duration-150 disabled:opacity-40 disabled:cursor-not-allowed";
74797
75447
  function TodosModal({ sessionId }) {
74798
75448
  const snap = useTodosFor(sessionId);
74799
75449
  const { close: close2 } = useModal();
@@ -74870,7 +75520,7 @@ function TodosModal({ sessionId }) {
74870
75520
  "button",
74871
75521
  {
74872
75522
  type: "button",
74873
- className: `${GHOST_BTN$2} text-[var(--zg-error)]`,
75523
+ className: `${GHOST_BTN$1} text-[var(--zg-error)]`,
74874
75524
  onClick: () => {
74875
75525
  commit(clearTodos());
74876
75526
  setConfirmClear(false);
@@ -74878,12 +75528,12 @@ function TodosModal({ sessionId }) {
74878
75528
  children: "Yes"
74879
75529
  }
74880
75530
  ),
74881
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN$2, onClick: () => setConfirmClear(false), children: "Cancel" })
75531
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN$1, onClick: () => setConfirmClear(false), children: "Cancel" })
74882
75532
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
74883
75533
  "button",
74884
75534
  {
74885
75535
  type: "button",
74886
- className: GHOST_BTN$2,
75536
+ className: GHOST_BTN$1,
74887
75537
  disabled: base2.length === 0,
74888
75538
  onClick: () => setConfirmClear(true),
74889
75539
  title: "Remove every todo from the live list",
@@ -74981,7 +75631,7 @@ function TodosModal({ sessionId }) {
74981
75631
  className: INPUT_CLS
74982
75632
  }
74983
75633
  ),
74984
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN$2, disabled: adding.trim().length === 0, onClick: submitAdd, children: "Add" })
75634
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN$1, disabled: adding.trim().length === 0, onClick: submitAdd, children: "Add" })
74985
75635
  ] })
74986
75636
  ] })
74987
75637
  }
@@ -75580,6 +76230,250 @@ function StackedChart({
75580
76230
  }
75581
76231
  );
75582
76232
  }
76233
+ const ARTIFACTS_PANEL_WIDTH = 288;
76234
+ function ArtifactsPanel({ sessionId }) {
76235
+ const cached = useArtifactsFor(sessionId);
76236
+ const fetchSession = useArtifactsFetcher();
76237
+ const [error, setError] = reactExports.useState(null);
76238
+ reactExports.useEffect(() => {
76239
+ void fetchSession(sessionId).catch((err) => setError(err.message));
76240
+ }, [fetchSession, sessionId]);
76241
+ const groups = cached;
76242
+ const total = countArtifacts(groups);
76243
+ const refreshed = reactExports.useRef(/* @__PURE__ */ new Set());
76244
+ const refresh = reactExports.useCallback((row, force = false) => {
76245
+ if (refreshed.current.has(row.artifact.id)) return;
76246
+ refreshed.current.add(row.artifact.id);
76247
+ void window.api.artifacts.refresh(row.artifact, force ? { force: true } : void 0).catch(() => void 0);
76248
+ }, []);
76249
+ reactExports.useEffect(() => {
76250
+ for (const group of groups ?? []) for (const row of group.rows) refresh(row, true);
76251
+ }, [groups, refresh]);
76252
+ const remove = reactExports.useCallback((row) => {
76253
+ setError(null);
76254
+ void window.api.artifacts.delete(row.artifact.sessionId, row.artifact.id).then((ok2) => {
76255
+ if (!ok2) setError("This session store does not support artifacts.");
76256
+ }).catch((err) => setError(err.message));
76257
+ }, []);
76258
+ const summary = reactExports.useMemo(() => {
76259
+ if (groups === null) return "";
76260
+ return groups.map((g) => `${g.rows.length} ${plural(g.label, g.rows.length)}`).join(" · ");
76261
+ }, [groups]);
76262
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
76263
+ "aside",
76264
+ {
76265
+ "aria-label": "Artifacts",
76266
+ className: "relative shrink-0 h-full flex flex-col",
76267
+ style: { width: ARTIFACTS_PANEL_WIDTH },
76268
+ children: [
76269
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-h-0 overflow-y-auto px-3 pt-3 pb-3", children: [
76270
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-warn)] mb-2", role: "alert", children: error }),
76271
+ groups === null ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-text-muted)] py-6 text-center", children: "Loading…" }) : total === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(EmptyState, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4", children: groups.map((group) => /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "flex flex-col", children: [
76272
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "m-0 mb-1 text-[10px] uppercase tracking-[0.08em] text-[var(--zg-text-muted)] select-none", children: group.rows.length === 1 ? group.label : `${group.label}s` }),
76273
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "m-0 p-0 list-none flex flex-col", children: group.rows.map((row) => /* @__PURE__ */ jsxRuntimeExports.jsx(
76274
+ ArtifactRow,
76275
+ {
76276
+ row,
76277
+ onFocus: () => refresh(row),
76278
+ onRemove: () => remove(row)
76279
+ },
76280
+ row.artifact.id
76281
+ )) })
76282
+ ] }, group.kind)) })
76283
+ ] }),
76284
+ summary && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0 px-3 py-2 text-[11px] text-[var(--zg-text-muted)] truncate", title: summary, children: summary })
76285
+ ]
76286
+ }
76287
+ );
76288
+ }
76289
+ function ArtifactRow({ row, onFocus, onRemove }) {
76290
+ const { artifact, row: view } = row;
76291
+ const href = view.href;
76292
+ const isUrl2 = href !== void 0 && /^https?:\/\//.test(href);
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
+ );
76315
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
76316
+ "li",
76317
+ {
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",
76319
+ onMouseEnter: onFocus,
76320
+ onFocus,
76321
+ onContextMenu: (e) => {
76322
+ e.preventDefault();
76323
+ setMenu({ x: e.clientX, y: e.clientY });
76324
+ },
76325
+ children: [
76326
+ /* @__PURE__ */ jsxRuntimeExports.jsx(StatusGlyph, { status: view.status, kind: artifact.kind }),
76327
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0 flex flex-col", children: [
76328
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 min-w-0", children: [
76329
+ isUrl2 ? (
76330
+ // `target="_blank"` routes through main's window-open handler → `shell.openExternal`.
76331
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76332
+ "a",
76333
+ {
76334
+ href,
76335
+ target: "_blank",
76336
+ rel: "noreferrer",
76337
+ className: "truncate text-[13px] text-[var(--zg-text)] no-underline hover:underline",
76338
+ title: href,
76339
+ children: view.title
76340
+ }
76341
+ )
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
+ )
76364
+ ] }),
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
+ ) })
76378
+ ] }),
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
+ )
76388
+ ]
76389
+ }
76390
+ );
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
+ }
76402
+ function EmptyState() {
76403
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-2 py-10 px-4 text-center", children: [
76404
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76405
+ "span",
76406
+ {
76407
+ "aria-hidden": true,
76408
+ className: "w-8 h-8 rounded-lg border border-dashed border-[var(--zg-border)] flex items-center justify-center text-[var(--zg-text-muted)]",
76409
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-cube-transparent text-[16px]" })
76410
+ }
76411
+ ),
76412
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-text)]", children: "Nothing yet" }),
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." })
76414
+ ] });
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
+ }
76454
+ function statusColor(status) {
76455
+ switch (status) {
76456
+ case "merged":
76457
+ return "hsl(265 60% 72%)";
76458
+ case "closed":
76459
+ return "var(--zg-danger)";
76460
+ case "draft":
76461
+ return "var(--zg-text-muted)";
76462
+ case "approved":
76463
+ return "var(--zg-success)";
76464
+ case "changes requested":
76465
+ return "var(--zg-warn)";
76466
+ case "open":
76467
+ return "var(--zg-accent)";
76468
+ default:
76469
+ return "var(--zg-border)";
76470
+ }
76471
+ }
76472
+ function plural(label, count2) {
76473
+ const lower2 = label.toLowerCase();
76474
+ if (count2 === 1) return lower2;
76475
+ return /(?:s|x|ch|sh)$/.test(lower2) ? `${lower2}es` : `${lower2}s`;
76476
+ }
75583
76477
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
75584
76478
  return function handleEvent(event) {
75585
76479
  originalEventHandler?.(event);
@@ -79701,8 +80595,7 @@ function useTranscriptSelectionCopy(containerRef) {
79701
80595
  }
79702
80596
  const USER_PROMPT_BUBBLE_STYLE = { background: "var(--zg-accent-soft-strong)" };
79703
80597
  const SELECTION_RING_STYLE = {
79704
- background: "rgba(20, 136, 252, 0.08)",
79705
- boxShadow: "inset 2px 0 0 0 var(--zg-accent)"
80598
+ background: "var(--zg-accent-soft-strong)"
79706
80599
  };
79707
80600
  const GUTTER_STEP_PX = 28;
79708
80601
  const SPINE_ACTIVE_STYLE = {
@@ -79757,12 +80650,41 @@ const Timeline = reactExports.memo(({ events, isStreaming, sessionId }) => {
79757
80650
  visibleRows.forEach((row, idx) => map3.set(row, idx));
79758
80651
  return map3;
79759
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]);
79760
80682
  const renderRow = (row, idx) => {
79761
80683
  const showCaret = idx === lastStreamingIdx;
79762
80684
  if ((row.kind === "thinking" || row.kind === "thinking-batch") && !showThinking) {
79763
80685
  return null;
79764
80686
  }
79765
- const highlighted = selectedTurnId !== null && ownership !== null && "turnId" in row ? isTurnHighlighted({ turnId: row.turnId }, selectedTurnId, ownership) : false;
80687
+ const highlighted = false;
79766
80688
  if (row.kind === "user-prompt") {
79767
80689
  const attachments = row.attachments ?? [];
79768
80690
  const hasRefs = (row.refs?.length ?? 0) > 0;
@@ -79844,33 +80766,55 @@ const Timeline = reactExports.memo(({ events, isStreaming, sessionId }) => {
79844
80766
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: containerRef, children: [
79845
80767
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-timeline relative pl-2 pr-1 py-1", children: [
79846
80768
  /* @__PURE__ */ jsxRuntimeExports.jsx(Spine, { active: isStreaming }),
79847
- clusters.map((cluster, ci) => {
79848
- if (cluster.kind === "single") {
79849
- if ((cluster.row.kind === "thinking" || cluster.row.kind === "thinking-batch") && !showThinking) {
79850
- 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;
79851
80794
  }
79852
- const idx = rowIndex.get(cluster.row) ?? -1;
79853
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(cluster.row), children: renderRow(cluster.row, idx) }, cluster.row.id);
79854
- }
79855
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
79856
- SubagentBlock,
79857
- {
79858
- childId: cluster.childId,
79859
- depth: cluster.depth,
79860
- rows: cluster.rows,
79861
- defaultCollapsed: collapseSubagents,
79862
- streaming: isStreaming,
79863
- children: cluster.rows.map((row) => {
79864
- if ((row.kind === "thinking" || row.kind === "thinking-batch") && !showThinking) {
79865
- return null;
79866
- }
79867
- const idx = rowIndex.get(row) ?? -1;
79868
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-cv-row", style: rowCvStyle(row), children: renderRow(row, idx) }, row.id);
79869
- })
79870
- },
79871
- `group-${ci}-${cluster.childId}`
79872
- );
79873
- })
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
+ })()
79874
80818
  ] }),
79875
80819
  /* @__PURE__ */ jsxRuntimeExports.jsx(TimelineKeyframes, {})
79876
80820
  ] });
@@ -79984,7 +80928,14 @@ ${task}` : ""}`,
79984
80928
  }
79985
80929
  ) }),
79986
80930
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2 min-w-0 flex-1", children: [
79987
- status === "open" && streaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs", label: "running" }) : status === "failed" ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-x-mark text-[11px] shrink-0 text-[#ef4444]", "aria-label": "failed" }) : status === "done" ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-check text-[11px] shrink-0 text-[#22c55e]", "aria-label": "done" }) : null,
80931
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
80932
+ Crossfade,
80933
+ {
80934
+ activeKey: status === "open" && streaming ? "running" : status === "failed" ? "failed" : status === "done" ? "done" : "none",
80935
+ className: "shrink-0",
80936
+ children: status === "open" && streaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs", label: "running" }) : status === "failed" ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-x-mark text-[11px] shrink-0 text-[#ef4444]", "aria-label": "failed" }) : status === "done" ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-heroicons-check text-[11px] shrink-0 text-[#22c55e]", "aria-label": "done" }) : null
80937
+ }
80938
+ ),
79988
80939
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs min-w-0 truncate", children: [
79989
80940
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-[var(--zg-text)]", children: "Agent" }),
79990
80941
  task && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
@@ -80158,7 +81109,7 @@ function SelectionRing({ highlighted, children }) {
80158
81109
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
80159
81110
  "div",
80160
81111
  {
80161
- className: "relative rounded-md transition-colors duration-150",
81112
+ className: "relative -mx-2 px-2 pt-2 rounded-xl transition-colors duration-150",
80162
81113
  style: SELECTION_RING_STYLE,
80163
81114
  "data-select-cursor": "true",
80164
81115
  children
@@ -80308,15 +81259,15 @@ function Dot({ variant }) {
80308
81259
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
80309
81260
  "span",
80310
81261
  {
80311
- className: "relative flex items-center justify-center w-4 h-4 rounded-full border-2 text-white",
81262
+ className: "zg-state-tween relative flex items-center justify-center w-4 h-4 rounded-full border-2 text-white",
80312
81263
  style: { background: cfg.bg, borderColor: cfg.border },
80313
81264
  children: [
80314
- cfg.icon && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `${cfg.icon} text-[10px]` }),
80315
- variant === "tool-running" && /* @__PURE__ */ jsxRuntimeExports.jsx(
81265
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Crossfade, { activeKey: cfg.icon || "none", children: cfg.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `${cfg.icon} text-[10px]` }) : null }),
81266
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show: variant === "tool-running", className: "absolute -inset-[2px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
80316
81267
  "span",
80317
81268
  {
80318
81269
  "aria-hidden": true,
80319
- className: "absolute -inset-[2px] rounded-full",
81270
+ className: "absolute inset-0 rounded-full",
80320
81271
  style: {
80321
81272
  background: "conic-gradient(from 0deg, var(--zg-accent) 0 30%, transparent 30% 100%)",
80322
81273
  WebkitMaskImage: "radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px))",
@@ -80324,7 +81275,7 @@ function Dot({ variant }) {
80324
81275
  animation: "zg-orbit 1.1s linear infinite"
80325
81276
  }
80326
81277
  }
80327
- )
81278
+ ) })
80328
81279
  ]
80329
81280
  }
80330
81281
  )
@@ -80738,7 +81689,7 @@ ${lines.slice(lines.length - USER_BASH_TAIL_LINES).join("\n")}`;
80738
81689
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-baseline gap-2 max-w-full py-0.5", children: [
80739
81690
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-accent-hover)] font-medium select-none", children: "!" }),
80740
81691
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text)] truncate", children: row.command }),
80741
- badge
81692
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Crossfade, { activeKey: row.running ? "running" : row.errored ? "failed" : row.exit === null ? "none" : "exit", children: badge })
80742
81693
  ] }),
80743
81694
  display !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "mt-1 px-3 py-2 rounded-md bg-[var(--zg-bg-elevated)] border border-[var(--zg-border)] text-[var(--zg-text-muted)] whitespace-pre-wrap font-mono text-xs leading-relaxed", children: display })
80744
81695
  ] });
@@ -80762,7 +81713,7 @@ function ToolTiming({
80762
81713
  return null;
80763
81714
  }
80764
81715
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 shrink-0 self-center text-[10px] font-mono tabular-nums text-[var(--zg-text-muted)]", children: [
80765
- running && /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs" }),
81716
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show: running, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentSpinner, { size: "xs" }) }),
80766
81717
  formatToolMs(ms)
80767
81718
  ] });
80768
81719
  }
@@ -81432,11 +82383,14 @@ function Center({
81432
82383
  modelId,
81433
82384
  contextStatus,
81434
82385
  costStatus,
82386
+ streaming = null,
81435
82387
  runningWorkCount = 0,
81436
82388
  onOpenRunningWork,
81437
82389
  lightsInCenter = false,
81438
82390
  searchOpen = false,
81439
- onCloseSearch
82391
+ onCloseSearch,
82392
+ artifactsOpen = false,
82393
+ onToggleArtifacts
81440
82394
  }) {
81441
82395
  const {
81442
82396
  createSession,
@@ -81698,6 +82652,9 @@ function Center({
81698
82652
  ...defaultProviderKey && defaultModelId ? { providerKey: defaultProviderKey, modelId: defaultModelId } : {}
81699
82653
  });
81700
82654
  sessionId = created.id;
82655
+ if (defaultAgentId !== "build") {
82656
+ setDefaultAgentId("build");
82657
+ }
81701
82658
  }
81702
82659
  const bashCommand = text2.trim().startsWith("!") ? text2.trim().slice(1).trim() : "";
81703
82660
  if (bashCommand) {
@@ -81795,7 +82752,16 @@ function Center({
81795
82752
  * the very top + a wider falloff so the band reads as soft.
81796
82753
  */
81797
82754
  /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "flex-1 min-w-0 flex flex-col h-full bg-[var(--zg-bg)]", children: [
81798
- activeSession ? /* @__PURE__ */ jsxRuntimeExports.jsx(SessionHeader, { session: activeSession, onOpenDetails: onOpenSessionDetails, lightsInCenter }) : (
82755
+ activeSession ? /* @__PURE__ */ jsxRuntimeExports.jsx(
82756
+ SessionHeader,
82757
+ {
82758
+ session: activeSession,
82759
+ onOpenDetails: onOpenSessionDetails,
82760
+ lightsInCenter,
82761
+ artifactsOpen,
82762
+ onToggleArtifacts
82763
+ }
82764
+ ) : (
81799
82765
  /**
81800
82766
  * No session yet — render the header as a pure drag region so the
81801
82767
  * window stays movable from the top edge. The sidebar's "+ New chat"
@@ -81834,103 +82800,109 @@ function Center({
81834
82800
  }
81835
82801
  )
81836
82802
  ),
81837
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex-1 min-h-0", children: [
81838
- /* @__PURE__ */ jsxRuntimeExports.jsx(
81839
- "section",
81840
- {
81841
- ref: scrollRef,
81842
- className: "absolute inset-0 overflow-y-auto p-6",
81843
- style: {
81844
- maskImage: "linear-gradient(to bottom, transparent 0, black 16px, black 100%)",
81845
- WebkitMaskImage: "linear-gradient(to bottom, transparent 0, black 16px, black 100%)"
81846
- },
81847
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mx-auto w-full max-w-[1160px] ${isNewSession ? "h-full" : ""}`, children: isNewSession ? /* @__PURE__ */ jsxRuntimeExports.jsx(WelcomeScreen, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(Timeline, { events, isStreaming: running, sessionId: activeSession?.id ?? null }) })
81848
- }
81849
- ),
81850
- searchOpen && activeSession && onCloseSearch && /* @__PURE__ */ jsxRuntimeExports.jsx(TranscriptSearch, { container: scrollRef, sessionId: activeSession.id, onClose: onCloseSearch }),
81851
- composerSearchQuery !== null && /* @__PURE__ */ jsxRuntimeExports.jsx(SearchHighlightStyle, {})
81852
- ] }),
81853
- /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "zg-chat-footer px-6 pb-3 pt-0 relative", "data-scrolled": scrolledFromTop && !pinned, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-full max-w-[1160px] flex flex-col gap-2", children: activeSession?.archived ? (
81854
- /**
81855
- * Archived sessions are read-only. The chatbox + all of its
81856
- * peripherals (call status, todo indicator, approval bar,
81857
- * queue strip) would imply the session can still be driven —
81858
- * which it can't until the user unarchives. We replace the
81859
- * whole footer cluster with a single banner so the affordance
81860
- * is unambiguous.
81861
- */
81862
- /* @__PURE__ */ jsxRuntimeExports.jsx(
81863
- ArchivedBanner,
81864
- {
81865
- onUnarchive: () => {
81866
- void setArchived(activeSession.id, false);
81867
- }
81868
- }
81869
- )
81870
- ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
81871
- /* @__PURE__ */ jsxRuntimeExports.jsxs(ComposerDock, { children: [
81872
- /* @__PURE__ */ jsxRuntimeExports.jsx(TodoIndicator, { sessionId: activeSession?.id ?? null }),
81873
- /* @__PURE__ */ jsxRuntimeExports.jsx(ApprovalBar, { sessionId: activeSession?.id ?? null }),
81874
- /* @__PURE__ */ jsxRuntimeExports.jsx(InteractionBar, { sessionId: activeSession?.id ?? null }),
81875
- /* @__PURE__ */ jsxRuntimeExports.jsx(QueueStrip, { messages: queuedMessages, onPush: onPushQueued, onDrop: onDropQueued })
81876
- ] }),
81877
- /* @__PURE__ */ jsxRuntimeExports.jsx(
81878
- Chatbox,
81879
- {
81880
- disabled: false,
81881
- folderPath,
81882
- activeSessionId: activeSession?.id ?? null,
81883
- running: running && Boolean(activeSession),
81884
- onStop,
81885
- onSend: handleSend,
81886
- onCycleHistory,
81887
- searchStatus: composerSearchQuery !== null ? composerSearch : null,
81888
- onSearchQueryChange: onComposerSearchQueryChange,
81889
- onSearchNavigate: composerSearch.goTo,
81890
- searchOverlayOpen: searchOpen,
81891
- remoteSearchApply,
81892
- leadingActions: /* @__PURE__ */ jsxRuntimeExports.jsx(
81893
- ChatboxControls,
82803
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-h-0 flex flex-row", children: [
82804
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0 flex flex-col", children: [
82805
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex-1 min-h-0", children: [
82806
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
82807
+ "section",
81894
82808
  {
81895
- activeSession,
81896
- defaultAgentId,
81897
- onDefaultAgentChange: setDefaultAgentId,
81898
- modelId,
81899
- providerKey: activeSession?.providerKey ?? null,
81900
- activeSupportsReasoning: contextStatus?.supportsReasoning ?? false,
81901
- activeModelOptions: contextStatus?.availableOptions ?? [],
81902
- activeEnabledOptions: contextStatus?.modelOptions ?? {}
82809
+ ref: scrollRef,
82810
+ className: "absolute inset-0 overflow-y-auto p-6",
82811
+ style: {
82812
+ maskImage: "linear-gradient(to bottom, transparent 0, black 16px, black 100%)",
82813
+ WebkitMaskImage: "linear-gradient(to bottom, transparent 0, black 16px, black 100%)"
82814
+ },
82815
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mx-auto w-full max-w-[1160px] ${isNewSession ? "h-full" : ""}`, children: isNewSession ? /* @__PURE__ */ jsxRuntimeExports.jsx(WelcomeScreen, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(Timeline, { events, isStreaming: running, sessionId: activeSession?.id ?? null }) })
81903
82816
  }
81904
82817
  ),
81905
- trailingActions: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
81906
- /* @__PURE__ */ jsxRuntimeExports.jsx(CallStatusPill, { sessionId: activeSession?.id ?? null }),
81907
- /* @__PURE__ */ jsxRuntimeExports.jsx(
81908
- ChatboxStatusPills,
81909
- {
81910
- activeSession,
81911
- contextStatus,
81912
- costStatus,
81913
- runningWorkCount,
81914
- onOpenRunningWork
82818
+ searchOpen && activeSession && onCloseSearch && /* @__PURE__ */ jsxRuntimeExports.jsx(TranscriptSearch, { container: scrollRef, sessionId: activeSession.id, onClose: onCloseSearch }),
82819
+ composerSearchQuery !== null && /* @__PURE__ */ jsxRuntimeExports.jsx(SearchHighlightStyle, {})
82820
+ ] }),
82821
+ /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "zg-chat-footer px-6 pb-3 pt-0 relative", "data-scrolled": scrolledFromTop && !pinned, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto w-full max-w-[1160px] flex flex-col gap-2", children: activeSession?.archived ? (
82822
+ /**
82823
+ * Archived sessions are read-only. The chatbox + all of its
82824
+ * peripherals (call status, todo indicator, approval bar,
82825
+ * queue strip) would imply the session can still be driven —
82826
+ * which it can't until the user unarchives. We replace the
82827
+ * whole footer cluster with a single banner so the affordance
82828
+ * is unambiguous.
82829
+ */
82830
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
82831
+ ArchivedBanner,
82832
+ {
82833
+ onUnarchive: () => {
82834
+ void setArchived(activeSession.id, false);
81915
82835
  }
81916
- ),
81917
- isNewSession && /* @__PURE__ */ jsxRuntimeExports.jsx(
81918
- ScopeToggle,
81919
- {
81920
- folderPath,
81921
- onJustChat: () => setFolderlessDraft(true),
81922
- onPickFolder: pickFolder,
81923
- recents: recentFolders,
81924
- onPickRecent: (dir) => {
81925
- setFolderlessDraft(false);
81926
- setDefaultFolder(dir);
82836
+ }
82837
+ )
82838
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
82839
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(ComposerDock, { children: [
82840
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TodoIndicator, { sessionId: activeSession?.id ?? null }),
82841
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ApprovalBar, { sessionId: activeSession?.id ?? null }),
82842
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InteractionBar, { sessionId: activeSession?.id ?? null }),
82843
+ /* @__PURE__ */ jsxRuntimeExports.jsx(QueueStrip, { messages: queuedMessages, onPush: onPushQueued, onDrop: onDropQueued })
82844
+ ] }),
82845
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
82846
+ Chatbox,
82847
+ {
82848
+ disabled: false,
82849
+ folderPath,
82850
+ activeSessionId: activeSession?.id ?? null,
82851
+ running: running && Boolean(activeSession),
82852
+ onStop,
82853
+ onSend: handleSend,
82854
+ onCycleHistory,
82855
+ searchStatus: composerSearchQuery !== null ? composerSearch : null,
82856
+ onSearchQueryChange: onComposerSearchQueryChange,
82857
+ onSearchNavigate: composerSearch.goTo,
82858
+ searchOverlayOpen: searchOpen,
82859
+ remoteSearchApply,
82860
+ leadingActions: /* @__PURE__ */ jsxRuntimeExports.jsx(
82861
+ ChatboxControls,
82862
+ {
82863
+ activeSession,
82864
+ defaultAgentId,
82865
+ onDefaultAgentChange: setDefaultAgentId,
82866
+ modelId,
82867
+ providerKey: activeSession?.providerKey ?? null,
82868
+ activeSupportsReasoning: contextStatus?.supportsReasoning ?? false,
82869
+ activeModelOptions: contextStatus?.availableOptions ?? [],
82870
+ activeEnabledOptions: contextStatus?.modelOptions ?? {}
81927
82871
  }
81928
- }
81929
- )
81930
- ] })
81931
- }
81932
- )
81933
- ] }) }) })
82872
+ ),
82873
+ trailingActions: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
82874
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CallStatusPill, { sessionId: activeSession?.id ?? null }),
82875
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
82876
+ ChatboxStatusPills,
82877
+ {
82878
+ activeSession,
82879
+ contextStatus,
82880
+ costStatus,
82881
+ streaming,
82882
+ runningWorkCount,
82883
+ onOpenRunningWork
82884
+ }
82885
+ ),
82886
+ isNewSession && /* @__PURE__ */ jsxRuntimeExports.jsx(
82887
+ ScopeToggle,
82888
+ {
82889
+ folderPath,
82890
+ onJustChat: () => setFolderlessDraft(true),
82891
+ onPickFolder: pickFolder,
82892
+ recents: recentFolders,
82893
+ onPickRecent: (dir) => {
82894
+ setFolderlessDraft(false);
82895
+ setDefaultFolder(dir);
82896
+ }
82897
+ }
82898
+ )
82899
+ ] })
82900
+ }
82901
+ )
82902
+ ] }) }) })
82903
+ ] }),
82904
+ artifactsOpen && activeSession && /* @__PURE__ */ jsxRuntimeExports.jsx(ArtifactsPanel, { sessionId: activeSession.id })
82905
+ ] })
81934
82906
  ] })
81935
82907
  );
81936
82908
  }
@@ -84507,29 +85479,27 @@ function SessionStatusDotInner({ sessionId, override }) {
84507
85479
  presence
84508
85480
  });
84509
85481
  const cfg = STYLES[state];
84510
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
84511
- "span",
84512
- {
84513
- "aria-label": cfg.label,
84514
- title: cfg.label,
84515
- className: "relative shrink-0 inline-block w-2 h-2 rounded-full",
84516
- style: cfg.style,
84517
- children: cfg.ring && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: `absolute rounded-full ${cfg.ring.className}`, style: cfg.ring.style })
84518
- }
84519
- );
84520
- }
84521
- function orbitRing(color2) {
84522
- const mask = "radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px))";
84523
- return {
84524
- className: "-inset-[3px]",
84525
- style: {
84526
- background: `conic-gradient(from 0deg, ${color2} 0 32%, transparent 32% 100%)`,
84527
- WebkitMaskImage: mask,
84528
- maskImage: mask,
84529
- animation: "zg-orbit 1.1s linear infinite"
84530
- }
84531
- };
85482
+ const orbit = cfg.ring?.kind === "orbit" ? cfg.ring : null;
85483
+ const ripple = cfg.ring?.kind === "ripple" ? cfg.ring : null;
85484
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { "aria-label": cfg.label, title: cfg.label, className: "relative shrink-0 inline-block w-2 h-2", children: [
85485
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "zg-state-tween absolute inset-0 rounded-full", style: cfg.style, "data-core": true }),
85486
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show: orbit !== null, className: "absolute -inset-[3px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: `absolute rounded-full ${ORBIT.className}`, style: ORBIT.style }) }),
85487
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show: ripple !== null, className: "absolute inset-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, className: "absolute inset-0 rounded-full", style: RIPPLE.style }) })
85488
+ ] });
84532
85489
  }
85490
+ const ORBIT_MASK = "radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px))";
85491
+ const ORBIT = {
85492
+ className: "inset-0",
85493
+ style: {
85494
+ background: "conic-gradient(from 0deg, var(--zg-accent) 0 32%, transparent 32% 100%)",
85495
+ WebkitMaskImage: ORBIT_MASK,
85496
+ maskImage: ORBIT_MASK,
85497
+ animation: "zg-orbit 1.1s linear infinite"
85498
+ }
85499
+ };
85500
+ const RIPPLE = {
85501
+ style: { background: "var(--zg-warn)", animation: "zg-dot 1.8s ease-in-out infinite" }
85502
+ };
84533
85503
  const SessionStatusDot = reactExports.memo(SessionStatusDotInner);
84534
85504
  const STYLES = {
84535
85505
  idle: {
@@ -84540,24 +85510,19 @@ const STYLES = {
84540
85510
  opacity: 0.5
84541
85511
  }
84542
85512
  },
84543
- // Core is a 5px radial fill (transparent edge, so it works on any row
84544
- // background) leaving the orbiting arc breathing room in the 8px slot.
85513
+ // Core scales down to ~5px (a tweenable transform, not a gradient) so the
85514
+ // orbiting arc has breathing room in the 8px slot.
84545
85515
  running: {
84546
85516
  label: "Running",
84547
- style: {
84548
- background: "radial-gradient(circle, var(--zg-accent) 0 2.3px, transparent 2.6px)"
84549
- },
84550
- ring: orbitRing("var(--zg-accent)")
85517
+ style: { background: "var(--zg-accent)", transform: "scale(0.62)" },
85518
+ ring: { kind: "orbit" }
84551
85519
  },
84552
85520
  // This window's own approval / question: the strongest "needs you" cue,
84553
85521
  // so it ripples outward instead of just breathing.
84554
85522
  pending: {
84555
85523
  label: "Pending approval",
84556
85524
  style: { background: "var(--zg-warn)" },
84557
- ring: {
84558
- className: "inset-0",
84559
- style: { background: "var(--zg-warn)", animation: "zg-dot 1.8s ease-in-out infinite" }
84560
- }
85525
+ ring: { kind: "ripple" }
84561
85526
  },
84562
85527
  attention: {
84563
85528
  label: "Awaiting input",
@@ -85313,7 +86278,7 @@ function Footer({
85313
86278
  settings.useDaemon && /* @__PURE__ */ jsxRuntimeExports.jsx(DaemonHealthDot, {}),
85314
86279
  hasAuth === false && /* @__PURE__ */ jsxRuntimeExports.jsx(SignInPrompt, { onClick: onOpenAuth }),
85315
86280
  settings.showUsageIndicator !== false && /* @__PURE__ */ jsxRuntimeExports.jsx(UsageIndicator, {}),
85316
- compacting && settings.showThrobber && /* @__PURE__ */ jsxRuntimeExports.jsx(CompactingIndicator, { progress: compactionProgress }),
86281
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Presence$1, { show: compacting && settings.showThrobber, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CompactingIndicator, { progress: compactionProgress }) }),
85317
86282
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-w-0" }),
85318
86283
  /* @__PURE__ */ jsxRuntimeExports.jsx(
85319
86284
  "button",
@@ -87370,293 +88335,51 @@ function RowItem({ row, merged }) {
87370
88335
  /* @__PURE__ */ jsxRuntimeExports.jsx(KeyHint, { spec })
87371
88336
  ] });
87372
88337
  }
87373
- function refKey(entry) {
87374
- return `${entry.providerKey}\0${entry.modelId}`;
87375
- }
87376
- function uniqueProviders(catalog) {
87377
- const seen2 = /* @__PURE__ */ new Map();
87378
- for (const entry of catalog) {
87379
- if (!seen2.has(entry.providerKey)) seen2.set(entry.providerKey, entry.providerLabel);
87380
- }
87381
- return [...seen2].map(([key2, label]) => ({ key: key2, label }));
87382
- }
87383
- function offCatalogRow(catalog, query, currentProviderKey) {
87384
- const custom = parseCustomModelQuery(query, uniqueProviders(catalog), currentProviderKey);
87385
- if (!custom) {
87386
- return null;
87387
- }
87388
- return {
87389
- providerKey: custom.providerKey,
87390
- providerLabel: custom.providerLabel,
87391
- modelId: custom.modelId,
87392
- modelName: custom.modelId,
87393
- contextWindow: null,
87394
- supportsReasoning: false,
87395
- options: [],
87396
- searchCorpus: "",
87397
- offCatalog: true
87398
- };
87399
- }
87400
- function selectedRowsFirst(entries, chain) {
87401
- if (chain.length === 0) {
87402
- return [...entries];
87403
- }
87404
- const byKey = new Map(entries.map((entry) => [`${entry.providerKey}\0${entry.modelId}`, entry]));
87405
- const selected = [];
87406
- const promoted = /* @__PURE__ */ new Set();
87407
- for (const pick of chain) {
87408
- const key2 = refKey(pick);
87409
- const entry = byKey.get(key2);
87410
- if (!entry || promoted.has(key2)) {
87411
- continue;
87412
- }
87413
- selected.push(entry);
87414
- promoted.add(key2);
87415
- }
87416
- return [...selected, ...entries.filter((entry) => !promoted.has(`${entry.providerKey}\0${entry.modelId}`))];
87417
- }
87418
88338
  function ModelPickerModal({ session, currentModelId, currentProviderKey }) {
87419
88339
  const modal = useModal();
87420
88340
  const { refresh: refreshSessions, setDefaultModel } = useSessions();
87421
- const { settings } = useSettings();
87422
- const [catalog, setCatalog] = reactExports.useState(null);
87423
- const [loadError, setLoadError] = reactExports.useState(null);
87424
- const [query, setQuery] = reactExports.useState("");
87425
- const [cursor, setCursor] = reactExports.useState(0);
87426
- const inputRef = reactExports.useRef(null);
87427
- const listRef = reactExports.useRef(null);
87428
- const extensionKey = settings.enabledExtensions?.join("") ?? "*";
87429
88341
  const [initialChain] = reactExports.useState(
87430
88342
  () => currentProviderKey && currentModelId ? [{ providerKey: currentProviderKey, modelId: currentModelId }, ...session.modelFallbacks ?? []] : []
87431
88343
  );
87432
- const [chainState, setChainState] = reactExports.useState(initialChain);
87433
- reactExports.useEffect(() => {
87434
- let cancelled = false;
87435
- window.api.sessions.listModels(session.cwd).then((entries) => {
87436
- if (cancelled) {
87437
- return;
87438
- }
87439
- setCatalog(entries);
87440
- if (currentProviderKey && currentModelId) {
87441
- const idx = indexOfEntry(entries, {
87442
- providerKey: currentProviderKey,
87443
- modelId: currentModelId
87444
- });
87445
- if (idx >= 0) {
87446
- setCursor(idx);
87447
- }
87448
- }
87449
- }).catch((err) => {
87450
- if (!cancelled) {
87451
- setLoadError(err.message ?? String(err));
87452
- }
87453
- });
87454
- return () => {
87455
- cancelled = true;
87456
- };
87457
- }, [currentProviderKey, currentModelId, session.cwd, extensionKey]);
87458
- reactExports.useEffect(() => {
87459
- inputRef.current?.focus();
87460
- }, []);
87461
- const filtered = reactExports.useMemo(() => {
87462
- if (!catalog) {
87463
- return [];
87464
- }
87465
- const matches2 = filterModelCatalog(catalog, query);
87466
- if (matches2.length > 0) {
87467
- return query.trim() ? matches2 : selectedRowsFirst(matches2, chainState);
87468
- }
87469
- const row = offCatalogRow(catalog, query, currentProviderKey);
87470
- return row ? [row] : [];
87471
- }, [catalog, query, chainState, currentProviderKey]);
87472
- reactExports.useEffect(() => {
87473
- if (filtered.length === 0) {
87474
- setCursor(0);
87475
- return;
87476
- }
87477
- setCursor((c) => Math.min(c, filtered.length - 1));
87478
- }, [filtered.length]);
87479
- reactExports.useEffect(() => {
87480
- const list2 = listRef.current;
87481
- if (!list2) {
87482
- return;
87483
- }
87484
- const row = list2.querySelector(`[data-row="${cursor}"]`);
87485
- row?.scrollIntoView({ block: "nearest" });
87486
- }, [cursor]);
87487
- const pick = (entry) => {
87488
- setChainState((prev) => pickPrimaryKeyed(prev, { providerKey: entry.providerKey, modelId: entry.modelId }, refKey));
87489
- };
87490
- const toggle = (entry) => {
87491
- setChainState((prev) => toggleKeyed(prev, { providerKey: entry.providerKey, modelId: entry.modelId }, refKey));
87492
- };
88344
+ const draft = reactExports.useRef(initialChain);
87493
88345
  const handleClose = () => {
87494
- const primary = chainState[0];
87495
- if (!primary || chainsEqualKeyed(chainState, initialChain, refKey)) {
88346
+ const chain = draft.current;
88347
+ const primary = chain[0];
88348
+ if (!primary || chainsEqualKeyed(chain, initialChain, refKey)) {
87496
88349
  modal.close();
87497
88350
  return;
87498
88351
  }
87499
- const fallbacks = chainState.slice(1);
87500
88352
  void (async () => {
87501
- 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));
87502
88354
  setDefaultModel(primary.providerKey, primary.modelId);
87503
88355
  await window.api.state.set({
87504
- lastModelChain: chainState.map((e) => ({ provider: e.providerKey, model: e.modelId }))
88356
+ lastModelChain: chain.map((e) => ({ provider: e.providerKey, model: e.modelId }))
87505
88357
  });
87506
88358
  await refreshSessions();
87507
88359
  modal.close();
87508
88360
  })();
87509
88361
  };
87510
- reactExports.useEffect(() => {
87511
- const onKey = (e) => {
87512
- if (e.ctrlKey && e.shiftKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
87513
- e.preventDefault();
87514
- const row = filtered[cursor];
87515
- if (!row) {
87516
- return;
87517
- }
87518
- const key2 = `${row.providerKey}\0${row.modelId}`;
87519
- const delta = e.key === "ArrowUp" ? -1 : 1;
87520
- setChainState((prev) => {
87521
- const reordered = reorderKeyed(prev, key2, delta, refKey);
87522
- if (reordered !== prev && !query.trim()) {
87523
- const served = new Set((catalog ?? []).map((entry) => `${entry.providerKey}\0${entry.modelId}`));
87524
- const next = reordered.filter((entry) => served.has(refKey(entry))).findIndex((entry) => refKey(entry) === key2);
87525
- if (next >= 0) {
87526
- setCursor(next);
87527
- }
87528
- }
87529
- return reordered === prev ? prev : [...reordered];
87530
- });
87531
- return;
87532
- }
87533
- if (e.key === "ArrowDown") {
87534
- e.preventDefault();
87535
- setCursor((c) => Math.min(Math.max(0, filtered.length - 1), c + 1));
87536
- } else if (e.key === "ArrowUp") {
87537
- e.preventDefault();
87538
- setCursor((c) => Math.max(0, c - 1));
87539
- } else if (e.key === "Tab" || e.key === "Enter" && e.shiftKey) {
87540
- e.preventDefault();
87541
- const entry = filtered[cursor];
87542
- if (entry) toggle(entry);
87543
- } else if (e.key === "Enter") {
87544
- e.preventDefault();
87545
- const entry = filtered[cursor];
87546
- if (entry) {
87547
- pick(entry);
87548
- }
87549
- }
87550
- };
87551
- document.addEventListener("keydown", onKey);
87552
- return () => document.removeEventListener("keydown", onKey);
87553
- }, [cursor, filtered, query, catalog]);
87554
- const multi = chainState.length > 1;
87555
88362
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
87556
88363
  ModalShell,
87557
88364
  {
87558
88365
  title: "Model",
87559
- 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.`,
87560
88367
  onClose: handleClose,
87561
88368
  size: "large",
87562
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col min-h-0 max-h-[min(70vh,560px)]", children: [
87563
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 pt-3 pb-2 border-b border-[var(--zg-border)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
87564
- "input",
87565
- {
87566
- ref: inputRef,
87567
- value: query,
87568
- onChange: (e) => setQuery(e.target.value),
87569
- placeholder: "Search models — try `claude opus` or `gpt mini`…",
87570
- 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",
87571
- spellCheck: false,
87572
- autoCorrect: "off"
87573
- }
87574
- ) }),
87575
- catalog === null && !loadError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-6 text-xs text-[var(--zg-text-muted)]", children: "Loading…" }),
87576
- loadError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-6 text-xs text-[#ef4444]", children: [
87577
- "Failed to load models: ",
87578
- loadError
87579
- ] }),
87580
- 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").' }),
87581
- /* @__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) => {
87582
- const position2 = positionKeyed(
87583
- chainState,
87584
- refKey({ providerKey: entry.providerKey, modelId: entry.modelId }),
87585
- refKey
87586
- );
87587
- const isCursor = idx === cursor;
87588
- return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
87589
- "button",
87590
- {
87591
- type: "button",
87592
- "data-row": idx,
87593
- onMouseEnter: () => setCursor(idx),
87594
- onClick: (e) => e.shiftKey ? toggle(entry) : pick(entry),
87595
- 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)]"}`,
87596
- children: [
87597
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 shrink-0 flex items-center justify-center", children: multi && position2 !== null ? /* @__PURE__ */ jsxRuntimeExports.jsx(
87598
- "span",
87599
- {
87600
- className: "text-[11px] font-semibold tabular-nums text-[var(--zg-accent)]",
87601
- title: position2 === 1 ? "Primary model" : `Fallback #${position2 - 1}`,
87602
- children: position2 > 9 ? "+" : position2
87603
- }
87604
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(SelectionDot, { active: position2 !== null }) }),
87605
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex-1 min-w-0 truncate", children: [
87606
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[13px] text-[var(--zg-text)]", children: entry.modelId }),
87607
- entry.modelName !== entry.modelId && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-xs text-[var(--zg-text-muted)]", children: entry.modelName })
87608
- ] }),
87609
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 flex items-center gap-1.5 text-[var(--zg-text-muted)]", children: [
87610
- entry.offCatalog ? (
87611
- // A stub has no capability metadata — say why rather than
87612
- // print an empty window column. Same wording as the TUI.
87613
- /* @__PURE__ */ jsxRuntimeExports.jsx(
87614
- "span",
87615
- {
87616
- className: "text-[11px] text-[#f59e0b]",
87617
- title: "Used as typed; no metadata is known for this id",
87618
- children: "not in catalog"
87619
- }
87620
- )
87621
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-11 text-right text-[11px] tabular-nums", title: "Context window", children: entry.contextWindow !== null ? formatWindow(entry.contextWindow) : "" }),
87622
- entry.supportsReasoning && /* @__PURE__ */ jsxRuntimeExports.jsx(
87623
- "span",
87624
- {
87625
- className: "inline-flex items-center h-[18px] rounded-md border border-[var(--zg-border)] px-1.5 text-[10px]",
87626
- title: "Supports reasoning effort (Ctrl+L)",
87627
- children: "reason"
87628
- }
87629
- ),
87630
- /* @__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 })
87631
- ] })
87632
- ]
87633
- }
87634
- ) }, `${entry.providerKey}:${entry.modelId}`);
87635
- }) }),
87636
- /* @__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: [
87637
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "↵ use as primary" }),
87638
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "⇥ add/remove fallback" }),
87639
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "ctrl+shift+↑↓ reorder" }),
87640
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "esc applies" }),
87641
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ml-auto text-[var(--zg-accent)]", "data-testid": "model-chain-count", children: [
87642
- chainState.length,
87643
- " selected",
87644
- multi ? " — order = fallback priority" : ""
87645
- ] })
87646
- ] })
87647
- ] })
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
+ )
87648
88380
  }
87649
88381
  );
87650
88382
  }
87651
- function formatWindow(tokens) {
87652
- if (tokens >= 1e6) {
87653
- return `${(tokens / 1e6).toFixed(2)}M`;
87654
- }
87655
- if (tokens >= 1e3) {
87656
- return `${Math.round(tokens / 1e3)}k`;
87657
- }
87658
- return `${tokens}`;
87659
- }
87660
88383
  function SafelistPanel({ onClose, onBack }) {
87661
88384
  const [groups, setGroups] = reactExports.useState(null);
87662
88385
  const [error, setError] = reactExports.useState(null);
@@ -88533,15 +89256,15 @@ function CredentialSources({
88533
89256
  }
88534
89257
  ),
88535
89258
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-mono ${method.active ? "text-[var(--zg-accent)]" : "text-[var(--zg-text)]"}`, children: method.source }),
88536
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] truncate min-w-0", title: method.detail, children: method.detail }),
88537
- 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)" }),
88538
89261
  selectable && /* @__PURE__ */ jsxRuntimeExports.jsx(
88539
89262
  "button",
88540
89263
  {
88541
89264
  type: "button",
88542
89265
  disabled: busy !== null,
88543
89266
  onClick: () => void use(method.source),
88544
- 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",
88545
89268
  title: `Make the ${method.source} credential the one zidane uses for ${status.label}`,
88546
89269
  children: busy === method.source ? "Switching…" : "Use"
88547
89270
  }
@@ -90401,7 +91124,14 @@ function ModelListPicker({
90401
91124
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-mono text-sm text-[var(--zg-text)]", children: entry.modelId }),
90402
91125
  entry.modelName !== entry.modelId && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-xs text-[var(--zg-text-muted)]", children: entry.modelName })
90403
91126
  ] }),
90404
- /* @__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
+ )
90405
91135
  ]
90406
91136
  }
90407
91137
  ) }, `${entry.providerKey}:${entry.modelId}`);
@@ -90935,6 +91665,7 @@ const TAB_SECTIONS = {
90935
91665
  keys: ["toolCallDisplay", "showToolResults", "showEditDiffs", "groupToolCalls", "showFullShellOutput"]
90936
91666
  },
90937
91667
  { title: "Transcript", keys: ["showThinking", "hideSubagentOutput", "showRunReceipt", "showTodoIndicator"] },
91668
+ { title: "Artifacts", keys: ["artifacts"] },
90938
91669
  { title: "Subscription usage", keys: ["subscriptionUsage", "showUsageIndicator"] },
90939
91670
  { title: "Composer", keys: ["attachmentsEnabled", "inlineAutocomplete"] }
90940
91671
  ],
@@ -91388,215 +92119,6 @@ function nextOption(row, current) {
91388
92119
  const next = row.options[(idx + 1) % row.options.length];
91389
92120
  return next.value;
91390
92121
  }
91391
- const ArtifactsContext = reactExports.createContext(null);
91392
- function ArtifactsProvider({ children }) {
91393
- const [byId, setById] = reactExports.useState(() => /* @__PURE__ */ new Map());
91394
- const pending = reactExports.useRef(/* @__PURE__ */ new Set());
91395
- const fetch = reactExports.useCallback(async (sessionId) => {
91396
- const groups = await window.api.artifacts.list({ sessionId });
91397
- setById((prev) => {
91398
- const next = new Map(prev);
91399
- next.set(sessionId, groups);
91400
- return next;
91401
- });
91402
- }, []);
91403
- reactExports.useEffect(() => {
91404
- return window.api.chat.onStreamSignal((signal) => {
91405
- if (signal.kind !== "artifact:recorded" && signal.kind !== "artifact:changed") return;
91406
- const { sessionId } = signal;
91407
- if (pending.current.has(sessionId)) return;
91408
- pending.current.add(sessionId);
91409
- queueMicrotask(() => {
91410
- pending.current.delete(sessionId);
91411
- void fetch(sessionId).catch(() => void 0);
91412
- });
91413
- });
91414
- }, [fetch]);
91415
- const groupsFor = reactExports.useCallback(
91416
- (sessionId) => sessionId ? byId.get(sessionId) ?? null : null,
91417
- [byId]
91418
- );
91419
- const value = reactExports.useMemo(() => ({ groupsFor, fetch }), [groupsFor, fetch]);
91420
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ArtifactsContext.Provider, { value, children });
91421
- }
91422
- function useArtifactsFor(sessionId) {
91423
- const ctx = reactExports.useContext(ArtifactsContext);
91424
- if (!ctx) throw new Error("useArtifactsFor must be used within ArtifactsProvider");
91425
- return ctx.groupsFor(sessionId);
91426
- }
91427
- function useArtifactsFetcher() {
91428
- const ctx = reactExports.useContext(ArtifactsContext);
91429
- if (!ctx) throw new Error("useArtifactsFetcher must be used within ArtifactsProvider");
91430
- return ctx.fetch;
91431
- }
91432
- function countArtifacts(groups) {
91433
- return groups ? groups.reduce((n, g) => n + g.rows.length, 0) : 0;
91434
- }
91435
- const GHOST_BTN$1 = "zg-press h-7 px-2 rounded-md text-xs text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border-0 bg-transparent cursor-pointer transition-colors duration-150 disabled:opacity-40 disabled:cursor-not-allowed";
91436
- const TAB_BTN = (active) => `zg-press h-7 px-2.5 rounded-md text-xs border-0 cursor-pointer transition-colors duration-150 ${active ? "bg-[var(--zg-bg-hover)] text-[var(--zg-text)]" : "bg-transparent text-[var(--zg-text-muted)] hover:text-[var(--zg-text)]"}`;
91437
- function ArtifactsModal({ sessionId, projectRoot, sessionTitle }) {
91438
- const { close: close2 } = useModal();
91439
- const cached = useArtifactsFor(sessionId);
91440
- const fetchSession = useArtifactsFetcher();
91441
- const [scope, setScope] = reactExports.useState("session");
91442
- const [project, setProject] = reactExports.useState(null);
91443
- const [error, setError] = reactExports.useState(null);
91444
- reactExports.useEffect(() => {
91445
- void fetchSession(sessionId).catch((err) => setError(err.message));
91446
- }, [fetchSession, sessionId]);
91447
- const loadProject = reactExports.useCallback(async () => {
91448
- if (!projectRoot) return;
91449
- try {
91450
- setProject(await window.api.artifacts.list({ projectRoot }));
91451
- } catch (err) {
91452
- setError(err.message);
91453
- }
91454
- }, [projectRoot]);
91455
- reactExports.useEffect(() => {
91456
- if (scope !== "project") return;
91457
- void loadProject();
91458
- return window.api.chat.onStreamSignal((signal) => {
91459
- if (signal.kind === "artifact:recorded" || signal.kind === "artifact:changed") void loadProject();
91460
- });
91461
- }, [scope, loadProject]);
91462
- const groups = scope === "project" ? project : cached;
91463
- const total = countArtifacts(groups);
91464
- const refreshed = reactExports.useRef(/* @__PURE__ */ new Set());
91465
- const refresh = reactExports.useCallback((row) => {
91466
- if (refreshed.current.has(row.artifact.id)) return;
91467
- refreshed.current.add(row.artifact.id);
91468
- void window.api.artifacts.refresh(row.artifact).catch(() => void 0);
91469
- }, []);
91470
- const remove = reactExports.useCallback(
91471
- (row) => {
91472
- setError(null);
91473
- void window.api.artifacts.delete(row.artifact.sessionId, row.artifact.id).then((ok2) => {
91474
- if (!ok2) setError("This session store does not support artifacts.");
91475
- else if (scope === "project") void loadProject();
91476
- }).catch((err) => setError(err.message));
91477
- },
91478
- [scope, loadProject]
91479
- );
91480
- const description = reactExports.useMemo(() => {
91481
- if (groups === null) return "Loading…";
91482
- if (total === 0) {
91483
- return scope === "project" ? `No artifacts recorded for ${projectRoot} yet.` : "No artifacts yet — pull requests, branches, commits and created files land here as the agent produces them.";
91484
- }
91485
- return groups.map((g) => `${g.rows.length} ${plural(g.label, g.rows.length)}`).join(" · ");
91486
- }, [groups, total, scope, projectRoot]);
91487
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
91488
- ModalShell,
91489
- {
91490
- title: "Artifacts",
91491
- description,
91492
- onClose: close2,
91493
- size: "medium",
91494
- footer: projectRoot ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 w-full", children: [
91495
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: TAB_BTN(scope === "session"), onClick: () => setScope("session"), children: "This session" }),
91496
- /* @__PURE__ */ jsxRuntimeExports.jsx(
91497
- "button",
91498
- {
91499
- type: "button",
91500
- className: TAB_BTN(scope === "project"),
91501
- onClick: () => setScope("project"),
91502
- title: `Every session under ${projectRoot}`,
91503
- children: "Project"
91504
- }
91505
- )
91506
- ] }) : void 0,
91507
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 p-4", children: [
91508
- error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-warn)] px-1", role: "alert", children: error }),
91509
- groups && total > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-3 overflow-y-auto", children: groups.map((group) => /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "flex flex-col gap-1.5", children: [
91510
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "m-0 text-[11px] uppercase tracking-wide text-[var(--zg-text-muted)] px-1", children: group.rows.length === 1 ? group.label : `${group.label}s` }),
91511
- /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "flex flex-col gap-1.5 m-0 list-none p-0", children: group.rows.map((row) => /* @__PURE__ */ jsxRuntimeExports.jsx(
91512
- ArtifactRow,
91513
- {
91514
- row,
91515
- showSession: scope === "project",
91516
- sessionTitle,
91517
- onFocus: () => refresh(row),
91518
- onRemove: () => remove(row)
91519
- },
91520
- row.artifact.id
91521
- )) })
91522
- ] }, group.kind)) })
91523
- ] })
91524
- }
91525
- );
91526
- }
91527
- function ArtifactRow({
91528
- row,
91529
- showSession,
91530
- sessionTitle,
91531
- onFocus,
91532
- onRemove
91533
- }) {
91534
- const { artifact, row: view } = row;
91535
- const href = view.href;
91536
- const isUrl2 = href !== void 0 && /^https?:\/\//.test(href);
91537
- const session = showSession ? sessionTitle?.(artifact.sessionId) ?? artifact.sessionId.slice(0, 8) : void 0;
91538
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
91539
- "li",
91540
- {
91541
- className: "group flex items-start gap-3 px-3 py-2 rounded-md bg-[var(--zg-bg)] border border-[var(--zg-border)]",
91542
- onMouseEnter: onFocus,
91543
- onFocus,
91544
- children: [
91545
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0 flex flex-col gap-0.5", children: [
91546
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
91547
- isUrl2 ? (
91548
- // `target="_blank"` routes through main's window-open handler → `shell.openExternal`.
91549
- /* @__PURE__ */ jsxRuntimeExports.jsx(
91550
- "a",
91551
- {
91552
- href,
91553
- target: "_blank",
91554
- rel: "noreferrer",
91555
- className: "truncate text-sm text-[var(--zg-text)] hover:text-[var(--zg-accent)] no-underline hover:underline",
91556
- title: href,
91557
- children: view.title
91558
- }
91559
- )
91560
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-sm text-[var(--zg-text)]", title: href ?? artifact.uri, children: view.title }),
91561
- view.status && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-[var(--zg-bg-hover)] text-[var(--zg-text-muted)]", children: view.status }),
91562
- session && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "shrink-0 text-xs text-[var(--zg-text-muted)]", children: [
91563
- "— ",
91564
- session
91565
- ] })
91566
- ] }),
91567
- view.subtitle && view.subtitle !== view.title && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "truncate text-xs text-[var(--zg-text-muted)] font-mono", title: view.subtitle, children: view.subtitle })
91568
- ] }),
91569
- /* @__PURE__ */ jsxRuntimeExports.jsx(
91570
- "button",
91571
- {
91572
- type: "button",
91573
- "aria-label": "Copy locator",
91574
- title: "Copy",
91575
- onClick: () => void navigator.clipboard.writeText(href ?? artifact.uri),
91576
- className: `${GHOST_BTN$1} opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,
91577
- children: "copy"
91578
- }
91579
- ),
91580
- /* @__PURE__ */ jsxRuntimeExports.jsx(
91581
- "button",
91582
- {
91583
- type: "button",
91584
- "aria-label": "Remove artifact",
91585
- title: "Remove from this session",
91586
- onClick: onRemove,
91587
- className: "opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-[var(--zg-text-muted)] hover:text-[var(--zg-error)] bg-transparent border-0 p-0 cursor-pointer text-base leading-6 transition-opacity",
91588
- children: "×"
91589
- }
91590
- )
91591
- ]
91592
- }
91593
- );
91594
- }
91595
- function plural(label, count2) {
91596
- const lower2 = label.toLowerCase();
91597
- if (count2 === 1) return lower2;
91598
- return /(?:s|x|ch|sh)$/.test(lower2) ? `${lower2}es` : `${lower2}s`;
91599
- }
91600
92122
  const TONE_CLS = {
91601
92123
  ok: "text-[var(--zg-accent)]",
91602
92124
  warn: "text-[#f59e0b]",
@@ -92048,7 +92570,10 @@ function AppShell() {
92048
92570
  const running = useSessionRunning(activeSessionId);
92049
92571
  const peekEvents = usePeekEvents();
92050
92572
  const [contextStatus, setContextStatus] = reactExports.useState(null);
92051
- const [costStatus, setCostStatus] = reactExports.useState(null);
92573
+ const [fetchedCostStatus, setFetchedCostStatus] = reactExports.useState(null);
92574
+ const [accruedCost, setAccruedCost] = reactExports.useState(0);
92575
+ const [streamProgress, setStreamProgress] = reactExports.useState(null);
92576
+ const runGenerationRef = reactExports.useRef(0);
92052
92577
  const [runningWork, setRunningWork] = reactExports.useState([]);
92053
92578
  const [compacting, setCompacting] = reactExports.useState(false);
92054
92579
  const [compactionProgress, setCompactionProgress] = reactExports.useState(
@@ -92056,19 +92581,11 @@ function AppShell() {
92056
92581
  );
92057
92582
  const [hasAuth, setHasAuth] = reactExports.useState(null);
92058
92583
  const [transcriptSearchOpen, setTranscriptSearchOpen] = reactExports.useState(false);
92059
- const [sidebarCollapsed, setSidebarCollapsed] = reactExports.useState(() => {
92060
- try {
92061
- return localStorage.getItem("zg-sidebar-collapsed") === "true";
92062
- } catch {
92063
- return false;
92064
- }
92065
- });
92066
- reactExports.useEffect(() => {
92067
- try {
92068
- localStorage.setItem("zg-sidebar-collapsed", sidebarCollapsed ? "true" : "false");
92069
- } catch {
92070
- }
92071
- }, [sidebarCollapsed]);
92584
+ const [sidebarCollapsed, setSidebarCollapsed] = usePersistedState(
92585
+ "zg-sidebar-collapsed",
92586
+ false,
92587
+ parseBoolean
92588
+ );
92072
92589
  const toggleSidebar = reactExports.useCallback(() => setSidebarCollapsed((prev) => !prev), []);
92073
92590
  const lightsInCenter = sidebarCollapsed;
92074
92591
  const activeSession = reactExports.useMemo(
@@ -92099,19 +92616,26 @@ function AppShell() {
92099
92616
  };
92100
92617
  }, [activeSessionId, running, activeSession?.modelId, activeSession?.providerKey]);
92101
92618
  reactExports.useEffect(() => {
92102
- setCostStatus(null);
92619
+ setFetchedCostStatus(null);
92620
+ setAccruedCost(0);
92621
+ setStreamProgress(null);
92103
92622
  if (!activeSessionId) {
92104
92623
  return;
92105
92624
  }
92106
92625
  let cancelled = false;
92626
+ const settlesAccrual = !running;
92627
+ const generationAtFetch = runGenerationRef.current;
92107
92628
  const fetchCost = () => {
92108
92629
  window.api.sessions.costStatus(activeSessionId).then((status) => {
92109
92630
  if (!cancelled) {
92110
- setCostStatus(status);
92631
+ setFetchedCostStatus(status);
92632
+ if (settlesAccrual && generationAtFetch === runGenerationRef.current) {
92633
+ setAccruedCost(0);
92634
+ }
92111
92635
  }
92112
92636
  }).catch(() => {
92113
92637
  if (!cancelled) {
92114
- setCostStatus(null);
92638
+ setFetchedCostStatus(null);
92115
92639
  }
92116
92640
  });
92117
92641
  };
@@ -92120,6 +92644,47 @@ function AppShell() {
92120
92644
  cancelled = true;
92121
92645
  };
92122
92646
  }, [activeSessionId, running, activeSession?.modelId, activeSession?.providerKey]);
92647
+ reactExports.useEffect(() => {
92648
+ if (!activeSessionId) {
92649
+ return;
92650
+ }
92651
+ const unsubscribe = window.api.chat.onStreamSignal((signal) => {
92652
+ if (!("sessionId" in signal) || signal.sessionId !== activeSessionId) {
92653
+ return;
92654
+ }
92655
+ if (signal.kind === "stream:progress") {
92656
+ setStreamProgress({
92657
+ turnId: signal.turnId,
92658
+ outputTokens: signal.outputTokens,
92659
+ estimated: signal.estimated,
92660
+ elapsedMs: signal.elapsedMs,
92661
+ ...signal.estCostUsd !== void 0 ? { estCostUsd: signal.estCostUsd } : {}
92662
+ });
92663
+ } else if (signal.kind === "turn:end") {
92664
+ if (signal.childId === void 0) {
92665
+ setStreamProgress(null);
92666
+ }
92667
+ const cost = signal.usage?.cost ?? 0;
92668
+ if (cost > 0) {
92669
+ setAccruedCost((prev) => prev + cost);
92670
+ }
92671
+ } else if (signal.kind === "run:start") {
92672
+ runGenerationRef.current += 1;
92673
+ setAccruedCost(0);
92674
+ } else if (signal.kind === "run:end") {
92675
+ setStreamProgress(null);
92676
+ }
92677
+ });
92678
+ return () => {
92679
+ unsubscribe();
92680
+ setStreamProgress(null);
92681
+ };
92682
+ }, [activeSessionId]);
92683
+ const costStatus = reactExports.useMemo(
92684
+ () => composeLiveCost(fetchedCostStatus, accruedCost, running ? streamProgress : null),
92685
+ [fetchedCostStatus, accruedCost, streamProgress, running]
92686
+ );
92687
+ const streaming = running ? streamProgress : null;
92123
92688
  reactExports.useEffect(() => {
92124
92689
  if (!activeSessionId) {
92125
92690
  setCompacting(false);
@@ -92463,22 +93028,13 @@ function AppShell() {
92463
93028
  }
92464
93029
  modal.open(/* @__PURE__ */ jsxRuntimeExports.jsx(TodosModal, { sessionId: activeSession.id }));
92465
93030
  }, [modal, activeSession]);
93031
+ const [artifactsOpen, setArtifactsOpen] = usePersistedState("zg-artifacts-open", false, parseBoolean);
92466
93032
  const openArtifacts = reactExports.useCallback(() => {
92467
93033
  if (!activeSession) {
92468
93034
  return;
92469
93035
  }
92470
- const projectRoot = activeSession.projectRoot ?? activeSession.cwd;
92471
- modal.open(
92472
- /* @__PURE__ */ jsxRuntimeExports.jsx(
92473
- ArtifactsModal,
92474
- {
92475
- sessionId: activeSession.id,
92476
- ...projectRoot ? { projectRoot } : {},
92477
- sessionTitle: (id) => sessions.find((s2) => s2.id === id)?.title
92478
- }
92479
- )
92480
- );
92481
- }, [modal, activeSession, sessions]);
93036
+ setArtifactsOpen((open) => !open);
93037
+ }, [activeSession]);
92482
93038
  const openUsagePanel = reactExports.useCallback(() => {
92483
93039
  modal.open(/* @__PURE__ */ jsxRuntimeExports.jsx(UsagePanelModal, { activeProviderKey: activeSession?.providerKey ?? null }));
92484
93040
  }, [modal, activeSession]);
@@ -92569,7 +93125,7 @@ function AppShell() {
92569
93125
  selectTurnRef.current.exit();
92570
93126
  return;
92571
93127
  }
92572
- const ids = selectableTurnIds(peekEvents(session.id), settingsRef.current);
93128
+ const ids = selectTurnRef.current.visibleIds(session.id) ?? selectableTurnIds(peekEvents(session.id), settingsRef.current);
92573
93129
  if (ids.length === 0) {
92574
93130
  return;
92575
93131
  }
@@ -92611,7 +93167,7 @@ function AppShell() {
92611
93167
  ...activeSession ? { openEffortPicker } : {},
92612
93168
  ...activeSession ? { openModelPicker } : {},
92613
93169
  ...activeSession ? { openTodos } : {},
92614
- ...activeSession ? { openArtifacts } : {},
93170
+ ...activeSession && settings.artifacts !== false ? { openArtifacts } : {},
92615
93171
  openUsagePanel,
92616
93172
  openMainSession,
92617
93173
  newSession: () => setActiveSessionId(null),
@@ -92674,11 +93230,14 @@ function AppShell() {
92674
93230
  onOpenEffort: activeSession ? openEffortPicker : void 0,
92675
93231
  contextStatus,
92676
93232
  costStatus,
93233
+ streaming,
92677
93234
  runningWorkCount: runningWork.length,
92678
93235
  onOpenRunningWork: openRunningWork,
92679
93236
  lightsInCenter,
92680
93237
  searchOpen: transcriptSearchOpen,
92681
- onCloseSearch: closeTranscriptSearch
93238
+ onCloseSearch: closeTranscriptSearch,
93239
+ artifactsOpen: settings.artifacts !== false && artifactsOpen,
93240
+ ...settings.artifacts !== false ? { onToggleArtifacts: openArtifacts } : {}
92682
93241
  }
92683
93242
  ),
92684
93243
  sidebarCollapsed && /*