@av-pi-studio/workbench 0.0.0-stage → 0.0.117

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.
Files changed (273) hide show
  1. package/README.md +157 -2
  2. package/dist/chunks/BinaryFallbackViewer-BN-9Yvel.js +19 -0
  3. package/dist/chunks/ChatPanel-CjPUJMEs.js +2493 -0
  4. package/dist/chunks/CodeView-6kJms_MF.js +143 -0
  5. package/dist/chunks/DiffView-BqDuT3CF.js +48 -0
  6. package/dist/chunks/FilePanel-B8IXG2bj.js +92 -0
  7. package/dist/chunks/HtmlViewer-DpuVFaDo.js +490 -0
  8. package/dist/chunks/ImageViewer-BBfyA5QN.js +27 -0
  9. package/dist/chunks/MarkdownFileViewer-DPFPDS7G.js +88 -0
  10. package/dist/chunks/ModelProvidersPanel-Dsezq7Ss.js +95 -0
  11. package/dist/chunks/MoleculeViewerPanel-DEEU6Zkx.js +191 -0
  12. package/dist/chunks/PdfViewer-BdacmAu_.js +300 -0
  13. package/dist/chunks/SaveFileButton-2rOu02Xx.js +33 -0
  14. package/dist/chunks/SettingsDialog-DO1tDhMW.js +471 -0
  15. package/dist/chunks/SkillsPanel-DZDia4Pw.js +833 -0
  16. package/dist/chunks/TerminalPanel-bphwCSyW.js +242 -0
  17. package/dist/chunks/TextViewer-CVGqN6yy.js +63 -0
  18. package/dist/chunks/VideoViewer-BkB9BoOr.js +20 -0
  19. package/dist/chunks/ViewersPanel-C2E9FLf7.js +50 -0
  20. package/dist/chunks/href-resolution-jv3tpRcp.js +25 -0
  21. package/dist/chunks/index-Dlz8mEKZ.js +6258 -0
  22. package/dist/chunks/markdown-B2OXhZ-_.js +353 -0
  23. package/dist/chunks/provider-auth-store-C1GaLTlw.js +34 -0
  24. package/dist/chunks/use-file-download-CogCqTvU.js +31 -0
  25. package/dist/chunks/use-file-watch-Bb_Xzbr-.js +55 -0
  26. package/dist/chunks/use-provider-auth-list-DTjIZycd.js +16 -0
  27. package/dist/features/agent-ui/AskCard.d.ts +62 -0
  28. package/dist/features/agent-ui/agent-ui-store.d.ts +84 -0
  29. package/dist/features/agent-ui/announce.d.ts +51 -0
  30. package/dist/features/agent-ui/ask-list.d.ts +53 -0
  31. package/dist/features/agent-ui/ask-placement.d.ts +47 -0
  32. package/dist/features/agent-ui/deadline.d.ts +27 -0
  33. package/dist/features/agent-ui/keyboard.d.ts +37 -0
  34. package/dist/features/agent-ui/notify-effect.d.ts +41 -0
  35. package/dist/features/agent-ui/option-layout.d.ts +24 -0
  36. package/dist/features/agent-ui/outcome-line.d.ts +38 -0
  37. package/dist/features/agent-ui/prompt-text.d.ts +24 -0
  38. package/dist/features/chat/Attachments.d.ts +20 -0
  39. package/dist/features/chat/ChatPanel.d.ts +12 -0
  40. package/dist/features/chat/CommandMenu.d.ts +41 -0
  41. package/dist/features/chat/Composer.d.ts +58 -0
  42. package/dist/features/chat/ForkDialog.d.ts +24 -0
  43. package/dist/features/chat/ModelMenu.d.ts +54 -0
  44. package/dist/features/chat/ThinkingMenu.d.ts +39 -0
  45. package/dist/features/chat/Timeline.d.ts +30 -0
  46. package/dist/features/chat/TurnProgressBar.d.ts +14 -0
  47. package/dist/features/chat/composer-busy.d.ts +22 -0
  48. package/dist/features/chat/composer-gate.d.ts +37 -0
  49. package/dist/features/chat/composer-path-drop.d.ts +75 -0
  50. package/dist/features/chat/fork-correlation.d.ts +39 -0
  51. package/dist/features/chat/fork-gate.d.ts +27 -0
  52. package/dist/features/chat/fork-picker-nav.d.ts +14 -0
  53. package/dist/features/chat/fork-result.d.ts +43 -0
  54. package/dist/features/chat/model-menu-sort.d.ts +30 -0
  55. package/dist/features/chat/onboarding-nudge.d.ts +18 -0
  56. package/dist/features/chat/rows/AssistantRow.d.ts +24 -0
  57. package/dist/features/chat/rows/CompactionRow.d.ts +16 -0
  58. package/dist/features/chat/rows/ErrorRow.d.ts +13 -0
  59. package/dist/features/chat/rows/ReasoningRow.d.ts +16 -0
  60. package/dist/features/chat/rows/RowShell.d.ts +37 -0
  61. package/dist/features/chat/rows/SystemRow.d.ts +11 -0
  62. package/dist/features/chat/rows/ToolCard.d.ts +30 -0
  63. package/dist/features/chat/rows/UserRow.d.ts +43 -0
  64. package/dist/features/chat/slash-commands.d.ts +81 -0
  65. package/dist/features/chat/thinking-level-source.d.ts +29 -0
  66. package/dist/features/chat/todos/TodoPanel.d.ts +11 -0
  67. package/dist/features/chat/todos/agent-todos-store.d.ts +35 -0
  68. package/dist/features/chat/todos/todo-collapse-codec.d.ts +12 -0
  69. package/dist/features/chat/todos/todo-panel-model.d.ts +37 -0
  70. package/dist/features/chat/use-bottom-anchor.d.ts +33 -0
  71. package/dist/features/chat/use-fork-action.d.ts +32 -0
  72. package/dist/features/connection/ConnectionBar.d.ts +18 -0
  73. package/dist/features/connection/connection-presentation.d.ts +70 -0
  74. package/dist/features/files/BinaryFallbackViewer.d.ts +9 -0
  75. package/dist/features/files/CodeView.d.ts +15 -0
  76. package/dist/features/files/DiffView.d.ts +18 -0
  77. package/dist/features/files/FileContextMenu.d.ts +13 -0
  78. package/dist/features/files/FileExplorer.d.ts +24 -0
  79. package/dist/features/files/FilePanel.d.ts +26 -0
  80. package/dist/features/files/HtmlViewer.d.ts +22 -0
  81. package/dist/features/files/ImageViewer.d.ts +8 -0
  82. package/dist/features/files/MarkdownFileViewer.d.ts +14 -0
  83. package/dist/features/files/MoleculeViewer.d.ts +60 -0
  84. package/dist/features/files/MoleculeViewerPanel.d.ts +9 -0
  85. package/dist/features/files/PdfViewer.d.ts +14 -0
  86. package/dist/features/files/RightSidebar.d.ts +9 -0
  87. package/dist/features/files/SaveFileButton.d.ts +9 -0
  88. package/dist/features/files/TextViewer.d.ts +23 -0
  89. package/dist/features/files/TreeDraftRow.d.ts +15 -0
  90. package/dist/features/files/TreeNode.d.ts +42 -0
  91. package/dist/features/files/TreeRenameRow.d.ts +19 -0
  92. package/dist/features/files/VideoViewer.d.ts +8 -0
  93. package/dist/features/files/create-entry.d.ts +23 -0
  94. package/dist/features/files/delete-entry.d.ts +17 -0
  95. package/dist/features/files/file-tree.d.ts +92 -0
  96. package/dist/features/files/git-status-index.d.ts +37 -0
  97. package/dist/features/files/html-asset-loader.d.ts +43 -0
  98. package/dist/features/files/html-assets.d.ts +97 -0
  99. package/dist/features/files/html-sandbox.d.ts +62 -0
  100. package/dist/features/files/molecule-reload.d.ts +20 -0
  101. package/dist/features/files/molecule-source.d.ts +10 -0
  102. package/dist/features/files/molecule-theme.d.ts +31 -0
  103. package/dist/features/files/move-entry.d.ts +10 -0
  104. package/dist/features/files/move-status.d.ts +10 -0
  105. package/dist/features/files/move-target.d.ts +31 -0
  106. package/dist/features/files/open-file-tab.d.ts +32 -0
  107. package/dist/features/files/pdf-layout.d.ts +28 -0
  108. package/dist/features/files/pdfjs-runtime.d.ts +30 -0
  109. package/dist/features/files/polymer-file.d.ts +33 -0
  110. package/dist/features/files/text-viewer-state.d.ts +53 -0
  111. package/dist/features/files/upload-sources.d.ts +20 -0
  112. package/dist/features/files/viewer-registry.d.ts +81 -0
  113. package/dist/features/files/write-file.d.ts +12 -0
  114. package/dist/features/git/ChangesPanel.d.ts +13 -0
  115. package/dist/features/provider-auth/LoginDialog.d.ts +21 -0
  116. package/dist/features/provider-auth/ModelProvidersPanel.d.ts +12 -0
  117. package/dist/features/provider-auth/QrCode.d.ts +26 -0
  118. package/dist/features/provider-auth/login-flow.d.ts +55 -0
  119. package/dist/features/provider-auth/provider-auth-presentation.d.ts +31 -0
  120. package/dist/features/provider-auth/provider-auth-store.d.ts +42 -0
  121. package/dist/features/sessions/SessionContextMenu.d.ts +11 -0
  122. package/dist/features/sessions/SessionItem.d.ts +22 -0
  123. package/dist/features/sessions/SessionList.d.ts +9 -0
  124. package/dist/features/sessions/WorkspaceContextMenu.d.ts +9 -0
  125. package/dist/features/sessions/WorkspaceGroupHeader.d.ts +26 -0
  126. package/dist/features/sessions/apply-agent-deep-link.d.ts +7 -0
  127. package/dist/features/sessions/open-chat-tab.d.ts +14 -0
  128. package/dist/features/sessions/open-workspace.d.ts +20 -0
  129. package/dist/features/sessions/session-actions.d.ts +18 -0
  130. package/dist/features/sessions/session-presentation.d.ts +47 -0
  131. package/dist/features/sessions/status-map.d.ts +10 -0
  132. package/dist/features/sessions/workspace-grouping.d.ts +30 -0
  133. package/dist/features/settings/SettingsDialog.d.ts +22 -0
  134. package/dist/features/settings/ViewersPanel.d.ts +18 -0
  135. package/dist/features/settings/settings-categories.d.ts +32 -0
  136. package/dist/features/skills/InstallSkillDialog.d.ts +21 -0
  137. package/dist/features/skills/SkillsPanel.d.ts +32 -0
  138. package/dist/features/skills/skills-presentation.d.ts +159 -0
  139. package/dist/features/skills/use-skills.d.ts +215 -0
  140. package/dist/features/terminal/TerminalPanel.d.ts +37 -0
  141. package/dist/features/terminal/terminal-font.d.ts +44 -0
  142. package/dist/features/terminal/terminal-size.d.ts +52 -0
  143. package/dist/features/workspace/ContextMeter.d.ts +15 -0
  144. package/dist/features/workspace/ContextMeterPopover.d.ts +16 -0
  145. package/dist/features/workspace/DropPreview.d.ts +23 -0
  146. package/dist/features/workspace/PaneDividers.d.ts +30 -0
  147. package/dist/features/workspace/StatusBar.d.ts +16 -0
  148. package/dist/features/workspace/TabContextMenu.d.ts +15 -0
  149. package/dist/features/workspace/TabPanelHost.d.ts +30 -0
  150. package/dist/features/workspace/TabStrip.d.ts +36 -0
  151. package/dist/features/workspace/compact-action.d.ts +21 -0
  152. package/dist/features/workspace/context-meter.d.ts +26 -0
  153. package/dist/features/workspace/external-drag.d.ts +99 -0
  154. package/dist/features/workspace/pane-dnd.d.ts +70 -0
  155. package/dist/features/workspace/pane-layout-view.d.ts +73 -0
  156. package/dist/features/workspace/pane-tree.d.ts +141 -0
  157. package/dist/features/workspace/panel-registry.d.ts +13 -0
  158. package/dist/features/workspace/reopen-client-tabs.d.ts +44 -0
  159. package/dist/features/workspace/restore-active-workspace.d.ts +30 -0
  160. package/dist/features/workspace/status-bar-format.d.ts +20 -0
  161. package/dist/features/workspace/tab-attention.d.ts +35 -0
  162. package/dist/features/workspace-picker/OpenWorkspaceDialog.d.ts +11 -0
  163. package/dist/fonts/CascadiaMono.woff2 +0 -0
  164. package/dist/fonts/CascadiaMonoNF.woff2 +0 -0
  165. package/dist/fonts/LICENSE-Cascadia.txt +97 -0
  166. package/dist/fonts.css +60 -0
  167. package/dist/hooks/agent-stream-events.d.ts +20 -0
  168. package/dist/hooks/file-text-state.d.ts +31 -0
  169. package/dist/hooks/file-transfer-instance.d.ts +10 -0
  170. package/dist/hooks/use-agent-commands.d.ts +18 -0
  171. package/dist/hooks/use-agent-deep-link-boot.d.ts +9 -0
  172. package/dist/hooks/use-agent-stream.d.ts +15 -0
  173. package/dist/hooks/use-agent-todos.d.ts +10 -0
  174. package/dist/hooks/use-checkout-status.d.ts +13 -0
  175. package/dist/hooks/use-connection.d.ts +27 -0
  176. package/dist/hooks/use-explorer-tree.d.ts +20 -0
  177. package/dist/hooks/use-explorer-watch.d.ts +39 -0
  178. package/dist/hooks/use-explorer.d.ts +21 -0
  179. package/dist/hooks/use-external-pane-drop.d.ts +47 -0
  180. package/dist/hooks/use-file-diff.d.ts +9 -0
  181. package/dist/hooks/use-file-download.d.ts +18 -0
  182. package/dist/hooks/use-file-live-refresh.d.ts +31 -0
  183. package/dist/hooks/use-file-read.d.ts +31 -0
  184. package/dist/hooks/use-file-source.d.ts +16 -0
  185. package/dist/hooks/use-file-text.d.ts +21 -0
  186. package/dist/hooks/use-file-transfer.d.ts +18 -0
  187. package/dist/hooks/use-file-watch.d.ts +36 -0
  188. package/dist/hooks/use-home-dir.d.ts +14 -0
  189. package/dist/hooks/use-inline-image.d.ts +37 -0
  190. package/dist/hooks/use-is-compacting.d.ts +9 -0
  191. package/dist/hooks/use-pane-drag.d.ts +40 -0
  192. package/dist/hooks/use-pane-layout.d.ts +40 -0
  193. package/dist/hooks/use-provider-auth-list.d.ts +19 -0
  194. package/dist/hooks/use-provider-models.d.ts +14 -0
  195. package/dist/hooks/use-session-restore.d.ts +44 -0
  196. package/dist/hooks/use-session-stats.d.ts +40 -0
  197. package/dist/hooks/use-shortcuts.d.ts +6 -0
  198. package/dist/hooks/use-terminal-exit-watch.d.ts +47 -0
  199. package/dist/hooks/use-terminal-restore.d.ts +38 -0
  200. package/dist/hooks/use-thinking-levels.d.ts +13 -0
  201. package/dist/hooks/use-timeline-reset-watch.d.ts +43 -0
  202. package/dist/hooks/use-viewer-settings.d.ts +17 -0
  203. package/dist/host/browser-clipboard.d.ts +9 -0
  204. package/dist/host/browser-connection.d.ts +13 -0
  205. package/dist/host/browser-files.d.ts +9 -0
  206. package/dist/host/browser-host.d.ts +14 -0
  207. package/dist/host/browser-launch.d.ts +19 -0
  208. package/dist/host/browser-worker-timers.d.ts +29 -0
  209. package/dist/host/external-link.d.ts +14 -0
  210. package/dist/host/index.d.ts +4 -0
  211. package/dist/host/install.d.ts +21 -0
  212. package/dist/host/types.d.ts +168 -0
  213. package/dist/index.d.ts +14 -0
  214. package/dist/index.js +18 -0
  215. package/dist/lib/agent-deep-link.d.ts +29 -0
  216. package/dist/lib/connection/connection-store.d.ts +49 -0
  217. package/dist/lib/connection/files-changed.d.ts +41 -0
  218. package/dist/lib/connection/live-file-transfer.d.ts +8 -0
  219. package/dist/lib/connection/normalize-url.d.ts +16 -0
  220. package/dist/lib/connection/query-client.d.ts +3 -0
  221. package/dist/lib/connection/resolve-connect-target.d.ts +10 -0
  222. package/dist/lib/connection/resume-action.d.ts +33 -0
  223. package/dist/lib/connection/resume-handler.d.ts +6 -0
  224. package/dist/lib/connection/rpc-keys.d.ts +39 -0
  225. package/dist/lib/drag-guard.d.ts +39 -0
  226. package/dist/lib/inline-image-cache.d.ts +34 -0
  227. package/dist/lib/pane-layout-persistence.d.ts +74 -0
  228. package/dist/lib/paths.d.ts +33 -0
  229. package/dist/lib/protocol/events.d.ts +19 -0
  230. package/dist/lib/protocol/timeline-paging.d.ts +29 -0
  231. package/dist/lib/random-id.d.ts +16 -0
  232. package/dist/shell/Workbench.d.ts +6 -0
  233. package/dist/shell/WorkbenchBoot.d.ts +4 -0
  234. package/dist/shell/WorkbenchProvider.d.ts +10 -0
  235. package/dist/shell/WorkspaceShell.d.ts +12 -0
  236. package/dist/shell/context.d.ts +8 -0
  237. package/dist/shell/hooks.d.ts +32 -0
  238. package/dist/shell/regions.d.ts +17 -0
  239. package/dist/stores/compaction-store.d.ts +45 -0
  240. package/dist/stores/deep-link-store.d.ts +15 -0
  241. package/dist/stores/draft-store.d.ts +45 -0
  242. package/dist/stores/explorer-store.d.ts +63 -0
  243. package/dist/stores/fork-store.d.ts +69 -0
  244. package/dist/stores/git-store.d.ts +59 -0
  245. package/dist/stores/layout-store.d.ts +137 -0
  246. package/dist/stores/materialize.d.ts +47 -0
  247. package/dist/stores/session-store.d.ts +76 -0
  248. package/dist/stores/stats-store.d.ts +48 -0
  249. package/dist/stores/tab-store.d.ts +145 -0
  250. package/dist/stores/ui-store.d.ts +85 -0
  251. package/dist/styles.css +1 -0
  252. package/dist/timeline/FileLink.d.ts +22 -0
  253. package/dist/timeline/InlineImage.d.ts +16 -0
  254. package/dist/timeline/bottom-anchor.d.ts +77 -0
  255. package/dist/timeline/compaction.d.ts +12 -0
  256. package/dist/timeline/file-link-src.d.ts +34 -0
  257. package/dist/timeline/file-open-target.d.ts +19 -0
  258. package/dist/timeline/format-meta-time.d.ts +10 -0
  259. package/dist/timeline/highlight.d.ts +9 -0
  260. package/dist/timeline/href-resolution.d.ts +34 -0
  261. package/dist/timeline/image-src.d.ts +32 -0
  262. package/dist/timeline/inline-image-view.d.ts +34 -0
  263. package/dist/timeline/live-tail.d.ts +5 -0
  264. package/dist/timeline/markdown.d.ts +35 -0
  265. package/dist/timeline/mermaid-theme.d.ts +23 -0
  266. package/dist/timeline/reducer.d.ts +38 -0
  267. package/dist/timeline/row-model.d.ts +154 -0
  268. package/dist/timeline/streaming-split.d.ts +42 -0
  269. package/dist/timeline/tool-mapping.d.ts +60 -0
  270. package/dist/viewer-plugins/viewer-settings-store.d.ts +55 -0
  271. package/dist/vite/index.d.ts +36 -0
  272. package/dist/vite/index.js +39 -0
  273. package/package.json +81 -4
@@ -0,0 +1,2493 @@
1
+ import { jsxs as l, jsx as n, Fragment as $ } from "react/jsx-runtime";
2
+ import { useEffect as I, useState as D, useRef as O, Fragment as dn, useCallback as Ae, useMemo as un, useId as mn } from "react";
3
+ import { useQueryClient as pn, useQuery as Fe } from "@tanstack/react-query";
4
+ import { t as Oe, c as K, d as hn, u as ee, o as fn, e as gn, f as wn, h as _t, i as vt, n as kt, j as bn, k as _n, l as vn, m as Ct, p as kn, q as ye, r as $e, s as we, v as Cn, w as yn, x as Ce, y as Nn, z as Tn, A as Sn, B as lt, C as Dn, D as xn, E as Bn, F as An, G as dt } from "./index-Dlz8mEKZ.js";
5
+ import { ListTree as En, Globe as Mn, Search as Rn, FilePlus as Pn, Pencil as On, Eye as Ln, Terminal as yt, HelpCircle as Te, Check as be, Bot as In, Brain as Nt, ChevronRight as _e, ArrowUpRight as Fn, Clock as $n, GitFork as zn, User as Hn, CircleAlert as Tt, ArrowDown as Kn, Plus as Wn, Slash as qn, Cpu as Un, ChevronDown as ut, Square as Gn, Navigation as Yn, ArrowUp as Vn, Circle as jn } from "lucide-react";
6
+ import { Icon as R, Button as F, TextInput as Qn, TextArea as St, Spinner as re, Dialog as Xn, IconButton as Jn, EmptyState as Zn, MenuContent as ze, groupOptions as eo, filterOptions as Dt, MenuGroup as to, Panel as mt } from "@av-pi-studio/ui-library";
7
+ import { useVirtualizer as no, measureElement as oo } from "@tanstack/react-virtual";
8
+ import { u as so } from "./use-provider-auth-list-DTjIZycd.js";
9
+ import { clsx as B } from "clsx";
10
+ import { remainingMs as ro } from "@av-pi-studio/client";
11
+ import { S as xt, M as He, r as io } from "./markdown-B2OXhZ-_.js";
12
+ import { D as ao, p as co } from "./DiffView-BqDuT3CF.js";
13
+ import * as Z from "@radix-ui/react-dropdown-menu";
14
+ import { AGENT_TODOS_MAX_TASKS as lo } from "@av-pi-studio/protocol";
15
+ const uo = {
16
+ shell: yt,
17
+ read: Ln,
18
+ edit: On,
19
+ write: Pn,
20
+ search: Rn,
21
+ fetch: Mn,
22
+ task: En
23
+ };
24
+ function mo(e) {
25
+ return uo[e.kind] ?? yt;
26
+ }
27
+ function Bt(e) {
28
+ switch (e.kind) {
29
+ case "read":
30
+ case "write":
31
+ case "edit":
32
+ return e.path ?? null;
33
+ default:
34
+ return null;
35
+ }
36
+ }
37
+ function po(e) {
38
+ return e.kind === "write" || e.kind === "edit" || e.kind === "shell";
39
+ }
40
+ function ho(e) {
41
+ const t = [];
42
+ if (e.kind === "edit" && e.diff) t.push({ kind: "diff", patch: e.diff });
43
+ else {
44
+ const o = Oe(e);
45
+ o && t.push({ kind: "code", text: o });
46
+ }
47
+ return e.output && t.push({ kind: "code", text: e.output }), t;
48
+ }
49
+ const pt = {
50
+ shell: { label: "SHELL", token: "statusInfo" },
51
+ read: { label: "READ", token: "statusInfo" },
52
+ write: { label: "WRITE", token: "statusSuccess" },
53
+ edit: { label: "EDIT", token: "statusWarning" },
54
+ search: { label: "SEARCH", token: "statusInfo" },
55
+ fetch: { label: "FETCH", token: "statusInfo" },
56
+ task: { label: "TASK", token: "foregroundMuted" }
57
+ };
58
+ function fo(e) {
59
+ return pt[e.kind] ?? pt.task;
60
+ }
61
+ function go(e) {
62
+ if (!e) return { added: 0, removed: 0 };
63
+ let t = 0, o = 0;
64
+ for (const s of e.split(`
65
+ `))
66
+ s.startsWith("+++") || s.startsWith("---") || (s.startsWith("+") ? t++ : s.startsWith("-") && o++);
67
+ return { added: t, removed: o };
68
+ }
69
+ function wo(e) {
70
+ return e ? (e.endsWith(`
71
+ `) ? e.slice(0, -1) : e).split(`
72
+ `).length : 0;
73
+ }
74
+ const bo = 500;
75
+ let Ee;
76
+ function _o(e, t, o, s) {
77
+ clearTimeout(Ee), Ee = setTimeout(() => {
78
+ Ee = void 0, e.invalidateQueries({ queryKey: ["file"] }), e.invalidateQueries({ queryKey: ["explorer"] }), t && o && t.connection.request("checkout_refresh_request", { cwd: o }).catch(() => {
79
+ });
80
+ }, bo);
81
+ }
82
+ function vo({
83
+ sessionId: e,
84
+ event: t,
85
+ timestamp: o,
86
+ client: s,
87
+ queryClient: r
88
+ }) {
89
+ const a = K.getState();
90
+ switch (a.applyStreamEvent(e, t, o), t.kind) {
91
+ case "turn_started":
92
+ a.setStatus(e, "running");
93
+ break;
94
+ case "turn_completed":
95
+ a.setStatus(e, "idle");
96
+ break;
97
+ case "turn_failed":
98
+ a.setStatus(e, "error");
99
+ break;
100
+ case "turn_canceled":
101
+ a.setStatus(e, "idle");
102
+ break;
103
+ case "compaction":
104
+ t.phase === "completed" && t.estimatedTokensAfter !== void 0 && hn(e, t.estimatedTokensAfter);
105
+ break;
106
+ case "tool_call": {
107
+ if (t.status === "completed" && po(t.tool)) {
108
+ const d = a.sessions[e]?.cwd || null;
109
+ _o(r, s, d, Bt(t.tool));
110
+ }
111
+ break;
112
+ }
113
+ }
114
+ }
115
+ function ko(e) {
116
+ const t = ee((r) => r.client), o = K((r) => r.sessions[e]?.agentId ?? null), s = pn();
117
+ I(() => !t || !o ? void 0 : t.agent(o).timeline.subscribe((a, c) => {
118
+ const d = typeof c.timestamp == "number" ? new Date(c.timestamp).toISOString() : c.timestamp;
119
+ vo({ sessionId: e, event: a, timestamp: d, client: t, queryClient: s });
120
+ }), [t, o, e, s]);
121
+ }
122
+ const At = 64;
123
+ function Me(e) {
124
+ return e.clientHeight > 0;
125
+ }
126
+ function Co(e, t, o, s = At) {
127
+ switch (t.kind) {
128
+ case "scroll":
129
+ return Me(o) ? o.scrollHeight - o.scrollTop - o.clientHeight <= s ? { pinned: !0, stick: !1 } : { pinned: t.gesture ? !1 : e, stick: !1 } : { pinned: e, stick: !1 };
130
+ case "tail":
131
+ return { pinned: e, stick: e && Me(o) };
132
+ case "shown":
133
+ return { pinned: e, stick: e };
134
+ case "pin":
135
+ return { pinned: !0, stick: Me(o) };
136
+ }
137
+ }
138
+ function yo(e) {
139
+ const t = e[e.length - 1];
140
+ return t?.kind === "user" ? t.id : null;
141
+ }
142
+ const No = "piwb-RowShell_shellRow_DVHFt", To = "piwb-RowShell_rail_22AA8", So = "piwb-RowShell_disc_UlnuH", Do = "piwb-RowShell_connector_NTCu7", xo = "piwb-RowShell_content_F_CSt", Bo = "piwb-RowShell_metaLine_KS5d8", Ao = "piwb-RowShell_metaTime_e_X-8", Eo = "piwb-RowShell_forkButton_zNW_f", Y = {
143
+ shellRow: No,
144
+ rail: To,
145
+ disc: So,
146
+ connector: Do,
147
+ content: xo,
148
+ metaLine: Bo,
149
+ metaTime: Ao,
150
+ forkButton: Eo
151
+ };
152
+ function Q({
153
+ disc: e,
154
+ discClassName: t,
155
+ connector: o,
156
+ meta: s,
157
+ metaTrailing: r,
158
+ className: a,
159
+ children: c
160
+ }) {
161
+ return /* @__PURE__ */ l("div", { className: Y.shellRow, children: [
162
+ /* @__PURE__ */ l("div", { className: Y.rail, children: [
163
+ /* @__PURE__ */ n("span", { className: B(Y.disc, t), children: e }),
164
+ o && /* @__PURE__ */ n("span", { className: Y.connector })
165
+ ] }),
166
+ /* @__PURE__ */ l("div", { className: B(Y.content, a), children: [
167
+ s && /* @__PURE__ */ l("div", { className: Y.metaLine, children: [
168
+ s,
169
+ r
170
+ ] }),
171
+ c
172
+ ] })
173
+ ] });
174
+ }
175
+ function ht(e) {
176
+ return typeof e == "number" ? e : Date.parse(e);
177
+ }
178
+ function Mo(e, t) {
179
+ const o = ht(e.entry.createdAt), s = ht(t.entry.createdAt);
180
+ return o !== s ? o - s : e.entry.requestId < t.entry.requestId ? -1 : e.entry.requestId > t.entry.requestId ? 1 : 0;
181
+ }
182
+ function Ro(e, t) {
183
+ return [
184
+ ...e.map((s) => ({ kind: "pending", entry: s })),
185
+ ...t.map((s) => ({ kind: "resolved", entry: s }))
186
+ ].toSorted(Mo);
187
+ }
188
+ function Po(e) {
189
+ return e.entry.requestId;
190
+ }
191
+ function Et(e) {
192
+ return e.receivedAt === void 0;
193
+ }
194
+ const Oo = 4;
195
+ function Lo(e, t) {
196
+ let o = 0;
197
+ const s = e.map((d) => d.kind !== "pending" ? { item: d, collapsed: !1 } : (o++, { item: d, collapsed: !t && o > Oo })), r = s.filter((d) => d.collapsed).length, a = s.findIndex((d) => d.collapsed), c = [];
198
+ return s.forEach((d, g) => {
199
+ g === a && c.push({ kind: "more", count: r }), c.push({ kind: "card", item: d.item, collapsed: d.collapsed });
200
+ }), c;
201
+ }
202
+ function Io(e, t) {
203
+ if (e.timeoutMs === void 0) return { show: !1, fraction: 0, approximate: !1 };
204
+ const o = ro(e, t) ?? 0;
205
+ return {
206
+ show: !0,
207
+ fraction: Math.max(0, Math.min(1, o / e.timeoutMs)),
208
+ approximate: e.receivedAt === void 0
209
+ };
210
+ }
211
+ function Mt(e) {
212
+ return e === "editor";
213
+ }
214
+ const Fo = "Esc again to dismiss — the extension gets an empty answer";
215
+ function $o(e, t) {
216
+ return t ? { kind: "warning", text: Fo } : {
217
+ kind: "keys",
218
+ segments: [
219
+ { key: Mt(e) ? "⇧↵" : "↵", label: "submit" },
220
+ { key: "Esc", label: "dismiss" }
221
+ ]
222
+ };
223
+ }
224
+ function zo(e) {
225
+ return e ? { armed: !1, resolve: !0 } : { armed: !0, resolve: !1 };
226
+ }
227
+ const Ho = 5, Ko = 40, Wo = 6;
228
+ function qo(e) {
229
+ return {
230
+ mode: e.length >= Ho || e.some((o) => o.length > Ko) ? "stack" : "row",
231
+ scrolls: e.length > Wo
232
+ };
233
+ }
234
+ function Le(e) {
235
+ const t = e.split(`
236
+ `), o = [];
237
+ let s = !1;
238
+ for (const r of t)
239
+ if (r === "") {
240
+ if (s) continue;
241
+ s = !0, o.push("");
242
+ } else
243
+ s = !1, o.push(r);
244
+ return o;
245
+ }
246
+ function Uo(e, t) {
247
+ return {
248
+ title: Le(e),
249
+ ...t !== void 0 ? { message: Le(t) } : {}
250
+ };
251
+ }
252
+ const Go = "piwb-AskCard_askDisc_HX3Uz", Yo = "piwb-AskCard_card_ioPB1", Vo = "piwb-AskCard_cardInert_tJeTG", jo = "piwb-AskCard_askDiscInert_eH658", Qo = "piwb-AskCard_reconnectingNote_hqoQJ", Xo = "piwb-AskCard_reconnectingDot_GstnF", Jo = "piwb-AskCard_deadlineBar_DXKgj", Zo = "piwb-AskCard_deadlineApproximate_MY0YS", es = "piwb-AskCard_header_a6fOQ", ts = "piwb-AskCard_askBadge_QGONM", ns = "piwb-AskCard_methodName_y7y-k", os = "piwb-AskCard_title_dYUdY", ss = "piwb-AskCard_titleEmphasised_3p_3w", rs = "piwb-AskCard_message_5hr4z", is = "piwb-AskCard_emptyOptionsNote_Kl7NI", as = "piwb-AskCard_controls_CmFP_", cs = "piwb-AskCard_controlsStack_zuFTN", ls = "piwb-AskCard_controlsScroll_ibOZg", ds = "piwb-AskCard_optionButton_30tZq", us = "piwb-AskCard_field_dcsEm", ms = "piwb-AskCard_editorField_vFLBB", ps = "piwb-AskCard_rawPayload_H4AVe", hs = "piwb-AskCard_resolvedCard_fN6JW", fs = "piwb-AskCard_askBadgeNeutral_MyG0B", gs = "piwb-AskCard_resolvedMethodName_Nzc_7", ws = "piwb-AskCard_outcome_lWf14", bs = "piwb-AskCard_outcomeSuccess_17CiQ", _s = "piwb-AskCard_outcomeText_E9vpl", vs = "piwb-AskCard_hint_PZCHD", ks = "piwb-AskCard_hintKey_0cNXz", Cs = "piwb-AskCard_hintSep_RPPsU", ys = "piwb-AskCard_recoveredChip_zaGx_", Ns = "piwb-AskCard_collapsedPendingCard_rqbyC", Ts = "piwb-AskCard_moreRow_hhYAo", w = {
253
+ askDisc: Go,
254
+ card: Yo,
255
+ cardInert: Vo,
256
+ askDiscInert: jo,
257
+ reconnectingNote: Qo,
258
+ reconnectingDot: Xo,
259
+ deadlineBar: Jo,
260
+ deadlineApproximate: Zo,
261
+ header: es,
262
+ askBadge: ts,
263
+ methodName: ns,
264
+ title: os,
265
+ titleEmphasised: ss,
266
+ message: rs,
267
+ emptyOptionsNote: is,
268
+ controls: as,
269
+ controlsStack: cs,
270
+ controlsScroll: ls,
271
+ optionButton: ds,
272
+ field: us,
273
+ editorField: ms,
274
+ rawPayload: ps,
275
+ resolvedCard: hs,
276
+ askBadgeNeutral: fs,
277
+ resolvedMethodName: gs,
278
+ outcome: ws,
279
+ outcomeSuccess: bs,
280
+ outcomeText: _s,
281
+ hint: vs,
282
+ hintKey: ks,
283
+ hintSep: Cs,
284
+ recoveredChip: ys,
285
+ collapsedPendingCard: Ns,
286
+ moreRow: Ts
287
+ }, Ss = 250, Ds = 320;
288
+ function ie(e, t) {
289
+ const o = e[t];
290
+ return typeof o == "string" ? o : void 0;
291
+ }
292
+ function xs(e, t) {
293
+ const o = e[t];
294
+ return Array.isArray(o) ? o.filter((s) => typeof s == "string") : [];
295
+ }
296
+ function Bs({
297
+ item: e,
298
+ connector: t,
299
+ collapsed: o = !1,
300
+ autoFocus: s = !1,
301
+ sessionTitle: r
302
+ }) {
303
+ return e.kind === "resolved" ? /* @__PURE__ */ n(Ms, { entry: e.entry, connector: t }) : o ? /* @__PURE__ */ n(As, { entry: e.entry, connector: t }) : /* @__PURE__ */ n(
304
+ Ps,
305
+ {
306
+ entry: e.entry,
307
+ connector: t,
308
+ autoFocus: s,
309
+ sessionTitle: r
310
+ }
311
+ );
312
+ }
313
+ function Rt() {
314
+ return /* @__PURE__ */ n("span", { className: w.recoveredChip, children: "still waiting" });
315
+ }
316
+ function As({
317
+ entry: e,
318
+ connector: t
319
+ }) {
320
+ return /* @__PURE__ */ n(
321
+ Q,
322
+ {
323
+ disc: /* @__PURE__ */ n(R, { icon: Te, size: "xs", color: "var(--pi-color-statusWarning)" }),
324
+ discClassName: w.askDisc,
325
+ connector: t,
326
+ children: /* @__PURE__ */ l("div", { className: B(w.resolvedCard, w.collapsedPendingCard), children: [
327
+ /* @__PURE__ */ n("span", { className: w.askBadge, children: "ASK" }),
328
+ /* @__PURE__ */ n("span", { className: w.resolvedMethodName, children: e.method }),
329
+ Et(e) && /* @__PURE__ */ n(Rt, {})
330
+ ] })
331
+ }
332
+ );
333
+ }
334
+ function Es({
335
+ count: e,
336
+ connector: t,
337
+ onExpand: o
338
+ }) {
339
+ return /* @__PURE__ */ n(
340
+ Q,
341
+ {
342
+ disc: /* @__PURE__ */ n(R, { icon: Te, size: "xs", color: "var(--pi-color-foregroundMuted)" }),
343
+ discClassName: w.askDiscInert,
344
+ connector: t,
345
+ children: /* @__PURE__ */ l("button", { type: "button", className: w.moreRow, onClick: o, children: [
346
+ e,
347
+ " more waiting"
348
+ ] })
349
+ }
350
+ );
351
+ }
352
+ function Ms({
353
+ entry: e,
354
+ connector: t
355
+ }) {
356
+ const o = fn(e);
357
+ return /* @__PURE__ */ n(
358
+ Q,
359
+ {
360
+ disc: /* @__PURE__ */ n(R, { icon: Te, size: "xs", color: "var(--pi-color-foregroundMuted)" }),
361
+ discClassName: w.askDiscInert,
362
+ connector: t,
363
+ children: /* @__PURE__ */ l("div", { className: w.resolvedCard, children: [
364
+ /* @__PURE__ */ n("span", { className: B(w.askBadge, w.askBadgeNeutral), children: "ASK" }),
365
+ /* @__PURE__ */ n("span", { className: w.resolvedMethodName, children: e.method }),
366
+ /* @__PURE__ */ l("span", { className: B(w.outcome, o.tone === "success" && w.outcomeSuccess), children: [
367
+ o.glyph === "check" && /* @__PURE__ */ n(be, { size: 11, "aria-hidden": !0 }),
368
+ /* @__PURE__ */ n("span", { className: B(o.truncate && w.outcomeText), children: o.text })
369
+ ] })
370
+ ] })
371
+ }
372
+ );
373
+ }
374
+ function te(e, t) {
375
+ return e.answerable ? e.submitting ? t ? { loading: !0, style: { opacity: 1 } } : { disabled: !0 } : {} : { disabled: !0, style: { opacity: 1 } };
376
+ }
377
+ function Rs({ hint: e }) {
378
+ return e.kind === "warning" ? /* @__PURE__ */ n("p", { className: w.hint, children: e.text }) : /* @__PURE__ */ n("p", { className: w.hint, children: e.segments.map((t, o) => /* @__PURE__ */ l(dn, { children: [
379
+ o > 0 && /* @__PURE__ */ n("span", { className: w.hintSep, children: "·" }),
380
+ /* @__PURE__ */ n("span", { className: w.hintKey, children: t.key }),
381
+ t.label
382
+ ] }, t.label)) });
383
+ }
384
+ function Ps({
385
+ entry: e,
386
+ connector: t,
387
+ autoFocus: o = !1,
388
+ sessionTitle: s
389
+ }) {
390
+ const [r, a] = D(() => Date.now()), c = Io(e, r), [d, g] = D(!1), m = O(null), u = O(null), p = O(null);
391
+ I(() => {
392
+ if (!c.show) return;
393
+ const y = setInterval(() => a(Date.now()), Ss);
394
+ return () => clearInterval(y);
395
+ }, [e.requestId, e.timeoutMs, c.show]), I(() => {
396
+ if (!o || !e.answerable) return;
397
+ const y = document.activeElement;
398
+ (y instanceof HTMLTextAreaElement || y instanceof HTMLInputElement) && y.value.length > 0 && !m.current?.contains(y) || u.current?.focus();
399
+ }, [o, e.answerable]);
400
+ function v(y) {
401
+ e.answerable && (y.target.closest("button, input, textarea, a, select") || m.current?.contains(document.activeElement) || m.current?.focus());
402
+ }
403
+ function A(y) {
404
+ gn(e.requestId, y);
405
+ }
406
+ function L(y) {
407
+ if (y.key !== "Escape" || !e.answerable) return;
408
+ y.preventDefault(), y.stopPropagation();
409
+ const S = zo(d);
410
+ if (g(S.armed), !S.resolve) {
411
+ p.current?.focus();
412
+ return;
413
+ }
414
+ p.current ? p.current.click() : A({ cancelled: !0 });
415
+ }
416
+ function V(y) {
417
+ y.currentTarget.contains(y.relatedTarget) || g(!1);
418
+ }
419
+ return /* @__PURE__ */ l(
420
+ Q,
421
+ {
422
+ disc: /* @__PURE__ */ n(
423
+ R,
424
+ {
425
+ icon: Te,
426
+ size: "xs",
427
+ color: e.answerable ? "var(--pi-color-statusWarning)" : "var(--pi-color-foregroundMuted)"
428
+ }
429
+ ),
430
+ discClassName: e.answerable ? w.askDisc : w.askDiscInert,
431
+ connector: t,
432
+ children: [
433
+ /* @__PURE__ */ l(
434
+ "div",
435
+ {
436
+ ref: m,
437
+ className: B(w.card, !e.answerable && w.cardInert),
438
+ role: "group",
439
+ "aria-label": `Question in ${s}`,
440
+ tabIndex: -1,
441
+ onKeyDown: L,
442
+ onMouseDown: v,
443
+ onBlur: V,
444
+ children: [
445
+ c.show && /* @__PURE__ */ n(
446
+ "div",
447
+ {
448
+ className: B(w.deadlineBar, c.approximate && w.deadlineApproximate),
449
+ style: { width: `${c.fraction * 100}%` }
450
+ }
451
+ ),
452
+ /* @__PURE__ */ l("div", { className: w.header, children: [
453
+ /* @__PURE__ */ n(
454
+ "span",
455
+ {
456
+ className: B(w.askBadge, !e.answerable && w.askBadgeNeutral),
457
+ "aria-hidden": "true",
458
+ children: "ASK"
459
+ }
460
+ ),
461
+ /* @__PURE__ */ n("span", { className: w.methodName, children: e.method }),
462
+ Et(e) && /* @__PURE__ */ n(Rt, {})
463
+ ] }),
464
+ /* @__PURE__ */ n(
465
+ Os,
466
+ {
467
+ entry: e,
468
+ onSubmit: A,
469
+ primaryRef: u,
470
+ dismissRef: p
471
+ }
472
+ )
473
+ ]
474
+ }
475
+ ),
476
+ /* @__PURE__ */ n(Rs, { hint: $o(e.method, d) }),
477
+ !e.answerable && /* @__PURE__ */ l("p", { className: w.reconnectingNote, children: [
478
+ /* @__PURE__ */ n("span", { className: w.reconnectingDot }),
479
+ "Reconnecting — you can answer again in a moment"
480
+ ] })
481
+ ]
482
+ }
483
+ );
484
+ }
485
+ function Os({ entry: e, onSubmit: t, primaryRef: o, dismissRef: s }) {
486
+ const { method: r, payload: a } = e;
487
+ return r === "select" ? /* @__PURE__ */ n(
488
+ Ls,
489
+ {
490
+ entry: e,
491
+ payload: a,
492
+ onSubmit: t,
493
+ primaryRef: o,
494
+ dismissRef: s
495
+ }
496
+ ) : r === "confirm" ? /* @__PURE__ */ n(
497
+ Is,
498
+ {
499
+ entry: e,
500
+ payload: a,
501
+ onSubmit: t,
502
+ primaryRef: o,
503
+ dismissRef: s
504
+ }
505
+ ) : r === "input" ? /* @__PURE__ */ n(Fs, { entry: e, payload: a, onSubmit: t, primaryRef: o }) : r === "editor" ? /* @__PURE__ */ n(
506
+ $s,
507
+ {
508
+ entry: e,
509
+ payload: a,
510
+ onSubmit: t,
511
+ primaryRef: o,
512
+ dismissRef: s
513
+ }
514
+ ) : /* @__PURE__ */ n(
515
+ zs,
516
+ {
517
+ entry: e,
518
+ method: r,
519
+ payload: a,
520
+ onSubmit: t,
521
+ primaryRef: o,
522
+ dismissRef: s
523
+ }
524
+ );
525
+ }
526
+ function Ne({ text: e }) {
527
+ return /* @__PURE__ */ n("div", { className: w.title, children: Le(e).join(`
528
+ `) });
529
+ }
530
+ function Ls({
531
+ entry: e,
532
+ payload: t,
533
+ onSubmit: o,
534
+ primaryRef: s,
535
+ dismissRef: r
536
+ }) {
537
+ const a = ie(t, "title") ?? "", c = xs(t, "options"), [d, g] = D(null);
538
+ if (c.length === 0) {
539
+ const u = te(e, d === 0);
540
+ return /* @__PURE__ */ l($, { children: [
541
+ /* @__PURE__ */ n(Ne, { text: a }),
542
+ /* @__PURE__ */ n("p", { className: w.emptyOptionsNote, children: "The extension offered no options." }),
543
+ /* @__PURE__ */ n("div", { className: w.controls, children: /* @__PURE__ */ n(
544
+ F,
545
+ {
546
+ ref: (p) => {
547
+ s.current = p, r.current = p;
548
+ },
549
+ size: "xs",
550
+ variant: "secondary",
551
+ onClick: () => {
552
+ g(0), o({ cancelled: !0 });
553
+ },
554
+ ...u,
555
+ children: "Cancel"
556
+ }
557
+ ) })
558
+ ] });
559
+ }
560
+ const m = qo(c);
561
+ return /* @__PURE__ */ l($, { children: [
562
+ /* @__PURE__ */ n(Ne, { text: a }),
563
+ /* @__PURE__ */ n(
564
+ "div",
565
+ {
566
+ className: B(
567
+ w.controls,
568
+ m.mode === "stack" && w.controlsStack,
569
+ m.scrolls && w.controlsScroll
570
+ ),
571
+ children: c.map((u, p) => (
572
+ // Duplicate labels are legal and never deduped/ordinal'd (§ 12) — index-only key.
573
+ // No dismissing control exists for a populated select (§ 07's "N/A" case) — only the
574
+ // first option takes the § 07 initial-focus ref.
575
+ /* @__PURE__ */ n(
576
+ F,
577
+ {
578
+ ref: p === 0 ? (v) => {
579
+ s.current = v;
580
+ } : void 0,
581
+ size: "xs",
582
+ variant: "secondary",
583
+ className: w.optionButton,
584
+ onClick: () => {
585
+ g(p), o({ value: u });
586
+ },
587
+ ...te(e, d === p),
588
+ children: u
589
+ },
590
+ p
591
+ )
592
+ ))
593
+ }
594
+ )
595
+ ] });
596
+ }
597
+ function Is({
598
+ entry: e,
599
+ payload: t,
600
+ onSubmit: o,
601
+ primaryRef: s,
602
+ dismissRef: r
603
+ }) {
604
+ const a = ie(t, "title") ?? "", c = ie(t, "message"), d = Uo(a, c), [g, m] = D(null);
605
+ return /* @__PURE__ */ l($, { children: [
606
+ /* @__PURE__ */ n("div", { className: B(w.title, d.message && w.titleEmphasised), children: d.title.join(`
607
+ `) }),
608
+ d.message && /* @__PURE__ */ n("div", { className: w.message, children: d.message.join(`
609
+ `) }),
610
+ /* @__PURE__ */ l("div", { className: w.controls, children: [
611
+ /* @__PURE__ */ n(
612
+ F,
613
+ {
614
+ ref: (u) => {
615
+ s.current = u;
616
+ },
617
+ size: "xs",
618
+ variant: "default",
619
+ onClick: () => {
620
+ m("yes"), o({ confirmed: !0 });
621
+ },
622
+ ...te(e, g === "yes"),
623
+ children: "Yes"
624
+ }
625
+ ),
626
+ /* @__PURE__ */ n(
627
+ F,
628
+ {
629
+ ref: (u) => {
630
+ r.current = u;
631
+ },
632
+ size: "xs",
633
+ variant: "secondary",
634
+ onClick: () => {
635
+ m("no"), o({ confirmed: !1 });
636
+ },
637
+ ...te(e, g === "no"),
638
+ children: "No"
639
+ }
640
+ )
641
+ ] })
642
+ ] });
643
+ }
644
+ function Fs({
645
+ entry: e,
646
+ payload: t,
647
+ onSubmit: o,
648
+ primaryRef: s
649
+ }) {
650
+ const r = ie(t, "title") ?? "", a = ie(t, "placeholder"), [c, d] = D(""), g = te(e, e.submitting === !0), m = g.disabled === !0 || g.loading === !0;
651
+ return /* @__PURE__ */ l($, { children: [
652
+ /* @__PURE__ */ n(Ne, { text: r }),
653
+ /* @__PURE__ */ l("div", { className: w.controls, children: [
654
+ /* @__PURE__ */ n(
655
+ Qn,
656
+ {
657
+ ref: (u) => {
658
+ s.current = u;
659
+ },
660
+ className: w.field,
661
+ value: c,
662
+ placeholder: a,
663
+ disabled: m,
664
+ onChange: (u) => d(u.target.value),
665
+ onKeyDown: (u) => {
666
+ u.key !== "Enter" || m || (u.preventDefault(), u.stopPropagation(), o({ value: c }));
667
+ }
668
+ }
669
+ ),
670
+ /* @__PURE__ */ n(F, { size: "xs", variant: "default", onClick: () => o({ value: c }), ...g, children: "Submit" })
671
+ ] })
672
+ ] });
673
+ }
674
+ function $s({
675
+ entry: e,
676
+ payload: t,
677
+ onSubmit: o,
678
+ primaryRef: s,
679
+ dismissRef: r
680
+ }) {
681
+ const a = ie(t, "title") ?? "", c = ie(t, "prefill") ?? "", [d, g] = D(c), [m, u] = D(null);
682
+ return /* @__PURE__ */ l($, { children: [
683
+ /* @__PURE__ */ n(Ne, { text: a }),
684
+ /* @__PURE__ */ n(
685
+ St,
686
+ {
687
+ ref: (p) => {
688
+ s.current = p;
689
+ },
690
+ className: w.editorField,
691
+ rows: 3,
692
+ value: d,
693
+ disabled: !e.answerable || e.submitting,
694
+ onChange: (p) => {
695
+ g(p.target.value);
696
+ const v = p.target;
697
+ v.style.height = "auto", v.style.height = `${Math.min(v.scrollHeight, Ds)}px`;
698
+ },
699
+ onKeyDown: (p) => {
700
+ p.key !== "Enter" || p.shiftKey !== Mt(e.method) || (p.preventDefault(), p.stopPropagation(), u("submit"), o({ value: d }));
701
+ }
702
+ }
703
+ ),
704
+ /* @__PURE__ */ l("div", { className: w.controls, children: [
705
+ /* @__PURE__ */ n(
706
+ F,
707
+ {
708
+ size: "xs",
709
+ variant: "default",
710
+ onClick: () => {
711
+ u("submit"), o({ value: d });
712
+ },
713
+ ...te(e, m === "submit"),
714
+ children: "Submit"
715
+ }
716
+ ),
717
+ /* @__PURE__ */ n(
718
+ F,
719
+ {
720
+ ref: (p) => {
721
+ r.current = p;
722
+ },
723
+ size: "xs",
724
+ variant: "secondary",
725
+ onClick: () => {
726
+ u("cancel"), o({ cancelled: !0 });
727
+ },
728
+ ...te(e, m === "cancel"),
729
+ children: "Cancel"
730
+ }
731
+ )
732
+ ] })
733
+ ] });
734
+ }
735
+ function zs({
736
+ entry: e,
737
+ method: t,
738
+ payload: o,
739
+ onSubmit: s,
740
+ primaryRef: r,
741
+ dismissRef: a
742
+ }) {
743
+ const c = { method: t, ...o }, d = te(e, e.submitting === !0);
744
+ return /* @__PURE__ */ l($, { children: [
745
+ /* @__PURE__ */ n("p", { className: w.title, children: "This extension asked something this version of Pi-Studio can't display." }),
746
+ /* @__PURE__ */ n("pre", { className: w.rawPayload, children: JSON.stringify(c, null, 2) }),
747
+ /* @__PURE__ */ n("div", { className: w.controls, children: /* @__PURE__ */ n(
748
+ F,
749
+ {
750
+ ref: (g) => {
751
+ r.current = g, a.current = g;
752
+ },
753
+ size: "xs",
754
+ variant: "secondary",
755
+ onClick: () => s({ cancelled: !0 }),
756
+ ...d,
757
+ children: "Cancel"
758
+ }
759
+ ) })
760
+ ] });
761
+ }
762
+ function ft(e) {
763
+ if (e === void 0) return null;
764
+ const t = typeof e == "number" ? e : Date.parse(e);
765
+ return Number.isNaN(t) ? null : t;
766
+ }
767
+ function Hs(e, t, o, s) {
768
+ if (t.length === 0) return e.map(o);
769
+ const r = [];
770
+ let a = 0;
771
+ const c = (d) => {
772
+ for (; a < e.length; ) {
773
+ const g = e[a];
774
+ if (g === void 0) break;
775
+ if (d !== null) {
776
+ const m = ft(g.timestamp);
777
+ if (m !== null && m > d) break;
778
+ }
779
+ r.push(o(g)), a++;
780
+ }
781
+ };
782
+ for (const d of t) {
783
+ if (d.kind === "more") {
784
+ r.push(s(d));
785
+ continue;
786
+ }
787
+ c(ft(d.item.entry.createdAt)), r.push(s(d));
788
+ }
789
+ for (; a < e.length; a++) {
790
+ const d = e[a];
791
+ d !== void 0 && r.push(o(d));
792
+ }
793
+ return r;
794
+ }
795
+ function Ks(e, t) {
796
+ return !e || t === void 0 ? !1 : t.every((o) => o.configured === !1);
797
+ }
798
+ const Ws = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
799
+ function gt(e) {
800
+ return String(e).padStart(2, "0");
801
+ }
802
+ function Ke(e) {
803
+ if (!e) return;
804
+ const t = new Date(e);
805
+ if (!Number.isNaN(t.getTime()))
806
+ return `${Ws[t.getMonth()]} ${t.getDate()}, ${gt(t.getHours())}:${gt(t.getMinutes())}`;
807
+ }
808
+ const qs = "piwb-rows_queuedBadge_8c1hh", Us = "piwb-rows_finalChip_rGg2-", Gs = "piwb-rows_userDisc_1YmfY", Ys = "piwb-rows_userAligned_ZlVNc", Vs = "piwb-rows_userPendingRow_JDcqT", js = "piwb-rows_userBubble_equYK", Qs = "piwb-rows_userBubbleFailed_VKO9m", Xs = "piwb-rows_userImages_JYtXF", Js = "piwb-rows_userImage_O83YH", Zs = "piwb-rows_imageDialog_-_EnS", er = "piwb-rows_imageDialogPreview_ivNiE", tr = "piwb-rows_assistantDisc_zoOg5", nr = "piwb-rows_assistantBody_oWH9U", or = "piwb-rows_reasoningDisc__OEuC", sr = "piwb-rows_reasoningBody_iktm-", rr = "piwb-rows_toolDisc_X1ppg", ir = "piwb-rows_toolCardBody_1eS8x", ar = "piwb-rows_toolCardBodyRunning_a-pN9", cr = "piwb-rows_toolCardBodyCompleted_O66jm", lr = "piwb-rows_toolCardBodyCanceled_eZNCM", dr = "piwb-rows_toolCardBodyError_A0Tal", ur = "piwb-rows_toolHeader_t0w6J", mr = "piwb-rows_toolHeaderRunning_8PU2A", pr = "piwb-rows_toolChevron_5vnEH", hr = "piwb-rows_toolChevronOpen_0iyno", fr = "piwb-rows_kindBadge_EniBd", gr = "piwb-rows_toolPath_EHLQw", wr = "piwb-rows_toolTrailing_9lP8h", br = "piwb-rows_toolStatusRunning_LgitY", _r = "piwb-rows_toolStatusSuccess_s1Pho", vr = "piwb-rows_toolStatusError_s5rLp", kr = "piwb-rows_toolStatusUnknown_eXmyk", Cr = "piwb-rows_toolDiffAdded_zpolQ", yr = "piwb-rows_toolDiffRemoved_AfWYP", Nr = "piwb-rows_toolOpenButton_aIUQC", Tr = "piwb-rows_toolLiveTail_blcwg", Sr = "piwb-rows_toolBody_xLlpO", Dr = "piwb-rows_toolCode_18XfN", xr = "piwb-rows_toolOutputStrip_AadJa", Br = "piwb-rows_toolDiffPreview_07Tvx", Ar = "piwb-rows_toolDiffPreviewLine_yQi_O", Er = "piwb-rows_toolDiffPreviewAdd_RAi8r", Mr = "piwb-rows_toolDiffPreviewDel_BiW24", Rr = "piwb-rows_toolDiffPreviewMore_bwAgw", Pr = "piwb-rows_errorDisc_YWjME", Or = "piwb-rows_errorCard_r3Iv8", Lr = "piwb-rows_errorLead_yScWg", Ir = "piwb-rows_systemRow_8si32", Fr = "piwb-rows_compactionRow_Byy3C", $r = "piwb-rows_compactionRowFailed_3Tdu3", zr = "piwb-rows_compactionDivider_a4FlH", Hr = "piwb-rows_compactionRule_v2vyl", Kr = "piwb-rows_compactionLabel_YVoq-", Wr = "piwb-rows_compactionText_gq3v6", qr = "piwb-rows_compactionToggle_87Vkf", Ur = "piwb-rows_compactionSummary_ydxYI", h = {
809
+ queuedBadge: qs,
810
+ finalChip: Us,
811
+ userDisc: Gs,
812
+ userAligned: Ys,
813
+ userPendingRow: Vs,
814
+ userBubble: js,
815
+ userBubbleFailed: Qs,
816
+ userImages: Xs,
817
+ userImage: Js,
818
+ imageDialog: Zs,
819
+ imageDialogPreview: er,
820
+ assistantDisc: tr,
821
+ assistantBody: nr,
822
+ reasoningDisc: or,
823
+ reasoningBody: sr,
824
+ toolDisc: rr,
825
+ toolCardBody: ir,
826
+ toolCardBodyRunning: ar,
827
+ toolCardBodyCompleted: cr,
828
+ toolCardBodyCanceled: lr,
829
+ toolCardBodyError: dr,
830
+ toolHeader: ur,
831
+ toolHeaderRunning: mr,
832
+ toolChevron: pr,
833
+ toolChevronOpen: hr,
834
+ kindBadge: fr,
835
+ toolPath: gr,
836
+ toolTrailing: wr,
837
+ toolStatusRunning: br,
838
+ toolStatusSuccess: _r,
839
+ toolStatusError: vr,
840
+ toolStatusUnknown: kr,
841
+ toolDiffAdded: Cr,
842
+ toolDiffRemoved: yr,
843
+ toolOpenButton: Nr,
844
+ toolLiveTail: Tr,
845
+ toolBody: Sr,
846
+ toolCode: Dr,
847
+ toolOutputStrip: xr,
848
+ toolDiffPreview: Br,
849
+ toolDiffPreviewLine: Ar,
850
+ toolDiffPreviewAdd: Er,
851
+ toolDiffPreviewDel: Mr,
852
+ toolDiffPreviewMore: Rr,
853
+ errorDisc: Pr,
854
+ errorCard: Or,
855
+ errorLead: Lr,
856
+ systemRow: Ir,
857
+ compactionRow: Fr,
858
+ compactionRowFailed: $r,
859
+ compactionDivider: zr,
860
+ compactionRule: Hr,
861
+ compactionLabel: Kr,
862
+ compactionText: Wr,
863
+ compactionToggle: qr,
864
+ compactionSummary: Ur
865
+ };
866
+ function Gr({
867
+ row: e,
868
+ assetBase: t = null,
869
+ owningPaneId: o = null,
870
+ workspaceCwd: s = null,
871
+ connector: r
872
+ }) {
873
+ const a = Ke(e.timestamp);
874
+ return /* @__PURE__ */ n(
875
+ Q,
876
+ {
877
+ disc: /* @__PURE__ */ n(R, { icon: In, size: "xs", color: "var(--pi-color-accentForeground)" }),
878
+ discClassName: h.assistantDisc,
879
+ connector: r,
880
+ meta: /* @__PURE__ */ l($, { children: [
881
+ "Assistant",
882
+ a && /* @__PURE__ */ l("span", { className: Y.metaTime, children: [
883
+ " · ",
884
+ a
885
+ ] })
886
+ ] }),
887
+ children: /* @__PURE__ */ n("div", { className: h.assistantBody, children: e.streaming ? /* @__PURE__ */ n(
888
+ xt,
889
+ {
890
+ text: e.text,
891
+ assetBase: t,
892
+ owningPaneId: o,
893
+ workspaceCwd: s
894
+ }
895
+ ) : /* @__PURE__ */ n(
896
+ He,
897
+ {
898
+ text: e.text,
899
+ assetBase: t,
900
+ owningPaneId: o,
901
+ workspaceCwd: s
902
+ }
903
+ ) })
904
+ }
905
+ );
906
+ }
907
+ function Yr({
908
+ row: e,
909
+ owningPaneId: t = null,
910
+ workspaceCwd: o = null,
911
+ connector: s
912
+ }) {
913
+ const r = Ke(e.timestamp);
914
+ return /* @__PURE__ */ n(
915
+ Q,
916
+ {
917
+ disc: /* @__PURE__ */ n(R, { icon: Nt, size: "xs", color: "var(--pi-color-foregroundMuted)" }),
918
+ discClassName: h.reasoningDisc,
919
+ connector: s,
920
+ meta: /* @__PURE__ */ l($, { children: [
921
+ "Reasoning",
922
+ r && /* @__PURE__ */ l("span", { className: Y.metaTime, children: [
923
+ " · ",
924
+ r
925
+ ] })
926
+ ] }),
927
+ metaTrailing: !e.streaming && /* @__PURE__ */ n("span", { className: h.finalChip, children: "final" }),
928
+ children: /* @__PURE__ */ n("div", { className: h.reasoningBody, children: e.streaming ? /* @__PURE__ */ n(
929
+ xt,
930
+ {
931
+ text: e.text,
932
+ owningPaneId: t,
933
+ workspaceCwd: o
934
+ }
935
+ ) : /* @__PURE__ */ n(He, { text: e.text, owningPaneId: t, workspaceCwd: o }) })
936
+ }
937
+ );
938
+ }
939
+ const Vr = 12;
940
+ function jr(e, t = Vr) {
941
+ const o = e.replace(/\r?\n$/, "").split(/\r?\n/);
942
+ return o.length <= t ? o.join(`
943
+ `) : o.slice(-t).join(`
944
+ `);
945
+ }
946
+ function Qr(e) {
947
+ const t = co(e).filter(
948
+ (s) => s.kind === "add" || s.kind === "del"
949
+ ), o = t[0];
950
+ return o ? { text: o.text, kind: o.kind, moreCount: t.length - 1 } : null;
951
+ }
952
+ function Xr(e) {
953
+ return e.status === "completed" ? /* @__PURE__ */ n("span", { className: h.toolStatusSuccess, children: "✓ completed" }) : e.status === "error" ? /* @__PURE__ */ n("span", { className: h.toolStatusError, children: e.statusText || "error" }) : e.status === "canceled" ? /* @__PURE__ */ n("span", { className: h.toolStatusUnknown, children: e.statusText || "canceled" }) : e.statusText && e.statusText !== "running" ? /* @__PURE__ */ n("span", { className: h.toolStatusUnknown, children: e.statusText }) : /* @__PURE__ */ l("span", { className: h.toolStatusRunning, children: [
954
+ /* @__PURE__ */ n(re, { size: "xs", color: "var(--pi-color-accentBright)" }),
955
+ "running"
956
+ ] });
957
+ }
958
+ function Jr({
959
+ row: e,
960
+ assetBase: t = null,
961
+ owningPaneId: o = null,
962
+ workspaceCwd: s = null,
963
+ connector: r
964
+ }) {
965
+ const [a, c] = D(!1), d = fo(e.tool), g = ho(e.tool), m = g.length > 0, u = wo(e.tool.output), p = e.tool.kind === "edit" || e.tool.kind === "write" ? Bt(e.tool) : null, v = e.tool.kind === "edit" ? go(e.tool.diff) : null, A = e.tool.kind === "edit" && e.tool.diff && !a ? Qr(e.tool.diff) : null;
966
+ function L() {
967
+ m && c((S) => !S);
968
+ }
969
+ function V(S) {
970
+ S.target === S.currentTarget && (S.key === "Enter" || S.key === " ") && (S.preventDefault(), L());
971
+ }
972
+ function y(S) {
973
+ if (S.stopPropagation(), !p) return;
974
+ const U = io(t, o, s);
975
+ wn(p, U.workspaceCwd, U.targetPaneId);
976
+ }
977
+ return /* @__PURE__ */ n(
978
+ Q,
979
+ {
980
+ disc: /* @__PURE__ */ n(R, { icon: mo(e.tool), size: "xs", color: "var(--pi-color-foregroundMuted)" }),
981
+ discClassName: h.toolDisc,
982
+ connector: r,
983
+ children: /* @__PURE__ */ l(
984
+ "div",
985
+ {
986
+ className: B(
987
+ h.toolCardBody,
988
+ e.status === "running" && h.toolCardBodyRunning,
989
+ e.status === "completed" && h.toolCardBodyCompleted,
990
+ e.status === "error" && h.toolCardBodyError,
991
+ e.status === "canceled" && h.toolCardBodyCanceled
992
+ ),
993
+ children: [
994
+ /* @__PURE__ */ l(
995
+ "div",
996
+ {
997
+ role: "button",
998
+ tabIndex: m ? 0 : -1,
999
+ "aria-expanded": m ? a : void 0,
1000
+ "aria-disabled": !m,
1001
+ className: B(h.toolHeader, e.status === "running" && h.toolHeaderRunning),
1002
+ onClick: L,
1003
+ onKeyDown: V,
1004
+ children: [
1005
+ m && /* @__PURE__ */ n(
1006
+ _e,
1007
+ {
1008
+ size: 12,
1009
+ className: B(h.toolChevron, a && h.toolChevronOpen)
1010
+ }
1011
+ ),
1012
+ /* @__PURE__ */ n(
1013
+ "span",
1014
+ {
1015
+ className: h.kindBadge,
1016
+ style: { "--kindToken": `var(--pi-color-${d.token})` },
1017
+ children: d.label
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ n("span", { className: h.toolPath, title: Oe(e.tool), children: Oe(e.tool) }),
1021
+ /* @__PURE__ */ l("span", { className: h.toolTrailing, children: [
1022
+ v && (v.added > 0 || v.removed > 0) && /* @__PURE__ */ l($, { children: [
1023
+ /* @__PURE__ */ l("span", { className: h.toolDiffAdded, children: [
1024
+ "+",
1025
+ v.added
1026
+ ] }),
1027
+ /* @__PURE__ */ l("span", { className: h.toolDiffRemoved, children: [
1028
+ "−",
1029
+ v.removed
1030
+ ] })
1031
+ ] }),
1032
+ Xr(e),
1033
+ p && /* @__PURE__ */ l(
1034
+ "button",
1035
+ {
1036
+ type: "button",
1037
+ className: h.toolOpenButton,
1038
+ onClick: y,
1039
+ onKeyDown: (S) => S.stopPropagation(),
1040
+ children: [
1041
+ "Open",
1042
+ /* @__PURE__ */ n(Fn, { size: 10 })
1043
+ ]
1044
+ }
1045
+ )
1046
+ ] })
1047
+ ]
1048
+ }
1049
+ ),
1050
+ e.status === "running" && e.tool.output && /* @__PURE__ */ n("pre", { className: B(h.toolCode, h.toolLiveTail), children: jr(e.tool.output) }),
1051
+ u > 0 && /* @__PURE__ */ l("div", { className: h.toolOutputStrip, children: [
1052
+ "output · ",
1053
+ u,
1054
+ " lines"
1055
+ ] }),
1056
+ A && /* @__PURE__ */ l("div", { className: h.toolDiffPreview, children: [
1057
+ /* @__PURE__ */ n(
1058
+ "div",
1059
+ {
1060
+ className: B(
1061
+ h.toolDiffPreviewLine,
1062
+ A.kind === "add" ? h.toolDiffPreviewAdd : h.toolDiffPreviewDel
1063
+ ),
1064
+ children: A.text
1065
+ }
1066
+ ),
1067
+ A.moreCount > 0 && /* @__PURE__ */ l("div", { className: h.toolDiffPreviewMore, children: [
1068
+ "… ",
1069
+ A.moreCount,
1070
+ " more lines"
1071
+ ] })
1072
+ ] }),
1073
+ a && m && /* @__PURE__ */ n("div", { className: h.toolBody, children: g.map(
1074
+ (S, U) => S.kind === "diff" ? /* @__PURE__ */ n(ao, { patch: S.patch }, U) : /* @__PURE__ */ n("pre", { className: h.toolCode, children: S.text }, U)
1075
+ ) })
1076
+ ]
1077
+ }
1078
+ )
1079
+ }
1080
+ );
1081
+ }
1082
+ const Zr = "Fork from here", ei = "Fork conversation from this message";
1083
+ function ti({ row: e, connector: t, onFork: o }) {
1084
+ const [s, r] = D(null), a = Ke(e.timestamp);
1085
+ return /* @__PURE__ */ l(
1086
+ Q,
1087
+ {
1088
+ disc: /* @__PURE__ */ n(R, { icon: Hn, size: "xs", color: "var(--pi-color-successForeground)" }),
1089
+ discClassName: h.userDisc,
1090
+ connector: t,
1091
+ className: B(h.userAligned, e.pending && h.userPendingRow),
1092
+ meta: /* @__PURE__ */ l($, { children: [
1093
+ "You",
1094
+ a && /* @__PURE__ */ l("span", { className: Y.metaTime, children: [
1095
+ " · ",
1096
+ a
1097
+ ] }),
1098
+ e.failed && " · failed to send"
1099
+ ] }),
1100
+ metaTrailing: /* @__PURE__ */ l($, { children: [
1101
+ e.queued && !e.failed && /* @__PURE__ */ l("span", { className: h.queuedBadge, children: [
1102
+ /* @__PURE__ */ n($n, { size: 9 }),
1103
+ "queued"
1104
+ ] }),
1105
+ o && /* @__PURE__ */ n(
1106
+ Jn,
1107
+ {
1108
+ className: Y.forkButton,
1109
+ hoverBase: "var(--pi-color-surface3)",
1110
+ title: Zr,
1111
+ "aria-label": ei,
1112
+ onClick: o,
1113
+ children: /* @__PURE__ */ n(zn, { size: 13, strokeWidth: 1.8, "aria-hidden": "true" })
1114
+ }
1115
+ )
1116
+ ] }),
1117
+ children: [
1118
+ /* @__PURE__ */ n("span", { className: B(h.userBubble, e.failed && h.userBubbleFailed), children: e.text }),
1119
+ e.images && e.images.length > 0 && /* @__PURE__ */ n("div", { className: h.userImages, children: e.images.map((c, d) => {
1120
+ const g = `data:${c.mimeType ?? "image/png"};base64,${c.data ?? ""}`;
1121
+ return /* @__PURE__ */ n(
1122
+ "img",
1123
+ {
1124
+ className: h.userImage,
1125
+ src: g,
1126
+ alt: "",
1127
+ role: "button",
1128
+ tabIndex: 0,
1129
+ onClick: () => r(g),
1130
+ onKeyDown: (m) => {
1131
+ (m.key === "Enter" || m.key === " ") && r(g);
1132
+ }
1133
+ },
1134
+ d
1135
+ );
1136
+ }) }),
1137
+ /* @__PURE__ */ n(
1138
+ Xn,
1139
+ {
1140
+ open: s !== null,
1141
+ onOpenChange: (c) => {
1142
+ c || r(null);
1143
+ },
1144
+ title: "Image",
1145
+ width: "auto",
1146
+ bare: !0,
1147
+ className: h.imageDialog,
1148
+ children: s && /* @__PURE__ */ n("img", { className: h.imageDialogPreview, src: s, alt: "" })
1149
+ }
1150
+ )
1151
+ ]
1152
+ }
1153
+ );
1154
+ }
1155
+ function ni({ row: e, connector: t }) {
1156
+ return /* @__PURE__ */ n(
1157
+ Q,
1158
+ {
1159
+ disc: /* @__PURE__ */ n(R, { icon: Tt, size: "xs", color: "var(--pi-color-destructive)" }),
1160
+ discClassName: h.errorDisc,
1161
+ connector: t,
1162
+ children: /* @__PURE__ */ l("div", { className: h.errorCard, children: [
1163
+ /* @__PURE__ */ n("span", { className: h.errorLead, children: "Error" }),
1164
+ " · ",
1165
+ e.text
1166
+ ] })
1167
+ }
1168
+ );
1169
+ }
1170
+ function oi({ row: e }) {
1171
+ return /* @__PURE__ */ n("div", { className: h.systemRow, children: e.text });
1172
+ }
1173
+ function si({
1174
+ row: e,
1175
+ assetBase: t = null,
1176
+ owningPaneId: o = null,
1177
+ workspaceCwd: s = null
1178
+ }) {
1179
+ const [r, a] = D(!1), c = _t(e), d = e.phase === "completed" && !!e.summary, g = /* @__PURE__ */ n("span", { className: h.compactionText, children: c });
1180
+ return /* @__PURE__ */ l(
1181
+ "div",
1182
+ {
1183
+ className: B(h.compactionRow, e.phase === "failed" && h.compactionRowFailed),
1184
+ children: [
1185
+ /* @__PURE__ */ l("div", { className: h.compactionDivider, children: [
1186
+ /* @__PURE__ */ n("span", { className: h.compactionRule, "aria-hidden": "true" }),
1187
+ /* @__PURE__ */ l("span", { className: h.compactionLabel, children: [
1188
+ e.phase === "started" && /* @__PURE__ */ n(re, { size: "xs", "aria-label": "Compacting context" }),
1189
+ e.phase === "failed" && /* @__PURE__ */ n(R, { icon: Tt, size: "xs", color: "var(--pi-color-statusDanger)" }),
1190
+ d ? /* @__PURE__ */ l(
1191
+ "button",
1192
+ {
1193
+ type: "button",
1194
+ className: h.compactionToggle,
1195
+ "aria-expanded": r,
1196
+ onClick: () => a((m) => !m),
1197
+ children: [
1198
+ /* @__PURE__ */ n(
1199
+ _e,
1200
+ {
1201
+ size: 12,
1202
+ className: B(h.toolChevron, r && h.toolChevronOpen)
1203
+ }
1204
+ ),
1205
+ g
1206
+ ]
1207
+ }
1208
+ ) : g
1209
+ ] }),
1210
+ /* @__PURE__ */ n("span", { className: h.compactionRule, "aria-hidden": "true" })
1211
+ ] }),
1212
+ d && r && /* @__PURE__ */ n("div", { className: h.compactionSummary, children: /* @__PURE__ */ n(
1213
+ He,
1214
+ {
1215
+ text: e.summary,
1216
+ assetBase: t,
1217
+ owningPaneId: o,
1218
+ workspaceCwd: s
1219
+ }
1220
+ ) })
1221
+ ]
1222
+ }
1223
+ );
1224
+ }
1225
+ const ri = 500;
1226
+ function ii(e, t) {
1227
+ const o = O(!0), [s, r] = D(!0), a = O(0), c = Ae(
1228
+ (m) => {
1229
+ const u = t.current, p = u ? { scrollTop: u.scrollTop, scrollHeight: u.scrollHeight, clientHeight: u.clientHeight } : { scrollTop: 0, scrollHeight: 0, clientHeight: 0 }, v = Co(o.current, m, p);
1230
+ v.pinned !== o.current && (o.current = v.pinned, r(v.pinned)), v.stick && e.options.count > 0 && e.scrollToEnd({ behavior: "auto" });
1231
+ },
1232
+ [t, e]
1233
+ );
1234
+ I(() => {
1235
+ const m = t.current;
1236
+ if (!m) return;
1237
+ const u = () => {
1238
+ a.current = performance.now();
1239
+ }, p = () => {
1240
+ c({
1241
+ kind: "scroll",
1242
+ gesture: performance.now() - a.current < ri
1243
+ });
1244
+ };
1245
+ m.addEventListener("scroll", p, { passive: !0 }), m.addEventListener("wheel", u, { passive: !0 }), m.addEventListener("touchmove", u, { passive: !0 }), m.addEventListener("pointerdown", u, { passive: !0 }), m.addEventListener("keydown", u, { passive: !0 });
1246
+ const v = new ResizeObserver(() => {
1247
+ m.clientHeight > 0 && c({ kind: "shown" });
1248
+ });
1249
+ return v.observe(m), () => {
1250
+ v.disconnect(), m.removeEventListener("scroll", p), m.removeEventListener("wheel", u), m.removeEventListener("touchmove", u), m.removeEventListener("pointerdown", u), m.removeEventListener("keydown", u);
1251
+ };
1252
+ }, [c, t]);
1253
+ const d = Ae(() => c({ kind: "tail" }), [c]), g = Ae(() => c({ kind: "pin" }), [c]);
1254
+ return { pinned: s, followTail: d, pinToBottom: g };
1255
+ }
1256
+ const ai = "piwb-Timeline_root_AjLfO", ci = "piwb-Timeline_viewport_FUU3A", li = "piwb-Timeline_inner_Q3P1o", di = "piwb-Timeline_rowWrap_IMwxO", ui = "piwb-Timeline_empty_jH3Pg", mi = "piwb-Timeline_nudge_Ct6rc", pi = "piwb-Timeline_jumpToLatest_W74NW", se = {
1257
+ root: ai,
1258
+ viewport: ci,
1259
+ inner: li,
1260
+ rowWrap: di,
1261
+ empty: ui,
1262
+ nudge: mi,
1263
+ jumpToLatest: pi
1264
+ }, hi = 160;
1265
+ function fi(e) {
1266
+ return e.kind === "ask" ? `ask:${Po(e.item)}` : e.kind === "ask-more" ? "ask-more" : e.row.id;
1267
+ }
1268
+ function gi(e, t, o, s, r, a) {
1269
+ switch (e.kind) {
1270
+ case "user": {
1271
+ const c = a.ordinalByRowId.get(e.id);
1272
+ return /* @__PURE__ */ n(ti, { row: e, connector: !t, onFork: c !== void 0 ? () => a.onForkFromRow(c) : null });
1273
+ }
1274
+ case "assistant":
1275
+ return /* @__PURE__ */ n(
1276
+ Gr,
1277
+ {
1278
+ row: e,
1279
+ assetBase: o,
1280
+ owningPaneId: s,
1281
+ workspaceCwd: r,
1282
+ connector: !t
1283
+ }
1284
+ );
1285
+ case "reasoning":
1286
+ return /* @__PURE__ */ n(
1287
+ Yr,
1288
+ {
1289
+ row: e,
1290
+ owningPaneId: s,
1291
+ workspaceCwd: r,
1292
+ connector: !t
1293
+ }
1294
+ );
1295
+ case "tool":
1296
+ return /* @__PURE__ */ n(
1297
+ Jr,
1298
+ {
1299
+ row: e,
1300
+ assetBase: o,
1301
+ owningPaneId: s,
1302
+ workspaceCwd: r,
1303
+ connector: !t
1304
+ }
1305
+ );
1306
+ case "error":
1307
+ return /* @__PURE__ */ n(ni, { row: e, connector: !t });
1308
+ case "system":
1309
+ return /* @__PURE__ */ n(oi, { row: e });
1310
+ case "compaction":
1311
+ return /* @__PURE__ */ n(
1312
+ si,
1313
+ {
1314
+ row: e,
1315
+ assetBase: o,
1316
+ owningPaneId: s,
1317
+ workspaceCwd: r
1318
+ }
1319
+ );
1320
+ }
1321
+ }
1322
+ function wi(e, t, o, s, r, a, c, d, g) {
1323
+ return e.kind === "ask" ? /* @__PURE__ */ n(
1324
+ Bs,
1325
+ {
1326
+ item: e.item,
1327
+ collapsed: e.collapsed,
1328
+ connector: !t,
1329
+ autoFocus: e.item.kind === "pending" && e.item.entry.requestId === c,
1330
+ sessionTitle: d
1331
+ }
1332
+ ) : e.kind === "ask-more" ? /* @__PURE__ */ n(Es, { count: e.count, connector: !t, onExpand: a }) : gi(e.row, t, o, s, r, g);
1333
+ }
1334
+ function bi({ session: e, owningPaneId: t, workspaceCwd: o }) {
1335
+ const s = e.timeline.rows, r = e.status === "running", a = vt(), c = kt(e.cwd, a), d = O(null), g = bn(e), m = _n(e.agentId ?? ""), u = vn(e.agentId ?? ""), [p, v] = D(!1), A = K((b) => b.activeSessionId === e.id), L = Ct(
1336
+ (b) => b.layouts[o]?.focusedPaneId === t
1337
+ ), V = A && L ? m[0]?.requestId ?? null : null, y = un(() => {
1338
+ const b = Lo(Ro(m, u), p);
1339
+ return Hs(
1340
+ s,
1341
+ b,
1342
+ (N) => ({ kind: "row", row: N }),
1343
+ (N) => N.kind === "more" ? { kind: "ask-more", count: N.count } : { kind: "ask", item: N.item, collapsed: N.collapsed }
1344
+ );
1345
+ }, [s, m, u, p]), S = ee((b) => b.status === "open"), M = !!ee((b) => b.serverInfo)?.features?.providerAuth, W = kn((b) => b.openSettings), { data: j } = so(
1346
+ s.length === 0 && S && M
1347
+ ), X = Ks(
1348
+ M,
1349
+ j
1350
+ ), z = no({
1351
+ count: y.length,
1352
+ getScrollElement: () => d.current,
1353
+ estimateSize: () => hi,
1354
+ overscan: 8,
1355
+ getItemKey: (b) => {
1356
+ const N = y[b];
1357
+ return N ? fi(N) : b;
1358
+ },
1359
+ // `TabPanelHost` keeps inactive chat tabs mounted under `display:none` rather than
1360
+ // unmounting them (so switching tabs preserves scroll position — see its own doc comment).
1361
+ // But a `display:none` ancestor collapses every row to a 0×0 border box, and the default
1362
+ // `measureElement` would cache that bogus 0 height — shrinking `.inner`'s total height to
1363
+ // ~0 and permanently clamping the scroll container's `scrollTop` to 0 in the process, which
1364
+ // survives the tab becoming visible again (the browser never un-clamps a scroll offset just
1365
+ // because content grows back). Skip the measurement while hidden and keep whatever size is
1366
+ // already cached (or the `estimateSize` default on first mount) instead.
1367
+ measureElement: (b, N, H) => {
1368
+ if (b.offsetParent !== null)
1369
+ return oo(b, N, H);
1370
+ const ue = H.indexFromElement(b), me = H.options.getItemKey(ue);
1371
+ return H.itemSizeCache.get(me) ?? H.options.estimateSize(ue);
1372
+ },
1373
+ // Keeps the view pinned to the bottom through every change that is NOT a new row: streamed
1374
+ // text appended into the assistant row that already exists, a tool card's growing output
1375
+ // tail, a late image/mermaid/highlight resolve, and — the one that made restored
1376
+ // conversations open mid-history — an estimated height being replaced by its real measured
1377
+ // one. All of those must be compensated inside `resizeItem`, before paint; an effect only
1378
+ // ever sees them after the fact, which is why this cannot be app code.
1379
+ anchorTo: "end",
1380
+ // Same number the controller detaches/re-attaches on, so "at the end" means one thing here.
1381
+ scrollEndThreshold: At
1382
+ }), { pinned: de, followTail: ne, pinToBottom: oe } = ii(z, d), P = yo(s);
1383
+ return I(() => {
1384
+ ne();
1385
+ }, [y.length, ne]), I(() => {
1386
+ P !== null && oe();
1387
+ }, [P, oe]), /* @__PURE__ */ l("div", { className: se.root, children: [
1388
+ /* @__PURE__ */ n("div", { className: se.viewport, ref: d, children: y.length === 0 ? !r && (X ? /* @__PURE__ */ l(Zn, { className: se.nudge, children: [
1389
+ /* @__PURE__ */ n("span", { children: "No messages yet — connect a model provider to get started." }),
1390
+ /* @__PURE__ */ n(F, { size: "xs", variant: "secondary", onClick: () => W(), children: "Connect a model provider" })
1391
+ ] }) : /* @__PURE__ */ n("div", { className: se.empty, children: "No messages yet — say something to start." })) : /* @__PURE__ */ n("div", { className: se.inner, style: { height: z.getTotalSize() }, children: z.getVirtualItems().map((b) => {
1392
+ const N = y[b.index];
1393
+ return N ? /* @__PURE__ */ n(
1394
+ "div",
1395
+ {
1396
+ ref: z.measureElement,
1397
+ "data-index": b.index,
1398
+ className: se.rowWrap,
1399
+ style: { transform: `translateY(${b.start}px)` },
1400
+ children: wi(
1401
+ N,
1402
+ b.index === y.length - 1,
1403
+ c,
1404
+ t,
1405
+ o,
1406
+ () => v(!0),
1407
+ V,
1408
+ e.title,
1409
+ g
1410
+ )
1411
+ },
1412
+ b.key
1413
+ ) : null;
1414
+ }) }) }),
1415
+ !de && y.length > 0 && /* @__PURE__ */ n(
1416
+ "button",
1417
+ {
1418
+ type: "button",
1419
+ className: se.jumpToLatest,
1420
+ onClick: oe,
1421
+ title: "Jump to latest",
1422
+ "aria-label": "Jump to latest",
1423
+ children: /* @__PURE__ */ n(Kn, { size: 16, "aria-hidden": "true" })
1424
+ }
1425
+ )
1426
+ ] });
1427
+ }
1428
+ function _i(e, t = !0) {
1429
+ const o = ee((s) => s.client);
1430
+ return Fe({
1431
+ queryKey: $e.agentCommands(e),
1432
+ queryFn: async () => {
1433
+ if (!o) throw new Error("not connected");
1434
+ const s = await ye(o, e), { commands: r } = await o.agent(s).listCommands();
1435
+ return r;
1436
+ },
1437
+ enabled: !!o && !!e && t
1438
+ });
1439
+ }
1440
+ function Pt(e, t, o = !0) {
1441
+ const s = ee((r) => r.client);
1442
+ return Fe({
1443
+ queryKey: $e.providerModels(e, t),
1444
+ queryFn: async () => {
1445
+ if (!s) throw new Error("not connected");
1446
+ return (await s.providers.listModels(e, t ? { agentId: t } : void 0)).models;
1447
+ },
1448
+ enabled: !!s && !!e && o
1449
+ });
1450
+ }
1451
+ function vi(e, t, o = !0) {
1452
+ const s = ee((r) => r.client);
1453
+ return Fe({
1454
+ queryKey: $e.thinkingLevels(e ?? "", t),
1455
+ queryFn: async () => {
1456
+ if (!s || !e) throw new Error("not connected");
1457
+ return (await s.agent(e).listThinkingLevels()).levels;
1458
+ },
1459
+ enabled: !!s && !!e && o,
1460
+ retry: !1
1461
+ });
1462
+ }
1463
+ const ki = "piwb-Attachments_strip_Fxysv", Ci = "piwb-Attachments_thumb_DpZLx", yi = "piwb-Attachments_remove_R7v6y", Re = {
1464
+ strip: ki,
1465
+ thumb: Ci,
1466
+ remove: yi
1467
+ };
1468
+ function Ni({ images: e, onRemove: t }) {
1469
+ return e.length === 0 ? null : /* @__PURE__ */ n("div", { className: Re.strip, children: e.map((o, s) => /* @__PURE__ */ l("div", { className: Re.thumb, children: [
1470
+ /* @__PURE__ */ n("img", { src: o.thumbUrl, alt: "" }),
1471
+ /* @__PURE__ */ n(
1472
+ "button",
1473
+ {
1474
+ type: "button",
1475
+ className: Re.remove,
1476
+ title: "Remove",
1477
+ onClick: () => t(s),
1478
+ children: "×"
1479
+ }
1480
+ )
1481
+ ] }, s)) });
1482
+ }
1483
+ function Ti(e) {
1484
+ const { promise: t, resolve: o, reject: s } = Promise.withResolvers(), r = new FileReader();
1485
+ return r.onload = () => {
1486
+ const a = r.result;
1487
+ if (typeof a != "string") {
1488
+ s(new Error("Unexpected FileReader result"));
1489
+ return;
1490
+ }
1491
+ const c = a.indexOf(","), d = c >= 0 ? a.slice(c + 1) : a;
1492
+ o({ mimeType: e.type, data: d, thumbUrl: a });
1493
+ }, r.onerror = () => s(r.error ?? new Error("Failed to read file")), r.readAsDataURL(e), t;
1494
+ }
1495
+ function Si(e, t, o) {
1496
+ return e ? o : t;
1497
+ }
1498
+ const Ie = [
1499
+ { name: "compact", description: "Manually compact the session context", source: "builtin" }
1500
+ ];
1501
+ function Ot(e) {
1502
+ const t = /^\/([^\s]+)(?:\s+([\s\S]*))?$/.exec(e.trim());
1503
+ if (t?.[1] !== "compact") return null;
1504
+ const o = t[2]?.trim();
1505
+ return { name: "compact", args: o || void 0 };
1506
+ }
1507
+ function We(e) {
1508
+ if (!e.startsWith("/")) return null;
1509
+ const o = /^\/(\S*)/.exec(e)?.[1] ?? "", s = 1 + o.length, r = /\S/.test(e.slice(s));
1510
+ return { name: o, end: s, hasArgs: r };
1511
+ }
1512
+ function Di(e) {
1513
+ return /^\/\S*$/.test(e);
1514
+ }
1515
+ function xi(e, t) {
1516
+ let o = 0;
1517
+ const s = Ie.map((a) => ({
1518
+ value: a.name,
1519
+ label: `/${a.name}`,
1520
+ description: a.description,
1521
+ kind: a.source,
1522
+ disabled: t.builtinsDisabled === !0
1523
+ })), r = new Set(Ie.map((a) => a.name));
1524
+ for (const a of e)
1525
+ if (!r.has(a.name)) {
1526
+ if (t.running && a.source === "extension") {
1527
+ o += 1;
1528
+ continue;
1529
+ }
1530
+ s.push({
1531
+ value: a.name,
1532
+ label: `/${a.name}`,
1533
+ description: a.description,
1534
+ kind: a.source
1535
+ });
1536
+ }
1537
+ return { options: s, hiddenExtensionCount: o };
1538
+ }
1539
+ function Bi(e, t, o) {
1540
+ return o <= 0 ? 0 : (e + t + o) % o;
1541
+ }
1542
+ function Ai(e, t) {
1543
+ const o = We(e);
1544
+ return o ? o.hasArgs ? `/${t}${e.slice(o.end)}` : `/${t} ` : `/${t} ${e}`;
1545
+ }
1546
+ function Ei(e, t) {
1547
+ const o = We(e);
1548
+ return !o || !t.includes(o.name) ? null : { end: o.end };
1549
+ }
1550
+ function Lt({ running: e, compacting: t, hasAgent: o }) {
1551
+ return o && !e && !t;
1552
+ }
1553
+ function Mi(e, t) {
1554
+ return !e.ok && e.reason !== "canceled" && t === "";
1555
+ }
1556
+ function Ri(e) {
1557
+ const t = e.text.trim().length > 0 || e.hasImages;
1558
+ return !e.hasClient || !t || e.busy || e.compacting ? !1 : Ot(e.text) !== null ? Lt(e) : !0;
1559
+ }
1560
+ function Pi(e, t) {
1561
+ const o = kt(e || "~", t).replace(/\/+$/, "");
1562
+ return o === "" || o.startsWith("~") ? null : o;
1563
+ }
1564
+ function Oi(e, t) {
1565
+ if (!t || t.startsWith("~")) return null;
1566
+ const o = e.endsWith("/"), s = o ? e.slice(0, -1) : e;
1567
+ if (!s.startsWith(`${t}/`)) return null;
1568
+ const r = s.slice(t.length + 1);
1569
+ return r === "" ? null : o ? `${r}/` : r;
1570
+ }
1571
+ function Li(e) {
1572
+ if (!/[\s`]/.test(e)) return e;
1573
+ let t = 0;
1574
+ for (const r of e.match(/`+/g) ?? []) t = Math.max(t, r.length);
1575
+ const o = "`".repeat(t + 1), s = e.startsWith("`") || e.endsWith("`") ? " " : "";
1576
+ return `${o}${s}${e}${s}${o}`;
1577
+ }
1578
+ function Ii(e, t, o, s) {
1579
+ const r = (v) => Math.min(Math.max(Number.isFinite(v) ? v : 0, 0), e.length), a = r(t), c = r(o), d = Math.min(a, c), g = Math.max(a, c), m = d > 0 && !/\s/.test(e[d - 1]) ? " " : "", u = g >= e.length || !/\s/.test(e[g]) ? " " : "", p = `${m}${s}${u}`;
1580
+ return { start: d, end: g, insert: p, caret: d + p.length };
1581
+ }
1582
+ function Fi(e) {
1583
+ if (e.refValue === null || e.compacting) return { kind: "ignore" };
1584
+ const t = Oi(e.refValue, e.root);
1585
+ if (t === null) return { kind: "refuse" };
1586
+ const { text: o } = e, s = e.neverFocused ? o.length : e.selStart, r = e.neverFocused ? o.length : e.selEnd;
1587
+ return { kind: "insert", plan: Ii(o, s, r, Li(t)) };
1588
+ }
1589
+ const $i = "piwb-ModelMenu_picker_CF9Ns", zi = "piwb-ModelMenu_search_xC3-G", Hi = "piwb-ModelMenu_searchWrap_W1YdS", Ki = "piwb-ModelMenu_searchSpinner_x1ZTV", Wi = "piwb-ModelMenu_list_EGiO8", qi = "piwb-ModelMenu_item_0R0tL", Ui = "piwb-ModelMenu_itemActive_dm7dt", Gi = "piwb-ModelMenu_checkSlot_qE0_B", Yi = "piwb-ModelMenu_label_Rc-Ov", Vi = "piwb-ModelMenu_modelId_ct32O", ji = "piwb-ModelMenu_state_r0-I0", Qi = "piwb-ModelMenu_stateError_6C4MF", Xi = "piwb-ModelMenu_commandContent_ma9BN", Ji = "piwb-ModelMenu_commandList_F8dHW", Zi = "piwb-ModelMenu_commandItem_C7IGN", ea = "piwb-ModelMenu_commandItemHeader_mKBTT", ta = "piwb-ModelMenu_commandKindBadge_5UszH", na = "piwb-ModelMenu_commandKindExtension_Aops0", oa = "piwb-ModelMenu_commandKindPrompt_krVwu", sa = "piwb-ModelMenu_commandKindSkill_eFgwH", ra = "piwb-ModelMenu_commandDescription_pYXh5", ia = "piwb-ModelMenu_commandItemDisabled_10bpi", k = {
1590
+ picker: $i,
1591
+ search: zi,
1592
+ searchWrap: Hi,
1593
+ searchSpinner: Ki,
1594
+ list: Wi,
1595
+ item: qi,
1596
+ itemActive: Ui,
1597
+ checkSlot: Gi,
1598
+ label: Yi,
1599
+ modelId: Vi,
1600
+ state: ji,
1601
+ stateError: Qi,
1602
+ commandContent: Xi,
1603
+ commandList: Ji,
1604
+ commandItem: Zi,
1605
+ commandItemHeader: ea,
1606
+ commandKindBadge: ta,
1607
+ commandKindExtension: na,
1608
+ commandKindPrompt: oa,
1609
+ commandKindSkill: sa,
1610
+ commandDescription: ra,
1611
+ commandItemDisabled: ia
1612
+ }, aa = {
1613
+ onOpenAutoFocus: (e) => e.preventDefault()
1614
+ };
1615
+ function ca(e) {
1616
+ switch (e) {
1617
+ case "extension":
1618
+ return k.commandKindExtension;
1619
+ case "prompt":
1620
+ return k.commandKindPrompt;
1621
+ case "skill":
1622
+ return k.commandKindSkill;
1623
+ default:
1624
+ return;
1625
+ }
1626
+ }
1627
+ function la({
1628
+ open: e,
1629
+ onOpenChange: t,
1630
+ options: o,
1631
+ highlightedIndex: s,
1632
+ onSelect: r,
1633
+ isLoading: a,
1634
+ isError: c,
1635
+ errorMessage: d,
1636
+ hiddenExtensionCount: g,
1637
+ renderTrigger: m
1638
+ }) {
1639
+ const u = O(null);
1640
+ return I(() => {
1641
+ e && u.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
1642
+ }, [e, s]), /* @__PURE__ */ l(Z.Root, { open: e, onOpenChange: t, modal: !1, children: [
1643
+ /* @__PURE__ */ n(Z.Trigger, { asChild: !0, children: m() }),
1644
+ /* @__PURE__ */ l(
1645
+ ze,
1646
+ {
1647
+ className: B(k.picker, k.commandContent),
1648
+ side: "top",
1649
+ sideOffset: 4,
1650
+ ...aa,
1651
+ onCloseAutoFocus: (p) => p.preventDefault(),
1652
+ children: [
1653
+ a && /* @__PURE__ */ n("div", { className: k.state, children: /* @__PURE__ */ n(re, { size: "sm" }) }),
1654
+ !a && c && /* @__PURE__ */ n("div", { className: k.stateError, children: d ?? "Failed to load commands" }),
1655
+ !a && !c && o.length === 0 && /* @__PURE__ */ n("div", { className: k.state, children: "No commands found" }),
1656
+ !a && !c && o.length > 0 && /* @__PURE__ */ n("div", { ref: u, className: B(k.list, k.commandList), children: o.map((p, v) => /* @__PURE__ */ l(
1657
+ "div",
1658
+ {
1659
+ role: "option",
1660
+ "aria-selected": v === s,
1661
+ "aria-disabled": p.disabled || void 0,
1662
+ className: B(
1663
+ k.item,
1664
+ k.commandItem,
1665
+ v === s && k.itemActive,
1666
+ p.disabled && k.commandItemDisabled
1667
+ ),
1668
+ title: p.description,
1669
+ onMouseDown: (A) => {
1670
+ A.preventDefault(), p.disabled || r(p.value);
1671
+ },
1672
+ children: [
1673
+ /* @__PURE__ */ l("div", { className: k.commandItemHeader, children: [
1674
+ /* @__PURE__ */ n("span", { className: k.label, children: p.label }),
1675
+ p.kind && /* @__PURE__ */ n("span", { className: B(k.commandKindBadge, ca(p.kind)), children: p.kind })
1676
+ ] }),
1677
+ p.description && /* @__PURE__ */ n("div", { className: k.commandDescription, children: p.description })
1678
+ ]
1679
+ },
1680
+ p.value
1681
+ )) }),
1682
+ !a && !c && g > 0 && /* @__PURE__ */ l("div", { className: k.state, children: [
1683
+ g,
1684
+ " extension command(s) unavailable while the agent is running"
1685
+ ] })
1686
+ ]
1687
+ }
1688
+ )
1689
+ ] });
1690
+ }
1691
+ function da(e, t, o) {
1692
+ if (!t) return e;
1693
+ const s = e.filter((a) => a.id === t), r = (o === void 0 ? void 0 : s.find((a) => a.provider === o)) ?? s[0];
1694
+ return r ? [r, ...e.filter((a) => a !== r)] : e;
1695
+ }
1696
+ function ua(e) {
1697
+ const t = /* @__PURE__ */ new Set();
1698
+ return e.filter((o) => {
1699
+ const s = `${o.provider ?? ""}/${o.id}`;
1700
+ return t.has(s) ? !1 : (t.add(s), !0);
1701
+ });
1702
+ }
1703
+ function ma({
1704
+ currentModel: e,
1705
+ currentModelProvider: t,
1706
+ provider: o,
1707
+ agentId: s,
1708
+ onSelect: r,
1709
+ renderTrigger: a
1710
+ }) {
1711
+ const [c, d] = D(!1), [g, m] = D(""), u = O(null), p = O(null), { data: v, isLoading: A, isFetching: L, isError: V, error: y, refetch: S } = Pt(
1712
+ o,
1713
+ s,
1714
+ c || e !== void 0
1715
+ ), U = v ?? [];
1716
+ I(() => {
1717
+ c && m("");
1718
+ }, [c]), I(() => {
1719
+ c && S({ cancelRefetch: !1 });
1720
+ }, [c, S]);
1721
+ const W = ua(da(U, e, t)).map((b) => ({
1722
+ value: b.id,
1723
+ label: b.label ?? b.id,
1724
+ description: b.id,
1725
+ group: b.provider
1726
+ })), j = W[0], X = j?.value === e ? j : void 0, z = eo(Dt(W, g), {
1727
+ priorityGroup: t,
1728
+ // Pi reports a provider for every model today; a future/custom entry without one gets an
1729
+ // honest header instead of silently joining whichever section rendered last.
1730
+ ungroupedLabel: "Other"
1731
+ }), de = z.length > 1, ne = y instanceof Error ? y.message : "Failed to load models";
1732
+ function oe(b) {
1733
+ if (b.stopPropagation(), b.key === "Escape" && d(!1), b.key === "ArrowDown") {
1734
+ const N = p.current?.querySelector('[role="menuitem"]');
1735
+ N && (b.preventDefault(), N.focus());
1736
+ }
1737
+ }
1738
+ const P = {
1739
+ onOpenAutoFocus: (b) => {
1740
+ b.preventDefault(), u.current?.focus();
1741
+ }
1742
+ };
1743
+ return /* @__PURE__ */ l(Z.Root, { open: c, onOpenChange: d, modal: !1, children: [
1744
+ /* @__PURE__ */ n(Z.Trigger, { asChild: !0, children: a(e, X?.label) }),
1745
+ /* @__PURE__ */ l(
1746
+ ze,
1747
+ {
1748
+ minWidth: 240,
1749
+ align: "end",
1750
+ sideOffset: 6,
1751
+ className: k.picker,
1752
+ ...P,
1753
+ children: [
1754
+ /* @__PURE__ */ l("div", { className: k.searchWrap, children: [
1755
+ /* @__PURE__ */ n(
1756
+ "input",
1757
+ {
1758
+ ref: u,
1759
+ className: k.search,
1760
+ placeholder: "Search models…",
1761
+ value: g,
1762
+ onChange: (b) => m(b.target.value),
1763
+ onKeyDown: oe
1764
+ }
1765
+ ),
1766
+ L && !A && /* @__PURE__ */ n(
1767
+ re,
1768
+ {
1769
+ size: "xs",
1770
+ color: "var(--pi-color-foregroundMuted)",
1771
+ className: k.searchSpinner,
1772
+ "aria-label": "Refreshing models"
1773
+ }
1774
+ )
1775
+ ] }),
1776
+ A && /* @__PURE__ */ n("div", { className: k.state, children: /* @__PURE__ */ n(re, { size: "sm" }) }),
1777
+ !A && V && v === void 0 && /* @__PURE__ */ n("div", { className: k.stateError, children: ne }),
1778
+ !A && v !== void 0 && z.length === 0 && /* @__PURE__ */ n("div", { className: k.state, children: "No models found" }),
1779
+ !A && v !== void 0 && z.length > 0 && /* @__PURE__ */ n("div", { ref: p, className: k.list, children: z.map((b) => /* @__PURE__ */ n(to, { label: de ? b.label : void 0, children: b.options.map((N) => /* @__PURE__ */ l(
1780
+ Z.Item,
1781
+ {
1782
+ className: k.item,
1783
+ onSelect: () => r(N.value, N.group),
1784
+ children: [
1785
+ /* @__PURE__ */ n("span", { className: k.checkSlot, "aria-hidden": !0, children: N === X && /* @__PURE__ */ n(be, { size: 14 }) }),
1786
+ /* @__PURE__ */ n("span", { className: k.label, children: N.label }),
1787
+ /* @__PURE__ */ l("span", { className: k.modelId, children: [
1788
+ "(",
1789
+ N.value,
1790
+ ")"
1791
+ ] })
1792
+ ]
1793
+ },
1794
+ `${N.group ?? ""}/${N.value}`
1795
+ )) }, b.key)) })
1796
+ ]
1797
+ }
1798
+ )
1799
+ ] });
1800
+ }
1801
+ function pa({
1802
+ currentLevel: e,
1803
+ levels: t,
1804
+ open: o,
1805
+ onOpenChange: s,
1806
+ onSelect: r,
1807
+ renderTrigger: a
1808
+ }) {
1809
+ return /* @__PURE__ */ l(Z.Root, { open: o, onOpenChange: s, modal: !1, children: [
1810
+ /* @__PURE__ */ n(Z.Trigger, { asChild: !0, children: a(e) }),
1811
+ /* @__PURE__ */ n(
1812
+ ze,
1813
+ {
1814
+ minWidth: 140,
1815
+ align: "end",
1816
+ side: "top",
1817
+ sideOffset: 6,
1818
+ className: k.picker,
1819
+ children: t.length === 0 ? /* @__PURE__ */ n("div", { className: k.state, children: "Loading levels…" }) : /* @__PURE__ */ n("div", { className: k.list, children: t.map((c) => /* @__PURE__ */ l(
1820
+ Z.Item,
1821
+ {
1822
+ className: k.item,
1823
+ onSelect: () => r(c),
1824
+ children: [
1825
+ /* @__PURE__ */ n("span", { className: k.checkSlot, "aria-hidden": !0, children: c === e && /* @__PURE__ */ n(be, { size: 14 }) }),
1826
+ /* @__PURE__ */ n("span", { className: k.label, children: c })
1827
+ ]
1828
+ },
1829
+ c
1830
+ )) })
1831
+ }
1832
+ )
1833
+ ] });
1834
+ }
1835
+ const wt = [
1836
+ "off",
1837
+ "minimal",
1838
+ "low",
1839
+ "medium",
1840
+ "high",
1841
+ "xhigh",
1842
+ "max"
1843
+ ];
1844
+ function ha(e, t) {
1845
+ if (!e) return wt;
1846
+ const o = t?.find((s) => s.id === e);
1847
+ return o?.thinkingLevels && o.thinkingLevels.length > 0 ? o.thinkingLevels : wt;
1848
+ }
1849
+ const fa = "piwb-Composer_composer_tcq0R", ga = "piwb-Composer_card_iM0Sn", wa = "piwb-Composer_flash_Bga5b", ba = "piwb-Composer_dropTarget_NVtqz", _a = "piwb-Composer_note_LJ5VR", va = "piwb-Composer_inlineError_-IHis", ka = "piwb-Composer_compacting_jD2v7", Ca = "piwb-Composer_textarea_4vTSY", ya = "piwb-Composer_compactStatus_N3w6d", Na = "piwb-Composer_compactStatusText_zBBhO", Ta = "piwb-Composer_compactCancel_hMhys", Sa = "piwb-Composer_textareaWrap_yxcGE", Da = "piwb-Composer_highlightLayer_GvqmF", xa = "piwb-Composer_commandMark_Vvn3u", Ba = "piwb-Composer_hiddenFileInput_Ughd4", Aa = "piwb-Composer_toolbar_Etupi", Ea = "piwb-Composer_toolbarRight_I1mn2", Ma = "piwb-Composer_toolBtn_kxxwq", Ra = "piwb-Composer_roundBtn_CFItr", Pa = "piwb-Composer_modelBtn_FBYqI", Oa = "piwb-Composer_modelLabel_8KwKO", La = "piwb-Composer_modelId_Fo-TA", Ia = "piwb-Composer_modelChevron_1q3Lm", T = {
1850
+ composer: fa,
1851
+ card: ga,
1852
+ flash: wa,
1853
+ dropTarget: ba,
1854
+ note: _a,
1855
+ inlineError: va,
1856
+ compacting: ka,
1857
+ textarea: Ca,
1858
+ compactStatus: ya,
1859
+ compactStatusText: Na,
1860
+ compactCancel: Ta,
1861
+ textareaWrap: Sa,
1862
+ highlightLayer: Da,
1863
+ commandMark: xa,
1864
+ hiddenFileInput: Ba,
1865
+ toolbar: Aa,
1866
+ toolbarRight: Ea,
1867
+ toolBtn: Ma,
1868
+ roundBtn: Ra,
1869
+ modelBtn: Pa,
1870
+ modelLabel: Oa,
1871
+ modelId: La,
1872
+ modelChevron: Ia
1873
+ }, Fa = 160;
1874
+ function le(e) {
1875
+ e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, Fa)}px`;
1876
+ }
1877
+ function $a(e) {
1878
+ return typeof e == "object" && e !== null && "ok" in e && e.ok === !1;
1879
+ }
1880
+ function za() {
1881
+ return typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1882
+ }
1883
+ function Ha({ sessionId: e, workspaceCwd: t, owningPaneId: o }) {
1884
+ const s = ee((i) => i.client), r = K((i) => i.sessions[e]), a = K((i) => i.addOptimisticUserMessage), c = K((i) => i.markUserMessageFailed), d = K((i) => i.setCwd), g = K((i) => i.setModel), m = K((i) => i.setThinkingLevel), u = ee((i) => i.serverInfo), [p, v] = D(!1), A = !!u?.features?.thinkingLevels, { data: L } = vi(
1885
+ r?.agentId,
1886
+ r?.model,
1887
+ p && !!r?.agentId && (r?.userMessageCount ?? 0) > 0
1888
+ ), { data: V } = Pt("pi", r?.agentId), y = ha(r?.model, V), S = L !== void 0 && L.length > 0 ? L : y, U = A && !(L !== void 0 && L.length === 0), M = we((i) => i.drafts[e] ?? ""), W = we((i) => i.setDraft), [j, X] = D([]), [z, de] = D(!1), [ne, oe] = D(!1), P = O(null), b = O(null), [N, H] = D(!1), [ue, me] = D(0), qe = Cn(Sn.chat(e)), Ue = we((i) => i.pendingFeedback[e]), [Ge, Ye] = D(null), [Se, ae] = D(null), [Ht, Ve] = D(!1), pe = O(null), he = O(null), [De, ve] = D(!1), je = O(!1), Kt = vt();
1889
+ I(() => {
1890
+ if (!qe || Ue === void 0) return;
1891
+ const i = we.getState().consumeFeedback(e);
1892
+ if (!i) return;
1893
+ Ye(i.copy === "filled" ? "Your message was filled in" : "Your draft was replaced"), pe.current !== null && window.clearTimeout(pe.current), pe.current = window.setTimeout(() => Ye(null), 4e3);
1894
+ const f = P.current;
1895
+ f && f.setSelectionRange(f.value.length, f.value.length), i.flash && (Ve(!0), he.current !== null && window.clearTimeout(he.current), he.current = window.setTimeout(
1896
+ () => Ve(!1),
1897
+ za() ? 1e3 : 400
1898
+ ));
1899
+ }, [qe, Ue, e]), I(() => () => {
1900
+ pe.current !== null && window.clearTimeout(pe.current), he.current !== null && window.clearTimeout(he.current);
1901
+ }, []), I(() => {
1902
+ if (!De) return;
1903
+ const i = () => ve(!1);
1904
+ return document.addEventListener("dragend", i), document.addEventListener("drop", i), () => {
1905
+ document.removeEventListener("dragend", i), document.removeEventListener("drop", i);
1906
+ };
1907
+ }, [De]);
1908
+ const q = r?.status === "running", E = yn(e), xe = Ce((i) => i.lastErrorBySession[e]), Wt = Ce((i) => i.compactSession), Be = Ce((i) => i.cancelCompaction), qt = Ce((i) => i.clearError), Qe = !!r?.agentId, Ut = Si(q, z, ne), Xe = Ri({
1909
+ hasClient: !!s,
1910
+ busy: Ut,
1911
+ compacting: E,
1912
+ running: q,
1913
+ hasAgent: Qe,
1914
+ text: M,
1915
+ hasImages: j.length > 0
1916
+ }), { data: Je = [], isLoading: Gt, isError: Yt, error: Ze } = _i(e, N), { options: et, hiddenExtensionCount: Vt } = xi(Je, {
1917
+ running: q,
1918
+ builtinsDisabled: !Lt({ running: q, compacting: E, hasAgent: Qe })
1919
+ }), tt = We(M), ke = tt ? Dt(et, tt.name) : et, jt = [...Ie, ...Je].map((i) => i.name), ce = Ei(M, jt), nt = E ? Nn(r?.timeline.rows ?? []) : void 0, Qt = nt ? _t(nt) : "Compacting context…";
1920
+ async function ot(i) {
1921
+ if (i.type.startsWith("image/"))
1922
+ try {
1923
+ const f = await Ti(i);
1924
+ X((_) => [..._, f]);
1925
+ } catch {
1926
+ }
1927
+ }
1928
+ function Xt(i) {
1929
+ for (const f of i.target.files ?? []) ot(f);
1930
+ i.target.value = "";
1931
+ }
1932
+ function Jt(i) {
1933
+ if (!E) {
1934
+ for (const f of i.clipboardData.items)
1935
+ if (f.type.startsWith("image/")) {
1936
+ i.preventDefault();
1937
+ const _ = f.getAsFile();
1938
+ _ && ot(_);
1939
+ }
1940
+ }
1941
+ }
1942
+ function Zt(i) {
1943
+ X((f) => f.filter((_, x) => x !== i));
1944
+ }
1945
+ function st(i, f) {
1946
+ W(e, f), le(i), xe && qt(e), Se && ae(null);
1947
+ const _ = Di(f);
1948
+ _ !== N && H(_), _ && me(0);
1949
+ }
1950
+ function en(i) {
1951
+ st(i.target, i.target.value);
1952
+ }
1953
+ function tn(i) {
1954
+ return !E && lt(i.dataTransfer.types);
1955
+ }
1956
+ function rt(i) {
1957
+ tn(i) && (i.preventDefault(), i.dataTransfer.dropEffect = "copy", ve(!0));
1958
+ }
1959
+ function nn(i) {
1960
+ i.currentTarget.contains(i.relatedTarget) || ve(!1);
1961
+ }
1962
+ function on(i, f) {
1963
+ i.focus(), i.setSelectionRange(f.start, f.end);
1964
+ const _ = i.value;
1965
+ let x = !1;
1966
+ try {
1967
+ x = document.execCommand("insertText", !1, f.insert) && i.value !== _;
1968
+ } catch {
1969
+ x = !1;
1970
+ }
1971
+ x || (i.setRangeText(f.insert, f.start, f.end, "end"), st(i, i.value)), i.setSelectionRange(f.caret, f.caret), o !== null && Ct.getState().focusPane(t, o);
1972
+ }
1973
+ function sn(i) {
1974
+ const { types: f } = i.dataTransfer;
1975
+ if (!lt(f) || (ve(!1), E)) return;
1976
+ i.preventDefault();
1977
+ const _ = P.current;
1978
+ if (!_) return;
1979
+ const x = Fi({
1980
+ refValue: Dn(f, (G) => i.dataTransfer.getData(G)),
1981
+ compacting: E,
1982
+ root: Pi(r?.cwd ?? "", Kt),
1983
+ text: _.value,
1984
+ selStart: _.selectionStart,
1985
+ selEnd: _.selectionEnd,
1986
+ neverFocused: !je.current
1987
+ });
1988
+ x.kind === "refuse" ? ae("Not inside this workspace") : x.kind === "insert" && on(_, x.plan);
1989
+ }
1990
+ function rn(i) {
1991
+ if (E) {
1992
+ i.key === "Escape" && (i.preventDefault(), Be(e));
1993
+ return;
1994
+ }
1995
+ if (!N && ce && i.key === "Backspace") {
1996
+ const f = i.currentTarget, _ = f.selectionStart;
1997
+ if (_ !== null && _ === f.selectionEnd) {
1998
+ const x = ce.end + (M[ce.end] === " " ? 1 : 0);
1999
+ if (_ > 0 && _ <= x) {
2000
+ i.preventDefault();
2001
+ const G = M.slice(x);
2002
+ W(e, G), f.setSelectionRange(0, 0), le(f);
2003
+ return;
2004
+ }
2005
+ }
2006
+ }
2007
+ if (N && ke.length > 0) {
2008
+ if (i.key === "ArrowDown" || i.key === "ArrowUp") {
2009
+ i.preventDefault(), me((f) => Bi(f, i.key === "ArrowDown" ? 1 : -1, ke.length));
2010
+ return;
2011
+ }
2012
+ if (i.key === "Enter" && !i.shiftKey || i.key === "Tab") {
2013
+ i.preventDefault();
2014
+ const f = ke[ue];
2015
+ f && !f.disabled && it(f.value);
2016
+ return;
2017
+ }
2018
+ }
2019
+ if (N && i.key === "Escape") {
2020
+ i.preventDefault(), H(!1);
2021
+ return;
2022
+ }
2023
+ i.key === "Enter" && !i.shiftKey && (i.preventDefault(), at(q ? "steer" : "send"));
2024
+ }
2025
+ function it(i) {
2026
+ const f = Ai(M, i);
2027
+ W(e, f), H(!1), me(0);
2028
+ const _ = P.current;
2029
+ _ && (_.focus(), _.setSelectionRange(f.length, f.length), le(_));
2030
+ }
2031
+ async function at(i) {
2032
+ if (!s || !r || (i === "steer" ? ne : z) || i === "steer" && !r.agentId) return;
2033
+ const f = M.trim();
2034
+ if (!f && j.length === 0 || !Xe) return;
2035
+ const _ = Ot(f);
2036
+ if (_) {
2037
+ H(!1), W(e, ""), P.current && le(P.current);
2038
+ const J = await Wt(e, _.args);
2039
+ Mi(J, we.getState().drafts[e] ?? "") && (W(e, M), P.current && le(P.current));
2040
+ return;
2041
+ }
2042
+ W(e, ""), H(!1), P.current && le(P.current);
2043
+ const x = j;
2044
+ X([]);
2045
+ const G = f || "Describe this image", fe = x.length > 0 ? x.map((J) => ({ mimeType: J.mimeType, data: J.data })) : void 0, ge = xn();
2046
+ a(e, ge, G, fe, i === "steer");
2047
+ const ct = i === "steer" ? oe : de;
2048
+ ct(!0);
2049
+ try {
2050
+ if (i === "steer") {
2051
+ const J = await s.agent(r.agentId).steer(G, { clientMessageId: ge, images: fe });
2052
+ $a(J) && c(e, ge);
2053
+ } else {
2054
+ r.agentId || d(e, r.cwd || "~");
2055
+ const J = await ye(s, e);
2056
+ await s.agent(J).send(G, { clientMessageId: ge, images: fe });
2057
+ }
2058
+ } catch {
2059
+ c(e, ge);
2060
+ } finally {
2061
+ ct(!1);
2062
+ }
2063
+ }
2064
+ function an() {
2065
+ r?.agentId && (E ? Be(e) : s?.agent(r.agentId).interrupt());
2066
+ }
2067
+ function cn(i, f) {
2068
+ const _ = { model: r?.model, provider: r?.modelProvider };
2069
+ g(e, i, f), ae(null), !(!s || !f) && (async () => {
2070
+ const x = await ye(s, e);
2071
+ await s.agent(x).setModel(f, i);
2072
+ })().catch((x) => {
2073
+ const G = K.getState().sessions[e];
2074
+ G?.model === i && G.modelProvider === f && g(e, _.model, _.provider);
2075
+ const fe = x instanceof Error ? x.message : String(x);
2076
+ ae(`Couldn't switch model: ${fe}`);
2077
+ });
2078
+ }
2079
+ function ln(i) {
2080
+ const f = r?.thinkingLevel;
2081
+ m(e, i), ae(null), s && (async () => {
2082
+ const _ = await ye(s, e), x = await s.agent(_).setThinking(i);
2083
+ m(e, x.level);
2084
+ })().catch((_) => {
2085
+ K.getState().sessions[e]?.thinkingLevel === i && m(e, f);
2086
+ const x = _ instanceof Error ? _.message : String(_);
2087
+ ae(`Couldn't set thinking level: ${x}`);
2088
+ });
2089
+ }
2090
+ return /* @__PURE__ */ l("div", { className: T.composer, children: [
2091
+ /* @__PURE__ */ l(
2092
+ "div",
2093
+ {
2094
+ className: B(
2095
+ T.card,
2096
+ Ht && T.flash,
2097
+ E && T.compacting,
2098
+ De && !E && T.dropTarget
2099
+ ),
2100
+ ...Tn(),
2101
+ onDragEnter: rt,
2102
+ onDragOver: rt,
2103
+ onDragLeave: nn,
2104
+ onDrop: sn,
2105
+ children: [
2106
+ /* @__PURE__ */ l("div", { className: T.textareaWrap, children: [
2107
+ /* @__PURE__ */ n("div", { className: T.highlightLayer, "aria-hidden": !0, children: ce ? /* @__PURE__ */ l($, { children: [
2108
+ /* @__PURE__ */ n("mark", { className: T.commandMark, children: M.slice(0, ce.end) }),
2109
+ M.slice(ce.end)
2110
+ ] }) : M }),
2111
+ /* @__PURE__ */ n(
2112
+ St,
2113
+ {
2114
+ ref: P,
2115
+ className: T.textarea,
2116
+ rows: 1,
2117
+ value: M,
2118
+ readOnly: E,
2119
+ placeholder: E ? "Compacting context… esc cancel" : q ? "Steer the running turn… ⏎ steer · ⇧⏎ newline" : "Ask anything… ⏎ send · ⇧⏎ newline · / commands",
2120
+ onChange: en,
2121
+ onFocus: () => {
2122
+ je.current = !0;
2123
+ },
2124
+ onKeyDown: rn,
2125
+ onPaste: Jt,
2126
+ "data-session-id": e
2127
+ }
2128
+ )
2129
+ ] }),
2130
+ /* @__PURE__ */ n(Ni, { images: j, onRemove: Zt }),
2131
+ /* @__PURE__ */ l("div", { className: T.toolbar, children: [
2132
+ /* @__PURE__ */ n(
2133
+ F,
2134
+ {
2135
+ className: T.toolBtn,
2136
+ variant: "ghost",
2137
+ size: "sm",
2138
+ iconOnly: !0,
2139
+ title: "Attach image",
2140
+ "aria-label": "Attach image",
2141
+ disabled: E,
2142
+ onClick: () => b.current?.click(),
2143
+ children: /* @__PURE__ */ n(Wn, { size: 16 })
2144
+ }
2145
+ ),
2146
+ /* @__PURE__ */ n(
2147
+ la,
2148
+ {
2149
+ open: N && !E,
2150
+ onOpenChange: H,
2151
+ options: ke,
2152
+ highlightedIndex: ue,
2153
+ onSelect: it,
2154
+ isLoading: Gt,
2155
+ isError: Yt,
2156
+ errorMessage: Ze instanceof Error ? Ze.message : void 0,
2157
+ hiddenExtensionCount: Vt,
2158
+ renderTrigger: () => /* @__PURE__ */ n(
2159
+ F,
2160
+ {
2161
+ className: T.toolBtn,
2162
+ variant: "ghost",
2163
+ size: "sm",
2164
+ iconOnly: !0,
2165
+ disabled: E,
2166
+ title: "Slash commands",
2167
+ "aria-label": "Slash commands",
2168
+ children: /* @__PURE__ */ n(qn, { size: 16 })
2169
+ }
2170
+ )
2171
+ }
2172
+ ),
2173
+ /* @__PURE__ */ l("div", { className: T.toolbarRight, children: [
2174
+ /* @__PURE__ */ n(
2175
+ ma,
2176
+ {
2177
+ currentModel: r?.model,
2178
+ currentModelProvider: r?.modelProvider,
2179
+ provider: "pi",
2180
+ agentId: r?.agentId,
2181
+ onSelect: cn,
2182
+ renderTrigger: (i, f) => {
2183
+ const _ = f !== void 0 && f !== i;
2184
+ return /* @__PURE__ */ l(
2185
+ "button",
2186
+ {
2187
+ type: "button",
2188
+ className: T.modelBtn,
2189
+ disabled: !s,
2190
+ title: i ? `Model: ${f ?? i}${_ ? ` (${i})` : ""}` : "Select model",
2191
+ children: [
2192
+ /* @__PURE__ */ n(Un, { size: 14, "aria-hidden": "true" }),
2193
+ /* @__PURE__ */ n("span", { className: T.modelLabel, children: f ?? i ?? "Model" }),
2194
+ _ && /* @__PURE__ */ l("span", { className: T.modelId, children: [
2195
+ "(",
2196
+ i,
2197
+ ")"
2198
+ ] }),
2199
+ /* @__PURE__ */ n(ut, { size: 13, className: T.modelChevron, "aria-hidden": "true" })
2200
+ ]
2201
+ }
2202
+ );
2203
+ }
2204
+ }
2205
+ ),
2206
+ U && /* @__PURE__ */ n(
2207
+ pa,
2208
+ {
2209
+ currentLevel: r?.thinkingLevel,
2210
+ levels: S,
2211
+ open: p,
2212
+ onOpenChange: v,
2213
+ onSelect: ln,
2214
+ renderTrigger: (i) => /* @__PURE__ */ l(
2215
+ "button",
2216
+ {
2217
+ type: "button",
2218
+ className: T.modelBtn,
2219
+ disabled: !s,
2220
+ title: i ? `Thinking: ${i}` : "Thinking level",
2221
+ children: [
2222
+ /* @__PURE__ */ n(Nt, { size: 14, "aria-hidden": "true" }),
2223
+ /* @__PURE__ */ n("span", { className: T.modelLabel, children: i ?? "Thinking" }),
2224
+ /* @__PURE__ */ n(ut, { size: 13, className: T.modelChevron, "aria-hidden": "true" })
2225
+ ]
2226
+ }
2227
+ )
2228
+ }
2229
+ ),
2230
+ (q || E) && /* @__PURE__ */ n(
2231
+ F,
2232
+ {
2233
+ className: T.roundBtn,
2234
+ variant: "destructive",
2235
+ size: "sm",
2236
+ iconOnly: !0,
2237
+ title: E ? "Cancel the compaction" : "Stop the running turn",
2238
+ "aria-label": "Stop",
2239
+ onClick: an,
2240
+ children: /* @__PURE__ */ n(Gn, { size: 14 })
2241
+ }
2242
+ ),
2243
+ /* @__PURE__ */ n(
2244
+ F,
2245
+ {
2246
+ className: T.roundBtn,
2247
+ size: "sm",
2248
+ iconOnly: !0,
2249
+ disabled: !Xe,
2250
+ title: q ? "Steer the running turn" : "Send",
2251
+ "aria-label": q ? "Steer" : "Send",
2252
+ onClick: () => void at(q ? "steer" : "send"),
2253
+ children: q ? /* @__PURE__ */ n(Yn, { size: 16 }) : /* @__PURE__ */ n(Vn, { size: 18 })
2254
+ }
2255
+ )
2256
+ ] })
2257
+ ] })
2258
+ ]
2259
+ }
2260
+ ),
2261
+ /* @__PURE__ */ n("div", { role: "status", children: E && /* @__PURE__ */ l("div", { className: T.compactStatus, children: [
2262
+ /* @__PURE__ */ n(re, { size: "xs", "aria-label": "Compacting" }),
2263
+ /* @__PURE__ */ n("span", { className: T.compactStatusText, children: Qt }),
2264
+ /* @__PURE__ */ n(
2265
+ "button",
2266
+ {
2267
+ type: "button",
2268
+ className: T.compactCancel,
2269
+ title: "Cancel the compaction (Esc)",
2270
+ onClick: () => void Be(e),
2271
+ children: "Cancel"
2272
+ }
2273
+ )
2274
+ ] }) }),
2275
+ Ge !== null && /* @__PURE__ */ n("div", { className: T.note, children: Ge }),
2276
+ xe && /* @__PURE__ */ n("div", { role: "alert", className: T.inlineError, children: xe }),
2277
+ Se && /* @__PURE__ */ n("div", { role: "alert", className: T.inlineError, children: Se }),
2278
+ /* @__PURE__ */ n(
2279
+ "input",
2280
+ {
2281
+ ref: b,
2282
+ className: T.hiddenFileInput,
2283
+ type: "file",
2284
+ accept: "image/*",
2285
+ multiple: !0,
2286
+ onChange: Xt
2287
+ }
2288
+ )
2289
+ ] });
2290
+ }
2291
+ const Ka = 5;
2292
+ function It(e) {
2293
+ return e.toSorted((t, o) => t.id - o.id);
2294
+ }
2295
+ function Wa(e) {
2296
+ return { done: e.filter((t) => t.status === "completed").length, total: e.length };
2297
+ }
2298
+ function Ft(e) {
2299
+ return It(e).find((t) => t.status === "in_progress");
2300
+ }
2301
+ function $t(e) {
2302
+ return e.status === "in_progress" && e.activeForm ? e.activeForm : e.subject;
2303
+ }
2304
+ function qa(e) {
2305
+ const t = Ft(e);
2306
+ return t ? $t(t) : void 0;
2307
+ }
2308
+ function Ua(e) {
2309
+ if (!(e.status === "completed" || !e.blockedBy?.length))
2310
+ return `blocked by ${e.blockedBy.map((t) => `#${t}`).join(", ")}`;
2311
+ }
2312
+ function Ga(e) {
2313
+ return !!e.description || !!e.owner;
2314
+ }
2315
+ function Ya(e, t = Ka) {
2316
+ const o = It(e), s = o.filter((d) => d.status === "completed"), r = s.length > t, a = [];
2317
+ let c = !1;
2318
+ return o.forEach((d, g) => {
2319
+ if (r && d.status === "completed") {
2320
+ c || (c = !0, a.push({
2321
+ kind: "completed-group",
2322
+ count: s.length,
2323
+ tasks: s,
2324
+ key: `group-${d.id}-${g}`
2325
+ }));
2326
+ return;
2327
+ }
2328
+ a.push({ kind: "task", task: d, key: `${d.id}-${g}` });
2329
+ }), a;
2330
+ }
2331
+ const Va = "piwb-TodoPanel_panel_al7nk", ja = "piwb-TodoPanel_header_SNYGm", Qa = "piwb-TodoPanel_rowButton_x-th-", Xa = "piwb-TodoPanel_chevron_63kTs", Ja = "piwb-TodoPanel_chevronOpen_BvnNz", Za = "piwb-TodoPanel_label_g773Q", ec = "piwb-TodoPanel_count_6h4cA", tc = "piwb-TodoPanel_summary_59C3r", nc = "piwb-TodoPanel_body_WTWEp", oc = "piwb-TodoPanel_row_ix7Oy", sc = "piwb-TodoPanel_rowStatic_bMzW_", rc = "piwb-TodoPanel_icon_VyD9z", ic = "piwb-TodoPanel_iconInProgress__cdyZ", ac = "piwb-TodoPanel_iconCompleted_1rcUN", cc = "piwb-TodoPanel_iconPending_emdnY", lc = "piwb-TodoPanel_text_rjqpV", dc = "piwb-TodoPanel_textCompleted_HdPKf", uc = "piwb-TodoPanel_id_PxLH-", mc = "piwb-TodoPanel_blocked_mEQBZ", pc = "piwb-TodoPanel_details_p9L7X", hc = "piwb-TodoPanel_footer_GBNPZ", fc = "piwb-TodoPanel_nested_f4HDq", C = {
2332
+ panel: Va,
2333
+ header: ja,
2334
+ rowButton: Qa,
2335
+ chevron: Xa,
2336
+ chevronOpen: Ja,
2337
+ label: Za,
2338
+ count: ec,
2339
+ summary: tc,
2340
+ body: nc,
2341
+ row: oc,
2342
+ rowStatic: sc,
2343
+ icon: rc,
2344
+ iconInProgress: ic,
2345
+ iconCompleted: ac,
2346
+ iconPending: cc,
2347
+ text: lc,
2348
+ textCompleted: dc,
2349
+ id: uc,
2350
+ blocked: mc,
2351
+ details: pc,
2352
+ footer: hc,
2353
+ nested: fc
2354
+ };
2355
+ function gc({ status: e }) {
2356
+ return e === "in_progress" ? /* @__PURE__ */ n("span", { className: `${C.icon} ${C.iconInProgress}`, children: /* @__PURE__ */ n(re, { size: 14, "aria-label": "In progress" }) }) : e === "completed" ? /* @__PURE__ */ n("span", { className: `${C.icon} ${C.iconCompleted}`, children: /* @__PURE__ */ n(R, { icon: be, size: "sm", "aria-label": "Completed" }) }) : /* @__PURE__ */ n("span", { className: `${C.icon} ${C.iconPending}`, children: /* @__PURE__ */ n(R, { icon: jn, size: "sm", "aria-label": "Pending" }) });
2357
+ }
2358
+ function zt({ task: e }) {
2359
+ const [t, o] = D(!1), s = Ua(e), r = Ga(e), a = /* @__PURE__ */ l($, { children: [
2360
+ /* @__PURE__ */ n(gc, { status: e.status }),
2361
+ /* @__PURE__ */ n("span", { className: `${C.text} ${e.status === "completed" ? C.textCompleted : ""}`, children: $t(e) }),
2362
+ s && /* @__PURE__ */ n("span", { className: C.blocked, children: s }),
2363
+ /* @__PURE__ */ l("span", { className: C.id, children: [
2364
+ "#",
2365
+ e.id
2366
+ ] }),
2367
+ r && /* @__PURE__ */ n("span", { className: `${C.chevron} ${t ? C.chevronOpen : ""}`, children: /* @__PURE__ */ n(R, { icon: _e, size: "xs", "aria-hidden": !0 }) })
2368
+ ] });
2369
+ return /* @__PURE__ */ l("li", { className: C.row, "data-status": e.status, "data-task-id": e.id, children: [
2370
+ r ? /* @__PURE__ */ n(
2371
+ "button",
2372
+ {
2373
+ type: "button",
2374
+ className: C.rowButton,
2375
+ "aria-expanded": t,
2376
+ onClick: () => o((c) => !c),
2377
+ children: a
2378
+ }
2379
+ ) : /* @__PURE__ */ n("div", { className: C.rowStatic, children: a }),
2380
+ t && /* @__PURE__ */ l("p", { className: C.details, children: [
2381
+ e.description,
2382
+ e.description && e.owner ? `
2383
+ ` : "",
2384
+ e.owner ? `Owner: ${e.owner}` : ""
2385
+ ] })
2386
+ ] });
2387
+ }
2388
+ function wc({ tasks: e }) {
2389
+ const [t, o] = D(!1);
2390
+ return /* @__PURE__ */ l("li", { className: C.row, children: [
2391
+ /* @__PURE__ */ l(
2392
+ "button",
2393
+ {
2394
+ type: "button",
2395
+ className: C.rowButton,
2396
+ "aria-expanded": t,
2397
+ onClick: () => o((s) => !s),
2398
+ children: [
2399
+ /* @__PURE__ */ n("span", { className: `${C.icon} ${C.iconCompleted}`, children: /* @__PURE__ */ n(R, { icon: be, size: "sm", "aria-hidden": !0 }) }),
2400
+ /* @__PURE__ */ l("span", { className: C.text, children: [
2401
+ e.length,
2402
+ " completed"
2403
+ ] }),
2404
+ /* @__PURE__ */ n("span", { className: `${C.chevron} ${t ? C.chevronOpen : ""}`, children: /* @__PURE__ */ n(R, { icon: _e, size: "xs", "aria-hidden": !0 }) })
2405
+ ]
2406
+ }
2407
+ ),
2408
+ t && /* @__PURE__ */ n("ol", { className: C.nested, children: e.map((s, r) => /* @__PURE__ */ n(zt, { task: s }, `${s.id}-${r}`)) })
2409
+ ] });
2410
+ }
2411
+ function bc({ agentId: e }) {
2412
+ const t = Bn(e), o = An(e), s = mn(), r = O(null);
2413
+ I(() => {
2414
+ if (e)
2415
+ return dt.getState().track(e);
2416
+ }, [e]);
2417
+ const a = t?.tasks, c = a ? Ft(a)?.id : void 0;
2418
+ if (I(() => {
2419
+ const u = r.current;
2420
+ if (!u || c === void 0 || o) return;
2421
+ const p = u.querySelector(
2422
+ `[data-task-id="${c}"][data-status="in_progress"]`
2423
+ );
2424
+ if (!p) return;
2425
+ const v = p.offsetTop - u.offsetTop;
2426
+ (v < u.scrollTop || v + p.offsetHeight > u.scrollTop + u.clientHeight) && (u.scrollTop = v - (u.clientHeight - p.offsetHeight) / 2);
2427
+ }, [c, o]), !e || !t || t.tasks.length === 0) return null;
2428
+ const { done: d, total: g } = Wa(t.tasks), m = o ? qa(t.tasks) : void 0;
2429
+ return /* @__PURE__ */ l("section", { className: C.panel, role: "region", "aria-label": "Agent todos", children: [
2430
+ /* @__PURE__ */ l(
2431
+ "button",
2432
+ {
2433
+ type: "button",
2434
+ className: C.header,
2435
+ "aria-expanded": !o,
2436
+ "aria-controls": s,
2437
+ onClick: () => dt.getState().setCollapsed(e, !o),
2438
+ children: [
2439
+ /* @__PURE__ */ n("span", { className: `${C.chevron} ${o ? "" : C.chevronOpen}`, children: /* @__PURE__ */ n(R, { icon: _e, size: "sm", "aria-hidden": !0 }) }),
2440
+ /* @__PURE__ */ n("span", { className: C.label, children: "Todos" }),
2441
+ /* @__PURE__ */ l("span", { className: C.count, children: [
2442
+ d,
2443
+ "/",
2444
+ g
2445
+ ] }),
2446
+ m && /* @__PURE__ */ n("span", { className: C.summary, children: m })
2447
+ ]
2448
+ }
2449
+ ),
2450
+ !o && /* @__PURE__ */ n("ol", { id: s, ref: r, className: C.body, children: Ya(t.tasks).map(
2451
+ (u) => u.kind === "task" ? /* @__PURE__ */ n(zt, { task: u.task }, u.key) : /* @__PURE__ */ n(wc, { tasks: u.tasks }, u.key)
2452
+ ) }),
2453
+ !o && t.truncated && /* @__PURE__ */ l("div", { className: C.footer, children: [
2454
+ "Showing first ",
2455
+ lo,
2456
+ " tasks"
2457
+ ] })
2458
+ ] });
2459
+ }
2460
+ const _c = "piwb-TurnProgressBar_track_Fa0dB", vc = "piwb-TurnProgressBar_sweep_uy5Z1", kc = "piwb-TurnProgressBar_visuallyHidden_QKz9s", Pe = {
2461
+ track: _c,
2462
+ sweep: vc,
2463
+ visuallyHidden: kc
2464
+ };
2465
+ function Cc({ running: e }) {
2466
+ return e ? /* @__PURE__ */ l("div", { className: Pe.track, role: "progressbar", "aria-label": "Turn in progress", children: [
2467
+ /* @__PURE__ */ n("div", { className: Pe.sweep, "aria-hidden": "true" }),
2468
+ /* @__PURE__ */ n("span", { className: Pe.visuallyHidden, role: "status", "aria-live": "polite", children: "Agent is working…" })
2469
+ ] }) : null;
2470
+ }
2471
+ const yc = "piwb-ChatPanel_panel_OLhmJ", Nc = "piwb-ChatPanel_empty_RknoH", bt = {
2472
+ panel: yc,
2473
+ empty: Nc
2474
+ };
2475
+ function Fc({ tab: e, owningPaneId: t }) {
2476
+ const { sessionId: o } = e.data, s = K((r) => r.sessions[o]);
2477
+ return ko(o), s ? /* @__PURE__ */ l(mt, { className: bt.panel, children: [
2478
+ /* @__PURE__ */ n(Cc, { running: s.status === "running" }),
2479
+ /* @__PURE__ */ n(bi, { session: s, owningPaneId: t, workspaceCwd: e.workspaceCwd }),
2480
+ /* @__PURE__ */ n(bc, { agentId: s.agentId }),
2481
+ /* @__PURE__ */ n(
2482
+ Ha,
2483
+ {
2484
+ sessionId: s.id,
2485
+ workspaceCwd: e.workspaceCwd,
2486
+ owningPaneId: t
2487
+ }
2488
+ )
2489
+ ] }) : /* @__PURE__ */ n(mt, { children: /* @__PURE__ */ n("div", { className: bt.empty, children: "Session not found." }) });
2490
+ }
2491
+ export {
2492
+ Fc as ChatPanel
2493
+ };