@puddle-code/cli 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/CHANGELOG.md +3 -27
  2. package/dist/index.js +1 -1
  3. package/dist/public/assets/{Dashboard-CEPwl8SL.js → Dashboard-DHkzWFd7.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-eigXdiCB.js → EditorTabClose-DziQNlDZ.js} +1 -1
  5. package/dist/public/assets/{ModelRefcount-BPtz3aiO.js → ModelRefcount-BD4m7wnM.js} +1 -1
  6. package/dist/public/assets/{PaneEditorBody-Cd-gTwQf.js → PaneEditorBody-6h7v53Gs.js} +1 -1
  7. package/dist/public/assets/{SettingsDialog-B772Gh8X.js → SettingsDialog-DEVVkj7N.js} +1 -1
  8. package/dist/public/assets/{Terminal-B4pgs3im.js → Terminal-DP-hFsEc.js} +2 -2
  9. package/dist/public/assets/{Workspace-P16s6r31.js → Workspace-BoKA3JKo.js} +2 -2
  10. package/dist/public/assets/{buffer-store-BQUZZSHc.js → buffer-store-C23koXgg.js} +2 -2
  11. package/dist/public/assets/{context-menu-pZk42aSN.js → context-menu-0Mq8MFLs.js} +1 -1
  12. package/dist/public/assets/{cssMode-ZS6zMeEj.js → cssMode-BBQ4UYhd.js} +1 -1
  13. package/dist/public/assets/{htmlMode-D4c37GJ9.js → htmlMode-CiqvxxB5.js} +1 -1
  14. package/dist/public/assets/{index-D-ztnhM0.css → index-Dg2mfzDf.css} +1 -1
  15. package/dist/public/assets/{index-BkJByuhy.js → index-bqEa9yZh.js} +2 -2
  16. package/dist/public/assets/{jsonMode-CF-1fM0S.js → jsonMode-B7C2cbcC.js} +1 -1
  17. package/dist/public/assets/{session-seed-uIZJKzcf.js → session-seed-BafHkB3F.js} +1 -1
  18. package/dist/public/assets/ssh-mode-DIXigRzL.js +1 -0
  19. package/dist/public/assets/{tsMode-BV-x0-vm.js → tsMode-ByErjETq.js} +1 -1
  20. package/dist/public/index.html +2 -2
  21. package/package.json +1 -1
  22. package/dist/public/assets/ssh-mode-DNQdm1uV.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,33 +7,9 @@ Past releases: see docs/changelogs/.
7
7
 
8
8
  # Changelog
9
9
 
10
- ## [0.0.6] — 2026-07-17
11
-
12
- ### Added
13
-
14
- - `puddle refresh [local | user@host]`: stop the target's cockpit (even a wedged one) and run the full start/connect flow again — daemon restart if needed, fresh tunnel, handshake — keeping the old UI port so open tabs survive. Target defaults to the sole running cockpit.
15
- - The same refresh from the UI: a bottom-anchored connection banner (shown when the daemon WebSocket stays down) and a ⌘K "Refresh connection" command drive the cockpit-local `POST /cockpit/refresh` control endpoint (Host/Origin-guarded + daemon bearer token; outside `PROTOCOL_VERSION` — the UI and cockpit ship together); the page reloads once the cockpit is back.
16
- - `--prefer-port` on `start`/`connect`: a non-strict starting point for the UI-port probe (what `refresh` passes through internally).
17
- - On Mac, ⌥+drag selects text in terminals whose TUI captures the mouse (e.g. Claude Code), so ⌘C copy works there too; Shift+drag has always worked.
18
- - Drag a file from the tree or a session from the right sidebar (row or collapsed dot) onto a tiling pane to open it as a permanent tab, positioned in one gesture — centre inserts, an edge splits, same zones as tab drags.
19
-
20
- - Settings → Sessions: per-kind new-session defaults — base branch, separate branch, separate directory — for new agents and new terminals alike; the modal opens on them, everything stays editable per session (profile setting `sessionDefaults`, protocol 7.0 → 7.1, additive).
21
-
22
- ### Changed
23
-
24
- - Creating an agent is now labelled "New agent" everywhere (sidebar buttons, ⌘K, the modal's title and submit, the profile panel's account rows), with a robot icon instead of a plus — "session" stays the umbrella term over agents and terminals.
25
- - "New terminal" joined the ⌘K palette alongside "New agent".
26
- - Settings: the "Terminal & Editor" section is gone — the daemon agent search path and terminal scrollback moved into Sessions (order: permission gate, agent path, scrollback, launch text, tab title); tab size, word wrap, and the editor-link SSH host live in a new Editor section directly below Sessions. Old `#settings/terminal` links resolve to Sessions.
27
- - The Files/Search worktree header ~-compresses the daemon home directory (`/home/…`, `/Users/…`) so the identifying tail of the path gets the width.
28
- - File-tree icons are monochrome in the heading colour (navy in light, white in dark; per-type glyph shapes kept): colour on a tree icon now always means git status — default folders were gold, indistinguishable from the modified tint.
29
- - A session's Resume button and ports now live on its OWN pane — for agents and plain terminals alike — instead of a verbose banner strip at the bottom of the whole workspace: Resume as a small click-transparent bottom-right overlay, ports as a slim in-flow strip below the terminal (never covering it; the terminal shrinks to make room).
10
+ ## [0.0.7] — 2026-07-19
30
11
 
31
12
  ### Fixed
32
13
 
33
- - Reloading a workspace no longer leaves every pane blank ("Loading editor…" / an empty terminal) until a tab click: the restored layout now mounts only after the Monaco/xterm chunks its tabs need are warm, so nothing suspends mid-restore terminal-only workspaces still load no Monaco.
34
- - Clicking inside a terminal now activates its tab (re-binding the left sidebar and claiming the URL), matching editor clicks: the kept-alive terminal's DOM is portal-rendered and physically adopted into the pane, so React's synthetic events never reached the pane's handlers — a native capture listener follows the real DOM instead.
35
-
36
- - The settings button opens the dialog reliably: its open state is one `useSyncExternalStore` snapshot consumed by an always-mounted dialog (the profile panel's structure) — the previous per-consumer state copies behind a conditional mount could desync, turning the next click into a deduped no-op.
37
- - Worktree directory names in the Worktrees navigator get the same hover-scroll as branch names (full path stays on the tooltip), and hovering a row no longer makes it jump — the appearing prune control used to exceed the row's resting height.
38
- - Double-clicking a session in the right sidebar (row or collapsed dot) now pins its terminal tab, exactly like double-clicking a file — SPEC promised this; a single click still opens it as an italic preview tab.
39
- - The left sidebar (file tree, search, changes) now follows the FOCUSED tab's worktree: every file/diff tab binds the worktree it was opened from, and clicking into an editor or terminal body activates that tab — previously the sidebar only tracked the URL-bound session, so file tabs never re-bound it and clicking inside a session changed nothing.
14
+ - Terminal now honours OSC 52 clipboard writes, so a mouse-reporting agent's own copy (e.g. Claude Code auto-copying the selection) lands in the system clipboard and ⌘V pastes itno Shift+drag needed.
15
+ - Pinned sidebar worktree header no longer masks the path tail: the hover-only file-action icons take no layout width at rest, so their background strip stops occluding the filename when the header is pinned.
package/dist/index.js CHANGED
@@ -19540,7 +19540,7 @@ import { readFileSync } from "node:fs";
19540
19540
  import { dirname, join as join2 } from "node:path";
19541
19541
  import { fileURLToPath } from "node:url";
19542
19542
  function cliVersion() {
19543
- if (true) return "0.0.6";
19543
+ if (true) return "0.0.7";
19544
19544
  const here = dirname(fileURLToPath(import.meta.url));
19545
19545
  for (const candidate of [
19546
19546
  join2(here, "..", "..", "package.json"),
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{v as r}from"./api-L5qtWa7E.js";import{a as i,g as a,i as o,n as s,o as c,t as l}from"./dialog-B43iKmfK.js";import{t as u}from"./utils-B6KiDbIe.js";import{A as d,M as f,N as p,O as m,c as h,j as g,k as _,n as v,r as y,t as b}from"./context-menu-pZk42aSN.js";import{r as x}from"./dist-fdPAlKke.js";import{$ as S,Lt as C,M as w,at as T,et as E,gt as D,h as O,ht as k,nt as A,pt as j,ut as M}from"./index-BkJByuhy.js";var N=e(t(),1),P=n(),F=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function I({projectId:e}){let t=j(e),n=(0,N.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,P.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),F.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function L({icon:e,label:t,onClick:n}){return(0,P.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,P.jsx)(e,{className:`size-4`})})}function R({project:e,repoPath:t,draggable:n,dragging:m,onDragStart:g,onDragEnd:_,onDragOver:x}){let S=E(),[w,T]=(0,N.useState)(!1),[O,A]=(0,N.useState)(e.name),j=t=>S.mutate({id:e.id,archived:t},{onError:e=>r.error(e.message)}),M=()=>{let t=O.trim();if(!t||t===e.name){T(!1);return}S.mutate({id:e.id,name:t},{onSuccess:()=>T(!1),onError:e=>r.error(e.message)})};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(b,{children:[(0,P.jsx)(h,{asChild:!0,children:(0,P.jsxs)(`div`,{draggable:n,onDragStart:g,onDragEnd:_,onDragOver:x,className:u(`group relative transition-opacity`,m&&`opacity-50`),children:[(0,P.jsxs)(C,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,P.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,P.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,P.jsx)(`div`,{className:`mt-3`,children:(0,P.jsx)(I,{projectId:e.id})})]}),(0,P.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex`,children:e.archived?(0,P.jsx)(L,{icon:p,label:`Reopen project`,onClick:()=>j(!1)}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(L,{icon:d,label:`Rename project`,onClick:()=>{A(e.name),T(!0)}}),(0,P.jsx)(L,{icon:f,label:`Archive project`,onClick:()=>j(!0)})]})})]})}),(0,P.jsx)(v,{children:e.archived?(0,P.jsxs)(y,{onSelect:()=>j(!1),children:[(0,P.jsx)(p,{}),` Reopen`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(y,{onSelect:()=>{A(e.name),T(!0)},children:[(0,P.jsx)(d,{}),` Rename`]}),(0,P.jsxs)(y,{onSelect:()=>j(!0),children:[(0,P.jsx)(f,{}),` Archive`]})]})})]}),(0,P.jsx)(l,{open:w,onOpenChange:T,children:(0,P.jsxs)(s,{children:[(0,P.jsx)(i,{children:(0,P.jsx)(c,{children:`Rename project`})}),(0,P.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,P.jsx)(D,{value:O,onChange:e=>A(e.target.value),autoFocus:!0}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(k,{className:`text-fg-muted`,children:`Path`}),(0,P.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,P.jsxs)(o,{children:[(0,P.jsx)(a,{type:`button`,variant:`ghost`,onClick:()=>T(!1),children:`Cancel`}),(0,P.jsx)(a,{type:`submit`,disabled:!O.trim()||S.isPending,children:`Rename`})]})]})]})})]})}function z(){let e=w(),t=T(e??void 0),n=M(),r=A(e??void 0),i=S(e??``),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(null),[d,p]=(0,N.useState)(!1),h=e=>n.data?.find(t=>t.id===e)?.path,v=t.data??[],y=r.data?.projectOrder??[],b=m(v.filter(e=>!e.archived),y),C=v.filter(e=>e.archived),E=(e,t)=>{e!==t&&i.mutate({projectOrder:_(b.map(e=>e.id),e,t)})};return(0,P.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[v.length===0&&(0,P.jsxs)(`div`,{className:`mt-24 flex flex-col items-center gap-6 text-center`,children:[(0,P.jsx)(x,{className:`size-8 text-fg-muted`}),(0,P.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — press ⌘K or create one to get started.`}),(0,P.jsx)(a,{onClick:()=>s(!0),children:`New project`})]}),(0,P.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:b.map(e=>(0,P.jsx)(R,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:c===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),c&&c!==e.id&&E(c,e.id)}},e.id))}),C.length>0&&(0,P.jsxs)(`div`,{className:`mt-6`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,P.jsx)(g,{className:u(`size-3 transition-transform`,d&&`rotate-90`)}),(0,P.jsx)(f,{className:`size-3`}),(0,P.jsx)(`span`,{children:`Archived`}),(0,P.jsx)(`span`,{className:`tabular-nums`,children:C.length})]}),d&&(0,P.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.map(e=>(0,P.jsx)(R,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]}),e!==null&&(0,P.jsx)(O,{profileId:e,open:o,onOpenChange:s})]})}export{z as Dashboard};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{v as r}from"./api-L5qtWa7E.js";import{a as i,g as a,i as o,n as s,o as c,t as l}from"./dialog-B43iKmfK.js";import{t as u}from"./utils-B6KiDbIe.js";import{A as d,M as f,N as p,O as m,c as h,j as g,k as _,n as v,r as y,t as b}from"./context-menu-0Mq8MFLs.js";import{r as x}from"./dist-fdPAlKke.js";import{$ as S,Lt as C,M as w,at as T,et as E,gt as D,h as O,ht as k,nt as A,pt as j,ut as M}from"./index-bqEa9yZh.js";var N=e(t(),1),P=n(),F=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function I({projectId:e}){let t=j(e),n=(0,N.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,P.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),F.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function L({icon:e,label:t,onClick:n}){return(0,P.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,P.jsx)(e,{className:`size-4`})})}function R({project:e,repoPath:t,draggable:n,dragging:m,onDragStart:g,onDragEnd:_,onDragOver:x}){let S=E(),[w,T]=(0,N.useState)(!1),[O,A]=(0,N.useState)(e.name),j=t=>S.mutate({id:e.id,archived:t},{onError:e=>r.error(e.message)}),M=()=>{let t=O.trim();if(!t||t===e.name){T(!1);return}S.mutate({id:e.id,name:t},{onSuccess:()=>T(!1),onError:e=>r.error(e.message)})};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(b,{children:[(0,P.jsx)(h,{asChild:!0,children:(0,P.jsxs)(`div`,{draggable:n,onDragStart:g,onDragEnd:_,onDragOver:x,className:u(`group relative transition-opacity`,m&&`opacity-50`),children:[(0,P.jsxs)(C,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,P.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,P.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,P.jsx)(`div`,{className:`mt-3`,children:(0,P.jsx)(I,{projectId:e.id})})]}),(0,P.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex`,children:e.archived?(0,P.jsx)(L,{icon:p,label:`Reopen project`,onClick:()=>j(!1)}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(L,{icon:d,label:`Rename project`,onClick:()=>{A(e.name),T(!0)}}),(0,P.jsx)(L,{icon:f,label:`Archive project`,onClick:()=>j(!0)})]})})]})}),(0,P.jsx)(v,{children:e.archived?(0,P.jsxs)(y,{onSelect:()=>j(!1),children:[(0,P.jsx)(p,{}),` Reopen`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(y,{onSelect:()=>{A(e.name),T(!0)},children:[(0,P.jsx)(d,{}),` Rename`]}),(0,P.jsxs)(y,{onSelect:()=>j(!0),children:[(0,P.jsx)(f,{}),` Archive`]})]})})]}),(0,P.jsx)(l,{open:w,onOpenChange:T,children:(0,P.jsxs)(s,{children:[(0,P.jsx)(i,{children:(0,P.jsx)(c,{children:`Rename project`})}),(0,P.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,P.jsx)(D,{value:O,onChange:e=>A(e.target.value),autoFocus:!0}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,P.jsx)(k,{className:`text-fg-muted`,children:`Path`}),(0,P.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,P.jsxs)(o,{children:[(0,P.jsx)(a,{type:`button`,variant:`ghost`,onClick:()=>T(!1),children:`Cancel`}),(0,P.jsx)(a,{type:`submit`,disabled:!O.trim()||S.isPending,children:`Rename`})]})]})]})})]})}function z(){let e=w(),t=T(e??void 0),n=M(),r=A(e??void 0),i=S(e??``),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(null),[d,p]=(0,N.useState)(!1),h=e=>n.data?.find(t=>t.id===e)?.path,v=t.data??[],y=r.data?.projectOrder??[],b=m(v.filter(e=>!e.archived),y),C=v.filter(e=>e.archived),E=(e,t)=>{e!==t&&i.mutate({projectOrder:_(b.map(e=>e.id),e,t)})};return(0,P.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[v.length===0&&(0,P.jsxs)(`div`,{className:`mt-24 flex flex-col items-center gap-6 text-center`,children:[(0,P.jsx)(x,{className:`size-8 text-fg-muted`}),(0,P.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — press ⌘K or create one to get started.`}),(0,P.jsx)(a,{onClick:()=>s(!0),children:`New project`})]}),(0,P.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:b.map(e=>(0,P.jsx)(R,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:c===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),c&&c!==e.id&&E(c,e.id)}},e.id))}),C.length>0&&(0,P.jsxs)(`div`,{className:`mt-6`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,P.jsx)(g,{className:u(`size-3 transition-transform`,d&&`rotate-90`)}),(0,P.jsx)(f,{className:`size-3`}),(0,P.jsx)(`span`,{children:`Archived`}),(0,P.jsx)(`span`,{className:`tabular-nums`,children:C.length})]}),d&&(0,P.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:C.map(e=>(0,P.jsx)(R,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]}),e!==null&&(0,P.jsx)(O,{profileId:e,open:o,onOpenChange:s})]})}export{z as Dashboard};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-BQUZZSHc.js";import{s as h,t as g}from"./editor-sync-F3Wyveaa.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t){let n=m(e,t);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(n,e),[n]),()=>p(n))}function x({session:e,path:t,kind:n,label:d,onClose:f}){let p=b(e,t)&&n!==`commit`,[m,x]=(0,v.useState)(!1),S=()=>p?x(!0):f();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${d}`,children:p?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(_,{className:`size-2 fill-current group-hover:hidden`}),(0,y.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,y.jsx)(a,{className:`size-3 opacity-0 group-hover:opacity-100`})}),(0,y.jsx)(u,{open:m,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,d,`?`]}),(0,y.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{h(e,t),g(e,t),x(!1),f()},children:`Discard`})]})]})})]})}export{x as EditorTabClose};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-C23koXgg.js";import{s as h,t as g}from"./editor-sync-F3Wyveaa.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t){let n=m(e,t);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(n,e),[n]),()=>p(n))}function x({session:e,path:t,kind:n,label:d,onClose:f}){let p=b(e,t)&&n!==`commit`,[m,x]=(0,v.useState)(!1),S=()=>p?x(!0):f();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${d}`,children:p?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(_,{className:`size-2 fill-current group-hover:hidden`}),(0,y.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,y.jsx)(a,{className:`size-3 opacity-0 group-hover:opacity-100`})}),(0,y.jsx)(u,{open:m,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,d,`?`]}),(0,y.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{h(e,t),g(e,t),x(!1),f()},children:`Discard`})]})]})})]})}export{x as EditorTabClose};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-BQUZZSHc.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path))),o=t.current;for(let e of a)o.has(e)||(r(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-C23koXgg.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path))),o=t.current;for(let e of a)o.has(e)||(r(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{c as r,d as i,f as a,h as o,m as s,n as c,p as l,r as u,t as d}from"./editor-tabs-CFnvx1pN.js";import{r as f,t as p,v as m}from"./api-L5qtWa7E.js";import{t as h}from"./createLucideIcon-DyMAgLa3.js";import{a as g,o as _,s as v}from"./index-BkJByuhy.js";import{i as y,r as b}from"./editor.api2-4X9Vh9Zw.js";import{a as x,c as S,d as C,f as w,i as T,l as E,n as ee,o as te,r as D,s as O,t as k,u as A}from"./buffer-store-BQUZZSHc.js";import{a as ne,c as j,i as M,l as N,n as P,o as F,r as I,s as L}from"./editor-sync-F3Wyveaa.js";import{r as R}from"./buffer-logic-BrpRsL1b.js";var z=h(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),B=e(t(),1);function V(e){return!e}function re(e,t){e.addCommand(y.CtrlCmd|b.KeyS,()=>t.onSave()),e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:[y.Alt|b.KeyZ],run:()=>_({editorWordWrap:V(g().editorWordWrap)})})}function H(e,t,n){let r=k(e,t),i=o(e,t),a=l(e),[s,c]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),f=(0,B.useRef)(!1),h=(0,B.useRef)(null),g=(0,B.useRef)(null),_=(0,B.useRef)(n);_.current=n;let v=(0,B.useRef)(!1),y=(0,B.useCallback)((e,t)=>{g.current?.cancel(),v.current=!0;try{te(r,e,t)}finally{v.current=!1}},[r]),b=(0,B.useSyncExternalStore)((0,B.useCallback)(e=>E(r,e),[r]),()=>D(r)),x=(0,B.useSyncExternalStore)((0,B.useCallback)(e=>F(r,e),[r]),()=>ne(r));(0,B.useEffect)(()=>{let n=i.data;if(!n||n.binary||n.content===null||f.current)return;f.current=!0;let a=S(r)!==void 0,o=ee(e,t,n.content,n.mtime_ms);c(o),!a&&N(e,t).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?R(o,e.content)&&d(!0):m(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{R(o,e.content)&&d(!0)}}}))})},[i.data,r,e,t]),(0,B.useEffect)(()=>{if(!s)return;let n=j(e,t);g.current=n;let i=s.onDidChangeContent(()=>{v.current||(n(s.getValue(),S(r)??0),P(e,t))});return()=>{n.flush(),i.dispose(),g.current=null}},[s,r,e,t]),(0,B.useEffect)(()=>{!s||!x.savedElsewhere||D(r)||i.refetch().then(e=>{D(r)||(e.data&&e.data.content!==null&&y(e.data.content,e.data.mtime_ms),M(r))})},[x.savedElsewhere,s,r]),(0,B.useEffect)(()=>{let e=i.data;!s||!e||e.content===null||!D(r)&&e.mtime_ms!==S(r)&&y(e.content,e.mtime_ms)},[i.data,s,r]);let C=(0,B.useCallback)((n,i)=>{T(r,n,i),g.current?.cancel(),L(e,t),I(e,t,i),d(!1)},[r,e,t]),w=(0,B.useCallback)(()=>{i.refetch().then(n=>{n.data&&n.data.content!==null&&y(n.data.content,n.data.mtime_ms),L(e,t),d(!1)})},[r,e,t,y]),O=(0,B.useCallback)((e,n)=>{a.mutate({path:t,content:e},{onSuccess:e=>C(n,e.mtime_ms),onError:e=>m.error(e instanceof Error?e.message:`Overwrite failed`)})},[a,t,C]),A=(0,B.useCallback)(()=>{if(!s||!D(r))return;let e=s.getValue(),n=s.getAlternativeVersionId();a.mutate({path:t,content:e,expected_mtime_ms:S(r)},{onSuccess:e=>C(n,e.mtime_ms),onError:t=>{t instanceof p&&t.status===409&&t.code===`stale_file`?m.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>w()},cancel:{label:`Overwrite`,onClick:()=>O(e,n)}}):m.error(t instanceof Error?t.message:`Save failed`)}})},[s,r,a,t,C,w,O]),z=(0,B.useRef)(A);z.current=A;let V=(0,B.useCallback)(()=>{let n=h.current,r=_.current;!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus())},[e,t]),H=(0,B.useCallback)(e=>{h.current=e,re(e,{onSave:()=>z.current()}),V()},[V]);(0,B.useEffect)(()=>{V()},[n,s,V]);let U=(0,B.useCallback)(()=>{w()},[w]),W,G=null;i.data?.binary?W=`binary`:i.error?i.error instanceof p&&i.error.status===413?W=`too-large`:(W=`error`,G=i.error instanceof Error?i.error.message:`Failed to load file`):W=s?`ready`:`loading`;let K=b&&x.savedElsewhere?`saved-elsewhere`:b&&x.dirtyElsewhere?`dirty-elsewhere`:null;return{status:W,errorMessage:G,model:s,dirty:b,restoredNotice:u,discardRestore:U,peerBadge:K,save:A,onMount:H}}var U=n();function W({message:e,session:t,path:n,download:i}){return(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{children:e}),i&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void r(t,n).catch(e=>m.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,U.jsx)(z,{className:`size-4`}),`Download`]})]})}function G({session:e,path:t,reveal:n}){let r=v(),i=H(e,t,n),a=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(i.status===`binary`)return(0,U.jsx)(W,{message:`Binary file — use Download`,session:e,path:t,download:!0});if(i.status===`too-large`)return(0,U.jsx)(W,{message:`File too large to edit — use Download`,session:e,path:t,download:!0});if(i.status===`error`)return(0,U.jsx)(W,{message:i.errorMessage??`Failed to load file`,session:e,path:t});let o=i.peerBadge===`saved-elsewhere`?`Saved in another window`:i.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,U.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[i.restoredNotice&&(0,U.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,U.jsx)(`span`,{children:`Restored unsaved changes`}),(0,U.jsx)(`button`,{type:`button`,onClick:i.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),o&&(0,U.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:o}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:i.model&&(0,U.jsx)(C,{path:i.model.uri.toString(),defaultValue:i.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>i.onMount(e),loading:(0,U.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:a,tabSize:r.editorTabSize,wordWrap:r.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function K({children:e}){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function q(e,t){let n=(0,B.useRef)(t);n.current=t,(0,B.useEffect)(()=>(O(e),()=>{n.current?.(),x(e)}),[e])}function J(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Y({session:e,refName:t,path:n,content:r}){let i=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,U.jsx)(C,{path:J(`puddle-view`,e,t,n),defaultValue:r,theme:A,loading:(0,U.jsx)(K,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function X({session:e,against:t,path:n}){let r=a(e,t,n);return r.isPending?(0,U.jsx)(K,{children:`…`}):r.error?(0,U.jsx)(K,{children:r.error instanceof Error?r.error.message:`Failed to load`}):r.data.binary?(0,U.jsx)(K,{children:`Binary file — deleted`}):(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,U.jsx)(Y,{session:e,refName:t,path:n,content:r.data.content??``})})]})}function ie({session:e,against:t,path:n,basePath:r}){let i=v(),o=H(e,n,null),s=a(e,t,r),c=(0,B.useRef)(null);q(k(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,B.useRef)(o.save);l.current=o.save;let u=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof p&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,U.jsx)(K,{children:`Binary file`}):o.status===`too-large`?(0,U.jsx)(K,{children:`File too large to show`}):o.status===`error`?(0,U.jsx)(K,{children:o.errorMessage??`Failed to load file`}):d?(0,U.jsx)(G,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,U.jsx)(K,{children:`…`}):s.error?(0,U.jsx)(K,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,U.jsx)(w,{modifiedModelPath:o.model.uri.toString(),originalModelPath:J(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:A,keepCurrentModifiedModel:!0,loading:(0,U.jsx)(K,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(y.CtrlCmd|b.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function ae({session:e,path:t}){return q(k(e,t)),(0,U.jsx)(G,{session:e,path:t,reveal:null})}function oe({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,U.jsx)(ae,{session:e,path:n.path});case`deleted`:return(0,U.jsx)(X,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,U.jsx)(ie,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Z({session:e,sha:t,path:n}){let r=a(e,t,n);return r.isPending?(0,U.jsx)(K,{children:`…`}):r.error?(0,U.jsx)(K,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,U.jsx)(K,{children:`Binary file`}):(0,U.jsx)(Y,{session:e,refName:t,path:n,content:r.data.content??``})}function se({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,B.useRef)(null),c=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,B.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,U.jsx)(w,{originalModelPath:J(`puddle-hist-orig`,e,t,n),modifiedModelPath:J(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:A,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,U.jsx)(K,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Q({session:e,sha:t,path:n,basePath:r}){let i=a(e,`${t}^`,r),o=a(e,t,n);return i.error instanceof p&&i.error.status===404?(0,U.jsx)(Z,{session:e,sha:t,path:n}):i.isPending||o.isPending?(0,U.jsx)(K,{children:`…`}):i.error?(0,U.jsx)(K,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):o.error?(0,U.jsx)(K,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):i.data.binary||o.data.binary?(0,U.jsx)(K,{children:`Binary file`}):(0,U.jsx)(se,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``})}function ce({session:e,sha:t,entry:n,isRootCommit:r}){switch(u(n.status,r)){case`added`:return(0,U.jsx)(Z,{session:e,sha:t,path:n.path});case`deleted`:return(0,U.jsx)(X,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,U.jsx)(Q,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function le({session:e,sha:t,path:n}){let r=i(e,t);if(r.isPending)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let a=r.data.files.find(e=>e.path===n);return a?(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(ce,{session:e,sha:t,entry:a,isRootCommit:r.data.parents.length===0})}):(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function ue({session:e,path:t}){let n=s(e);if(n.isPending)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(oe,{session:e,against:n.data.against,entry:r})}):(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,U.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var de={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function fe(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:de[t.slice(n+1).toLowerCase()]??null}function pe({session:e,path:t,kind:n}){let{url:r,error:i}=he(e,t);return i?(0,U.jsxs)($,{children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,U.jsx)(me,{session:e,path:t})]}):r?n===`image`?(0,U.jsx)($,{children:(0,U.jsx)(`img`,{src:r,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,U.jsx)($,{children:(0,U.jsx)(`video`,{src:r,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,U.jsx)($,{children:(0,U.jsx)(`audio`,{src:r,controls:!0,className:`w-full max-w-xl`})}):(0,U.jsx)(`iframe`,{src:r,title:t,className:`h-full w-full border-0 bg-ground`}):(0,U.jsx)($,{children:(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function $({children:e}){return(0,U.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function me({session:e,path:t}){return(0,U.jsx)(`button`,{type:`button`,onClick:()=>void r(e,t).catch(e=>m.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function he(e,t){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let n=null,i=!1;return r(null),a(!1),f(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(e=>{i||(n=URL.createObjectURL(e),r(n))}).catch(()=>{i||a(!0)}),()=>{i=!0,n&&URL.revokeObjectURL(n)}},[e,t]),{url:n,error:i}}function ge({tab:e,reveal:t}){let n=c(e);if(n===`diff`)return(0,U.jsx)(ue,{session:e.session,path:e.path},d(e));if(n===`commit`&&e.sha)return(0,U.jsx)(le,{session:e.session,sha:e.sha,path:e.path},d(e));let r=fe(e.path);return r?(0,U.jsx)(pe,{session:e.session,path:e.path,kind:r},d(e)):(0,U.jsx)(G,{session:e.session,path:e.path,reveal:t},d(e))}export{ge as PaneEditorBody};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{c as r,d as i,f as a,h as o,m as s,n as c,p as l,r as u,t as d}from"./editor-tabs-CFnvx1pN.js";import{r as f,t as p,v as m}from"./api-L5qtWa7E.js";import{t as h}from"./createLucideIcon-DyMAgLa3.js";import{a as g,o as _,s as v}from"./index-bqEa9yZh.js";import{i as y,r as b}from"./editor.api2-4X9Vh9Zw.js";import{a as x,c as S,d as C,f as w,i as T,l as E,n as ee,o as te,r as D,s as O,t as k,u as A}from"./buffer-store-C23koXgg.js";import{a as ne,c as j,i as M,l as N,n as P,o as F,r as I,s as L}from"./editor-sync-F3Wyveaa.js";import{r as R}from"./buffer-logic-BrpRsL1b.js";var z=h(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),B=e(t(),1);function V(e){return!e}function re(e,t){e.addCommand(y.CtrlCmd|b.KeyS,()=>t.onSave()),e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:[y.Alt|b.KeyZ],run:()=>_({editorWordWrap:V(g().editorWordWrap)})})}function H(e,t,n){let r=k(e,t),i=o(e,t),a=l(e),[s,c]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),f=(0,B.useRef)(!1),h=(0,B.useRef)(null),g=(0,B.useRef)(null),_=(0,B.useRef)(n);_.current=n;let v=(0,B.useRef)(!1),y=(0,B.useCallback)((e,t)=>{g.current?.cancel(),v.current=!0;try{te(r,e,t)}finally{v.current=!1}},[r]),b=(0,B.useSyncExternalStore)((0,B.useCallback)(e=>E(r,e),[r]),()=>D(r)),x=(0,B.useSyncExternalStore)((0,B.useCallback)(e=>F(r,e),[r]),()=>ne(r));(0,B.useEffect)(()=>{let n=i.data;if(!n||n.binary||n.content===null||f.current)return;f.current=!0;let a=S(r)!==void 0,o=ee(e,t,n.content,n.mtime_ms);c(o),!a&&N(e,t).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?R(o,e.content)&&d(!0):m(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{R(o,e.content)&&d(!0)}}}))})},[i.data,r,e,t]),(0,B.useEffect)(()=>{if(!s)return;let n=j(e,t);g.current=n;let i=s.onDidChangeContent(()=>{v.current||(n(s.getValue(),S(r)??0),P(e,t))});return()=>{n.flush(),i.dispose(),g.current=null}},[s,r,e,t]),(0,B.useEffect)(()=>{!s||!x.savedElsewhere||D(r)||i.refetch().then(e=>{D(r)||(e.data&&e.data.content!==null&&y(e.data.content,e.data.mtime_ms),M(r))})},[x.savedElsewhere,s,r]),(0,B.useEffect)(()=>{let e=i.data;!s||!e||e.content===null||!D(r)&&e.mtime_ms!==S(r)&&y(e.content,e.mtime_ms)},[i.data,s,r]);let C=(0,B.useCallback)((n,i)=>{T(r,n,i),g.current?.cancel(),L(e,t),I(e,t,i),d(!1)},[r,e,t]),w=(0,B.useCallback)(()=>{i.refetch().then(n=>{n.data&&n.data.content!==null&&y(n.data.content,n.data.mtime_ms),L(e,t),d(!1)})},[r,e,t,y]),O=(0,B.useCallback)((e,n)=>{a.mutate({path:t,content:e},{onSuccess:e=>C(n,e.mtime_ms),onError:e=>m.error(e instanceof Error?e.message:`Overwrite failed`)})},[a,t,C]),A=(0,B.useCallback)(()=>{if(!s||!D(r))return;let e=s.getValue(),n=s.getAlternativeVersionId();a.mutate({path:t,content:e,expected_mtime_ms:S(r)},{onSuccess:e=>C(n,e.mtime_ms),onError:t=>{t instanceof p&&t.status===409&&t.code===`stale_file`?m.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>w()},cancel:{label:`Overwrite`,onClick:()=>O(e,n)}}):m.error(t instanceof Error?t.message:`Save failed`)}})},[s,r,a,t,C,w,O]),z=(0,B.useRef)(A);z.current=A;let V=(0,B.useCallback)(()=>{let n=h.current,r=_.current;!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus())},[e,t]),H=(0,B.useCallback)(e=>{h.current=e,re(e,{onSave:()=>z.current()}),V()},[V]);(0,B.useEffect)(()=>{V()},[n,s,V]);let U=(0,B.useCallback)(()=>{w()},[w]),W,G=null;i.data?.binary?W=`binary`:i.error?i.error instanceof p&&i.error.status===413?W=`too-large`:(W=`error`,G=i.error instanceof Error?i.error.message:`Failed to load file`):W=s?`ready`:`loading`;let K=b&&x.savedElsewhere?`saved-elsewhere`:b&&x.dirtyElsewhere?`dirty-elsewhere`:null;return{status:W,errorMessage:G,model:s,dirty:b,restoredNotice:u,discardRestore:U,peerBadge:K,save:A,onMount:H}}var U=n();function W({message:e,session:t,path:n,download:i}){return(0,U.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{children:e}),i&&(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void r(t,n).catch(e=>m.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,U.jsx)(z,{className:`size-4`}),`Download`]})]})}function G({session:e,path:t,reveal:n}){let r=v(),i=H(e,t,n),a=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(i.status===`binary`)return(0,U.jsx)(W,{message:`Binary file — use Download`,session:e,path:t,download:!0});if(i.status===`too-large`)return(0,U.jsx)(W,{message:`File too large to edit — use Download`,session:e,path:t,download:!0});if(i.status===`error`)return(0,U.jsx)(W,{message:i.errorMessage??`Failed to load file`,session:e,path:t});let o=i.peerBadge===`saved-elsewhere`?`Saved in another window`:i.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,U.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[i.restoredNotice&&(0,U.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,U.jsx)(`span`,{children:`Restored unsaved changes`}),(0,U.jsx)(`button`,{type:`button`,onClick:i.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),o&&(0,U.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:o}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:i.model&&(0,U.jsx)(C,{path:i.model.uri.toString(),defaultValue:i.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>i.onMount(e),loading:(0,U.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:a,tabSize:r.editorTabSize,wordWrap:r.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function K({children:e}){return(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function q(e,t){let n=(0,B.useRef)(t);n.current=t,(0,B.useEffect)(()=>(O(e),()=>{n.current?.(),x(e)}),[e])}function J(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function Y({session:e,refName:t,path:n,content:r}){let i=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,U.jsx)(C,{path:J(`puddle-view`,e,t,n),defaultValue:r,theme:A,loading:(0,U.jsx)(K,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function X({session:e,against:t,path:n}){let r=a(e,t,n);return r.isPending?(0,U.jsx)(K,{children:`…`}):r.error?(0,U.jsx)(K,{children:r.error instanceof Error?r.error.message:`Failed to load`}):r.data.binary?(0,U.jsx)(K,{children:`Binary file — deleted`}):(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,U.jsx)(Y,{session:e,refName:t,path:n,content:r.data.content??``})})]})}function ie({session:e,against:t,path:n,basePath:r}){let i=v(),o=H(e,n,null),s=a(e,t,r),c=(0,B.useRef)(null);q(k(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,B.useRef)(o.save);l.current=o.save;let u=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof p&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,U.jsx)(K,{children:`Binary file`}):o.status===`too-large`?(0,U.jsx)(K,{children:`File too large to show`}):o.status===`error`?(0,U.jsx)(K,{children:o.errorMessage??`Failed to load file`}):d?(0,U.jsx)(G,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,U.jsx)(K,{children:`…`}):s.error?(0,U.jsx)(K,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,U.jsx)(w,{modifiedModelPath:o.model.uri.toString(),originalModelPath:J(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:A,keepCurrentModifiedModel:!0,loading:(0,U.jsx)(K,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(y.CtrlCmd|b.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function ae({session:e,path:t}){return q(k(e,t)),(0,U.jsx)(G,{session:e,path:t,reveal:null})}function oe({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,U.jsx)(ae,{session:e,path:n.path});case`deleted`:return(0,U.jsx)(X,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,U.jsx)(ie,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Z({session:e,sha:t,path:n}){let r=a(e,t,n);return r.isPending?(0,U.jsx)(K,{children:`…`}):r.error?(0,U.jsx)(K,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,U.jsx)(K,{children:`Binary file`}):(0,U.jsx)(Y,{session:e,refName:t,path:n,content:r.data.content??``})}function se({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,B.useRef)(null),c=(0,B.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,B.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,U.jsx)(w,{originalModelPath:J(`puddle-hist-orig`,e,t,n),modifiedModelPath:J(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:A,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,U.jsx)(K,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Q({session:e,sha:t,path:n,basePath:r}){let i=a(e,`${t}^`,r),o=a(e,t,n);return i.error instanceof p&&i.error.status===404?(0,U.jsx)(Z,{session:e,sha:t,path:n}):i.isPending||o.isPending?(0,U.jsx)(K,{children:`…`}):i.error?(0,U.jsx)(K,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):o.error?(0,U.jsx)(K,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):i.data.binary||o.data.binary?(0,U.jsx)(K,{children:`Binary file`}):(0,U.jsx)(se,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``})}function ce({session:e,sha:t,entry:n,isRootCommit:r}){switch(u(n.status,r)){case`added`:return(0,U.jsx)(Z,{session:e,sha:t,path:n.path});case`deleted`:return(0,U.jsx)(X,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,U.jsx)(Q,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function le({session:e,sha:t,path:n}){let r=i(e,t);if(r.isPending)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let a=r.data.files.find(e=>e.path===n);return a?(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(ce,{session:e,sha:t,entry:a,isRootCommit:r.data.parents.length===0})}):(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function ue({session:e,path:t}){let n=s(e);if(n.isPending)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,U.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(oe,{session:e,against:n.data.against,entry:r})}):(0,U.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,U.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var de={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function fe(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:de[t.slice(n+1).toLowerCase()]??null}function pe({session:e,path:t,kind:n}){let{url:r,error:i}=he(e,t);return i?(0,U.jsxs)($,{children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,U.jsx)(me,{session:e,path:t})]}):r?n===`image`?(0,U.jsx)($,{children:(0,U.jsx)(`img`,{src:r,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,U.jsx)($,{children:(0,U.jsx)(`video`,{src:r,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,U.jsx)($,{children:(0,U.jsx)(`audio`,{src:r,controls:!0,className:`w-full max-w-xl`})}):(0,U.jsx)(`iframe`,{src:r,title:t,className:`h-full w-full border-0 bg-ground`}):(0,U.jsx)($,{children:(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function $({children:e}){return(0,U.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function me({session:e,path:t}){return(0,U.jsx)(`button`,{type:`button`,onClick:()=>void r(e,t).catch(e=>m.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function he(e,t){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let n=null,i=!1;return r(null),a(!1),f(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(e=>{i||(n=URL.createObjectURL(e),r(n))}).catch(()=>{i||a(!0)}),()=>{i=!0,n&&URL.revokeObjectURL(n)}},[e,t]),{url:n,error:i}}function ge({tab:e,reveal:t}){let n=c(e);if(n===`diff`)return(0,U.jsx)(ue,{session:e.session,path:e.path},d(e));if(n===`commit`&&e.sha)return(0,U.jsx)(le,{session:e.session,sha:e.sha,path:e.path},d(e));let r=fe(e.path);return r?(0,U.jsx)(pe,{session:e.session,path:e.path,kind:r},d(e)):(0,U.jsx)(G,{session:e.session,path:e.path,reveal:t},d(e))}export{ge as PaneEditorBody};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{c as r,d as i,f as a,l as o,p as s,u as c,v as l}from"./api-L5qtWa7E.js";import{a as u,g as d,i as f,n as p,o as m,r as h,t as g}from"./dialog-B43iKmfK.js";import{t as _}from"./utils-B6KiDbIe.js";import{t as v}from"./createLucideIcon-DyMAgLa3.js";import{a as y,c as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./session-seed-uIZJKzcf.js";import{r as D}from"./dist-fdPAlKke.js";import{$ as O,B as k,C as A,D as ee,E as te,F as j,Ft as ne,G as re,H as ie,I as ae,J as M,K as oe,M as N,O as se,Q as ce,W as le,X as ue,Z as P,_ as de,_t as fe,at as pe,b as me,g as he,gt as F,ht as I,i as ge,j as _e,jt as ve,l as L,nt as R,o as z,p as ye,rt as B,s as V,tt as be,ut as xe,x as Se,y as H,z as U}from"./index-BkJByuhy.js";var Ce=v(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),we=v(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),W=v(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Te=v(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Ee=v(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),De=v(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Oe=v(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ke=v(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({label:e,description:t,htmlFor:n,children:r,className:i}){return(0,K.jsxs)(`div`,{className:_(`flex items-center gap-4 py-2.5`,i),children:[(0,K.jsxs)(`label`,{htmlFor:n,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]})}function J({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Ae(){let e=V(),[t,n]=(0,G.useState)(ne());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(w,{value:t,onValueChange:e=>{n(e),ve(e)},children:[(0,K.jsx)(C,{className:`w-32`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:`dark`,children:`Dark`}),(0,K.jsx)(y,{value:`light`,children:`Light`}),(0,K.jsx)(y,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(F,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>z({uiFontSize:Number(e.target.value)||ge.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(F,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>z({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(w,{value:e.density,onValueChange:e=>z({density:e}),children:[(0,K.jsx)(C,{className:`w-36`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:`compact`,children:`Compact`}),(0,K.jsx)(y,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,K.jsx)(S,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>z({reducedMotion:e})})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(S,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>z({showAllProjectSessions:e})})})]})}var Y=`__none__`;function je(){let e=N(),t=B().data?.find(t=>t.id===e),n=j(e??void 0),i=R(e??void 0),a=ce(),o=O(e??``),s=le(),[c,_]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[S,E]=(0,G.useState)(!1),[D,k]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(_(t.name),b(t.branch_prefix))},[t]),!t)return null;let A=i.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(F,{id:`profile-name`,value:c,onChange:e=>_(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:c},{onError:e=>l.error(e.message)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(F,{id:`branch-prefix`,value:v,onChange:e=>b(e.target.value),placeholder:r,className:`w-44 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:v},{onError:e=>l.error(e.message)}),children:`Save`})]}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(w,{value:typeof A==`number`?String(A):Y,onValueChange:e=>o.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>l.error(e.message)}),children:[(0,K.jsx)(C,{className:`w-56`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(y,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(d,{variant:`danger`,size:`sm`,onClick:()=>E(!0),children:`Delete…`})}),(0,K.jsx)(g,{open:S,onOpenChange:e=>{e||(E(!1),k(``))},children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(h,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(I,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(F,{id:`delete-confirm-name`,value:D,onChange:e=>k(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>{E(!1),k(``)},children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:D!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{H(),_e.set(null)},onError:e=>{E(!1),k(``),l.error(e.message)}}),children:`Delete profile`})]})]})})]})}function Me({agentId:e,profileId:t,onClose:n}){let r=k(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=re(he(o,150)),_=i.trim()!==``&&(o.startsWith(`/`)||o.startsWith(`~`));return(0,K.jsx)(g,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsx)(m,{children:`Import an existing account`}),(0,K.jsx)(h,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(F,{placeholder:`label, e.g. personal`,value:i,onChange:e=>a(e.target.value),className:`font-mono`}),(0,K.jsx)(de,{value:o,onValueChange:s,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(c.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(d,{disabled:!_||r.isPending,onClick:()=>r.mutate({profile_id:t,agent_type:e,label:i.trim(),import_dir:o.trim()},{onSuccess:e=>{n(),e.logged_in||l.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>l.error(e.message)}),children:[(0,K.jsx)(W,{}),`Import`]})]})]})})}function Ne({account:e,gateOpen:t}){let n=M(),r=ue(),i=ie(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[_,v]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>v(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onBlur:()=>{let t=_.trim();if(t!==e.label){if(t===``){v(e.label);return}r.mutate({id:e.id,label:t},{onError:t=>{l.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-running`:`text-waiting`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(S,{checked:e.skip_permissions_default,onCheckedChange:t=>r.mutate({id:e.id,skip_permissions_default:t},{onError:e=>l.error(e.message)})})]}),(0,K.jsxs)(d,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>o(e.stream),onError:e=>l.error(e.message)}),children:[(0,K.jsx)(se,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(d,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>c(!0),children:[(0,K.jsx)(b,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),a&&(0,K.jsx)(L,{stream:a,label:`${e.agent_type}/${e.label}`,onClose:()=>o(null)}),(0,K.jsx)(g,{open:s,onOpenChange:c,children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(h,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:i.isPending,onClick:()=>i.mutate(e.id,{onSuccess:()=>c(!1),onError:e=>{c(!1),l.error(e.message)}}),children:`Delete account`})]})]})})]})}function Pe(){let e=N(),t=ae(),n=j(e??void 0),r=R(e??void 0),i=k(),a=M(),[o,s]=(0,G.useState)({}),[c,u]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),m=r.data?.allowSkipPermissions===!0,h=t=>{let n=(o[t]??``).trim();!n||e===null||i.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{s(e=>({...e,[t]:``})),a.mutate(e.id,{onSuccess:n=>u({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>l.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(Ne,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,K.jsx)(F,{placeholder:`label, e.g. personal`,value:o[e.id]??``,onChange:t=>s(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,K.jsxs)(d,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(o[e.id]??``).trim()||i.isPending,children:[(0,K.jsx)(ee,{}),`Add account`]}),(0,K.jsxs)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,K.jsx)(W,{}),`Import existing…`]})]})]})]},e.id)}),c&&(0,K.jsx)(L,{stream:c.stream,label:c.label,onClose:()=>u(null)}),f!==null&&e!==null&&(0,K.jsx)(Me,{agentId:f,profileId:e,onClose:()=>p(null)})]})}function Fe(){let e=U(),t=P(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function X({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=E(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(S,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(S,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Ie(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(F,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:V().terminalScrollback,onChange:e=>z({terminalScrollback:Number(e.target.value)||5e3})})})}function Z({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(fe,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(d,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Le={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function Re({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),o=r.length>0?r:a;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:a}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:ye(Le,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:s.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(d,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(a),t(a)},children:`Reset to default`})]})]})}function ze(){let e=N(),t=B().data?.find(t=>t.id===e),n=R(e??void 0),r=O(e??``),[a,s]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),v(``)},onError:e=>l.error(e.message)}),x=e=>t=>r.mutate({[e]:t},{onError:e=>l.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(S,{id:`gate`,checked:y,onCheckedChange:e=>{e?s(!0):b(!1)}})}),(0,K.jsx)(Fe,{}),(0,K.jsx)(Ie,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>l.error(e.message)}),pending:r.isPending},`${e}:agent-seed`),(0,K.jsx)(X,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>l.error(e.message)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??c,defaultText:c,onSave:x(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,K.jsx)(Z,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??o,defaultText:o,onSave:x(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,K.jsx)(Z,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??i,defaultText:i,onSave:x(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(Re,{initial:n.data.tabTitleTemplate??"${name}",onSave:x(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,K.jsx)(g,{open:a,onOpenChange:e=>{e||(s(!1),v(``))},children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{className:`flex items-center gap-2`,children:[(0,K.jsx)(De,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(h,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(I,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(F,{id:`confirm-name`,value:_,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>{s(!1),v(``)},children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:_!==t?.name||r.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var Be={desktop:!0,sound:!1,muted_projects:[]};function Ve(){let e=N(),t=R(e??void 0),n=O(e??``),r=pe(e??void 0),i={...Be,...t.data?.notifications??{}},a=e=>n.mutate({notifications:e},{onError:e=>l.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Delivery lands in a later phase`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`When a session flips to waiting for input.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(S,{id:`notify-desktop`,checked:i.desktop,onCheckedChange:e=>a({...i,desktop:e})})}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(S,{id:`notify-sound`,checked:i.sound,onCheckedChange:e=>a({...i,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[i.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(S,{checked:i.muted_projects.includes(e.id),onCheckedChange:t=>a({...i,muted_projects:t?[...i.muted_projects,e.id]:i.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function He(){let e=V();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(F,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>z({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(S,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>z({editorWordWrap:e})})}),(0,K.jsx)(q,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>z({editorLinkSshHost:e.target.value})})})]})}function Ue({repo:e}){let t=be(),n=oe(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>l.error(e.message);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(d,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>l.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(te,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,K.jsx)(q,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(S,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,K.jsx)(fe,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function We(){let e=xe();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Ue,{repo:e},e.id))]})}function Q({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=P();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>l.error(e.message)})}})})}function Ge(){let e=U(),t=P();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(Q,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)(Q,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)(Q,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)(Q,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(S,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>l.error(e.message)})})})]}):null}var $=[{id:`appearance`,label:`Appearance`,icon:Te,render:()=>(0,K.jsx)(Ae,{})},{id:`profile`,label:`Profile`,icon:A,render:()=>(0,K.jsx)(je,{})},{id:`accounts`,label:`Accounts`,icon:ke,render:()=>(0,K.jsx)(Pe,{})},{id:`sessions`,label:`Sessions`,icon:Oe,render:()=>(0,K.jsx)(ze,{})},{id:`editor`,label:`Editor`,icon:we,render:()=>(0,K.jsx)(He,{})},{id:`notifications`,label:`Notifications`,icon:Ce,render:()=>(0,K.jsx)(Ve,{})},{id:`repositories`,label:`Repositories`,icon:D,render:()=>(0,K.jsx)(We,{})},{id:`host`,label:`Host`,icon:Ee,render:()=>(0,K.jsx)(Ge,{})}],Ke={terminal:`sessions`};function qe(){let e=Se(),t=e===null?null:Ke[e]??e,n=$.find(e=>e.id===t)??$[0];return(0,K.jsx)(g,{open:e!==null,onOpenChange:e=>!e&&H(),children:(0,K.jsxs)(p,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(m,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),$.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>me(e),className:_(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{qe as SettingsDialog};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{c as r,d as i,f as a,l as o,p as s,u as c,v as l}from"./api-L5qtWa7E.js";import{a as u,g as d,i as f,n as p,o as m,r as h,t as g}from"./dialog-B43iKmfK.js";import{t as _}from"./utils-B6KiDbIe.js";import{t as v}from"./createLucideIcon-DyMAgLa3.js";import{a as y,c as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./session-seed-BafHkB3F.js";import{r as D}from"./dist-fdPAlKke.js";import{$ as O,B as k,C as A,D as ee,E as te,F as j,Ft as ne,G as re,H as ie,I as ae,J as M,K as oe,M as N,O as se,Q as ce,W as le,X as ue,Z as P,_ as de,_t as fe,at as pe,b as me,g as he,gt as F,ht as I,i as ge,j as _e,jt as ve,l as L,nt as R,o as z,p as ye,rt as B,s as V,tt as be,ut as xe,x as Se,y as H,z as U}from"./index-bqEa9yZh.js";var Ce=v(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),we=v(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),W=v(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Te=v(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Ee=v(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),De=v(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Oe=v(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ke=v(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({label:e,description:t,htmlFor:n,children:r,className:i}){return(0,K.jsxs)(`div`,{className:_(`flex items-center gap-4 py-2.5`,i),children:[(0,K.jsxs)(`label`,{htmlFor:n,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]})}function J({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Ae(){let e=V(),[t,n]=(0,G.useState)(ne());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(w,{value:t,onValueChange:e=>{n(e),ve(e)},children:[(0,K.jsx)(C,{className:`w-32`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:`dark`,children:`Dark`}),(0,K.jsx)(y,{value:`light`,children:`Light`}),(0,K.jsx)(y,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(F,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>z({uiFontSize:Number(e.target.value)||ge.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(F,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>z({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(w,{value:e.density,onValueChange:e=>z({density:e}),children:[(0,K.jsx)(C,{className:`w-36`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:`compact`,children:`Compact`}),(0,K.jsx)(y,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,K.jsx)(S,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>z({reducedMotion:e})})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(S,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>z({showAllProjectSessions:e})})})]})}var Y=`__none__`;function je(){let e=N(),t=B().data?.find(t=>t.id===e),n=j(e??void 0),i=R(e??void 0),a=ce(),o=O(e??``),s=le(),[c,_]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[S,E]=(0,G.useState)(!1),[D,k]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(_(t.name),b(t.branch_prefix))},[t]),!t)return null;let A=i.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(F,{id:`profile-name`,value:c,onChange:e=>_(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:c===t.name||c.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:c},{onError:e=>l.error(e.message)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(F,{id:`branch-prefix`,value:v,onChange:e=>b(e.target.value),placeholder:r,className:`w-44 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:v},{onError:e=>l.error(e.message)}),children:`Save`})]}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(w,{value:typeof A==`number`?String(A):Y,onValueChange:e=>o.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>l.error(e.message)}),children:[(0,K.jsx)(C,{className:`w-56`,children:(0,K.jsx)(T,{})}),(0,K.jsxs)(x,{children:[(0,K.jsx)(y,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(y,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(d,{variant:`danger`,size:`sm`,onClick:()=>E(!0),children:`Delete…`})}),(0,K.jsx)(g,{open:S,onOpenChange:e=>{e||(E(!1),k(``))},children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(h,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(I,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(F,{id:`delete-confirm-name`,value:D,onChange:e=>k(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>{E(!1),k(``)},children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:D!==t.name||s.isPending,onClick:()=>s.mutate(t.id,{onSuccess:()=>{H(),_e.set(null)},onError:e=>{E(!1),k(``),l.error(e.message)}}),children:`Delete profile`})]})]})})]})}function Me({agentId:e,profileId:t,onClose:n}){let r=k(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=re(he(o,150)),_=i.trim()!==``&&(o.startsWith(`/`)||o.startsWith(`~`));return(0,K.jsx)(g,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsx)(m,{children:`Import an existing account`}),(0,K.jsx)(h,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(F,{placeholder:`label, e.g. personal`,value:i,onChange:e=>a(e.target.value),className:`font-mono`}),(0,K.jsx)(de,{value:o,onValueChange:s,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(c.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(d,{disabled:!_||r.isPending,onClick:()=>r.mutate({profile_id:t,agent_type:e,label:i.trim(),import_dir:o.trim()},{onSuccess:e=>{n(),e.logged_in||l.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>l.error(e.message)}),children:[(0,K.jsx)(W,{}),`Import`]})]})]})})}function Ne({account:e,gateOpen:t}){let n=M(),r=ue(),i=ie(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[_,v]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>v(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onBlur:()=>{let t=_.trim();if(t!==e.label){if(t===``){v(e.label);return}r.mutate({id:e.id,label:t},{onError:t=>{l.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-running`:`text-waiting`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(S,{checked:e.skip_permissions_default,onCheckedChange:t=>r.mutate({id:e.id,skip_permissions_default:t},{onError:e=>l.error(e.message)})})]}),(0,K.jsxs)(d,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>o(e.stream),onError:e=>l.error(e.message)}),children:[(0,K.jsx)(se,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(d,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>c(!0),children:[(0,K.jsx)(b,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),a&&(0,K.jsx)(L,{stream:a,label:`${e.agent_type}/${e.label}`,onClose:()=>o(null)}),(0,K.jsx)(g,{open:s,onOpenChange:c,children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(h,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:i.isPending,onClick:()=>i.mutate(e.id,{onSuccess:()=>c(!1),onError:e=>{c(!1),l.error(e.message)}}),children:`Delete account`})]})]})})]})}function Pe(){let e=N(),t=ae(),n=j(e??void 0),r=R(e??void 0),i=k(),a=M(),[o,s]=(0,G.useState)({}),[c,u]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),m=r.data?.allowSkipPermissions===!0,h=t=>{let n=(o[t]??``).trim();!n||e===null||i.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{s(e=>({...e,[t]:``})),a.mutate(e.id,{onSuccess:n=>u({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>l.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(Ne,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,K.jsx)(F,{placeholder:`label, e.g. personal`,value:o[e.id]??``,onChange:t=>s(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,K.jsxs)(d,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(o[e.id]??``).trim()||i.isPending,children:[(0,K.jsx)(ee,{}),`Add account`]}),(0,K.jsxs)(d,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,K.jsx)(W,{}),`Import existing…`]})]})]})]},e.id)}),c&&(0,K.jsx)(L,{stream:c.stream,label:c.label,onClose:()=>u(null)}),f!==null&&e!==null&&(0,K.jsx)(Me,{agentId:f,profileId:e,onClose:()=>p(null)})]})}function Fe(){let e=U(),t=P(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function X({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=E(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(S,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(S,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Ie(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(F,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:V().terminalScrollback,onChange:e=>z({terminalScrollback:Number(e.target.value)||5e3})})})}function Z({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(fe,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(d,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Le={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function Re({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),o=r.length>0?r:a;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:a}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:ye(Le,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:s.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(d,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(a),t(a)},children:`Reset to default`})]})]})}function ze(){let e=N(),t=B().data?.find(t=>t.id===e),n=R(e??void 0),r=O(e??``),[a,s]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),v(``)},onError:e=>l.error(e.message)}),x=e=>t=>r.mutate({[e]:t},{onError:e=>l.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(S,{id:`gate`,checked:y,onCheckedChange:e=>{e?s(!0):b(!1)}})}),(0,K.jsx)(Fe,{}),(0,K.jsx)(Ie,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>l.error(e.message)}),pending:r.isPending},`${e}:agent-seed`),(0,K.jsx)(X,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>l.error(e.message)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Z,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??c,defaultText:c,onSave:x(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,K.jsx)(Z,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??o,defaultText:o,onSave:x(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,K.jsx)(Z,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??i,defaultText:i,onSave:x(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(Re,{initial:n.data.tabTitleTemplate??"${name}",onSave:x(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,K.jsx)(g,{open:a,onOpenChange:e=>{e||(s(!1),v(``))},children:(0,K.jsxs)(p,{children:[(0,K.jsxs)(u,{children:[(0,K.jsxs)(m,{className:`flex items-center gap-2`,children:[(0,K.jsx)(De,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(h,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(I,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(F,{id:`confirm-name`,value:_,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(f,{children:[(0,K.jsx)(d,{variant:`ghost`,onClick:()=>{s(!1),v(``)},children:`Cancel`}),(0,K.jsx)(d,{variant:`danger`,disabled:_!==t?.name||r.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var Be={desktop:!0,sound:!1,muted_projects:[]};function Ve(){let e=N(),t=R(e??void 0),n=O(e??``),r=pe(e??void 0),i={...Be,...t.data?.notifications??{}},a=e=>n.mutate({notifications:e},{onError:e=>l.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Delivery lands in a later phase`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`When a session flips to waiting for input.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(S,{id:`notify-desktop`,checked:i.desktop,onCheckedChange:e=>a({...i,desktop:e})})}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(S,{id:`notify-sound`,checked:i.sound,onCheckedChange:e=>a({...i,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[i.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(S,{checked:i.muted_projects.includes(e.id),onCheckedChange:t=>a({...i,muted_projects:t?[...i.muted_projects,e.id]:i.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function He(){let e=V();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(F,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>z({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(S,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>z({editorWordWrap:e})})}),(0,K.jsx)(q,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>z({editorLinkSshHost:e.target.value})})})]})}function Ue({repo:e}){let t=be(),n=oe(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>l.error(e.message);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(d,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>l.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(te,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,K.jsx)(q,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(S,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,K.jsx)(fe,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(d,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function We(){let e=xe();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Ue,{repo:e},e.id))]})}function Q({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=P();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>l.error(e.message)})}})})}function Ge(){let e=U(),t=P();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(Q,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)(Q,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)(Q,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)(Q,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(S,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>l.error(e.message)})})})]}):null}var $=[{id:`appearance`,label:`Appearance`,icon:Te,render:()=>(0,K.jsx)(Ae,{})},{id:`profile`,label:`Profile`,icon:A,render:()=>(0,K.jsx)(je,{})},{id:`accounts`,label:`Accounts`,icon:ke,render:()=>(0,K.jsx)(Pe,{})},{id:`sessions`,label:`Sessions`,icon:Oe,render:()=>(0,K.jsx)(ze,{})},{id:`editor`,label:`Editor`,icon:we,render:()=>(0,K.jsx)(He,{})},{id:`notifications`,label:`Notifications`,icon:Ce,render:()=>(0,K.jsx)(Ve,{})},{id:`repositories`,label:`Repositories`,icon:D,render:()=>(0,K.jsx)(We,{})},{id:`host`,label:`Host`,icon:Ee,render:()=>(0,K.jsx)(Ge,{})}],Ke={terminal:`sessions`};function qe(){let e=Se(),t=e===null?null:Ke[e]??e,n=$.find(e=>e.id===t)??$[0];return(0,K.jsx)(g,{open:e!==null,onOpenChange:e=>!e&&H(),children:(0,K.jsxs)(p,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(m,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),$.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>me(e),className:_(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{qe as SettingsDialog};