zidane-gui 8.2.4 → 8.2.5

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.
@@ -32984,9 +32984,9 @@ function searchHighlightRanges(text2, query) {
32984
32984
  const parsed = parseQuery(query.trim());
32985
32985
  if (parsed.tokens.length === 0) return [];
32986
32986
  const lowerText = lower(text2);
32987
- const phrase = findTermRanges(lowerText, parsed.phraseLower);
32987
+ const phrase = findTermRanges$1(lowerText, parsed.phraseLower);
32988
32988
  if (phrase.length > 0) return mergeRanges$1(phrase, text2.length);
32989
- const exact = parsed.tokens.flatMap((token2) => findTermRanges(lowerText, token2.lower));
32989
+ const exact = parsed.tokens.flatMap((token2) => findTermRanges$1(lowerText, token2.lower));
32990
32990
  if (exact.length > 0) return mergeRanges$1(exact, text2.length);
32991
32991
  return mergeRanges$1(parsed.tokens.flatMap((token2) => findFuzzyWordRange(lowerText, token2.lower) ?? []), text2.length);
32992
32992
  }
@@ -33058,7 +33058,7 @@ function tokenize$2(query) {
33058
33058
  }
33059
33059
  return tokens.filter((token2) => token2.text.length > 0);
33060
33060
  }
33061
- function findTermRanges(text2, termLower) {
33061
+ function findTermRanges$1(text2, termLower) {
33062
33062
  if (!termLower) return [];
33063
33063
  const ranges2 = [];
33064
33064
  let from2 = 0;
@@ -42379,14 +42379,14 @@ const entries$2 = /* @__PURE__ */ new Map();
42379
42379
  const invalidationListeners = /* @__PURE__ */ new Set();
42380
42380
  const watchCounts = /* @__PURE__ */ new Map();
42381
42381
  let wired$5 = false;
42382
- const IDLE$1 = Object.freeze({
42382
+ const IDLE$2 = Object.freeze({
42383
42383
  data: void 0,
42384
42384
  error: void 0,
42385
42385
  status: "idle",
42386
42386
  stale: false,
42387
42387
  refresh: () => Promise.resolve()
42388
42388
  });
42389
- const PENDING = Object.freeze({ ...IDLE$1, status: "loading" });
42389
+ const PENDING = Object.freeze({ ...IDLE$2, status: "loading" });
42390
42390
  function serializeIpcResourceKey(key2) {
42391
42391
  return typeof key2 === "string" ? key2 : JSON.stringify(key2);
42392
42392
  }
@@ -42550,7 +42550,7 @@ function useIpcResource(spec) {
42550
42550
  // eslint-disable-next-line react-hooks/exhaustive-deps
42551
42551
  [id2]
42552
42552
  );
42553
- const read2 = () => id2 ? entries$2.get(id2)?.snapshot ?? PENDING : IDLE$1;
42553
+ const read2 = () => id2 ? entries$2.get(id2)?.snapshot ?? PENDING : IDLE$2;
42554
42554
  return reactExports.useSyncExternalStore(subscribe2, read2, read2);
42555
42555
  }
42556
42556
  function subscribeIpcResource(spec, onChange) {
@@ -45581,7 +45581,7 @@ function loadSymbolsFont(url) {
45581
45581
  return symbolsFont;
45582
45582
  }
45583
45583
  function loadGhostty$1(symbolsFontUrl2) {
45584
- ghosttyModule ??= Promise.all([__vitePreload(() => import("./ghostty-web-BTRdAlae.js"), true ? [] : void 0, import.meta.url), loadSymbolsFont(symbolsFontUrl2)]).then(async ([m2]) => {
45584
+ ghosttyModule ??= Promise.all([__vitePreload(() => import("./ghostty-web-wgkS5jGl.js"), true ? [] : void 0, import.meta.url), loadSymbolsFont(symbolsFontUrl2)]).then(async ([m2]) => {
45585
45585
  await m2.init();
45586
45586
  drawBoxGlyphs(m2);
45587
45587
  return m2;
@@ -80460,34 +80460,106 @@ const Timeline = reactExports.memo(({ events, isStreaming, sessionId }) => {
80460
80460
  }
80461
80461
  ) }) }) }) });
80462
80462
  });
80463
+ function tokenizeQuery(query) {
80464
+ const tokens = [];
80465
+ let i2 = 0;
80466
+ while (i2 < query.length) {
80467
+ while (i2 < query.length && /\s/u.test(query[i2])) i2 += 1;
80468
+ if (i2 >= query.length) break;
80469
+ if (query[i2] === '"') {
80470
+ i2 += 1;
80471
+ let value = "";
80472
+ while (i2 < query.length && query[i2] !== '"') {
80473
+ value += query[i2];
80474
+ i2 += 1;
80475
+ }
80476
+ if (query[i2] === '"') i2 += 1;
80477
+ if (value.length > 0) tokens.push(value);
80478
+ continue;
80479
+ }
80480
+ const start2 = i2;
80481
+ while (i2 < query.length && !/\s/u.test(query[i2])) i2 += 1;
80482
+ tokens.push(query.slice(start2, i2));
80483
+ }
80484
+ return tokens;
80485
+ }
80486
+ function findTermRanges(text2, terms) {
80487
+ const haystack = text2.toLowerCase();
80488
+ const found2 = [];
80489
+ for (const term of terms) {
80490
+ const needle = term.toLowerCase();
80491
+ if (needle.trim().length === 0) continue;
80492
+ for (let at2 = haystack.indexOf(needle); at2 !== -1; at2 = haystack.indexOf(needle, at2 + needle.length)) {
80493
+ found2.push([at2, at2 + needle.length]);
80494
+ }
80495
+ }
80496
+ found2.sort((a2, b2) => a2[0] - b2[0] || a2[1] - b2[1]);
80497
+ const merged2 = [];
80498
+ for (const range2 of found2) {
80499
+ const last = merged2.at(-1);
80500
+ if (last && range2[0] <= last[1]) last[1] = Math.max(last[1], range2[1]);
80501
+ else merged2.push([range2[0], range2[1]]);
80502
+ }
80503
+ return merged2;
80504
+ }
80505
+ function focusExcerpt(text2, ranges2, lead = 24) {
80506
+ const first2 = ranges2[0];
80507
+ if (!first2 || first2[0] <= lead) return { text: text2, ranges: [...ranges2] };
80508
+ let cut2 = first2[0] - lead;
80509
+ const space2 = text2.indexOf(" ", cut2);
80510
+ if (space2 !== -1 && space2 < first2[0]) cut2 = space2 + 1;
80511
+ const prefix = "… ";
80512
+ const shift2 = prefix.length - cut2;
80513
+ return {
80514
+ text: prefix + text2.slice(cut2),
80515
+ ranges: ranges2.map(([start2, end2]) => [start2 + shift2, end2 + shift2])
80516
+ };
80517
+ }
80463
80518
  const MAX_MATCHES = 500;
80464
80519
  const RESCAN_MS = 150;
80465
80520
  const HIGHLIGHT_ALL = "zg-search";
80466
80521
  const HIGHLIGHT_ACTIVE = "zg-search-active";
80467
80522
  const highlightsSupported = typeof CSS !== "undefined" && "highlights" in CSS;
80468
80523
  let highlightOwner = null;
80469
- function collectMatches(root2, needle) {
80524
+ const NO_NEEDLE = { key: "", needles: [] };
80525
+ function needleOf(query, terms) {
80526
+ const text2 = query.trim().toLowerCase();
80527
+ if (!text2) return NO_NEEDLE;
80528
+ return terms ? { key: `terms:${text2}`, needles: [...new Set(tokenizeQuery(text2))] } : { key: `phrase:${text2}`, needles: [text2] };
80529
+ }
80530
+ function occurrences(haystack, needles) {
80531
+ const found2 = [];
80532
+ for (const needle of needles) {
80533
+ for (let at2 = haystack.indexOf(needle); at2 !== -1; at2 = haystack.indexOf(needle, at2 + needle.length)) {
80534
+ found2.push([at2, at2 + needle.length]);
80535
+ }
80536
+ }
80537
+ if (needles.length === 1) return found2;
80538
+ found2.sort((a2, b2) => a2[0] - b2[0] || b2[1] - a2[1]);
80539
+ const kept = [];
80540
+ for (const span of found2) if (kept.length === 0 || span[0] >= kept.at(-1)[1]) kept.push(span);
80541
+ return kept;
80542
+ }
80543
+ function collectMatches(root2, needles) {
80470
80544
  const ranges2 = [];
80471
80545
  const walker = document.createTreeWalker(root2, NodeFilter.SHOW_TEXT);
80472
80546
  let node2;
80473
80547
  while (node2 = walker.nextNode()) {
80474
- const haystack = node2.data.toLowerCase();
80475
- let idx = haystack.indexOf(needle);
80476
- if (idx === -1) {
80548
+ const spans = occurrences(node2.data.toLowerCase(), needles);
80549
+ if (spans.length === 0) {
80477
80550
  continue;
80478
80551
  }
80479
80552
  if (node2.parentElement?.closest('.zg-collapsible[data-open="false"]')) {
80480
80553
  continue;
80481
80554
  }
80482
- while (idx !== -1) {
80555
+ for (const [start2, end2] of spans) {
80483
80556
  const range2 = document.createRange();
80484
- range2.setStart(node2, idx);
80485
- range2.setEnd(node2, idx + needle.length);
80557
+ range2.setStart(node2, start2);
80558
+ range2.setEnd(node2, end2);
80486
80559
  ranges2.push(range2);
80487
80560
  if (ranges2.length >= MAX_MATCHES) {
80488
80561
  return ranges2;
80489
80562
  }
80490
- idx = haystack.indexOf(needle, idx + needle.length);
80491
80563
  }
80492
80564
  }
80493
80565
  return ranges2;
@@ -80516,8 +80588,8 @@ function releaseHighlights(owner2) {
80516
80588
  function scrollToRange(range2) {
80517
80589
  range2.startContainer.parentElement?.scrollIntoView({ block: "center" });
80518
80590
  }
80519
- function useTranscriptSearch(container, query, revision) {
80520
- const [needle, setNeedle] = reactExports.useState("");
80591
+ function useTranscriptSearch(container, query, revision, { terms = false, revealFirstMatch = false } = {}) {
80592
+ const [needle, setNeedle] = reactExports.useState(NO_NEEDLE);
80521
80593
  const [matches2, setMatches] = reactExports.useState({ count: 0, capped: false });
80522
80594
  const [activeIndex, setActiveIndex] = reactExports.useState(0);
80523
80595
  const rangesRef = reactExports.useRef([]);
@@ -80526,12 +80598,14 @@ function useTranscriptSearch(container, query, revision) {
80526
80598
  const ownerRef = reactExports.useRef(null);
80527
80599
  ownerRef.current ??= {};
80528
80600
  reactExports.useEffect(() => {
80529
- const timer2 = setTimeout(() => setNeedle(query.trim().toLowerCase()), 150);
80601
+ const next = needleOf(query, terms);
80602
+ const timer2 = setTimeout(() => setNeedle((current2) => current2.key === next.key ? current2 : next), 150);
80530
80603
  return () => clearTimeout(timer2);
80531
- }, [query]);
80604
+ }, [query, terms]);
80605
+ const revealArmed = reactExports.useRef(revealFirstMatch);
80532
80606
  const prevNeedleRef = reactExports.useRef("");
80533
80607
  const rowsMounted = useForceMountRows();
80534
- const searching = needle.length > 0;
80608
+ const searching = needle.key !== "";
80535
80609
  reactExports.useEffect(() => searching ? holdForceMountRows() : void 0, [searching]);
80536
80610
  const rescanTimer = reactExports.useRef(null);
80537
80611
  reactExports.useEffect(
@@ -80543,14 +80617,15 @@ function useTranscriptSearch(container, query, revision) {
80543
80617
  reactExports.useEffect(() => {
80544
80618
  const owner2 = ownerRef.current;
80545
80619
  const root2 = container.current;
80546
- if (needle.length > 0 && !rowsMounted) return;
80547
- const needleChanged = prevNeedleRef.current !== needle;
80548
- prevNeedleRef.current = needle;
80620
+ if (searching && !rowsMounted) return;
80621
+ const needleChanged = prevNeedleRef.current !== needle.key;
80622
+ if (needleChanged && prevNeedleRef.current !== "") revealArmed.current = false;
80623
+ prevNeedleRef.current = needle.key;
80549
80624
  if (rescanTimer.current) {
80550
80625
  clearTimeout(rescanTimer.current);
80551
80626
  rescanTimer.current = null;
80552
80627
  }
80553
- if (!root2 || needle.length === 0) {
80628
+ if (!root2 || !searching) {
80554
80629
  if (rangesRef.current.length === 0 && !needleChanged) return;
80555
80630
  rangesRef.current = [];
80556
80631
  setMatches((prev) => prev.count === 0 && !prev.capped ? prev : { count: 0, capped: false });
@@ -80560,7 +80635,8 @@ function useTranscriptSearch(container, query, revision) {
80560
80635
  }
80561
80636
  const scan = () => {
80562
80637
  rescanTimer.current = null;
80563
- const ranges2 = collectMatches(root2, needle);
80638
+ const ranges2 = collectMatches(root2, needle.needles);
80639
+ const jump = needleChanged || revealArmed.current;
80564
80640
  const nextIndex = needleChanged ? 0 : Math.min(activeIndexRef.current, Math.max(0, ranges2.length - 1));
80565
80641
  rangesRef.current = ranges2;
80566
80642
  setMatches(
@@ -80568,13 +80644,14 @@ function useTranscriptSearch(container, query, revision) {
80568
80644
  );
80569
80645
  setActiveIndex(nextIndex);
80570
80646
  setHighlights(owner2, ranges2, nextIndex);
80571
- if (needleChanged && ranges2.length > 0) {
80647
+ if (jump && ranges2.length > 0) {
80648
+ revealArmed.current = false;
80572
80649
  scrollToRange(ranges2[nextIndex]);
80573
80650
  }
80574
80651
  };
80575
80652
  if (needleChanged) scan();
80576
80653
  else rescanTimer.current = setTimeout(scan, RESCAN_MS);
80577
- }, [needle, revision, container, rowsMounted]);
80654
+ }, [needle, searching, revision, container, rowsMounted]);
80578
80655
  reactExports.useEffect(() => {
80579
80656
  const owner2 = ownerRef.current;
80580
80657
  return () => releaseHighlights(owner2);
@@ -80589,7 +80666,7 @@ function useTranscriptSearch(container, query, revision) {
80589
80666
  setHighlights(ownerRef.current, ranges2, next);
80590
80667
  scrollToRange(ranges2[next]);
80591
80668
  }, []);
80592
- return { count: matches2.count, capped: matches2.capped, activeIndex, hasNeedle: needle.length > 0, goTo };
80669
+ return { count: matches2.count, capped: matches2.capped, activeIndex, hasNeedle: searching, goTo };
80593
80670
  }
80594
80671
  function SearchHighlightStyle() {
80595
80672
  const accent = reactExports.useMemo(
@@ -80604,12 +80681,16 @@ function SearchHighlightStyle() {
80604
80681
  ::highlight(${HIGHLIGHT_ACTIVE}) { background-color: color-mix(in srgb, ${accent} 65%, transparent); }
80605
80682
  ` });
80606
80683
  }
80607
- function TranscriptSearch({ container, sessionId, onClose }) {
80684
+ function TranscriptSearch({ container, sessionId, initialQuery, onClose }) {
80608
80685
  const modal = useModal();
80609
80686
  const events = useSessionEvents(sessionId);
80610
80687
  const inputRef = reactExports.useRef(null);
80611
- const [query, setQuery] = reactExports.useState("");
80612
- const { count: count2, capped, activeIndex, hasNeedle, goTo } = useTranscriptSearch(container, query, events);
80688
+ const [query, setQuery] = reactExports.useState(initialQuery ?? "");
80689
+ const seeded2 = Boolean(initialQuery) && query === initialQuery;
80690
+ const { count: count2, capped, activeIndex, hasNeedle, goTo } = useTranscriptSearch(container, query, events, {
80691
+ terms: seeded2,
80692
+ revealFirstMatch: seeded2
80693
+ });
80613
80694
  reactExports.useEffect(() => {
80614
80695
  inputRef.current?.select();
80615
80696
  }, []);
@@ -83772,11 +83853,11 @@ function AnswerField({ placeholder, onSubmit }) {
83772
83853
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "submit", disabled: !text2.trim(), className: buttonClass({ variant: "secondary", size: "sm" }), children: labels.signInSubmit })
83773
83854
  ] });
83774
83855
  }
83775
- const IDLE = constant(null);
83856
+ const IDLE$1 = constant(null);
83776
83857
  const ended = (state2) => state2?.kind === "done" || state2?.kind === "error";
83777
83858
  function useSignIn(onDone) {
83778
83859
  const [flow2, setFlow] = reactExports.useState(null);
83779
- const state2 = useReadable(flow2 ? flow2.state : IDLE);
83860
+ const state2 = useReadable(flow2 ? flow2.state : IDLE$1);
83780
83861
  const done = reactExports.useRef(onDone);
83781
83862
  reactExports.useEffect(() => {
83782
83863
  done.current = onDone;
@@ -106851,6 +106932,10 @@ function readPrList(result) {
106851
106932
  if (result && !Array.isArray(result)) return { list: [], retryAt: result.rateLimited.retryAt };
106852
106933
  return { list: result, retryAt: null };
106853
106934
  }
106935
+ function worktreeChat(sessions2, ids, current2) {
106936
+ const wanted = new Set(ids);
106937
+ return sessions2.filter((s2) => wanted.has(s2.id) && s2.id !== current2 && !s2.archived).sort((a2, b2) => b2.updatedAt - a2.updatedAt)[0];
106938
+ }
106854
106939
  function clock(ms2) {
106855
106940
  const d2 = new Date(ms2);
106856
106941
  return `${String(d2.getHours()).padStart(2, "0")}:${String(d2.getMinutes()).padStart(2, "0")}`;
@@ -106879,6 +106964,7 @@ function BranchMenu({
106879
106964
  const [expanded, setExpanded] = reactExports.useState(/* @__PURE__ */ new Set());
106880
106965
  const [active2, setActive2] = reactExports.useState(0);
106881
106966
  const [error, setError] = reactExports.useState(null);
106967
+ const [elsewhere, setElsewhere] = reactExports.useState(null);
106882
106968
  const [busy2, setBusy] = reactExports.useState(null);
106883
106969
  const [pendingEnter, setPendingEnter] = reactExports.useState(false);
106884
106970
  const surfaceRef = reactExports.useRef(null);
@@ -106890,6 +106976,7 @@ function BranchMenu({
106890
106976
  worktreeOpen.current = worktreeBranch !== null;
106891
106977
  const worktreeInputRef = reactExports.useRef(null);
106892
106978
  const { allSessions } = useSessionsList();
106979
+ const { setActiveSessionId } = useSessionsActions();
106893
106980
  const session = sessionId ? allSessions.find((s2) => s2.id === sessionId) : void 0;
106894
106981
  const canMove = session !== void 0 && (session.environment?.kind ?? "local") === "local";
106895
106982
  const hostKey = sessionId ? parseSessionKey(sessionId).hostId : LOCAL_SESSION_HOST;
@@ -106910,6 +106997,7 @@ function BranchMenu({
106910
106997
  setExpanded(/* @__PURE__ */ new Set());
106911
106998
  setActive2(0);
106912
106999
  setError(null);
107000
+ setElsewhere(null);
106913
107001
  setPendingEnter(false);
106914
107002
  setWorktreeBranch(null);
106915
107003
  setBranches(branchCache.get(cwd2) ?? null);
@@ -106990,7 +107078,18 @@ function BranchMenu({
106990
107078
  return { ...sec, all: all2, shown: shown2, hidden: all2.length - shown2.length };
106991
107079
  }).filter((sec) => sec.all.length > 0);
106992
107080
  }, [prs, branches, search2, searched, q2, expanded]);
106993
- const entries2 = reactExports.useMemo(() => sections.flatMap((sec) => sec.shown), [sections]);
107081
+ const typed = query.trim();
107082
+ const canStartWorktree = worktree?.available === true;
107083
+ const creates = reactExports.useMemo(() => {
107084
+ if (!typed || branches === null || typed === current2) return [];
107085
+ const known = (p2) => !p2.fork && p2.branch === typed;
107086
+ if (branches.some((b2) => b2.name === typed) || (prs ?? []).some(known) || search2?.list?.some(known)) return [];
107087
+ return [
107088
+ { kind: "create", name: typed, worktree: false },
107089
+ ...canStartWorktree ? [{ kind: "create", name: typed, worktree: true }] : []
107090
+ ];
107091
+ }, [typed, branches, prs, search2, current2, canStartWorktree]);
107092
+ const entries2 = reactExports.useMemo(() => [...sections.flatMap((sec) => sec.shown), ...creates], [sections, creates]);
106994
107093
  const activeIndex = Math.min(active2, Math.max(0, entries2.length - 1));
106995
107094
  reactExports.useEffect(() => {
106996
107095
  if (!scrollToActive.current) return;
@@ -107002,22 +107101,42 @@ function BranchMenu({
107002
107101
  setPendingEnter(false);
107003
107102
  if (entries2[activeIndex]) void pick2(entries2[activeIndex]);
107004
107103
  }, [pendingEnter, branches, entries2]);
107005
- const keyOf2 = (e2) => e2.kind === "pr" ? `pr:${e2.pr.number}` : `branch:${e2.row.name}`;
107006
- const isCurrent = (e2) => current2 !== null && (e2.kind === "branch" ? e2.row.name === current2 : !e2.pr.fork && e2.pr.branch === current2);
107104
+ const keyOf2 = (e2) => e2.kind === "pr" ? `pr:${e2.pr.number}` : e2.kind === "branch" ? `branch:${e2.row.name}` : `create:${e2.worktree}`;
107105
+ const isCurrent = (e2) => current2 !== null && e2.kind !== "create" && (e2.kind === "branch" ? e2.row.name === current2 : !e2.pr.fork && e2.pr.branch === current2);
107007
107106
  const pick2 = async (entry) => {
107008
- if (isCurrent(entry) || busy2) return onClose();
107107
+ if (busy2) return onClose();
107108
+ if (entry.kind === "create")
107109
+ return entry.worktree ? startWorktree(entry.name, keyOf2(entry)) : createBranch(entry.name);
107110
+ if (isCurrent(entry)) return onClose();
107009
107111
  const target = entry.kind === "branch" ? entry.row.name : entry.pr.local ? entry.pr.branch : { pr: entry.pr.number };
107010
107112
  setBusy(keyOf2(entry));
107011
107113
  setError(null);
107114
+ setElsewhere(null);
107012
107115
  const result = await window.api.workspace.gitSwitch(cwd2, target, sessionId);
107013
107116
  setBusy(null);
107117
+ if (result.ok) return onSwitched();
107118
+ const chat = result.worktree ? worktreeChat(allSessions, result.chats ?? [], sessionId) : void 0;
107119
+ if (!chat || !result.worktree) return setError(result.error);
107120
+ setElsewhere({
107121
+ branch: entry.kind === "branch" ? entry.row.name : entry.pr.branch,
107122
+ worktree: result.worktree,
107123
+ chat: chat.id
107124
+ });
107125
+ };
107126
+ const createBranch = async (name2) => {
107127
+ setBusy(keyOf2({ kind: "create", worktree: false }));
107128
+ setError(null);
107129
+ setElsewhere(null);
107130
+ const result = await window.api.workspace.gitCreateBranch(cwd2, name2, sessionId);
107131
+ setBusy(null);
107014
107132
  if (result.ok) onSwitched();
107015
107133
  else setError(result.error);
107016
107134
  };
107017
- const startWorktree = async () => {
107135
+ const startWorktree = async (typedBranch, busyKey = "worktree") => {
107018
107136
  if (!sessionId || !worktree || busy2) return;
107019
- const branch = worktreeBranch?.trim() || worktree.suggestedBranch;
107020
- setBusy("worktree");
107137
+ const branch = typedBranch ?? (worktreeBranch?.trim() || worktree.suggestedBranch);
107138
+ setBusy(busyKey);
107139
+ setElsewhere(null);
107021
107140
  setError(null);
107022
107141
  try {
107023
107142
  await window.api.sessions.moveEnvironment(sessionId, { kind: "worktree", ...branch ? { branch } : {} });
@@ -107095,6 +107214,26 @@ function BranchMenu({
107095
107214
  }
107096
107215
  ) }),
107097
107216
  error && /* @__PURE__ */ jsxRuntimeExports.jsx(MenuNote, { icon: "i-ph-warning", className: "text-[var(--zg-danger)]", children: error }),
107217
+ elsewhere && /* @__PURE__ */ jsxRuntimeExports.jsx(MenuNote, { icon: environmentKindIcon("worktree"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2 min-w-0", children: [
107218
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "truncate", title: elsewhere.worktree, children: [
107219
+ elsewhere.branch,
107220
+ " is checked out in ",
107221
+ elsewhere.worktree
107222
+ ] }),
107223
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
107224
+ "button",
107225
+ {
107226
+ type: "button",
107227
+ "data-testid": "git-open-worktree-chat",
107228
+ className: "shrink-0 text-[var(--zg-accent)] hover:underline",
107229
+ onClick: () => {
107230
+ onClose();
107231
+ setActiveSessionId(elsewhere.chat);
107232
+ },
107233
+ children: "Open its chat"
107234
+ }
107235
+ )
107236
+ ] }) }),
107098
107237
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
107099
107238
  "div",
107100
107239
  {
@@ -107127,7 +107266,7 @@ function BranchMenu({
107127
107266
  onHover: rowHandlers.hover,
107128
107267
  onPick: rowHandlers.pick
107129
107268
  };
107130
- return entry.kind === "pr" ? /* @__PURE__ */ jsxRuntimeExports.jsx(PrRow, { pr: entry.pr, now: now2, ...common }, keyOf2(entry)) : /* @__PURE__ */ jsxRuntimeExports.jsx(BranchRow, { row: entry.row, now: now2, ...common }, keyOf2(entry));
107269
+ return entry.kind === "pr" ? /* @__PURE__ */ jsxRuntimeExports.jsx(PrRow, { pr: entry.pr, now: now2, ...common }, keyOf2(entry)) : entry.kind === "branch" ? /* @__PURE__ */ jsxRuntimeExports.jsx(BranchRow, { row: entry.row, now: now2, ...common }, keyOf2(entry)) : null;
107131
107270
  }),
107132
107271
  sec.hidden > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(
107133
107272
  "button",
@@ -107152,6 +107291,27 @@ function BranchMenu({
107152
107291
  },
107153
107292
  sec.id
107154
107293
  )),
107294
+ creates.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: sections.length > 0 ? "mt-1 pt-1 border-t border-[var(--zg-hairline)]" : "", children: creates.map((entry) => {
107295
+ if (entry.kind !== "create") return null;
107296
+ const i2 = index2++;
107297
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
107298
+ CreateRow,
107299
+ {
107300
+ id: `git-switch-${i2}`,
107301
+ index: i2,
107302
+ active: i2 === activeIndex,
107303
+ current: false,
107304
+ busy: busy2 === keyOf2(entry),
107305
+ disabled: busy2 !== null,
107306
+ now: now2,
107307
+ onHover: rowHandlers.hover,
107308
+ onPick: rowHandlers.pick,
107309
+ name: entry.name,
107310
+ worktree: entry.worktree
107311
+ },
107312
+ keyOf2(entry)
107313
+ );
107314
+ }) }),
107155
107315
  searching && /* @__PURE__ */ jsxRuntimeExports.jsx(MenuNote, { icon: "i-ph-magnifying-glass", children: "Searching open pull requests…" }),
107156
107316
  prs === null && !q2 && /* @__PURE__ */ jsxRuntimeExports.jsx(MenuNote, { icon: "i-ph-git-pull-request", children: "To see pull requests, install the GitHub CLI (gh) and sign in." }),
107157
107317
  rateLimitedUntil !== null && rateLimitedUntil > Date.now() && /* @__PURE__ */ jsxRuntimeExports.jsxs(MenuNote, { icon: "i-ph-warning-circle", children: [
@@ -107419,6 +107579,35 @@ const BranchRow = reactExports.memo(function BranchRow2({ row: b2, now: now2, ..
107419
107579
  }
107420
107580
  );
107421
107581
  });
107582
+ const CreateRow = reactExports.memo(function CreateRow2({
107583
+ name: name2,
107584
+ worktree,
107585
+ now: _now,
107586
+ ...row
107587
+ }) {
107588
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
107589
+ Row$1,
107590
+ {
107591
+ ...row,
107592
+ testId: worktree ? "git-create-worktree" : "git-create-branch",
107593
+ label: worktree ? `Start ${name2} as a worktree` : `Start branch ${name2}`,
107594
+ icon: /* @__PURE__ */ jsxRuntimeExports.jsx(
107595
+ "span",
107596
+ {
107597
+ "aria-hidden": true,
107598
+ className: `${worktree ? environmentKindIcon("worktree") : "i-ph-plus"} text-[13px] text-[var(--zg-text-muted)]`
107599
+ }
107600
+ ),
107601
+ title: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
107602
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0", children: worktree ? "Start as worktree" : "Start branch" }),
107603
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta truncate text-[var(--zg-text)]", children: name2 })
107604
+ ] }),
107605
+ meta: worktree ? /* @__PURE__ */ jsxRuntimeExports.jsx(Chip$1, { kind: "new", icon: "i-ph-arrow-bend-up-right", children: "moves this chat" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Chip$1, { kind: "new", icon: "i-ph-git-branch", children: "from here, changes kept" }),
107606
+ size: null,
107607
+ actions: null
107608
+ }
107609
+ );
107610
+ });
107422
107611
  function PrPlaceholder() {
107423
107612
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "aria-hidden": true, className: "zg-menu-row", "data-size": "lg", children: [
107424
107613
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "shrink-0 w-4" }),
@@ -134544,6 +134733,7 @@ const ConversationPane = reactExports.memo(function ConversationPane2({
134544
134733
  session,
134545
134734
  lightsInCenter,
134546
134735
  searchOpen,
134736
+ searchQuery,
134547
134737
  actions
134548
134738
  }) {
134549
134739
  const sessionId = session?.id ?? null;
@@ -134599,7 +134789,17 @@ const ConversationPane = reactExports.memo(function ConversationPane2({
134599
134789
  )
134600
134790
  }
134601
134791
  ),
134602
- searchOpen && session && /* @__PURE__ */ jsxRuntimeExports.jsx(TranscriptSearch, { container: scrollRef, sessionId: session.id, onClose: actions.closeSearch }),
134792
+ searchOpen && session && // Keyed by the query: a new palette match opens a fresh search, not the old one edited.
134793
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
134794
+ TranscriptSearch,
134795
+ {
134796
+ container: scrollRef,
134797
+ sessionId: session.id,
134798
+ initialQuery: searchQuery,
134799
+ onClose: actions.closeSearch
134800
+ },
134801
+ searchQuery ?? ""
134802
+ ),
134603
134803
  search2.query !== null && /* @__PURE__ */ jsxRuntimeExports.jsx(SearchHighlightStyle, {})
134604
134804
  ] }),
134605
134805
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -168386,7 +168586,7 @@ function ancestorDirs(paths) {
168386
168586
  return [...dirs];
168387
168587
  }
168388
168588
  const TREE_WIDTH = { default: 220, min: 160, max: 480 };
168389
- const SEARCH_DEBOUNCE_MS$1 = 100;
168589
+ const SEARCH_DEBOUNCE_MS$2 = 100;
168390
168590
  const MemoFileTree = reactExports.memo(FileTree2);
168391
168591
  const TreeColumn = reactExports.memo(function TreeColumn2(p2) {
168392
168592
  const onRight = p2.side === "right";
@@ -168404,7 +168604,7 @@ const TreeColumn = reactExports.memo(function TreeColumn2(p2) {
168404
168604
  const [query, setQuery] = reactExports.useState("");
168405
168605
  const { controlRef, entries: entries2 } = p2;
168406
168606
  reactExports.useEffect(() => {
168407
- const t2 = window.setTimeout(() => controlRef.current?.setSearch(query), SEARCH_DEBOUNCE_MS$1);
168607
+ const t2 = window.setTimeout(() => controlRef.current?.setSearch(query), SEARCH_DEBOUNCE_MS$2);
168408
168608
  return () => window.clearTimeout(t2);
168409
168609
  }, [controlRef, query]);
168410
168610
  const queryRef = reactExports.useRef(query);
@@ -170938,6 +171138,7 @@ function Center(props) {
170938
171138
  session: activeSession,
170939
171139
  lightsInCenter,
170940
171140
  searchOpen: props.searchOpen,
171141
+ searchQuery: props.searchQuery,
170941
171142
  actions
170942
171143
  }
170943
171144
  ),
@@ -178038,7 +178239,7 @@ function SidebarSearchRow({ value, onChange }) {
178038
178239
  /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarFilterMenu, {})
178039
178240
  ] });
178040
178241
  }
178041
- const SEARCH_DEBOUNCE_MS = 200;
178242
+ const SEARCH_DEBOUNCE_MS$1 = 200;
178042
178243
  function useSessionSearch(sessions2, archiveFilter) {
178043
178244
  const [searchQuery, setSearchQuery] = reactExports.useState("");
178044
178245
  const [contentHits, setContentHits] = reactExports.useState([]);
@@ -178054,7 +178255,7 @@ function useSessionSearch(sessions2, archiveFilter) {
178054
178255
  }
178055
178256
  setSearching(true);
178056
178257
  const timer2 = setTimeout(() => {
178057
- void window.api.sessions.search(trimmedQuery, { archive: archiveFilter }).then((res) => {
178258
+ void window.api.sessions.search(trimmedQuery, { archive: archiveFilter }, "sidebar").then((res) => {
178058
178259
  if (res.token < searchTokenRef.current) {
178059
178260
  return;
178060
178261
  }
@@ -178062,7 +178263,7 @@ function useSessionSearch(sessions2, archiveFilter) {
178062
178263
  setContentHits(res.results);
178063
178264
  setSearching(false);
178064
178265
  }).catch(() => setSearching(false));
178065
- }, SEARCH_DEBOUNCE_MS);
178266
+ }, SEARCH_DEBOUNCE_MS$1);
178066
178267
  return () => clearTimeout(timer2);
178067
178268
  }, [searchMode, trimmedQuery, archiveFilter]);
178068
178269
  const titleMatches = reactExports.useMemo(() => {
@@ -189068,11 +189269,10 @@ function sessionItemId(key2) {
189068
189269
  function sessionKeyOfItem(itemId) {
189069
189270
  return itemId.slice(SESSION_ITEM_PREFIX.length);
189070
189271
  }
189071
- const MAX_SESSIONS = 60;
189072
189272
  const PALETTE_SESSIONS_SHOWN = 6;
189073
189273
  function orderPaletteSessions(sessions2, activeSessionId, rankOf) {
189074
189274
  const ranks = new Map(sessions2.map((s2) => [s2.id, rankOf(s2.id)]));
189075
- const ordered = [...sessions2].sort((a2, b2) => ranks.get(a2.id) - ranks.get(b2.id) || b2.updatedAt - a2.updatedAt).slice(0, MAX_SESSIONS);
189275
+ const ordered = [...sessions2].sort((a2, b2) => ranks.get(a2.id) - ranks.get(b2.id) || b2.updatedAt - a2.updatedAt);
189076
189276
  const shown2 = new Set(
189077
189277
  ordered.filter((s2) => s2.id !== activeSessionId).slice(0, PALETTE_SESSIONS_SHOWN).map((s2) => s2.id)
189078
189278
  );
@@ -189101,16 +189301,104 @@ function sessionsSource(sessions2, activeSessionId, setActiveSessionId, rankOf)
189101
189301
  }
189102
189302
  };
189103
189303
  }
189304
+ const CONVERSATIONS_SOURCE_ID = "builtin:conversations";
189305
+ const CONVERSATION_ITEM_PREFIX = "conversation:";
189306
+ const CONVERSATIONS_GROUP = "In conversations";
189307
+ function conversationItemId(target) {
189308
+ return CONVERSATION_ITEM_PREFIX + JSON.stringify([target.sessionId, target.query]);
189309
+ }
189310
+ function conversationTargetOf(itemId) {
189311
+ if (!itemId.startsWith(CONVERSATION_ITEM_PREFIX)) return null;
189312
+ try {
189313
+ const parsed = JSON.parse(itemId.slice(CONVERSATION_ITEM_PREFIX.length));
189314
+ if (!Array.isArray(parsed) || typeof parsed[0] !== "string" || typeof parsed[1] !== "string") return null;
189315
+ return { sessionId: parsed[0], query: parsed[1] };
189316
+ } catch {
189317
+ return null;
189318
+ }
189319
+ }
189320
+ function conversationItem(hit, session, query) {
189321
+ return {
189322
+ id: conversationItemId({ sessionId: hit.sessionId, query }),
189323
+ title: session.title || hit.title || "Untitled session",
189324
+ description: hit.excerpt,
189325
+ group: CONVERSATIONS_GROUP,
189326
+ keywords: [basename$2(session.cwd)],
189327
+ source: CONVERSATIONS_SOURCE_ID
189328
+ };
189329
+ }
189330
+ function conversationsSource(open) {
189331
+ return {
189332
+ id: CONVERSATIONS_SOURCE_ID,
189333
+ // Query-driven: never in the catalog (see the module doc).
189334
+ items: () => [],
189335
+ run: (itemId) => {
189336
+ const target = conversationTargetOf(itemId);
189337
+ if (target) open(target);
189338
+ }
189339
+ };
189340
+ }
189341
+ const SEARCH_DEBOUNCE_MS = 150;
189342
+ const CONVERSATION_SEARCH_MIN_CHARS = 2;
189343
+ const IDLE = { rows: [], hits: /* @__PURE__ */ new Map(), searching: false };
189344
+ function useConversationSearch(query, enabled, sessions2, archive, listed) {
189345
+ const text2 = query.trim();
189346
+ const active2 = enabled && text2.length >= CONVERSATION_SEARCH_MIN_CHARS;
189347
+ const [answer, setAnswer] = reactExports.useState(null);
189348
+ const latest = reactExports.useRef(0);
189349
+ reactExports.useEffect(() => {
189350
+ const request2 = ++latest.current;
189351
+ if (!active2) {
189352
+ setAnswer(null);
189353
+ return;
189354
+ }
189355
+ const timer2 = setTimeout(() => {
189356
+ window.api.sessions.search(text2, { archive }, "palette").then(
189357
+ (res) => {
189358
+ if (request2 === latest.current) setAnswer({ query: text2, hits: res.results });
189359
+ },
189360
+ () => {
189361
+ if (request2 === latest.current) setAnswer({ query: text2, hits: [] });
189362
+ }
189363
+ );
189364
+ }, SEARCH_DEBOUNCE_MS);
189365
+ return () => clearTimeout(timer2);
189366
+ }, [active2, text2, archive]);
189367
+ return reactExports.useMemo(() => {
189368
+ if (!active2) return IDLE;
189369
+ const searching = answer?.query !== text2;
189370
+ if (!answer) return { ...IDLE, searching };
189371
+ const byId = new Map(sessions2.map((s2) => [s2.id, s2]));
189372
+ const rows2 = [];
189373
+ const hits = /* @__PURE__ */ new Map();
189374
+ for (const hit of answer.hits) {
189375
+ const session = byId.get(hit.sessionId);
189376
+ if (!session || listed.has(hit.sessionId)) continue;
189377
+ const item = conversationItem(hit, session, answer.query);
189378
+ rows2.push({ item, score: 0, titleMatches: [] });
189379
+ hits.set(item.id, hit);
189380
+ }
189381
+ return { rows: rows2, hits, searching };
189382
+ }, [active2, answer, text2, sessions2, listed]);
189383
+ }
189384
+ const ConversationHitsContext = reactExports.createContext(/* @__PURE__ */ new Map());
189385
+ function useConversationHit(itemId) {
189386
+ return reactExports.useContext(ConversationHitsContext).get(itemId);
189387
+ }
189104
189388
  const isSession = (item) => item.source === SESSIONS_SOURCE_ID && item.id.startsWith(SESSION_ITEM_PREFIX);
189389
+ const isConversationHit = (item) => item.source === CONVERSATIONS_SOURCE_ID;
189105
189390
  const isFile = (item) => item.source === FILES_SOURCE_ID && item.id.startsWith("file:") && item.id !== "file:go";
189106
189391
  const paletteKeys = (spec) => /* @__PURE__ */ jsxRuntimeExports.jsx(KeyHint, { spec, size: "sm" });
189107
189392
  function paletteVerbOf(row) {
189108
189393
  if (isSession(row.item)) return "Switch to session";
189394
+ if (isConversationHit(row.item)) return "Open and find";
189109
189395
  if (isFile(row.item)) return "Open file";
189110
189396
  return void 0;
189111
189397
  }
189112
189398
  function renderPaletteRow(props) {
189113
- return isSession(props.row.item) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SessionPaletteRow, { ...props }) : void 0;
189399
+ if (isSession(props.row.item)) return /* @__PURE__ */ jsxRuntimeExports.jsx(SessionPaletteRow, { ...props });
189400
+ if (isConversationHit(props.row.item)) return /* @__PURE__ */ jsxRuntimeExports.jsx(ConversationHitRow, { ...props });
189401
+ return void 0;
189114
189402
  }
189115
189403
  function renderPaletteIcon(row) {
189116
189404
  const { item } = row;
@@ -189129,8 +189417,8 @@ const SessionPaletteRow = reactExports.memo(function SessionPaletteRow2(props) {
189129
189417
  const { row, terms } = props;
189130
189418
  const id2 = sessionKeyOfItem(row.item.id);
189131
189419
  const status = SESSION_STATUS[useSessionDotState(id2)];
189132
- const { sessions: sessions2, activeSessionId } = useSessionsList();
189133
- const session = sessions2.find((s2) => s2.id === id2);
189420
+ const { allSessions, activeSessionId } = useSessionsList();
189421
+ const session = allSessions.find((s2) => s2.id === id2);
189134
189422
  const age = session ? ageString(session.updatedAt).replace(/ ago$/, "") : null;
189135
189423
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
189136
189424
  PaletteOption,
@@ -189147,6 +189435,44 @@ const SessionPaletteRow = reactExports.memo(function SessionPaletteRow2(props) {
189147
189435
  }
189148
189436
  );
189149
189437
  });
189438
+ function MarkedText({ text: text2, ranges: ranges2 }) {
189439
+ const out = [];
189440
+ let from2 = 0;
189441
+ for (const [start2, end2] of ranges2) {
189442
+ if (start2 > from2) out.push(text2.slice(from2, start2));
189443
+ out.push(
189444
+ /* @__PURE__ */ jsxRuntimeExports.jsx("mark", { className: "zg-palette-match", children: text2.slice(start2, end2) }, start2)
189445
+ );
189446
+ from2 = end2;
189447
+ }
189448
+ if (from2 < text2.length) out.push(text2.slice(from2));
189449
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: out });
189450
+ }
189451
+ const ConversationHitRow = reactExports.memo(function ConversationHitRow2(props) {
189452
+ const { row } = props;
189453
+ const target = conversationTargetOf(row.item.id);
189454
+ const hit = useConversationHit(row.item.id);
189455
+ const excerpt = row.item.description ?? "";
189456
+ const focused = focusExcerpt(excerpt, findTermRanges(excerpt, tokenizeQuery(target?.query ?? "")));
189457
+ const folder = row.item.keywords?.[0];
189458
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
189459
+ PaletteOption,
189460
+ {
189461
+ ...props,
189462
+ icon: target ? /* @__PURE__ */ jsxRuntimeExports.jsx(SessionStatusDot, { sessionId: target.sessionId }) : void 0,
189463
+ title: row.item.title,
189464
+ description: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "data-testid": "conversation-excerpt", children: /* @__PURE__ */ jsxRuntimeExports.jsx(MarkedText, { text: focused.text, ranges: focused.ranges }) }),
189465
+ trailing: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
189466
+ hit && hit.matchCount > 1 && /* @__PURE__ */ jsxRuntimeExports.jsxs(MetaChip, { children: [
189467
+ hit.matchCount,
189468
+ " matches"
189469
+ ] }),
189470
+ folder && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta max-w-[8rem] truncate", children: folder }),
189471
+ hit && /* @__PURE__ */ jsxRuntimeExports.jsx(MetaChip, { children: ageString(hit.updatedAt).replace(/ ago$/, "") })
189472
+ ] })
189473
+ }
189474
+ );
189475
+ });
189150
189476
  const NO_RECENTS = [];
189151
189477
  function CommandPalette({ context }) {
189152
189478
  const palette = usePalette();
@@ -189189,7 +189515,16 @@ function CommandPalette({ context }) {
189189
189515
  const nested = stack.length > 0;
189190
189516
  const levelRecents = nested ? NO_RECENTS : recents;
189191
189517
  const { rows: ranked, settled: settled2 } = useRankedItems(items, query, levelRecents);
189192
- const groups = reactExports.useMemo(() => groupPaletteRows(ranked, query, levelRecents), [ranked, query, levelRecents]);
189518
+ const { allSessions, archiveFilter } = useSessionsList();
189519
+ const listed = reactExports.useMemo(
189520
+ () => new Set(ranked.flatMap((r2) => r2.item.source === SESSIONS_SOURCE_ID ? [sessionKeyOfItem(r2.item.id)] : [])),
189521
+ [ranked]
189522
+ );
189523
+ const conversations2 = useConversationSearch(query, !nested, allSessions, archiveFilter, listed);
189524
+ const groups = reactExports.useMemo(() => {
189525
+ const sections = groupPaletteRows(ranked, query, levelRecents);
189526
+ return conversations2.rows.length > 0 ? [...sections, { title: CONVERSATIONS_GROUP, rows: conversations2.rows }] : sections;
189527
+ }, [ranked, query, levelRecents, conversations2.rows]);
189193
189528
  const runRow = reactExports.useCallback(
189194
189529
  async (row) => {
189195
189530
  const item = row.item;
@@ -189207,7 +189542,8 @@ function CommandPalette({ context }) {
189207
189542
  return;
189208
189543
  }
189209
189544
  setRunning(false);
189210
- if (!nested) markRecent(item.id);
189545
+ const target = conversationTargetOf(item.id);
189546
+ if (!nested) markRecent(target ? sessionItemId(target.sessionId) : item.id);
189211
189547
  if (!result) {
189212
189548
  close2();
189213
189549
  return;
@@ -189245,8 +189581,8 @@ function CommandPalette({ context }) {
189245
189581
  setQuery("");
189246
189582
  setCursor(0);
189247
189583
  }, []);
189248
- const placeholder = level?.placeholder ?? (nested ? void 0 : "Search actions, sessions, files and settings");
189249
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
189584
+ const placeholder = level?.placeholder ?? (nested ? void 0 : "Search actions, sessions, conversations, files and settings");
189585
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ConversationHitsContext.Provider, { value: conversations2.hits, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
189250
189586
  PalettePanel,
189251
189587
  {
189252
189588
  groups,
@@ -189262,7 +189598,7 @@ function CommandPalette({ context }) {
189262
189598
  placeholder,
189263
189599
  settled: settled2,
189264
189600
  loading: root2 === null && !nested,
189265
- running: running2,
189601
+ running: running2 || conversations2.searching,
189266
189602
  notice,
189267
189603
  verb: paletteVerbOf,
189268
189604
  renderRow: renderPaletteRow,
@@ -189270,7 +189606,7 @@ function CommandPalette({ context }) {
189270
189606
  renderKeys: paletteKeys,
189271
189607
  inputRef
189272
189608
  }
189273
- );
189609
+ ) });
189274
189610
  }
189275
189611
  const ACTIONS = {
189276
189612
  newSession: { title: "New session", group: "Session actions", icon: "i-ph-plus", keywords: ["create", "chat"] },
@@ -189806,13 +190142,14 @@ function PaletteHost({
189806
190142
  handlers: handlers2,
189807
190143
  busy: busy2,
189808
190144
  openSettings,
189809
- onRunSetup
190145
+ onRunSetup,
190146
+ onFindInConversation
189810
190147
  }) {
189811
190148
  const palette = usePalette();
189812
190149
  const modal = useModal();
189813
190150
  const panels = usePanels();
189814
190151
  const {
189815
- sessions: sessions2,
190152
+ allSessions,
189816
190153
  activeSessionId,
189817
190154
  setActiveSessionId,
189818
190155
  defaultFolder,
@@ -189822,7 +190159,7 @@ function PaletteHost({
189822
190159
  activeSpace,
189823
190160
  setActiveSpace
189824
190161
  } = useSessions();
189825
- const active2 = activeSessionId ? sessions2.find((s2) => s2.id === activeSessionId) : void 0;
190162
+ const active2 = activeSessionId ? allSessions.find((s2) => s2.id === activeSessionId) : void 0;
189826
190163
  const cwd2 = active2?.cwd ?? defaultFolder ?? void 0;
189827
190164
  const approvals = useSafeModeQueue();
189828
190165
  const interactions = useInteractions().pending;
@@ -189840,8 +190177,19 @@ function PaletteHost({
189840
190177
  );
189841
190178
  usePaletteSource(
189842
190179
  reactExports.useMemo(
189843
- () => sessionsSource(sessions2, activeSessionId, setActiveSessionId, rankOf),
189844
- [sessions2, activeSessionId, setActiveSessionId, rankOf]
190180
+ () => sessionsSource(allSessions, activeSessionId, setActiveSessionId, rankOf),
190181
+ [allSessions, activeSessionId, setActiveSessionId, rankOf]
190182
+ )
190183
+ );
190184
+ const findInConversationRef = reactExports.useRef(onFindInConversation);
190185
+ findInConversationRef.current = onFindInConversation;
190186
+ usePaletteSource(
190187
+ reactExports.useMemo(
190188
+ () => conversationsSource((target) => {
190189
+ setActiveSessionId(target.sessionId);
190190
+ findInConversationRef.current(target);
190191
+ }),
190192
+ [setActiveSessionId]
189845
190193
  )
189846
190194
  );
189847
190195
  usePaletteSource(reactExports.useMemo(() => actionsSource(handlers2), [handlers2]));
@@ -190234,7 +190582,7 @@ function App({ appearanceFirstRun: appearanceFirstRun2 = false }) {
190234
190582
  function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190235
190583
  useNativeChromeZoomVar();
190236
190584
  const {
190237
- sessions: sessions2,
190585
+ allSessions,
190238
190586
  activeSessionId,
190239
190587
  setActiveSessionId,
190240
190588
  defaultFolder,
@@ -190259,7 +190607,8 @@ function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190259
190607
  null
190260
190608
  );
190261
190609
  const hasAuth = useProviderReady();
190262
- const [transcriptSearchOpen, setTranscriptSearchOpen] = reactExports.useState(false);
190610
+ const [transcriptSearch, setTranscriptSearch] = reactExports.useState(null);
190611
+ const transcriptSearchOpen = transcriptSearch !== null && transcriptSearch.sessionId === activeSessionId;
190263
190612
  const [windowSidebarCollapsed, setWindowSidebarCollapsed] = usePersistedState(
190264
190613
  "zg-sidebar-collapsed",
190265
190614
  false,
@@ -190272,8 +190621,9 @@ function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190272
190621
  );
190273
190622
  const lightsInCenter = sidebarCollapsed;
190274
190623
  const activeSession = reactExports.useMemo(
190275
- () => sessions2.find((s2) => s2.id === activeSessionId) ?? null,
190276
- [sessions2, activeSessionId]
190624
+ // Every loaded session: the palette can open one the sidebar's filters hide.
190625
+ () => allSessions.find((s2) => s2.id === activeSessionId) ?? null,
190626
+ [allSessions, activeSessionId]
190277
190627
  );
190278
190628
  const pinnedTitle = standalone ? activeSession?.title : void 0;
190279
190629
  reactExports.useEffect(() => {
@@ -190566,15 +190916,20 @@ function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190566
190916
  return;
190567
190917
  }
190568
190918
  e2.preventDefault();
190569
- setTranscriptSearchOpen(true);
190919
+ const sessionId = activeSession.id;
190920
+ setTranscriptSearch((open) => open?.sessionId === sessionId ? open : { sessionId, query: "" });
190570
190921
  }
190571
190922
  window.addEventListener("keydown", onKey2);
190572
190923
  return () => window.removeEventListener("keydown", onKey2);
190573
190924
  }, [activeSession, modalIsOpen]);
190574
190925
  reactExports.useEffect(() => {
190575
- setTranscriptSearchOpen(false);
190576
- }, [activeSessionId]);
190577
- const closeTranscriptSearch = reactExports.useCallback(() => setTranscriptSearchOpen(false), []);
190926
+ if (transcriptSearch && transcriptSearch.sessionId !== activeSessionId) setTranscriptSearch(null);
190927
+ }, [activeSessionId, transcriptSearch]);
190928
+ const closeTranscriptSearch = reactExports.useCallback(() => setTranscriptSearch(null), []);
190929
+ const findInConversation = reactExports.useCallback(
190930
+ ({ sessionId, query }) => setTranscriptSearch({ sessionId, query }),
190931
+ []
190932
+ );
190578
190933
  const openModelPicker = reactExports.useCallback(() => {
190579
190934
  if (!activeSession) {
190580
190935
  return;
@@ -190907,7 +191262,8 @@ function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190907
191262
  handlers: handlers2,
190908
191263
  busy: running2,
190909
191264
  openSettings,
190910
- onRunSetup: () => openOnboarding("rerun")
191265
+ onRunSetup: () => openOnboarding("rerun"),
191266
+ onFindInConversation: findInConversation
190911
191267
  }
190912
191268
  ) }),
190913
191269
  /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { region: "Browser", resetKey: regionKey, fallback: null, children: /* @__PURE__ */ jsxRuntimeExports.jsx(BrowserHost, {}) }),
@@ -190939,6 +191295,7 @@ function AppShell({ appearanceFirstRun: appearanceFirstRun2 }) {
190939
191295
  onOpenRunningWork: openRunningWorkFor,
190940
191296
  lightsInCenter,
190941
191297
  searchOpen: transcriptSearchOpen,
191298
+ searchQuery: transcriptSearch?.query,
190942
191299
  onCloseSearch: closeTranscriptSearch,
190943
191300
  onOpenEnvironmentSettings: openEnvironmentSettings
190944
191301
  }