ompchamber 0.8.0 → 1.0.0

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 (79) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/static/css/{index.5c0447cefe.css → index.e880517fcd.css} +1 -1
  3. package/dist/client/static/js/async/g.a06ca3b3e9.js +2 -0
  4. package/dist/client/static/js/async/{m.0896dab823.js → m.c038c71b9f.js} +2 -2
  5. package/dist/client/static/js/async/ms.98960af4eb.js +67 -0
  6. package/dist/client/static/js/async/ms.98960af4eb.js.LICENSE.txt +12 -0
  7. package/dist/client/static/js/async/ot.84c71b308f.js +2 -0
  8. package/dist/client/static/js/async/{x4.69ec69c61b.js.LICENSE.txt → ot.84c71b308f.js.LICENSE.txt} +5 -0
  9. package/dist/client/static/js/{index.dc5f5fabe8.js → index.0de15c5e17.js} +10 -10
  10. package/package.json +2 -1
  11. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
  12. package/src/client/components/layout/session-sidebar/SessionItem.tsx +1 -1
  13. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  14. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
  15. package/src/client/components/mobile/mobile-session-sidebar/List.tsx +1 -1
  16. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +2 -2
  17. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +11 -4
  18. package/src/client/components/workspace/chat-timeline/QueueList.tsx +18 -14
  19. package/src/client/components/workspace/chat-timeline/index.tsx +4 -2
  20. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
  21. package/src/client/components/workspace/git-panel/index.tsx +5 -1
  22. package/src/client/components/workspace/terminal-panel/Header.tsx +51 -19
  23. package/src/client/components/workspace/terminal-panel/RealtimeXtermView.tsx +86 -282
  24. package/src/client/components/workspace/terminal-panel/index.tsx +76 -50
  25. package/src/client/components/workspace/terminal-panel/mount.ts +275 -0
  26. package/src/client/data/theme/terminal.ts +27 -29
  27. package/src/client/hooks/chat/omp/session-list.tsx +19 -2
  28. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +1 -1
  29. package/src/client/hooks/chat/timeline/actions.ts +23 -25
  30. package/src/client/hooks/chat/timeline/index.ts +12 -20
  31. package/src/client/hooks/chat/timeline/queue.ts +110 -46
  32. package/src/client/hooks/workspace/terminal/index.ts +217 -0
  33. package/src/client/hooks/workspace/terminal/socket.ts +227 -0
  34. package/src/server/db.server.ts +19 -0
  35. package/src/server/lib/fs/git-sync.ts +191 -0
  36. package/src/server/lib/omp/rpc/manager.ts +58 -3
  37. package/src/server/lib/omp/rpc/session-commands.ts +6 -0
  38. package/src/server/lib/omp/session/sidebar-data.server.ts +3 -3
  39. package/src/server/lib/queue/delivery.server.ts +114 -0
  40. package/src/server/lib/queue/schema-migration.server.ts +50 -0
  41. package/src/server/lib/queue/store.server.ts +185 -0
  42. package/src/server/lib/terminal/foreground.ts +73 -0
  43. package/src/server/lib/terminal/history.test.ts +118 -0
  44. package/src/server/lib/terminal/history.ts +205 -0
  45. package/src/server/lib/terminal/runtime.server.ts +338 -0
  46. package/src/server/lib/terminal/session.server.ts +215 -0
  47. package/src/server/lib/terminal/shell.test.ts +97 -0
  48. package/src/server/lib/terminal/shell.ts +103 -0
  49. package/src/server/routes/fs/git.ts +22 -12
  50. package/src/server/routes/index.ts +2 -1
  51. package/src/server/routes/sessions/index.ts +11 -3
  52. package/src/server/routes/sessions/queue.ts +121 -0
  53. package/src/server/routes/sessions/session.ts +1 -132
  54. package/src/server/routes/settings/commands.ts +1 -1
  55. package/src/server/routes/terminal/index.ts +2 -2
  56. package/src/server/routes/terminal/run.ts +8 -100
  57. package/src/server/routes/terminal/sessions.ts +24 -0
  58. package/src/server/routes/terminal/ws.ts +149 -0
  59. package/src/shared/lib/chat/omp/agent-events.test.ts +37 -1
  60. package/src/shared/lib/chat/omp/agent-events.ts +30 -0
  61. package/src/shared/lib/chat/timeline/omp-callbacks.test.ts +9 -1
  62. package/src/shared/lib/chat/timeline/omp-callbacks.ts +45 -8
  63. package/src/shared/lib/omp/session/stream-state.server.ts +2 -3
  64. package/src/shared/lib/workspace/session-state/store.ts +1 -4
  65. package/src/shared/lib/workspace/terminal/protocol.ts +222 -0
  66. package/src/shared/types/omp/agent.ts +12 -0
  67. package/src/shared/types/terminal.ts +17 -15
  68. package/src/shared/types/workspace.ts +2 -2
  69. package/dist/client/static/js/async/g.d1c2fe09aa.js +0 -2
  70. package/dist/client/static/js/async/x4.69ec69c61b.js +0 -6
  71. package/src/client/components/workspace/terminal-panel/InputBar.tsx +0 -82
  72. package/src/client/components/workspace/terminal-panel/LogEntry.tsx +0 -70
  73. package/src/client/hooks/workspace/terminal-output.ts +0 -66
  74. package/src/client/hooks/workspace/terminal.ts +0 -283
  75. package/src/server/lib/fs/terminal-cwd.ts +0 -49
  76. package/src/server/routes/terminal/stream.ts +0 -100
  77. /package/dist/client/static/js/async/{g.d1c2fe09aa.js.LICENSE.txt → g.a06ca3b3e9.js.LICENSE.txt} +0 -0
  78. /package/dist/client/static/js/async/{m.0896dab823.js.LICENSE.txt → m.c038c71b9f.js.LICENSE.txt} +0 -0
  79. /package/dist/client/static/js/{index.dc5f5fabe8.js.LICENSE.txt → index.0de15c5e17.js.LICENSE.txt} +0 -0
@@ -1,19 +1,21 @@
1
- export interface TerminalLogItem {
2
- id: string;
3
- command: string;
4
- stdout?: string;
5
- stderr?: string;
6
- exitCode: number;
7
- durationMs?: number;
8
- timestamp: string;
9
- cwd?: string;
1
+ /**
2
+ * Live terminal inventory, as served by `GET /api/terminal/sessions`.
3
+ *
4
+ * The frame types themselves live in `@/shared/lib/workspace/terminal/protocol`
5
+ * — they are the wire contract the socket encodes and decodes, not domain data.
6
+ */
7
+
8
+ import type { TerminalSnapshot } from '@/shared/lib/workspace/terminal/protocol';
9
+
10
+ export interface TerminalSessionsResponse {
11
+ terminals: TerminalSnapshot[];
10
12
  }
11
13
 
12
- export interface TerminalRunResponse {
13
- stdout: string;
14
- stderr: string;
15
- exitCode: number;
16
- durationMs: number;
14
+ /** Launch context for the terminal header (`GET /api/terminal/run`). */
15
+ export interface TerminalContextResponse {
16
+ bunVersion: string;
17
+ nodeVersion: string;
18
+ gitBranch: string;
17
19
  cwd: string;
18
- error?: string;
20
+ relativePath: string;
19
21
  }
@@ -15,8 +15,8 @@ export interface SessionItemData {
15
15
  hasSubagents?: boolean;
16
16
  subagentCount?: number;
17
17
  /** Server-tracked stream state: `stream` while a run is in flight, then a
18
- * one-shot `finish`/`abort`/`error` badge cleared when the session opens. */
19
- streamStatus?: 'stream' | 'finish' | 'abort' | 'error';
18
+ * one-shot `finish`/`abort` badge cleared when the session opens. */
19
+ streamStatus?: 'stream' | 'finish' | 'abort';
20
20
  /** Live-only: the session's omp process is BLOCKED on an ask/approval dialog
21
21
  * waiting for a user answer. Derived from the running process registry, never
22
22
  * persisted — the process it describes is the same thing that owns the flag. */
@@ -1,2 +0,0 @@
1
- /*! LICENSE: g.d1c2fe09aa.js.LICENSE.txt */
2
- "use strict";(self.rspackChunkompchamber=self.rspackChunkompchamber||[]).push([["g"],{Wh(e,t,n){n.d(t,{MobileLayoutWrapper:()=>eJ});var i=n("j"),s=n("H"),a=n("s"),l=n("NO"),r=n("y");let o=(0,r.A)({name:"menu",size:24,node:[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]});var c=n("Go"),d=n("r"),p=n("z"),h=n("se"),m=n("oj"),x=n("SS"),f=n("A9"),u=n("FE"),b=n("R2"),g=n("U8");function k(e){let{activeSessionTitle:t,activeSessionId:n,onOpenSessionSidebar:a,onOpenRightSidebar:l,onNewSession:r,onSelectSession:k}=e,{folders:v}=(0,f.k)(),N=(0,u.H)(),[Y,w]=(0,s.J0)(!1),[y,S]=(0,s.J0)(!1),[F,D]=(0,s.J0)(null),C=(0,s.li)(null);(0,m.W)(C,()=>w(!1));let A=(0,s.li)(null);(0,m.W)(A,()=>S(!1)),(0,s.vJ)(()=>{if(!n)return void D(null);let e=!1;return fetch(`/api/telemetry/context?sessionId=${encodeURIComponent(String(n))}`).then(e=>e.ok?e.json():null).then(t=>{e||D(t?.telemetry??null)}).catch(()=>{e||D(null)}),()=>{e=!0}},[n]);let z=(0,s.Kr)(()=>{let e=Date.now(),t=[];for(let n of v)for(let i of n.sessions??[]){if(1===i.is_archived)continue;let s=(0,x.R7)(String(i.id)),a=i.updated_at?Date.parse(i.updated_at):0,l=void 0!==s&&e-s<=6e5?s:a;void 0!==s&&e-s>6e5||t.push({id:i.id,title:i.title,folderName:n.name,modified:l})}return t.sort((e,t)=>t.modified-e.modified).slice(0,10)},[v]),j=t?t.charAt(0).toUpperCase()+t.slice(1):"New session";return(0,i.FD)("header",{className:"flex-shrink-0 bg-canvas border-b border-ink/10 flex items-center justify-between px-3 z-20 titlebar-drag-region select-none",style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px), env(titlebar-area-x, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px), calc(100vw - env(titlebar-area-width, 100vw)))",paddingTop:"env(safe-area-inset-top, 0px)"},children:[(0,i.FD)("div",{className:"flex items-center space-x-2 min-w-0 titlebar-no-drag",children:[(0,i.Y)("button",{type:"button",onClick:a,className:"p-1.5 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0",title:"Open Sessions","aria-label":"Open Sessions",children:(0,i.Y)(o,{size:20,strokeWidth:2})}),(0,i.FD)("span",{className:"relative font-bold text-sm tracking-tight flex items-center flex-shrink-0",children:[(0,i.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,i.Y)("span",{className:"ml-[1px] text-ink",children:"Chamber"}),(0,i.Y)("span",{className:"absolute -top-0.5 -right-1.5 flex",children:(0,i.Y)(b.c,{status:N})})]}),(0,i.Y)("span",{className:"text-ink/25 font-light text-xs flex-shrink-0 select-none",children:"/"}),(0,i.FD)("div",{className:"relative min-w-0",ref:C,children:[(0,i.FD)("button",{type:"button",onClick:()=>w(!Y),className:"flex items-center space-x-1 text-xs font-semibold text-ink hover:text-ink/80 transition-colors py-1 max-w-[150px] min-w-0",title:j,children:[(0,i.Y)("span",{className:"truncate",children:j}),(0,i.Y)(c.A,{size:13,className:"text-ink/50 flex-shrink-0"})]}),Y&&(0,i.FD)("div",{className:"fixed z-50 bg-paper border border-ink/15 rounded-xl shadow-lg p-2 text-xs",style:{top:"calc(3.5rem + env(safe-area-inset-top, 0px) + 0.375rem)",left:"max(0.75rem, env(safe-area-inset-left, 0px))",right:"max(0.75rem, env(safe-area-inset-right, 0px))",maxWidth:"18rem",maxHeight:"calc(100dvh - 3.5rem - env(safe-area-inset-top, 0px) - 1.125rem)",overflowY:"auto"},children:[(0,i.FD)("button",{type:"button",onClick:()=>{r(),w(!1)},className:"w-full text-left px-3 py-2 rounded-lg bg-ink text-canvas flex items-center space-x-2 font-medium mb-1.5 active:scale-98",children:[(0,i.Y)(d.A,{size:14}),(0,i.Y)("span",{children:"Start New Session"})]}),(0,i.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40",children:"Recent Sessions"}),(0,i.Y)("div",{className:"max-h-64 scrollbar-overlay-container scrollbar-overlay-static space-y-0.5",children:0===z.length?(0,i.Y)("div",{className:"px-2.5 py-2 text-ink/40 italic",children:"No sessions yet"}):z.map(e=>(0,i.FD)("button",{type:"button",onClick:()=>{k(e.id),w(!1)},className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between space-x-2 transition-colors ${String(n)===String(e.id)?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[(0,i.FD)("span",{className:"min-w-0 flex flex-col",children:[(0,i.Y)("span",{className:"truncate",children:e.title?e.title.charAt(0).toUpperCase()+e.title.slice(1):"Untitled"}),(0,i.Y)("span",{className:"truncate text-[10px] text-ink/40 font-mono",children:e.folderName})]}),String(n)===String(e.id)&&(0,i.Y)(p.A,{size:12,className:"flex-shrink-0"})]},e.id))})]})]})]}),(0,i.FD)("div",{className:"flex items-center space-x-1 text-ink",children:[(0,i.FD)("div",{className:"relative flex items-center",ref:A,children:[(0,i.Y)("button",{type:"button",onClick:()=>S(!y),className:"w-8 h-8 rounded-lg hover:bg-ink/5 active:bg-ink/10 flex items-center justify-center text-ink transition-colors cursor-pointer",title:"Context usage","aria-label":"Context usage",children:(0,i.Y)("span",{className:"w-4 h-4 rounded-full border-[1.5px] border-ink/60 hover:border-ink transition-colors"})}),y&&(0,i.FD)("div",{className:"absolute top-full right-0 mt-2 w-56 bg-paper border border-ink/20 rounded-xl shadow-xl z-50 p-3 text-xs font-mono",children:[(0,i.FD)("div",{className:"font-semibold text-ink font-sans pb-1.5 border-b border-ink/10 flex items-center justify-between",children:[(0,i.Y)("span",{children:"Context"}),F&&F.messagesCount>0&&(0,i.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"})]}),F&&0!==F.messagesCount?(0,i.FD)("div",{className:"pt-2 space-y-1.5 text-[11px] text-ink/80",children:[(0,i.FD)("div",{className:"flex justify-between gap-2",children:[(0,i.Y)("span",{className:"text-ink/50",children:"Model:"}),(0,i.Y)("span",{className:"truncate",children:F.modelName||"—"})]}),(0,i.FD)("div",{className:"flex justify-between",children:[(0,i.Y)("span",{className:"text-ink/50",children:"Context:"}),(0,i.FD)("span",{children:[(0,g.Rk)(F.contextUsed)??"0"," / ",(0,g.Rk)(F.contextLimit)??"0"," (",F.contextPercent,"%)"]})]}),(0,i.FD)("div",{className:"flex justify-between",children:[(0,i.Y)("span",{className:"text-ink/50",children:"Messages:"}),(0,i.Y)("span",{children:F.messagesCount})]}),(0,i.FD)("div",{className:"flex justify-between",children:[(0,i.Y)("span",{className:"text-ink/50",children:"Cost:"}),(0,i.Y)("span",{children:F.costFormatted})]}),"number"==typeof F.cacheHitAverage&&(0,i.FD)("div",{className:"flex justify-between",children:[(0,i.Y)("span",{className:"text-ink/50",children:"Cache hit:"}),(0,i.FD)("span",{children:[F.cacheHitAverage.toFixed(1),"%"]})]})]}):(0,i.Y)("div",{className:"pt-2 text-[11px] text-ink/50 italic font-sans",children:"Session not started"})]})]}),(0,i.Y)("button",{type:"button",onClick:l,className:"w-8 h-8 rounded-lg hover:bg-ink/5 active:bg-ink/10 flex items-center justify-center text-ink transition-colors cursor-pointer",title:"Right Panel","aria-label":"Open Right Panel",children:(0,i.Y)(h.A,{size:18,strokeWidth:1.8})})]})]})}var v=n("d");function N(e){let{activeSessionId:t,onSelectSession:n,onNewSession:a,onOpenSessionSidebar:l,onOpenRightSidebar:r,appSettings:o={}}=e,{folders:c}=(0,f.k)(),[d,p]=(0,s.J0)(null),h=(0,s.Kr)(()=>{if(!t)return"New session";for(let e of c){let n=e.sessions?.find(e=>String(e.id)===String(t));if(n)return n.title}return null},[t,c]);return(0,i.FD)("div",{className:"flex flex-col h-full w-full bg-canvas text-ink relative",children:[(0,i.Y)(k,{activeSessionTitle:d||h||"New session",activeSessionId:t,onOpenSessionSidebar:l,onOpenRightSidebar:r,onNewSession:a,onSelectSession:n}),(0,i.Y)("div",{className:"flex-1 min-h-0",children:(0,i.Y)(v.E,{appSettings:o,onSessionTitle:p,variant:"mobile"})})]})}var Y=n("S");function w(e){let{onClose:t}=e;return(0,i.FD)("div",{className:"border-b border-ink/10 flex items-center justify-between px-3.5 flex-shrink-0 bg-canvas titlebar-drag-region select-none",style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingLeft:"max(0.875rem, env(safe-area-inset-left, 0px), env(titlebar-area-x, 0px))",paddingRight:"max(0.875rem, env(safe-area-inset-right, 0px))",paddingTop:"env(safe-area-inset-top, 0px)"},children:[(0,i.FD)("div",{className:"flex items-center space-x-2.5 titlebar-no-drag",children:[(0,i.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,i.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[16px] tracking-tighter",children:"OMP"}),(0,i.Y)("span",{className:"ml-[1px] text-ink font-bold text-sm",children:"Chamber"})]}),(0,i.Y)("span",{className:"text-ink/25 text-xs select-none",children:"/"}),(0,i.Y)("span",{className:"text-[11px] font-semibold text-ink/60 uppercase tracking-wider font-mono",children:"Sessions"})]}),(0,i.Y)("button",{type:"button",onClick:t,className:"w-9 h-9 rounded-xl hover:bg-ink/5 active:bg-ink/10 text-ink flex items-center justify-center transition-colors cursor-pointer titlebar-no-drag",title:"Close sidebar","aria-label":"Close sidebar",children:(0,i.Y)(Y.A,{size:19,strokeWidth:2})})]})}var y=n("D"),S=n("O");let F=(0,r.A)({name:"arrow-up-down",size:24,node:[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]});var D=n("p7"),C=n("t3"),A=n("E");function z(e){let{searchQuery:t,sortOption:n,optionsOpen:s,showArchived:a,optionsRef:l,onNewSession:r,onNewWorkspace:o,onScheduler:c,onToggleOptions:h,onSortChange:m,onResetSort:x,onToggleArchived:f,onHideArchived:u,onSearchChange:b,onClearSearch:g}=e;return(0,i.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2.5 flex-shrink-0 bg-canvas",children:[(0,i.FD)("div",{className:"flex items-center space-x-2",children:[(0,i.FD)("button",{type:"button",onClick:r,className:"flex-1 h-9.5 flex items-center justify-center space-x-2 px-3.5 rounded-xl bg-ink text-canvas hover:bg-ink/90 active:scale-[0.98] text-xs font-semibold transition-all shadow-xs",children:[(0,i.Y)(d.A,{size:15,strokeWidth:2.4}),(0,i.Y)("span",{children:"New Session"})]}),(0,i.Y)("button",{type:"button",onClick:o,className:"w-9.5 h-9.5 rounded-xl border border-ink/15 bg-paper hover:bg-ink/5 active:scale-95 text-ink/80 hover:text-ink flex items-center justify-center transition-all flex-shrink-0 cursor-pointer shadow-xs",title:"New Workspace","aria-label":"New Workspace",children:(0,i.Y)(y.A,{size:16,strokeWidth:1.8})}),(0,i.Y)("button",{type:"button",onClick:c,className:"w-9.5 h-9.5 rounded-xl border border-ink/15 bg-paper hover:bg-ink/5 active:scale-95 text-ink/80 hover:text-ink flex items-center justify-center transition-all flex-shrink-0 cursor-pointer shadow-xs",title:"Schedule Task","aria-label":"Schedule Task",children:(0,i.Y)(S.A,{size:16,strokeWidth:1.8})}),(0,i.FD)("div",{className:"relative flex-shrink-0",ref:l,children:[(0,i.Y)("button",{type:"button",onClick:h,className:`w-9.5 h-9.5 rounded-xl border active:scale-95 flex items-center justify-center transition-all cursor-pointer shadow-xs ${s||"A-Z"!==n||a?"bg-ink/10 text-ink border-ink/30":"border-ink/15 bg-paper hover:bg-ink/5 text-ink/80 hover:text-ink"}`,title:"Sort & Filter","aria-label":"Sort & Filter",children:(0,i.Y)(F,{size:15,strokeWidth:1.8})}),s&&(0,i.FD)("div",{className:"absolute right-0 top-full mt-2 w-52 bg-paper border border-ink/15 rounded-xl shadow-xl z-50 p-2 text-xs",children:[(0,i.Y)(A.i,{variant:"mobile",sortOption:n,onSortChange:m}),(0,i.Y)("div",{className:"border-t border-ink/10 my-1.5"}),(0,i.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Filter"}),(0,i.FD)("button",{type:"button",onClick:f,className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${a?"bg-amber-500/15 text-amber-950 font-semibold":"hover:bg-ink/5 text-ink/80"}`,children:[(0,i.FD)("span",{className:"flex items-center space-x-1.5",children:[(0,i.Y)(D.A,{size:13}),(0,i.Y)("span",{children:"Show Archived"})]}),a&&(0,i.Y)(p.A,{size:13})]})]})]})]}),(0,i.FD)("div",{className:"relative flex items-center",children:[(0,i.Y)(C.A,{size:14,className:"absolute left-3 text-ink/40"}),(0,i.Y)("input",{type:"text",value:t,onChange:e=>b(e.currentTarget.value),placeholder:"Search workspaces & sessions...",className:"w-full bg-paper border border-ink/15 rounded-xl pl-8 pr-8 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),t&&(0,i.Y)("button",{type:"button",onClick:g,className:"absolute right-2.5 text-ink/40 hover:text-ink p-1","aria-label":"Clear search",children:(0,i.Y)(Y.A,{size:13})})]}),(a||"A-Z"!==n)&&(0,i.FD)("div",{className:"flex items-center space-x-1.5 flex-wrap gap-y-1 pt-0.5",children:["A-Z"!==n&&(0,i.FD)("span",{className:"inline-flex items-center space-x-1 bg-ink/5 border border-ink/10 text-ink/80 rounded-lg px-2 py-0.5 text-[10px] font-mono",children:[(0,i.FD)("span",{children:["Sort: ",n.replace("_"," ")]}),(0,i.Y)("button",{type:"button",onClick:x,className:"hover:text-ink ml-0.5",title:"Reset sort",children:(0,i.Y)(Y.A,{size:10})})]}),a&&(0,i.FD)("span",{className:"inline-flex items-center space-x-1 bg-amber-500/15 border border-amber-500/25 text-amber-900 rounded-lg px-2 py-0.5 text-[10px] font-mono",children:[(0,i.Y)(D.A,{size:10}),(0,i.Y)("span",{children:"Archived"}),(0,i.Y)("button",{type:"button",onClick:u,className:"hover:text-amber-950 ml-0.5",title:"Hide archived",children:(0,i.Y)(Y.A,{size:10})})]})]})]})}var j=n("qn"),T=n("vZ"),O=n("Sj"),W=n("Nf"),P=n("t"),R=n("b"),$=n("HZ"),E=n("P6");function J(e){let{session:t,isActive:n,status:s,timeAgo:a,showTreeGlyph:l=!1,onSelect:r,onArchive:o,onRename:c}=e,{isEditing:d,draft:h,setDraft:m,inputRef:x,startRename:f,handleKeyDown:u,handleBlur:b}=(0,E.B)(t.title,c);return d?(0,i.Y)("div",{className:"w-full rounded-lg flex items-center bg-ink/10",children:(0,i.Y)("input",{ref:x,autoFocus:!0,value:h,onChange:e=>m(e.currentTarget.value),onKeyDown:u,onBlur:b,className:"flex-1 min-w-0 mx-2 my-1.5 bg-paper border border-ink/25 rounded px-2 py-1 text-xs text-ink outline-none focus:border-ink/50"})}):(0,i.FD)("div",{className:`w-full rounded-lg flex items-center transition-colors ${n?"bg-ink/10 font-medium text-ink":"hover:bg-ink/5 text-ink/85"}`,children:[(0,i.FD)("button",{type:"button",onClick:r,className:"flex-1 text-left px-3 py-2 flex items-center justify-between min-w-0",children:[(0,i.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 pr-2",children:[(0,i.FD)("span",{className:"w-4 flex-shrink-0 flex items-center justify-center",children:["stream"===s&&(0,i.Y)(P.A,{size:13,className:"text-ink/50 animate-spin"}),("finish"===s||"abort"===s||"error"===s)&&(0,i.Y)(p.A,{size:13,className:"text-ink/50"})]}),l&&(0,i.Y)("span",{className:"text-ink/40 text-xs flex-shrink-0 font-mono",children:">"}),(0,i.Y)("span",{className:"text-xs truncate leading-snug",children:t.title.charAt(0).toUpperCase()+t.title.slice(1)})]}),(0,i.Y)("span",{className:"text-[11px] text-ink/45 font-mono flex-shrink-0 ml-2",children:a??""})]}),c&&(0,i.Y)("button",{type:"button",onClick:f,title:"Rename session",className:"flex-shrink-0 p-2 text-ink/35 hover:text-ink rounded-lg cursor-pointer",children:(0,i.Y)(R.A,{size:14})}),(0,i.Y)("button",{type:"button",onClick:o,title:1===t.is_archived?"Unarchive session":"Archive session",className:"flex-shrink-0 p-2 mr-1 text-ink/35 hover:text-ink rounded-lg cursor-pointer",children:1===t.is_archived?(0,i.Y)($.A,{size:14}):(0,i.Y)(D.A,{size:14})})]})}var M=n("C4"),U=n("NR"),I=n("U"),L=n("A");function H(e){let{folder:t,activeSessionId:n,onSelectSession:a,isExpanded:l,onToggleExpand:r,showArchived:o=!1,sessionStatus:d={}}=e,{visibleCount:p,showMore:h}=(0,U.y)(),{refresh:x}=(0,f.k)(),[u,b]=(0,s.J0)(!1),g=(0,s.li)(null),{confirmDelete:k,requestDelete:v,cancelDelete:N,handlePin:Y,handleDelete:w,handleArchive:y,handleRename:S}=(0,I.C)(t,x);(0,m.W)(g,()=>{b(!1),N()});let F=(t.sessions||[]).filter(e=>o?1===e.is_archived:1!==e.is_archived),D=F.slice(0,p),C=(0,L.x)(t.icon);return(0,i.FD)("div",{className:"mb-4",children:[(0,i.FD)("div",{onClick:r,className:"flex items-center justify-between px-3 py-2 cursor-pointer hover:bg-ink/5 rounded-lg select-none transition-colors",children:[(0,i.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[t.customIconUrl?(0,i.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):"chat"===t.iconType?(0,i.Y)(j.A,{size:15,className:"text-ink/80 flex-shrink-0"}):(0,i.Y)(C,{size:15,className:"text-ink/80 flex-shrink-0",style:{color:t.accentColor||void 0}}),(0,i.Y)("span",{className:"text-sm font-semibold text-ink truncate",children:t.name})]}),(0,i.FD)("div",{className:"flex items-center space-x-2 text-xs text-ink/60",children:[(0,i.Y)("span",{className:"font-mono text-[11px] text-ink/70",children:F.length}),t.project_path&&(0,i.Y)(T.A,{size:13,className:"text-ink/50 ml-1"}),(0,i.FD)("div",{className:"relative flex items-center",ref:g,onClick:e=>e.stopPropagation(),children:[(0,i.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),b(e=>!e)},className:"p-1.5 rounded-lg hover:bg-ink/10 active:bg-ink/15 text-ink/60 hover:text-ink",title:"Workspace options","aria-label":`Options for ${t.name}`,children:(0,i.Y)(O.A,{size:15})}),u&&(0,i.Y)("div",{className:"absolute right-0 top-full mt-1 w-48 bg-paper border border-ink/15 rounded-lg shadow-lg z-50 py-1 text-xs",children:(0,i.Y)(M.t,{variant:"mobile",isPinned:t.isPinned,confirmDelete:k,onPin:()=>{Y(),b(!1)},onDelete:()=>{w(),b(!1)},onRequestDelete:v,onCancelDelete:N})})]}),l?(0,i.Y)(c.A,{size:14}):(0,i.Y)(W.A,{size:14})]})]}),l&&(0,i.FD)("div",{className:"mt-0.5 space-y-0.5 pl-2",children:[D.map(e=>(0,i.Y)(J,{session:e,isActive:String(n)===String(e.id),status:d[String(e.id)],timeAgo:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(null==e||""===e)return null;let n="number"==typeof e?e:Date.parse(e);if(Number.isNaN(n))return null;let i=Math.round((t-n)/1e3);if(i<45)return"now";let s=Math.round(i/60);if(s<60)return`${s}m`;let a=Math.round(s/60);if(a<24)return`${a}h`;let l=Math.round(a/24);if(l<7)return`${l}d`;let r=Math.round(l/7);if(r<5)return`${r}w`;let o=new Date(n),c=o.getFullYear()===new Date(t).getFullYear(),d=o.getDate(),p=o.toLocaleString("en-US",{month:"short"});return c?`${d} ${p}`:`${d} ${p} ${o.getFullYear()}`}(e.updated_at??e.created_at),onSelect:()=>a(e.id),onArchive:()=>y(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void S(e,t)},e.id)),F.length>p&&(0,i.FD)("button",{type:"button",onClick:h,className:"w-full text-left px-3 py-2 text-xs text-ink/60 hover:text-ink flex items-center space-x-1.5",children:[(0,i.Y)(c.A,{size:12,className:"w-4 flex-shrink-0"}),(0,i.FD)("span",{children:["Show more sessions (",F.length-p,")"]})]})]})]})}var K=n("jo");function B(e){let{folders:t,activeSessionId:n,expandedFolders:s,showArchived:a,sessionStatus:l,isScrolling:r,onScroll:o,onSelectSession:c,onToggleFolder:d}=e;return(0,i.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-3 ${(0,K.p)(r)}`,children:0===t.length?(0,i.Y)("div",{className:"text-center py-12 text-xs text-ink/50 italic",children:"No matching sessions found"}):t.map(e=>(0,i.Y)(H,{folder:e,activeSessionId:n,onSelectSession:c,isExpanded:s[e.id]??!0,onToggleExpand:()=>d(e.id),showArchived:a,sessionStatus:l},e.id))})}var _=n("vB"),Z=n("wU"),G=n("mX"),q=n("P");function V(e){let{onSettings:t,onAbout:n,updateAvailable:s,onUpdateClick:a,onDesktopToggle:l}=e;return(0,i.FD)("div",{className:"px-3 pt-3 border-t border-ink/10 flex items-center justify-between flex-shrink-0 bg-canvas text-xs text-ink/60",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"},children:[(0,i.FD)("div",{className:"flex items-center space-x-3",children:[(0,i.FD)("button",{type:"button",onClick:t,className:"flex items-center space-x-1 hover:text-ink transition-colors",children:[(0,i.Y)(_.A,{size:14}),(0,i.Y)("span",{children:"Settings"})]}),(0,i.FD)("button",{type:"button",onClick:n,className:"flex items-center space-x-1 hover:text-ink transition-colors",children:[(0,i.Y)(Z.A,{size:14}),(0,i.Y)("span",{children:"About"})]}),l&&(0,i.FD)("button",{type:"button",onClick:l,className:"flex items-center space-x-1 hover:text-ink transition-colors",title:"Switch to desktop view",children:[(0,i.Y)(G.A,{size:14}),(0,i.Y)("span",{children:"Desktop"})]})]}),(0,i.FD)("div",{className:"flex items-center gap-2",children:[(0,i.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:["v",q.rE]}),s&&(0,i.Y)("button",{type:"button",onClick:a,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})]})}var X=n("wu"),Q=n("g"),ee=n("oZ"),et=n("DO"),en=n("z4");let ei=[3,2];function es(){return(0,i.Y)("div",{className:"flex-1 p-3 space-y-4","aria-hidden":"true",children:ei.map((e,t)=>(0,i.FD)("div",{className:"space-y-2",children:[(0,i.FD)("div",{className:"flex items-center gap-2 px-1 py-2",children:[(0,i.Y)("span",{className:"w-4 h-4 rounded-sm animate-pulse bg-ink/10"}),(0,i.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,i.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-2",children:[(0,i.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,i.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}function ea(e){let{activeSessionId:t,onSelectSession:n,onNewSession:a,onCreateFolder:l,onClose:r,onDesktopToggle:o,appSettings:c={}}=e,{folders:d,initializing:p,searchQuery:h,setSearchQuery:x,showArchived:f,setShowArchived:u,optionsOpen:b,setOptionsOpen:g,sortOption:k,handleSortChange:v,processedFolders:N,sessionStatus:Y,handleSelectSession:y}=(0,en.K)(c,{onSelectSession:n,onAfterSelect:r}),[S,F]=(0,s.J0)({1:!0,2:!0,3:!0}),[D,C]=(0,s.J0)(!1),[A,j]=(0,s.J0)(!1),[T,O]=(0,s.J0)(!1),W=(0,et.M)(),{toasts:P,pushToast:R,dismissToast:$}=(0,ee.Y)(),E=(0,s.li)(null);(0,m.W)(E,()=>g(!1));let{isScrolling:J,handleScroll:M}=(0,K.K)();return(0,s.vJ)(()=>{F(Object.fromEntries(d.map(e=>[e.id,e.isExpanded])))},[d]),(0,i.FD)("div",{className:"flex flex-col h-full w-full bg-canvas text-ink relative select-none",children:[(0,i.Y)(w,{onClose:r}),(0,i.Y)(z,{searchQuery:h,sortOption:k,optionsOpen:b,showArchived:f,optionsRef:E,onNewSession:()=>{a(),r()},onNewWorkspace:()=>C(!0),onScheduler:()=>j(!0),onToggleOptions:()=>g(!b),onSortChange:v,onResetSort:()=>v("A-Z"),onToggleArchived:()=>{u(!f),g(!1)},onHideArchived:()=>u(!1),onSearchChange:x,onClearSearch:()=>x("")}),p?(0,i.Y)(es,{}):(0,i.Y)(B,{folders:N,activeSessionId:t,expandedFolders:S,showArchived:f,sessionStatus:Y,isScrolling:J,onScroll:M,onSelectSession:y,onToggleFolder:e=>{F(t=>({...t,[e]:!t[e]}));let t=d.find(t=>t.id===e),n=!(S[e]??t?.isExpanded??!0);fetch(`/api/folders/${e}/toggle`,{method:"POST",body:new URLSearchParams({isExpanded:String(n)})}).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status}`);window.dispatchEvent(new CustomEvent("omp:workspace-updated",{detail:{folderId:e}}))}).catch(e=>{console.error("Failed to save mobile workspace state:",e)})}}),(0,i.Y)(V,{onSettings:()=>window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{}})),onAbout:()=>O(!0),onDesktopToggle:o,updateAvailable:W.hasUpdate,onUpdateClick:()=>{O(!0),W.check()}}),(0,i.Y)(Q.xV,{isOpen:D,onClose:()=>C(!1),onCreate:l}),(0,i.Y)(Q.Lo,{isOpen:A,onClose:()=>j(!1)}),(0,i.Y)(Q.VT,{isOpen:T,onClose:()=>O(!1),updates:W,onToast:R}),(0,i.Y)(X.y,{toasts:P,onDismiss:$})]})}var el=n("G"),er=n("oE"),eo=n("Asb"),ec=n("N"),ed=n("Oj"),ep=n("lW"),eh=n("SJ"),em=n("nG"),ex=n("so"),ef=n("ET");let eu={context:{title:"Context & Telemetry",label:"Context",icon:(0,i.Y)(er.A,{size:14,className:"flex-shrink-0"})},files:{title:"Files Explorer",label:"Files",icon:(0,i.Y)(eo.A,{size:14,className:"flex-shrink-0"})},search:{title:"Search Workspace",label:"Search",icon:(0,i.Y)(C.A,{size:14,className:"flex-shrink-0"})},git:{title:"GIT",label:"GIT",icon:(0,i.Y)(T.A,{size:14,className:"flex-shrink-0"})},terminal:{title:"Bun Terminal",label:"Terminal",icon:(0,i.Y)(ec.A,{size:14,className:"flex-shrink-0"})},"user-browser":{title:"Browser (Anda)",label:"Browser",icon:(0,i.Y)(ed.A,{size:14,className:"flex-shrink-0"})},browser:{title:"Browser Agent",label:"Agent",icon:(0,i.Y)(ep.A,{size:14,className:"flex-shrink-0"})},usage:{title:"Usage",label:"Usage",icon:(0,i.Y)(eh.A,{size:14,className:"flex-shrink-0"})}};function eb(e){let{enabled:t=!0,rootPath:n,refreshKey:a=0,onRefresh:l,onOpenFile:r,onClose:o}=e,[c,d]=(0,s.J0)("files"),{changes:p}=(0,ex.e)(n,".",a,t,15e3),h=p.length>0;return(0,i.FD)("div",{className:"flex flex-col h-full w-full bg-paper text-ink relative select-none",children:[(0,i.FD)("div",{className:"border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0 bg-canvas",style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px))"},children:[(0,i.Y)("div",{className:"flex items-center space-x-1.5 overflow-x-auto no-scrollbar py-1",children:ef.G7.map(e=>(0,i.FD)("button",{type:"button",onClick:()=>d(e),className:`relative flex items-center transition-all cursor-pointer ${c===e?"space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold bg-ink text-canvas shadow-sm":"p-2 rounded-lg text-ink/70 hover:bg-ink/5"}`,title:eu[e].title,children:[eu[e].icon,c===e&&(0,i.Y)("span",{className:"git"===e?"tracking-wide":void 0,children:eu[e].label}),"git"===e&&h&&(0,i.Y)("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-info",title:"Uncommitted changes"})]},e))}),(0,i.Y)("button",{type:"button",onClick:o,className:"p-1.5 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0 ml-2",title:"Close right sidebar","aria-label":"Close right sidebar",children:(0,i.Y)(Y.A,{size:20,strokeWidth:1.8})})]}),(0,i.Y)("div",{className:"flex-1 min-h-0 overflow-hidden relative",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:t?(0,i.Y)(i.FK,{children:(0,i.FD)(el.tY,{fallback:(0,i.Y)("div",{className:"h-full flex items-center justify-center text-ink/40",children:(0,i.Y)("span",{className:"text-xs font-mono",children:"Loading…"})}),children:["files"===c&&(0,i.Y)(em.gI,{className:"h-full w-full",enabled:t,rootPath:n,refreshKey:a,onRefresh:l,onOpenFile:r}),"search"===c&&(0,i.Y)(em.N1,{className:"h-full w-full",enabled:t,rootPath:n}),"git"===c&&(0,i.Y)(em.nR,{className:"h-full w-full",enabled:t,rootPath:n,refreshKey:a}),"context"===c&&(0,i.Y)(em.ov,{className:"h-full w-full",enabled:t,refreshKey:a,onClose:o}),"terminal"===c&&(0,i.Y)(em.Bz,{className:"h-full w-full",enabled:t,rootPath:n,showHeader:!1}),"user-browser"===c&&(0,i.Y)(em.M,{className:"h-full w-full"}),"browser"===c&&(0,i.Y)(em.XL,{className:"h-full w-full",active:!0}),"usage"===c&&(0,i.Y)(em.WE,{className:"h-full w-full"})]})}):(0,i.Y)("div",{className:"h-full flex items-center justify-center text-ink/40",children:(0,i.Y)("span",{className:"text-xs font-mono",children:"No session selected"})})})]})}var eg=n("E6"),ek=n("vp"),ev=n("uf"),eN=n("Kv"),eY=n("Soe"),ew=n("bH"),ey=n("yh"),eS=n("hj"),eF=n("na"),eD=n("b0"),eC=n("tC"),eA=n("ob");function ez(e){let{fileName:t,isMarkdown:n,isPreview:s,wordWrap:a,copied:l,onClose:r,onTogglePreview:o,onToggleWrap:c,onZoomOut:d,onZoomIn:h,onCopy:m,onDownload:x}=e;return(0,i.FD)("header",{className:"bg-canvas border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0",style:{height:"calc(3rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px))"},children:[(0,i.FD)("div",{className:"flex items-center space-x-2 min-w-0 pr-2",children:[(0,i.Y)("button",{type:"button",onClick:r,className:"p-1.5 rounded-lg hover:bg-ink/10 text-ink transition-colors active:scale-90 flex-shrink-0 cursor-pointer",title:"Close editor","aria-label":"Close editor",children:(0,i.Y)(eN.A,{size:18,strokeWidth:2})}),(0,i.FD)("div",{className:"flex items-center space-x-1.5 truncate",children:[(0,i.Y)(eA.o,{name:t,size:15,className:"flex-shrink-0"}),(0,i.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t})]})]}),(0,i.FD)("div",{className:"flex items-center space-x-1 text-ink/70 flex-shrink-0",children:[n&&(0,i.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"bg-ink text-canvas":""}`,title:s?"View code":"Preview markdown",children:s?(0,i.Y)(eY.A,{size:15}):(0,i.Y)(ew.A,{size:15})}),(0,i.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${a?"text-ink":""}`,title:"Toggle word wrap",children:(0,i.Y)(ey.A,{size:15})}),(0,i.Y)("button",{type:"button",onClick:d,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Decrease font size",children:(0,i.Y)(eS.A,{size:15})}),(0,i.Y)("button",{type:"button",onClick:h,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Increase font size",children:(0,i.Y)(eF.A,{size:15})}),(0,i.Y)("button",{type:"button",onClick:m,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Copy content",children:l?(0,i.Y)(p.A,{size:15,className:"text-success"}):(0,i.Y)(eD.A,{size:15})}),(0,i.Y)("button",{type:"button",onClick:x,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Download file",children:(0,i.Y)(eC.A,{size:15})})]})]})}var ej=n("XY");function eT(e){let{file:t,onClose:n,onFileSaved:a}=e,[l,r]=(0,s.J0)(t.name.endsWith(".md")),[o,c]=(0,s.J0)(12),[d,p]=(0,s.J0)(!0),{isScrolling:h,handleScroll:m}=(0,K.K)(),x=t.name.endsWith(".md"),f=(0,ej.n)(t,{reportLoadError:!0,flushOnUnmount:!0,reportSaveError:!0,downloadMimeType:"text/plain;charset=utf-8",onFileSaved:a}),u=f.content,b=f.language,g=u.split("\n").length;return(0,i.FD)("div",{className:"fixed inset-x-0 top-0 h-dvh z-[60] bg-paper flex flex-col font-mono text-xs select-none",children:[(0,i.Y)(ez,{fileName:t.name,isMarkdown:x,isPreview:l,wordWrap:d,copied:f.copied,onClose:n,onTogglePreview:()=>r(!l),onToggleWrap:()=>p(!d),onZoomOut:()=>c(e=>Math.max(10,e-1)),onZoomIn:()=>c(e=>Math.min(18,e+1)),onCopy:f.copy,onDownload:f.download}),(0,i.Y)("div",{onScroll:m,className:`flex-1 min-h-0 overflow-auto relative bg-paper text-ink select-text ${(0,K.p)(h)}`,children:f.isLoading?(0,i.FD)("div",{className:"flex items-center justify-center h-full text-ink/40 text-xs gap-2",children:[(0,i.Y)(P.A,{size:14,className:"animate-spin"}),(0,i.Y)("span",{children:"Loading file content..."})]}):f.loadError?(0,i.FD)("div",{className:"flex flex-col items-center justify-center h-full gap-2 px-6 text-center",children:[(0,i.Y)(eg.A,{size:20,className:"text-error"}),(0,i.FD)("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),(0,i.Y)("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:f.loadError})]}):x&&l?(0,i.Y)("div",{className:"p-4 bg-paper text-ink min-h-full font-sans prose prose-sm max-w-none",children:(0,i.Y)(ek.T,{content:u})}):(0,i.Y)(ev.P,{value:u,onValueChange:f.onChange,language:b,wordWrap:d,rootClassName:"flex min-h-full bg-paper",gutterClassName:"w-10 py-3 pr-2 select-none text-right text-[10px] text-ink/30 bg-canvas border-r border-ink/10 font-mono leading-[20px] flex-shrink-0",editorWrapperClassName:"flex-1 p-3 overflow-x-auto min-w-0 bg-paper text-ink code-surface",editorClassName:"focus:outline-none",editorStyle:{fontFamily:"monospace",fontSize:`${o}px`,lineHeight:"20px",backgroundColor:"transparent",minHeight:"100%",color:"var(--theme-ink)"}})}),(0,i.FD)("footer",{className:"bg-canvas border-t border-ink/10 px-3 flex items-center justify-between text-[10px] text-ink/60 flex-shrink-0 font-mono",style:{height:"calc(1.75rem + env(safe-area-inset-bottom, 0px))",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px))"},children:[(0,i.FD)("div",{className:"flex items-center space-x-3",children:[(0,i.FD)("span",{children:[g," lines"]}),(0,i.FD)("span",{children:[u.length," chars"]}),(0,i.Y)("span",{className:"uppercase",children:b})]}),(0,i.FD)("div",{className:"flex items-center space-x-2",children:["saving"===f.saveStatus&&(0,i.FD)(i.FK,{children:[(0,i.Y)(P.A,{size:10,className:"animate-spin"}),(0,i.Y)("span",{children:"Saving…"})]}),"saved"===f.saveStatus&&(0,i.FD)(i.FK,{children:[(0,i.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),(0,i.Y)("span",{children:"Saved"})]}),"error"===f.saveStatus&&(0,i.FD)(i.FK,{children:[(0,i.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-error"}),(0,i.Y)("span",{className:"text-error",children:"Save failed"})]}),"idle"===f.saveStatus&&t.path&&(0,i.Y)("span",{className:"truncate max-w-[140px]",children:t.path})]})]})]})}var eO=n("Xg"),eW=n("LQ");function eP(e){let{diff:t,onClose:n,onFileSaved:s}=e,a=t.path.split("/").pop()||t.path,l=!!t.staged,r=t.status||"M",o=(0,eW.R)(r,l);return(0,i.FD)("div",{className:"fixed inset-x-0 top-0 h-dvh z-[60] bg-paper flex flex-col",children:[(0,i.FD)("header",{className:"bg-canvas border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0",style:{height:"calc(3rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px))"},children:[(0,i.FD)("div",{className:"flex items-center space-x-2 min-w-0 pr-2",children:[(0,i.Y)("button",{type:"button",onClick:n,className:"p-1.5 -ml-1 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0",title:"Back","aria-label":"Close diff",children:(0,i.Y)(eN.A,{size:18,strokeWidth:1.9})}),(0,i.Y)(eA.o,{name:a,size:14,className:"flex-shrink-0"}),(0,i.Y)("span",{className:"font-mono text-xs text-ink font-medium truncate",title:t.path,children:a})]}),(0,i.FD)("span",{className:`px-1.5 py-0.5 text-[10px] font-mono font-semibold rounded border flex-shrink-0 ${o.badgeBgClass}`,children:[o.charStatus," ",o.label]})]}),(0,i.Y)("div",{className:"flex-1 min-h-0",children:(0,i.Y)(eO.M,{className:"h-full",filePath:t.path,status:r,isStaged:l,root:t.root,repo:t.repo||".",onFileSaved:s})})]})}var eR=n("u"),e$=n("Gb"),eE=n("wm");function eJ(e){let{onDesktopToggle:t,appSettings:n={}}=e,{folders:r}=(0,f.k)(),[o,c]=(0,a.o)(),d=o.get("sessionId"),p=d?Number.isNaN(Number(d))?d:Number(d):null,h=o.get("folderId"),m=h?Number.isNaN(Number(h))?h:Number(h):null,[x,u]=(0,s.J0)("main"),[b,g]=(0,s.J0)(null),[k,v]=(0,s.J0)(null),[Y,w]=(0,s.J0)(0),[y,S]=(0,s.J0)(!1),[F,D]=(0,s.J0)("appearance"),[C,A]=(0,s.J0)(!1),z=(0,s.hb)(()=>w(e=>e+1),[]),{folder:j}=(0,e$.t)(r,p),T=j??(m?r.find(e=>String(e.id)===String(m))??null:null),O=T?.project_path??null,W=!!T;(0,l.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,"");g({name:e.detail.name||t.split("/").pop()||"file",path:t,content:e.detail.content,root:e.detail.root})}),(0,l.sY)("omp:open-diff",e=>{let t=e.detail;t?.file&&v({path:t.file.replace(/^\/+/,""),status:t.status,staged:t.staged,repo:t.repo,root:t.root??O??void 0})}),(0,l.sY)("omp:open-settings",e=>{let t=e.detail;D(t?.category??"appearance"),A(!!t?.autoOpenAdd),S(!0)});let P=e=>{c(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),u("main")},R=()=>{let e=(0,eE.l)(r,d,m??void 0);e&&(0,eE.r)(e),c(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=r.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}return n},{replace:!0}),u("main")},$=async e=>{let t=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok||!n.success)throw Error(n.error||`HTTP ${t.status}`);window.location.reload()},E=(0,s.hb)(e=>{let t=(e?.path||"").replace(/^\/+/,"");g({name:e?.name||t.split("/").pop()||"file",path:t,content:e?.content,root:e?.root??O??void 0})},[O]);return(0,i.FD)("div",{className:"flex flex-col h-dvh w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas relative",children:[(0,i.Y)("div",{className:`flex-1 min-h-0 w-full ${"main"===x?"block":"hidden"}`,children:(0,i.Y)(N,{activeSessionId:p,onSelectSession:P,onNewSession:R,onOpenSessionSidebar:()=>u("session"),onOpenRightSidebar:()=>u("right"),appSettings:n})}),(0,i.Y)("div",{className:`flex-1 min-h-0 w-full ${"session"===x?"block":"hidden"}`,children:(0,i.Y)(ea,{activeSessionId:p,onSelectSession:P,onNewSession:R,onCreateFolder:$,onClose:()=>u("main"),onDesktopToggle:t,appSettings:n})}),"right"===x&&(0,i.Y)("div",{className:"flex-1 min-h-0 w-full",children:(0,i.Y)(eb,{enabled:W,rootPath:O??void 0,refreshKey:Y,onRefresh:z,onOpenFile:E,onClose:()=>u("main")})}),b&&(0,i.Y)(eT,{file:b,onClose:()=>g(null),onFileSaved:z}),k&&(0,i.Y)(eP,{diff:k,onClose:()=>v(null),onFileSaved:z}),(0,i.Y)(eR.b,{isOpen:y,onClose:()=>{S(!1),A(!1)},initialCategory:F,autoOpenAddProvider:C,appSettings:n})]})}},qn(e,t,n){let i=(0,n("y").A)({name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]});n.d(t,{},{A:i})},mX(e,t,n){let i=(0,n("y").A)({name:"monitor",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]});n.d(t,{},{A:i})}}]);
@@ -1,6 +0,0 @@
1
- /*! LICENSE: x4.69ec69c61b.js.LICENSE.txt */
2
- "use strict";(self.rspackChunkompchamber=self.rspackChunkompchamber||[]).push([["x4"],{wA(e,t,r){var n=r("j"),l=r("H"),i=r("rm"),o=r("Go"),c=r("t3"),a=r("Ir"),s=r("z"),u=r("oj");function d(e){let{rootPath:t,activeRepo:r,onSelectRepo:d}=e,[m,h]=(0,l.J0)(!1),[b,f]=(0,l.J0)(["."]),[p,x]=(0,l.J0)(!1),[g,w]=(0,l.J0)(""),v=(0,l.li)(null),k=function(e){if(!e)return"workspace root";let t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t.length>0?t[t.length-1]:"workspace root"}(t),y=e=>"."===e?k:e,N=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=new URLSearchParams({reposOnly:"1"});t&&r.set("root",t),e&&r.set("rescan","1"),r.set("t",String(Date.now()));let n=await fetch(`/api/fs/git?${r.toString()}`).then(e=>e.json()).catch(()=>null);n&&Array.isArray(n.repos)&&(f(n.repos),n.reposPending?x(!0):x(!1))};(0,l.vJ)(()=>{m&&N()},[m,t]),(0,l.vJ)(()=>{if(!p)return;let e=new URLSearchParams({reposOnly:"1"});t&&e.set("root",t);let r=setInterval(async()=>{let t=await fetch(`/api/fs/git?${e.toString()}`).then(e=>e.json()).catch(()=>null);t&&!t.reposPending&&Array.isArray(t.repos)&&(f(t.repos),x(!1))},1500);return()=>clearInterval(r)},[p,t]),(0,u.W)(v,()=>h(!1));let C=b.filter(e=>!g.trim()||y(e).toLowerCase().includes(g.toLowerCase()));return(0,n.FD)("div",{className:"relative",ref:v,children:[(0,n.FD)("button",{type:"button",onClick:()=>h(!m),title:"Switch git project",className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium",children:[(0,n.Y)(i.A,{size:12,className:"text-ink/60"}),(0,n.Y)("span",{className:"truncate max-w-[110px]",children:"."===r?k:r.split("/").pop()}),(0,n.Y)(o.A,{size:12,className:"text-ink/40"})]}),m&&(0,n.FD)("div",{className:"absolute top-full left-0 mt-1 w-52 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:[(0,n.FD)("div",{className:"px-2 py-1.5 border-b border-ink/10 flex items-center space-x-1.5",children:[(0,n.Y)(c.A,{size:11,className:"text-ink/40 flex-shrink-0"}),(0,n.Y)("input",{type:"text",value:g,onChange:e=>w(e.currentTarget.value),placeholder:"Search repos...",title:"Search repositories",className:"w-full bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),g&&(0,n.Y)("button",{type:"button",onClick:()=>w(""),title:"Clear search",className:"text-ink/40 hover:text-ink flex-shrink-0",children:"×"}),(0,n.Y)("button",{type:"button",onClick:()=>void N(!0),title:"Refresh nested repos",disabled:p,className:"text-ink/40 hover:text-ink flex-shrink-0 transition-colors disabled:opacity-40 disabled:hover:text-ink/40",children:(0,n.Y)(a.A,{size:11,className:p?"animate-spin":""})})]}),(0,n.Y)("div",{className:"max-h-48 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===C.length?(0,n.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No repos found"}):C.map(e=>(0,n.FD)("button",{type:"button",onClick:()=>{d(e),h(!1),w("")},title:y(e),className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,n.Y)("span",{className:"truncate",children:y(e)}),r===e&&(0,n.Y)(s.A,{size:12,className:"text-ink"})]},e))})]})]})}r.d(t,{I:()=>d})},Xc(e,t,r){r.d(t,{TerminalPanel:()=>D});var n=r("j"),l=r("H"),i=r("FL"),o=r("As");let c=["bun --version","bun run build","git status -s"];var a=r("N"),s=r("t"),u=r("wA");function d(e){let{isRunning:t,rootPath:r,activeRepo:l,onSelectRepo:i,bunVersion:o,nodeVersion:c}=e;return(0,n.FD)("div",{className:"h-10 px-3 border-b border-ink/10 bg-paper flex items-center justify-between flex-shrink-0 select-none",children:[(0,n.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,n.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,n.Y)(a.A,{size:14,className:"text-ink/80 flex-shrink-0"}),(0,n.Y)("span",{className:"text-xs font-semibold tracking-wider text-ink uppercase",children:"Terminal"})]}),t&&(0,n.FD)("span",{className:"inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono bg-warning/10 text-warning border border-warning/20 animate-pulse",children:[(0,n.Y)(s.A,{size:10,className:"animate-spin"}),(0,n.Y)("span",{className:"hidden xs:inline",children:"RUNNING"})]}),(0,n.Y)(u.I,{rootPath:r,activeRepo:l,onSelectRepo:i})]}),o&&(0,n.FD)("span",{className:"hidden sm:flex items-center space-x-2 text-[10px] font-mono text-ink/40 flex-shrink-0",children:[(0,n.FD)("span",{children:["Bun ",o]}),c&&(0,n.FD)("span",{children:["Node ",c]})]})]})}var m=r("XT");let h=[{label:"bun build",cmd:"bun run build"},{label:"bun test",cmd:"bun test"},{label:"git status",cmd:"git status -s"},{label:"git diff",cmd:"git diff"},{label:"ls -la",cmd:"ls -la"},{label:"pwd",cmd:"pwd"},{label:"bun -v",cmd:"bun --version"}];function b(e){let{onSelectCommand:t,disabled:r}=e;return(0,n.FD)("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-1.5 bg-paper border-b border-ink/10 flex-shrink-0",children:[(0,n.FD)("div",{className:"flex items-center space-x-1 text-[10px] font-mono text-ink/50 uppercase tracking-wider flex-shrink-0 select-none",children:[(0,n.Y)(m.A,{size:11,className:"text-warning"}),(0,n.Y)("span",{children:"Quick:"})]}),h.map(e=>(0,n.Y)("button",{type:"button",disabled:r,onClick:()=>t(e.cmd),className:"px-2 py-0.5 rounded text-[10px] font-mono bg-canvas hover:bg-ink/5 active:bg-ink/10 text-ink/80 hover:text-ink border border-ink/15 transition-all whitespace-nowrap disabled:opacity-40 cursor-pointer shadow-2xs",children:e.label},e.cmd))]})}var f=r("s8"),p=r("DTR");function x(e){let{value:t,onChange:r,onSubmit:i,onKeyDown:o,onCancel:c,isRunning:a}=e,s=(0,l.li)(null);return(0,l.vJ)(()=>{s.current?.focus()},[]),(0,n.FD)("form",{onSubmit:e=>{e.preventDefault(),a||i()},className:"p-2 border-t border-ink/10 bg-paper flex items-center space-x-2 flex-shrink-0",children:[(0,n.FD)("div",{className:"flex items-center space-x-2 flex-1 min-w-0 bg-canvas border border-ink/20 rounded-lg px-2.5 py-1.5 focus-within:border-ink/50 focus-within:ring-1 focus-within:ring-ink/10 transition-all",children:[(0,n.Y)("span",{className:"text-warning font-mono text-xs select-none font-bold",children:"$"}),(0,n.Y)("input",{ref:s,type:"text",value:t,onChange:e=>r(e.currentTarget.value),onKeyDown:o,disabled:a,placeholder:a?"Command is executing in live session...":"bun run build, git status, ls -la...",className:"flex-1 bg-transparent font-mono text-xs text-ink placeholder:text-ink/40 outline-none min-w-0"}),(0,n.Y)("span",{className:"hidden sm:inline-block text-[10px] font-mono text-ink/40 select-none",children:"↑↓ history"})]}),a?(0,n.FD)("button",{type:"button",onClick:c,className:"px-2.5 py-1.5 rounded-lg bg-error text-white hover:bg-error/90 active:scale-95 transition-all flex items-center space-x-1 cursor-pointer shadow-xs font-mono text-xs",title:"Interrupt process (Ctrl+C)",children:[(0,n.Y)(f.A,{size:12,fill:"currentColor"}),(0,n.Y)("span",{className:"hidden xs:inline text-[10px]",children:"Stop"})]}):(0,n.Y)("button",{type:"submit",disabled:!t.trim(),className:"p-2 rounded-lg bg-ink text-paper hover:bg-ink/85 active:scale-95 transition-all flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none cursor-pointer shadow-xs",title:"Execute command (Enter)",children:(0,n.Y)(p.A,{size:13})})]})}var g=r("G"),w=r("zi"),v=r("fe"),k=r("SS");let y={background:"#f4f1ea",foreground:"#141310",cursor:"#141310",cursorAccent:"#f4f1ea",selectionBackground:"#ded8ce",selectionForeground:"#141310",black:"#141310",red:"#c8321e",green:"#047857",yellow:"#b45309",blue:"#1d4ed8",magenta:"#9333ea",cyan:"#0284c7",white:"#faf8f3",brightBlack:"#78716c",brightRed:"#dc2626",brightGreen:"#059669",brightYellow:"#d97706",brightBlue:"#2563eb",brightMagenta:"#a855f7",brightCyan:"#0ea5e9",brightWhite:"#292524"},N={background:"#21252b",foreground:"#abb2bf",cursor:"#528bff",cursorAccent:"#21252b",selectionBackground:"#3e4451",selectionForeground:"#abb2bf",black:"#282c34",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#abb2bf",brightBlack:"#5c6370",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},C={device:{char:{width:9,height:17,left:0,top:0},cell:{width:9,height:17},canvas:{width:0,height:0}},css:{canvas:{width:0,height:0},cell:{width:9,height:17}}},Y="",S=(0,g.Rf)((e,t)=>{let{onCommandSubmit:c,cwd:a}=e,{isDark:s}=(0,v.DP)(),u=(0,l.li)(null),d=(0,l.li)(null),m=(0,l.li)(null),h=(0,l.li)(""),b=(0,l.li)([]),[f,p]=(0,l.J0)(!1),x=(0,l.li)(c),{recordOutput:g,clearOutput:S}=function(e){let{sessionId:t,ready:r}=(0,o.O)(),[,n]=(0,i.bL)("terminal.output",""),c=(0,l.li)(n);c.current=n;let a=(0,l.li)(r);a.current=r;let s=(0,l.li)(0),u=(0,l.li)(null),d=(0,l.li)(null),m=(0,l.hb)(e=>{if((Y+=e).length>25e4&&(Y=Y.slice(-2e5)),!a.current)return;let t=Date.now();t-s.current<1e3||(s.current=t,c.current(Y.length<=8e3?Y:Y.slice(-8e3)))},[]),h=(0,l.hb)(()=>{Y="",a.current&&(s.current=Date.now(),c.current(""))},[]);return(0,l.vJ)(()=>{if(!r||u.current===t)return;let n=null!==d.current;u.current=t,d.current=t;let l=(0,k.WV)(t,"terminal.output");if(void 0===l&&!n)return;Y=l??"";let i=e.current;i&&(i.clear(),l?(i.write(l),i.scrollToBottom()):i.write("\x1b[33m$\x1b[0m "))},[r,t,e]),{recordOutput:m,clearOutput:h}}(d);(0,l.vJ)(()=>{d.current&&(d.current.options.theme=s?N:y,d.current.refresh(0,d.current.rows-1))},[s]),(0,l.vJ)(()=>{x.current=c},[c]);let D=(0,l.hb)(()=>{d.current&&(d.current.scrollToBottom(),p(!1))},[]),A=(0,l.hb)(()=>{d.current?.scrollToTop()},[]),$=(0,l.hb)(e=>{d.current?.scrollLines(e)},[]);return(0,l.Yn)(t,()=>({write:e=>{if(g(e),d.current){let t=d.current,r=t.buffer.active.viewportY===t.buffer.active.baseY;t.write(e,()=>{r&&t.scrollToBottom()})}else b.current.push(e)},writeln:e=>{if(g(e+"\r\n"),d.current){let t=d.current,r=t.buffer.active.viewportY===t.buffer.active.baseY;t.writeln(e,()=>{r&&t.scrollToBottom()})}else b.current.push(e+"\r\n")},clear:()=>{S(),d.current?(d.current.clear(),d.current.write("\r\x1b[33m$\x1b[0m "),g("\r\x1b[33m$\x1b[0m "),p(!1)):b.current=[]},focus:()=>{d.current?.focus()},scrollToBottom:D,scrollToTop:A,scrollLines:$})),(0,l.vJ)(()=>{let e=!0,t=null,n=null,l=null,i=null,o=null,c=null,a=null,f=null,w=()=>{if(!e||!t||!n||!u.current)return;let r=u.current;if(!(r.clientWidth<=0)&&!(r.clientHeight<=0))try{let e=t._core,r=e?._renderService;if(!r)return;let l=r.dimensions;if(!l?.css?.cell?.width||!l?.css?.cell?.height)return;n.fit()}catch{}};return async function(){if(!u.current||!e)return;let v=await r.e("f").then(r.bind(r,"JX")),k=await r.e("xnl").then(r.bind(r,"r3")),D=v.Terminal||v.default?.Terminal||v.default,A=k.FitAddon||k.default?.FitAddon||k.default;if(!D||!A||!u.current||!e)return;try{let e=A?.prototype;if(e&&!e.__safePatched){e.__safePatched=!0;let t=e.proposeDimensions;e.proposeDimensions=function(){try{let e=this._terminal?._core;if(!e?._renderService)return;let r=e._renderService.dimensions;if(!r?.css?.cell?.width||!r?.css?.cell?.height)return;return t?.call(this)}catch{return}}}}catch{}let $=new D({cursorBlink:!0,cursorStyle:"block",fontSize:12,lineHeight:1.25,fontFamily:"'Fira Code', Menlo, Monaco, 'Courier New', monospace",theme:s?N:y,convertEol:!0,scrollback:1e4,scrollSensitivity:1.5,fastScrollSensitivity:5,smoothScrollDuration:0,allowProposedApi:!0});$.open(u.current);try{let e=$?._core;if(e?._renderService){let t=Object.getPrototypeOf(e._renderService),r=Object.getOwnPropertyDescriptor(t,"dimensions");if(r?.get&&!t.__safePatched){t.__safePatched=!0;let e=r.get;Object.defineProperty(t,"dimensions",{get(){try{if(!this._renderer?.value)return C;return e.call(this)}catch{return C}},configurable:!0,enumerable:!0})}}}catch{}let F=new A;$.loadAddon(F),t=$,n=F,d.current=$,m.current=F,a=requestAnimationFrame(()=>{e&&w()}),$.attachCustomKeyEventHandler(e=>(function(e,t){if("keydown"!==t.type)return!0;if(t.shiftKey){if("PageUp"===t.key)return e.scrollPages(-1),!1;if("PageDown"===t.key)return e.scrollPages(1),!1;if("Home"===t.key)return e.scrollToTop(),!1;if("End"===t.key)return e.scrollToBottom(),!1;if("ArrowUp"===t.key)return e.scrollLines(-1),!1;if("ArrowDown"===t.key)return e.scrollLines(1),!1}return!0})($,e)),o=$.onScroll(()=>{let e=$.buffer.active;p(e.viewportY<e.baseY)});let E=Y;if(E)$.write(E);else{let e="\x1b[1;33m[OMPChamber Realtime Terminal]\x1b[0m\r\n\x1b[90mStream connected. Live xterm canvas active.\x1b[0m\r\n\r\n\x1b[33m$\x1b[0m ";$.write(e),g(e)}if(b.current.length>0){for(let e of b.current)$.write(e);b.current=[],$.scrollToBottom()}i=$.onData(e=>{if("\r"===e){let e=h.current.trim();$.write("\r\n"),h.current="",e&&x.current?(g(e+"\r\n"),x.current(e,{fromXterm:!0})):($.write("\x1b[33m$\x1b[0m "),g("\r\n\x1b[33m$\x1b[0m "))}else""===e||"\b"===e?h.current.length>0&&(h.current=h.current.slice(0,-1),$.write("\b \b")):"\x03"===e?(h.current="",$.write("^C\r\n\x1b[33m$\x1b[0m "),g("^C\r\n\x1b[33m$\x1b[0m ")):"\f"===e?(S(),$.clear(),$.write("\x1b[33m$\x1b[0m "),g("\x1b[33m$\x1b[0m ")):e>=" "&&(h.current+=e,$.write(e))});let T=0,R=u.current,L=e=>{1===e.touches.length&&(T=e.touches[0].clientY)},P=e=>{if(1===e.touches.length){let t=T-e.touches[0].clientY;Math.abs(t)>=16&&($.scrollLines(Math.trunc(t/16)),T=e.touches[0].clientY)}};R&&(R.addEventListener("touchstart",L,{passive:!0}),R.addEventListener("touchmove",P,{passive:!0}),f=()=>{R.removeEventListener("touchstart",L),R.removeEventListener("touchmove",P)}),l=new ResizeObserver(()=>{c&&clearTimeout(c),c=setTimeout(()=>{w()},35)}),R&&l.observe(R)}(),()=>{e=!1,null!==a&&cancelAnimationFrame(a),null!==c&&clearTimeout(c),f?.(),i?.dispose(),o?.dispose(),l?.disconnect();try{n?.dispose()}catch{}try{t?.dispose()}catch{}d.current=null,m.current=null}},[]),(0,n.FD)("div",{className:"relative flex-1 w-full h-full bg-canvas overflow-hidden",children:[(0,n.Y)("div",{ref:u,className:"w-full h-full cursor-text p-1.5",style:{height:"100%",width:"100%"}}),f&&(0,n.FD)("button",{type:"button",onClick:D,className:"absolute bottom-3 right-4 z-20 flex items-center space-x-1.5 px-2.5 py-1 bg-paper hover:bg-canvas text-ink border border-ink/20 rounded-full shadow-lg text-[11px] font-mono transition-all animate-fade-in cursor-pointer active:scale-95",title:"Scroll to latest output (Shift+End)",children:[(0,n.Y)(w.A,{size:12,className:"text-warning"}),(0,n.Y)("span",{children:"Latest"})]})]})});function D(e){let{className:t="",enabled:r=!0,rootPath:a,showHeader:s=!0}=e,u=(0,l.li)(null),[m,h]=(0,i.bL)("terminal.activeRepo","."),{terminalInput:f,setTerminalInput:p,isRunning:g,cwd:w,systemInfo:v,executeCommand:k,cancelRunningCommand:y,handleKeyDown:N}=function(e){let[t,r]=(0,l.J0)([]),[n,a]=(0,i.bL)("terminal.input",""),[s,u]=(0,l.J0)(!1),[d,m]=(0,i.bL)("terminal.cwd","."),[h,b]=(0,i.bL)("terminal.commandHistory",c),[f,p]=(0,l.J0)(-1),[x,g]=(0,l.J0)({bunVersion:"",nodeVersion:"",gitBranch:"main"}),w=(0,l.li)(null),v=(0,l.li)(e?.onStreamChunk);v.current=e?.onStreamChunk;let k=(0,l.li)(e?.onCommandStart);k.current=e?.onCommandStart;let y=(0,l.li)(e?.onCommandEnd);y.current=e?.onCommandEnd;let N=(0,l.li)(e?.onClear);N.current=e?.onClear;let C=(0,l.li)(e?.root);C.current=e?.root;let Y=(0,l.li)(e?.root),S=(0,l.li)(e?.repo);S.current=e?.repo;let D=(0,l.li)(e?.repo),{sessionId:A,ready:$}=(0,o.O)(),F=(0,l.li)(A),E=(0,l.li)(!0);(0,l.vJ)(()=>{if(F.current!==A&&(F.current=A,E.current=!0),!$||!E.current)return;let e=setTimeout(()=>{E.current=!1},0);return()=>clearTimeout(e)},[A,$]),(0,l.vJ)(()=>{let t=e?.root,n=e?.repo;(Y.current!==t||D.current!==n)&&(Y.current=t,D.current=n,E.current||(m("."),r([]),N.current?.()));let l=t?`?root=${encodeURIComponent(t)}`:"",i=n&&"."!==n?`&repo=${encodeURIComponent(n)}`:"";fetch(`/api/terminal/run${l}${i}`).then(e=>e.json()).then(e=>{e&&e.bunVersion&&g({bunVersion:e.bunVersion??"",nodeVersion:e.nodeVersion??"",gitBranch:e.gitBranch||"main"})}).catch(()=>{})},[e?.root,e?.repo]);let T=(0,l.hb)(()=>{r([])},[]),R=(0,l.hb)(async(e,t)=>{let l=(void 0!==e?e:n).trim();if(!l||s)return;if("clear"===l||"cls"===l){r([]),a(""),p(-1),N.current?.();return}let i=`cmd-${Date.now()}-${Math.random().toString(36).substring(2,6)}`,o=new Date().toLocaleTimeString();b(e=>e[e.length-1]===l?e:[...e,l]),p(-1),a(""),u(!0),k.current?.(l,t);let c=new AbortController;w.current=c;let h="",f=0,x=d;try{let e=C.current?`&root=${encodeURIComponent(C.current)}`:"",t=S.current&&"."!==S.current?`&repo=${encodeURIComponent(S.current)}`:"",r=`/api/terminal/stream?cmd=${encodeURIComponent(l)}&cwd=${encodeURIComponent(d)}${e}${t}`,n=await fetch(r,{signal:c.signal});if(!n.body)throw Error("Streaming not supported by browser");let i=n.body.getReader(),o=new TextDecoder,a="";for(;;){let{value:e,done:t}=await i.read();if(t)break;let r=(a+=o.decode(e,{stream:!0})).split("\n");a=r.pop()||"";let n="message";for(let e of r){let t=e.trim();if(t.startsWith("event:"))n=t.slice(6).trim();else if(t.startsWith("data:")){let e=t.slice(5).trim();try{let t=JSON.parse(e);if("data"===n&&t.text){let e=t.text.replace(/\r?\n/g,"\r\n");h+=e,v.current?.(e)}else"exit"===n&&(f="number"==typeof t.exitCode?t.exitCode:0,t.cwd&&t.cwd!==d&&(x=t.cwd,m(t.cwd)))}catch{}}}}}catch(e){if("AbortError"===e.name){f=130;let e="\r\n^C (Interrupted)\r\n";h+=e,v.current?.(e)}else{f=1;let t=`\r
3
- \x1b[31mError: ${e.message||"Execution failed"}\x1b[0m\r
4
- `;h+=t,v.current?.(t)}}finally{u(!1),w.current=null,y.current?.(f,x),r(e=>{var t;return(t=[...e,{id:i,command:l,stdout:h,exitCode:f,timestamp:o,cwd:x}]).length>50?t.slice(-50):t})}},[n,s,d,A]),L=(0,l.hb)(()=>{w.current&&w.current.abort()},[]),P=(0,l.hb)(e=>{if("ArrowUp"===e.key)e.preventDefault(),0!==h.length&&p(e=>{let t=-1===e?h.length-1:Math.max(0,e-1);return a(h[t]||""),t});else if("ArrowDown"===e.key){if(e.preventDefault(),-1===f)return;p(e=>{let t=e+1;return t>=h.length?(a(""),-1):(a(h[t]||""),t)})}else"c"===e.key&&e.ctrlKey?s&&L():"l"===e.key&&e.ctrlKey&&(e.preventDefault(),T(),N.current?.())},[h,f,s,L,T,A]);return{terminalLogs:t,terminalInput:n,setTerminalInput:a,isRunning:s,cwd:d,systemInfo:x,executeCommand:R,clearLogs:T,cancelRunningCommand:L,handleKeyDown:P}}({onStreamChunk:(0,l.hb)(e=>{u.current?.write(e)},[]),onCommandStart:(0,l.hb)((e,t)=>{t?.fromXterm||u.current?.write(`\r\x1b[K\x1b[33m$\x1b[0m \x1b[1m${e}\x1b[0m\r
5
- `)},[]),onCommandEnd:(0,l.hb)((e,t)=>{0!==e&&130!==e&&u.current?.write(`\x1b[31m[exit ${e}]\x1b[0m\r
6
- `),u.current?.write("\x1b[33m$\x1b[0m ")},[]),onClear:(0,l.hb)(()=>{u.current?.clear()},[]),root:r?a:void 0,repo:m}),C=(0,l.hb)((e,t)=>{k(e,t)},[k]);return r?(0,n.FD)("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[s&&(0,n.Y)(d,{isRunning:g,rootPath:a,activeRepo:m,onSelectRepo:h,bunVersion:v.bunVersion,nodeVersion:v.nodeVersion}),(0,n.Y)(b,{onSelectCommand:k,disabled:g}),(0,n.Y)("div",{className:"flex-1 w-full min-h-0 bg-canvas overflow-hidden",children:(0,n.Y)(S,{ref:u,cwd:w,onCommandSubmit:C})}),(0,n.Y)(x,{value:f,onChange:p,onSubmit:()=>k(),onKeyDown:N,onCancel:y,isRunning:g})]}):(0,n.Y)("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:(0,n.Y)("span",{className:"text-xs font-mono",children:"No session selected"})})}S.displayName="RealtimeXtermView"},C7q(e,t,r){var n=r("H"),l=r("So");function i(){return(0,n.hb)(e=>{(0,l.l1)(e)},[])}r.d(t,{g:()=>i})},fe(e,t,r){var n=r("H"),l=r("C7q");function i(e){"u">typeof document&&(document.documentElement.dataset.theme=e,window.dispatchEvent(new CustomEvent("omp:theme-changed",{detail:e})))}function o(){let e=(0,l.g)(),[t,r]=(0,n.J0)(()=>"u">typeof document&&(document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme"))||"paper"),o="one-dark-pro-soft"===t||"noir"===t||"dark"===t;(0,n.vJ)(()=>{if("u"<typeof document)return;let e=()=>{let e=document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme")||"paper";r(e);let t=document.querySelector('meta[name="theme-color"]');t&&t.setAttribute("content","one-dark-pro-soft"===e?"#282c34":"#faf8f3")};e();let t=new MutationObserver(t=>{for(let r of t)"attributes"===r.type&&("data-theme"===r.attributeName||"class"===r.attributeName)&&e()});t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});let n=t=>{t.detail?r(t.detail):e()};return window.addEventListener("omp:theme-changed",n),()=>{t.disconnect(),window.removeEventListener("omp:theme-changed",n)}},[]);let c=(0,n.hb)(t=>{i(t),r(t),e({theme:t})},[e]),a=(0,n.hb)(()=>{c(o?"paper":"one-dark-pro-soft")},[o,c]);return{theme:t,isDark:o,setTheme:c,toggleTheme:a}}r.d(t,{DP:()=>o,Ps:()=>i})},rm(e,t,r){let n=(0,r("y").A)({name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 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 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]});r.d(t,{},{A:n})}}]);
@@ -1,82 +0,0 @@
1
- import { useEffect, useRef } from 'preact/hooks';
2
- import type { FormEvent, KeyboardEvent } from 'preact/compat';
3
- import { CornerDownLeft, Square } from 'lucide-preact';
4
-
5
- interface TerminalInputBarProps {
6
- value: string;
7
- onChange: (val: string) => void;
8
- onSubmit: () => void;
9
- onKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
10
- onCancel: () => void;
11
- isRunning: boolean;
12
- }
13
-
14
- export function TerminalInputBar({
15
- value,
16
- onChange,
17
- onSubmit,
18
- onKeyDown,
19
- onCancel,
20
- isRunning,
21
- }: TerminalInputBarProps) {
22
- const inputRef = useRef<HTMLInputElement>(null);
23
-
24
- // Auto focus input
25
- useEffect(() => {
26
- inputRef.current?.focus();
27
- }, []);
28
-
29
- const handleSubmit = (e: FormEvent) => {
30
- e.preventDefault();
31
- if (!isRunning) {
32
- onSubmit();
33
- }
34
- };
35
-
36
- return (
37
- <form
38
- onSubmit={handleSubmit}
39
- className="p-2 border-t border-ink/10 bg-paper flex items-center space-x-2 flex-shrink-0"
40
- >
41
- <div className="flex items-center space-x-2 flex-1 min-w-0 bg-canvas border border-ink/20 rounded-lg px-2.5 py-1.5 focus-within:border-ink/50 focus-within:ring-1 focus-within:ring-ink/10 transition-all">
42
- <span className="text-warning font-mono text-xs select-none font-bold">
43
- $
44
- </span>
45
- <input
46
- ref={inputRef}
47
- type="text"
48
- value={value}
49
- onChange={e => onChange(e.currentTarget.value)}
50
- onKeyDown={onKeyDown}
51
- disabled={isRunning}
52
- placeholder={isRunning ? "Command is executing in live session..." : "bun run build, git status, ls -la..."}
53
- className="flex-1 bg-transparent font-mono text-xs text-ink placeholder:text-ink/40 outline-none min-w-0"
54
- />
55
- <span className="hidden sm:inline-block text-[10px] font-mono text-ink/40 select-none">
56
- ↑↓ history
57
- </span>
58
- </div>
59
-
60
- {isRunning ? (
61
- <button
62
- type="button"
63
- onClick={onCancel}
64
- className="px-2.5 py-1.5 rounded-lg bg-error text-white hover:bg-error/90 active:scale-95 transition-all flex items-center space-x-1 cursor-pointer shadow-xs font-mono text-xs"
65
- title="Interrupt process (Ctrl+C)"
66
- >
67
- <Square size={12} fill="currentColor" />
68
- <span className="hidden xs:inline text-[10px]">Stop</span>
69
- </button>
70
- ) : (
71
- <button
72
- type="submit"
73
- disabled={!value.trim()}
74
- className="p-2 rounded-lg bg-ink text-paper hover:bg-ink/85 active:scale-95 transition-all flex items-center justify-center disabled:opacity-40 disabled:pointer-events-none cursor-pointer shadow-xs"
75
- title="Execute command (Enter)"
76
- >
77
- <CornerDownLeft size={13} />
78
- </button>
79
- )}
80
- </form>
81
- );
82
- }
@@ -1,70 +0,0 @@
1
- import type { TerminalLogItem } from '@/shared/types';
2
- import { Check, Clock, Loader2, X } from 'lucide-preact';
3
-
4
- interface TerminalLogEntryProps {
5
- item: TerminalLogItem;
6
- }
7
-
8
- export function TerminalLogEntry({ item }: TerminalLogEntryProps) {
9
- const isRunning = item.exitCode === -1;
10
- const isError = !isRunning && item.exitCode !== 0;
11
- const isSuccess = !isRunning && item.exitCode === 0;
12
-
13
- return (
14
- <div className="space-y-1 font-mono text-[11px] leading-relaxed select-text">
15
- {/* Command prompt line */}
16
- <div className="flex items-center justify-between text-ink bg-canvas px-2.5 py-1 rounded border border-ink/15">
17
- <div className="flex items-center space-x-2 min-w-0">
18
- <span className="text-warning font-bold select-none">$</span>
19
- <span className="font-semibold text-ink truncate">{item.command}</span>
20
- </div>
21
-
22
- <div className="flex items-center space-x-2 text-[10px] text-ink/50 flex-shrink-0 ml-2 select-none">
23
- {isRunning ? (
24
- <span className="flex items-center space-x-1 text-warning">
25
- <Loader2 size={10} className="animate-spin" />
26
- <span>executing...</span>
27
- </span>
28
- ) : (
29
- <>
30
- {typeof item.durationMs === 'number' && (
31
- <span className="flex items-center space-x-0.5">
32
- <Clock size={9} />
33
- <span>{item.durationMs}ms</span>
34
- </span>
35
- )}
36
- {isSuccess && (
37
- <span className="flex items-center text-success" title="Exit code: 0">
38
- <Check size={11} />
39
- </span>
40
- )}
41
- {isError && (
42
- <span
43
- className="flex items-center space-x-0.5 text-error font-bold"
44
- title={`Exit code: ${item.exitCode}`}
45
- >
46
- <X size={11} />
47
- <span>{item.exitCode}</span>
48
- </span>
49
- )}
50
- </>
51
- )}
52
- </div>
53
- </div>
54
-
55
- {/* Stdout block */}
56
- {item.stdout && (
57
- <pre className="text-ink/85 whitespace-pre-wrap break-all px-2.5 py-1 overflow-x-auto selection:bg-ink/15 bg-canvas/40 rounded">
58
- {item.stdout}
59
- </pre>
60
- )}
61
-
62
- {/* Stderr block in signal red */}
63
- {item.stderr && (
64
- <pre className="text-error font-medium whitespace-pre-wrap break-all px-2.5 py-1 bg-error/10 rounded border border-error/20 selection:bg-error/30">
65
- {item.stderr}
66
- </pre>
67
- )}
68
- </div>
69
- );
70
- }
@@ -1,66 +0,0 @@
1
- import { useCallback, useEffect, useRef } from 'preact/hooks';
2
- import type { RefObject } from 'preact/compat';
3
- import type { Terminal } from '@xterm/xterm';
4
- import { useSessionState } from '@/client/hooks/workspace/session-state';
5
- import { useSessionStateContext } from '@/client/hooks/workspace/session-state/context';
6
- import { getSessionValue } from '@/shared/lib/workspace/session-state/store';
7
- import { appendTerminalSessionOutput, clearTerminalSessionOutput, getTerminalOutputSnapshot, setTerminalOutputSnapshot } from '@/client/data/theme/terminal';
8
-
9
- interface TerminalOutputSync {
10
- recordOutput: (chunk: string) => void;
11
- clearOutput: () => void;
12
- }
13
-
14
- const OUTPUT_PERSIST_INTERVAL_MS = 1000;
15
-
16
- export function useTerminalOutputSync(terminalRef: RefObject<Terminal>): TerminalOutputSync {
17
- const { sessionId, ready } = useSessionStateContext();
18
- const [, setStoredOutput] = useSessionState<string>('terminal.output', '');
19
- const setStoredOutputRef = useRef(setStoredOutput);
20
- setStoredOutputRef.current = setStoredOutput;
21
- const readyRef = useRef(ready);
22
- readyRef.current = ready;
23
- const lastPersistRef = useRef(0);
24
- const hydratedSessionRef = useRef<string | null>(null);
25
- const prevHydratedSessionRef = useRef<string | null>(null);
26
-
27
- const recordOutput = useCallback((chunk: string) => {
28
- appendTerminalSessionOutput(chunk);
29
- if (!readyRef.current) return;
30
- const now = Date.now();
31
- if (now - lastPersistRef.current < OUTPUT_PERSIST_INTERVAL_MS) return;
32
- lastPersistRef.current = now;
33
- setStoredOutputRef.current(getTerminalOutputSnapshot());
34
- }, []);
35
-
36
- const clearOutput = useCallback(() => {
37
- clearTerminalSessionOutput();
38
- if (!readyRef.current) return;
39
- lastPersistRef.current = Date.now();
40
- setStoredOutputRef.current('');
41
- }, []);
42
-
43
- // On restore, seed the module singleton before xterm rehydrates it; when the
44
- // term is already live, replace its buffer. A session switch always re-seeds,
45
- // while an initial mount without a stored snapshot keeps the live output.
46
- useEffect(() => {
47
- if (!ready || hydratedSessionRef.current === sessionId) return;
48
- const isSessionSwitch = prevHydratedSessionRef.current !== null;
49
- hydratedSessionRef.current = sessionId;
50
- prevHydratedSessionRef.current = sessionId;
51
- const restored = getSessionValue<string>(sessionId, 'terminal.output');
52
- if (restored === undefined && !isSessionSwitch) return;
53
- setTerminalOutputSnapshot(restored ?? '');
54
- const term = terminalRef.current;
55
- if (!term) return;
56
- term.clear();
57
- if (restored) {
58
- term.write(restored);
59
- term.scrollToBottom();
60
- } else {
61
- term.write('\x1b[33m$\x1b[0m ');
62
- }
63
- }, [ready, sessionId, terminalRef]);
64
-
65
- return { recordOutput, clearOutput };
66
- }