@nandoblanco/opencode-local-backup 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 1.1.1 (2026-11-17)
4
+
5
+ - Removed the trailing keyboard shortcut badge (`Ctrl+Shift+B`) from the left sidebar `vertical-tabs-backups` button and added `whitespace-nowrap` so sidebar button labels do not wrap (`gui.tsx`).
6
+ - Expanded the cross-plugin Playwright suite (`test/panel-fallback.tsx`, `test/panel-fallback.mjs`) to verify sidebar labels and icons (`Search`, `DLab Balance`, `Token Audit`), `DLab Balance` timeframe and date-range model breakdowns, `Token Audit` sorting, manual tagging, and `Per Tag` view, and `Search` centered loading spinner.
7
+
8
+ ## 1.1.0 (2026-11-12)
9
+
10
+ - Added OpenCode Desktop Backup Manager (`gui.tsx`, `gui.css`, `dist/gui-experimental.cjs`, and `BackupRpc` in `rpc.js`) with a persistent side panel (`Ctrl+Shift+B` to open/focus, `Ctrl+Alt+B` to toggle), fallback dialog when no session is active, scope/tool/date/retention filters, unified diff preview, and validated snapshot restore with pre-restore safety backups.
11
+ - Added Desktop GUI smoke and fallback dialog tests (`test/gui-smoke.mjs`, `test/panel-fallback.mjs`).
12
+
13
+ ## 1.0.3 (2026-10-28)
14
+
15
+ - Refined the `/backups` OpenTUI modal layout (`tui.ts`) with bordered filter and diff cards and removed duplicate slash command aliases.
16
+
17
+ ## 1.0.2 (2026-10-27)
18
+
19
+ - Fixed `backup_list` and `backup_restore` tool registration on the OpenCode V2 server plugin API (`index.js`).
20
+
21
+ ## 1.0.1 (2026-10-26)
22
+
23
+ - Scoped npm package as `@nandoblanco/opencode-local-backup` with public `publishConfig` and normalized `bin` and `repository` fields.
24
+ - Hardened relative path traversal checks on restore, external diff binary spawning (`openExternalDiff`), and comment-preserving JSONC config installation (`installPlugin`).
25
+
26
+ ## 1.0.0 (2026-10-26)
27
+
28
+ - Initial release of `opencode-local-backup` for OpenCode.
29
+ - Added engine-level `execute.before` hook intercepting `edit`, `write`, `patch`, `apply_patch`, and `multiedit` tool calls to snapshot files into `<project-root>/.backups/<timestamp>_<slug>/` with `.backup-meta.json`.
30
+ - Added upward project-root resolution (`findProjectRoot`), configurable retention auto-pruning (`pruneBackups`), pre-restore safety snapshots (`restoreSnapshot`), `backup_list` and `backup_restore` agent tools, CLI commands (`install`, `list`, `restore`, `prune`, `root`), and the zero-token `/backups` TUI diff and restore modal (`tui.ts`).
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("solid-js/web"),t=require("@opencode/plugin/gui"),n=require("solid-js");var r=`.oc-lb-root{--oc-lb-bg-base:var(--v2-background-bg-base,#141417);--oc-lb-bg-elevated:var(--v2-background-bg-elevated,#1b1b20);--oc-lb-bg-sunken:var(--v2-background-bg-sunken,#101013);--oc-lb-border-muted:var(--v2-border-border-muted,#ffffff14);--oc-lb-border-base:var(--v2-border-border-base,#ffffff24);--oc-lb-border-focus:var(--v2-border-border-focus,#3b82f6);--oc-lb-text-strong:var(--v2-text-text-strong,#f4f4f6);--oc-lb-text-base:var(--v2-text-text-base,#d4d4d8);--oc-lb-text-muted:var(--v2-text-text-muted,#9ca3af);--oc-lb-text-faint:var(--v2-text-text-faint,#6b7280);--oc-lb-hover:var(--v2-overlay-simple-overlay-hover,#ffffff0d);--oc-lb-selected:var(--v2-overlay-simple-overlay-selected,#3b82f624);--oc-lb-accent:#3b82f6;--oc-lb-green:#22c55e;--oc-lb-green-bg:#22c55e1f;--oc-lb-red:#ef4444;--oc-lb-red-bg:#ef44441f;--oc-lb-amber:#f59e0b;--oc-lb-amber-bg:#f59e0b24;--oc-lb-purple:#a855f7;--oc-lb-purple-bg:#a855f724;box-sizing:border-box;width:100%;color:var(--oc-lb-text-base);font-family:var(--v2-font-family-sans,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);outline:none;flex-direction:column;font-size:.8125rem;display:flex;position:relative}.oc-lb-root[data-scheme=light]{--oc-lb-bg-base:var(--v2-background-bg-base,#fff);--oc-lb-bg-elevated:var(--v2-background-bg-elevated,#f8fafc);--oc-lb-bg-sunken:var(--v2-background-bg-sunken,#f1f5f9);--oc-lb-border-muted:var(--v2-border-border-muted,#0f172a14);--oc-lb-border-base:var(--v2-border-border-base,#0f172a26);--oc-lb-text-strong:var(--v2-text-text-strong,#0f172a);--oc-lb-text-base:var(--v2-text-text-base,#1e293b);--oc-lb-text-muted:var(--v2-text-text-muted,#475569);--oc-lb-text-faint:var(--v2-text-text-faint,#64748b);--oc-lb-hover:var(--v2-overlay-simple-overlay-hover,#0f172a0a);--oc-lb-selected:var(--v2-overlay-simple-overlay-selected,#2563eb1a)}.oc-lb-root-modal{height:min(74vh,660px);max-height:100%;overflow:hidden}.oc-lb-root-panel{height:100%;min-height:440px;overflow:hidden}.oc-lb-toolbar{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-direction:column;flex-shrink:0;gap:.45rem;padding:.65rem .85rem;display:flex}.oc-lb-search-row{flex-wrap:wrap;align-items:center;gap:.45rem;display:flex}.oc-lb-search-box{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-bg-sunken);border-radius:.375rem;flex:14rem;align-items:center;min-width:11rem;height:1.875rem;padding:0 .55rem;transition:border-color .12s;display:flex}.oc-lb-search-box:focus-within{border-color:var(--oc-lb-border-focus)}.oc-lb-search-icon{color:var(--oc-lb-text-faint);-webkit-user-select:none;user-select:none;margin-right:.4rem;font-size:.875rem}.oc-lb-search-input{min-width:0;color:var(--oc-lb-text-strong);background:0 0;border:none;outline:none;flex:1;font-size:.8125rem}.oc-lb-search-input::placeholder{color:var(--oc-lb-text-faint)}.oc-lb-search-clear{color:var(--oc-lb-text-muted);cursor:pointer;background:0 0;border:none;border-radius:.25rem;padding:0 .25rem;font-size:.95rem;line-height:1}.oc-lb-search-clear:hover{color:var(--oc-lb-text-strong);background:var(--oc-lb-hover)}.oc-lb-search-clear:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-scope-seg{border:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-sunken);border-radius:.375rem;align-items:center;padding:.125rem;display:inline-flex}.oc-lb-scope-btn{color:var(--oc-lb-text-muted);cursor:pointer;background:0 0;border:none;border-radius:.25rem;padding:.2rem .5rem;font-size:.75rem;transition:background-color .12s,color .12s}.oc-lb-scope-btn:hover{color:var(--oc-lb-text-strong)}.oc-lb-scope-btn:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-scope-btn.is-active{background:var(--oc-lb-bg-elevated);color:var(--oc-lb-text-strong);font-weight:600}.oc-lb-active-chips{flex-wrap:wrap;align-items:center;gap:.4rem;min-height:1.25rem;display:flex}.oc-lb-filter-chip{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-selected);color:var(--oc-lb-text-strong);cursor:pointer;border-radius:999px;align-items:center;gap:.3rem;padding:.12rem .45rem;font-size:.72rem;display:inline-flex}.oc-lb-filter-chip:hover{background:var(--oc-lb-hover)}.oc-lb-filter-chip:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-filter-chip-x{opacity:.75;font-weight:700}.oc-lb-count-summary{color:var(--oc-lb-text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:100%;margin-left:auto;font-size:.72rem;overflow:hidden}.oc-lb-status{border-bottom:1px solid var(--oc-lb-border-muted);flex-shrink:0;padding:.4rem .85rem;font-size:.76rem}.oc-lb-status-ok{background:var(--oc-lb-green-bg);color:var(--oc-lb-green)}.oc-lb-status-warn{background:var(--oc-lb-amber-bg);color:var(--oc-lb-amber)}.oc-lb-status-err{background:var(--oc-lb-red-bg);color:var(--oc-lb-red)}.oc-lb-split{flex:1;grid-template-columns:minmax(15rem,42%) minmax(0,58%);min-height:0;display:grid;overflow:hidden}.oc-lb-root-panel .oc-lb-split{grid-template-rows:minmax(11rem,44%) minmax(0,56%);grid-template-columns:1fr}.oc-lb-list-pane{border-right:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-base);flex-direction:column;min-height:0;display:flex}.oc-lb-root-panel .oc-lb-list-pane{border-right:none;border-bottom:1px solid var(--oc-lb-border-muted)}.oc-lb-preview-pane{background:var(--oc-lb-bg-base);flex-direction:column;min-height:0;display:flex}.oc-lb-pane-header{letter-spacing:.04em;text-transform:uppercase;color:var(--oc-lb-text-faint);border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-shrink:0;justify-content:space-between;align-items:center;padding:.4rem .75rem;font-size:.6875rem;font-weight:600;display:flex}.oc-lb-list-scroll{flex:1;min-height:0;overflow-y:auto}.oc-lb-row{border-bottom:1px solid var(--oc-lb-border-muted);cursor:pointer;flex-direction:column;gap:.2rem;padding:.5rem .75rem;transition:background-color .1s;display:flex}.oc-lb-row:hover{background:var(--oc-lb-hover)}.oc-lb-row.is-selected{background:var(--oc-lb-selected);border-left:2px solid var(--oc-lb-accent);padding-left:calc(.75rem - 2px)}.oc-lb-row-top{align-items:center;gap:.4rem;min-width:0;display:flex}.oc-lb-row-title{min-width:0;color:var(--oc-lb-text-strong);white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.oc-lb-badge{text-transform:lowercase;background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-muted);border-radius:.25rem;flex-shrink:0;padding:.08rem .38rem;font-size:.65rem;font-weight:600}.oc-lb-badge-edit{color:#60a5fa;background:#3b82f626}.oc-lb-badge-write{background:var(--oc-lb-green-bg);color:var(--oc-lb-green)}.oc-lb-badge-patch,.oc-lb-badge-apply_patch,.oc-lb-badge-multiedit{background:var(--oc-lb-purple-bg);color:var(--oc-lb-purple)}.oc-lb-badge-pre-restore{background:var(--oc-lb-amber-bg);color:var(--oc-lb-amber)}.oc-lb-row-age{color:var(--oc-lb-text-faint);flex-shrink:0;font-size:.7rem}.oc-lb-row-sub{color:var(--oc-lb-text-muted);white-space:nowrap;text-overflow:ellipsis;font-size:.7rem;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);overflow:hidden}.oc-lb-meta-card{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-shrink:0;padding:.65rem .85rem}.oc-lb-meta-title-row{flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:.65rem;margin-bottom:.45rem;display:flex}.oc-lb-meta-filename{color:var(--oc-lb-text-strong);word-break:break-all;font-size:.875rem;font-weight:600}.oc-lb-meta-sub{color:var(--oc-lb-text-muted);margin-top:.15rem;font-size:.72rem}.oc-lb-action-bar{flex-wrap:wrap;align-items:center;gap:.35rem;display:flex}.oc-lb-meta-grid{font-size:.72rem;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);grid-template-columns:4.25rem minmax(0,1fr);gap:.2rem .5rem;display:grid}.oc-lb-meta-label{color:var(--oc-lb-text-faint)}.oc-lb-meta-val{color:var(--oc-lb-text-base);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.oc-lb-diff-summary{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-muted);flex-shrink:0;padding:.35rem .85rem;font-size:.72rem;font-weight:500}.oc-lb-diff-status-modified{color:var(--oc-lb-amber)}.oc-lb-diff-status-identical{color:var(--oc-lb-green)}.oc-lb-diff-status-deleted,.oc-lb-diff-status-error{color:var(--oc-lb-red)}.oc-lb-diff-scroll{min-height:0;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);background:var(--oc-lb-bg-sunken);flex:1;padding:.4rem 0;font-size:.75rem;line-height:1.45;overflow:auto}.oc-lb-diff-line{white-space:pre;padding:.05rem .85rem}.oc-lb-diff-add{color:#4ade80;background:#22c55e24}.oc-lb-root[data-scheme=light] .oc-lb-diff-add{color:#15803d;background:#22c55e29}.oc-lb-diff-del{color:#f87171;background:#ef444424}.oc-lb-root[data-scheme=light] .oc-lb-diff-del{color:#b91c1c;background:#ef444429}.oc-lb-diff-hunk{color:#60a5fa;background:#3b82f61f;margin-top:.2rem;font-weight:600}.oc-lb-diff-context{color:var(--oc-lb-text-muted)}.oc-lb-mark{color:inherit;background:#f59e0b59;border-radius:.15rem;padding:0 .1rem}.oc-lb-empty{text-align:center;color:var(--oc-lb-text-muted);padding:2rem 1.25rem;font-size:.8rem;line-height:1.5}.oc-lb-modal-backdrop{z-index:20;background:#0000008c;justify-content:center;align-items:center;padding:1rem;display:flex;position:absolute;inset:0}.oc-lb-modal-card{background:var(--oc-lb-bg-elevated);border:1px solid var(--oc-lb-border-base);border-radius:.5rem;width:min(32rem,100%);padding:1rem 1.15rem;box-shadow:0 12px 32px #00000073}.oc-lb-modal-title{color:var(--oc-lb-text-strong);margin:0 0 .45rem;font-size:.95rem;font-weight:600}.oc-lb-modal-desc{color:var(--oc-lb-text-base);margin:0 0 .65rem;font-size:.8rem;line-height:1.45}.oc-lb-modal-paths{background:var(--oc-lb-bg-sunken);border:1px solid var(--oc-lb-border-muted);font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);color:var(--oc-lb-text-muted);word-break:break-all;border-radius:.375rem;flex-direction:column;gap:.25rem;margin-bottom:.85rem;padding:.5rem .65rem;font-size:.72rem;display:flex}.oc-lb-modal-actions{justify-content:flex-end;align-items:center;gap:.45rem;display:flex}.oc-lb-dialog-footer{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.75rem;width:100%;display:flex}.oc-lb-footer-shortcuts{color:var(--oc-lb-text-muted);flex-wrap:wrap;align-items:center;gap:.65rem;font-size:.72rem;display:flex}.oc-lb-footer-shortcuts kbd{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-strong);font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);border-radius:.25rem;padding:.1rem .32rem;font-size:.68rem}.oc-lb-titlebar-quick-btn{appearance:none;color:var(--v2-icon-icon-muted,var(--v2-text-text-muted));cursor:pointer;-webkit-app-region:no-drag;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;width:36px;height:28px;transition:background-color .12s,color .12s;display:inline-flex}.oc-lb-titlebar-quick-btn:hover{background:var(--v2-overlay-simple-overlay-hover);color:var(--v2-icon-icon-base,var(--v2-text-text-base))}.oc-lb-titlebar-quick-btn:focus-visible{outline:2px solid var(--v2-border-border-focus);outline-offset:-2px}@media (width<=768px){.oc-lb-split{grid-template-rows:minmax(11rem,44%) minmax(0,56%);grid-template-columns:1fr}.oc-lb-list-pane{border-right:none;border-bottom:1px solid var(--oc-lb-border-muted)}}`,i={id:`opencode-local-backup`,methods:{list:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{rootDir:{type:`string`},includeSubprojects:{type:`boolean`},limit:{type:`number`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{scanRoot:{type:`string`},workspaceDir:{type:`string`},settings:{type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},required:[`retentionDays`,`debounceMs`,`rootDir`,`dialogWidth`]},entries:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},snapshotId:{type:`string`},root:{type:`string`},slug:{type:`string`},tool:{type:`string`},timeMs:{type:`number`},relativePath:{type:`string`},fileName:{type:`string`},backupPath:{type:`string`},originalPath:{type:`string`},size:{type:`number`}},required:[`id`,`snapshotId`,`root`,`slug`,`tool`,`timeMs`,`relativePath`,`fileName`,`backupPath`,`originalPath`,`size`]}}},required:[`scanRoot`,`workspaceDir`,`settings`,`entries`]}},diff:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},originalPath:{type:`string`},maxLines:{type:`number`}},required:[`backupPath`,`originalPath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{status:{type:`string`},summary:{type:`string`},lines:{type:`array`,items:{type:`object`,properties:{type:{type:`string`},text:{type:`string`}},required:[`type`,`text`]}}},required:[`status`,`summary`,`lines`]}},restore:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{entry:{type:`object`,properties:{id:{type:`string`},snapshotId:{type:`string`},root:{type:`string`},slug:{type:`string`},tool:{type:`string`},timeMs:{type:`number`},relativePath:{type:`string`},fileName:{type:`string`},backupPath:{type:`string`},originalPath:{type:`string`},size:{type:`number`}},required:[`root`,`backupPath`,`originalPath`]}},required:[`entry`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{restoredPath:{type:`string`},fromSnapshot:{type:`string`},safetySnapshot:{type:[`string`,`null`]}},required:[`restoredPath`,`fromSnapshot`]}},openFile:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{filePath:{type:`string`}},required:[`filePath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{openedPath:{type:`string`},launcher:{type:`string`}},required:[`openedPath`,`launcher`]}},openDiff:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},originalPath:{type:`string`}},required:[`backupPath`,`originalPath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},currentPath:{type:`string`},launcher:{type:`string`}},required:[`backupPath`,`currentPath`,`launcher`]}},prune:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{rootDir:{type:`string`},retentionDays:{type:`number`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{removed:{type:`number`},disabled:{type:`boolean`},retentionDays:{type:`number`}},required:[`removed`,`disabled`,`retentionDays`]}},updateSettings:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{filePath:{type:`string`},settings:{type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},required:[`retentionDays`,`debounceMs`,`rootDir`,`dialogWidth`]}},required:[`filePath`,`settings`]}}},events:{}},a=(0,e.template)(`<mark class=oc-lb-mark>`),o=(0,e.template)(`<button type=button class=oc-lb-search-clear title="Clear search">×`),s=(0,e.template)(`<div class=oc-lb-scope-seg role=group aria-label="Scan scope"><button type=button>All Root</button><button type=button>Workspace`),c=(0,e.template)(`<button type=button class=oc-lb-filter-chip title="Click to clear tool filter"><span>tool: </span><span class=oc-lb-filter-chip-x>×`),l=(0,e.template)(`<button type=button class=oc-lb-filter-chip title="Click to clear age filter"><span>age: </span><span class=oc-lb-filter-chip-x>×`),u=(0,e.template)(`<div tabindex=-1><div class=oc-lb-toolbar><div class=oc-lb-search-row><div class=oc-lb-search-box><span class=oc-lb-search-icon aria-hidden=true>⌕</span><input type=text class=oc-lb-search-input placeholder="Filter backups by file path, project, snapshot ID, or slug..."></div></div><div class=oc-lb-active-chips><span class=oc-lb-count-summary>/<!> snapshots • Root: </span></div></div><div class=oc-lb-split><div class=oc-lb-list-pane><div class=oc-lb-pane-header><span>SNAPSHOTS (<!>)</span><span>↑↓ Navigate</span></div><div class=oc-lb-list-scroll></div></div><div class=oc-lb-preview-pane><div class=oc-lb-pane-header><span>SNAPSHOT DETAILS & UNIFIED DIFF`),d=(0,e.template)(`<div>`),f=(0,e.template)(`<div class=oc-lb-empty>Scanning .backups folders...`),p=(0,e.template)(`<div class=oc-lb-empty>`),m=(0,e.template)(`<div><div class=oc-lb-row-top><span class=oc-lb-row-title></span><span></span><span class=oc-lb-row-age></span></div><div class=oc-lb-row-sub>↳ `),h=(0,e.template)(`<span>`),ee=(0,e.template)(`<div class=oc-lb-empty>Select a backup snapshot on the left to inspect its metadata and diff against the current file on disk.`),te=(0,e.template)(`<div class=oc-lb-meta-card><div class=oc-lb-meta-title-row><div><div class=oc-lb-meta-filename></div><div class=oc-lb-meta-sub> (<!>) • <!> • [<!>] • </div></div><div class=oc-lb-action-bar></div></div><div class=oc-lb-meta-grid><span class=oc-lb-meta-label>Original:</span><span class=oc-lb-meta-val></span><span class=oc-lb-meta-label>Backup:</span><span class=oc-lb-meta-val>`),ne=(0,e.template)(`<div class=oc-lb-diff-summary>`),re=(0,e.template)(`<div class=oc-lb-diff-scroll>`),ie=(0,e.template)(`<span>Computing unified diff...`),ae=(0,e.template)(`<div class=oc-lb-modal-backdrop><div class=oc-lb-modal-card><h3 class=oc-lb-modal-title>Restore Backup Snapshot?</h3><p class=oc-lb-modal-desc>Restoring <strong></strong> from snapshot <code></code> will overwrite the current file on disk. A <code>pre-restore</code> safety backup of the current file will be saved automatically first.</p><div class=oc-lb-modal-paths><div><strong>From Backup:</strong> </div><div><strong>To Original:</strong> </div></div><div class=oc-lb-modal-actions>`),g=[`all`,`edit`,`write`,`patch`,`pre-restore`],_=[`all`,`24h`,`7d`,`30d`],v=[30,14,7,5,0];function oe(e){if(!e)return`unknown`;let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toISOString().slice(0,10)}function se(e){if(!e)return`unknown`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function ce(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function le(e){let t=String(e||``).replace(/\\/g,`/`),n=t.indexOf(`/.backups/`);if(n<=0)return t;let r=t.slice(0,n),i=r.lastIndexOf(`/`),a=i>0?r.slice(0,i):``;return a&&t.startsWith(a+`/`)?t.slice(a.length+1):t}function y(e,t){let n=String(e||``);if(!n)return[{text:``,match:!1}];let r=t.map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(r.length===0)return[{text:n,match:!1}];let i=n.toLowerCase(),a=[];for(let e of r){let t=0;for(;t<i.length;){let n=i.indexOf(e,t);if(n===-1)break;a.push([n,n+e.length]),t=n+Math.max(1,e.length)}}if(a.length===0)return[{text:n,match:!1}];a.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let o=[a[0]];for(let e=1;e<a.length;e++){let t=o[o.length-1],n=a[e];n[0]<=t[1]?t[1]=Math.max(t[1],n[1]):o.push([n[0],n[1]])}let s=[],c=0;for(let[e,t]of o)e>c&&s.push({text:n.slice(c,e),match:!1}),s.push({text:n.slice(e,t),match:!0}),c=t;return c<n.length&&s.push({text:n.slice(c),match:!1}),s}function b(t){let r=(0,n.createMemo)(()=>y(t.text,t.terms));return(0,e.createComponent)(n.For,{get each(){return r()},children:t=>(0,e.createComponent)(n.Show,{get when(){return t.match},get fallback(){return(0,e.memo)(()=>t.text)},get children(){var n=a();return(0,e.insert)(n,()=>t.text),n}})})}function x(e){let t=e.sessions.current();if(t?.server?.client?.rpc)return t.server.client.rpc(i);let n=e.servers;if(n){let e=typeof n.list==`function`?n.list():[];for(let t of e){if(t?.client?.rpc)return t.client.rpc(i);if(t?.id&&typeof n.get==`function`){let e=n.get(t.id);if(e?.client?.rpc)return e.client.rpc(i)}}if(typeof n.get==`function`){let e=n.get(`local`)||n.get(`default`);if(e?.client?.rpc)return e.client.rpc(i)}}let r=e.client;return r?.rpc?r.rpc(i):null}function S(t){let{ui:r}=t.ctx,[i,a]=(0,n.createSignal)([]),[y,S]=(0,n.createSignal)(``),[w,T]=(0,n.createSignal)(``),[E,D]=(0,n.createSignal)(`scan-root`),[O,k]=(0,n.createSignal)({retentionDays:30,debounceMs:0,rootDir:``,dialogWidth:`80%`}),[A,j]=(0,n.createSignal)(t.initialQuery||``);(0,n.createEffect)(()=>{let e=C();e&&j(e)});let[M,N]=(0,n.createSignal)(`all`),[P,F]=(0,n.createSignal)(`all`),[I,L]=(0,n.createSignal)(0),[ue,R]=(0,n.createSignal)(!0),[de,z]=(0,n.createSignal)(!1),[fe,B]=(0,n.createSignal)(null),[pe,V]=(0,n.createSignal)(!1),[me,H]=(0,n.createSignal)(null),U,he=new Map,ge=(0,n.createMemo)(()=>{let e=t.ctx.appearance.mode();return e===`light`||e===`dark`?e:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`});function W(e,t=`ok`){H({text:e,kind:t}),typeof window<`u`&&window.setTimeout(()=>{H(t=>t?.text===e?null:t)},4500)}async function G(e){let n=x(t.ctx);if(!n)R(!1),W(`No active OpenCode server session found for Backup RPC.`,`err`);else{R(!0);try{let t=E()===`workspace`&&w(),r=await n.list({rootDir:t?w():void 0,includeSubprojects:!0,limit:500});S(r.scanRoot||``),T(r.workspaceDir||``),r.settings&&k(r.settings);let i=Array.isArray(r.entries)?r.entries:[];if(a(i),e){let t=q().findIndex(t=>t.id===e);L(t>=0?t:0)}else L(e=>Math.min(e,Math.max(0,q().length-1)))}catch(e){W(`Failed to load backups: ${e?.message||String(e)}`,`err`)}finally{R(!1)}}}let K=(0,n.createMemo)(()=>{let e=A().trim().toLowerCase();return e?e.split(/\s+/).filter(Boolean):[]}),q=(0,n.createMemo)(()=>{let e=K(),t=M(),n=P(),r=Date.now(),a=n===`24h`?864e5:n===`7d`?6048e5:n===`30d`?2592e6:0;return i().filter(n=>{if(t!==`all`&&n.tool!==t||a>0&&r-n.timeMs>a)return!1;if(e.length>0){let t=`${n.relativePath} ${n.backupPath} ${n.originalPath} ${n.root} ${n.snapshotId} ${n.slug}`.toLowerCase();if(!e.every(e=>t.includes(e)))return!1}return!0})});(0,n.createEffect)(()=>{let e=q();I()>=e.length&&L(Math.max(0,e.length-1))});let J=(0,n.createMemo)(()=>q()[I()]||null);(0,n.createEffect)(()=>{let e=J(),r=x(t.ctx);if(!e||!r){B(null);return}let i=!1;z(!0),r.diff({backupPath:e.backupPath,originalPath:e.originalPath,maxLines:220}).then(e=>{i||(B(e),z(!1))}).catch(e=>{i||(B({status:`error`,summary:`Diff error: ${e?.message||String(e)}`,lines:[]}),z(!1))}),(0,n.onCleanup)(()=>{i=!0})});function _e(e){let t=he.get(e);t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`nearest`})}function Y(e){let t=q().length;if(t===0)return;let n=Math.max(0,Math.min(t-1,I()+e));L(n),_e(n)}function X(){let e=g[(g.indexOf(M())+1)%g.length];N(e),L(0)}function Z(){let e=_[(_.indexOf(P())+1)%_.length];F(e),L(0)}async function ve(e){let n=x(t.ctx);if(n)try{let t=await n.updateSettings({retentionDays:e});t?.settings&&k(t.settings),W(`Updated backup retention to ${e===0?`never auto-prune (0d)`:`${e} days`}`,`ok`)}catch(e){W(`Failed to update retention: ${e?.message||String(e)}`,`err`)}}function ye(){let e=O().retentionDays,t=v.indexOf(e);ve(t>=0?v[(t+1)%v.length]:v[0])}async function be(){let e=x(t.ctx);if(!e)return;let n=O().retentionDays;if(n<=0)W(`Retention is set to never (0d); nothing pruned.`,`warn`);else try{let t=E()===`workspace`&&w(),r=await e.prune({rootDir:t?w():y()||void 0,retentionDays:n});await G(J()?.id),W(`Pruned ${r.removed} snapshot folder(s) older than ${r.retentionDays}d`,`ok`)}catch(e){W(`Prune failed: ${e?.message||String(e)}`,`err`)}}async function xe(){let e=J(),n=x(t.ctx);if(e&&n){V(!1);try{let t=await n.restore({entry:e}),r=t.safetySnapshot?` (safety backup: ${t.safetySnapshot})`:``;await G(e.id),W(`Restored ${e.relativePath}${r}`,`ok`)}catch(e){W(`Restore failed: ${e?.message||String(e)}`,`err`)}}}async function Se(e,n){let r=x(t.ctx);if(r&&e)try{W(`Opened ${n} via ${(await r.openFile({filePath:e})).launcher}`,`ok`)}catch(e){W(`Open failed: ${e?.message||String(e)}`,`err`)}}async function Q(){let e=J(),n=x(t.ctx);if(e&&n)try{let t=await n.openDiff({backupPath:e.backupPath,originalPath:e.originalPath});W(`Opened diff for ${e.relativePath} via ${t.launcher}`,`ok`)}catch(e){W(`Open diff failed: ${e?.message||String(e)}`,`err`)}}let $=(0,n.createMemo)(()=>{let e=0;return M()!==`all`&&e++,P()!==`all`&&e++,e}),Ce=(0,n.createMemo)(()=>[{type:`group`,label:`Tool Filter (^T)`,items:g.map(e=>({label:e===`all`?`All tools`:`[${e}]`,...M()===e?{icon:`check-small`}:{},onSelect:()=>{N(e),L(0)}}))},{type:`separator`},{type:`group`,label:`Age Filter (^G)`,items:_.map(e=>({label:e===`all`?`All dates`:`Last ${e}`,...P()===e?{icon:`check-small`}:{},onSelect:()=>{F(e),L(0)}}))},{type:`separator`},{type:`group`,label:`Auto-Prune Retention (^R)`,items:v.map(e=>({label:e===0?`Never auto-prune (0d)`:`${e} days`,...O().retentionDays===e?{icon:`check-small`}:{},onSelect:()=>{ve(e)}}))},{type:`separator`},{label:`Reset tool & date filters`,icon:`reset`,disabled:$()===0,onSelect:()=>{N(`all`),F(`all`),L(0)}}]);function we(e){if(pe())e.key===`Escape`?(e.preventDefault(),V(!1)):e.key===`Enter`&&(e.preventDefault(),xe());else{if(e.ctrlKey||e.metaKey){let t=e.key.toLowerCase();if(t===`t`){e.preventDefault(),X();return}if(t===`g`){e.preventDefault(),Z();return}if(t===`r`){e.preventDefault(),ye();return}if(t===`d`){e.preventDefault(),be();return}if(t===`o`){e.preventDefault();let t=J();t&&Se(t.backupPath,t.relativePath);return}if(t===`e`){e.preventDefault(),Q();return}}e.key===`ArrowDown`?(e.preventDefault(),Y(1)):e.key===`ArrowUp`?(e.preventDefault(),Y(-1)):e.key===`PageDown`?(e.preventDefault(),Y(8)):e.key===`PageUp`?(e.preventDefault(),Y(-8)):e.key===`Enter`&&J()&&(e.preventDefault(),V(!0))}}(0,n.onMount)(()=>{G(),typeof window<`u`&&window.setTimeout(()=>U?.focus(),40)});let Te=(0,n.createMemo)(()=>{let e=y().replace(/\\/g,`/`).toLowerCase(),t=w().replace(/\\/g,`/`).toLowerCase();return!!(e&&t&&e!==t)});return(()=>{var a=u(),g=a.firstChild,_=g.firstChild,v=_.firstChild,x=v.firstChild.nextSibling,S=_.nextSibling,C=S.firstChild,T=C.firstChild,k=T.nextSibling;k.nextSibling;var R=g.nextSibling,z=R.firstChild,B=z.firstChild,H=B.firstChild,W=H.firstChild.nextSibling;W.nextSibling;var _e=B.nextSibling,Y=z.nextSibling,X=Y.firstChild;X.firstChild,a.$$keydown=we,x.$$input=e=>{j(e.currentTarget.value),L(0)};var Z=U;return typeof Z==`function`?(0,e.use)(Z,x):U=x,(0,e.insert)(v,(0,e.createComponent)(n.Show,{get when(){return A().length>0},get children(){var e=o();return e.$$click=()=>{j(``),L(0),U?.focus()},e}}),null),(0,e.insert)(_,(0,e.createComponent)(n.Show,{get when(){return Te()},get children(){var t=s(),n=t.firstChild,r=n.nextSibling;return n.$$click=()=>{D(`scan-root`),G()},r.$$click=()=>{D(`workspace`),G()},(0,e.effect)(t=>{var i=`oc-lb-scope-btn ${E()===`scan-root`?`is-active`:``}`,a=`Scan configured root: ${y()}`,o=`oc-lb-scope-btn ${E()===`workspace`?`is-active`:``}`,s=`Scan current workspace only: ${w()}`;return i!==t.e&&(0,e.className)(n,t.e=i),a!==t.t&&(0,e.setAttribute)(n,`title`,t.t=a),o!==t.a&&(0,e.className)(r,t.a=o),s!==t.o&&(0,e.setAttribute)(r,`title`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),t}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Menu,{get label(){return(0,e.memo)(()=>$()>0)()?`Filters (${$()})`:`Filters`},trigger:`button`,icon:`sliders`,placement:`bottom-end`,get items(){return Ce()}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>ye(),get children(){return[`Retain: `,(0,e.memo)(()=>(0,e.memo)(()=>O().retentionDays===0)()?`never`:`${O().retentionDays}d`)]}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>void be(),children:`Prune`}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>void G(J()?.id),children:`Refresh`}),null),(0,e.insert)(S,(0,e.createComponent)(n.Show,{get when(){return M()!==`all`},get children(){var t=c(),n=t.firstChild;return n.firstChild,t.$$click=()=>N(`all`),(0,e.insert)(n,M,null),t}}),C),(0,e.insert)(S,(0,e.createComponent)(n.Show,{get when(){return P()!==`all`},get children(){var t=l(),n=t.firstChild;return n.firstChild,t.$$click=()=>F(`all`),(0,e.insert)(n,P,null),t}}),C),(0,e.insert)(C,()=>q().length,T),(0,e.insert)(C,()=>i().length,k),(0,e.insert)(C,(()=>{var t=(0,e.memo)(()=>!!(E()===`workspace`&&w()));return()=>t()?w():y()||w()||`workspace`})(),null),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return me()},children:t=>(()=>{var n=d();return(0,e.insert)(n,()=>t().text),(0,e.effect)(()=>(0,e.className)(n,`oc-lb-status oc-lb-status-${t().kind}`)),n})()}),R),(0,e.insert)(H,()=>q().length,W),(0,e.insert)(_e,(0,e.createComponent)(n.Show,{get when(){return!ue()},get fallback(){return f()},get children(){return(0,e.createComponent)(n.Show,{get when(){return q().length>0},get fallback(){return(()=>{var t=p();return(0,e.insert)(t,()=>i().length===0?`No backups found yet. Automatic snapshots are created before edit, write, patch, apply_patch, and multiedit tool calls.`:`No backups match your current search or filter criteria.`),t})()},get children(){return(0,e.createComponent)(n.For,{get each(){return q()},children:(t,n)=>{let r=()=>n()===I(),i=()=>le(t.backupPath);return(()=>{var a=m(),o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=c.nextSibling,u=o.nextSibling;return u.firstChild,a.$$dblclick=()=>{L(n()),V(!0)},a.$$click=()=>L(n()),(0,e.use)(e=>he.set(n(),e),a),(0,e.insert)(s,(0,e.createComponent)(b,{get text(){return t.relativePath},get terms(){return K()}})),(0,e.insert)(c,()=>t.tool),(0,e.insert)(l,()=>oe(t.timeMs)),(0,e.insert)(u,(0,e.createComponent)(b,{get text(){return i()},get terms(){return K()}}),null),(0,e.effect)(n=>{var i=`oc-lb-row ${r()?`is-selected`:``}`,o=t.relativePath,l=`oc-lb-badge oc-lb-badge-${t.tool}`,d=t.backupPath;return i!==n.e&&(0,e.className)(a,n.e=i),o!==n.t&&(0,e.setAttribute)(s,`title`,n.t=o),l!==n.a&&(0,e.className)(c,n.a=l),d!==n.o&&(0,e.setAttribute)(u,`title`,n.o=d),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()}})}})}})),(0,e.insert)(X,(0,e.createComponent)(n.Show,{get when(){return J()},children:t=>(()=>{var n=h();return(0,e.insert)(n,()=>ce(t().size)),n})()}),null),(0,e.insert)(Y,(0,e.createComponent)(n.Show,{get when(){return J()},get fallback(){return ee()},children:t=>[(()=>{var n=te(),i=n.firstChild,a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild,l=c.nextSibling,u=l.nextSibling.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=a.nextSibling,p=i.nextSibling.firstChild.nextSibling,m=p.nextSibling.nextSibling;return(0,e.insert)(o,(0,e.createComponent)(b,{get text(){return t().relativePath},get terms(){return K()}})),(0,e.insert)(s,()=>se(t().timeMs),c),(0,e.insert)(s,()=>oe(t().timeMs),l),(0,e.insert)(s,()=>ce(t().size),u),(0,e.insert)(s,()=>t().tool,d),(0,e.insert)(s,(0,e.createComponent)(b,{get text(){return t().snapshotId},get terms(){return K()}}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`contrast`,size:`small`,onClick:()=>V(!0),children:`Restore File`}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>void Se(t().backupPath,t().relativePath),children:`Open Backup`}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>void Q(),children:`Diff in Editor`}),null),(0,e.insert)(p,(0,e.createComponent)(b,{get text(){return t().originalPath},get terms(){return K()}})),(0,e.insert)(m,(0,e.createComponent)(b,{get text(){return t().backupPath},get terms(){return K()}})),(0,e.effect)(n=>{var r=t().originalPath,i=t().backupPath;return r!==n.e&&(0,e.setAttribute)(p,`title`,n.e=r),i!==n.t&&(0,e.setAttribute)(m,`title`,n.t=i),n},{e:void 0,t:void 0}),n})(),(()=>{var t=ne();return(0,e.insert)(t,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!de())()&&fe()},get fallback(){return ie()},children:t=>(()=>{var n=h();return(0,e.insert)(n,()=>t().summary),(0,e.effect)(()=>(0,e.className)(n,`oc-lb-diff-status-${t().status}`)),n})()})),t})(),(()=>{var t=re();return(0,e.insert)(t,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!de())()&&fe()},children:t=>(0,e.createComponent)(n.Show,{get when(){return t().lines.length>0},get fallback(){return(()=>{var n=p();return(0,e.insert)(n,(()=>{var n=(0,e.memo)(()=>t().status===`identical`);return()=>n()?`No differences: backup snapshot and current file on disk are byte-for-byte identical.`:t().summary})()),n})()},get children(){return(0,e.createComponent)(n.For,{get each(){return t().lines},children:t=>{let n=t.type===`add`?`+ `:t.type===`del`?`- `:t.type===`hunk`?``:` `;return(()=>{var r=d();return(0,e.insert)(r,n,null),(0,e.insert)(r,(0,e.createComponent)(b,{get text(){return t.text},get terms(){return K()}}),null),(0,e.effect)(()=>(0,e.className)(r,`oc-lb-diff-line oc-lb-diff-${t.type}`)),r})()}})}})})),t})()]}),null),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!!pe())()&&J()},children:t=>(()=>{var n=ae(),i=n.firstChild,a=i.firstChild.nextSibling,o=a.firstChild.nextSibling,s=o.nextSibling.nextSibling,c=a.nextSibling,l=c.firstChild;l.firstChild.nextSibling;var u=l.nextSibling;u.firstChild.nextSibling;var d=c.nextSibling;return n.$$click=()=>V(!1),i.$$click=e=>e.stopPropagation(),(0,e.insert)(o,()=>t().relativePath),(0,e.insert)(s,()=>t().snapshotId),(0,e.insert)(l,()=>t().backupPath,null),(0,e.insert)(u,()=>t().originalPath,null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>V(!1),children:`Cancel (Esc)`}),null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>{V(!1),Q()},children:`Open Diff in Editor`}),null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`contrast`,size:`small`,onClick:()=>void xe(),children:`Restore File (Enter)`}),null),n})()}),null),(0,e.effect)(n=>{var r=`oc-lb-root ${t.surface===`panel`?`oc-lb-root-panel`:`oc-lb-root-modal`}`,i=ge();return r!==n.e&&(0,e.className)(a,n.e=r),i!==n.t&&(0,e.setAttribute)(a,`data-scheme`,n.t=i),n},{e:void 0,t:void 0}),(0,e.effect)(()=>x.value=A()),a})()}var[C,w]=(0,n.createSignal)(``),T;function E(t,r=``){r&&w(r);let i=t.sessions.current();if(i){T?.close();try{t.layout.open(`${t.id}:backups`,i)}catch{}}else{if(T)return;let i=t.ui;T=t.dialogs.open(a=>((0,n.onCleanup)(()=>{T=void 0}),(0,e.createComponent)(i.Dialog,{title:`Backup Manager`,size:`x-large`,get children(){return(0,e.createComponent)(S,{ctx:t,surface:`modal`,initialQuery:r,get onClose(){return a.close}})}})))}}function D(e,t){let n=`http://www.w3.org/2000/svg`,r=document.createElementNS(n,`svg`);r.setAttribute(`data-slot`,`icon-svg`),t?r.setAttribute(`class`,t):(r.setAttribute(`width`,`16`),r.setAttribute(`height`,`16`)),r.setAttribute(`viewBox`,`0 0 14 14`),r.setAttribute(`fill`,`none`),r.setAttribute(`aria-hidden`,`true`);let i=document.createElementNS(n,`use`);return i.setAttribute(`href`,`#opencode-v2-icon-${e}`),r.appendChild(i),r}var O=t.Plugin.define({i18n:{en:{"backups.command.title":`Browse & Restore File Backups`,"backups.command.description":`Inspect automatic file snapshots, view unified diffs, and restore files`,"backups.panel":`Backups`,"backups.panel.toggle":`Toggle Backups Side Panel`}},setup(i){let{ui:a}=i,o=`${i.id}:backups`,s={id:`backups`,get title(){return i.t(`backups.panel`)},closable:`compact`};if(i.add(t.Style,r),typeof document<`u`){document.querySelectorAll(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`).forEach(e=>e.remove());let e=()=>{if(document.querySelector(`[data-action="titlebar-backups"]`))return;let e=document.querySelector(`header[data-slot="titlebar-v2"] button[aria-label*="Search"]`)?.parentElement;if(!e)return;let t=document.createElement(`button`);t.type=`button`,t.setAttribute(`data-action`,`titlebar-backups`),t.setAttribute(`aria-label`,`Backup Snapshots (Ctrl+Shift+B)`),t.title=`Backup Snapshots (Ctrl+Shift+B)`,t.className=`oc-lb-titlebar-quick-btn`,t.appendChild(D(`archive`)),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),E(i,``)}),e.appendChild(t)},t=()=>{if(document.querySelector(`[data-action="vertical-tabs-backups"]`))return;let e=document.querySelector(`button[data-action="vertical-tabs-usage"]`)??document.querySelector(`button[data-action="vertical-tabs-memories"]`)??document.querySelector(`button[data-action="vertical-tabs-search"]`);if(!e?.parentElement||!e)return;let t=document.createElement(`button`);t.type=`button`,t.setAttribute(`data-action`,`vertical-tabs-backups`),t.setAttribute(`data-titlebar-tab-action`,``),t.setAttribute(`aria-label`,`Backup Snapshots (Ctrl+Shift+B)`),t.title=`Backup Snapshots (Ctrl+Shift+B)`,t.className=`group flex h-7 w-full shrink-0 items-center gap-1.5 rounded-[6px] ps-1.5 pe-2 text-[13px] leading-4 text-v2-text-text-faint hover:text-v2-text-text-base`;let n=document.createElement(`span`);n.className=`flex size-4 shrink-0 items-center justify-center`,n.appendChild(D(`archive`,`size-4 shrink-0`));let r=document.createElement(`span`);r.className=`min-w-0 flex-1 truncate text-start font-[460]`,r.textContent=`Backups`;let a=document.createElement(`span`);a.className=`ms-auto shrink-0 text-[11px] leading-none text-v2-text-text-faint opacity-0 transition-opacity group-hover:opacity-100`,a.textContent=`Ctrl+Shift+B`,t.appendChild(n),t.appendChild(r),t.appendChild(a),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),E(i,``)}),e.insertAdjacentElement(`afterend`,t)},r=()=>{e(),t()},a=e=>{let t=e.target;t&&typeof t.closest==`function`&&t.closest(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),E(i,``))},s=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();if(e.shiftKey&&!e.altKey&&t===`b`)e.preventDefault(),e.stopPropagation(),E(i,``);else if(e.altKey&&!e.shiftKey&&t===`b`){e.preventDefault(),e.stopPropagation();let t=i.sessions.current();t?i.layout.toggle(o,t):E(i,``)}};r();let c=new MutationObserver(()=>r());c.observe(document.body,{childList:!0,subtree:!0}),document.addEventListener(`click`,a,!0),window.addEventListener(`keydown`,s,!0),(0,n.onCleanup)(()=>{c.disconnect(),document.removeEventListener(`click`,a,!0),window.removeEventListener(`keydown`,s,!0),document.querySelectorAll(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`).forEach(e=>e.remove())})}i.add(t.Command,()=>({id:`backups`,title:i.t(`backups.command.title`),description:i.t(`backups.command.description`),keywords:`backups backup restore snapshots diff undo`,group:`Session`,section:`session`,bind:`mod+shift+b`,slash:{name:`backups`,arguments:!0},featured:!0,run(e){E(i,(e??``).trim())}})),i.add(t.Command,()=>{let e=i.sessions.current();return{id:`backups-panel`,title:i.t(`backups.panel.toggle`),description:i.t(`backups.command.description`),keywords:`backups panel sidebar snapshots`,group:`Session`,section:`session`,bind:`mod+alt+b`,run(){e?i.layout.toggle(o,e):E(i,``)}}}),i.add(t.MenuItem,()=>{let e=i.sessions.current(),t=!!e&&i.layout.state(o,e)!==`closed`;return{menu:`session.panel`,id:`backups`,title:i.t(`backups.panel`),description:i.t(`backups.command.description`),icon:`archive`,keybind:`${i.id}.backups-panel`,opened:t,run(){let e=i.sessions.current();e?i.layout.toggle(o,e):E(i,``)}}}),i.add(t.Panel,{id:`backups`,region:`side`,list:e=>e.open.includes(`backups`)?[s]:[],render:()=>(0,e.createComponent)(S,{ctx:i,surface:`panel`,initialQuery:``})})}});(0,e.delegateEvents)([`keydown`,`input`,`click`,`dblclick`]),exports.default=O;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("solid-js/web"),t=require("@opencode/plugin/gui"),n=require("solid-js");var r=`.oc-lb-root{--oc-lb-bg-base:var(--v2-background-bg-base,#141417);--oc-lb-bg-elevated:var(--v2-background-bg-elevated,#1b1b20);--oc-lb-bg-sunken:var(--v2-background-bg-sunken,#101013);--oc-lb-border-muted:var(--v2-border-border-muted,#ffffff14);--oc-lb-border-base:var(--v2-border-border-base,#ffffff24);--oc-lb-border-focus:var(--v2-border-border-focus,#3b82f6);--oc-lb-text-strong:var(--v2-text-text-strong,#f4f4f6);--oc-lb-text-base:var(--v2-text-text-base,#d4d4d8);--oc-lb-text-muted:var(--v2-text-text-muted,#9ca3af);--oc-lb-text-faint:var(--v2-text-text-faint,#6b7280);--oc-lb-hover:var(--v2-overlay-simple-overlay-hover,#ffffff0d);--oc-lb-selected:var(--v2-overlay-simple-overlay-selected,#3b82f624);--oc-lb-accent:#3b82f6;--oc-lb-green:#22c55e;--oc-lb-green-bg:#22c55e1f;--oc-lb-red:#ef4444;--oc-lb-red-bg:#ef44441f;--oc-lb-amber:#f59e0b;--oc-lb-amber-bg:#f59e0b24;--oc-lb-purple:#a855f7;--oc-lb-purple-bg:#a855f724;box-sizing:border-box;width:100%;color:var(--oc-lb-text-base);font-family:var(--v2-font-family-sans,-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);outline:none;flex-direction:column;font-size:.8125rem;display:flex;position:relative}.oc-lb-root[data-scheme=light]{--oc-lb-bg-base:var(--v2-background-bg-base,#fff);--oc-lb-bg-elevated:var(--v2-background-bg-elevated,#f8fafc);--oc-lb-bg-sunken:var(--v2-background-bg-sunken,#f1f5f9);--oc-lb-border-muted:var(--v2-border-border-muted,#0f172a14);--oc-lb-border-base:var(--v2-border-border-base,#0f172a26);--oc-lb-text-strong:var(--v2-text-text-strong,#0f172a);--oc-lb-text-base:var(--v2-text-text-base,#1e293b);--oc-lb-text-muted:var(--v2-text-text-muted,#475569);--oc-lb-text-faint:var(--v2-text-text-faint,#64748b);--oc-lb-hover:var(--v2-overlay-simple-overlay-hover,#0f172a0a);--oc-lb-selected:var(--v2-overlay-simple-overlay-selected,#2563eb1a)}.oc-lb-root-modal{height:min(74vh,660px);max-height:100%;overflow:hidden}.oc-lb-root-panel{height:100%;min-height:440px;overflow:hidden}.oc-lb-toolbar{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-direction:column;flex-shrink:0;gap:.45rem;padding:.65rem .85rem;display:flex}.oc-lb-search-row{flex-wrap:wrap;align-items:center;gap:.45rem;display:flex}.oc-lb-search-box{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-bg-sunken);border-radius:.375rem;flex:14rem;align-items:center;min-width:11rem;height:1.875rem;padding:0 .55rem;transition:border-color .12s;display:flex}.oc-lb-search-box:focus-within{border-color:var(--oc-lb-border-focus)}.oc-lb-search-icon{color:var(--oc-lb-text-faint);-webkit-user-select:none;user-select:none;margin-right:.4rem;font-size:.875rem}.oc-lb-search-input{min-width:0;color:var(--oc-lb-text-strong);background:0 0;border:none;outline:none;flex:1;font-size:.8125rem}.oc-lb-search-input::placeholder{color:var(--oc-lb-text-faint)}.oc-lb-search-clear{color:var(--oc-lb-text-muted);cursor:pointer;background:0 0;border:none;border-radius:.25rem;padding:0 .25rem;font-size:.95rem;line-height:1}.oc-lb-search-clear:hover{color:var(--oc-lb-text-strong);background:var(--oc-lb-hover)}.oc-lb-search-clear:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-scope-seg{border:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-sunken);border-radius:.375rem;align-items:center;padding:.125rem;display:inline-flex}.oc-lb-scope-btn{color:var(--oc-lb-text-muted);cursor:pointer;background:0 0;border:none;border-radius:.25rem;padding:.2rem .5rem;font-size:.75rem;transition:background-color .12s,color .12s}.oc-lb-scope-btn:hover{color:var(--oc-lb-text-strong)}.oc-lb-scope-btn:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-scope-btn.is-active{background:var(--oc-lb-bg-elevated);color:var(--oc-lb-text-strong);font-weight:600}.oc-lb-active-chips{flex-wrap:wrap;align-items:center;gap:.4rem;min-height:1.25rem;display:flex}.oc-lb-filter-chip{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-selected);color:var(--oc-lb-text-strong);cursor:pointer;border-radius:999px;align-items:center;gap:.3rem;padding:.12rem .45rem;font-size:.72rem;display:inline-flex}.oc-lb-filter-chip:hover{background:var(--oc-lb-hover)}.oc-lb-filter-chip:focus-visible{outline:2px solid var(--oc-lb-border-focus)}.oc-lb-filter-chip-x{opacity:.75;font-weight:700}.oc-lb-count-summary{color:var(--oc-lb-text-muted);white-space:nowrap;text-overflow:ellipsis;max-width:100%;margin-left:auto;font-size:.72rem;overflow:hidden}.oc-lb-status{border-bottom:1px solid var(--oc-lb-border-muted);flex-shrink:0;padding:.4rem .85rem;font-size:.76rem}.oc-lb-status-ok{background:var(--oc-lb-green-bg);color:var(--oc-lb-green)}.oc-lb-status-warn{background:var(--oc-lb-amber-bg);color:var(--oc-lb-amber)}.oc-lb-status-err{background:var(--oc-lb-red-bg);color:var(--oc-lb-red)}.oc-lb-split{flex:1;grid-template-columns:minmax(15rem,42%) minmax(0,58%);min-height:0;display:grid;overflow:hidden}.oc-lb-root-panel .oc-lb-split{grid-template-rows:minmax(11rem,44%) minmax(0,56%);grid-template-columns:1fr}.oc-lb-list-pane{border-right:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-base);flex-direction:column;min-height:0;display:flex}.oc-lb-root-panel .oc-lb-list-pane{border-right:none;border-bottom:1px solid var(--oc-lb-border-muted)}.oc-lb-preview-pane{background:var(--oc-lb-bg-base);flex-direction:column;min-height:0;display:flex}.oc-lb-pane-header{letter-spacing:.04em;text-transform:uppercase;color:var(--oc-lb-text-faint);border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-shrink:0;justify-content:space-between;align-items:center;padding:.4rem .75rem;font-size:.6875rem;font-weight:600;display:flex}.oc-lb-list-scroll{flex:1;min-height:0;overflow-y:auto}.oc-lb-row{border-bottom:1px solid var(--oc-lb-border-muted);cursor:pointer;flex-direction:column;gap:.2rem;padding:.5rem .75rem;transition:background-color .1s;display:flex}.oc-lb-row:hover{background:var(--oc-lb-hover)}.oc-lb-row.is-selected{background:var(--oc-lb-selected);border-left:2px solid var(--oc-lb-accent);padding-left:calc(.75rem - 2px)}.oc-lb-row-top{align-items:center;gap:.4rem;min-width:0;display:flex}.oc-lb-row-title{min-width:0;color:var(--oc-lb-text-strong);white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.oc-lb-badge{text-transform:lowercase;background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-muted);border-radius:.25rem;flex-shrink:0;padding:.08rem .38rem;font-size:.65rem;font-weight:600}.oc-lb-badge-edit{color:#60a5fa;background:#3b82f626}.oc-lb-badge-write{background:var(--oc-lb-green-bg);color:var(--oc-lb-green)}.oc-lb-badge-patch,.oc-lb-badge-apply_patch,.oc-lb-badge-multiedit{background:var(--oc-lb-purple-bg);color:var(--oc-lb-purple)}.oc-lb-badge-pre-restore{background:var(--oc-lb-amber-bg);color:var(--oc-lb-amber)}.oc-lb-row-age{color:var(--oc-lb-text-faint);flex-shrink:0;font-size:.7rem}.oc-lb-row-sub{color:var(--oc-lb-text-muted);white-space:nowrap;text-overflow:ellipsis;font-size:.7rem;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);overflow:hidden}.oc-lb-meta-card{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-elevated);flex-shrink:0;padding:.65rem .85rem}.oc-lb-meta-title-row{flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:.65rem;margin-bottom:.45rem;display:flex}.oc-lb-meta-filename{color:var(--oc-lb-text-strong);word-break:break-all;font-size:.875rem;font-weight:600}.oc-lb-meta-sub{color:var(--oc-lb-text-muted);margin-top:.15rem;font-size:.72rem}.oc-lb-action-bar{flex-wrap:wrap;align-items:center;gap:.35rem;display:flex}.oc-lb-meta-grid{font-size:.72rem;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);grid-template-columns:4.25rem minmax(0,1fr);gap:.2rem .5rem;display:grid}.oc-lb-meta-label{color:var(--oc-lb-text-faint)}.oc-lb-meta-val{color:var(--oc-lb-text-base);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.oc-lb-diff-summary{border-bottom:1px solid var(--oc-lb-border-muted);background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-muted);flex-shrink:0;padding:.35rem .85rem;font-size:.72rem;font-weight:500}.oc-lb-diff-status-modified{color:var(--oc-lb-amber)}.oc-lb-diff-status-identical{color:var(--oc-lb-green)}.oc-lb-diff-status-deleted,.oc-lb-diff-status-error{color:var(--oc-lb-red)}.oc-lb-diff-scroll{min-height:0;font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);background:var(--oc-lb-bg-sunken);flex:1;padding:.4rem 0;font-size:.75rem;line-height:1.45;overflow:auto}.oc-lb-diff-line{white-space:pre;padding:.05rem .85rem}.oc-lb-diff-add{color:#4ade80;background:#22c55e24}.oc-lb-root[data-scheme=light] .oc-lb-diff-add{color:#15803d;background:#22c55e29}.oc-lb-diff-del{color:#f87171;background:#ef444424}.oc-lb-root[data-scheme=light] .oc-lb-diff-del{color:#b91c1c;background:#ef444429}.oc-lb-diff-hunk{color:#60a5fa;background:#3b82f61f;margin-top:.2rem;font-weight:600}.oc-lb-diff-context{color:var(--oc-lb-text-muted)}.oc-lb-mark{color:inherit;background:#f59e0b59;border-radius:.15rem;padding:0 .1rem}.oc-lb-empty{text-align:center;color:var(--oc-lb-text-muted);padding:2rem 1.25rem;font-size:.8rem;line-height:1.5}.oc-lb-modal-backdrop{z-index:20;background:#0000008c;justify-content:center;align-items:center;padding:1rem;display:flex;position:absolute;inset:0}.oc-lb-modal-card{background:var(--oc-lb-bg-elevated);border:1px solid var(--oc-lb-border-base);border-radius:.5rem;width:min(32rem,100%);padding:1rem 1.15rem;box-shadow:0 12px 32px #00000073}.oc-lb-modal-title{color:var(--oc-lb-text-strong);margin:0 0 .45rem;font-size:.95rem;font-weight:600}.oc-lb-modal-desc{color:var(--oc-lb-text-base);margin:0 0 .65rem;font-size:.8rem;line-height:1.45}.oc-lb-modal-paths{background:var(--oc-lb-bg-sunken);border:1px solid var(--oc-lb-border-muted);font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);color:var(--oc-lb-text-muted);word-break:break-all;border-radius:.375rem;flex-direction:column;gap:.25rem;margin-bottom:.85rem;padding:.5rem .65rem;font-size:.72rem;display:flex}.oc-lb-modal-actions{justify-content:flex-end;align-items:center;gap:.45rem;display:flex}.oc-lb-dialog-footer{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.75rem;width:100%;display:flex}.oc-lb-footer-shortcuts{color:var(--oc-lb-text-muted);flex-wrap:wrap;align-items:center;gap:.65rem;font-size:.72rem;display:flex}.oc-lb-footer-shortcuts kbd{border:1px solid var(--oc-lb-border-base);background:var(--oc-lb-bg-sunken);color:var(--oc-lb-text-strong);font-family:var(--v2-font-family-mono,ui-monospace, SFMono-Regular, Consolas, monospace);border-radius:.25rem;padding:.1rem .32rem;font-size:.68rem}.oc-lb-titlebar-quick-btn{appearance:none;color:var(--v2-icon-icon-muted,var(--v2-text-text-muted));cursor:pointer;-webkit-app-region:no-drag;background:0 0;border:none;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;width:36px;height:28px;transition:background-color .12s,color .12s;display:inline-flex}.oc-lb-titlebar-quick-btn:hover{background:var(--v2-overlay-simple-overlay-hover);color:var(--v2-icon-icon-base,var(--v2-text-text-base))}.oc-lb-titlebar-quick-btn:focus-visible{outline:2px solid var(--v2-border-border-focus);outline-offset:-2px}@media (width<=768px){.oc-lb-split{grid-template-rows:minmax(11rem,44%) minmax(0,56%);grid-template-columns:1fr}.oc-lb-list-pane{border-right:none;border-bottom:1px solid var(--oc-lb-border-muted)}}`,i={id:`opencode-local-backup`,methods:{list:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{rootDir:{type:`string`},includeSubprojects:{type:`boolean`},limit:{type:`number`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{scanRoot:{type:`string`},workspaceDir:{type:`string`},settings:{type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},required:[`retentionDays`,`debounceMs`,`rootDir`,`dialogWidth`]},entries:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},snapshotId:{type:`string`},root:{type:`string`},slug:{type:`string`},tool:{type:`string`},timeMs:{type:`number`},relativePath:{type:`string`},fileName:{type:`string`},backupPath:{type:`string`},originalPath:{type:`string`},size:{type:`number`}},required:[`id`,`snapshotId`,`root`,`slug`,`tool`,`timeMs`,`relativePath`,`fileName`,`backupPath`,`originalPath`,`size`]}}},required:[`scanRoot`,`workspaceDir`,`settings`,`entries`]}},diff:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},originalPath:{type:`string`},maxLines:{type:`number`}},required:[`backupPath`,`originalPath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{status:{type:`string`},summary:{type:`string`},lines:{type:`array`,items:{type:`object`,properties:{type:{type:`string`},text:{type:`string`}},required:[`type`,`text`]}}},required:[`status`,`summary`,`lines`]}},restore:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{entry:{type:`object`,properties:{id:{type:`string`},snapshotId:{type:`string`},root:{type:`string`},slug:{type:`string`},tool:{type:`string`},timeMs:{type:`number`},relativePath:{type:`string`},fileName:{type:`string`},backupPath:{type:`string`},originalPath:{type:`string`},size:{type:`number`}},required:[`root`,`backupPath`,`originalPath`]}},required:[`entry`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{restoredPath:{type:`string`},fromSnapshot:{type:`string`},safetySnapshot:{type:[`string`,`null`]}},required:[`restoredPath`,`fromSnapshot`]}},openFile:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{filePath:{type:`string`}},required:[`filePath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{openedPath:{type:`string`},launcher:{type:`string`}},required:[`openedPath`,`launcher`]}},openDiff:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},originalPath:{type:`string`}},required:[`backupPath`,`originalPath`],additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{backupPath:{type:`string`},currentPath:{type:`string`},launcher:{type:`string`}},required:[`backupPath`,`currentPath`,`launcher`]}},prune:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{rootDir:{type:`string`},retentionDays:{type:`number`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{removed:{type:`number`},disabled:{type:`boolean`},retentionDays:{type:`number`}},required:[`removed`,`disabled`,`retentionDays`]}},updateSettings:{input:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},additionalProperties:!1},output:{$schema:`https://json-schema.org/draft/2020-12/schema`,type:`object`,properties:{filePath:{type:`string`},settings:{type:`object`,properties:{retentionDays:{type:`number`},debounceMs:{type:`number`},rootDir:{type:`string`},dialogWidth:{type:`string`}},required:[`retentionDays`,`debounceMs`,`rootDir`,`dialogWidth`]}},required:[`filePath`,`settings`]}}},events:{}},a=(0,e.template)(`<mark class=oc-lb-mark>`),o=(0,e.template)(`<button type=button class=oc-lb-search-clear title="Clear search">×`),s=(0,e.template)(`<div class=oc-lb-scope-seg role=group aria-label="Scan scope"><button type=button>All Root</button><button type=button>Workspace`),c=(0,e.template)(`<button type=button class=oc-lb-filter-chip title="Click to clear tool filter"><span>tool: </span><span class=oc-lb-filter-chip-x>×`),l=(0,e.template)(`<button type=button class=oc-lb-filter-chip title="Click to clear age filter"><span>age: </span><span class=oc-lb-filter-chip-x>×`),u=(0,e.template)(`<div tabindex=-1><div class=oc-lb-toolbar><div class=oc-lb-search-row><div class=oc-lb-search-box><span class=oc-lb-search-icon aria-hidden=true>⌕</span><input type=text class=oc-lb-search-input placeholder="Filter backups by file path, project, snapshot ID, or slug..."></div></div><div class=oc-lb-active-chips><span class=oc-lb-count-summary>/<!> snapshots • Root: </span></div></div><div class=oc-lb-split><div class=oc-lb-list-pane><div class=oc-lb-pane-header><span>SNAPSHOTS (<!>)</span><span>↑↓ Navigate</span></div><div class=oc-lb-list-scroll></div></div><div class=oc-lb-preview-pane><div class=oc-lb-pane-header><span>SNAPSHOT DETAILS & UNIFIED DIFF`),d=(0,e.template)(`<div>`),f=(0,e.template)(`<div class=oc-lb-empty>Scanning .backups folders...`),p=(0,e.template)(`<div class=oc-lb-empty>`),m=(0,e.template)(`<div><div class=oc-lb-row-top><span class=oc-lb-row-title></span><span></span><span class=oc-lb-row-age></span></div><div class=oc-lb-row-sub>↳ `),h=(0,e.template)(`<span>`),ee=(0,e.template)(`<div class=oc-lb-empty>Select a backup snapshot on the left to inspect its metadata and diff against the current file on disk.`),te=(0,e.template)(`<div class=oc-lb-meta-card><div class=oc-lb-meta-title-row><div><div class=oc-lb-meta-filename></div><div class=oc-lb-meta-sub> (<!>) • <!> • [<!>] • </div></div><div class=oc-lb-action-bar></div></div><div class=oc-lb-meta-grid><span class=oc-lb-meta-label>Original:</span><span class=oc-lb-meta-val></span><span class=oc-lb-meta-label>Backup:</span><span class=oc-lb-meta-val>`),ne=(0,e.template)(`<div class=oc-lb-diff-summary>`),re=(0,e.template)(`<div class=oc-lb-diff-scroll>`),ie=(0,e.template)(`<span>Computing unified diff...`),ae=(0,e.template)(`<div class=oc-lb-modal-backdrop><div class=oc-lb-modal-card><h3 class=oc-lb-modal-title>Restore Backup Snapshot?</h3><p class=oc-lb-modal-desc>Restoring <strong></strong> from snapshot <code></code> will overwrite the current file on disk. A <code>pre-restore</code> safety backup of the current file will be saved automatically first.</p><div class=oc-lb-modal-paths><div><strong>From Backup:</strong> </div><div><strong>To Original:</strong> </div></div><div class=oc-lb-modal-actions>`),g=[`all`,`edit`,`write`,`patch`,`pre-restore`],_=[`all`,`24h`,`7d`,`30d`],v=[30,14,7,5,0];function oe(e){if(!e)return`unknown`;let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toISOString().slice(0,10)}function se(e){if(!e)return`unknown`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function ce(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function le(e){let t=String(e||``).replace(/\\/g,`/`),n=t.indexOf(`/.backups/`);if(n<=0)return t;let r=t.slice(0,n),i=r.lastIndexOf(`/`),a=i>0?r.slice(0,i):``;return a&&t.startsWith(a+`/`)?t.slice(a.length+1):t}function y(e,t){let n=String(e||``);if(!n)return[{text:``,match:!1}];let r=t.map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(r.length===0)return[{text:n,match:!1}];let i=n.toLowerCase(),a=[];for(let e of r){let t=0;for(;t<i.length;){let n=i.indexOf(e,t);if(n===-1)break;a.push([n,n+e.length]),t=n+Math.max(1,e.length)}}if(a.length===0)return[{text:n,match:!1}];a.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let o=[a[0]];for(let e=1;e<a.length;e++){let t=o[o.length-1],n=a[e];n[0]<=t[1]?t[1]=Math.max(t[1],n[1]):o.push([n[0],n[1]])}let s=[],c=0;for(let[e,t]of o)e>c&&s.push({text:n.slice(c,e),match:!1}),s.push({text:n.slice(e,t),match:!0}),c=t;return c<n.length&&s.push({text:n.slice(c),match:!1}),s}function b(t){let r=(0,n.createMemo)(()=>y(t.text,t.terms));return(0,e.createComponent)(n.For,{get each(){return r()},children:t=>(0,e.createComponent)(n.Show,{get when(){return t.match},get fallback(){return(0,e.memo)(()=>t.text)},get children(){var n=a();return(0,e.insert)(n,()=>t.text),n}})})}function x(e){let t=e.sessions.current();if(t?.server?.client?.rpc)return t.server.client.rpc(i);let n=e.servers;if(n){let e=typeof n.list==`function`?n.list():[];for(let t of e){if(t?.client?.rpc)return t.client.rpc(i);if(t?.id&&typeof n.get==`function`){let e=n.get(t.id);if(e?.client?.rpc)return e.client.rpc(i)}}if(typeof n.get==`function`){let e=n.get(`local`)||n.get(`default`);if(e?.client?.rpc)return e.client.rpc(i)}}let r=e.client;return r?.rpc?r.rpc(i):null}function S(t){let{ui:r}=t.ctx,[i,a]=(0,n.createSignal)([]),[y,S]=(0,n.createSignal)(``),[w,T]=(0,n.createSignal)(``),[E,D]=(0,n.createSignal)(`scan-root`),[O,k]=(0,n.createSignal)({retentionDays:30,debounceMs:0,rootDir:``,dialogWidth:`80%`}),[A,j]=(0,n.createSignal)(t.initialQuery||``);(0,n.createEffect)(()=>{let e=C();e&&j(e)});let[M,N]=(0,n.createSignal)(`all`),[P,F]=(0,n.createSignal)(`all`),[I,L]=(0,n.createSignal)(0),[ue,R]=(0,n.createSignal)(!0),[de,z]=(0,n.createSignal)(!1),[fe,B]=(0,n.createSignal)(null),[pe,V]=(0,n.createSignal)(!1),[me,H]=(0,n.createSignal)(null),U,he=new Map,ge=(0,n.createMemo)(()=>{let e=t.ctx.appearance.mode();return e===`light`||e===`dark`?e:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`});function W(e,t=`ok`){H({text:e,kind:t}),typeof window<`u`&&window.setTimeout(()=>{H(t=>t?.text===e?null:t)},4500)}async function G(e){let n=x(t.ctx);if(!n)R(!1),W(`No active OpenCode server session found for Backup RPC.`,`err`);else{R(!0);try{let t=E()===`workspace`&&w(),r=await n.list({rootDir:t?w():void 0,includeSubprojects:!0,limit:500});S(r.scanRoot||``),T(r.workspaceDir||``),r.settings&&k(r.settings);let i=Array.isArray(r.entries)?r.entries:[];if(a(i),e){let t=q().findIndex(t=>t.id===e);L(t>=0?t:0)}else L(e=>Math.min(e,Math.max(0,q().length-1)))}catch(e){W(`Failed to load backups: ${e?.message||String(e)}`,`err`)}finally{R(!1)}}}let K=(0,n.createMemo)(()=>{let e=A().trim().toLowerCase();return e?e.split(/\s+/).filter(Boolean):[]}),q=(0,n.createMemo)(()=>{let e=K(),t=M(),n=P(),r=Date.now(),a=n===`24h`?864e5:n===`7d`?6048e5:n===`30d`?2592e6:0;return i().filter(n=>{if(t!==`all`&&n.tool!==t||a>0&&r-n.timeMs>a)return!1;if(e.length>0){let t=`${n.relativePath} ${n.backupPath} ${n.originalPath} ${n.root} ${n.snapshotId} ${n.slug}`.toLowerCase();if(!e.every(e=>t.includes(e)))return!1}return!0})});(0,n.createEffect)(()=>{let e=q();I()>=e.length&&L(Math.max(0,e.length-1))});let J=(0,n.createMemo)(()=>q()[I()]||null);(0,n.createEffect)(()=>{let e=J(),r=x(t.ctx);if(!e||!r){B(null);return}let i=!1;z(!0),r.diff({backupPath:e.backupPath,originalPath:e.originalPath,maxLines:220}).then(e=>{i||(B(e),z(!1))}).catch(e=>{i||(B({status:`error`,summary:`Diff error: ${e?.message||String(e)}`,lines:[]}),z(!1))}),(0,n.onCleanup)(()=>{i=!0})});function _e(e){let t=he.get(e);t&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`nearest`})}function Y(e){let t=q().length;if(t===0)return;let n=Math.max(0,Math.min(t-1,I()+e));L(n),_e(n)}function X(){let e=g[(g.indexOf(M())+1)%g.length];N(e),L(0)}function Z(){let e=_[(_.indexOf(P())+1)%_.length];F(e),L(0)}async function ve(e){let n=x(t.ctx);if(n)try{let t=await n.updateSettings({retentionDays:e});t?.settings&&k(t.settings),W(`Updated backup retention to ${e===0?`never auto-prune (0d)`:`${e} days`}`,`ok`)}catch(e){W(`Failed to update retention: ${e?.message||String(e)}`,`err`)}}function ye(){let e=O().retentionDays,t=v.indexOf(e);ve(t>=0?v[(t+1)%v.length]:v[0])}async function be(){let e=x(t.ctx);if(!e)return;let n=O().retentionDays;if(n<=0)W(`Retention is set to never (0d); nothing pruned.`,`warn`);else try{let t=E()===`workspace`&&w(),r=await e.prune({rootDir:t?w():y()||void 0,retentionDays:n});await G(J()?.id),W(`Pruned ${r.removed} snapshot folder(s) older than ${r.retentionDays}d`,`ok`)}catch(e){W(`Prune failed: ${e?.message||String(e)}`,`err`)}}async function xe(){let e=J(),n=x(t.ctx);if(e&&n){V(!1);try{let t=await n.restore({entry:e}),r=t.safetySnapshot?` (safety backup: ${t.safetySnapshot})`:``;await G(e.id),W(`Restored ${e.relativePath}${r}`,`ok`)}catch(e){W(`Restore failed: ${e?.message||String(e)}`,`err`)}}}async function Se(e,n){let r=x(t.ctx);if(r&&e)try{W(`Opened ${n} via ${(await r.openFile({filePath:e})).launcher}`,`ok`)}catch(e){W(`Open failed: ${e?.message||String(e)}`,`err`)}}async function Q(){let e=J(),n=x(t.ctx);if(e&&n)try{let t=await n.openDiff({backupPath:e.backupPath,originalPath:e.originalPath});W(`Opened diff for ${e.relativePath} via ${t.launcher}`,`ok`)}catch(e){W(`Open diff failed: ${e?.message||String(e)}`,`err`)}}let $=(0,n.createMemo)(()=>{let e=0;return M()!==`all`&&e++,P()!==`all`&&e++,e}),Ce=(0,n.createMemo)(()=>[{type:`group`,label:`Tool Filter (^T)`,items:g.map(e=>({label:e===`all`?`All tools`:`[${e}]`,...M()===e?{icon:`check-small`}:{},onSelect:()=>{N(e),L(0)}}))},{type:`separator`},{type:`group`,label:`Age Filter (^G)`,items:_.map(e=>({label:e===`all`?`All dates`:`Last ${e}`,...P()===e?{icon:`check-small`}:{},onSelect:()=>{F(e),L(0)}}))},{type:`separator`},{type:`group`,label:`Auto-Prune Retention (^R)`,items:v.map(e=>({label:e===0?`Never auto-prune (0d)`:`${e} days`,...O().retentionDays===e?{icon:`check-small`}:{},onSelect:()=>{ve(e)}}))},{type:`separator`},{label:`Reset tool & date filters`,icon:`reset`,disabled:$()===0,onSelect:()=>{N(`all`),F(`all`),L(0)}}]);function we(e){if(pe())e.key===`Escape`?(e.preventDefault(),V(!1)):e.key===`Enter`&&(e.preventDefault(),xe());else{if(e.ctrlKey||e.metaKey){let t=e.key.toLowerCase();if(t===`t`){e.preventDefault(),X();return}if(t===`g`){e.preventDefault(),Z();return}if(t===`r`){e.preventDefault(),ye();return}if(t===`d`){e.preventDefault(),be();return}if(t===`o`){e.preventDefault();let t=J();t&&Se(t.backupPath,t.relativePath);return}if(t===`e`){e.preventDefault(),Q();return}}e.key===`ArrowDown`?(e.preventDefault(),Y(1)):e.key===`ArrowUp`?(e.preventDefault(),Y(-1)):e.key===`PageDown`?(e.preventDefault(),Y(8)):e.key===`PageUp`?(e.preventDefault(),Y(-8)):e.key===`Enter`&&J()&&(e.preventDefault(),V(!0))}}(0,n.onMount)(()=>{G(),typeof window<`u`&&window.setTimeout(()=>U?.focus(),40)});let Te=(0,n.createMemo)(()=>{let e=y().replace(/\\/g,`/`).toLowerCase(),t=w().replace(/\\/g,`/`).toLowerCase();return!!(e&&t&&e!==t)});return(()=>{var a=u(),g=a.firstChild,_=g.firstChild,v=_.firstChild,x=v.firstChild.nextSibling,S=_.nextSibling,C=S.firstChild,T=C.firstChild,k=T.nextSibling;k.nextSibling;var R=g.nextSibling,z=R.firstChild,B=z.firstChild,H=B.firstChild,W=H.firstChild.nextSibling;W.nextSibling;var _e=B.nextSibling,Y=z.nextSibling,X=Y.firstChild;X.firstChild,a.$$keydown=we,x.$$input=e=>{j(e.currentTarget.value),L(0)};var Z=U;return typeof Z==`function`?(0,e.use)(Z,x):U=x,(0,e.insert)(v,(0,e.createComponent)(n.Show,{get when(){return A().length>0},get children(){var e=o();return e.$$click=()=>{j(``),L(0),U?.focus()},e}}),null),(0,e.insert)(_,(0,e.createComponent)(n.Show,{get when(){return Te()},get children(){var t=s(),n=t.firstChild,r=n.nextSibling;return n.$$click=()=>{D(`scan-root`),G()},r.$$click=()=>{D(`workspace`),G()},(0,e.effect)(t=>{var i=`oc-lb-scope-btn ${E()===`scan-root`?`is-active`:``}`,a=`Scan configured root: ${y()}`,o=`oc-lb-scope-btn ${E()===`workspace`?`is-active`:``}`,s=`Scan current workspace only: ${w()}`;return i!==t.e&&(0,e.className)(n,t.e=i),a!==t.t&&(0,e.setAttribute)(n,`title`,t.t=a),o!==t.a&&(0,e.className)(r,t.a=o),s!==t.o&&(0,e.setAttribute)(r,`title`,t.o=s),t},{e:void 0,t:void 0,a:void 0,o:void 0}),t}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Menu,{get label(){return(0,e.memo)(()=>$()>0)()?`Filters (${$()})`:`Filters`},trigger:`button`,icon:`sliders`,placement:`bottom-end`,get items(){return Ce()}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>ye(),get children(){return[`Retain: `,(0,e.memo)(()=>(0,e.memo)(()=>O().retentionDays===0)()?`never`:`${O().retentionDays}d`)]}}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>void be(),children:`Prune`}),null),(0,e.insert)(_,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>void G(J()?.id),children:`Refresh`}),null),(0,e.insert)(S,(0,e.createComponent)(n.Show,{get when(){return M()!==`all`},get children(){var t=c(),n=t.firstChild;return n.firstChild,t.$$click=()=>N(`all`),(0,e.insert)(n,M,null),t}}),C),(0,e.insert)(S,(0,e.createComponent)(n.Show,{get when(){return P()!==`all`},get children(){var t=l(),n=t.firstChild;return n.firstChild,t.$$click=()=>F(`all`),(0,e.insert)(n,P,null),t}}),C),(0,e.insert)(C,()=>q().length,T),(0,e.insert)(C,()=>i().length,k),(0,e.insert)(C,(()=>{var t=(0,e.memo)(()=>!!(E()===`workspace`&&w()));return()=>t()?w():y()||w()||`workspace`})(),null),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return me()},children:t=>(()=>{var n=d();return(0,e.insert)(n,()=>t().text),(0,e.effect)(()=>(0,e.className)(n,`oc-lb-status oc-lb-status-${t().kind}`)),n})()}),R),(0,e.insert)(H,()=>q().length,W),(0,e.insert)(_e,(0,e.createComponent)(n.Show,{get when(){return!ue()},get fallback(){return f()},get children(){return(0,e.createComponent)(n.Show,{get when(){return q().length>0},get fallback(){return(()=>{var t=p();return(0,e.insert)(t,()=>i().length===0?`No backups found yet. Automatic snapshots are created before edit, write, patch, apply_patch, and multiedit tool calls.`:`No backups match your current search or filter criteria.`),t})()},get children(){return(0,e.createComponent)(n.For,{get each(){return q()},children:(t,n)=>{let r=()=>n()===I(),i=()=>le(t.backupPath);return(()=>{var a=m(),o=a.firstChild,s=o.firstChild,c=s.nextSibling,l=c.nextSibling,u=o.nextSibling;return u.firstChild,a.$$dblclick=()=>{L(n()),V(!0)},a.$$click=()=>L(n()),(0,e.use)(e=>he.set(n(),e),a),(0,e.insert)(s,(0,e.createComponent)(b,{get text(){return t.relativePath},get terms(){return K()}})),(0,e.insert)(c,()=>t.tool),(0,e.insert)(l,()=>oe(t.timeMs)),(0,e.insert)(u,(0,e.createComponent)(b,{get text(){return i()},get terms(){return K()}}),null),(0,e.effect)(n=>{var i=`oc-lb-row ${r()?`is-selected`:``}`,o=t.relativePath,l=`oc-lb-badge oc-lb-badge-${t.tool}`,d=t.backupPath;return i!==n.e&&(0,e.className)(a,n.e=i),o!==n.t&&(0,e.setAttribute)(s,`title`,n.t=o),l!==n.a&&(0,e.className)(c,n.a=l),d!==n.o&&(0,e.setAttribute)(u,`title`,n.o=d),n},{e:void 0,t:void 0,a:void 0,o:void 0}),a})()}})}})}})),(0,e.insert)(X,(0,e.createComponent)(n.Show,{get when(){return J()},children:t=>(()=>{var n=h();return(0,e.insert)(n,()=>ce(t().size)),n})()}),null),(0,e.insert)(Y,(0,e.createComponent)(n.Show,{get when(){return J()},get fallback(){return ee()},children:t=>[(()=>{var n=te(),i=n.firstChild,a=i.firstChild,o=a.firstChild,s=o.nextSibling,c=s.firstChild,l=c.nextSibling,u=l.nextSibling.nextSibling,d=u.nextSibling.nextSibling;d.nextSibling;var f=a.nextSibling,p=i.nextSibling.firstChild.nextSibling,m=p.nextSibling.nextSibling;return(0,e.insert)(o,(0,e.createComponent)(b,{get text(){return t().relativePath},get terms(){return K()}})),(0,e.insert)(s,()=>se(t().timeMs),c),(0,e.insert)(s,()=>oe(t().timeMs),l),(0,e.insert)(s,()=>ce(t().size),u),(0,e.insert)(s,()=>t().tool,d),(0,e.insert)(s,(0,e.createComponent)(b,{get text(){return t().snapshotId},get terms(){return K()}}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`contrast`,size:`small`,onClick:()=>V(!0),children:`Restore File`}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>void Se(t().backupPath,t().relativePath),children:`Open Backup`}),null),(0,e.insert)(f,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>void Q(),children:`Diff in Editor`}),null),(0,e.insert)(p,(0,e.createComponent)(b,{get text(){return t().originalPath},get terms(){return K()}})),(0,e.insert)(m,(0,e.createComponent)(b,{get text(){return t().backupPath},get terms(){return K()}})),(0,e.effect)(n=>{var r=t().originalPath,i=t().backupPath;return r!==n.e&&(0,e.setAttribute)(p,`title`,n.e=r),i!==n.t&&(0,e.setAttribute)(m,`title`,n.t=i),n},{e:void 0,t:void 0}),n})(),(()=>{var t=ne();return(0,e.insert)(t,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!de())()&&fe()},get fallback(){return ie()},children:t=>(()=>{var n=h();return(0,e.insert)(n,()=>t().summary),(0,e.effect)(()=>(0,e.className)(n,`oc-lb-diff-status-${t().status}`)),n})()})),t})(),(()=>{var t=re();return(0,e.insert)(t,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!de())()&&fe()},children:t=>(0,e.createComponent)(n.Show,{get when(){return t().lines.length>0},get fallback(){return(()=>{var n=p();return(0,e.insert)(n,(()=>{var n=(0,e.memo)(()=>t().status===`identical`);return()=>n()?`No differences: backup snapshot and current file on disk are byte-for-byte identical.`:t().summary})()),n})()},get children(){return(0,e.createComponent)(n.For,{get each(){return t().lines},children:t=>{let n=t.type===`add`?`+ `:t.type===`del`?`- `:t.type===`hunk`?``:` `;return(()=>{var r=d();return(0,e.insert)(r,n,null),(0,e.insert)(r,(0,e.createComponent)(b,{get text(){return t.text},get terms(){return K()}}),null),(0,e.effect)(()=>(0,e.className)(r,`oc-lb-diff-line oc-lb-diff-${t.type}`)),r})()}})}})})),t})()]}),null),(0,e.insert)(a,(0,e.createComponent)(n.Show,{get when(){return(0,e.memo)(()=>!!pe())()&&J()},children:t=>(()=>{var n=ae(),i=n.firstChild,a=i.firstChild.nextSibling,o=a.firstChild.nextSibling,s=o.nextSibling.nextSibling,c=a.nextSibling,l=c.firstChild;l.firstChild.nextSibling;var u=l.nextSibling;u.firstChild.nextSibling;var d=c.nextSibling;return n.$$click=()=>V(!1),i.$$click=e=>e.stopPropagation(),(0,e.insert)(o,()=>t().relativePath),(0,e.insert)(s,()=>t().snapshotId),(0,e.insert)(l,()=>t().backupPath,null),(0,e.insert)(u,()=>t().originalPath,null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`ghost`,size:`small`,onClick:()=>V(!1),children:`Cancel (Esc)`}),null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`neutral`,size:`small`,onClick:()=>{V(!1),Q()},children:`Open Diff in Editor`}),null),(0,e.insert)(d,(0,e.createComponent)(r.Button,{variant:`contrast`,size:`small`,onClick:()=>void xe(),children:`Restore File (Enter)`}),null),n})()}),null),(0,e.effect)(n=>{var r=`oc-lb-root ${t.surface===`panel`?`oc-lb-root-panel`:`oc-lb-root-modal`}`,i=ge();return r!==n.e&&(0,e.className)(a,n.e=r),i!==n.t&&(0,e.setAttribute)(a,`data-scheme`,n.t=i),n},{e:void 0,t:void 0}),(0,e.effect)(()=>x.value=A()),a})()}var[C,w]=(0,n.createSignal)(``),T;function E(t,r=``){r&&w(r);let i=t.sessions.current();if(i){T?.close();try{t.layout.open(`${t.id}:backups`,i)}catch{}}else{if(T)return;let i=t.ui;T=t.dialogs.open(a=>((0,n.onCleanup)(()=>{T=void 0}),(0,e.createComponent)(i.Dialog,{title:`Backup Manager`,size:`x-large`,get children(){return(0,e.createComponent)(S,{ctx:t,surface:`modal`,initialQuery:r,get onClose(){return a.close}})}})))}}function D(e,t){let n=`http://www.w3.org/2000/svg`,r=document.createElementNS(n,`svg`);r.setAttribute(`data-slot`,`icon-svg`),t?r.setAttribute(`class`,t):(r.setAttribute(`width`,`16`),r.setAttribute(`height`,`16`)),r.setAttribute(`viewBox`,`0 0 14 14`),r.setAttribute(`fill`,`none`),r.setAttribute(`aria-hidden`,`true`);let i=document.createElementNS(n,`use`);return i.setAttribute(`href`,`#opencode-v2-icon-${e}`),r.appendChild(i),r}var O=t.Plugin.define({i18n:{en:{"backups.command.title":`Browse & Restore File Backups`,"backups.command.description":`Inspect automatic file snapshots, view unified diffs, and restore files`,"backups.panel":`Backups`,"backups.panel.toggle":`Toggle Backups Side Panel`}},setup(i){let{ui:a}=i,o=`${i.id}:backups`,s={id:`backups`,get title(){return i.t(`backups.panel`)},closable:`compact`};if(i.add(t.Style,r),typeof document<`u`){document.querySelectorAll(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`).forEach(e=>e.remove());let e=()=>{if(document.querySelector(`[data-action="titlebar-backups"]`))return;let e=document.querySelector(`header[data-slot="titlebar-v2"] button[aria-label*="Search"]`)?.parentElement;if(!e)return;let t=document.createElement(`button`);t.type=`button`,t.setAttribute(`data-action`,`titlebar-backups`),t.setAttribute(`aria-label`,`Backup Snapshots (Ctrl+Shift+B)`),t.title=`Backup Snapshots (Ctrl+Shift+B)`,t.className=`oc-lb-titlebar-quick-btn`,t.appendChild(D(`archive`)),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),E(i,``)}),e.appendChild(t)},t=()=>{if(document.querySelector(`[data-action="vertical-tabs-backups"]`))return;let e=document.querySelector(`button[data-action="vertical-tabs-usage"]`)??document.querySelector(`button[data-action="vertical-tabs-memories"]`)??document.querySelector(`button[data-action="vertical-tabs-search"]`);if(!e?.parentElement||!e)return;let t=document.createElement(`button`);t.type=`button`,t.setAttribute(`data-action`,`vertical-tabs-backups`),t.setAttribute(`data-titlebar-tab-action`,``),t.setAttribute(`aria-label`,`Backup Snapshots (Ctrl+Shift+B)`),t.title=`Backup Snapshots (Ctrl+Shift+B)`,t.className=`group flex h-7 w-full shrink-0 items-center gap-1.5 rounded-[6px] ps-1.5 pe-2 text-[13px] leading-4 text-v2-text-text-faint hover:text-v2-text-text-base`;let n=document.createElement(`span`);n.className=`flex size-4 shrink-0 items-center justify-center`,n.appendChild(D(`archive`,`size-4 shrink-0`));let r=document.createElement(`span`);r.className=`min-w-0 flex-1 truncate whitespace-nowrap text-start font-[460]`,r.textContent=`Backups`,t.appendChild(n),t.appendChild(r),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),E(i,``)}),e.insertAdjacentElement(`afterend`,t)},r=()=>{e(),t()},a=e=>{let t=e.target;t&&typeof t.closest==`function`&&t.closest(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),E(i,``))},s=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();if(e.shiftKey&&!e.altKey&&t===`b`)e.preventDefault(),e.stopPropagation(),E(i,``);else if(e.altKey&&!e.shiftKey&&t===`b`){e.preventDefault(),e.stopPropagation();let t=i.sessions.current();t?i.layout.toggle(o,t):E(i,``)}};r();let c=new MutationObserver(()=>r());c.observe(document.body,{childList:!0,subtree:!0}),document.addEventListener(`click`,a,!0),window.addEventListener(`keydown`,s,!0),(0,n.onCleanup)(()=>{c.disconnect(),document.removeEventListener(`click`,a,!0),window.removeEventListener(`keydown`,s,!0),document.querySelectorAll(`[data-action="titlebar-backups"], [data-action="vertical-tabs-backups"]`).forEach(e=>e.remove())})}i.add(t.Command,()=>({id:`backups`,title:i.t(`backups.command.title`),description:i.t(`backups.command.description`),keywords:`backups backup restore snapshots diff undo`,group:`Session`,section:`session`,bind:`mod+shift+b`,slash:{name:`backups`,arguments:!0},featured:!0,run(e){E(i,(e??``).trim())}})),i.add(t.Command,()=>{let e=i.sessions.current();return{id:`backups-panel`,title:i.t(`backups.panel.toggle`),description:i.t(`backups.command.description`),keywords:`backups panel sidebar snapshots`,group:`Session`,section:`session`,bind:`mod+alt+b`,run(){e?i.layout.toggle(o,e):E(i,``)}}}),i.add(t.MenuItem,()=>{let e=i.sessions.current(),t=!!e&&i.layout.state(o,e)!==`closed`;return{menu:`session.panel`,id:`backups`,title:i.t(`backups.panel`),description:i.t(`backups.command.description`),icon:`archive`,keybind:`${i.id}.backups-panel`,opened:t,run(){let e=i.sessions.current();e?i.layout.toggle(o,e):E(i,``)}}}),i.add(t.Panel,{id:`backups`,region:`side`,list:e=>e.open.includes(`backups`)?[s]:[],render:()=>(0,e.createComponent)(S,{ctx:i,surface:`panel`,initialQuery:``})})}});(0,e.delegateEvents)([`keydown`,`input`,`click`,`dblclick`]),exports.default=O;
package/gui.tsx CHANGED
@@ -1105,17 +1105,11 @@ export default Plugin.define({
1105
1105
  iconWrap.appendChild(createSpriteIcon("archive", "size-4 shrink-0"));
1106
1106
 
1107
1107
  const labelSpan = document.createElement("span");
1108
- labelSpan.className = "min-w-0 flex-1 truncate text-start font-[460]";
1108
+ labelSpan.className = "min-w-0 flex-1 truncate whitespace-nowrap text-start font-[460]";
1109
1109
  labelSpan.textContent = "Backups";
1110
1110
 
1111
- const kbdSpan = document.createElement("span");
1112
- kbdSpan.className =
1113
- "ms-auto shrink-0 text-[11px] leading-none text-v2-text-text-faint opacity-0 transition-opacity group-hover:opacity-100";
1114
- kbdSpan.textContent = "Ctrl+Shift+B";
1115
-
1116
1111
  btn.appendChild(iconWrap);
1117
1112
  btn.appendChild(labelSpan);
1118
- btn.appendChild(kbdSpan);
1119
1113
 
1120
1114
  btn.addEventListener("click", (e) => {
1121
1115
  e.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nandoblanco/opencode-local-backup",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,6 +27,7 @@
27
27
  "dist/gui-experimental.cjs",
28
28
  "assets/screenshot.png",
29
29
  "README.md",
30
+ "CHANGELOG.md",
30
31
  "LICENSE"
31
32
  ],
32
33
  "scripts": {