@av-pi-studio/web-client 0.0.35 → 0.0.36
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/web/assets/{BinaryFallbackViewer-CtNuXHUk.js → BinaryFallbackViewer-ls9k8qFA.js} +2 -2
- package/dist/web/assets/{BinaryFallbackViewer-CtNuXHUk.js.map → BinaryFallbackViewer-ls9k8qFA.js.map} +1 -1
- package/dist/web/assets/{ChatPanel-BxmhC02j.css → ChatPanel-CTnpkb2U.css} +1 -1
- package/dist/web/assets/ChatPanel-Dmjwv8CH.js +3 -0
- package/dist/web/assets/ChatPanel-Dmjwv8CH.js.map +1 -0
- package/dist/web/assets/{CodeView-DBAtguCy.js → CodeView-CxwkReS7.js} +2 -2
- package/dist/web/assets/{CodeView-DBAtguCy.js.map → CodeView-CxwkReS7.js.map} +1 -1
- package/dist/web/assets/{FilePanel-BGAxlnTJ.js → FilePanel-B-PgAhBO.js} +3 -3
- package/dist/web/assets/{FilePanel-BGAxlnTJ.js.map → FilePanel-B-PgAhBO.js.map} +1 -1
- package/dist/web/assets/{ImageViewer-CLqpRK4l.js → ImageViewer-CJpwwyXN.js} +2 -2
- package/dist/web/assets/{ImageViewer-CLqpRK4l.js.map → ImageViewer-CJpwwyXN.js.map} +1 -1
- package/dist/web/assets/{MarkdownFileViewer-UJPP7vox.js → MarkdownFileViewer-D-1EpRwI.js} +2 -2
- package/dist/web/assets/{MarkdownFileViewer-UJPP7vox.js.map → MarkdownFileViewer-D-1EpRwI.js.map} +1 -1
- package/dist/web/assets/{TerminalPanel-C9bP_u5_.js → TerminalPanel-CexJxdF7.js} +2 -2
- package/dist/web/assets/{TerminalPanel-C9bP_u5_.js.map → TerminalPanel-CexJxdF7.js.map} +1 -1
- package/dist/web/assets/{TextViewer-DD2_TH2C.js → TextViewer-D5R2xI5H.js} +2 -2
- package/dist/web/assets/{TextViewer-DD2_TH2C.js.map → TextViewer-D5R2xI5H.js.map} +1 -1
- package/dist/web/assets/{VideoViewer-D6cldFSO.js → VideoViewer-Cr94FgpX.js} +2 -2
- package/dist/web/assets/{VideoViewer-D6cldFSO.js.map → VideoViewer-Cr94FgpX.js.map} +1 -1
- package/dist/web/assets/{index-D_2xgUa4.css → index-BXAEsQz1.css} +1 -1
- package/dist/web/assets/index-NVEAioqx.js +3 -0
- package/dist/web/assets/index-NVEAioqx.js.map +1 -0
- package/dist/web/assets/{use-file-download-DRdPYoQk.js → use-file-download-D4CRNqB1.js} +2 -2
- package/dist/web/assets/{use-file-download-DRdPYoQk.js.map → use-file-download-D4CRNqB1.js.map} +1 -1
- package/dist/web/assets/{vendor-icons-BouiMPVM.js → vendor-icons-Bk3OssJx.js} +2 -2
- package/dist/web/assets/{vendor-icons-BouiMPVM.js.map → vendor-icons-Bk3OssJx.js.map} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +3 -3
- package/dist/web/assets/ChatPanel-DgWlIJic.js +0 -3
- package/dist/web/assets/ChatPanel-DgWlIJic.js.map +0 -1
- package/dist/web/assets/index-CwYwO1IN.js +0 -3
- package/dist/web/assets/index-CwYwO1IN.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/ModelMenu.tsx","../src/features/chat/Timeline.tsx","../src/features/chat/model-menu-sort.test.ts","../src/features/chat/model-menu-sort.ts","../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.
|
|
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/ModelMenu.tsx","../src/features/chat/Timeline.tsx","../src/features/chat/model-menu-sort.test.ts","../src/features/chat/model-menu-sort.ts","../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.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-provider-models.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/materialize.test.ts","../src/stores/materialize.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"}
|
package/dist/web/assets/{BinaryFallbackViewer-CtNuXHUk.js → BinaryFallbackViewer-ls9k8qFA.js}
RENAMED
|
@@ -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-
|
|
2
|
-
//# sourceMappingURL=BinaryFallbackViewer-
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-BoIQBqDW.js";import{S as m,B as a}from"./index-NVEAioqx.js";import{u as d}from"./use-file-download-D4CRNqB1.js";import{y as c}from"./vendor-icons-Bk3OssJx.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-ls9k8qFA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BinaryFallbackViewer-
|
|
1
|
+
{"version":3,"file":"BinaryFallbackViewer-ls9k8qFA.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 +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}.
|
|
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 p}from"./vendor-react-BoIQBqDW.js";import{c as Y,d as J,m as Z}from"./vendor-query-AtKBh_Yt.js";import{t as q,u as x,a as M,D as ee,T as te,B as S,e as P}from"./index-NVEAioqx.js";import{o as se,p as ne,q as re,r as ae,s as oe,t as ie,T as U,C as ce,u as le,v as de,N as ue,w as me,x as ge}from"./vendor-icons-Bk3OssJx.js";import{M as H}from"./markdown-D9FuaV1m.js";import{C as T}from"./vendor--os7hw7d.js";import{D as pe}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 _e="_badge_jtokc_3",he={badge:_e};function fe(e){switch(e){case"success":return{token:"statusSuccess"};case"error":return{token:"statusDanger"};case"muted":return{token:"foregroundMuted"}}}function xe({label:e,variant:s,className:n}){const{token:i}=fe(s),o=`var(--pi-color-${i})`;return t.jsx("span",{className:`${he.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 ye={shell:U,read:ie,edit:oe,write:ae,search:re,fetch:ne,task:se};function je(e){return ye[e.kind]??U}function ke(e){return e.kind}function ve(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function be(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function we(e){const s=[];if(e.kind==="edit"&&e.diff)s.push({kind:"diff",patch:e.diff});else{const n=q(e);n&&s.push({kind:"code",text:n})}return e.output&&s.push({kind:"code",text:e.output}),s}function Ne(e){const s=q(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 Se=500;let $;function Ie(e,s,n,i){clearTimeout($),$=setTimeout(()=>{$=void 0,e.invalidateQueries({queryKey:["file"]}),e.invalidateQueries({queryKey:["explorer"]}),s&&n&&s.connection.request("checkout_refresh_request",{cwd:n}).catch(()=>{})},Se)}function Ce({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"&&be(s.tool)){const l=o.sessions[e],d=(l==null?void 0:l.cwd)||null;Ie(i,n,d,ve(s.tool))}break}}}function De(e){const s=M(o=>o.client),n=x(o=>{var l;return((l=o.sessions[e])==null?void 0:l.agentId)??null}),i=Y();p.useEffect(()=>!s||!n?void 0:s.agent(n).timeline.subscribe(l=>{Ce({sessionId:e,event:l,client:s,queryClient:i})}),[s,n,e,i])}const Te="_row_5yddc_3",$e="_who_5yddc_13",Ee="_queuedBadge_5yddc_22",Be="_user_5yddc_40",Re="_userPending_5yddc_47",Fe="_userQueued_5yddc_51",Ae="_userFailed_5yddc_55",ze="_userImages_5yddc_61",Pe="_userImage_5yddc_61",Oe="_imageDialog_5yddc_77",qe="_imageDialogPreview_5yddc_81",Me="_assistant_5yddc_90",Ue="_streaming_5yddc_97",He="_streamingText_5yddc_101",Ke="_cursor_5yddc_106",Le="_blink_5yddc_1",Qe="_reasoning_5yddc_121",We="_tool_5yddc_131",Ve="_toolHeader_5yddc_141",Ge="_toolChevron_5yddc_159",Xe="_toolChevronOpen_5yddc_165",Ye="_toolInlineDetail_5yddc_169",Je="_toolBody_5yddc_179",Ze="_toolCode_5yddc_185",et="_toolIcon_5yddc_196",tt="_running_5yddc_202",st="_pulse_5yddc_1",nt="_completed_5yddc_207",rt="_error_5yddc_211",at="_toolLabel_5yddc_221",ot="_toolBadge_5yddc_226",it="_system_5yddc_239",r={row:Te,who:$e,queuedBadge:Ee,user:Be,userPending:Re,userQueued:Fe,userFailed:Ae,userImages:ze,userImage:Pe,imageDialog:Oe,imageDialogPreview:qe,assistant:Me,streaming:Ue,streamingText:He,cursor:Ke,blink:Le,reasoning:Qe,tool:We,toolHeader:Ve,toolChevron:Ge,toolChevronOpen:Xe,toolInlineDetail:Ye,toolBody:Je,toolCode:Ze,toolIcon:et,running:tt,pulse:st,completed:nt,error:rt,toolLabel:at,toolBadge:ot,system:it};function ct({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(H,{text:e.text})]})}function lt({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(H,{text:e.text})]})}const dt={running:"muted",completed:"success",error:"error"};function ut({row:e}){const[s,n]=p.useState(!1),i=je(e.tool),o=Ne(e.tool),l=we(e.tool),d=l.length>0;return t.jsxs("div",{className:T(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(ce,{size:12,className:T(r.toolChevron,s&&r.toolChevronOpen)}),t.jsx("span",{className:T(r.toolIcon,r[e.status]),children:t.jsx(i,{size:14})}),t.jsx("span",{className:r.toolLabel,children:ke(e.tool)}),o&&t.jsx("span",{className:r.toolInlineDetail,title:o,children:o}),t.jsx(xe,{className:r.toolBadge,label:e.status,variant:dt[e.status]})]}),s&&d&&t.jsx("div",{className:r.toolBody,children:l.map((u,c)=>u.kind==="diff"?t.jsx(pe,{patch:u.patch},c):t.jsx("pre",{className:r.toolCode,children:u.text},c))})]})}function mt({row:e}){const[s,n]=p.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(le,{size:9}),"queued"]})]}),e.text,e.images&&e.images.length>0&&t.jsx("div",{className:r.userImages,children:e.images.map((o,l)=>{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)}},l)})}),t.jsx(ee,{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 gt({row:e}){return t.jsxs("div",{className:`${r.row} ${r.error}`,children:[t.jsx("span",{className:r.who,children:"error"}),e.text]})}function pt({row:e}){return t.jsx("div",{className:`${r.row} ${r.system}`,children:e.text})}const _t="_viewport_1byko_3",ht="_inner_1byko_10",ft="_rowWrap_1byko_15",xt="_empty_1byko_25",yt="_working_1byko_34",jt="_workingDots_1byko_43",_={viewport:_t,inner:ht,rowWrap:ft,empty:xt,working:yt,workingDots:jt},kt=40;function vt(e){switch(e.kind){case"user":return t.jsx(mt,{row:e});case"assistant":return t.jsx(ct,{row:e});case"reasoning":return t.jsx(lt,{row:e});case"tool":return t.jsx(ut,{row:e});case"error":return t.jsx(gt,{row:e});case"system":return t.jsx(pt,{row:e})}}function bt({session:e}){const s=e.timeline.rows,n=e.status==="running",i=p.useRef(null),o=p.useRef(!0),l=p.useRef(0),d=J({count:s.length,getScrollElement:()=>i.current,estimateSize:()=>48,overscan:8,getItemKey:c=>{var m;return((m=s[c])==null?void 0:m.id)??c},measureElement:(c,m,h)=>{if(c.offsetParent!==null)return Z(c,m,h);const w=h.indexFromElement(c),N=h.options.getItemKey(w);return h.itemSizeCache.get(N)??h.options.estimateSize(w)}});function u(){const c=i.current;if(!c)return;const m=c.scrollHeight-c.scrollTop-c.clientHeight;o.current=m<kt}return p.useEffect(()=>{const c=l.current,m=s.length>c;return l.current=s.length,m&&o.current&&d.scrollToIndex(s.length-1,{align:"end"}),()=>{l.current=c}},[s.length,d]),s.length===0?t.jsx("div",{className:_.viewport,ref:i,children:n?t.jsxs("div",{className:_.working,role:"status","aria-live":"polite",children:[t.jsxs("span",{className:_.workingDots,"aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),"Agent is working…"]}):t.jsx("div",{className:_.empty,children:"No messages yet — say something to start."})}):t.jsxs("div",{className:_.viewport,ref:i,onScroll:u,children:[t.jsx("div",{className:_.inner,style:{height:d.getTotalSize()},children:d.getVirtualItems().map(c=>{const m=s[c.index];return m?t.jsx("div",{ref:d.measureElement,"data-index":c.index,className:_.rowWrap,style:{transform:`translateY(${c.start}px)`},children:vt(m)},c.key):null})}),n&&t.jsxs("div",{className:_.working,role:"status","aria-live":"polite",children:[t.jsxs("span",{className:_.workingDots,"aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),"Agent is working…"]})]})}const wt="_strip_5sm81_4",Nt="_thumb_5sm81_11",St="_remove_5sm81_28",E={strip:wt,thumb:Nt,remove:St};function It({images:e,onRemove:s}){return e.length===0?null:t.jsx("div",{className:E.strip,children:e.map((n,i)=>t.jsxs("div",{className:E.thumb,children:[t.jsx("img",{src:n.thumbUrl,alt:""}),t.jsx("button",{type:"button",className:E.remove,title:"Remove",onClick:()=>s(i),children:"×"})]},i))})}function Ct(e){const{promise:s,resolve:n,reject:i}=Promise.withResolvers(),o=new FileReader;return o.onload=()=>{const l=o.result;if(typeof l!="string"){i(new Error("Unexpected FileReader result"));return}const d=l.indexOf(","),u=d>=0?l.slice(d+1):l;n({mimeType:e.type,data:u,thumbUrl:l})},o.onerror=()=>i(o.error??new Error("Failed to read file")),o.readAsDataURL(e),s}const Dt="_composer_1cudo_1",Tt="_inputArea_1cudo_13",$t="_textarea_1cudo_21",Et="_attachBtn_1cudo_28",Bt="_hiddenFileInput_1cudo_32",Rt="_actions_1cudo_36",j={composer:Dt,inputArea:Tt,textarea:$t,attachBtn:Et,hiddenFileInput:Bt,actions:Rt},Ft=160;function O(e){e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,Ft)}px`}function At(e){return typeof e=="object"&&e!==null&&"ok"in e&&e.ok===!1}function zt({sessionId:e}){const s=M(a=>a.client),n=x(a=>a.sessions[e]),i=x(a=>a.addOptimisticUserMessage),o=x(a=>a.markUserMessageFailed),l=x(a=>a.setCwd),[d,u]=p.useState(""),[c,m]=p.useState([]),[h,w]=p.useState(!1),[N,K]=p.useState(!1),I=p.useRef(null),R=p.useRef(null),k=(n==null?void 0:n.status)==="running",F=!!s&&!(k?N:h)&&(d.trim().length>0||c.length>0);async function A(a){if(a.type.startsWith("image/"))try{const g=await Ct(a);m(f=>[...f,g])}catch{}}function L(a){for(const g of a.target.files??[])A(g);a.target.value=""}function Q(a){for(const g of a.clipboardData.items)if(g.type.startsWith("image/")){a.preventDefault();const f=g.getAsFile();f&&A(f)}}function W(a){m(g=>g.filter((f,v)=>v!==a))}function V(a){const g=d.length===0;u(a.target.value),O(a.target),g&&a.target.value.length>0&&s&&n&&!n.agentId&&P(s,e).catch(()=>{})}function G(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),C(k?"steer":"send"))}async function C(a){if(!s||!n||(a==="steer"?N:h)||a==="steer"&&!n.agentId)return;const g=d.trim();if(!g&&c.length===0)return;u(""),I.current&&O(I.current);const f=c;m([]);const v=g||"Describe this image",D=f.length>0?f.map(y=>({mimeType:y.mimeType,data:y.data})):void 0,b=crypto.randomUUID();i(e,b,v,D,a==="steer");const z=a==="steer"?K:w;z(!0);try{if(a==="steer"){const y=await s.agent(n.agentId).steer(v,{clientMessageId:b,images:D});At(y)&&o(e,b)}else{n.agentId||l(e,n.cwd||"~");const y=await P(s,e);await s.agent(y).send(v,{clientMessageId:b,images:D})}}catch{o(e,b)}finally{z(!1)}}function X(){n!=null&&n.agentId&&(s==null||s.agent(n.agentId).interrupt())}return t.jsxs("div",{className:j.composer,children:[t.jsxs("div",{className:j.inputArea,children:[t.jsx(te,{ref:I,className:j.textarea,rows:1,value:d,placeholder:k?"Steer the running turn… (Enter to steer, Shift+Enter for newline)":"Ask anything… (Enter to send, Shift+Enter for newline)",onChange:V,onKeyDown:G,onPaste:Q}),t.jsx(It,{images:c,onRemove:W})]}),t.jsx(S,{className:j.attachBtn,variant:"ghost",size:"md",iconOnly:!0,title:"Attach image",onClick:()=>{var a;return(a=R.current)==null?void 0:a.click()},children:t.jsx(de,{size:16})}),t.jsx("input",{ref:R,className:j.hiddenFileInput,type:"file",accept:"image/*",multiple:!0,onChange:L}),t.jsxs("div",{className:j.actions,children:[k?t.jsx(S,{size:"sm",disabled:!F,onClick:()=>void C("steer"),leftIcon:t.jsx(ue,{size:14}),children:"Steer"}):t.jsx(S,{size:"sm",disabled:!F,onClick:()=>void C("send"),leftIcon:t.jsx(me,{size:14}),children:"Send"}),k&&t.jsx(S,{size:"sm",variant:"destructive",onClick:X,leftIcon:t.jsx(ge,{size:14}),children:"Stop"})]})]})}const Pt="_panel_12s9l_1",Ot="_empty_12s9l_8",B={panel:Pt,empty:Ot};function Jt({tab:e}){const{sessionId:s}=e.data,n=x(i=>i.sessions[s]);return De(s),n?t.jsxs("div",{className:B.panel,children:[t.jsx(bt,{session:n}),t.jsx(zt,{sessionId:n.id})]}):t.jsx("div",{className:B.panel,children:t.jsx("div",{className:B.empty,children:"Session not found."})})}export{Jt as ChatPanel};
|
|
3
|
+
//# sourceMappingURL=ChatPanel-Dmjwv8CH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatPanel-Dmjwv8CH.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, consumed by the live subscription\n * (`use-agent-stream.ts`), which attaches the instant a session's `agentId` is bound —\n * including a freshly materialized draft, before its first turn can possibly start streaming\n * (`Composer.tsx`'s file header) — so there is no separate raw-broadcast/first-turn-gate path\n * here anymore.\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\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). The mount-time \"grew\" tracking ref reverts itself on\n * cleanup — required for correctness under React StrictMode's dev-only double-invoke, which\n * otherwise swallows the necessary scroll-to-bottom on a freshly restored/opened session (see\n * the effect's own comment).\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 prevCount = prevRowCountRef.current;\n const grew = rows.length > prevCount;\n prevRowCountRef.current = rows.length;\n if (grew && stickToBottomRef.current) {\n virtualizer.scrollToIndex(rows.length - 1, { align: \"end\" });\n }\n // React StrictMode double-invokes this effect on mount (mount -> phantom cleanup -> mount,\n // same instance — see TerminalPanel.tsx's own StrictMode doc comment for the established\n // pattern here). `@tanstack/react-virtual`'s own scroll-element attachment effect DOES\n // correctly redo its setup across that phantom cycle and, in doing so, resets the DOM\n // `scrollTop` back to 0 on the second (real) attach — but without this cleanup, this ref's\n // `grew` flip from the first (phantom) invocation would make the second invocation a false\n // \"unchanged\" no-op, permanently losing the scroll-to-bottom to the library's reset and\n // leaving a freshly restored/opened session's timeline stuck at the top. Reverting the ref\n // on cleanup makes each real invocation see the true count it started from.\n return () => {\n prevRowCountRef.current = prevCount;\n };\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). Every send goes through `ensureMaterialized` (`stores/\n * materialize.ts`) first: a brand-new session (`agentId: null`) becomes a real, persisted draft\n * via a no-`initialPrompt` `createAgent` call — the daemon persists the record but does NOT spawn\n * a provider process yet (`agent-service.ts` `handleCreate`'s deferred-draft branch); the process\n * spawns lazily on this very send (`spawnOrResumeSession`). `ensureMaterialized` is a no-op once\n * already bound, so this is the single path for both \"first message ever\" and every follow-up:\n * `client.agent(agentId).send(...)`. Stop → `client.agent(agentId).interrupt()`.\n *\n * Because the agent is bound (materialized) *before* this call, `useAgentStream` (attaches once\n * `agentId` is set) is already subscribed by the time `send`'s turn starts streaming — unlike the\n * old \"one RPC does create-agent-and-run-the-first-turn\" path, there is no window where the first\n * turn's events arrive on a raw broadcast nobody is listening to, so this file no longer needs a\n * first-turn gate/latch dance for a still-unbound session.\n *\n * OPTIMISTIC ECHO: `send_agent_prompt` blocks server-side until the whole turn finishes, and even\n * the *first* broadcast event only fires once the agent process is booted/warm — for a session\n * materializing on this very send, that means a real process-spawn+handshake before anything\n * appears (see AGENTS.md \"First-message latency\"). To hide that, `submit` mints a\n * `clientMessageId` and inserts the user's row into the timeline *synchronously*, before the RPC\n * is even issued. The daemon echoes the same id back verbatim as the `user_message` event's\n * `messageId` (`packages/server/src/agent/agent-service.ts` `runTurn`); the reducer\n * (`timeline/reducer.ts` `onUserMessage`) matches it against the pending row and confirms it in\n * place instead of appending a duplicate.\n *\n * MODEL PRESELECT: a brand-new session shows the model it would actually run on (`tab-store.ts`\n * `openNewChat` seeds it via `resolveDefaultModel`) before anything is materialized. Picking a\n * different model (`StatusBar.tsx`'s `handleSelectModel`, moved there from this file since the\n * model picker now lives in the footer, not the composer) or typing the first character here\n * both materialize the draft immediately, pinning whatever model is CURRENTLY displayed into\n * `config.model`/`config.modelProvider` — replayed by the server on first spawn regardless of\n * whether it's the untouched default or an explicit pick (`spawnOrResumeSession`).\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. Steering only makes sense against a\n * live agent — never triggers materialization itself.\n */\n\nimport { useRef, useState, type ChangeEvent, type ClipboardEvent, type KeyboardEvent } from \"react\";\nimport { Navigation, Paperclip, Send, Square } from \"lucide-react\";\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 { ensureMaterialized } from \"@pi-studio-ui/stores/materialize.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\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 addOptimisticUserMessage = useSessionStore((s) => s.addOptimisticUserMessage);\n const markUserMessageFailed = useSessionStore((s) => s.markUserMessageFailed);\n const setCwd = useSessionStore((s) => s.setCwd);\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 const wasEmpty = text.length === 0;\n setText(ev.target.value);\n autoResize(ev.target);\n // First keystroke on a still-client-only draft materializes it — pins whatever model is\n // currently displayed (the preselected default, or an earlier explicit pick) into the record.\n if (wasEmpty && ev.target.value.length > 0 && client && session && !session.agentId) {\n void ensureMaterialized(client, sessionId).catch(() => {\n // Best-effort: if this fails, `submit`'s own `ensureMaterialized` call retries on send.\n });\n }\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.\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 materialization, which\n // only applies to the send-only, no-agent-yet path below.\n const result = await client\n .agent(session.agentId!)\n .steer(prompt, { clientMessageId, images: rpcImages });\n if (isOkFalse(result)) markUserMessageFailed(sessionId, clientMessageId);\n } else {\n if (!session.agentId) setCwd(sessionId, session.cwd || \"~\");\n // Materializes the still-client-only draft if `handleTextareaChange`/`handleSelectModel`\n // haven't already (e.g. text arrived by some path other than the tracked keystroke) — a\n // no-op once bound. `useAgentStream` attaches the instant `agentId` is bound, before this\n // turn's first event can possibly arrive (see file header), so `send` needs no separate\n // first-turn broadcast path the way a combined create-and-run RPC used to.\n const agentId = await ensureMaterialized(client, sessionId);\n await client.agent(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\n size=\"sm\"\n disabled={!canSubmit}\n onClick={() => void submit(\"send\")}\n leftIcon={<Send size={14} />}\n >\n Send\n </Button>\n )}\n {running && (\n <Button\n size=\"sm\"\n variant=\"destructive\"\n onClick={handleStop}\n leftIcon={<Square size={14} />}\n >\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","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","prevCount","grew","virtualRow","Attachments","images","onRemove","readImageFile","file","promise","resolve","reject","reader","result","commaIndex","data","MAX_TEXTAREA_HEIGHT","autoResize","isOkFalse","value","Composer","addOptimisticUserMessage","markUserMessageFailed","setCwd","setText","setImages","sending","setSending","steering","setSteering","textareaRef","fileInputRef","canSubmit","addImageFile","image","prev","handleFileInputChange","handlePaste","item","handleRemoveImage","_","handleTextareaChange","wasEmpty","ensureMaterialized","handleKeyDown","submit","mode","trimmed","sentImages","prompt","rpcImages","clientMessageId","setBusy","handleStop","TextArea","Button","Paperclip","Navigation","Send","Square","ChatPanel","tab"],"mappings":"kpBAcO,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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OAAO,EAClC,SAAUzI,EAAAA,IAACqJ,GAAA,CAAW,KAAM,EAAA,CAAI,EACjC,SAAA,OAAA,CAAA,EAIDrJ,EAAAA,IAACmJ,EAAA,CACC,KAAK,KACL,SAAU,CAACvB,EACX,QAAS,IAAM,KAAKa,EAAO,MAAM,EACjC,SAAUzI,EAAAA,IAACsJ,GAAA,CAAK,KAAM,EAAA,CAAI,EAC3B,SAAA,MAAA,CAAA,EAIFzE,GACC7E,EAAAA,IAACmJ,EAAA,CACC,KAAK,KACL,QAAQ,cACR,QAASF,EACT,SAAUjJ,EAAAA,IAACuJ,GAAA,CAAO,KAAM,EAAA,CAAI,EAC7B,SAAA,MAAA,CAAA,CAED,CAAA,CAEJ,CAAA,EACF,CAEJ,qECtQO,SAASC,GAAU,CAAE,IAAAC,GAAuB,CAGjD,KAAM,CAAE,UAAA5H,GAAc4H,EAAI,KACpBxH,EAAUD,EAAiBI,GAAMA,EAAE,SAASP,CAAS,CAAC,EAI5D,OAFAK,GAAeL,CAAS,EAEnBI,EASHU,EAAAA,KAAC,MAAA,CAAI,UAAW1C,EAAO,MACrB,SAAA,CAAAD,MAAC2E,IAAS,QAAA1C,EAAkB,EAC5BjC,EAAAA,IAACgH,GAAA,CAAS,UAAW/E,EAAQ,EAAA,CAAI,CAAA,EACnC,EAVEjC,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-
|
|
2
|
-
//# sourceMappingURL=CodeView-
|
|
1
|
+
import{u as l}from"./vendor-query-AtKBh_Yt.js";import{a as f,r as p}from"./index-NVEAioqx.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-CxwkReS7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeView-
|
|
1
|
+
{"version":3,"file":"CodeView-CxwkReS7.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-
|
|
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-
|
|
3
|
-
//# sourceMappingURL=FilePanel-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TextViewer-D5R2xI5H.js","assets/vendor-react-BoIQBqDW.js","assets/index-NVEAioqx.js","assets/vendor-query-AtKBh_Yt.js","assets/vendor--os7hw7d.js","assets/vendor-markdown-B8HSIhaA.js","assets/vendor-highlight-DCzuSv8g.js","assets/vendor-icons-Bk3OssJx.js","assets/vendor-overlays-UwLNGk04.js","assets/vendor-dnd-D9kA7FgH.js","assets/index-BXAEsQz1.css","assets/CodeView-CxwkReS7.js","assets/CodeView-CLRODhB8.css","assets/DiffView-DlVCPvLc.js","assets/DiffView-CRbeRztO.css","assets/MarkdownFileViewer-D-1EpRwI.js","assets/markdown-D9FuaV1m.js","assets/markdown-BQwXm0MF.css","assets/MarkdownFileViewer-BD5Ri_Fb.css","assets/ImageViewer-CJpwwyXN.js","assets/use-file-download-D4CRNqB1.js","assets/ImageViewer-ijzMsq8H.css","assets/VideoViewer-Cr94FgpX.js","assets/VideoViewer-BBuZ4wou.css","assets/BinaryFallbackViewer-ls9k8qFA.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-NVEAioqx.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-D5R2xI5H.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-D-1EpRwI.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-CJpwwyXN.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-Cr94FgpX.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-ls9k8qFA.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-B-PgAhBO.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,EAAKC,CAAM,EAC5C,QAAS,SAAqC,CAC5C,GAAI,CAACE,EAAQ,MAAM,IAAI,MAAM,eAAe,EAM5C,MAAO,CAAE,OALQ,MAAMA,EAAO,WAAW,QAA6B,oBAAqB,CACzF,KAAAJ,EACA,IAAAC,EACA,OAAAC,CAAA,CACD,GACwB,OAAS,GACpC,EACA,QAAS,EAAQE,GAAW,EAAQJ,GAAS,EAAQC,GAAQE,CAAA,CAC9D,CACH,CChBA,MAAMM,EAAaC,OAAK,IAAAC,EAAA,IAAM,OAAO,0BAAiB,yDAAE,KAAMC,IAAO,CAAE,QAASA,EAAE,YAAa,CAAC,EAC1FC,EAAqBH,OAAK,IAAAC,EAAA,IAC9B,OAAO,kCAAyB,mEAAE,KAAMC,IAAO,CAAE,QAASA,EAAE,oBAAqB,CACnF,EACME,EA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AU,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-BGAxlnTJ.js"}
|
|
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,EAAKC,CAAM,EAC5C,QAAS,SAAqC,CAC5C,GAAI,CAACE,EAAQ,MAAM,IAAI,MAAM,eAAe,EAM5C,MAAO,CAAE,OALQ,MAAMA,EAAO,WAAW,QAA6B,oBAAqB,CACzF,KAAAJ,EACA,IAAAC,EACA,OAAAC,CAAA,CACD,GACwB,OAAS,GACpC,EACA,QAAS,EAAQE,GAAW,EAAQJ,GAAS,EAAQC,GAAQE,CAAA,CAC9D,CACH,CChBA,MAAMM,EAAaC,OAAK,IAAAC,EAAA,IAAM,OAAO,0BAAiB,yDAAE,KAAMC,IAAO,CAAE,QAASA,EAAE,YAAa,CAA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,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-B-PgAhBO.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-BoIQBqDW.js";import{S as t}from"./index-
|
|
2
|
-
//# sourceMappingURL=ImageViewer-
|
|
1
|
+
import{j as e}from"./vendor-react-BoIQBqDW.js";import{S as t}from"./index-NVEAioqx.js";import{u as a}from"./use-file-download-D4CRNqB1.js";import{p as s}from"./FilePanel-B-PgAhBO.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-Bk3OssJx.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-CJpwwyXN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageViewer-
|
|
1
|
+
{"version":3,"file":"ImageViewer-CJpwwyXN.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-
|
|
2
|
-
//# sourceMappingURL=MarkdownFileViewer-
|
|
1
|
+
import{r as d,j as r}from"./vendor-react-BoIQBqDW.js";import{S as c,B as a}from"./index-NVEAioqx.js";import{u as m,C as p}from"./CodeView-CxwkReS7.js";import{M as l}from"./markdown-D9FuaV1m.js";import{p as n}from"./FilePanel-B-PgAhBO.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor--os7hw7d.js";import"./vendor-markdown-B8HSIhaA.js";import"./vendor-highlight-DCzuSv8g.js";import"./vendor-icons-Bk3OssJx.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-D-1EpRwI.js.map
|
package/dist/web/assets/{MarkdownFileViewer-UJPP7vox.js.map → MarkdownFileViewer-D-1EpRwI.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFileViewer-
|
|
1
|
+
{"version":3,"file":"MarkdownFileViewer-D-1EpRwI.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{
|
|
2
|
-
//# sourceMappingURL=TerminalPanel-
|
|
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{b as E,a as N,c as T,S as D}from"./index-NVEAioqx.js";import"./vendor--os7hw7d.js";import"./vendor-query-AtKBh_Yt.js";import"./vendor-icons-Bk3OssJx.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-CexJxdF7.js.map
|