@puddle-code/cli 0.0.5 → 0.0.6

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 (31) hide show
  1. package/CHANGELOG.md +21 -10
  2. package/dist/index.js +206 -13
  3. package/dist/public/assets/Dashboard-CEPwl8SL.js +1 -0
  4. package/dist/public/assets/{EditorTabClose-82Z5eiQN.js → EditorTabClose-eigXdiCB.js} +1 -1
  5. package/dist/public/assets/{ModelRefcount-DuJU1nuj.js → ModelRefcount-BPtz3aiO.js} +1 -1
  6. package/dist/public/assets/{PaneEditorBody-DmMOCV_I.js → PaneEditorBody-Cd-gTwQf.js} +1 -1
  7. package/dist/public/assets/SettingsDialog-B772Gh8X.js +1 -0
  8. package/dist/public/assets/{Terminal-CD3LbItq.js → Terminal-B4pgs3im.js} +2 -2
  9. package/dist/public/assets/Workspace-P16s6r31.js +6 -0
  10. package/dist/public/assets/{api-BJKPJeFZ.js → api-L5qtWa7E.js} +1 -1
  11. package/dist/public/assets/{buffer-store--EObrd7i.js → buffer-store-BQUZZSHc.js} +2 -2
  12. package/dist/public/assets/context-menu-pZk42aSN.js +1 -0
  13. package/dist/public/assets/{cssMode-Dgj8FXvj.js → cssMode-ZS6zMeEj.js} +1 -1
  14. package/dist/public/assets/{editor-tabs-Cw21CVB0.js → editor-tabs-CFnvx1pN.js} +1 -1
  15. package/dist/public/assets/{htmlMode-r2nOt3Tp.js → htmlMode-D4c37GJ9.js} +1 -1
  16. package/dist/public/assets/index-BkJByuhy.js +10 -0
  17. package/dist/public/assets/index-D-ztnhM0.css +2 -0
  18. package/dist/public/assets/{jsonMode-te9Xmu_C.js → jsonMode-CF-1fM0S.js} +1 -1
  19. package/dist/public/assets/session-seed-uIZJKzcf.js +1 -0
  20. package/dist/public/assets/ssh-mode-DNQdm1uV.js +1 -0
  21. package/dist/public/assets/{tsMode-Cs7L_kKV.js → tsMode-BV-x0-vm.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/Dashboard-C1H7r1Al.js +0 -1
  25. package/dist/public/assets/SettingsDialog-aRqM2FKI.js +0 -1
  26. package/dist/public/assets/Workspace-ChM_ssfz.js +0 -6
  27. package/dist/public/assets/context-menu-CGL06LiB.js +0 -1
  28. package/dist/public/assets/index-D994oCvG.js +0 -10
  29. package/dist/public/assets/index-YunCFzL-.css +0 -2
  30. package/dist/public/assets/ssh-mode-DWHs6m9n.js +0 -1
  31. package/dist/public/assets/switch-BbnQDPjG.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,22 +7,33 @@ Past releases: see docs/changelogs/.
7
7
 
8
8
  # Changelog
9
9
 
10
- ## [0.0.5] — 2026-07-17
10
+ ## [0.0.6] — 2026-07-17
11
11
 
12
12
  ### Added
13
13
 
14
- - "Open terminal in worktree" in the session lifecycle menu (expanded rows, collapsed dots, and tab right-click alike): spawns a terminal session sharing that session's working directory and lands in it.
15
- - Reorder tabs within a pane's tab strip by drag: each chip and the strip's tail are drop targets resolving to an insertion index, marked by a live caret.
16
- - Session status dots now show on terminal tabs from OTHER projects too the tiling area labels its tabs against the daemon's full session list, not just the current project's.
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).
17
21
 
18
22
  ### Changed
19
23
 
20
- - **Breaking (protocol 7.0):** workspace ui_state is keyed by profile alone, not (project, profile) the centre editor area is one surface shared across a profile's projects, so navigating between projects keeps the same layout tree. `GET/PUT /api/projects/:id/state` moved to `/api/profiles/:id/state`; the `project_states` table migrates to `profile_states` (each profile keeps its most recent snapshot), and cross-profile seeding is gone — a fresh profile starts with a fresh workspace.
21
- - Dragging a tab into another pane now MOVES it — file tabs behave exactly like terminals, leaving nothing behind (previously an editor drop into a different pane duplicated the tab).
22
- - A drag pins: dropping a preview (italic) tab anywhere promotes it to a permanent tab, as in VSCode.
23
- - Session reordering in the right sidebar works in the cross-project view too (expanded rows and collapsed dots alike): drag within a project's group; the order persists profile-wide and a drag can never move a session between projects.
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).
24
30
 
25
31
  ### Fixed
26
32
 
27
- - Tab reordering within a pane's strip works again a centre drop used to append to the end of the target strip regardless of where the tab was dropped.
28
- - Reordering sessions in the right sidebar works again it had been disabled whenever the cross-project sidebar (the default) was on.
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.
package/dist/index.js CHANGED
@@ -3912,6 +3912,8 @@ usage:
3912
3912
  [--tarball <path>]
3913
3913
  puddle connect user@host [--port <local>] [--remote-port <p>] [--foreground]
3914
3914
  [--no-browser] [--no-upgrade] [--tarball <path>]
3915
+ puddle refresh [local | user@host] [--port <p>] [--remote-port <p>]
3916
+ [--foreground] [--no-browser] [--no-upgrade] [--tarball <path>]
3915
3917
  puddle list
3916
3918
  puddle kill [local | user@host | --all]
3917
3919
  puddle status [user@host]
@@ -3924,8 +3926,10 @@ start serves the cockpit at http://localhost:7433 against the daemon on this
3924
3926
  machine (installing it under ~/.puddle if needed); connect does the same for
3925
3927
  an SSH host through one tunnel. Both keep running in the background once
3926
3928
  ready, so the terminal may close (--foreground to stay attached; Ctrl-C then
3927
- stops the cockpit). list shows running cockpits; kill stops one \u2014 sessions
3928
- keep running on the host either way.`;
3929
+ stops the cockpit). refresh stops a target's cockpit (even a wedged one) and
3930
+ runs the full start/connect flow again \u2014 tunnel, daemon restart if needed \u2014
3931
+ keeping the old UI port so open tabs survive. list shows running cockpits;
3932
+ kill stops one \u2014 sessions keep running on the host either way.`;
3929
3933
  function parseArgs(argv) {
3930
3934
  const [cmd, ...rest] = argv;
3931
3935
  if (cmd === void 0 || cmd === "help" || cmd === "--help" || cmd === "-h")
@@ -3937,7 +3941,7 @@ function parseArgs(argv) {
3937
3941
  const arg = rest[i];
3938
3942
  if (arg === void 0) continue;
3939
3943
  if (arg.startsWith("-")) {
3940
- const valued = /* @__PURE__ */ new Set(["--port", "--remote-port", "--tarball", "--term"]);
3944
+ const valued = /* @__PURE__ */ new Set(["--port", "--prefer-port", "--remote-port", "--tarball", "--term"]);
3941
3945
  if (valued.has(arg)) {
3942
3946
  const value = rest[i + 1];
3943
3947
  if (value === void 0 || value.startsWith("-")) {
@@ -3981,11 +3985,20 @@ function parseArgs(argv) {
3981
3985
  );
3982
3986
  }
3983
3987
  const port = intFlag("--port");
3988
+ const preferPort = intFlag("--prefer-port");
3984
3989
  const tarball = strFlag("--tarball");
3985
- expect("--port", "--no-browser", "--no-upgrade", "--tarball", "--foreground");
3990
+ expect(
3991
+ "--port",
3992
+ "--prefer-port",
3993
+ "--no-browser",
3994
+ "--no-upgrade",
3995
+ "--tarball",
3996
+ "--foreground"
3997
+ );
3986
3998
  return {
3987
3999
  cmd: "start",
3988
4000
  ...port !== void 0 ? { port } : {},
4001
+ ...preferPort !== void 0 ? { preferPort } : {},
3989
4002
  ...tarball !== void 0 ? { tarball } : {},
3990
4003
  noBrowser: flags.has("--no-browser"),
3991
4004
  noUpgrade: flags.has("--no-upgrade"),
@@ -3999,10 +4012,12 @@ function parseArgs(argv) {
3999
4012
  if (positionals.length > 1)
4000
4013
  throw new CliError("bad_arguments", "connect takes exactly one host");
4001
4014
  const port = intFlag("--port");
4015
+ const preferPort = intFlag("--prefer-port");
4002
4016
  const remotePort = intFlag("--remote-port");
4003
4017
  const tarball = strFlag("--tarball");
4004
4018
  expect(
4005
4019
  "--port",
4020
+ "--prefer-port",
4006
4021
  "--remote-port",
4007
4022
  "--no-browser",
4008
4023
  "--no-upgrade",
@@ -4013,6 +4028,33 @@ function parseArgs(argv) {
4013
4028
  cmd: "connect",
4014
4029
  host,
4015
4030
  ...port !== void 0 ? { port } : {},
4031
+ ...preferPort !== void 0 ? { preferPort } : {},
4032
+ ...remotePort !== void 0 ? { remotePort } : {},
4033
+ ...tarball !== void 0 ? { tarball } : {},
4034
+ noBrowser: flags.has("--no-browser"),
4035
+ noUpgrade: flags.has("--no-upgrade"),
4036
+ foreground: flags.has("--foreground")
4037
+ };
4038
+ }
4039
+ case "refresh": {
4040
+ if (positionals.length > 1)
4041
+ throw new CliError("bad_arguments", "refresh takes at most one target");
4042
+ const target = positionals[0];
4043
+ const port = intFlag("--port");
4044
+ const remotePort = intFlag("--remote-port");
4045
+ const tarball = strFlag("--tarball");
4046
+ expect(
4047
+ "--port",
4048
+ "--remote-port",
4049
+ "--no-browser",
4050
+ "--no-upgrade",
4051
+ "--tarball",
4052
+ "--foreground"
4053
+ );
4054
+ return {
4055
+ cmd: "refresh",
4056
+ ...target !== void 0 ? { target } : {},
4057
+ ...port !== void 0 ? { port } : {},
4016
4058
  ...remotePort !== void 0 ? { remotePort } : {},
4017
4059
  ...tarball !== void 0 ? { tarball } : {},
4018
4060
  noBrowser: flags.has("--no-browser"),
@@ -4088,6 +4130,20 @@ function parseArgs(argv) {
4088
4130
  throw new CliError("bad_arguments", `unknown command '${cmd}'`, "see: puddle --help");
4089
4131
  }
4090
4132
  }
4133
+ function argvFor(command) {
4134
+ const argv = [command.cmd];
4135
+ if (command.cmd === "connect") argv.push(command.host);
4136
+ if (command.port !== void 0) argv.push("--port", String(command.port));
4137
+ if (command.preferPort !== void 0) argv.push("--prefer-port", String(command.preferPort));
4138
+ if (command.cmd === "connect" && command.remotePort !== void 0) {
4139
+ argv.push("--remote-port", String(command.remotePort));
4140
+ }
4141
+ if (command.tarball !== void 0) argv.push("--tarball", command.tarball);
4142
+ if (command.noBrowser) argv.push("--no-browser");
4143
+ if (command.noUpgrade) argv.push("--no-upgrade");
4144
+ if (command.foreground) argv.push("--foreground");
4145
+ return argv;
4146
+ }
4091
4147
 
4092
4148
  // src/cli/run.ts
4093
4149
  init_attach();
@@ -4111,7 +4167,7 @@ function openBrowser(url2, platform = process.platform) {
4111
4167
  }
4112
4168
 
4113
4169
  // ../shared/src/protocol.ts
4114
- var PROTOCOL_VERSION = { major: 7, minor: 0 };
4170
+ var PROTOCOL_VERSION = { major: 7, minor: 1 };
4115
4171
 
4116
4172
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
4117
4173
  var external_exports = {};
@@ -18722,6 +18778,15 @@ var patchProfileRequestSchema = external_exports.object({
18722
18778
  name: fsSafeName.optional(),
18723
18779
  branch_prefix: external_exports.string().max(64).optional()
18724
18780
  });
18781
+ var sessionSeedSchema = external_exports.looseObject({
18782
+ baseBranch: external_exports.string().optional(),
18783
+ separateBranch: external_exports.boolean().optional(),
18784
+ separateWorktree: external_exports.boolean().optional()
18785
+ });
18786
+ var sessionDefaultsSchema = external_exports.looseObject({
18787
+ agent: sessionSeedSchema.optional(),
18788
+ terminal: sessionSeedSchema.optional()
18789
+ });
18725
18790
  var profileSettingsSchema = external_exports.looseObject({
18726
18791
  allowSkipPermissions: external_exports.boolean().default(false),
18727
18792
  /**
@@ -18748,7 +18813,15 @@ var profileSettingsSchema = external_exports.looseObject({
18748
18813
  * absent from this list — newly created ones — sort to the top. The right
18749
18814
  * sidebar's cross-project grouping inherits this order (SPEC §11, §12).
18750
18815
  */
18751
- projectOrder: external_exports.array(external_exports.string()).optional()
18816
+ projectOrder: external_exports.array(external_exports.string()).optional(),
18817
+ /**
18818
+ * Seed defaults for the new-session modal, per kind (SPEC §11). An absent
18819
+ * key falls back to the built-ins — agents branch off the base in their own
18820
+ * directory; terminals share the base branch's directory. `baseBranch`
18821
+ * absent or empty means the repository's default base branch. The modal
18822
+ * still enforces that a separate branch always gets its own directory.
18823
+ */
18824
+ sessionDefaults: sessionDefaultsSchema.optional()
18752
18825
  });
18753
18826
  var patchProfileSettingsRequestSchema = external_exports.record(external_exports.string(), external_exports.unknown());
18754
18827
 
@@ -19273,6 +19346,11 @@ var sessionPortsResponseSchema = external_exports.object({
19273
19346
  scanned_at: isoTimestamp
19274
19347
  });
19275
19348
 
19349
+ // ../shared/src/api/cockpit.ts
19350
+ var cockpitRefreshResponseSchema = external_exports.object({
19351
+ status: external_exports.literal("refreshing")
19352
+ });
19353
+
19276
19354
  // ../shared/src/ws/messages.ts
19277
19355
  var termId = external_exports.string().regex(/^(agent|shell-[0-9]+)$/);
19278
19356
  var dims = {
@@ -19462,7 +19540,7 @@ import { readFileSync } from "node:fs";
19462
19540
  import { dirname, join as join2 } from "node:path";
19463
19541
  import { fileURLToPath } from "node:url";
19464
19542
  function cliVersion() {
19465
- if (true) return "0.0.5";
19543
+ if (true) return "0.0.6";
19466
19544
  const here = dirname(fileURLToPath(import.meta.url));
19467
19545
  for (const candidate of [
19468
19546
  join2(here, "..", "..", "package.json"),
@@ -19942,6 +20020,10 @@ async function startUiServer(opts) {
19942
20020
  res.end();
19943
20021
  return;
19944
20022
  }
20023
+ if ((url2.split("?")[0] ?? "") === "/cockpit/refresh") {
20024
+ handleRefresh(req, res, opts.control);
20025
+ return;
20026
+ }
19945
20027
  if (isProxiedPath(url2)) {
19946
20028
  if (!isLocalHostHeader(req.headers.host) || !isLocalOrigin(req.headers.origin)) {
19947
20029
  res.writeHead(403, { "content-type": "application/json" });
@@ -19987,6 +20069,25 @@ async function startUiServer(opts) {
19987
20069
  }
19988
20070
  };
19989
20071
  }
20072
+ function handleRefresh(req, res, control) {
20073
+ const fail = (status, code, message) => {
20074
+ res.writeHead(status, { "content-type": "application/json" });
20075
+ res.end(JSON.stringify({ error: { code, message } }));
20076
+ };
20077
+ if (!isLocalHostHeader(req.headers.host) || !isLocalOrigin(req.headers.origin)) {
20078
+ return fail(403, "forbidden_host", "requests must address localhost");
20079
+ }
20080
+ if (control === void 0) {
20081
+ return fail(404, "refresh_unavailable", "this cockpit has no refresh control");
20082
+ }
20083
+ if (req.method !== "POST") return fail(405, "method_not_allowed", "use POST");
20084
+ if (req.headers.authorization !== `Bearer ${control.token}`) {
20085
+ return fail(401, "unauthorised", "missing or invalid token");
20086
+ }
20087
+ res.writeHead(202, { "content-type": "application/json" });
20088
+ res.end(JSON.stringify({ status: "refreshing" }));
20089
+ setImmediate(control.onRefresh);
20090
+ }
19990
20091
  async function listen(server, startPort, strict, avoidPort) {
19991
20092
  for (let probe = 0; probe < MAX_PORT_PROBES; probe += 1) {
19992
20093
  const port = startPort + probe;
@@ -20406,10 +20507,12 @@ async function connectRemote(opts) {
20406
20507
  const avoidPort = await readDaemonPort(new LocalTransport());
20407
20508
  const ui = await startUiServer({
20408
20509
  assetsDir: opts.assetsDir,
20409
- port: opts.port,
20510
+ port: opts.port ?? opts.preferPort,
20410
20511
  strictPort: opts.port !== void 0,
20512
+ // a preferred port stays non-strict
20411
20513
  avoidPort,
20412
- target: { host: "127.0.0.1", port: tunnel.localPort }
20514
+ target: { host: "127.0.0.1", port: tunnel.localPort },
20515
+ ...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {}
20413
20516
  });
20414
20517
  tunnel.onPortChange((port) => ui.setTarget({ host: "127.0.0.1", port }));
20415
20518
  const eventCbs = /* @__PURE__ */ new Set();
@@ -20547,11 +20650,13 @@ async function startLocal(opts) {
20547
20650
  });
20548
20651
  const ui = await startUiServer({
20549
20652
  assetsDir: opts.assetsDir,
20550
- port: opts.port,
20653
+ port: opts.port ?? opts.preferPort,
20551
20654
  strictPort: opts.port !== void 0,
20655
+ // a preferred port stays non-strict
20552
20656
  avoidPort: endpoint.port,
20553
20657
  // never squat the daemon's own port
20554
- target: { host: "127.0.0.1", port: endpoint.port }
20658
+ target: { host: "127.0.0.1", port: endpoint.port },
20659
+ ...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {}
20555
20660
  });
20556
20661
  const eventCbs = /* @__PURE__ */ new Set();
20557
20662
  return {
@@ -20658,7 +20763,8 @@ async function launchDetached(opts) {
20658
20763
  const logFile = cockpitLogPath(target);
20659
20764
  mkdirSync4(dirname4(logFile), { recursive: true });
20660
20765
  const fd = openSync(logFile, "w");
20661
- const child = spawn5(process.execPath, [process.argv[1] ?? "", ...process.argv.slice(2)], {
20766
+ const argv = opts.argv ?? process.argv.slice(2);
20767
+ const child = spawn5(process.execPath, [process.argv[1] ?? "", ...argv], {
20662
20768
  detached: true,
20663
20769
  stdio: ["ignore", fd, fd],
20664
20770
  env: { ...process.env, [COCKPIT_CHILD_ENV]: "1" }
@@ -20718,6 +20824,20 @@ async function followStartup(target, childPid, logFile) {
20718
20824
  const last = readCockpitRecord(target);
20719
20825
  return last !== null && last.pid === childPid ? last : null;
20720
20826
  }
20827
+ function spawnDetachedRefresh(target, argv) {
20828
+ const logFile = cockpitLogPath(target);
20829
+ mkdirSync4(dirname4(logFile), { recursive: true });
20830
+ const fd = openSync(logFile, "a");
20831
+ const env = { ...process.env };
20832
+ delete env[COCKPIT_CHILD_ENV];
20833
+ const child = spawn5(process.execPath, [process.argv[1] ?? "", ...argv], {
20834
+ detached: true,
20835
+ stdio: ["ignore", fd, fd],
20836
+ env
20837
+ });
20838
+ closeSync(fd);
20839
+ child.unref();
20840
+ }
20721
20841
  async function terminateCockpit(record2) {
20722
20842
  try {
20723
20843
  process.kill(record2.pid, "SIGTERM");
@@ -20838,6 +20958,66 @@ async function run(command) {
20838
20958
  }
20839
20959
  return runCockpit(command, target, logger);
20840
20960
  }
20961
+ case "refresh": {
20962
+ let target = command.target;
20963
+ if (target === void 0) {
20964
+ const records = listCockpitRecords();
20965
+ if (records.length === 1) target = records[0].target;
20966
+ else if (records.length === 0) {
20967
+ throw new CliError(
20968
+ "no_cockpit",
20969
+ "no cockpits are running \u2014 name the target to refresh",
20970
+ "puddle refresh <local | user@host>"
20971
+ );
20972
+ } else {
20973
+ throw new CliError(
20974
+ "bad_arguments",
20975
+ "several cockpits are running \u2014 name the one to refresh",
20976
+ `puddle refresh <${records.map((r) => r.target).join(" | ")}>`
20977
+ );
20978
+ }
20979
+ }
20980
+ if (target === "local" && command.remotePort !== void 0) {
20981
+ throw new CliError("bad_arguments", "--remote-port only applies to a remote target");
20982
+ }
20983
+ const existing = readCockpitRecord(target);
20984
+ let oldPort;
20985
+ if (existing !== null) {
20986
+ if (existing.origin !== void 0) {
20987
+ const parsed = Number(new URL(existing.origin).port);
20988
+ if (Number.isInteger(parsed) && parsed > 0) oldPort = parsed;
20989
+ }
20990
+ if (await checkCockpit(existing) === "dead") {
20991
+ removeCockpitRecord(target);
20992
+ } else {
20993
+ await terminateCockpit(existing);
20994
+ logger.info(`stopped the old cockpit for ${target}`);
20995
+ }
20996
+ }
20997
+ const shared = {
20998
+ ...command.port !== void 0 ? { port: command.port } : {},
20999
+ ...command.port === void 0 && oldPort !== void 0 ? { preferPort: oldPort } : {},
21000
+ ...command.tarball !== void 0 ? { tarball: command.tarball } : {},
21001
+ noBrowser: command.noBrowser,
21002
+ noUpgrade: command.noUpgrade,
21003
+ foreground: command.foreground
21004
+ };
21005
+ const next = target === "local" ? { cmd: "start", ...shared } : {
21006
+ cmd: "connect",
21007
+ host: target,
21008
+ ...shared,
21009
+ ...command.remotePort !== void 0 ? { remotePort: command.remotePort } : {}
21010
+ };
21011
+ if (!command.foreground && !isCockpitChild()) {
21012
+ return launchDetached({
21013
+ target,
21014
+ noBrowser: command.noBrowser,
21015
+ logger,
21016
+ argv: argvFor(next)
21017
+ });
21018
+ }
21019
+ return runCockpit(next, target, logger);
21020
+ }
20841
21021
  case "list": {
20842
21022
  const rows = [];
20843
21023
  for (const record2 of listCockpitRecords()) {
@@ -21024,9 +21204,22 @@ async function runCockpit(command, target, terminal) {
21024
21204
  ...detached ? { logFile: cockpitLogPath(target) } : {}
21025
21205
  };
21026
21206
  writeCockpitRecord(base);
21207
+ const onRefreshRequest = () => {
21208
+ logger.info("refresh requested from the UI \u2014 replacing this cockpit");
21209
+ spawnDetachedRefresh(target, [
21210
+ "refresh",
21211
+ target,
21212
+ "--no-browser",
21213
+ // the requesting tab reloads itself; no second tab
21214
+ ...command.port !== void 0 ? ["--port", String(command.port)] : [],
21215
+ ...command.cmd === "connect" && command.remotePort !== void 0 ? ["--remote-port", String(command.remotePort)] : [],
21216
+ ...command.tarball !== void 0 ? ["--tarball", command.tarball] : [],
21217
+ ...command.noUpgrade ? ["--no-upgrade"] : []
21218
+ ]);
21219
+ };
21027
21220
  let cockpit;
21028
21221
  try {
21029
- cockpit = command.cmd === "start" ? await startLocal({ ...command, assetsDir: assetsDir(), logger }) : await connectRemote({ ...command, assetsDir: assetsDir(), logger });
21222
+ cockpit = command.cmd === "start" ? await startLocal({ ...command, assetsDir: assetsDir(), logger, onRefreshRequest }) : await connectRemote({ ...command, assetsDir: assetsDir(), logger, onRefreshRequest });
21030
21223
  } catch (err) {
21031
21224
  if (err instanceof CliError) {
21032
21225
  writeCockpitRecord({
@@ -0,0 +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 +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--EObrd7i.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-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 +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--EObrd7i.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-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 +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-Cw21CVB0.js";import{g as f,r as p,t as m}from"./api-BJKPJeFZ.js";import{t as h}from"./createLucideIcon-DyMAgLa3.js";import{a as g,o as _,s as v}from"./index-D994oCvG.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--EObrd7i.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),p=(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||p.current)return;p.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):f(`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=>f.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 m&&t.status===409&&t.code===`stale_file`?f.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>w()},cancel:{label:`Overwrite`,onClick:()=>O(e,n)}}):f.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 m&&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=>f.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 m&&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 m&&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=>f.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),p(`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-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};
@@ -0,0 +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};