@av-pi-studio/web-client 0.0.33 → 0.0.34

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 (35) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/web/assets/{BinaryFallbackViewer-DcdvHipL.js → BinaryFallbackViewer-HicqzbWd.js} +2 -2
  3. package/dist/web/assets/{BinaryFallbackViewer-DcdvHipL.js.map → BinaryFallbackViewer-HicqzbWd.js.map} +1 -1
  4. package/dist/web/assets/ChatPanel-CTnpkb2U.css +1 -0
  5. package/dist/web/assets/ChatPanel-XI36Imum.js +3 -0
  6. package/dist/web/assets/ChatPanel-XI36Imum.js.map +1 -0
  7. package/dist/web/assets/{CodeView-CHtX3XUo.js → CodeView-z3x4ATgx.js} +2 -2
  8. package/dist/web/assets/{CodeView-CHtX3XUo.js.map → CodeView-z3x4ATgx.js.map} +1 -1
  9. package/dist/web/assets/{FilePanel-DFrjCgQW.js → FilePanel-VOhIehHw.js} +3 -3
  10. package/dist/web/assets/{FilePanel-DFrjCgQW.js.map → FilePanel-VOhIehHw.js.map} +1 -1
  11. package/dist/web/assets/{ImageViewer-BU0ZsYF9.js → ImageViewer-BivcSG2D.js} +2 -2
  12. package/dist/web/assets/{ImageViewer-BU0ZsYF9.js.map → ImageViewer-BivcSG2D.js.map} +1 -1
  13. package/dist/web/assets/{MarkdownFileViewer-n81kPpQE.js → MarkdownFileViewer-CcfSk7Qc.js} +2 -2
  14. package/dist/web/assets/{MarkdownFileViewer-n81kPpQE.js.map → MarkdownFileViewer-CcfSk7Qc.js.map} +1 -1
  15. package/dist/web/assets/{TerminalPanel-yVOy1dbu.js → TerminalPanel-KNfHGYYL.js} +2 -2
  16. package/dist/web/assets/{TerminalPanel-yVOy1dbu.js.map → TerminalPanel-KNfHGYYL.js.map} +1 -1
  17. package/dist/web/assets/{TextViewer-DjulYYEe.js → TextViewer-DlvdoBEv.js} +2 -2
  18. package/dist/web/assets/{TextViewer-DjulYYEe.js.map → TextViewer-DlvdoBEv.js.map} +1 -1
  19. package/dist/web/assets/{VideoViewer-CWUu0A0W.js → VideoViewer-BmTmnaOQ.js} +2 -2
  20. package/dist/web/assets/{VideoViewer-CWUu0A0W.js.map → VideoViewer-BmTmnaOQ.js.map} +1 -1
  21. package/dist/web/assets/index-C5SpA_B-.js +3 -0
  22. package/dist/web/assets/index-C5SpA_B-.js.map +1 -0
  23. package/dist/web/assets/{index-ZP_-GPM5.css → index-D_2xgUa4.css} +1 -1
  24. package/dist/web/assets/{use-file-download-BxA_7HBl.js → use-file-download-t12JJGKT.js} +2 -2
  25. package/dist/web/assets/{use-file-download-BxA_7HBl.js.map → use-file-download-t12JJGKT.js.map} +1 -1
  26. package/dist/web/assets/{vendor-icons-BJD_eLBz.js → vendor-icons-BouiMPVM.js} +68 -38
  27. package/dist/web/assets/vendor-icons-BouiMPVM.js.map +1 -0
  28. package/dist/web/index.html +3 -3
  29. package/package.json +3 -3
  30. package/dist/web/assets/ChatPanel-C5cHHrg2.js +0 -3
  31. package/dist/web/assets/ChatPanel-C5cHHrg2.js.map +0 -1
  32. package/dist/web/assets/ChatPanel-DRMI3PJR.css +0 -1
  33. package/dist/web/assets/index-B_Wls_vp.js +0 -3
  34. package/dist/web/assets/index-B_Wls_vp.js.map +0 -1
  35. package/dist/web/assets/vendor-icons-BJD_eLBz.js.map +0 -1
package/dist/.tsbuildinfo CHANGED
@@ -1 +1 @@
1
- {"root":["../src/app.tsx","../src/css-modules.d.ts","../src/main.tsx","../src/vite-env.d.ts","../src/brand/brand-logo.ts","../src/brand/config.ts","../src/brand/index.ts","../src/brand/theme-injection.ts","../src/components/primitives/Avatar.tsx","../src/components/primitives/Button.tsx","../src/components/primitives/Checkbox.tsx","../src/components/primitives/Dialog.tsx","../src/components/primitives/Divider.tsx","../src/components/primitives/Icon.tsx","../src/components/primitives/ResizeHandle.tsx","../src/components/primitives/ScreenTitle.tsx","../src/components/primitives/ScrollArea.tsx","../src/components/primitives/Select.tsx","../src/components/primitives/Shortcut.tsx","../src/components/primitives/Spinner.tsx","../src/components/primitives/StatusBadge.tsx","../src/components/primitives/StatusDot.tsx","../src/components/primitives/Surface.tsx","../src/components/primitives/Switch.tsx","../src/components/primitives/TextInput.tsx","../src/components/primitives/helpers.ts","../src/components/primitives/index.ts","../src/components/primitives/useHover.ts","../src/features/chat/Attachments.tsx","../src/features/chat/ChatPanel.tsx","../src/features/chat/Composer.tsx","../src/features/chat/Timeline.tsx","../src/features/chat/rows/AssistantRow.tsx","../src/features/chat/rows/ErrorRow.tsx","../src/features/chat/rows/ReasoningRow.tsx","../src/features/chat/rows/SystemRow.tsx","../src/features/chat/rows/ToolCard.tsx","../src/features/chat/rows/UserRow.tsx","../src/features/connection/ConnectionStatus.tsx","../src/features/connection/Toolbar.tsx","../src/features/files/BinaryFallbackViewer.tsx","../src/features/files/CodeView.tsx","../src/features/files/DiffView.tsx","../src/features/files/FileContextMenu.tsx","../src/features/files/FileExplorer.tsx","../src/features/files/FilePanel.tsx","../src/features/files/ImageViewer.tsx","../src/features/files/MarkdownFileViewer.tsx","../src/features/files/RightSidebar.tsx","../src/features/files/TextViewer.tsx","../src/features/files/TreeNode.tsx","../src/features/files/VideoViewer.tsx","../src/features/files/file-tree.test.ts","../src/features/files/file-tree.ts","../src/features/files/viewer-registry.ts","../src/features/git/ChangesPanel.tsx","../src/features/sessions/SessionContextMenu.tsx","../src/features/sessions/SessionItem.tsx","../src/features/sessions/SessionList.tsx","../src/features/sessions/WorkspaceGroupHeader.tsx","../src/features/sessions/open-workspace.ts","../src/features/sessions/status-map.ts","../src/features/sessions/workspace-grouping.ts","../src/features/terminal/TerminalPanel.tsx","../src/features/workspace/TabPanelHost.tsx","../src/features/workspace/TabStrip.tsx","../src/features/workspace/panel-registry.ts","../src/features/workspace-picker/OpenWorkspaceDialog.tsx","../src/hooks/agent-stream-events.test.ts","../src/hooks/agent-stream-events.ts","../src/hooks/file-transfer-instance.ts","../src/hooks/use-agent-stream.ts","../src/hooks/use-checkout-status.ts","../src/hooks/use-connection.ts","../src/hooks/use-explorer-tree.ts","../src/hooks/use-explorer.ts","../src/hooks/use-file-diff.ts","../src/hooks/use-file-download.ts","../src/hooks/use-file-read.ts","../src/hooks/use-file-transfer.ts","../src/hooks/use-home-dir.ts","../src/hooks/use-session-restore.ts","../src/hooks/use-shortcuts.ts","../src/hooks/use-terminal-restore.ts","../src/lib/promise-with-resolvers.d.ts","../src/lib/connection/connection-store.ts","../src/lib/connection/files-changed.ts","../src/lib/connection/normalize-url.test.ts","../src/lib/connection/normalize-url.ts","../src/lib/connection/query-client.ts","../src/lib/connection/resolve-connect-target.test.ts","../src/lib/connection/resolve-connect-target.ts","../src/lib/connection/rpc-keys.ts","../src/lib/protocol/events.ts","../src/platform/breakpoints.ts","../src/providers/AppProviders.tsx","../src/providers/kv-store.ts","../src/routes/WorkspacePage.tsx","../src/stores/explorer-store.test.ts","../src/stores/explorer-store.ts","../src/stores/git-store.ts","../src/stores/session-store.ts","../src/stores/tab-store.ts","../src/stores/ui-store.ts","../src/theme/ThemeBoundary.tsx","../src/theme/appearance-store.ts","../src/theme/color-utils.ts","../src/theme/colors.ts","../src/theme/css-bridge.ts","../src/theme/index.ts","../src/theme/palette.ts","../src/theme/theme.ts","../src/theme/tokens.ts","../src/theme/variants.ts","../src/timeline/highlight.ts","../src/timeline/markdown.tsx","../src/timeline/reducer.test.ts","../src/timeline/reducer.ts","../src/timeline/row-model.ts","../src/timeline/tool-mapping.test.ts","../src/timeline/tool-mapping.ts","../src/ui/avatar.ts","../src/ui/button.ts","../src/ui/combobox.ts","../src/ui/index.ts","../src/ui/screen-header.ts","../src/ui/shortcut.ts","../src/ui/status-badge.ts","../src/ui/status-dot.ts","../src/ui/toast.ts"],"version":"5.9.3"}
1
+ {"root":["../src/app.tsx","../src/css-modules.d.ts","../src/main.tsx","../src/vite-env.d.ts","../src/brand/brand-logo.ts","../src/brand/config.ts","../src/brand/index.ts","../src/brand/theme-injection.ts","../src/components/primitives/Avatar.tsx","../src/components/primitives/Button.tsx","../src/components/primitives/Checkbox.tsx","../src/components/primitives/Dialog.tsx","../src/components/primitives/Divider.tsx","../src/components/primitives/Icon.tsx","../src/components/primitives/ResizeHandle.tsx","../src/components/primitives/ScreenTitle.tsx","../src/components/primitives/ScrollArea.tsx","../src/components/primitives/Select.tsx","../src/components/primitives/Shortcut.tsx","../src/components/primitives/Spinner.tsx","../src/components/primitives/StatusBadge.tsx","../src/components/primitives/StatusDot.tsx","../src/components/primitives/Surface.tsx","../src/components/primitives/Switch.tsx","../src/components/primitives/TextInput.tsx","../src/components/primitives/helpers.ts","../src/components/primitives/index.ts","../src/components/primitives/useHover.ts","../src/features/chat/Attachments.tsx","../src/features/chat/ChatPanel.tsx","../src/features/chat/Composer.tsx","../src/features/chat/Timeline.tsx","../src/features/chat/rows/AssistantRow.tsx","../src/features/chat/rows/ErrorRow.tsx","../src/features/chat/rows/ReasoningRow.tsx","../src/features/chat/rows/SystemRow.tsx","../src/features/chat/rows/ToolCard.tsx","../src/features/chat/rows/UserRow.tsx","../src/features/connection/ConnectionStatus.tsx","../src/features/connection/Toolbar.tsx","../src/features/files/BinaryFallbackViewer.tsx","../src/features/files/CodeView.tsx","../src/features/files/DiffView.tsx","../src/features/files/FileContextMenu.tsx","../src/features/files/FileExplorer.tsx","../src/features/files/FilePanel.tsx","../src/features/files/ImageViewer.tsx","../src/features/files/MarkdownFileViewer.tsx","../src/features/files/RightSidebar.tsx","../src/features/files/TextViewer.tsx","../src/features/files/TreeNode.tsx","../src/features/files/VideoViewer.tsx","../src/features/files/file-tree.test.ts","../src/features/files/file-tree.ts","../src/features/files/viewer-registry.ts","../src/features/git/ChangesPanel.tsx","../src/features/sessions/SessionContextMenu.tsx","../src/features/sessions/SessionItem.tsx","../src/features/sessions/SessionList.tsx","../src/features/sessions/WorkspaceGroupHeader.tsx","../src/features/sessions/open-workspace.ts","../src/features/sessions/status-map.ts","../src/features/sessions/workspace-grouping.ts","../src/features/terminal/TerminalPanel.tsx","../src/features/workspace/StatusBar.tsx","../src/features/workspace/TabPanelHost.tsx","../src/features/workspace/TabStrip.tsx","../src/features/workspace/panel-registry.ts","../src/features/workspace/status-bar-format.test.ts","../src/features/workspace/status-bar-format.ts","../src/features/workspace-picker/OpenWorkspaceDialog.tsx","../src/hooks/agent-stream-events.test.ts","../src/hooks/agent-stream-events.ts","../src/hooks/file-transfer-instance.ts","../src/hooks/use-agent-stream.ts","../src/hooks/use-checkout-status.ts","../src/hooks/use-connection.ts","../src/hooks/use-explorer-tree.ts","../src/hooks/use-explorer.ts","../src/hooks/use-file-diff.ts","../src/hooks/use-file-download.ts","../src/hooks/use-file-read.ts","../src/hooks/use-file-transfer.ts","../src/hooks/use-home-dir.ts","../src/hooks/use-session-restore.test.ts","../src/hooks/use-session-restore.ts","../src/hooks/use-session-stats.test.ts","../src/hooks/use-session-stats.ts","../src/hooks/use-shortcuts.ts","../src/hooks/use-terminal-restore.ts","../src/lib/promise-with-resolvers.d.ts","../src/lib/connection/connection-store.ts","../src/lib/connection/files-changed.ts","../src/lib/connection/normalize-url.test.ts","../src/lib/connection/normalize-url.ts","../src/lib/connection/query-client.ts","../src/lib/connection/resolve-connect-target.test.ts","../src/lib/connection/resolve-connect-target.ts","../src/lib/connection/rpc-keys.ts","../src/lib/protocol/events.ts","../src/platform/breakpoints.ts","../src/providers/AppProviders.tsx","../src/providers/kv-store.ts","../src/routes/WorkspacePage.tsx","../src/stores/explorer-store.test.ts","../src/stores/explorer-store.ts","../src/stores/git-store.test.ts","../src/stores/git-store.ts","../src/stores/session-store.test.ts","../src/stores/session-store.ts","../src/stores/stats-store.test.ts","../src/stores/stats-store.ts","../src/stores/tab-store.ts","../src/stores/ui-store.ts","../src/theme/ThemeBoundary.tsx","../src/theme/appearance-store.ts","../src/theme/color-utils.ts","../src/theme/colors.ts","../src/theme/css-bridge.ts","../src/theme/index.ts","../src/theme/palette.ts","../src/theme/theme.ts","../src/theme/tokens.ts","../src/theme/variants.ts","../src/timeline/highlight.ts","../src/timeline/markdown.tsx","../src/timeline/reducer.test.ts","../src/timeline/reducer.ts","../src/timeline/row-model.ts","../src/timeline/tool-mapping.test.ts","../src/timeline/tool-mapping.ts","../src/ui/avatar.ts","../src/ui/button.ts","../src/ui/combobox.ts","../src/ui/index.ts","../src/ui/screen-header.ts","../src/ui/shortcut.ts","../src/ui/status-badge.ts","../src/ui/status-dot.ts","../src/ui/toast.ts"],"version":"5.9.3"}
@@ -1,2 +1,2 @@
1
- import{r as l,j as e}from"./vendor-react-BoIQBqDW.js";import{S as m,B as a}from"./index-B_Wls_vp.js";import{u as d}from"./use-file-download-BxA_7HBl.js";import{t as c}from"./vendor-icons-BJD_eLBz.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";const p="_wrap_renwa_1",f="_name_renwa_12",t={wrap:p,name:f};function N({path:s}){const[i,n]=l.useState(!1),r=d(s,i),o=s.split("/").pop()||s;return e.jsxs("div",{className:t.wrap,children:[e.jsx(c,{size:32}),e.jsx("div",{className:t.name,children:o}),e.jsx("div",{children:"No preview available for this file type."}),r.isError&&e.jsxs("div",{children:["Error: ",r.error instanceof Error?r.error.message:"download failed"]}),i&&r.isLoading?e.jsx(m,{size:"sm"}):r.data?e.jsx("a",{href:r.data.objectUrl,download:r.data.fileName||o,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>n(!0),children:"Download"})]})}export{N as BinaryFallbackViewer};
2
- //# sourceMappingURL=BinaryFallbackViewer-DcdvHipL.js.map
1
+ import{r as l,j as e}from"./vendor-react-BoIQBqDW.js";import{S as m,B as a}from"./index-C5SpA_B-.js";import{u as d}from"./use-file-download-t12JJGKT.js";import{y as c}from"./vendor-icons-BouiMPVM.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";const p="_wrap_renwa_1",f="_name_renwa_12",t={wrap:p,name:f};function N({path:s}){const[i,n]=l.useState(!1),r=d(s,i),o=s.split("/").pop()||s;return e.jsxs("div",{className:t.wrap,children:[e.jsx(c,{size:32}),e.jsx("div",{className:t.name,children:o}),e.jsx("div",{children:"No preview available for this file type."}),r.isError&&e.jsxs("div",{children:["Error: ",r.error instanceof Error?r.error.message:"download failed"]}),i&&r.isLoading?e.jsx(m,{size:"sm"}):r.data?e.jsx("a",{href:r.data.objectUrl,download:r.data.fileName||o,children:e.jsx(a,{size:"sm",children:"Save file"})}):e.jsx(a,{size:"sm",onClick:()=>n(!0),children:"Download"})]})}export{N as BinaryFallbackViewer};
2
+ //# sourceMappingURL=BinaryFallbackViewer-HicqzbWd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryFallbackViewer-DcdvHipL.js","sources":["../../../src/features/files/BinaryFallbackViewer.tsx"],"sourcesContent":["/**\n * BinaryFallbackViewer — the registry's catch-all for binary files with no dedicated viewer\n * (archives, executables, unrecognized blobs). No preview is attempted eagerly; a manual\n * \"Download\" action fetches the bytes on demand via `useFileDownload` and saves them locally\n * (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file preview).\n */\n\nimport { useState } from \"react\";\nimport { FileQuestion } from \"lucide-react\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDownload } from \"@pi-studio-ui/hooks/use-file-download.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport styles from \"./BinaryFallbackViewer.module.css\";\n\nexport function BinaryFallbackViewer({ path }: ViewerProps) {\n const [requested, setRequested] = useState(false);\n const query = useFileDownload(path, requested);\n const name = path.split(\"/\").pop() || path;\n\n return (\n <div className={styles.wrap}>\n <FileQuestion size={32} />\n <div className={styles.name}>{name}</div>\n <div>No preview available for this file type.</div>\n {query.isError && (\n <div>Error: {query.error instanceof Error ? query.error.message : \"download failed\"}</div>\n )}\n {requested && query.isLoading ? (\n <Spinner size=\"sm\" />\n ) : query.data ? (\n <a href={query.data.objectUrl} download={query.data.fileName || name}>\n <Button size=\"sm\">Save file</Button>\n </a>\n ) : (\n <Button size=\"sm\" onClick={() => setRequested(true)}>\n Download\n </Button>\n )}\n </div>\n );\n}\n"],"names":["BinaryFallbackViewer","path","requested","setRequested","useState","query","useFileDownload","name","jsxs","styles","jsx","FileQuestion","Spinner","Button"],"mappings":"ydAeO,SAASA,EAAqB,CAAE,KAAAC,GAAqB,CAC1D,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAAA,SAAS,EAAK,EAC1CC,EAAQC,EAAgBL,EAAMC,CAAS,EACvCK,EAAON,EAAK,MAAM,GAAG,EAAE,OAASA,EAEtC,OACEO,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAO,KACrB,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAa,KAAM,EAAA,CAAI,EACxBD,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAO,KAAO,SAAAF,EAAK,EACnCG,EAAAA,IAAC,OAAI,SAAA,0CAAA,CAAwC,EAC5CL,EAAM,SACLG,EAAAA,KAAC,MAAA,CAAI,SAAA,CAAA,UAAQH,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,iBAAA,EAAkB,EAErFH,GAAaG,EAAM,UAClBK,EAAAA,IAACE,EAAA,CAAQ,KAAK,IAAA,CAAK,EACjBP,EAAM,WACP,IAAA,CAAE,KAAMA,EAAM,KAAK,UAAW,SAAUA,EAAM,KAAK,UAAYE,EAC9D,SAAAG,MAACG,EAAA,CAAO,KAAK,KAAK,qBAAS,EAC7B,EAEAH,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAAS,IAAMV,EAAa,EAAI,EAAG,SAAA,UAAA,CAErD,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"BinaryFallbackViewer-HicqzbWd.js","sources":["../../../src/features/files/BinaryFallbackViewer.tsx"],"sourcesContent":["/**\n * BinaryFallbackViewer — the registry's catch-all for binary files with no dedicated viewer\n * (archives, executables, unrecognized blobs). No preview is attempted eagerly; a manual\n * \"Download\" action fetches the bytes on demand via `useFileDownload` and saves them locally\n * (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file preview).\n */\n\nimport { useState } from \"react\";\nimport { FileQuestion } from \"lucide-react\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDownload } from \"@pi-studio-ui/hooks/use-file-download.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport styles from \"./BinaryFallbackViewer.module.css\";\n\nexport function BinaryFallbackViewer({ path }: ViewerProps) {\n const [requested, setRequested] = useState(false);\n const query = useFileDownload(path, requested);\n const name = path.split(\"/\").pop() || path;\n\n return (\n <div className={styles.wrap}>\n <FileQuestion size={32} />\n <div className={styles.name}>{name}</div>\n <div>No preview available for this file type.</div>\n {query.isError && (\n <div>Error: {query.error instanceof Error ? query.error.message : \"download failed\"}</div>\n )}\n {requested && query.isLoading ? (\n <Spinner size=\"sm\" />\n ) : query.data ? (\n <a href={query.data.objectUrl} download={query.data.fileName || name}>\n <Button size=\"sm\">Save file</Button>\n </a>\n ) : (\n <Button size=\"sm\" onClick={() => setRequested(true)}>\n Download\n </Button>\n )}\n </div>\n );\n}\n"],"names":["BinaryFallbackViewer","path","requested","setRequested","useState","query","useFileDownload","name","jsxs","styles","jsx","FileQuestion","Spinner","Button"],"mappings":"ydAeO,SAASA,EAAqB,CAAE,KAAAC,GAAqB,CAC1D,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAAAA,SAAS,EAAK,EAC1CC,EAAQC,EAAgBL,EAAMC,CAAS,EACvCK,EAAON,EAAK,MAAM,GAAG,EAAE,OAASA,EAEtC,OACEO,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAO,KACrB,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAa,KAAM,EAAA,CAAI,EACxBD,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAO,KAAO,SAAAF,EAAK,EACnCG,EAAAA,IAAC,OAAI,SAAA,0CAAA,CAAwC,EAC5CL,EAAM,SACLG,EAAAA,KAAC,MAAA,CAAI,SAAA,CAAA,UAAQH,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,iBAAA,EAAkB,EAErFH,GAAaG,EAAM,UAClBK,EAAAA,IAACE,EAAA,CAAQ,KAAK,IAAA,CAAK,EACjBP,EAAM,WACP,IAAA,CAAE,KAAMA,EAAM,KAAK,UAAW,SAAUA,EAAM,KAAK,UAAYE,EAC9D,SAAAG,MAACG,EAAA,CAAO,KAAK,KAAK,qBAAS,EAC7B,EAEAH,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAAS,IAAMV,EAAa,EAAI,EAAG,SAAA,UAAA,CAErD,CAAA,EAEJ,CAEJ"}
@@ -0,0 +1 @@
1
+ ._badge_jtokc_3{display:inline-flex;align-items:center;justify-content:center;padding:1px 6px;border-radius:9999px;border:1px solid;font-size:var(--pi-font-size-xs, 12px);font-family:var(--pi-font-ui, system-ui, sans-serif);font-weight:500;white-space:nowrap;line-height:1.5}._row_5yddc_3{padding:8px 12px;border-radius:var(--pi-borderRadius-md, 6px);max-width:85%;white-space:pre-wrap;word-break:break-word;line-height:1.5;font-size:13px}._who_5yddc_13{display:block;font-size:10px;color:var(--pi-color-foregroundMuted, #7a8394);margin-bottom:3px;text-transform:uppercase;letter-spacing:.03em}._queuedBadge_5yddc_22{display:inline-flex;align-items:center;gap:2px;margin-left:6px;padding:0 4px;border-radius:3px;font-size:9px;font-weight:600;text-transform:none;letter-spacing:normal;vertical-align:middle;background:#14141873;color:#c7cbd1}._user_5yddc_40{background:var(--pi-color-accentMuted, #1e3a5f);color:var(--pi-color-foreground, #dbe9ff);align-self:flex-end;border-bottom-right-radius:2px}._userPending_5yddc_47{opacity:.6}._userQueued_5yddc_51{opacity:.88}._userFailed_5yddc_55{background:var(--pi-color-destructive, #3a1515);color:var(--pi-color-destructiveForeground, #ff8a80);opacity:1}._userImages_5yddc_61{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}._userImage_5yddc_61{max-width:200px;max-height:150px;border-radius:4px;display:block;object-fit:cover;cursor:pointer}._imageDialog_5yddc_77{max-width:90vw}._imageDialogPreview_5yddc_81{display:block;max-width:90vw;max-height:80vh;object-fit:contain}._assistant_5yddc_90{background:var(--pi-color-surface, #1c1f26);color:var(--pi-color-foreground, #d6dae0);align-self:flex-start;border-bottom-left-radius:2px}._assistant_5yddc_90._streaming_5yddc_97{border-left:2px solid var(--pi-color-accent, #2e5cb8)}._streamingText_5yddc_101{white-space:pre-wrap;word-break:break-word}._cursor_5yddc_106{display:inline-block;margin-left:1px;animation:_blink_5yddc_1 1s step-start infinite;color:var(--pi-color-accentBright, #a2b4d7)}@keyframes _blink_5yddc_1{50%{opacity:0}}._reasoning_5yddc_121{background:var(--pi-color-background, #0f1115);color:var(--pi-color-foregroundMuted, #7a8394);font-style:italic;font-size:12px;align-self:flex-start}._tool_5yddc_131{background:var(--pi-color-surface, #1c1f26);border:1px solid var(--pi-color-border, #2c313b);align-self:flex-start;font-size:12px;max-width:90%;padding:0;overflow:hidden}._toolHeader_5yddc_141{display:flex;align-items:center;gap:6px;width:100%;padding:8px 12px;background:none;border:none;color:inherit;font:inherit;text-align:left;cursor:pointer}._toolHeader_5yddc_141:disabled{cursor:default}._toolChevron_5yddc_159{flex-shrink:0;color:var(--pi-color-foregroundMuted, #7a8394);transition:transform .12s ease}._toolChevronOpen_5yddc_165{transform:rotate(90deg)}._toolInlineDetail_5yddc_169{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pi-color-foregroundMuted, #9aa0a6);font-family:var(--pi-font-mono, ui-monospace, monospace);min-width:0;flex:1}._toolBody_5yddc_179{border-top:1px solid var(--pi-color-border, #2c313b);max-height:420px;overflow:auto}._toolCode_5yddc_185{margin:0;padding:8px 12px;font-family:var(--pi-font-mono, ui-monospace, monospace);font-size:12px;line-height:1.5;white-space:pre-wrap;word-break:break-word;color:var(--pi-color-foreground, #dbe3f0)}._toolIcon_5yddc_196{display:flex;align-items:center;flex-shrink:0}._toolIcon_5yddc_196._running_5yddc_202{color:var(--pi-color-accentBright, #a2b4d7);animation:_pulse_5yddc_1 1.2s ease-in-out infinite}._toolIcon_5yddc_196._completed_5yddc_207{color:var(--pi-color-statusSuccess, #27ae60)}._toolIcon_5yddc_196._error_5yddc_211{color:var(--pi-color-statusDanger, #c0392b)}@keyframes _pulse_5yddc_1{50%{opacity:.5}}._toolLabel_5yddc_221{font-weight:600;text-transform:capitalize}._toolBadge_5yddc_226{margin-left:auto}._error_5yddc_211{background:var(--pi-color-destructive, #3a1515);color:var(--pi-color-destructiveForeground, #ff8a80);align-self:flex-start}._system_5yddc_239{background:transparent;color:var(--pi-color-foregroundMuted, #7a8394);font-style:italic;align-self:flex-start;padding:4px 12px}._viewport_1byko_3{flex:1 1 auto;overflow-y:auto;min-height:0;padding:16px 20px}._inner_1byko_10{position:relative;width:100%}._rowWrap_1byko_15{position:absolute;top:0;left:0;width:100%;display:flex;flex-direction:column;padding-bottom:4px}._empty_1byko_25{display:flex;align-items:center;justify-content:center;height:100%;color:var(--pi-color-foregroundMuted, #7a8394);font-size:13px}._working_1byko_34{display:flex;align-items:center;gap:8px;padding:8px 2px 4px;color:var(--pi-color-foregroundMuted, #7a8394);font-size:13px}._workingDots_1byko_43{display:inline-flex;gap:4px}._workingDots_1byko_43 span{width:6px;height:6px;border-radius:50%;background:var(--pi-color-accentBright, #a2b4d7);animation:_workingBounce_1byko_1 1.2s ease-in-out infinite}._workingDots_1byko_43 span:nth-child(2){animation-delay:.16s}._workingDots_1byko_43 span:nth-child(3){animation-delay:.32s}@keyframes _workingBounce_1byko_1{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}._strip_5sm81_4{display:flex;gap:6px;flex-wrap:wrap;padding:6px 0 0}._thumb_5sm81_11{position:relative;width:48px;height:48px;border-radius:4px;overflow:hidden;border:1px solid var(--pi-color-border, #2c313b);flex-shrink:0}._thumb_5sm81_11 img{width:100%;height:100%;object-fit:cover;display:block}._remove_5sm81_28{position:absolute;top:-2px;right:-2px;width:16px;height:16px;background:var(--pi-color-statusDanger, #c0392b);color:#fff;border:none;border-radius:50%;font-size:10px;line-height:16px;text-align:center;cursor:pointer;padding:0}._composer_1cudo_1{padding:10px 16px;border-top:1px solid var(--pi-color-border, #2c313b);background:var(--pi-color-surface, #14161a);display:flex;gap:8px;align-items:center;flex-shrink:0}._inputArea_1cudo_13{flex:1;display:flex;flex-direction:column;gap:0;min-width:0}._textarea_1cudo_21{resize:none;min-height:38px;max-height:160px;overflow-y:auto}._attachBtn_1cudo_28{flex-shrink:0}._hiddenFileInput_1cudo_32{display:none}._actions_1cudo_36{display:flex;flex-direction:row;gap:4px;flex-shrink:0}._panel_12s9l_1{display:flex;flex-direction:column;height:100%;min-height:0}._empty_12s9l_8{display:flex;align-items:center;justify-content:center;height:100%;color:var(--pi-color-foregroundMuted, #7a8394);font-size:13px}
@@ -0,0 +1,3 @@
1
+ import{j as t,r as m}from"./vendor-react-BoIQBqDW.js";import{c as U,d as re,m as ae}from"./vendor-query-AtKBh_Yt.js";import{t as H,u as x,a as L,D as oe,T as ie,B as S}from"./index-C5SpA_B-.js";import{o as ce,p as le,q as de,r as ue,s as me,t as ge,T as K,C as pe,u as _e,v as fe,N as he,w as xe,x as ye}from"./vendor-icons-BouiMPVM.js";import{M as Q}from"./markdown-D9FuaV1m.js";import{C as $}from"./vendor--os7hw7d.js";import{D as je}from"./DiffView-DlVCPvLc.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-markdown-B8HSIhaA.js";const ve="_badge_jtokc_3",ke={badge:ve};function be(e){switch(e){case"success":return{token:"statusSuccess"};case"error":return{token:"statusDanger"};case"muted":return{token:"foregroundMuted"}}}function we({label:e,variant:s,className:n}){const{token:i}=be(s),o=`var(--pi-color-${i})`;return t.jsx("span",{className:`${ke.badge}${n?` ${n}`:""}`,style:{backgroundColor:`color-mix(in srgb, ${o} 18%, transparent)`,borderColor:`color-mix(in srgb, ${o} 45%, transparent)`,color:o},children:e})}const Ne={shell:K,read:ge,edit:me,write:ue,search:de,fetch:le,task:ce};function Ie(e){return Ne[e.kind]??K}function Se(e){return e.kind}function Ce(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function De(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function Te(e){const s=[];if(e.kind==="edit"&&e.diff)s.push({kind:"diff",patch:e.diff});else{const n=H(e);n&&s.push({kind:"code",text:n})}return e.output&&s.push({kind:"code",text:e.output}),s}function $e(e){const s=H(e);if(!s)return"";switch(e.kind){case"read":case"write":case"edit":{const n=s.split("/");return n[n.length-1]||s}case"shell":return s.split(`
2
+ `,1)[0]??s;default:return s}}const Ee=500;let E;function Be(e,s,n,i){clearTimeout(E),E=setTimeout(()=>{E=void 0,e.invalidateQueries({queryKey:["file"]}),e.invalidateQueries({queryKey:["explorer"]}),s&&n&&s.connection.request("checkout_refresh_request",{cwd:n}).catch(()=>{})},Ee)}function Re(e){let s=null;return n=>{if(s===null){if(n.event.kind!=="user_message"||n.event.messageId!==e)return!1;s=n.agentId}return n.agentId===s}}function W({sessionId:e,event:s,client:n,queryClient:i}){const o=x.getState();switch(o.applyStreamEvent(e,s),s.kind){case"turn_started":o.setStatus(e,"running");break;case"turn_completed":o.setStatus(e,"idle");break;case"turn_failed":o.setStatus(e,"error");break;case"turn_canceled":o.setStatus(e,"idle");break;case"tool_call":{if(s.status==="completed"&&De(s.tool)){const c=o.sessions[e],d=(c==null?void 0:c.cwd)||null;Be(i,n,d,Ce(s.tool))}break}}}function Ae(e){const s=L(o=>o.client),n=x(o=>{var c;return((c=o.sessions[e])==null?void 0:c.agentId)??null}),i=U();m.useEffect(()=>!s||!n?void 0:s.agent(n).timeline.subscribe(c=>{W({sessionId:e,event:c,client:s,queryClient:i})}),[s,n,e,i])}const Fe="_row_5yddc_3",Pe="_who_5yddc_13",ze="_queuedBadge_5yddc_22",Oe="_user_5yddc_40",qe="_userPending_5yddc_47",Me="_userQueued_5yddc_51",Ue="_userFailed_5yddc_55",He="_userImages_5yddc_61",Le="_userImage_5yddc_61",Ke="_imageDialog_5yddc_77",Qe="_imageDialogPreview_5yddc_81",We="_assistant_5yddc_90",Ge="_streaming_5yddc_97",Ve="_streamingText_5yddc_101",Xe="_cursor_5yddc_106",Ye="_blink_5yddc_1",Je="_reasoning_5yddc_121",Ze="_tool_5yddc_131",et="_toolHeader_5yddc_141",tt="_toolChevron_5yddc_159",st="_toolChevronOpen_5yddc_165",nt="_toolInlineDetail_5yddc_169",rt="_toolBody_5yddc_179",at="_toolCode_5yddc_185",ot="_toolIcon_5yddc_196",it="_running_5yddc_202",ct="_pulse_5yddc_1",lt="_completed_5yddc_207",dt="_error_5yddc_211",ut="_toolLabel_5yddc_221",mt="_toolBadge_5yddc_226",gt="_system_5yddc_239",r={row:Fe,who:Pe,queuedBadge:ze,user:Oe,userPending:qe,userQueued:Me,userFailed:Ue,userImages:He,userImage:Le,imageDialog:Ke,imageDialogPreview:Qe,assistant:We,streaming:Ge,streamingText:Ve,cursor:Xe,blink:Ye,reasoning:Je,tool:Ze,toolHeader:et,toolChevron:tt,toolChevronOpen:st,toolInlineDetail:nt,toolBody:rt,toolCode:at,toolIcon:ot,running:it,pulse:ct,completed:lt,error:dt,toolLabel:ut,toolBadge:mt,system:gt};function pt({row:e}){return t.jsxs("div",{className:`${r.row} ${r.assistant}${e.streaming?` ${r.streaming}`:""}`,children:[t.jsx("span",{className:r.who,children:"assistant"}),e.streaming?t.jsxs("span",{className:r.streamingText,children:[e.text,t.jsx("span",{className:r.cursor,children:"▍"})]}):t.jsx(Q,{text:e.text})]})}function _t({row:e}){return t.jsxs("div",{className:`${r.row} ${r.reasoning}`,children:[t.jsx("span",{className:r.who,children:"thinking"}),e.streaming?t.jsxs("span",{className:r.streamingText,children:[e.text,t.jsx("span",{className:r.cursor,children:"▍"})]}):t.jsx(Q,{text:e.text})]})}const ft={running:"muted",completed:"success",error:"error"};function ht({row:e}){const[s,n]=m.useState(!1),i=Ie(e.tool),o=$e(e.tool),c=Te(e.tool),d=c.length>0;return t.jsxs("div",{className:$(r.row,r.tool),children:[t.jsxs("button",{type:"button",className:r.toolHeader,onClick:()=>d&&n(u=>!u),"aria-expanded":d?s:void 0,disabled:!d,children:[d&&t.jsx(pe,{size:12,className:$(r.toolChevron,s&&r.toolChevronOpen)}),t.jsx("span",{className:$(r.toolIcon,r[e.status]),children:t.jsx(i,{size:14})}),t.jsx("span",{className:r.toolLabel,children:Se(e.tool)}),o&&t.jsx("span",{className:r.toolInlineDetail,title:o,children:o}),t.jsx(we,{className:r.toolBadge,label:e.status,variant:ft[e.status]})]}),s&&d&&t.jsx("div",{className:r.toolBody,children:c.map((u,l)=>u.kind==="diff"?t.jsx(je,{patch:u.patch},l):t.jsx("pre",{className:r.toolCode,children:u.text},l))})]})}function xt({row:e}){const[s,n]=m.useState(null),i=e.failed?r.userFailed:e.pending?r.userPending:e.queued?r.userQueued:"";return t.jsxs("div",{className:`${r.row} ${r.user}${i?` ${i}`:""}`,children:[t.jsxs("span",{className:r.who,children:["you",e.failed?" · failed to send":"",e.queued&&!e.failed&&t.jsxs("span",{className:r.queuedBadge,children:[t.jsx(_e,{size:9}),"queued"]})]}),e.text,e.images&&e.images.length>0&&t.jsx("div",{className:r.userImages,children:e.images.map((o,c)=>{const d=`data:${o.mimeType??"image/png"};base64,${o.data??""}`;return t.jsx("img",{className:r.userImage,src:d,alt:"",role:"button",tabIndex:0,onClick:()=>n(d),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&n(d)}},c)})}),t.jsx(oe,{open:s!==null,onOpenChange:o=>{o||n(null)},title:"Image",width:"auto",bare:!0,className:r.imageDialog,children:s&&t.jsx("img",{className:r.imageDialogPreview,src:s,alt:""})})]})}function yt({row:e}){return t.jsxs("div",{className:`${r.row} ${r.error}`,children:[t.jsx("span",{className:r.who,children:"error"}),e.text]})}function jt({row:e}){return t.jsx("div",{className:`${r.row} ${r.system}`,children:e.text})}const vt="_viewport_1byko_3",kt="_inner_1byko_10",bt="_rowWrap_1byko_15",wt="_empty_1byko_25",Nt="_working_1byko_34",It="_workingDots_1byko_43",f={viewport:vt,inner:kt,rowWrap:bt,empty:wt,working:Nt,workingDots:It},St=40;function Ct(e){switch(e.kind){case"user":return t.jsx(xt,{row:e});case"assistant":return t.jsx(pt,{row:e});case"reasoning":return t.jsx(_t,{row:e});case"tool":return t.jsx(ht,{row:e});case"error":return t.jsx(yt,{row:e});case"system":return t.jsx(jt,{row:e})}}function Dt({session:e}){const s=e.timeline.rows,n=e.status==="running",i=m.useRef(null),o=m.useRef(!0),c=m.useRef(0),d=re({count:s.length,getScrollElement:()=>i.current,estimateSize:()=>48,overscan:8,getItemKey:l=>{var g;return((g=s[l])==null?void 0:g.id)??l},measureElement:(l,g,_)=>{if(l.offsetParent!==null)return ae(l,g,_);const v=_.indexFromElement(l),N=_.options.getItemKey(v);return _.itemSizeCache.get(N)??_.options.estimateSize(v)}});function u(){const l=i.current;if(!l)return;const g=l.scrollHeight-l.scrollTop-l.clientHeight;o.current=g<St}return m.useEffect(()=>{const l=s.length>c.current;c.current=s.length,l&&o.current&&d.scrollToIndex(s.length-1,{align:"end"})},[s.length,d]),s.length===0?t.jsx("div",{className:f.viewport,ref:i,children:n?t.jsxs("div",{className:f.working,role:"status","aria-live":"polite",children:[t.jsxs("span",{className:f.workingDots,"aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),"Agent is working…"]}):t.jsx("div",{className:f.empty,children:"No messages yet — say something to start."})}):t.jsxs("div",{className:f.viewport,ref:i,onScroll:u,children:[t.jsx("div",{className:f.inner,style:{height:d.getTotalSize()},children:d.getVirtualItems().map(l=>{const g=s[l.index];return g?t.jsx("div",{ref:d.measureElement,"data-index":l.index,className:f.rowWrap,style:{transform:`translateY(${l.start}px)`},children:Ct(g)},l.key):null})}),n&&t.jsxs("div",{className:f.working,role:"status","aria-live":"polite",children:[t.jsxs("span",{className:f.workingDots,"aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),"Agent is working…"]})]})}const Tt="_strip_5sm81_4",$t="_thumb_5sm81_11",Et="_remove_5sm81_28",B={strip:Tt,thumb:$t,remove:Et};function Bt({images:e,onRemove:s}){return e.length===0?null:t.jsx("div",{className:B.strip,children:e.map((n,i)=>t.jsxs("div",{className:B.thumb,children:[t.jsx("img",{src:n.thumbUrl,alt:""}),t.jsx("button",{type:"button",className:B.remove,title:"Remove",onClick:()=>s(i),children:"×"})]},i))})}function Rt(e){const{promise:s,resolve:n,reject:i}=Promise.withResolvers(),o=new FileReader;return o.onload=()=>{const c=o.result;if(typeof c!="string"){i(new Error("Unexpected FileReader result"));return}const d=c.indexOf(","),u=d>=0?c.slice(d+1):c;n({mimeType:e.type,data:u,thumbUrl:c})},o.onerror=()=>i(o.error??new Error("Failed to read file")),o.readAsDataURL(e),s}const At="_composer_1cudo_1",Ft="_inputArea_1cudo_13",Pt="_textarea_1cudo_21",zt="_attachBtn_1cudo_28",Ot="_hiddenFileInput_1cudo_32",qt="_actions_1cudo_36",b={composer:At,inputArea:Ft,textarea:Pt,attachBtn:zt,hiddenFileInput:Ot,actions:qt},Mt=160;function M(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Mt)}px`}function Ut(e){return typeof e!="object"||e===null||!("type"in e)||e.type!=="agent_stream"?!1:"agentId"in e&&typeof e.agentId=="string"&&"event"in e}function Ht(e){return typeof e=="object"&&e!==null&&"ok"in e&&e.ok===!1}function Lt({sessionId:e}){const s=L(a=>a.client),n=x(a=>a.sessions[e]),i=x(a=>a.bindAgent),o=x(a=>a.addOptimisticUserMessage),c=x(a=>a.markUserMessageFailed),d=x(a=>a.setCwd),u=U(),[l,g]=m.useState(""),[_,v]=m.useState([]),[N,G]=m.useState(!1),[A,V]=m.useState(!1),C=m.useRef(null),F=m.useRef(null),w=(n==null?void 0:n.status)==="running",P=!!s&&!(w?A:N)&&(l.trim().length>0||_.length>0);async function z(a){if(a.type.startsWith("image/"))try{const p=await Rt(a);v(h=>[...h,p])}catch{}}function X(a){for(const p of a.target.files??[])z(p);a.target.value=""}function Y(a){for(const p of a.clipboardData.items)if(p.type.startsWith("image/")){a.preventDefault();const h=p.getAsFile();h&&z(h)}}function J(a){v(p=>p.filter((h,k)=>k!==a))}function Z(a){g(a.target.value),M(a.target)}function ee(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),D(w?"steer":"send"))}async function D(a){if(!s||!n||(a==="steer"?A:N)||a==="steer"&&!n.agentId)return;const p=l.trim();if(!p&&_.length===0)return;g(""),C.current&&M(C.current);const h=_;v([]);const k=p||"Describe this image",I=h.length>0?h.map(j=>({mimeType:j.mimeType,data:j.data})):void 0,y=crypto.randomUUID();o(e,y,k,I,a==="steer");const O=a==="steer"?V:G;O(!0);try{if(a==="steer"){const j=await s.agent(n.agentId).steer(k,{clientMessageId:y,images:I});Ht(j)&&c(e,y)}else if(n.agentId)await s.agent(n.agentId).send(k,{clientMessageId:y,images:I});else{const j=n.cwd||"~";d(e,j);const se=Re(y),ne=s.connection.onSessionMessage(T=>{!Ut(T)||!se(T)||W({sessionId:e,event:T.event,client:s,queryClient:u})});let q;try{q=await s.createAgent({config:{provider:"pi",cwd:j},initialPrompt:k,clientMessageId:y,images:I,labels:{}})}finally{ne()}i(e,q.agentId)}}catch{c(e,y)}finally{O(!1)}}function te(){n!=null&&n.agentId&&(s==null||s.agent(n.agentId).interrupt())}return t.jsxs("div",{className:b.composer,children:[t.jsxs("div",{className:b.inputArea,children:[t.jsx(ie,{ref:C,className:b.textarea,rows:1,value:l,placeholder:w?"Steer the running turn… (Enter to steer, Shift+Enter for newline)":"Ask anything… (Enter to send, Shift+Enter for newline)",onChange:Z,onKeyDown:ee,onPaste:Y}),t.jsx(Bt,{images:_,onRemove:J})]}),t.jsx(S,{className:b.attachBtn,variant:"ghost",size:"md",iconOnly:!0,title:"Attach image",onClick:()=>{var a;return(a=F.current)==null?void 0:a.click()},children:t.jsx(fe,{size:16})}),t.jsx("input",{ref:F,className:b.hiddenFileInput,type:"file",accept:"image/*",multiple:!0,onChange:X}),t.jsxs("div",{className:b.actions,children:[w?t.jsx(S,{size:"sm",disabled:!P,onClick:()=>void D("steer"),leftIcon:t.jsx(he,{size:14}),children:"Steer"}):t.jsx(S,{size:"sm",disabled:!P,onClick:()=>void D("send"),leftIcon:t.jsx(xe,{size:14}),children:"Send"}),w&&t.jsx(S,{size:"sm",variant:"destructive",onClick:te,leftIcon:t.jsx(ye,{size:14}),children:"Stop"})]})]})}const Kt="_panel_12s9l_1",Qt="_empty_12s9l_8",R={panel:Kt,empty:Qt};function as({tab:e}){const{sessionId:s}=e.data,n=x(i=>i.sessions[s]);return Ae(s),n?t.jsxs("div",{className:R.panel,children:[t.jsx(Dt,{session:n}),t.jsx(Lt,{sessionId:n.id})]}):t.jsx("div",{className:R.panel,children:t.jsx("div",{className:R.empty,children:"Session not found."})})}export{as as ChatPanel};
3
+ //# sourceMappingURL=ChatPanel-XI36Imum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatPanel-XI36Imum.js","sources":["../../../src/ui/status-badge.ts","../../../src/components/primitives/StatusBadge.tsx","../../../src/timeline/tool-mapping.ts","../../../src/lib/connection/files-changed.ts","../../../src/hooks/agent-stream-events.ts","../../../src/hooks/use-agent-stream.ts","../../../src/features/chat/rows/AssistantRow.tsx","../../../src/features/chat/rows/ReasoningRow.tsx","../../../src/features/chat/rows/ToolCard.tsx","../../../src/features/chat/rows/UserRow.tsx","../../../src/features/chat/rows/ErrorRow.tsx","../../../src/features/chat/rows/SystemRow.tsx","../../../src/features/chat/Timeline.tsx","../../../src/features/chat/Attachments.tsx","../../../src/features/chat/Composer.tsx","../../../src/features/chat/ChatPanel.tsx"],"sourcesContent":["// StatusBadge + Alert variant contracts.\n// ui-components.md § Surfaces / badges / chips / avatars\n\nexport type StatusBadgeVariant = \"success\" | \"error\" | \"muted\";\n\n// Single semantic token per variant — text color AND a translucent tint of the SAME token as\n// background (matches `ChangesPanel.module.css`'s `.added`/`.modified`/`.deleted` convention).\n// Never split bg/border/text across different token families (e.g. `success` vs `statusSuccess`)\n// — they can diverge in the theme (dark mode's `success` aliases the blue accent, not green),\n// producing a badge with mismatched border/background colors.\nexport type BadgeTokens = {\n token: string;\n};\n\nexport function statusBadgeTokens(variant: StatusBadgeVariant): BadgeTokens {\n switch (variant) {\n case \"success\":\n return { token: \"statusSuccess\" };\n case \"error\":\n return { token: \"statusDanger\" };\n case \"muted\":\n return { token: \"foregroundMuted\" };\n }\n}\n\nexport type AlertVariant = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport type AlertIconInfo = {\n /** Lucide icon name string for the alert variant. */\n icon: string;\n /** Theme token key for the icon/border/title accent color. */\n accentToken: string;\n};\n\nexport function alertIconInfo(variant: AlertVariant): AlertIconInfo {\n switch (variant) {\n case \"default\":\n return { icon: \"info\", accentToken: \"foregroundMuted\" };\n case \"info\":\n return { icon: \"info\", accentToken: \"accent\" };\n case \"success\":\n return { icon: \"check-circle\", accentToken: \"success\" };\n case \"warning\":\n return { icon: \"triangle-alert\", accentToken: \"statusWarning\" };\n case \"error\":\n return { icon: \"circle-x\", accentToken: \"destructive\" };\n }\n}\n\n// AttachmentPill remove-button visibility — mirrors hover-to-show pattern.\nexport function attachmentPillRemoveVisible(\n isNativeCtx: boolean,\n isCompact: boolean,\n hovered: boolean,\n): boolean {\n return isNativeCtx || isCompact || hovered;\n}\n","/**\n * StatusBadge — small rounded pill with variant coloring.\n * ui-components.md § Surfaces / badges / chips / avatars\n */\n\nimport { type ReactNode } from \"react\";\nimport styles from \"./StatusBadge.module.css\";\nimport { statusBadgeTokens, type StatusBadgeVariant } from \"@pi-studio-ui/ui/status-badge.js\";\n\nexport interface StatusBadgeProps {\n label: ReactNode;\n variant: StatusBadgeVariant;\n className?: string;\n}\n\nexport function StatusBadge({ label, variant, className }: StatusBadgeProps) {\n const { token } = statusBadgeTokens(variant);\n const color = `var(--pi-color-${token})`;\n return (\n <span\n className={`${styles.badge}${className ? ` ${className}` : \"\"}`}\n style={{\n backgroundColor: `color-mix(in srgb, ${color} 18%, transparent)`,\n borderColor: `color-mix(in srgb, ${color} 45%, transparent)`,\n color,\n }}\n >\n {label}\n </span>\n );\n}\n","/**\n * tool.kind → display label + icon. Scoped to the protocol's `ToolCallDetail` union\n * (shell/read/edit/write/search/fetch/task) — POC_TO_APP_PLAN_UI.md §3 `timeline/tool-mapping.ts`.\n */\n\nimport type { ToolCallDetail } from \"@av-pi-studio/protocol\";\nimport {\n Terminal,\n Eye,\n Pencil,\n FilePlus,\n Search,\n Globe,\n ListTree,\n type LucideIcon,\n} from \"lucide-react\";\nimport { toolDetailText } from \"./row-model.js\";\n\nconst ICON_BY_KIND: Record<ToolCallDetail[\"kind\"], LucideIcon> = {\n shell: Terminal,\n read: Eye,\n edit: Pencil,\n write: FilePlus,\n search: Search,\n fetch: Globe,\n task: ListTree,\n};\n\nexport function toolIcon(tool: ToolCallDetail): LucideIcon {\n return ICON_BY_KIND[tool.kind] ?? Terminal;\n}\n\n/** Human label for a tool card header, e.g. \"shell\", \"edit\". */\nexport function toolLabel(tool: ToolCallDetail): string {\n return tool.kind;\n}\n\n/** One-line detail summary for a tool card (POC: `t.command || t.path || t.query || …`). */\nexport function toolSummary(tool: ToolCallDetail): string {\n return toolDetailText(tool);\n}\n\n/** File path a tool touched, if any — used to target `filesChanged` invalidation (§4.5). */\nexport function toolFilePath(tool: ToolCallDetail): string | null {\n switch (tool.kind) {\n case \"read\":\n case \"write\":\n case \"edit\":\n return tool.path ?? null;\n default:\n return null;\n }\n}\n\n/** True for tool kinds whose completion should invalidate open file/diff/explorer/git queries. */\nexport function toolMutatesFiles(tool: ToolCallDetail): boolean {\n return tool.kind === \"write\" || tool.kind === \"edit\" || tool.kind === \"shell\";\n}\n\n/**\n * Expandable detail body for a tool card, as an ordered list of sections. `diff` renders as a\n * `<DiffView>`; `code` renders in a monospace block. Order: input detail (command/path/query/…)\n * first, then tool output (stdout, file content, etc.) if present. Empty array = header-only card\n * with nothing worth expanding.\n */\nexport type ToolBodySection = { kind: \"diff\"; patch: string } | { kind: \"code\"; text: string };\n\nexport function toolBody(tool: ToolCallDetail): ToolBodySection[] {\n const sections: ToolBodySection[] = [];\n if (tool.kind === \"edit\" && tool.diff) sections.push({ kind: \"diff\", patch: tool.diff });\n else {\n const text = toolDetailText(tool);\n if (text) sections.push({ kind: \"code\", text });\n }\n if (tool.output) sections.push({ kind: \"code\", text: tool.output });\n return sections;\n}\n\n/** Concise inline label shown in the collapsed header (basename for paths, first line for commands). */\nexport function toolInlineDetail(tool: ToolCallDetail): string {\n const text = toolDetailText(tool);\n if (!text) return \"\";\n switch (tool.kind) {\n case \"read\":\n case \"write\":\n case \"edit\": {\n const parts = text.split(\"/\");\n return parts[parts.length - 1] || text;\n }\n case \"shell\": {\n const firstLine = text.split(\"\\n\", 1)[0] ?? text;\n return firstLine;\n }\n default:\n return text;\n }\n}\n","/**\n * `filesChanged` signal — invalidates the file/diff/explorer query caches after a completed\n * write/edit/shell tool call (POC `scheduleFileRefresh`/`reloadOpenFileTabs`, chat.html\n * ~line 1070-1092, POC_TO_APP_PLAN_UI.md §4.3/§4.5/§5). Debounced ~500ms to coalesce a burst of\n * tool completions (POC used `setTimeout(...,600)`/`400`).\n *\n * The daemon does NOT push a `checkout_status_update` automatically after a git-affecting tool\n * completion, so this module also fires an explicit `checkout_refresh_request` for the active\n * cwd — `ChangesPanel`/`FileExplorer` then pick up the resulting push/refetch reactively, since\n * they're already subscribed (`use-checkout-status.ts`) or query-cache-driven (`use-explorer.ts`).\n *\n * NOTE (follow-up, cross-slice): this module only *exports* the invalidation function. The actual\n * call site — wiring this into the timeline reducer's `tool_call` handling on `status:\"completed\"`\n * for `toolMutatesFiles(tool) === true` — belongs to the chat/session-store slice (built in\n * parallel) or the top-level app wiring; do not import/call it from `timeline/reducer.ts` here,\n * that file is a shared contract file owned across slices.\n */\n\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport type { PiStudioClient } from \"@av-pi-studio/client\";\n\nconst DEBOUNCE_MS = 500;\nlet pendingTimer: ReturnType<typeof setTimeout> | undefined;\n\n/**\n * Invalidate file/diff/explorer TanStack Query caches and refresh git status for `cwd`.\n * Debounced: repeated calls within `DEBOUNCE_MS` coalesce into a single invalidation pass.\n *\n * `toolFilePath` is accepted for future path-scoped invalidation (POC `reloadOpenFileTabs`\n * matched by path suffix) but the current pass invalidates the whole `file`/`explorer` query\n * families — TanStack Query dedupes refetches for inactive queries, so this is cheap and correct\n * even when the path is unknown.\n */\nexport function invalidateAfterToolCompletion(\n queryClient: QueryClient,\n client: PiStudioClient | null,\n cwd: string | null,\n _toolFilePath: string | null,\n): void {\n clearTimeout(pendingTimer);\n pendingTimer = setTimeout(() => {\n pendingTimer = undefined;\n void queryClient.invalidateQueries({ queryKey: [\"file\"] });\n void queryClient.invalidateQueries({ queryKey: [\"explorer\"] });\n if (client && cwd) {\n void client.connection.request(\"checkout_refresh_request\", { cwd }).catch(() => {});\n }\n }, DEBOUNCE_MS);\n}\n","/**\n * Shared `AgentStreamEvent` → store-update logic, used both by the live subscription\n * (`use-agent-stream.ts`) and by the live first-turn apply in `Composer.tsx` (see its comment for\n * why: `create_agent_request` blocks until the whole first turn completes, so the timeline is fed\n * from the raw broadcast as events arrive rather than from a not-yet-attached subscription).\n */\n\nimport type { PiStudioClient } from \"@av-pi-studio/client\";\nimport type { AgentStreamEvent } from \"@av-pi-studio/protocol\";\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { toolMutatesFiles, toolFilePath } from \"@pi-studio-ui/timeline/tool-mapping.js\";\nimport { invalidateAfterToolCompletion } from \"@pi-studio-ui/lib/connection/files-changed.js\";\n\nexport interface ApplyAgentStreamEventArgs {\n sessionId: string;\n event: AgentStreamEvent;\n client: PiStudioClient;\n queryClient: QueryClient;\n}\n\n/**\n * Correlates first-turn `agent_stream` broadcasts with the agent a specific `createAgent` call\n * just spawned. `create_agent_request` doesn't resolve with the new `agentId` until the whole\n * first turn completes, so `Composer.handleSend` watches the raw broadcast and applies frames as\n * they arrive — but the socket is shared across every open session, and another session's agent\n * can be mid-turn concurrently. The first `agent_stream` frame observed after subscribing is\n * therefore NOT necessarily this call's own agent. Only latch onto an `agentId` once its\n * canonical `user_message` echo is seen (`messageId === clientMessageId`, minted by this call and\n * echoed back verbatim by the daemon — `agent-service.ts` `runTurn`), then accept only further\n * frames carrying that same `agentId`. Returns a predicate reporting whether a given frame belongs\n * to this turn and should be applied.\n */\nexport function createFirstTurnGate(\n clientMessageId: string,\n): (msg: { agentId: string; event: AgentStreamEvent }) => boolean {\n let liveAgentId: string | null = null;\n return (msg) => {\n if (liveAgentId === null) {\n if (msg.event.kind !== \"user_message\" || msg.event.messageId !== clientMessageId) return false;\n liveAgentId = msg.agentId;\n }\n return msg.agentId === liveAgentId;\n };\n}\n\nexport function applyAgentStreamEvent({\n sessionId,\n event,\n client,\n queryClient,\n}: ApplyAgentStreamEventArgs): void {\n const sessionStore = useSessionStore.getState();\n sessionStore.applyStreamEvent(sessionId, event);\n switch (event.kind) {\n case \"turn_started\":\n sessionStore.setStatus(sessionId, \"running\");\n break;\n case \"turn_completed\":\n sessionStore.setStatus(sessionId, \"idle\");\n break;\n case \"turn_failed\":\n sessionStore.setStatus(sessionId, \"error\");\n break;\n case \"turn_canceled\":\n sessionStore.setStatus(sessionId, \"idle\");\n break;\n case \"tool_call\": {\n if (event.status === \"completed\" && toolMutatesFiles(event.tool)) {\n const session = sessionStore.sessions[sessionId];\n const cwd = session?.cwd || null;\n invalidateAfterToolCompletion(queryClient, client, cwd, toolFilePath(event.tool));\n }\n break;\n }\n default:\n break;\n }\n}\n","/**\n * Live timeline subscription for a chat session. Subscribes to\n * `client.agent(agentId).timeline.subscribe` whenever both the connection's `client` and the\n * session's `agentId` are available, routing every event through `applyAgentStreamEvent`\n * (POC_TO_APP_PLAN_UI.md §4.3). Also mirrors the POC's `handleAgentStream` turn-lifecycle →\n * `session.status` transitions so the Composer's Stop button and the session-list status dot\n * stay live.\n *\n * NOTE: this only covers events that arrive *after* the subscription attaches, which requires a\n * bound `agentId`. The daemon runs the whole first turn of a brand-new agent *before*\n * `create_agent_request` resolves, so `Composer.handleSend` applies that first turn live from the\n * raw broadcast (latching the agent id from the first `agent_stream` frame it sees) and only\n * calls `bindAgent` once the RPC resolves — after the turn is already applied. This hook therefore\n * attaches only in time for *follow-up* turns, which is exactly what avoids double-applying the\n * first turn (the reducer is not event-id-idempotent).\n */\n\nimport { useEffect } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { applyAgentStreamEvent } from \"./agent-stream-events.js\";\n\nexport function useAgentStream(sessionId: string): void {\n const client = useConnectionStore((s) => s.client);\n const agentId = useSessionStore((s) => s.sessions[sessionId]?.agentId ?? null);\n const queryClient = useQueryClient();\n\n useEffect(() => {\n if (!client || !agentId) return;\n\n const unsubscribe = client.agent(agentId).timeline.subscribe((event) => {\n applyAgentStreamEvent({ sessionId, event, client, queryClient });\n });\n\n return unsubscribe;\n }, [client, agentId, sessionId, queryClient]);\n}\n","/**\n * Assistant message row (POC `.msg.assistant`, POC_TO_APP_PLAN_UI.md §4.3). While streaming,\n * renders plain text with a blinking cursor — re-parsing markdown on every token would be\n * wasteful (§6 Performance strategy). Once `turn_completed` finalizes the row (`streaming:\n * false`), it renders through `<Markdown>`.\n */\n\nimport type { AssistantRow as AssistantRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface AssistantRowProps {\n row: AssistantRowModel;\n}\n\nexport function AssistantRow({ row }: AssistantRowProps) {\n return (\n <div className={`${styles.row} ${styles.assistant}${row.streaming ? ` ${styles.streaming}` : \"\"}`}>\n <span className={styles.who}>assistant</span>\n {row.streaming ? (\n <span className={styles.streamingText}>\n {row.text}\n <span className={styles.cursor}>▍</span>\n </span>\n ) : (\n <Markdown text={row.text} />\n )}\n </div>\n );\n}\n","/**\n * Reasoning row — dimmer/italic styling, visually distinct from assistant replies (POC\n * `.msg.reasoning`, POC_TO_APP_PLAN_UI.md §4.3). Streams as plain text with a cursor, same\n * rationale as `AssistantRow`.\n */\n\nimport type { ReasoningRow as ReasoningRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ReasoningRowProps {\n row: ReasoningRowModel;\n}\n\nexport function ReasoningRow({ row }: ReasoningRowProps) {\n return (\n <div className={`${styles.row} ${styles.reasoning}`}>\n <span className={styles.who}>thinking</span>\n {row.streaming ? (\n <span className={styles.streamingText}>\n {row.text}\n <span className={styles.cursor}>▍</span>\n </span>\n ) : (\n <Markdown text={row.text} />\n )}\n </div>\n );\n}\n","/**\n * Tool call card — icon + label + inline detail + status badge header, with an expandable body\n * (POC `.msg.tool`, POC_TO_APP_PLAN_UI.md §4.3). Collapsed by default; clicking the header reveals\n * the full detail as an ordered list of sections: input detail (`edit` diffs render through the\n * shared `<DiffView>`; shell command/path/query/url/task description render in a monospace block)\n * followed by tool output (stdout, file content, etc.), when present. Cards with no expandable\n * sections (`toolBody` → `[]`) show only the header. The virtualized timeline re-measures on\n * expand via `measureElement`, so height changes need no special handling here.\n */\n\nimport { useState } from \"react\";\nimport { ChevronRight } from \"lucide-react\";\nimport { clsx } from \"clsx\";\nimport { StatusBadge } from \"@pi-studio-ui/components/primitives/StatusBadge.js\";\nimport { DiffView } from \"@pi-studio-ui/features/files/DiffView.js\";\nimport { toolIcon, toolLabel, toolInlineDetail, toolBody } from \"@pi-studio-ui/timeline/tool-mapping.js\";\nimport type { ToolRow } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ToolCardProps {\n row: ToolRow;\n}\n\nconst BADGE_VARIANT = {\n running: \"muted\",\n completed: \"success\",\n error: \"error\",\n} as const;\n\nexport function ToolCard({ row }: ToolCardProps) {\n const [expanded, setExpanded] = useState(false);\n const Icon = toolIcon(row.tool);\n const inlineDetail = toolInlineDetail(row.tool);\n const body = toolBody(row.tool);\n const hasBody = body.length > 0;\n\n return (\n <div className={clsx(styles.row, styles.tool)}>\n <button\n type=\"button\"\n className={styles.toolHeader}\n onClick={() => hasBody && setExpanded((v) => !v)}\n aria-expanded={hasBody ? expanded : undefined}\n disabled={!hasBody}\n >\n {hasBody && (\n <ChevronRight\n size={12}\n className={clsx(styles.toolChevron, expanded && styles.toolChevronOpen)}\n />\n )}\n <span className={clsx(styles.toolIcon, styles[row.status])}>\n <Icon size={14} />\n </span>\n <span className={styles.toolLabel}>{toolLabel(row.tool)}</span>\n {inlineDetail && (\n <span className={styles.toolInlineDetail} title={inlineDetail}>\n {inlineDetail}\n </span>\n )}\n <StatusBadge className={styles.toolBadge} label={row.status} variant={BADGE_VARIANT[row.status]} />\n </button>\n {expanded && hasBody && (\n <div className={styles.toolBody}>\n {body.map((section, i) =>\n section.kind === \"diff\" ? (\n <DiffView key={i} patch={section.patch} />\n ) : (\n <pre key={i} className={styles.toolCode}>\n {section.text}\n </pre>\n ),\n )}\n </div>\n )}\n </div>\n );\n}\n","/**\n * User message row — plain text + optional image thumbnails (POC `.msg.user`,\n * POC_TO_APP_PLAN_UI.md §4.3/§4.4). Images render at up to 200×150, matching the POC's inline\n * `userBubble.appendChild(img)` styling. Clicking a thumbnail opens it full-size in a `Dialog`.\n *\n * `row.pending` (optimistic echo not yet confirmed by the server's `user_message` broadcast —\n * see Composer.tsx) dims the row via CSS; `row.failed` (the RPC rejected before confirmation\n * ever arrived) tints it toward the error color and appends a \"failed to send\" label instead.\n * `row.queued` (steered mid-turn, not yet handed to the LLM — cleared by a `queue_update` stream\n * event, see `timeline/reducer.ts`'s `onQueueUpdate`) shows a small \"queued\" pill next to the\n * sender label. All three are terminal/transient states set by the reducer — this component only\n * reflects them.\n */\n\nimport { useState } from \"react\";\nimport { Clock } from \"lucide-react\";\nimport { Dialog } from \"@pi-studio-ui/components/primitives/Dialog.js\";\nimport type { UserRow as UserRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface UserRowProps {\n row: UserRowModel;\n}\n\nexport function UserRow({ row }: UserRowProps) {\n const [openedSrc, setOpenedSrc] = useState<string | null>(null);\n\n const stateClass = row.failed\n ? styles.userFailed\n : row.pending\n ? styles.userPending\n : row.queued\n ? styles.userQueued\n : \"\";\n\n return (\n <div className={`${styles.row} ${styles.user}${stateClass ? ` ${stateClass}` : \"\"}`}>\n <span className={styles.who}>\n you{row.failed ? \" · failed to send\" : \"\"}\n {row.queued && !row.failed && (\n <span className={styles.queuedBadge}>\n <Clock size={9} />\n queued\n </span>\n )}\n </span>\n {row.text}\n {row.images && row.images.length > 0 && (\n <div className={styles.userImages}>\n {row.images.map((img, i) => {\n const src = `data:${img.mimeType ?? \"image/png\"};base64,${img.data ?? \"\"}`;\n return (\n <img\n key={i}\n className={styles.userImage}\n src={src}\n alt=\"\"\n role=\"button\"\n tabIndex={0}\n onClick={() => setOpenedSrc(src)}\n onKeyDown={(ev) => {\n if (ev.key === \"Enter\" || ev.key === \" \") setOpenedSrc(src);\n }}\n />\n );\n })}\n </div>\n )}\n <Dialog\n open={openedSrc !== null}\n onOpenChange={(open) => {\n if (!open) setOpenedSrc(null);\n }}\n title=\"Image\"\n width=\"auto\"\n bare\n className={styles.imageDialog}\n >\n {openedSrc && <img className={styles.imageDialogPreview} src={openedSrc} alt=\"\" />}\n </Dialog>\n </div>\n );\n}\n","/**\n * Error row — red-tinted block (POC `.msg.err`, POC_TO_APP_PLAN_UI.md §4.3), used for\n * `turn_failed`/`error` stream events.\n */\n\nimport type { ErrorRow as ErrorRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ErrorRowProps {\n row: ErrorRowModel;\n}\n\nexport function ErrorRow({ row }: ErrorRowProps) {\n return (\n <div className={`${styles.row} ${styles.error}`}>\n <span className={styles.who}>error</span>\n {row.text}\n </div>\n );\n}\n","/**\n * System row — muted/italic styling (POC's `turn_canceled` \"(canceled)\" reasoning-styled bubble,\n * POC_TO_APP_PLAN_UI.md §4.3), used for canceled-turn markers and other system notices.\n */\n\nimport type { SystemRow as SystemRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface SystemRowProps {\n row: SystemRowModel;\n}\n\nexport function SystemRow({ row }: SystemRowProps) {\n return <div className={`${styles.row} ${styles.system}`}>{row.text}</div>;\n}\n","/**\n * Virtualized timeline viewport — TanStack Virtual over `session.timeline.rows` with\n * variable-size rows (POC `.chat-area`, POC_TO_APP_PLAN_UI.md §4.3/§6). Auto-scrolls to the\n * bottom on new rows unless the user has scrolled up more than 40px from the bottom; re-sticks\n * whenever the row count grows from a user's own send (POC's forced `scrollTop = scrollHeight`,\n * fixed to respect manual scroll-up).\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { measureElement as measureElementDefault, useVirtualizer } from \"@tanstack/react-virtual\";\nimport type { SessionEntry } from \"@pi-studio-ui/stores/session-store.js\";\nimport type { TimelineRow } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { AssistantRow } from \"./rows/AssistantRow.js\";\nimport { ReasoningRow } from \"./rows/ReasoningRow.js\";\nimport { ToolCard } from \"./rows/ToolCard.js\";\nimport { UserRow } from \"./rows/UserRow.js\";\nimport { ErrorRow } from \"./rows/ErrorRow.js\";\nimport { SystemRow } from \"./rows/SystemRow.js\";\nimport styles from \"./Timeline.module.css\";\n\nexport interface TimelineProps {\n session: SessionEntry;\n}\n\nconst STICK_THRESHOLD_PX = 40;\n\nfunction renderRow(row: TimelineRow) {\n switch (row.kind) {\n case \"user\":\n return <UserRow row={row} />;\n case \"assistant\":\n return <AssistantRow row={row} />;\n case \"reasoning\":\n return <ReasoningRow row={row} />;\n case \"tool\":\n return <ToolCard row={row} />;\n case \"error\":\n return <ErrorRow row={row} />;\n case \"system\":\n return <SystemRow row={row} />;\n }\n}\n\nexport function Timeline({ session }: TimelineProps) {\n const rows = session.timeline.rows;\n const running = session.status === \"running\";\n const scrollRef = useRef<HTMLDivElement>(null);\n const stickToBottomRef = useRef(true);\n // Init to 0 (not `rows.length`) so a freshly-mounted tab with existing history — a brand-new\n // chat tab switch or a session restored from disk — still counts as \"grew\" on its first effect\n // run and scrolls to the last message, instead of opening at the top.\n const prevRowCountRef = useRef(0);\n\n const virtualizer = useVirtualizer({\n count: rows.length,\n getScrollElement: () => scrollRef.current,\n estimateSize: () => 48,\n overscan: 8,\n getItemKey: (index) => rows[index]?.id ?? index,\n // `TabPanelHost` keeps inactive chat tabs mounted under `display:none` rather than\n // unmounting them (so switching tabs preserves scroll position — see its own doc comment).\n // But a `display:none` ancestor collapses every row to a 0×0 border box, and the default\n // `measureElement` would cache that bogus 0 height — shrinking `.inner`'s total height to\n // ~0 and permanently clamping the scroll container's `scrollTop` to 0 in the process, which\n // survives the tab becoming visible again (the browser never un-clamps a scroll offset just\n // because content grows back). Skip the measurement while hidden and keep whatever size is\n // already cached (or the `estimateSize` default on first mount) instead.\n measureElement: (element, entry, instance) => {\n if ((element as HTMLElement).offsetParent !== null) return measureElementDefault(element, entry, instance);\n const index = instance.indexFromElement(element);\n const key = instance.options.getItemKey(index);\n return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);\n },\n });\n\n function handleScroll(): void {\n const el = scrollRef.current;\n if (!el) return;\n const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;\n stickToBottomRef.current = distanceFromBottom < STICK_THRESHOLD_PX;\n }\n\n useEffect(() => {\n const grew = rows.length > prevRowCountRef.current;\n prevRowCountRef.current = rows.length;\n if (!grew) return;\n if (!stickToBottomRef.current) return;\n virtualizer.scrollToIndex(rows.length - 1, { align: \"end\" });\n }, [rows.length, virtualizer]);\n\n if (rows.length === 0) {\n return (\n <div className={styles.viewport} ref={scrollRef}>\n {running ? (\n <div className={styles.working} role=\"status\" aria-live=\"polite\">\n <span className={styles.workingDots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n Agent is working…\n </div>\n ) : (\n <div className={styles.empty}>No messages yet — say something to start.</div>\n )}\n </div>\n );\n }\n\n return (\n <div className={styles.viewport} ref={scrollRef} onScroll={handleScroll}>\n <div className={styles.inner} style={{ height: virtualizer.getTotalSize() }}>\n {virtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n if (!row) return null;\n return (\n <div\n key={virtualRow.key}\n ref={virtualizer.measureElement}\n data-index={virtualRow.index}\n className={styles.rowWrap}\n style={{ transform: `translateY(${virtualRow.start}px)` }}\n >\n {renderRow(row)}\n </div>\n );\n })}\n </div>\n {running && (\n <div className={styles.working} role=\"status\" aria-live=\"polite\">\n <span className={styles.workingDots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n Agent is working…\n </div>\n )}\n </div>\n );\n}\n","/**\n * Attachment preview strip — presentational thumbnail row with remove buttons (POC\n * `renderAttachments`, POC_TO_APP_PLAN_UI.md §4.4). Pending-image state lives in `Composer`;\n * this component only renders `images` and forwards `onRemove(index)`.\n */\n\nimport styles from \"./Attachments.module.css\";\n\nexport interface PendingImage {\n mimeType: string;\n /** Base64 payload, no `data:...;base64,` prefix — sent to the daemon as-is. */\n data: string;\n /** Full data URL, for the thumbnail `<img src>`. */\n thumbUrl: string;\n}\n\nexport interface AttachmentsProps {\n images: PendingImage[];\n onRemove: (index: number) => void;\n}\n\nexport function Attachments({ images, onRemove }: AttachmentsProps) {\n if (images.length === 0) return null;\n\n return (\n <div className={styles.strip}>\n {images.map((img, i) => (\n <div key={i} className={styles.thumb}>\n <img src={img.thumbUrl} alt=\"\" />\n <button\n type=\"button\"\n className={styles.remove}\n title=\"Remove\"\n onClick={() => onRemove(i)}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n );\n}\n\n/** `FileReader.readAsDataURL` wrapped as a promise (POC `addImageFile`). */\nexport function readImageFile(file: File): Promise<PendingImage> {\n const { promise, resolve, reject } = Promise.withResolvers<PendingImage>();\n const reader = new FileReader();\n reader.onload = () => {\n const result = reader.result;\n if (typeof result !== \"string\") {\n reject(new Error(\"Unexpected FileReader result\"));\n return;\n }\n const commaIndex = result.indexOf(\",\");\n const data = commaIndex >= 0 ? result.slice(commaIndex + 1) : result;\n resolve({ mimeType: file.type, data, thumbUrl: result });\n };\n reader.onerror = () => reject(reader.error ?? new Error(\"Failed to read file\"));\n reader.readAsDataURL(file);\n return promise;\n}\n","/**\n * Composer — autosizing textarea + attach/send/stop (POC `initChatPanel`/`send()`,\n * POC_TO_APP_PLAN_UI.md §4.4). Send routing: no `agentId` yet → `client.createAgent(...)` then\n * `sessionStore.bindAgent` on success (the race-free binding point `useAgentStream` reacts to);\n * else → `client.agent(agentId).send(...)`. Stop → `client.agent(agentId).interrupt()`.\n *\n * OPTIMISTIC ECHO: `create_agent_request`/`send_agent_prompt` block server-side until the whole\n * turn finishes, and even the *first* broadcast event for that turn (the canonical `user_message`)\n * only fires once the agent process is booted/warm — for a brand-new session that means a real\n * process-spawn+handshake before anything appears (see AGENTS.md \"First-message latency\"). To hide\n * that, `submit` mints a `clientMessageId` and inserts the user's row into the timeline\n * *synchronously*, before the RPC is even issued. The daemon echoes the same id back verbatim as\n * the `user_message` event's `messageId` (`packages/server/src/agent/agent-service.ts` `runTurn`);\n * the reducer (`timeline/reducer.ts` `onUserMessage`) matches it against the pending row and\n * confirms it in place instead of appending a duplicate.\n *\n * A brand-new agent has no live subscription yet when the first turn's events start arriving —\n * `useAgentStream` only attaches once `bindAgent` sets `agentId`, which happens *after*\n * `createAgent()` resolves. So for the first turn `submit` subscribes to the raw broadcast\n * directly and applies each `agent_stream` event *as it arrives*, latching the new agent's id\n * from *its own* `user_message` echo (`messageId === clientMessageId`) — never from \"the first\n * such event\", since another session's agent can be mid-turn on the same socket concurrently and\n * its frames would otherwise be misattributed here (agent_update frames are top-level and never\n * reach `onSessionMessage`; agent_stream frames are session-wrapped and do). That includes the\n * `user_message` event that reconciles the optimistic row above.\n * `bindAgent` is deferred until the RPC resolves so `useAgentStream` attaches only for follow-up\n * turns and never re-applies the first turn (the reducer is not event-id-idempotent).\n *\n * STEERING: while the agent is running, the primary action becomes **Steer** instead of Send\n * (`send_agent_prompt` is only legal when idle — see AGENTS.md \"Steering\"). Steer reuses the exact\n * optimistic-echo + reconciliation path above (`clientMessageId` in, same `user_message` echo\n * back), just against `client.agent(id).steer(...)` instead of `.send(...)`, and marks the\n * optimistic row `queued: true` so `UserRow` can show a \"queued\" badge until a `queue_update`\n * stream event drops the text from its `steering[]` list (`timeline/reducer.ts`'s\n * `onQueueUpdate`). Follow-up (`.followUp(...)`, delivered only after the turn fully stops) is\n * intentionally not surfaced here — SDK/CLI only for now.\n */\n\nimport { useRef, useState, type ChangeEvent, type ClipboardEvent, type KeyboardEvent } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { Navigation, Paperclip, Send, Square } from \"lucide-react\";\nimport type { AgentStreamEvent } from \"@av-pi-studio/protocol\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { TextArea } from \"@pi-studio-ui/components/primitives/TextInput.js\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { applyAgentStreamEvent, createFirstTurnGate } from \"@pi-studio-ui/hooks/agent-stream-events.js\";\nimport { Attachments, readImageFile, type PendingImage } from \"./Attachments.js\";\nimport styles from \"./Composer.module.css\";\n\nconst MAX_TEXTAREA_HEIGHT = 160;\n\nexport interface ComposerProps {\n sessionId: string;\n}\n\nfunction autoResize(el: HTMLTextAreaElement): void {\n el.style.height = \"auto\";\n el.style.height = `${Math.min(el.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n}\n\ninterface AgentStreamMessage {\n type: \"agent_stream\";\n agentId: string;\n event: AgentStreamEvent;\n}\n\nfunction isAgentStreamMessage(msg: unknown): msg is AgentStreamMessage {\n if (typeof msg !== \"object\" || msg === null) return false;\n if (!(\"type\" in msg) || msg.type !== \"agent_stream\") return false;\n return \"agentId\" in msg && typeof msg.agentId === \"string\" && \"event\" in msg;\n}\n\n/** `steer_agent_response`'s `{ ok: false }` — no live turn, or the provider lacks steering. */\nfunction isOkFalse(value: unknown): boolean {\n return typeof value === \"object\" && value !== null && \"ok\" in value && value.ok === false;\n}\n\nexport function Composer({ sessionId }: ComposerProps) {\n const client = useConnectionStore((s) => s.client);\n const session = useSessionStore((s) => s.sessions[sessionId]);\n const bindAgent = useSessionStore((s) => s.bindAgent);\n const addOptimisticUserMessage = useSessionStore((s) => s.addOptimisticUserMessage);\n const markUserMessageFailed = useSessionStore((s) => s.markUserMessageFailed);\n const setCwd = useSessionStore((s) => s.setCwd);\n const queryClient = useQueryClient();\n\n const [text, setText] = useState(\"\");\n const [images, setImages] = useState<PendingImage[]>([]);\n // Two independent busy flags: `sending` guards Send/create-agent, whose RPC blocks\n // server-side for the *entire* turn (`runTurn` doesn't resolve until the turn ends — see\n // AGENTS.md \"Steering\"); `steering` guards the separate, fire-and-forget steer RPC. Sharing\n // one flag would leave the Steer button disabled for the whole turn, since the original\n // send's promise stays pending throughout it.\n const [sending, setSending] = useState(false);\n const [steering, setSteering] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const running = session?.status === \"running\";\n const busy = running ? steering : sending;\n const canSubmit = Boolean(client) && !busy && (text.trim().length > 0 || images.length > 0);\n\n async function addImageFile(file: File): Promise<void> {\n if (!file.type.startsWith(\"image/\")) return;\n try {\n const image = await readImageFile(file);\n setImages((prev) => [...prev, image]);\n } catch {\n // Best-effort attachment read — ignore unreadable files (POC has no error UI here either).\n }\n }\n\n function handleFileInputChange(ev: ChangeEvent<HTMLInputElement>): void {\n for (const file of ev.target.files ?? []) void addImageFile(file);\n ev.target.value = \"\";\n }\n\n function handlePaste(ev: ClipboardEvent<HTMLTextAreaElement>): void {\n for (const item of ev.clipboardData.items) {\n if (item.type.startsWith(\"image/\")) {\n ev.preventDefault();\n const file = item.getAsFile();\n if (file) void addImageFile(file);\n }\n }\n }\n\n function handleRemoveImage(index: number): void {\n setImages((prev) => prev.filter((_, i) => i !== index));\n }\n\n function handleTextareaChange(ev: ChangeEvent<HTMLTextAreaElement>): void {\n setText(ev.target.value);\n autoResize(ev.target);\n }\n\n function handleKeyDown(ev: KeyboardEvent<HTMLTextAreaElement>): void {\n if (ev.key === \"Enter\" && !ev.shiftKey) {\n ev.preventDefault();\n void submit(running ? \"steer\" : \"send\");\n }\n }\n\n async function submit(mode: \"send\" | \"steer\"): Promise<void> {\n if (!client || !session) return;\n if (mode === \"steer\" ? steering : sending) return;\n // Steering only makes sense against a live agent — a running session always has one; bail\n // rather than fall through to the create-agent path below (that path is send-only).\n if (mode === \"steer\" && !session.agentId) return;\n const trimmed = text.trim();\n if (!trimmed && images.length === 0) return;\n\n setText(\"\");\n if (textareaRef.current) autoResize(textareaRef.current);\n const sentImages = images;\n setImages([]);\n\n const prompt = trimmed || \"Describe this image\";\n const rpcImages =\n sentImages.length > 0\n ? sentImages.map((img) => ({ mimeType: img.mimeType, data: img.data }))\n : undefined;\n\n // Optimistic echo: render the user's row synchronously instead of waiting for the daemon's\n // `user_message` broadcast (see file header). `clientMessageId` is round-tripped through the\n // RPC below and echoed back verbatim as the broadcast event's `messageId`, which is how the\n // reducer reconciles this row instead of appending a duplicate once the server confirms it.\n // Steered rows are additionally marked `queued: true` (cleared by a later `queue_update`).\n const clientMessageId = crypto.randomUUID();\n addOptimisticUserMessage(sessionId, clientMessageId, prompt, rpcImages, mode === \"steer\");\n\n const setBusy = mode === \"steer\" ? setSteering : setSending;\n setBusy(true);\n try {\n if (mode === \"steer\") {\n // Fire-and-forget injection into the live turn — never touches `bindAgent` or the\n // first-turn broadcast gate below (those exist only for the no-agent-yet create path).\n const result = await client.agent(session.agentId!).steer(prompt, { clientMessageId, images: rpcImages });\n if (isOkFalse(result)) markUserMessageFailed(sessionId, clientMessageId);\n } else if (!session.agentId) {\n const cwd = session.cwd || \"~\";\n setCwd(sessionId, cwd);\n // The daemon runs the entire first turn *before* `createAgent()` resolves, broadcasting\n // every `agent_stream` event for it in the meantime (agent-service.ts `runTurn`). If we\n // waited for the RPC to learn our agentId the timeline would stay empty (and show no\n // running indicator) until the whole turn finished — the reported bug. Instead we watch\n // the live broadcast during the call and apply events as they arrive.\n //\n // We latch the agent id from *our own* canonical `user_message` echo (`messageId ===\n // clientMessageId`), never from \"the first `agent_stream` frame we happen to observe\":\n // another session's agent can be mid-turn on this same socket right now, so the first\n // frame to arrive after we subscribe may belong to THAT agent, not ours. Latching onto it\n // would misattribute its events into this session's timeline and then silently drop this\n // turn's real events (mismatched agentId) once they start arriving. `agent_update` frames\n // are broadcast bare/top-level and never reach `onSessionMessage` (only `session`-wrapped\n // frames do), but every `agent_stream` frame IS session-wrapped, including the\n // `user_message` echo — so this key is always observable here.\n //\n // `bindAgent` is deferred until *after* the RPC resolves: binding attaches\n // `useAgentStream`, and since the reducer isn't event-id-idempotent, a mid-turn attach\n // would double every remaining row. Binding post-resolve means this handler is the sole\n // applier for the first turn and `useAgentStream` only ever sees follow-up turns.\n const isOwnTurnEvent = createFirstTurnGate(clientMessageId);\n const unsubscribeLive = client.connection.onSessionMessage((msg) => {\n if (!isAgentStreamMessage(msg) || !isOwnTurnEvent(msg)) return;\n applyAgentStreamEvent({ sessionId, event: msg.event, client, queryClient });\n });\n\n let result: { agentId: string };\n try {\n result = await client.createAgent({\n config: { provider: \"pi\", cwd },\n initialPrompt: prompt,\n clientMessageId,\n images: rpcImages,\n labels: {},\n });\n } finally {\n unsubscribeLive();\n }\n\n bindAgent(sessionId, result.agentId);\n } else {\n await client.agent(session.agentId).send(prompt, { clientMessageId, images: rpcImages });\n }\n } catch {\n // RPC rejection before any `user_message` broadcast arrived (e.g. dropped connection) —\n // the optimistic row would otherwise stay pending forever with no feedback. If the server\n // *did* manage to broadcast `user_message` first (the row is already reconciled), this is\n // a no-op — `markUserMessageFailed` only touches a still-pending row. Turn-level failures\n // that occur after that point still surface via `agent_stream` `error`/`turn_failed`\n // events (POC swallows the RPC rejection the same way; the stream is the source of truth\n // for those).\n markUserMessageFailed(sessionId, clientMessageId);\n } finally {\n setBusy(false);\n }\n }\n\n function handleStop(): void {\n if (!session?.agentId) return;\n void client?.agent(session.agentId).interrupt();\n }\n\n return (\n <div className={styles.composer}>\n <div className={styles.inputArea}>\n <TextArea\n ref={textareaRef}\n className={styles.textarea}\n rows={1}\n value={text}\n placeholder={\n running\n ? \"Steer the running turn… (Enter to steer, Shift+Enter for newline)\"\n : \"Ask anything… (Enter to send, Shift+Enter for newline)\"\n }\n onChange={handleTextareaChange}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n />\n <Attachments images={images} onRemove={handleRemoveImage} />\n </div>\n <Button\n className={styles.attachBtn}\n variant=\"ghost\"\n size=\"md\"\n iconOnly\n title=\"Attach image\"\n onClick={() => fileInputRef.current?.click()}\n >\n <Paperclip size={16} />\n </Button>\n <input\n ref={fileInputRef}\n className={styles.hiddenFileInput}\n type=\"file\"\n accept=\"image/*\"\n multiple\n onChange={handleFileInputChange}\n />\n <div className={styles.actions}>\n {running ? (\n <Button\n size=\"sm\"\n disabled={!canSubmit}\n onClick={() => void submit(\"steer\")}\n leftIcon={<Navigation size={14} />}\n >\n Steer\n </Button>\n ) : (\n <Button size=\"sm\" disabled={!canSubmit} onClick={() => void submit(\"send\")} leftIcon={<Send size={14} />}>\n Send\n </Button>\n )}\n {running && (\n <Button size=\"sm\" variant=\"destructive\" onClick={handleStop} leftIcon={<Square size={14} />}>\n Stop\n </Button>\n )}\n </div>\n </div>\n );\n}\n","/**\n * ChatPanel — the tab content mounted by `panel-registry.ts` for `kind: \"chat\"` tabs. Looks up\n * the session by `tab.data.sessionId`, keeps its timeline live via `useAgentStream`, and renders\n * the virtualized `Timeline` + `Composer` (POC_TO_APP_PLAN_UI.md §4.3/§4.4).\n */\n\nimport { useAgentStream } from \"@pi-studio-ui/hooks/use-agent-stream.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport type { Tab, ChatTabData } from \"@pi-studio-ui/stores/tab-store.js\";\nimport { Timeline } from \"./Timeline.js\";\nimport { Composer } from \"./Composer.js\";\nimport styles from \"./ChatPanel.module.css\";\n\nexport interface ChatPanelProps {\n tab: Tab;\n}\n\nexport function ChatPanel({ tab }: ChatPanelProps) {\n // `panel-registry.ts` only ever mounts this component for `tab.kind === \"chat\"`, whose `data`\n // is always `ChatTabData` — narrowed here since `Tab[\"data\"]` is a union at the type level.\n const { sessionId } = tab.data as ChatTabData;\n const session = useSessionStore((s) => s.sessions[sessionId]);\n\n useAgentStream(sessionId);\n\n if (!session) {\n return (\n <div className={styles.panel}>\n <div className={styles.empty}>Session not found.</div>\n </div>\n );\n }\n\n return (\n <div className={styles.panel}>\n <Timeline session={session} />\n <Composer sessionId={session.id} />\n </div>\n );\n}\n"],"names":["statusBadgeTokens","variant","StatusBadge","label","className","token","color","jsx","styles","ICON_BY_KIND","Terminal","Eye","Pencil","FilePlus","Search","Globe","ListTree","toolIcon","tool","toolLabel","toolFilePath","toolMutatesFiles","toolBody","sections","text","toolDetailText","toolInlineDetail","parts","DEBOUNCE_MS","pendingTimer","invalidateAfterToolCompletion","queryClient","client","cwd","_toolFilePath","createFirstTurnGate","clientMessageId","liveAgentId","msg","applyAgentStreamEvent","sessionId","event","sessionStore","useSessionStore","session","useAgentStream","useConnectionStore","s","agentId","_a","useQueryClient","useEffect","AssistantRow","row","jsxs","Markdown","ReasoningRow","BADGE_VARIANT","ToolCard","expanded","setExpanded","useState","Icon","inlineDetail","body","hasBody","clsx","v","ChevronRight","section","i","DiffView","UserRow","openedSrc","setOpenedSrc","stateClass","Clock","img","src","ev","Dialog","open","ErrorRow","SystemRow","STICK_THRESHOLD_PX","renderRow","Timeline","rows","running","scrollRef","useRef","stickToBottomRef","prevRowCountRef","virtualizer","useVirtualizer","index","element","entry","instance","measureElementDefault","key","handleScroll","el","distanceFromBottom","grew","virtualRow","Attachments","images","onRemove","readImageFile","file","promise","resolve","reject","reader","result","commaIndex","data","MAX_TEXTAREA_HEIGHT","autoResize","isAgentStreamMessage","isOkFalse","value","Composer","bindAgent","addOptimisticUserMessage","markUserMessageFailed","setCwd","setText","setImages","sending","setSending","steering","setSteering","textareaRef","fileInputRef","canSubmit","addImageFile","image","prev","handleFileInputChange","handlePaste","item","handleRemoveImage","_","handleTextareaChange","handleKeyDown","submit","mode","trimmed","sentImages","prompt","rpcImages","setBusy","isOwnTurnEvent","unsubscribeLive","handleStop","TextArea","Button","Paperclip","Navigation","Send","Square","ChatPanel","tab"],"mappings":"6oBAcO,SAASA,GAAkBC,EAA0C,CAC1E,OAAQA,EAAA,CACN,IAAK,UACH,MAAO,CAAE,MAAO,eAAA,EAClB,IAAK,QACH,MAAO,CAAE,MAAO,cAAA,EAClB,IAAK,QACH,MAAO,CAAE,MAAO,iBAAA,CAAkB,CAExC,CCRO,SAASC,GAAY,CAAE,MAAAC,EAAO,QAAAF,EAAS,UAAAG,GAA+B,CAC3E,KAAM,CAAE,MAAAC,CAAA,EAAUL,GAAkBC,CAAO,EACrCK,EAAQ,kBAAkBD,CAAK,IACrC,OACE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AC,MAAA,CAAI,UAAW9C,EAAO,MACrB,SAAA,CAAAD,MAAC+E,IAAS,QAAA1C,EAAkB,EAC5BrC,EAAAA,IAACoH,GAAA,CAAS,UAAW/E,EAAQ,EAAA,CAAI,CAAA,EACnC,EAVErC,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,MACrB,SAAAD,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,MAAO,SAAA,oBAAA,CAAkB,EAClD,CAUN"}
@@ -1,2 +1,2 @@
1
- import{u as l}from"./vendor-query-AtKBh_Yt.js";import{a as f,r as p}from"./index-B_Wls_vp.js";import{j as i,r as u}from"./vendor-react-BoIQBqDW.js";import{O as d,P as m,Q as g,S as h,T as w,U as x}from"./vendor--os7hw7d.js";function q(r,n=!0){const t=f(e=>e.client);return l({queryKey:p.fileRead(r),queryFn:async()=>{if(!t)throw new Error("not connected");const e=await t.connection.request("file_read_request",{path:r});if(!e.ok)throw new Error(e.error??"file read failed");return{content:e.content??"",size:e.size??0}},enabled:!!t&&!!r&&n})}const y="_wrap_17s3u_1",E={wrap:y},c=new Map;function C(r){const[n,t]=u.useState(null);return u.useEffect(()=>{const e=w.matchFilename(x,r);if(!e){t(null);return}const s=c.get(e.name);if(s){t(s);return}let a=!1;return t(null),e.load().then(o=>{c.set(e.name,o),a||t(o)}),()=>{a=!0}},[r]),n?[n]:[]}function v({path:r,content:n}){const t=C(r),e=[d.lineWrapping,m(),...t];return i.jsx("div",{className:E.wrap,children:i.jsx(g,{value:n,theme:h,extensions:e,editable:!1,readOnly:!0,basicSetup:{highlightActiveLine:!1,foldGutter:!1,searchKeymap:!1},height:"100%"})})}export{v as C,q as u};
2
- //# sourceMappingURL=CodeView-CHtX3XUo.js.map
1
+ import{u as l}from"./vendor-query-AtKBh_Yt.js";import{a as f,r as p}from"./index-C5SpA_B-.js";import{j as i,r as u}from"./vendor-react-BoIQBqDW.js";import{O as d,P as m,Q as g,S as h,T as w,U as x}from"./vendor--os7hw7d.js";function q(r,n=!0){const t=f(e=>e.client);return l({queryKey:p.fileRead(r),queryFn:async()=>{if(!t)throw new Error("not connected");const e=await t.connection.request("file_read_request",{path:r});if(!e.ok)throw new Error(e.error??"file read failed");return{content:e.content??"",size:e.size??0}},enabled:!!t&&!!r&&n})}const y="_wrap_17s3u_1",E={wrap:y},c=new Map;function C(r){const[n,t]=u.useState(null);return u.useEffect(()=>{const e=w.matchFilename(x,r);if(!e){t(null);return}const s=c.get(e.name);if(s){t(s);return}let a=!1;return t(null),e.load().then(o=>{c.set(e.name,o),a||t(o)}),()=>{a=!0}},[r]),n?[n]:[]}function v({path:r,content:n}){const t=C(r),e=[d.lineWrapping,m(),...t];return i.jsx("div",{className:E.wrap,children:i.jsx(g,{value:n,theme:h,extensions:e,editable:!1,readOnly:!0,basicSetup:{highlightActiveLine:!1,foldGutter:!1,searchKeymap:!1},height:"100%"})})}export{v as C,q as u};
2
+ //# sourceMappingURL=CodeView-z3x4ATgx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeView-CHtX3XUo.js","sources":["../../../src/hooks/use-file-read.ts","../../../src/features/files/CodeView.tsx"],"sourcesContent":["/**\n * `use-file-read` — TanStack Query wrapper over `file_read_request` (POC `loadFileContent`,\n * POC_TO_APP_PLAN_UI.md §4.5 / §3 `hooks/use-file-read.ts`).\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\n\nexport interface FileReadResult {\n content: string;\n size: number;\n}\n\ninterface FileReadRpcResponse {\n ok: boolean;\n content?: string;\n size?: number;\n error?: string;\n}\n\nexport function useFileRead(path: string, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n\n return useQuery({\n queryKey: rpcKeys.fileRead(path),\n queryFn: async (): Promise<FileReadResult> => {\n if (!client) throw new Error(\"not connected\");\n const response = await client.connection.request<FileReadRpcResponse>(\"file_read_request\", {\n path,\n });\n if (!response.ok) throw new Error(response.error ?? \"file read failed\");\n return { content: response.content ?? \"\", size: response.size ?? 0 };\n },\n enabled: Boolean(client) && Boolean(path) && enabled,\n });\n}\n","/**\n * CodeView — highlighted, read-only file body with a line-number gutter (POC `showFile`/\n * `reloadFileInPanel`, chat.html ~line 812-828, POC_TO_APP_PLAN_UI.md §4.5). Built on CodeMirror 6\n * (`@uiw/react-codemirror`) rather than a hand-rolled `<pre>` + separate gutter `<pre>`: the two\n * previously drifted out of sync on scroll (independent scroll containers, no shared scroll\n * anchor) whenever content was long enough to scroll or lines wrapped. CodeMirror owns a single\n * scrollable viewport with gutter and content painted from the same layout pass, so this class of\n * bug cannot recur.\n */\n\nimport { useEffect, useState } from \"react\";\nimport CodeMirror from \"@uiw/react-codemirror\";\nimport type { Extension } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport { languages } from \"@codemirror/language-data\";\nimport { LanguageDescription, type LanguageSupport, foldGutter } from \"@codemirror/language\";\nimport { githubDark } from \"@uiw/codemirror-theme-github\";\nimport styles from \"./CodeView.module.css\";\n\nexport interface CodeViewProps {\n path: string;\n content: string;\n}\n\n// `LanguageDescription.support` is populated lazily by `.load()`, which dynamically imports the\n// grammar the first time a given language is used and resolves instantly (cached) after that.\nconst supportCache = new Map<string, LanguageSupport>();\n\nfunction useLanguageExtension(path: string): Extension[] {\n const [support, setSupport] = useState<LanguageSupport | null>(null);\n\n useEffect(() => {\n const desc = LanguageDescription.matchFilename(languages, path);\n if (!desc) {\n setSupport(null);\n return;\n }\n const cached = supportCache.get(desc.name);\n if (cached) {\n setSupport(cached);\n return;\n }\n let cancelled = false;\n setSupport(null);\n void desc.load().then((loaded) => {\n supportCache.set(desc.name, loaded);\n if (!cancelled) setSupport(loaded);\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return support ? [support] : [];\n}\n\nexport function CodeView({ path, content }: CodeViewProps) {\n const languageExt = useLanguageExtension(path);\n const extensions: Extension[] = [EditorView.lineWrapping, foldGutter(), ...languageExt];\n\n return (\n <div className={styles.wrap}>\n <CodeMirror\n value={content}\n theme={githubDark}\n extensions={extensions}\n editable={false}\n readOnly\n basicSetup={{\n highlightActiveLine: false,\n foldGutter: false,\n searchKeymap: false,\n }}\n height=\"100%\"\n />\n </div>\n );\n}\n"],"names":["useFileRead","path","enabled","client","useConnectionStore","s","useQuery","rpcKeys","response","supportCache","useLanguageExtension","support","setSupport","useState","useEffect","desc","LanguageDescription","languages","cached","cancelled","loaded","CodeView","content","languageExt","extensions","EditorView","foldGutter","jsx","styles","CodeMirror","githubDark"],"mappings":"gOAqBO,SAASA,EAAYC,EAAcC,EAAU,GAAM,CACxD,MAAMC,EAASC,EAAoBC,GAAMA,EAAE,MAAM,EAEjD,OAAOC,EAAS,CACd,SAAUC,EAAQ,SAASN,CAAI,EAC/B,QAAS,SAAqC,CAC5C,GAAI,CAACE,EAAQ,MAAM,IAAI,MAAM,eAAe,EAC5C,MAAMK,EAAW,MAAML,EAAO,WAAW,QAA6B,oBAAqB,CACzF,KAAAF,CAAA,CACD,EACD,GAAI,CAACO,EAAS,GAAI,MAAM,IAAI,MAAMA,EAAS,OAAS,kBAAkB,EACtE,MAAO,CAAE,QAASA,EAAS,SAAW,GAAI,KAAMA,EAAS,MAAQ,CAAA,CACnE,EACA,QAAS,EAAQL,GAAW,EAAQF,GAASC,CAAA,CAC9C,CACH,oCCVMO,MAAmB,IAEzB,SAASC,EAAqBT,EAA2B,CACvD,KAAM,CAACU,EAASC,CAAU,EAAIC,EAAAA,SAAiC,IAAI,EAEnEC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOC,EAAoB,cAAcC,EAAWhB,CAAI,EAC9D,GAAI,CAACc,EAAM,CACTH,EAAW,IAAI,EACf,MACF,CACA,MAAMM,EAAST,EAAa,IAAIM,EAAK,IAAI,EACzC,GAAIG,EAAQ,CACVN,EAAWM,CAAM,EACjB,MACF,CACA,IAAIC,EAAY,GAChB,OAAAP,EAAW,IAAI,EACVG,EAAK,KAAA,EAAO,KAAMK,GAAW,CAChCX,EAAa,IAAIM,EAAK,KAAMK,CAAM,EAC7BD,GAAWP,EAAWQ,CAAM,CACnC,CAAC,EACM,IAAM,CACXD,EAAY,EACd,CACF,EAAG,CAAClB,CAAI,CAAC,EAEFU,EAAU,CAACA,CAAO,EAAI,CAAA,CAC/B,CAEO,SAASU,EAAS,CAAE,KAAApB,EAAM,QAAAqB,GAA0B,CACzD,MAAMC,EAAcb,EAAqBT,CAAI,EACvCuB,EAA0B,CAACC,EAAW,aAAcC,EAAA,EAAc,GAAGH,CAAW,EAEtF,OACEI,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,KACrB,SAAAD,EAAAA,IAACE,EAAA,CACC,MAAOP,EACP,MAAOQ,EACP,WAAAN,EACA,SAAU,GACV,SAAQ,GACR,WAAY,CACV,oBAAqB,GACrB,WAAY,GACZ,aAAc,EAAA,EAEhB,OAAO,MAAA,CAAA,EAEX,CAEJ"}
1
+ {"version":3,"file":"CodeView-z3x4ATgx.js","sources":["../../../src/hooks/use-file-read.ts","../../../src/features/files/CodeView.tsx"],"sourcesContent":["/**\n * `use-file-read` — TanStack Query wrapper over `file_read_request` (POC `loadFileContent`,\n * POC_TO_APP_PLAN_UI.md §4.5 / §3 `hooks/use-file-read.ts`).\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\n\nexport interface FileReadResult {\n content: string;\n size: number;\n}\n\ninterface FileReadRpcResponse {\n ok: boolean;\n content?: string;\n size?: number;\n error?: string;\n}\n\nexport function useFileRead(path: string, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n\n return useQuery({\n queryKey: rpcKeys.fileRead(path),\n queryFn: async (): Promise<FileReadResult> => {\n if (!client) throw new Error(\"not connected\");\n const response = await client.connection.request<FileReadRpcResponse>(\"file_read_request\", {\n path,\n });\n if (!response.ok) throw new Error(response.error ?? \"file read failed\");\n return { content: response.content ?? \"\", size: response.size ?? 0 };\n },\n enabled: Boolean(client) && Boolean(path) && enabled,\n });\n}\n","/**\n * CodeView — highlighted, read-only file body with a line-number gutter (POC `showFile`/\n * `reloadFileInPanel`, chat.html ~line 812-828, POC_TO_APP_PLAN_UI.md §4.5). Built on CodeMirror 6\n * (`@uiw/react-codemirror`) rather than a hand-rolled `<pre>` + separate gutter `<pre>`: the two\n * previously drifted out of sync on scroll (independent scroll containers, no shared scroll\n * anchor) whenever content was long enough to scroll or lines wrapped. CodeMirror owns a single\n * scrollable viewport with gutter and content painted from the same layout pass, so this class of\n * bug cannot recur.\n */\n\nimport { useEffect, useState } from \"react\";\nimport CodeMirror from \"@uiw/react-codemirror\";\nimport type { Extension } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport { languages } from \"@codemirror/language-data\";\nimport { LanguageDescription, type LanguageSupport, foldGutter } from \"@codemirror/language\";\nimport { githubDark } from \"@uiw/codemirror-theme-github\";\nimport styles from \"./CodeView.module.css\";\n\nexport interface CodeViewProps {\n path: string;\n content: string;\n}\n\n// `LanguageDescription.support` is populated lazily by `.load()`, which dynamically imports the\n// grammar the first time a given language is used and resolves instantly (cached) after that.\nconst supportCache = new Map<string, LanguageSupport>();\n\nfunction useLanguageExtension(path: string): Extension[] {\n const [support, setSupport] = useState<LanguageSupport | null>(null);\n\n useEffect(() => {\n const desc = LanguageDescription.matchFilename(languages, path);\n if (!desc) {\n setSupport(null);\n return;\n }\n const cached = supportCache.get(desc.name);\n if (cached) {\n setSupport(cached);\n return;\n }\n let cancelled = false;\n setSupport(null);\n void desc.load().then((loaded) => {\n supportCache.set(desc.name, loaded);\n if (!cancelled) setSupport(loaded);\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return support ? [support] : [];\n}\n\nexport function CodeView({ path, content }: CodeViewProps) {\n const languageExt = useLanguageExtension(path);\n const extensions: Extension[] = [EditorView.lineWrapping, foldGutter(), ...languageExt];\n\n return (\n <div className={styles.wrap}>\n <CodeMirror\n value={content}\n theme={githubDark}\n extensions={extensions}\n editable={false}\n readOnly\n basicSetup={{\n highlightActiveLine: false,\n foldGutter: false,\n searchKeymap: false,\n }}\n height=\"100%\"\n />\n </div>\n );\n}\n"],"names":["useFileRead","path","enabled","client","useConnectionStore","s","useQuery","rpcKeys","response","supportCache","useLanguageExtension","support","setSupport","useState","useEffect","desc","LanguageDescription","languages","cached","cancelled","loaded","CodeView","content","languageExt","extensions","EditorView","foldGutter","jsx","styles","CodeMirror","githubDark"],"mappings":"gOAqBO,SAASA,EAAYC,EAAcC,EAAU,GAAM,CACxD,MAAMC,EAASC,EAAoBC,GAAMA,EAAE,MAAM,EAEjD,OAAOC,EAAS,CACd,SAAUC,EAAQ,SAASN,CAAI,EAC/B,QAAS,SAAqC,CAC5C,GAAI,CAACE,EAAQ,MAAM,IAAI,MAAM,eAAe,EAC5C,MAAMK,EAAW,MAAML,EAAO,WAAW,QAA6B,oBAAqB,CACzF,KAAAF,CAAA,CACD,EACD,GAAI,CAACO,EAAS,GAAI,MAAM,IAAI,MAAMA,EAAS,OAAS,kBAAkB,EACtE,MAAO,CAAE,QAASA,EAAS,SAAW,GAAI,KAAMA,EAAS,MAAQ,CAAA,CACnE,EACA,QAAS,EAAQL,GAAW,EAAQF,GAASC,CAAA,CAC9C,CACH,oCCVMO,MAAmB,IAEzB,SAASC,EAAqBT,EAA2B,CACvD,KAAM,CAACU,EAASC,CAAU,EAAIC,EAAAA,SAAiC,IAAI,EAEnEC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOC,EAAoB,cAAcC,EAAWhB,CAAI,EAC9D,GAAI,CAACc,EAAM,CACTH,EAAW,IAAI,EACf,MACF,CACA,MAAMM,EAAST,EAAa,IAAIM,EAAK,IAAI,EACzC,GAAIG,EAAQ,CACVN,EAAWM,CAAM,EACjB,MACF,CACA,IAAIC,EAAY,GAChB,OAAAP,EAAW,IAAI,EACVG,EAAK,KAAA,EAAO,KAAMK,GAAW,CAChCX,EAAa,IAAIM,EAAK,KAAMK,CAAM,EAC7BD,GAAWP,EAAWQ,CAAM,CACnC,CAAC,EACM,IAAM,CACXD,EAAY,EACd,CACF,EAAG,CAAClB,CAAI,CAAC,EAEFU,EAAU,CAACA,CAAO,EAAI,CAAA,CAC/B,CAEO,SAASU,EAAS,CAAE,KAAApB,EAAM,QAAAqB,GAA0B,CACzD,MAAMC,EAAcb,EAAqBT,CAAI,EACvCuB,EAA0B,CAACC,EAAW,aAAcC,EAAA,EAAc,GAAGH,CAAW,EAEtF,OACEI,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,KACrB,SAAAD,EAAAA,IAACE,EAAA,CACC,MAAOP,EACP,MAAOQ,EACP,WAAAN,EACA,SAAU,GACV,SAAQ,GACR,WAAY,CACV,oBAAqB,GACrB,WAAY,GACZ,aAAc,EAAA,EAEhB,OAAO,MAAA,CAAA,EAEX,CAEJ"}
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TextViewer-DjulYYEe.js","assets/vendor-react-BoIQBqDW.js","assets/index-B_Wls_vp.js","assets/vendor-query-AtKBh_Yt.js","assets/vendor--os7hw7d.js","assets/vendor-markdown-B8HSIhaA.js","assets/vendor-highlight-DCzuSv8g.js","assets/vendor-icons-BJD_eLBz.js","assets/vendor-overlays-UwLNGk04.js","assets/vendor-dnd-D9kA7FgH.js","assets/index-ZP_-GPM5.css","assets/CodeView-CHtX3XUo.js","assets/CodeView-CLRODhB8.css","assets/DiffView-DlVCPvLc.js","assets/DiffView-CRbeRztO.css","assets/MarkdownFileViewer-n81kPpQE.js","assets/markdown-D9FuaV1m.js","assets/markdown-BQwXm0MF.css","assets/MarkdownFileViewer-BD5Ri_Fb.css","assets/ImageViewer-BU0ZsYF9.js","assets/use-file-download-BxA_7HBl.js","assets/ImageViewer-ijzMsq8H.css","assets/VideoViewer-CWUu0A0W.js","assets/VideoViewer-BBuZ4wou.css","assets/BinaryFallbackViewer-DcdvHipL.js","assets/BinaryFallbackViewer-CLiNWU_S.css"])))=>i.map(i=>d[i]);
2
- import{r as d,j as i}from"./vendor-react-BoIQBqDW.js";import{C as h}from"./vendor--os7hw7d.js";import{a as b,r as v,B as _,S as p}from"./index-B_Wls_vp.js";import{u as x}from"./vendor-query-AtKBh_Yt.js";import{D as E}from"./DiffView-DlVCPvLc.js";import{_ as f}from"./vendor-highlight-DCzuSv8g.js";function V(e,a,t,r=!0){const o=b(n=>n.client);return x({queryKey:v.fileDiff(e,a,t),queryFn:async()=>{if(!o)throw new Error("not connected");return{patch:(await o.connection.request("file_diff_request",{path:e,cwd:a,staged:t})).patch??""}},enabled:!!o&&!!e&&!!a&&r})}const j=d.lazy(()=>f(()=>import("./TextViewer-DjulYYEe.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(e=>({default:e.TextViewer}))),T=d.lazy(()=>f(()=>import("./MarkdownFileViewer-n81kPpQE.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,12,16,17,13,14,18])).then(e=>({default:e.MarkdownFileViewer}))),k=d.lazy(()=>f(()=>import("./ImageViewer-BU0ZsYF9.js"),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,20,13,14,21])).then(e=>({default:e.ImageViewer}))),z=d.lazy(()=>f(()=>import("./VideoViewer-CWUu0A0W.js"),__vite__mapDeps([22,1,2,3,4,5,6,7,8,9,10,20,13,14,23])).then(e=>({default:e.VideoViewer}))),D=d.lazy(()=>f(()=>import("./BinaryFallbackViewer-DcdvHipL.js"),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,20,25])).then(e=>({default:e.BinaryFallbackViewer}))),I={text:j,markdown:T,image:k,video:z,binary:D},S={md:"markdown",markdown:"markdown",mdx:"markdown",png:"image",jpg:"image",jpeg:"image",gif:"image",webp:"image",svg:"image",bmp:"image",ico:"image",avif:"image",mp4:"video",webm:"video",mov:"video",m4v:"video",ogv:"video",pdf:"binary",zip:"binary",gz:"binary",tar:"binary",exe:"binary",wasm:"binary",woff:"binary",woff2:"binary",ttf:"binary",otf:"binary"},N=[["image/","image"],["video/","video"]];function F(e){const a=e.split("/").pop()??e,t=a.lastIndexOf(".");return t>0?a.slice(t+1).toLowerCase():""}function O(e,a={}){const t=S[F(e)];if(t)return t;const r=a.mimeHint??"";for(const[o,n]of N)if(r.startsWith(o))return n;return a.isBinary?"binary":"text"}const P="_panel_i61bw_1",R="_header_i61bw_7",B="_path_i61bw_17",L="_size_i61bw_24",M="_viewToggle_i61bw_29",A="_body_i61bw_34",C="_emptyState_i61bw_39",K="_diffEmpty_i61bw_48",s={panel:P,header:R,path:B,size:L,viewToggle:M,body:A,emptyState:C,diffEmpty:K};function u(e){return"path"in e}function q(e){return"staged"in e}function W({tab:e}){var m;const a=e.kind==="diff",t=e.data,r=u(t)?t.path:"",o=u(t)&&q(t)?t.staged:!1,[n,l]=d.useState(a?"diff":"file"),w=e.workspaceCwd||"~",c=V(r,w,o,n==="diff"),y=O(r),g=I[y];return i.jsxs("div",{className:s.panel,children:[i.jsxs("div",{className:s.header,children:[i.jsx("span",{className:s.path,children:r}),i.jsx("span",{className:s.size,children:n==="diff"?o?"staged":"unstaged":null}),i.jsxs("div",{className:s.viewToggle,children:[i.jsx(_,{size:"xs",variant:n==="file"?"default":"ghost",onClick:()=>l("file"),children:"File"}),i.jsx(_,{size:"xs",variant:n==="diff"?"default":"ghost",onClick:()=>l("diff"),children:"Diff"})]})]}),i.jsx("div",{className:h(s.body,"file-body"),children:n==="file"?i.jsx(d.Suspense,{fallback:i.jsxs("div",{className:s.emptyState,children:[i.jsx(p,{size:"sm"})," Loading..."]}),children:i.jsx(g,{path:r})}):c.isLoading?i.jsxs("div",{className:s.emptyState,children:[i.jsx(p,{size:"sm"})," Loading diff..."]}):c.isError?i.jsxs("div",{className:s.emptyState,children:["Error: ",c.error instanceof Error?c.error.message:"unknown error"]}):(m=c.data)!=null&&m.patch?i.jsx(E,{patch:c.data.patch}):i.jsx("div",{className:s.diffEmpty,children:"No changes (file matches HEAD)"})})]})}const J=Object.freeze(Object.defineProperty({__proto__:null,FilePanel:W},Symbol.toStringTag,{value:"Module"}));export{J as F,s as p};
3
- //# sourceMappingURL=FilePanel-DFrjCgQW.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TextViewer-DlvdoBEv.js","assets/vendor-react-BoIQBqDW.js","assets/index-C5SpA_B-.js","assets/vendor-query-AtKBh_Yt.js","assets/vendor--os7hw7d.js","assets/vendor-markdown-B8HSIhaA.js","assets/vendor-highlight-DCzuSv8g.js","assets/vendor-icons-BouiMPVM.js","assets/vendor-overlays-UwLNGk04.js","assets/vendor-dnd-D9kA7FgH.js","assets/index-D_2xgUa4.css","assets/CodeView-z3x4ATgx.js","assets/CodeView-CLRODhB8.css","assets/DiffView-DlVCPvLc.js","assets/DiffView-CRbeRztO.css","assets/MarkdownFileViewer-CcfSk7Qc.js","assets/markdown-D9FuaV1m.js","assets/markdown-BQwXm0MF.css","assets/MarkdownFileViewer-BD5Ri_Fb.css","assets/ImageViewer-BivcSG2D.js","assets/use-file-download-t12JJGKT.js","assets/ImageViewer-ijzMsq8H.css","assets/VideoViewer-BmTmnaOQ.js","assets/VideoViewer-BBuZ4wou.css","assets/BinaryFallbackViewer-HicqzbWd.js","assets/BinaryFallbackViewer-CLiNWU_S.css"])))=>i.map(i=>d[i]);
2
+ import{r as d,j as i}from"./vendor-react-BoIQBqDW.js";import{C as h}from"./vendor--os7hw7d.js";import{a as b,r as v,B as _,S as p}from"./index-C5SpA_B-.js";import{u as x}from"./vendor-query-AtKBh_Yt.js";import{D as E}from"./DiffView-DlVCPvLc.js";import{_ as f}from"./vendor-highlight-DCzuSv8g.js";function V(e,a,t,r=!0){const o=b(n=>n.client);return x({queryKey:v.fileDiff(e,a,t),queryFn:async()=>{if(!o)throw new Error("not connected");return{patch:(await o.connection.request("file_diff_request",{path:e,cwd:a,staged:t})).patch??""}},enabled:!!o&&!!e&&!!a&&r})}const j=d.lazy(()=>f(()=>import("./TextViewer-DlvdoBEv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(e=>({default:e.TextViewer}))),T=d.lazy(()=>f(()=>import("./MarkdownFileViewer-CcfSk7Qc.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,12,16,17,13,14,18])).then(e=>({default:e.MarkdownFileViewer}))),k=d.lazy(()=>f(()=>import("./ImageViewer-BivcSG2D.js"),__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,10,20,13,14,21])).then(e=>({default:e.ImageViewer}))),z=d.lazy(()=>f(()=>import("./VideoViewer-BmTmnaOQ.js"),__vite__mapDeps([22,1,2,3,4,5,6,7,8,9,10,20,13,14,23])).then(e=>({default:e.VideoViewer}))),D=d.lazy(()=>f(()=>import("./BinaryFallbackViewer-HicqzbWd.js"),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,20,25])).then(e=>({default:e.BinaryFallbackViewer}))),I={text:j,markdown:T,image:k,video:z,binary:D},S={md:"markdown",markdown:"markdown",mdx:"markdown",png:"image",jpg:"image",jpeg:"image",gif:"image",webp:"image",svg:"image",bmp:"image",ico:"image",avif:"image",mp4:"video",webm:"video",mov:"video",m4v:"video",ogv:"video",pdf:"binary",zip:"binary",gz:"binary",tar:"binary",exe:"binary",wasm:"binary",woff:"binary",woff2:"binary",ttf:"binary",otf:"binary"},N=[["image/","image"],["video/","video"]];function F(e){const a=e.split("/").pop()??e,t=a.lastIndexOf(".");return t>0?a.slice(t+1).toLowerCase():""}function O(e,a={}){const t=S[F(e)];if(t)return t;const r=a.mimeHint??"";for(const[o,n]of N)if(r.startsWith(o))return n;return a.isBinary?"binary":"text"}const P="_panel_i61bw_1",R="_header_i61bw_7",B="_path_i61bw_17",L="_size_i61bw_24",M="_viewToggle_i61bw_29",A="_body_i61bw_34",C="_emptyState_i61bw_39",K="_diffEmpty_i61bw_48",s={panel:P,header:R,path:B,size:L,viewToggle:M,body:A,emptyState:C,diffEmpty:K};function u(e){return"path"in e}function q(e){return"staged"in e}function W({tab:e}){var m;const a=e.kind==="diff",t=e.data,r=u(t)?t.path:"",o=u(t)&&q(t)?t.staged:!1,[n,l]=d.useState(a?"diff":"file"),w=e.workspaceCwd||"~",c=V(r,w,o,n==="diff"),y=O(r),g=I[y];return i.jsxs("div",{className:s.panel,children:[i.jsxs("div",{className:s.header,children:[i.jsx("span",{className:s.path,children:r}),i.jsx("span",{className:s.size,children:n==="diff"?o?"staged":"unstaged":null}),i.jsxs("div",{className:s.viewToggle,children:[i.jsx(_,{size:"xs",variant:n==="file"?"default":"ghost",onClick:()=>l("file"),children:"File"}),i.jsx(_,{size:"xs",variant:n==="diff"?"default":"ghost",onClick:()=>l("diff"),children:"Diff"})]})]}),i.jsx("div",{className:h(s.body,"file-body"),children:n==="file"?i.jsx(d.Suspense,{fallback:i.jsxs("div",{className:s.emptyState,children:[i.jsx(p,{size:"sm"})," Loading..."]}),children:i.jsx(g,{path:r})}):c.isLoading?i.jsxs("div",{className:s.emptyState,children:[i.jsx(p,{size:"sm"})," Loading diff..."]}):c.isError?i.jsxs("div",{className:s.emptyState,children:["Error: ",c.error instanceof Error?c.error.message:"unknown error"]}):(m=c.data)!=null&&m.patch?i.jsx(E,{patch:c.data.patch}):i.jsx("div",{className:s.diffEmpty,children:"No changes (file matches HEAD)"})})]})}const J=Object.freeze(Object.defineProperty({__proto__:null,FilePanel:W},Symbol.toStringTag,{value:"Module"}));export{J as F,s as p};
3
+ //# sourceMappingURL=FilePanel-VOhIehHw.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";ySAiBO,SAASA,EAAYC,EAAcC,EAAaC,EAAiBC,EAAU,GAAM,CACtF,MAAMC,EAASC,EAAoBC,GAAMA,EAAE,MAAM,EAEjD,OAAOC,EAAS,CACd,SAAUC,EAAQ,SAASR,EAAMC,EAA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S,SAAW,WAAc,KAAK,EAC7FuC,OAAC,OAAI,UAAWC,EAAO,WACrB,UAAAC,MAACC,EAAA,CACC,KAAK,KACL,QAAST,IAAa,OAAS,UAAY,QAC3C,QAAS,IAAMC,EAAY,MAAM,EAClC,kBAGDO,MAACC,EAAA,CACC,KAAK,KACL,QAAST,IAAa,OAAS,UAAY,QAC3C,QAAS,IAAMC,EAAY,MAAM,EAClC,iBAED,EACF,GACF,QACC,OAAI,UAAWS,EAAKH,EAAO,KAAM,WAAW,EAC1C,SAAAP,IAAa,aACXW,WAAA,CAAS,gBAAW,OAAI,UAAWJ,EAAO,WAAY,UAAAC,MAACI,EAAA,CAAQ,KAAK,KAAK,EAAE,eAAW,EACrF,SAAAJ,MAACH,EAAA,CAAO,KAAAxC,CAAA,CAAY,EACtB,EACEsC,EAAU,UACZG,OAAC,OAAI,UAAWC,EAAO,WACrB,UAAAC,MAACI,EAAA,CAAQ,KAAK,KAAK,EAAE,oBACvB,EACET,EAAU,eACX,OAAI,UAAWI,EAAO,WAAY,oBACzBJ,EAAU,iBAAiB,MAAQA,EAAU,MAAM,QAAU,iBACvE,GACEU,EAAAV,EAAU,OAAV,MAAAU,EAAgB,MAClBL,MAACM,GAAS,MAAOX,EAAU,KAAK,MAAO,EAEvCK,MAAC,OAAI,UAAWD,EAAO,UAAW,0CAA8B,EAEpE,GACF,CAEJ","names":["useFileDiff","path","cwd","staged","enabled","client","useConnectionStore","s","useQuery","rpcKeys","TextViewer","lazy","__vitePreload","m","MarkdownFileViewer","ImageViewer","VideoViewer","BinaryFallbackViewer","VIEWER_BY_KIND","EXT_TO_VIEWER","MIME_PREFIX_TO_VIEWER","extOf","name","dot","detectViewerKind","opts","byExt","mime","prefix","kind","hasPath","data","isDiffTabData","FilePanel","tab","isDiffTab","viewMode","setViewMode","useState","diffQuery","viewerKind","Viewer","jsxs","styles","jsx","Button","clsx","Suspense","Spinner","_a","DiffView"],"ignoreList":[],"sources":["../../../src/hooks/use-file-diff.ts","../../../src/features/files/viewer-registry.ts","../../../src/features/files/FilePanel.tsx"],"sourcesContent":["/**\n * `use-file-diff` — TanStack Query wrapper over `file_diff_request` (POC `loadDiffContent`,\n * POC_TO_APP_PLAN_UI.md §4.5 / §3 `hooks/use-file-diff.ts`).\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\n\nexport interface FileDiffResult {\n patch: string;\n}\n\ninterface FileDiffRpcResponse {\n patch?: string;\n}\n\nexport function useFileDiff(path: string, cwd: string, staged: boolean, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n\n return useQuery({\n queryKey: rpcKeys.fileDiff(path, cwd, staged),\n queryFn: async (): Promise<FileDiffResult> => {\n if (!client) throw new Error(\"not connected\");\n const response = await client.connection.request<FileDiffRpcResponse>(\"file_diff_request\", {\n path,\n cwd,\n staged,\n });\n return { patch: response.patch ?? \"\" };\n },\n enabled: Boolean(client) && Boolean(path) && Boolean(cwd) && enabled,\n });\n}\n","/**\n * File-viewer registry — maps a detected file kind to the viewer component that renders it\n * (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file preview). `FilePanel` detects the kind from\n * `path` (extension) and the explorer's binary `mimeHint` (for extension-less/ambiguous files),\n * then looks up the viewer here — adding a new file type is one entry in `EXT_TO_VIEWER`/\n * `MIME_PREFIX_TO_VIEWER` plus one entry in `VIEWER_BY_KIND`, no changes to `FilePanel` itself.\n */\n\nimport { lazy, type ComponentType } from \"react\";\n\nexport type ViewerKind = \"text\" | \"markdown\" | \"image\" | \"video\" | \"binary\";\n\nexport interface ViewerProps {\n /** Explorer-relative or absolute path, as opened from the file tree/diff panel. */\n path: string;\n}\n\nconst TextViewer = lazy(() => import(\"./TextViewer.js\").then((m) => ({ default: m.TextViewer })));\nconst MarkdownFileViewer = lazy(() =>\n import(\"./MarkdownFileViewer.js\").then((m) => ({ default: m.MarkdownFileViewer })),\n);\nconst ImageViewer = lazy(() => import(\"./ImageViewer.js\").then((m) => ({ default: m.ImageViewer })));\nconst VideoViewer = lazy(() => import(\"./VideoViewer.js\").then((m) => ({ default: m.VideoViewer })));\nconst BinaryFallbackViewer = lazy(() =>\n import(\"./BinaryFallbackViewer.js\").then((m) => ({ default: m.BinaryFallbackViewer })),\n);\n\n/** One component per `ViewerKind`. Register a new file type here — nowhere else. */\nexport const VIEWER_BY_KIND: Record<ViewerKind, ComponentType<ViewerProps>> = {\n text: TextViewer,\n markdown: MarkdownFileViewer,\n image: ImageViewer,\n video: VideoViewer,\n binary: BinaryFallbackViewer,\n};\n\nconst EXT_TO_VIEWER: Record<string, ViewerKind> = {\n md: \"markdown\",\n markdown: \"markdown\",\n mdx: \"markdown\",\n\n png: \"image\",\n jpg: \"image\",\n jpeg: \"image\",\n gif: \"image\",\n webp: \"image\",\n svg: \"image\",\n bmp: \"image\",\n ico: \"image\",\n avif: \"image\",\n\n mp4: \"video\",\n webm: \"video\",\n mov: \"video\",\n m4v: \"video\",\n ogv: \"video\",\n\n // No dedicated preview yet — show the binary fallback (name + manual download) instead of\n // dumping raw/garbled bytes into the text viewer.\n pdf: \"binary\",\n zip: \"binary\",\n gz: \"binary\",\n tar: \"binary\",\n exe: \"binary\",\n wasm: \"binary\",\n woff: \"binary\",\n woff2: \"binary\",\n ttf: \"binary\",\n otf: \"binary\",\n};\n\nconst MIME_PREFIX_TO_VIEWER: Array<[prefix: string, kind: ViewerKind]> = [\n [\"image/\", \"image\"],\n [\"video/\", \"video\"],\n];\n\nfunction extOf(path: string): string {\n const name = path.split(\"/\").pop() ?? path;\n const dot = name.lastIndexOf(\".\");\n return dot > 0 ? name.slice(dot + 1).toLowerCase() : \"\";\n}\n\n/**\n * Detects the viewer kind for a file, preferring the extension (fast, always available) and\n * falling back to a server-supplied MIME hint (extension-less files, e.g. binary blobs the\n * explorer sniffed) — `isBinary` further distinguishes an unrecognized binary from unrecognized\n * text, so unknown-but-textual files (`.env`, `.gitignore`) still fall through to `TextViewer`.\n */\nexport function detectViewerKind(\n path: string,\n opts: { mimeHint?: string; isBinary?: boolean } = {},\n): ViewerKind {\n const byExt = EXT_TO_VIEWER[extOf(path)];\n if (byExt) return byExt;\n\n const mime = opts.mimeHint ?? \"\";\n for (const [prefix, kind] of MIME_PREFIX_TO_VIEWER) {\n if (mime.startsWith(prefix)) return kind;\n }\n\n if (opts.isBinary) return \"binary\";\n return \"text\";\n}\n","/**\n * FilePanel — the file/diff view toggle panel (POC `buildFilePanel`/`buildDiffPanel` +\n * `loadFileContent`/`loadDiffContent`, chat.html ~line 800-900, POC_TO_APP_PLAN_UI.md §4.5).\n * `panel-registry.ts` mounts this component for BOTH `kind:\"file\"` and `kind:\"diff\"` tabs — a\n * `kind:\"file\"` tab defaults to the File view, a `kind:\"diff\"` tab defaults to the Diff view.\n * Both views stay toggleable within the same panel via local `viewMode` state (not tab-store\n * state), matching the POC's per-panel `showFile`/`showDiff` toggle.\n *\n * The File view dispatches through the modular viewer registry (`viewer-registry.ts`):\n * `detectViewerKind` picks a viewer from the path's extension, and `VIEWER_BY_KIND` resolves the\n * (lazily-loaded) component — text/markdown/image/video today, more by adding one registry entry.\n */\n\nimport { Suspense, useState } from \"react\";\nimport { clsx } from \"clsx\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDiff } from \"@pi-studio-ui/hooks/use-file-diff.js\";\nimport type { Tab, FileTabData, DiffTabData } from \"@pi-studio-ui/stores/tab-store.js\";\nimport { DiffView } from \"./DiffView.js\";\nimport { detectViewerKind, VIEWER_BY_KIND } from \"./viewer-registry.js\";\nimport styles from \"./FilePanel.module.css\";\n\ntype ViewMode = \"file\" | \"diff\";\n\nfunction hasPath(data: Tab[\"data\"]): data is FileTabData | DiffTabData {\n return \"path\" in data;\n}\n\nfunction isDiffTabData(data: FileTabData | DiffTabData): data is DiffTabData {\n return \"staged\" in data;\n}\n\nexport interface FilePanelProps {\n tab: Tab;\n}\n\nexport function FilePanel({ tab }: FilePanelProps) {\n const isDiffTab = tab.kind === \"diff\";\n const data = tab.data;\n const path = hasPath(data) ? data.path : \"\";\n const staged = hasPath(data) && isDiffTabData(data) ? data.staged : false;\n\n const [viewMode, setViewMode] = useState<ViewMode>(isDiffTab ? \"diff\" : \"file\");\n const cwd = tab.workspaceCwd || \"~\";\n\n const diffQuery = useFileDiff(path, cwd, staged, viewMode === \"diff\");\n\n const viewerKind = detectViewerKind(path);\n const Viewer = VIEWER_BY_KIND[viewerKind];\n\n return (\n <div className={styles.panel}>\n <div className={styles.header}>\n <span className={styles.path}>{path}</span>\n <span className={styles.size}>{viewMode === \"diff\" ? (staged ? \"staged\" : \"unstaged\") : null}</span>\n <div className={styles.viewToggle}>\n <Button\n size=\"xs\"\n variant={viewMode === \"file\" ? \"default\" : \"ghost\"}\n onClick={() => setViewMode(\"file\")}\n >\n File\n </Button>\n <Button\n size=\"xs\"\n variant={viewMode === \"diff\" ? \"default\" : \"ghost\"}\n onClick={() => setViewMode(\"diff\")}\n >\n Diff\n </Button>\n </div>\n </div>\n <div className={clsx(styles.body, \"file-body\")}>\n {viewMode === \"file\" ? (\n <Suspense fallback={<div className={styles.emptyState}><Spinner size=\"sm\" /> Loading...</div>}>\n <Viewer path={path} />\n </Suspense>\n ) : diffQuery.isLoading ? (\n <div className={styles.emptyState}>\n <Spinner size=\"sm\" /> Loading diff...\n </div>\n ) : diffQuery.isError ? (\n <div className={styles.emptyState}>\n Error: {diffQuery.error instanceof Error ? diffQuery.error.message : \"unknown error\"}\n </div>\n ) : diffQuery.data?.patch ? (\n <DiffView patch={diffQuery.data.patch} />\n ) : (\n <div className={styles.diffEmpty}>No changes (file matches HEAD)</div>\n )}\n </div>\n </div>\n );\n}\n"],"file":"assets/FilePanel-DFrjCgQW.js"}
1
+ {"version":3,"mappings":";ySAiBO,SAASA,EAAYC,EAAcC,EAAaC,EAAiBC,EAA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,UAAAC,MAAC,QAAK,UAAWD,EAAO,KAAO,SAAA1C,EAAK,EACpC2C,MAAC,QAAK,UAAWD,EAAO,KAAO,aAAa,OAAUxC,EAAS,SAAW,WAAc,KAAK,EAC7FuC,OAAC,OAAI,UAAWC,EAAO,WACrB,UAAAC,MAACC,EAAA,CACC,KAAK,KACL,QAAST,IAAa,OAAS,UAAY,QAC3C,QAAS,IAAMC,EAAY,MAAM,EAClC,kBAGDO,MAACC,EAAA,CACC,KAAK,KACL,QAAST,IAAa,OAAS,UAAY,QAC3C,QAAS,IAAMC,EAAY,MAAM,EAClC,iBAED,EACF,GACF,QACC,OAAI,UAAWS,EAAKH,EAAO,KAAM,WAAW,EAC1C,SAAAP,IAAa,aACXW,WAAA,CAAS,gBAAW,OAAI,UAAWJ,EAAO,WAAY,UAAAC,MAACI,EAAA,CAAQ,KAAK,KAAK,EAAE,eAAW,EACrF,SAAAJ,MAACH,EAAA,CAAO,KAAAxC,CAAA,CAAY,EACtB,EACEsC,EAAU,UACZG,OAAC,OAAI,UAAWC,EAAO,WACrB,UAAAC,MAACI,EAAA,CAAQ,KAAK,KAAK,EAAE,oBACvB,EACET,EAAU,eACX,OAAI,UAAWI,EAAO,WAAY,oBACzBJ,EAAU,iBAAiB,MAAQA,EAAU,MAAM,QAAU,iBACvE,GACEU,EAAAV,EAAU,OAAV,MAAAU,EAAgB,MAClBL,MAACM,GAAS,MAAOX,EAAU,KAAK,MAAO,EAEvCK,MAAC,OAAI,UAAWD,EAAO,UAAW,0CAA8B,EAEpE,GACF,CAEJ","names":["useFileDiff","path","cwd","staged","enabled","client","useConnectionStore","s","useQuery","rpcKeys","TextViewer","lazy","__vitePreload","m","MarkdownFileViewer","ImageViewer","VideoViewer","BinaryFallbackViewer","VIEWER_BY_KIND","EXT_TO_VIEWER","MIME_PREFIX_TO_VIEWER","extOf","name","dot","detectViewerKind","opts","byExt","mime","prefix","kind","hasPath","data","isDiffTabData","FilePanel","tab","isDiffTab","viewMode","setViewMode","useState","diffQuery","viewerKind","Viewer","jsxs","styles","jsx","Button","clsx","Suspense","Spinner","_a","DiffView"],"ignoreList":[],"sources":["../../../src/hooks/use-file-diff.ts","../../../src/features/files/viewer-registry.ts","../../../src/features/files/FilePanel.tsx"],"sourcesContent":["/**\n * `use-file-diff` — TanStack Query wrapper over `file_diff_request` (POC `loadDiffContent`,\n * POC_TO_APP_PLAN_UI.md §4.5 / §3 `hooks/use-file-diff.ts`).\n */\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\n\nexport interface FileDiffResult {\n patch: string;\n}\n\ninterface FileDiffRpcResponse {\n patch?: string;\n}\n\nexport function useFileDiff(path: string, cwd: string, staged: boolean, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n\n return useQuery({\n queryKey: rpcKeys.fileDiff(path, cwd, staged),\n queryFn: async (): Promise<FileDiffResult> => {\n if (!client) throw new Error(\"not connected\");\n const response = await client.connection.request<FileDiffRpcResponse>(\"file_diff_request\", {\n path,\n cwd,\n staged,\n });\n return { patch: response.patch ?? \"\" };\n },\n enabled: Boolean(client) && Boolean(path) && Boolean(cwd) && enabled,\n });\n}\n","/**\n * File-viewer registry — maps a detected file kind to the viewer component that renders it\n * (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file preview). `FilePanel` detects the kind from\n * `path` (extension) and the explorer's binary `mimeHint` (for extension-less/ambiguous files),\n * then looks up the viewer here — adding a new file type is one entry in `EXT_TO_VIEWER`/\n * `MIME_PREFIX_TO_VIEWER` plus one entry in `VIEWER_BY_KIND`, no changes to `FilePanel` itself.\n */\n\nimport { lazy, type ComponentType } from \"react\";\n\nexport type ViewerKind = \"text\" | \"markdown\" | \"image\" | \"video\" | \"binary\";\n\nexport interface ViewerProps {\n /** Explorer-relative or absolute path, as opened from the file tree/diff panel. */\n path: string;\n}\n\nconst TextViewer = lazy(() => import(\"./TextViewer.js\").then((m) => ({ default: m.TextViewer })));\nconst MarkdownFileViewer = lazy(() =>\n import(\"./MarkdownFileViewer.js\").then((m) => ({ default: m.MarkdownFileViewer })),\n);\nconst ImageViewer = lazy(() => import(\"./ImageViewer.js\").then((m) => ({ default: m.ImageViewer })));\nconst VideoViewer = lazy(() => import(\"./VideoViewer.js\").then((m) => ({ default: m.VideoViewer })));\nconst BinaryFallbackViewer = lazy(() =>\n import(\"./BinaryFallbackViewer.js\").then((m) => ({ default: m.BinaryFallbackViewer })),\n);\n\n/** One component per `ViewerKind`. Register a new file type here — nowhere else. */\nexport const VIEWER_BY_KIND: Record<ViewerKind, ComponentType<ViewerProps>> = {\n text: TextViewer,\n markdown: MarkdownFileViewer,\n image: ImageViewer,\n video: VideoViewer,\n binary: BinaryFallbackViewer,\n};\n\nconst EXT_TO_VIEWER: Record<string, ViewerKind> = {\n md: \"markdown\",\n markdown: \"markdown\",\n mdx: \"markdown\",\n\n png: \"image\",\n jpg: \"image\",\n jpeg: \"image\",\n gif: \"image\",\n webp: \"image\",\n svg: \"image\",\n bmp: \"image\",\n ico: \"image\",\n avif: \"image\",\n\n mp4: \"video\",\n webm: \"video\",\n mov: \"video\",\n m4v: \"video\",\n ogv: \"video\",\n\n // No dedicated preview yet — show the binary fallback (name + manual download) instead of\n // dumping raw/garbled bytes into the text viewer.\n pdf: \"binary\",\n zip: \"binary\",\n gz: \"binary\",\n tar: \"binary\",\n exe: \"binary\",\n wasm: \"binary\",\n woff: \"binary\",\n woff2: \"binary\",\n ttf: \"binary\",\n otf: \"binary\",\n};\n\nconst MIME_PREFIX_TO_VIEWER: Array<[prefix: string, kind: ViewerKind]> = [\n [\"image/\", \"image\"],\n [\"video/\", \"video\"],\n];\n\nfunction extOf(path: string): string {\n const name = path.split(\"/\").pop() ?? path;\n const dot = name.lastIndexOf(\".\");\n return dot > 0 ? name.slice(dot + 1).toLowerCase() : \"\";\n}\n\n/**\n * Detects the viewer kind for a file, preferring the extension (fast, always available) and\n * falling back to a server-supplied MIME hint (extension-less files, e.g. binary blobs the\n * explorer sniffed) — `isBinary` further distinguishes an unrecognized binary from unrecognized\n * text, so unknown-but-textual files (`.env`, `.gitignore`) still fall through to `TextViewer`.\n */\nexport function detectViewerKind(\n path: string,\n opts: { mimeHint?: string; isBinary?: boolean } = {},\n): ViewerKind {\n const byExt = EXT_TO_VIEWER[extOf(path)];\n if (byExt) return byExt;\n\n const mime = opts.mimeHint ?? \"\";\n for (const [prefix, kind] of MIME_PREFIX_TO_VIEWER) {\n if (mime.startsWith(prefix)) return kind;\n }\n\n if (opts.isBinary) return \"binary\";\n return \"text\";\n}\n","/**\n * FilePanel — the file/diff view toggle panel (POC `buildFilePanel`/`buildDiffPanel` +\n * `loadFileContent`/`loadDiffContent`, chat.html ~line 800-900, POC_TO_APP_PLAN_UI.md §4.5).\n * `panel-registry.ts` mounts this component for BOTH `kind:\"file\"` and `kind:\"diff\"` tabs — a\n * `kind:\"file\"` tab defaults to the File view, a `kind:\"diff\"` tab defaults to the Diff view.\n * Both views stay toggleable within the same panel via local `viewMode` state (not tab-store\n * state), matching the POC's per-panel `showFile`/`showDiff` toggle.\n *\n * The File view dispatches through the modular viewer registry (`viewer-registry.ts`):\n * `detectViewerKind` picks a viewer from the path's extension, and `VIEWER_BY_KIND` resolves the\n * (lazily-loaded) component — text/markdown/image/video today, more by adding one registry entry.\n */\n\nimport { Suspense, useState } from \"react\";\nimport { clsx } from \"clsx\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDiff } from \"@pi-studio-ui/hooks/use-file-diff.js\";\nimport type { Tab, FileTabData, DiffTabData } from \"@pi-studio-ui/stores/tab-store.js\";\nimport { DiffView } from \"./DiffView.js\";\nimport { detectViewerKind, VIEWER_BY_KIND } from \"./viewer-registry.js\";\nimport styles from \"./FilePanel.module.css\";\n\ntype ViewMode = \"file\" | \"diff\";\n\nfunction hasPath(data: Tab[\"data\"]): data is FileTabData | DiffTabData {\n return \"path\" in data;\n}\n\nfunction isDiffTabData(data: FileTabData | DiffTabData): data is DiffTabData {\n return \"staged\" in data;\n}\n\nexport interface FilePanelProps {\n tab: Tab;\n}\n\nexport function FilePanel({ tab }: FilePanelProps) {\n const isDiffTab = tab.kind === \"diff\";\n const data = tab.data;\n const path = hasPath(data) ? data.path : \"\";\n const staged = hasPath(data) && isDiffTabData(data) ? data.staged : false;\n\n const [viewMode, setViewMode] = useState<ViewMode>(isDiffTab ? \"diff\" : \"file\");\n const cwd = tab.workspaceCwd || \"~\";\n\n const diffQuery = useFileDiff(path, cwd, staged, viewMode === \"diff\");\n\n const viewerKind = detectViewerKind(path);\n const Viewer = VIEWER_BY_KIND[viewerKind];\n\n return (\n <div className={styles.panel}>\n <div className={styles.header}>\n <span className={styles.path}>{path}</span>\n <span className={styles.size}>{viewMode === \"diff\" ? (staged ? \"staged\" : \"unstaged\") : null}</span>\n <div className={styles.viewToggle}>\n <Button\n size=\"xs\"\n variant={viewMode === \"file\" ? \"default\" : \"ghost\"}\n onClick={() => setViewMode(\"file\")}\n >\n File\n </Button>\n <Button\n size=\"xs\"\n variant={viewMode === \"diff\" ? \"default\" : \"ghost\"}\n onClick={() => setViewMode(\"diff\")}\n >\n Diff\n </Button>\n </div>\n </div>\n <div className={clsx(styles.body, \"file-body\")}>\n {viewMode === \"file\" ? (\n <Suspense fallback={<div className={styles.emptyState}><Spinner size=\"sm\" /> Loading...</div>}>\n <Viewer path={path} />\n </Suspense>\n ) : diffQuery.isLoading ? (\n <div className={styles.emptyState}>\n <Spinner size=\"sm\" /> Loading diff...\n </div>\n ) : diffQuery.isError ? (\n <div className={styles.emptyState}>\n Error: {diffQuery.error instanceof Error ? diffQuery.error.message : \"unknown error\"}\n </div>\n ) : diffQuery.data?.patch ? (\n <DiffView patch={diffQuery.data.patch} />\n ) : (\n <div className={styles.diffEmpty}>No changes (file matches HEAD)</div>\n )}\n </div>\n </div>\n );\n}\n"],"file":"assets/FilePanel-VOhIehHw.js"}
@@ -1,2 +1,2 @@
1
- import{j as e}from"./vendor-react-BoIQBqDW.js";import{S as t}from"./index-B_Wls_vp.js";import{u as a}from"./use-file-download-BxA_7HBl.js";import{p as s}from"./FilePanel-DFrjCgQW.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-BJD_eLBz.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./DiffView-DlVCPvLc.js";const m="_wrap_1al28_1",n="_image_1al28_14",o={wrap:m,image:n};function S({path:i}){const r=a(i);return r.isLoading?e.jsxs("div",{className:s.emptyState,children:[e.jsx(t,{size:"sm"})," Loading image..."]}):r.isError?e.jsxs("div",{className:s.emptyState,children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?e.jsx("div",{className:o.wrap,children:e.jsx("img",{className:o.image,src:r.data.objectUrl,alt:i.split("/").pop()||i})}):null}export{S as ImageViewer};
2
- //# sourceMappingURL=ImageViewer-BU0ZsYF9.js.map
1
+ import{j as e}from"./vendor-react-BoIQBqDW.js";import{S as t}from"./index-C5SpA_B-.js";import{u as a}from"./use-file-download-t12JJGKT.js";import{p as s}from"./FilePanel-VOhIehHw.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-BouiMPVM.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./DiffView-DlVCPvLc.js";const m="_wrap_1al28_1",n="_image_1al28_14",o={wrap:m,image:n};function S({path:i}){const r=a(i);return r.isLoading?e.jsxs("div",{className:s.emptyState,children:[e.jsx(t,{size:"sm"})," Loading image..."]}):r.isError?e.jsxs("div",{className:s.emptyState,children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?e.jsx("div",{className:o.wrap,children:e.jsx("img",{className:o.image,src:r.data.objectUrl,alt:i.split("/").pop()||i})}):null}export{S as ImageViewer};
2
+ //# sourceMappingURL=ImageViewer-BivcSG2D.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ImageViewer-BU0ZsYF9.js","sources":["../../../src/features/files/ImageViewer.tsx"],"sourcesContent":["/**\n * ImageViewer — renders a binary image file by downloading it over the file-transfer binary\n * frames (`useFileDownload`) and displaying the resulting object URL (POC_TO_APP_PLAN_UI.md §4.5\n * follow-up: modular file preview). A checkerboard background shows through transparent PNGs.\n */\n\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDownload } from \"@pi-studio-ui/hooks/use-file-download.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport panelStyles from \"./FilePanel.module.css\";\nimport styles from \"./ImageViewer.module.css\";\n\nexport function ImageViewer({ path }: ViewerProps) {\n const query = useFileDownload(path);\n\n if (query.isLoading) {\n return (\n <div className={panelStyles.emptyState}>\n <Spinner size=\"sm\" /> Loading image...\n </div>\n );\n }\n if (query.isError) {\n return (\n <div className={panelStyles.emptyState}>\n Error: {query.error instanceof Error ? query.error.message : \"unknown error\"}\n </div>\n );\n }\n if (!query.data) return null;\n\n return (\n <div className={styles.wrap}>\n <img className={styles.image} src={query.data.objectUrl} alt={path.split(\"/\").pop() || path} />\n </div>\n );\n}\n"],"names":["ImageViewer","path","query","useFileDownload","jsxs","panelStyles","jsx","Spinner","styles"],"mappings":"4gBAYO,SAASA,EAAY,CAAE,KAAAC,GAAqB,CACjD,MAAMC,EAAQC,EAAgBF,CAAI,EAElC,OAAIC,EAAM,UAENE,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAC1B,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAQ,KAAK,IAAA,CAAK,EAAE,mBAAA,EACvB,EAGAL,EAAM,QAENE,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAAY,SAAA,CAAA,UAC9BH,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,eAAA,EAC/D,EAGCA,EAAM,KAGTI,MAAC,OAAI,UAAWE,EAAO,KACrB,SAAAF,MAAC,MAAA,CAAI,UAAWE,EAAO,MAAO,IAAKN,EAAM,KAAK,UAAW,IAAKD,EAAK,MAAM,GAAG,EAAE,IAAA,GAASA,CAAA,CAAM,CAAA,CAC/F,EALsB,IAO1B"}
1
+ {"version":3,"file":"ImageViewer-BivcSG2D.js","sources":["../../../src/features/files/ImageViewer.tsx"],"sourcesContent":["/**\n * ImageViewer — renders a binary image file by downloading it over the file-transfer binary\n * frames (`useFileDownload`) and displaying the resulting object URL (POC_TO_APP_PLAN_UI.md §4.5\n * follow-up: modular file preview). A checkerboard background shows through transparent PNGs.\n */\n\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileDownload } from \"@pi-studio-ui/hooks/use-file-download.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport panelStyles from \"./FilePanel.module.css\";\nimport styles from \"./ImageViewer.module.css\";\n\nexport function ImageViewer({ path }: ViewerProps) {\n const query = useFileDownload(path);\n\n if (query.isLoading) {\n return (\n <div className={panelStyles.emptyState}>\n <Spinner size=\"sm\" /> Loading image...\n </div>\n );\n }\n if (query.isError) {\n return (\n <div className={panelStyles.emptyState}>\n Error: {query.error instanceof Error ? query.error.message : \"unknown error\"}\n </div>\n );\n }\n if (!query.data) return null;\n\n return (\n <div className={styles.wrap}>\n <img className={styles.image} src={query.data.objectUrl} alt={path.split(\"/\").pop() || path} />\n </div>\n );\n}\n"],"names":["ImageViewer","path","query","useFileDownload","jsxs","panelStyles","jsx","Spinner","styles"],"mappings":"4gBAYO,SAASA,EAAY,CAAE,KAAAC,GAAqB,CACjD,MAAMC,EAAQC,EAAgBF,CAAI,EAElC,OAAIC,EAAM,UAENE,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAC1B,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAQ,KAAK,IAAA,CAAK,EAAE,mBAAA,EACvB,EAGAL,EAAM,QAENE,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAAY,SAAA,CAAA,UAC9BH,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,eAAA,EAC/D,EAGCA,EAAM,KAGTI,MAAC,OAAI,UAAWE,EAAO,KACrB,SAAAF,MAAC,MAAA,CAAI,UAAWE,EAAO,MAAO,IAAKN,EAAM,KAAK,UAAW,IAAKD,EAAK,MAAM,GAAG,EAAE,IAAA,GAASA,CAAA,CAAM,CAAA,CAC/F,EALsB,IAO1B"}
@@ -1,2 +1,2 @@
1
- import{r as d,j as r}from"./vendor-react-BoIQBqDW.js";import{S as c,B as a}from"./index-B_Wls_vp.js";import{u as m,C as p}from"./CodeView-CHtX3XUo.js";import{M as l}from"./markdown-D9FuaV1m.js";import{p as n}from"./FilePanel-DFrjCgQW.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-BJD_eLBz.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./DiffView-DlVCPvLc.js";const x="_wrap_khhx0_1",u="_toolbar_khhx0_6",h="_rendered_khhx0_17",o={wrap:x,toolbar:u,rendered:h};function M({path:s}){const e=m(s),[t,i]=d.useState("preview");return e.isLoading?r.jsxs("div",{className:n.emptyState,children:[r.jsx(c,{size:"sm"})," Loading..."]}):e.isError?r.jsxs("div",{className:n.emptyState,children:["Error: ",e.error instanceof Error?e.error.message:"unknown error"]}):e.data?r.jsxs("div",{className:o.wrap,children:[r.jsxs("div",{className:o.toolbar,children:[r.jsx(a,{size:"xs",variant:t==="preview"?"default":"ghost",onClick:()=>i("preview"),children:"Preview"}),r.jsx(a,{size:"xs",variant:t==="source"?"default":"ghost",onClick:()=>i("source"),children:"Source"})]}),t==="preview"?r.jsx("div",{className:o.rendered,children:r.jsx(l,{text:e.data.content})}):r.jsx(p,{path:s,content:e.data.content})]}):null}export{M as MarkdownFileViewer};
2
- //# sourceMappingURL=MarkdownFileViewer-n81kPpQE.js.map
1
+ import{r as d,j as r}from"./vendor-react-BoIQBqDW.js";import{S as c,B as a}from"./index-C5SpA_B-.js";import{u as m,C as p}from"./CodeView-z3x4ATgx.js";import{M as l}from"./markdown-D9FuaV1m.js";import{p as n}from"./FilePanel-VOhIehHw.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-BouiMPVM.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./DiffView-DlVCPvLc.js";const x="_wrap_khhx0_1",u="_toolbar_khhx0_6",h="_rendered_khhx0_17",o={wrap:x,toolbar:u,rendered:h};function M({path:s}){const e=m(s),[t,i]=d.useState("preview");return e.isLoading?r.jsxs("div",{className:n.emptyState,children:[r.jsx(c,{size:"sm"})," Loading..."]}):e.isError?r.jsxs("div",{className:n.emptyState,children:["Error: ",e.error instanceof Error?e.error.message:"unknown error"]}):e.data?r.jsxs("div",{className:o.wrap,children:[r.jsxs("div",{className:o.toolbar,children:[r.jsx(a,{size:"xs",variant:t==="preview"?"default":"ghost",onClick:()=>i("preview"),children:"Preview"}),r.jsx(a,{size:"xs",variant:t==="source"?"default":"ghost",onClick:()=>i("source"),children:"Source"})]}),t==="preview"?r.jsx("div",{className:o.rendered,children:r.jsx(l,{text:e.data.content})}):r.jsx(p,{path:s,content:e.data.content})]}):null}export{M as MarkdownFileViewer};
2
+ //# sourceMappingURL=MarkdownFileViewer-CcfSk7Qc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownFileViewer-n81kPpQE.js","sources":["../../../src/features/files/MarkdownFileViewer.tsx"],"sourcesContent":["/**\n * MarkdownFileViewer — renders a `.md`/`.mdx` file's content through the app's sanitized\n * Markdown renderer (`timeline/markdown.tsx`, react-markdown + remark-gfm — no\n * `dangerouslySetInnerHTML` of user content), with a Preview/Source toggle since raw markdown is\n * sometimes what you actually want to read (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file\n * preview).\n */\n\nimport { useState } from \"react\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileRead } from \"@pi-studio-ui/hooks/use-file-read.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport { CodeView } from \"./CodeView.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport panelStyles from \"./FilePanel.module.css\";\nimport styles from \"./MarkdownFileViewer.module.css\";\n\ntype Mode = \"preview\" | \"source\";\n\nexport function MarkdownFileViewer({ path }: ViewerProps) {\n const query = useFileRead(path);\n const [mode, setMode] = useState<Mode>(\"preview\");\n\n if (query.isLoading) {\n return (\n <div className={panelStyles.emptyState}>\n <Spinner size=\"sm\" /> Loading...\n </div>\n );\n }\n if (query.isError) {\n return (\n <div className={panelStyles.emptyState}>\n Error: {query.error instanceof Error ? query.error.message : \"unknown error\"}\n </div>\n );\n }\n if (!query.data) return null;\n\n return (\n <div className={styles.wrap}>\n <div className={styles.toolbar}>\n <Button size=\"xs\" variant={mode === \"preview\" ? \"default\" : \"ghost\"} onClick={() => setMode(\"preview\")}>\n Preview\n </Button>\n <Button size=\"xs\" variant={mode === \"source\" ? \"default\" : \"ghost\"} onClick={() => setMode(\"source\")}>\n Source\n </Button>\n </div>\n {mode === \"preview\" ? (\n <div className={styles.rendered}>\n <Markdown text={query.data.content} />\n </div>\n ) : (\n <CodeView path={path} content={query.data.content} />\n )}\n </div>\n );\n}\n"],"names":["MarkdownFileViewer","path","query","useFileRead","mode","setMode","useState","jsxs","panelStyles","jsx","Spinner","styles","Button","Markdown","CodeView"],"mappings":"wmBAoBO,SAASA,EAAmB,CAAE,KAAAC,GAAqB,CACxD,MAAMC,EAAQC,EAAYF,CAAI,EACxB,CAACG,EAAMC,CAAO,EAAIC,EAAAA,SAAe,SAAS,EAEhD,OAAIJ,EAAM,UAENK,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAC1B,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAQ,KAAK,IAAA,CAAK,EAAE,aAAA,EACvB,EAGAR,EAAM,QAENK,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAAY,SAAA,CAAA,UAC9BN,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,eAAA,EAC/D,EAGCA,EAAM,KAGTK,EAAAA,KAAC,MAAA,CAAI,UAAWI,EAAO,KACrB,SAAA,CAAAJ,EAAAA,KAAC,MAAA,CAAI,UAAWI,EAAO,QACrB,SAAA,CAAAF,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAASR,IAAS,UAAY,UAAY,QAAS,QAAS,IAAMC,EAAQ,SAAS,EAAG,SAAA,UAExG,EACAI,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAASR,IAAS,SAAW,UAAY,QAAS,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtG,CAAA,EACF,EACCD,IAAS,UACRK,MAAC,MAAA,CAAI,UAAWE,EAAO,SACrB,eAACE,EAAA,CAAS,KAAMX,EAAM,KAAK,OAAA,CAAS,EACtC,EAEAO,EAAAA,IAACK,GAAS,KAAAb,EAAY,QAASC,EAAM,KAAK,OAAA,CAAS,CAAA,EAEvD,EAnBsB,IAqB1B"}
1
+ {"version":3,"file":"MarkdownFileViewer-CcfSk7Qc.js","sources":["../../../src/features/files/MarkdownFileViewer.tsx"],"sourcesContent":["/**\n * MarkdownFileViewer — renders a `.md`/`.mdx` file's content through the app's sanitized\n * Markdown renderer (`timeline/markdown.tsx`, react-markdown + remark-gfm — no\n * `dangerouslySetInnerHTML` of user content), with a Preview/Source toggle since raw markdown is\n * sometimes what you actually want to read (POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular file\n * preview).\n */\n\nimport { useState } from \"react\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { Spinner } from \"@pi-studio-ui/components/primitives/Spinner.js\";\nimport { useFileRead } from \"@pi-studio-ui/hooks/use-file-read.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport { CodeView } from \"./CodeView.js\";\nimport type { ViewerProps } from \"./viewer-registry.js\";\nimport panelStyles from \"./FilePanel.module.css\";\nimport styles from \"./MarkdownFileViewer.module.css\";\n\ntype Mode = \"preview\" | \"source\";\n\nexport function MarkdownFileViewer({ path }: ViewerProps) {\n const query = useFileRead(path);\n const [mode, setMode] = useState<Mode>(\"preview\");\n\n if (query.isLoading) {\n return (\n <div className={panelStyles.emptyState}>\n <Spinner size=\"sm\" /> Loading...\n </div>\n );\n }\n if (query.isError) {\n return (\n <div className={panelStyles.emptyState}>\n Error: {query.error instanceof Error ? query.error.message : \"unknown error\"}\n </div>\n );\n }\n if (!query.data) return null;\n\n return (\n <div className={styles.wrap}>\n <div className={styles.toolbar}>\n <Button size=\"xs\" variant={mode === \"preview\" ? \"default\" : \"ghost\"} onClick={() => setMode(\"preview\")}>\n Preview\n </Button>\n <Button size=\"xs\" variant={mode === \"source\" ? \"default\" : \"ghost\"} onClick={() => setMode(\"source\")}>\n Source\n </Button>\n </div>\n {mode === \"preview\" ? (\n <div className={styles.rendered}>\n <Markdown text={query.data.content} />\n </div>\n ) : (\n <CodeView path={path} content={query.data.content} />\n )}\n </div>\n );\n}\n"],"names":["MarkdownFileViewer","path","query","useFileRead","mode","setMode","useState","jsxs","panelStyles","jsx","Spinner","styles","Button","Markdown","CodeView"],"mappings":"wmBAoBO,SAASA,EAAmB,CAAE,KAAAC,GAAqB,CACxD,MAAMC,EAAQC,EAAYF,CAAI,EACxB,CAACG,EAAMC,CAAO,EAAIC,EAAAA,SAAe,SAAS,EAEhD,OAAIJ,EAAM,UAENK,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAC1B,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAQ,KAAK,IAAA,CAAK,EAAE,aAAA,EACvB,EAGAR,EAAM,QAENK,EAAAA,KAAC,MAAA,CAAI,UAAWC,EAAY,WAAY,SAAA,CAAA,UAC9BN,EAAM,iBAAiB,MAAQA,EAAM,MAAM,QAAU,eAAA,EAC/D,EAGCA,EAAM,KAGTK,EAAAA,KAAC,MAAA,CAAI,UAAWI,EAAO,KACrB,SAAA,CAAAJ,EAAAA,KAAC,MAAA,CAAI,UAAWI,EAAO,QACrB,SAAA,CAAAF,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAASR,IAAS,UAAY,UAAY,QAAS,QAAS,IAAMC,EAAQ,SAAS,EAAG,SAAA,UAExG,EACAI,EAAAA,IAACG,EAAA,CAAO,KAAK,KAAK,QAASR,IAAS,SAAW,UAAY,QAAS,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtG,CAAA,EACF,EACCD,IAAS,UACRK,MAAC,MAAA,CAAI,UAAWE,EAAO,SACrB,eAACE,EAAA,CAAS,KAAMX,EAAM,KAAK,OAAA,CAAS,EACtC,EAEAO,EAAAA,IAACK,GAAS,KAAAb,EAAY,QAASC,EAAM,KAAK,OAAA,CAAS,CAAA,EAEvD,EAnBsB,IAqB1B"}
@@ -1,2 +1,2 @@
1
- var A=Object.defineProperty;var I=(n,e,t)=>e in n?A(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>I(n,typeof e!="symbol"?e+"":e,t);import{r as a,j as l}from"./vendor-react-BoIQBqDW.js";import{x as B,a as F}from"./vendor-terminal-BhzX2_ts.js";import{e as E,a as N,b as T,S as D}from"./index-B_Wls_vp.js";import"./vendor--os7hw7d.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor-icons-BJD_eLBz.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-markdown-B8HSIhaA.js";class O{constructor(e){g(this,"subscribers",new Map);g(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onTerminalFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null}subscribeSlot(e,t){return this.subscribers.set(e,t),()=>{this.subscribers.get(e)===t&&this.subscribers.delete(e)}}hasSlot(e){return this.subscribers.has(e)}sendInput(e,t){this.daemon.sendBinary(E({opcode:"Input",slot:e,data:t}))}sendResize(e,t,m){this.daemon.sendBinary(E({opcode:"Resize",slot:e,rows:t,cols:m}))}dispatch(e){var m,p,u;const t=this.subscribers.get(e.slot);if(t)switch(e.opcode){case"Output":(m=t.onOutput)==null||m.call(t,e.data);return;case"Snapshot":(p=t.onSnapshot)==null||p.call(t,e.data);return;case"Restore":(u=t.onRestore)==null||u.call(t,e.data);return;default:return}}}const C="_wrap_b74ul_1",P="_terminal_b74ul_11",W="_status_b74ul_18",f={wrap:C,terminal:P,status:W},q=new WeakMap;function G(n){let e=q.get(n);return e||(e=new O(n),e.start(),q.set(n,e)),e}const H={background:"#181b1a",foreground:"#fafafa",cursor:"#a2b4d7",cursorAccent:"#181b1a",selectionBackground:"rgba(255,255,255,0.18)",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#14b8a6",white:"#d4d4d8",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#2dd4bf",brightWhite:"#fafafa"};function te({tab:n}){const e=n.data,t=N(r=>r.client),p=T(r=>r.activeTabId)===n.id,u=a.useRef(null),w=a.useRef(null),h=a.useRef(null),b=a.useRef(e.slot),S=a.useRef(t);S.current=t;const[c,k]=a.useState(e.slot),[_,v]=a.useState(null),d=a.useRef(!1),R=a.useRef(!1);return a.useEffect(()=>{if(d.current=!0,!t||b.current!==null||R.current)return()=>{d.current=!1};R.current=!0;const r=e.cwd||"~";return t.connection.request("create_terminal_request",{workspaceId:"",cwd:r}).then(s=>{const i=s.terminal.slot;if(!d.current){t.connection.request("kill_terminal_request",{slot:i}).catch(()=>{});return}b.current=i,k(i),T.getState().updateData(n.id,{slot:i})}).catch(s=>{d.current&&v(s instanceof Error?s.message:String(s))}).finally(()=>{R.current=!1}),()=>{d.current=!1}},[t,n.id]),a.useEffect(()=>()=>{const r=b.current;r!==null&&setTimeout(()=>{var s;d.current||(s=S.current)==null||s.connection.request("kill_terminal_request",{slot:r}).catch(()=>{})},0)},[]),a.useEffect(()=>{if(!t||c===null||!u.current)return;const r=new B.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,scrollback:5e3,theme:H,allowProposedApi:!0}),s=new F.FitAddon;r.loadAddon(s),r.open(u.current),s.fit(),w.current=r,h.current=s;const i=G(t.connection),j=i.subscribeSlot(c,{onOutput:o=>r.write(o),onSnapshot:o=>{r.clear(),r.write(o)},onRestore:o=>r.write(o)});t.connection.request("subscribe_terminal_request",{slot:c}).catch(o=>{v(o instanceof Error?o.message:String(o))});const y=r.onData(o=>{i.sendInput(c,new TextEncoder().encode(o))}),z=r.onResize(({cols:o,rows:M})=>{i.sendResize(c,M,o)}),x=new ResizeObserver(()=>{s.fit()});return x.observe(u.current),()=>{x.disconnect(),y.dispose(),z.dispose(),j(),t.connection.request("unsubscribe_terminal_request",{slot:c}).catch(()=>{}),r.dispose(),w.current=null,h.current=null}},[t,c]),a.useEffect(()=>{var r;p&&((r=h.current)==null||r.fit())},[p]),_?l.jsx("div",{className:f.wrap,children:l.jsxs("div",{className:f.status,children:["Terminal error: ",_]})}):c===null?l.jsx("div",{className:f.wrap,children:l.jsxs("div",{className:f.status,children:[l.jsx(D,{size:"sm"})," Starting terminal…"]})}):l.jsx("div",{className:f.wrap,children:l.jsx("div",{ref:u,className:f.terminal})})}export{te as TerminalPanel};
2
- //# sourceMappingURL=TerminalPanel-yVOy1dbu.js.map
1
+ var A=Object.defineProperty;var I=(n,e,t)=>e in n?A(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>I(n,typeof e!="symbol"?e+"":e,t);import{r as a,j as l}from"./vendor-react-BoIQBqDW.js";import{x as B,a as F}from"./vendor-terminal-BhzX2_ts.js";import{e as E,a as N,b as T,S as D}from"./index-C5SpA_B-.js";import"./vendor--os7hw7d.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor-icons-BouiMPVM.js";import"./vendor-overlays-UwLNGk04.js";import"./vendor-dnd-D9kA7FgH.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-markdown-B8HSIhaA.js";class O{constructor(e){g(this,"subscribers",new Map);g(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onTerminalFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null}subscribeSlot(e,t){return this.subscribers.set(e,t),()=>{this.subscribers.get(e)===t&&this.subscribers.delete(e)}}hasSlot(e){return this.subscribers.has(e)}sendInput(e,t){this.daemon.sendBinary(E({opcode:"Input",slot:e,data:t}))}sendResize(e,t,m){this.daemon.sendBinary(E({opcode:"Resize",slot:e,rows:t,cols:m}))}dispatch(e){var m,p,u;const t=this.subscribers.get(e.slot);if(t)switch(e.opcode){case"Output":(m=t.onOutput)==null||m.call(t,e.data);return;case"Snapshot":(p=t.onSnapshot)==null||p.call(t,e.data);return;case"Restore":(u=t.onRestore)==null||u.call(t,e.data);return;default:return}}}const C="_wrap_b74ul_1",P="_terminal_b74ul_11",W="_status_b74ul_18",f={wrap:C,terminal:P,status:W},q=new WeakMap;function G(n){let e=q.get(n);return e||(e=new O(n),e.start(),q.set(n,e)),e}const H={background:"#181b1a",foreground:"#fafafa",cursor:"#a2b4d7",cursorAccent:"#181b1a",selectionBackground:"rgba(255,255,255,0.18)",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#14b8a6",white:"#d4d4d8",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#2dd4bf",brightWhite:"#fafafa"};function te({tab:n}){const e=n.data,t=N(r=>r.client),p=T(r=>r.activeTabId)===n.id,u=a.useRef(null),w=a.useRef(null),h=a.useRef(null),b=a.useRef(e.slot),S=a.useRef(t);S.current=t;const[c,k]=a.useState(e.slot),[_,v]=a.useState(null),d=a.useRef(!1),R=a.useRef(!1);return a.useEffect(()=>{if(d.current=!0,!t||b.current!==null||R.current)return()=>{d.current=!1};R.current=!0;const r=e.cwd||"~";return t.connection.request("create_terminal_request",{workspaceId:"",cwd:r}).then(s=>{const i=s.terminal.slot;if(!d.current){t.connection.request("kill_terminal_request",{slot:i}).catch(()=>{});return}b.current=i,k(i),T.getState().updateData(n.id,{slot:i})}).catch(s=>{d.current&&v(s instanceof Error?s.message:String(s))}).finally(()=>{R.current=!1}),()=>{d.current=!1}},[t,n.id]),a.useEffect(()=>()=>{const r=b.current;r!==null&&setTimeout(()=>{var s;d.current||(s=S.current)==null||s.connection.request("kill_terminal_request",{slot:r}).catch(()=>{})},0)},[]),a.useEffect(()=>{if(!t||c===null||!u.current)return;const r=new B.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,scrollback:5e3,theme:H,allowProposedApi:!0}),s=new F.FitAddon;r.loadAddon(s),r.open(u.current),s.fit(),w.current=r,h.current=s;const i=G(t.connection),j=i.subscribeSlot(c,{onOutput:o=>r.write(o),onSnapshot:o=>{r.clear(),r.write(o)},onRestore:o=>r.write(o)});t.connection.request("subscribe_terminal_request",{slot:c}).catch(o=>{v(o instanceof Error?o.message:String(o))});const y=r.onData(o=>{i.sendInput(c,new TextEncoder().encode(o))}),z=r.onResize(({cols:o,rows:M})=>{i.sendResize(c,M,o)}),x=new ResizeObserver(()=>{s.fit()});return x.observe(u.current),()=>{x.disconnect(),y.dispose(),z.dispose(),j(),t.connection.request("unsubscribe_terminal_request",{slot:c}).catch(()=>{}),r.dispose(),w.current=null,h.current=null}},[t,c]),a.useEffect(()=>{var r;p&&((r=h.current)==null||r.fit())},[p]),_?l.jsx("div",{className:f.wrap,children:l.jsxs("div",{className:f.status,children:["Terminal error: ",_]})}):c===null?l.jsx("div",{className:f.wrap,children:l.jsxs("div",{className:f.status,children:[l.jsx(D,{size:"sm"})," Starting terminal…"]})}):l.jsx("div",{className:f.wrap,children:l.jsx("div",{ref:u,className:f.terminal})})}export{te as TerminalPanel};
2
+ //# sourceMappingURL=TerminalPanel-KNfHGYYL.js.map