@orion-agents/orion-code 0.3.9 → 0.3.11

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 CHANGED
@@ -22,12 +22,45 @@ which is **not** a pass.
22
22
 
23
23
  ## [Unreleased]
24
24
 
25
- ## [0.3.9] — CANDIDATE
25
+ ## [0.3.11] — CANDIDATE
26
+
27
+ > **Status: candidate.** Not merged, tagged or published to npm.
28
+
29
+ ### Added
30
+
31
+ - The right work panel becomes a **vertical-rail menu** (v0.3.8-plan carried
32
+ forward): a persistent 48px icon rail replaces the expand-then-horizontal-tabs
33
+ flow; clicking an icon shows exactly that panel, re-clicking collapses back to
34
+ the rail, and Esc closes the content area (input/terminal/alertdialog
35
+ exempted). The rail carries terminal status badges (running/queued/approval/
36
+ failed), keyboard shortcuts (Cmd/Ctrl+Shift+1-5) jump directly without
37
+ toggling, and the terminal keeps its xterm session while resource panels
38
+ mount active-only. An optional user icon order is persisted in the layout
39
+ preference (`workPanel.order`).
40
+ - Idempotency contract tests carried over from the v0.3.8 branch: reducer
41
+ archive/restore/delete no-op and no-duplicate cases; storage archive-twice
42
+ and restore-never-archived cases.
43
+
44
+ ## [0.3.10] — NPM-PUBLISHED
45
+
46
+ > **Status: npm-published.** `@orion-agents/orion-code@0.3.10` is available through the npm
47
+ > registry (latest tag). Published 2026-09-04; git tag/release may lag.
48
+
49
+ ### Added
50
+
51
+ - The local Web host defaults to port **4242** (M42, the Orion Nebula) instead of
52
+ the generic 3080; `DEFAULT_WEB_PORT` is the single source shared by
53
+ cli-options, launch and server.
54
+ - `orion web start [--port N]`: idempotent background-host start (prints the URL
55
+ when already running); start/restart/`--background` share one arg builder.
56
+ - README documents the background-host lifecycle (`start|status|stop|restart`,
57
+ pidfile/log locations) and the launchd foreground-supervision recipe.
26
58
 
27
59
  ## [0.3.9] — CANDIDATE
28
60
 
29
- > **Status: candidate.** Deterministic-bug-fix release + background host lifecycle
30
- > (issue #247 S1/S2). Not merged, tagged or published to npm.
61
+ > **Status: npm-published.** `@orion-agents/orion-code@0.3.9` is available through the npm
62
+ > registry (latest tag); deterministic-bug-fix release + background host lifecycle
63
+ > (issue #247 S1/S2). Published 2026-09-04; git tag/release may lag.
31
64
 
32
65
  ### Added
33
66
 
package/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Local-first, goal-driven coding agent for the terminal and browser.
4
4
 
5
- > v0.3.9 candidate — deterministic-bug sweep over the open issue set plus a native
6
- > background-host lifecycle: `orion web --background` with pidfile/log management
7
- > (`orion web status|stop|restart`). Candidate source is not an npm publication,
8
- > Git tag, or merge-ready release.
5
+ > v0.3.11 candidate — the right work panel is a vertical-rail menu: a persistent
6
+ > 48px icon rail shows exactly the panel you click (re-click collapses, Esc
7
+ > closes), carries terminal status badges, and honors a persisted icon order.
8
+ > Candidate source is not an npm publication, Git tag, or merge-ready release.
9
9
 
10
10
  [中文说明](README.zh-CN.md) ·
11
11
  [v0.3.7 plan](docs/plan/v0.3.7-left-rail-improvement-plan.md) ·
@@ -170,7 +170,7 @@ current development environments. Node 20 is upstream EOL and is no longer a v0.
170
170
  After the immutable `0.3.5` npm receipt exists:
171
171
 
172
172
  ```bash
173
- npm install -g @orion-agents/orion-code@0.3.9
173
+ npm install -g @orion-agents/orion-code@0.3.11
174
174
  orion --version
175
175
  orion doctor
176
176
  ```
@@ -258,6 +258,30 @@ atomic, revision-guarded Context transition. The left dock is 240–480px or a 4
258
258
  Narrow layouts use drawers without overwriting desktop widths. Files, Git and Review are read-only;
259
259
  terminal creation requires an explicit gesture and its ticket/output never enter Workbench SSE.
260
260
 
261
+ #### Background host & lifecycle (v0.3.10)
262
+
263
+ The Web Workbench binds **127.0.0.1 only**; the default port is **4242** (M42, the
264
+ Orion Nebula) so it never collides with common dev-tool ports.
265
+
266
+ ```bash
267
+ orion web # foreground; open http://127.0.0.1:4242
268
+ orion web --background # detached host (pidfile + logs, survives terminal exit)
269
+ orion web start [--port N] # idempotent background start
270
+ orion web status [--port N] # running pid/URL/workspace or stale report
271
+ orion web restart [--port N] # stop + start
272
+ orion web stop [--port N] # graceful SIGTERM stop
273
+ ```
274
+
275
+ The pidfile lives at `~/.orion-code/web-host.<port>.pid` and logs append to
276
+ `~/.orion-code/logs/web-<port>.log`. Backgrounding is a process-lifecycle feature
277
+ only: approval, context-revision and sandbox rules stay fail-closed, and the host
278
+ never binds beyond loopback.
279
+
280
+ For crash-restart and login autostart on macOS, register the **foreground** command
281
+ (`orion web --no-open --port 4242 --cwd <dir>`) in a launchd LaunchAgent
282
+ (`RunAtLoad` + `KeepAlive`) — do not combine it with `--background`, because
283
+ launchd must supervise the host process itself.
284
+
261
285
  #### Host-managed Settings
262
286
 
263
287
  The Settings dialog reads from the active Host rather than treating browser storage as a second
package/README.zh-CN.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  面向终端与浏览器、本地优先的目标驱动 Coding Agent。
4
4
 
5
- > v0.3.9 候选版本:对 OPEN issue 集的确定性 bug 清扫 + 原生后台 host 生命周期 ——
6
- > `orion web --background`(pidfile/日志)与 `orion web status|stop|restart` 管理。
5
+ > v0.3.11 候选版本:右侧工作面板改为**竖状 rail 菜单**——常驻 48px 竖栏,
6
+ > 点击图标即展示对应面板(再点收起、Esc 关闭),带终端状态徽标并支持持久化图标顺序。
7
7
  > Candidate 源码不代表已创建 npm 发布、Git tag 或达到可合并状态。
8
8
 
9
9
  [English](README.md) ·
@@ -101,7 +101,7 @@ Current。Node 20 已结束上游维护,不再属于 v0.3 Runtime 合同。
101
101
  当 npm 已存在不可变的 `0.3.4` 发布凭据后:
102
102
 
103
103
  ```bash
104
- npm install -g @orion-agents/orion-code@0.3.9
104
+ npm install -g @orion-agents/orion-code@0.3.11
105
105
  orion --version
106
106
  orion doctor
107
107
  ```
@@ -185,6 +185,23 @@ Host 时会 abort 并 fail-closed。
185
185
  键盘精细调宽。窄屏自动使用 drawer,且不覆盖桌面宽度偏好。文件、Git 和审阅保持只读;创建终端需要
186
186
  显式 user gesture,短期 ticket 与输出均不进入 Workbench SSE。
187
187
 
188
+ #### 后台运行与管理(v0.3.10)
189
+
190
+ Web Workbench 只绑定 **127.0.0.1**;默认端口为 **4242**(M42,猎户座大星云),避免与常用开发端口冲突。
191
+
192
+ ```bash
193
+ orion web # 前台启动;打开 http://127.0.0.1:4242
194
+ orion web --background # 脱离终端的后台 host(pidfile + 日志)
195
+ orion web start [--port N] # 幂等后台启动
196
+ orion web status [--port N] # 查看运行 pid/URL/workspace
197
+ orion web restart [--port N] # 重启
198
+ orion web stop [--port N] # 优雅停止
199
+ ```
200
+
201
+ pidfile 位于 `~/.orion-code/web-host.<port>.pid`,日志追加到 `~/.orion-code/logs/web-<port>.log`。后台化只涉及进程生命周期:审批/上下文版本/沙箱规则保持 fail-closed,host 绝不绑定局域网。
202
+
203
+ macOS 需要崩溃自动重启与开机自启时,用 launchd LaunchAgent 托管**前台**命令(`orion web --no-open --port 4242 --cwd <dir>`,`RunAtLoad`+`KeepAlive`)——不要与 `--background` 混用,launchd 必须直接监管 host 进程。
204
+
188
205
  #### Host 管理的 Settings
189
206
 
190
207
  Settings dialog 从当前 Host 读取设置,不把浏览器存储当成第二配置真源。主题和减少动效会跨刷新、端口
package/dist/cli.js CHANGED
@@ -58,10 +58,20 @@ function showWebHelp() {
58
58
  console.log('Usage: orion web [--port <number>] [--no-open] [--cwd <directory>] [--background]');
59
59
  console.log('Starts the local-only Web Workbench on 127.0.0.1.');
60
60
  console.log(' --background run detached in the background (pidfile + logs under ~/.orion-code)');
61
+ console.log('orion web start [--port <number>] [--cwd <directory>] [--no-open]');
61
62
  console.log('orion web status [--port <number>]');
62
63
  console.log('orion web stop [--port <number>]');
63
64
  console.log('orion web restart [--port <number>]');
64
- console.log(' Manage a background host started with --background.');
65
+ console.log(' Manage a background host started with --background (start starts one).');
66
+ }
67
+ function webBackgroundArgs(options) {
68
+ return [
69
+ ...(options.open ? [] : ['--no-open']),
70
+ '--port',
71
+ String(options.port),
72
+ '--cwd',
73
+ options.cwd,
74
+ ];
65
75
  }
66
76
  async function manageBackgroundHost(command, args) {
67
77
  const options = (0, cli_options_1.parseWebCliOptions)(args);
@@ -157,6 +167,20 @@ async function main() {
157
167
  return;
158
168
  }
159
169
  const rest = args.slice(1);
170
+ if (rest[0] === 'start') {
171
+ const startOptions = (0, cli_options_1.parseWebCliOptions)(rest.slice(1));
172
+ const current = (0, host_daemon_1.hostDaemonStatus)(startOptions.port);
173
+ if (current.state === 'running') {
174
+ console.log(`orion web is already running: ${current.pidfile.url} (pid ${current.pidfile.pid})`);
175
+ return;
176
+ }
177
+ await (0, web_1.runOrionWeb)({
178
+ ...startOptions,
179
+ background: true,
180
+ backgroundArgs: webBackgroundArgs(startOptions),
181
+ });
182
+ return;
183
+ }
160
184
  if (rest[0] === 'status' || rest[0] === 'stop') {
161
185
  await manageBackgroundHost(rest[0], rest.slice(1));
162
186
  return;
@@ -167,25 +191,12 @@ async function main() {
167
191
  await (0, web_1.runOrionWeb)({
168
192
  ...restartOptions,
169
193
  background: true,
170
- backgroundArgs: [
171
- ...(restartOptions.open ? [] : ['--no-open']),
172
- '--port',
173
- String(restartOptions.port),
174
- '--cwd',
175
- restartOptions.cwd,
176
- ],
194
+ backgroundArgs: webBackgroundArgs(restartOptions),
177
195
  });
178
196
  return;
179
197
  }
180
198
  const options = (0, cli_options_1.parseWebCliOptions)(rest);
181
- const backgroundArgs = [
182
- ...(options.open ? [] : ['--no-open']),
183
- '--port',
184
- String(options.port),
185
- '--cwd',
186
- options.cwd,
187
- ];
188
- await (0, web_1.runOrionWeb)({ ...options, backgroundArgs });
199
+ await (0, web_1.runOrionWeb)({ ...options, backgroundArgs: webBackgroundArgs(options) });
189
200
  return;
190
201
  }
191
202
  if (args[0] === 'migrate') {
@@ -2,7 +2,11 @@
2
2
  * CLI option parsing for `orion web` (extracted from the CLI entry so the
3
3
  * grammar has a unit-testable surface — issue #218 regression coverage).
4
4
  */
5
- export declare const DEFAULT_WEB_PORT = 3080;
5
+ /**
6
+ * M42 (Orion Nebula) — the local Web Workbench host binds this by default so
7
+ * `orion web` never collides with common dev-tool ports.
8
+ */
9
+ export declare const DEFAULT_WEB_PORT = 4242;
6
10
  export interface WebCliOptions {
7
11
  readonly port: number;
8
12
  readonly open: boolean;
@@ -6,7 +6,11 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.DEFAULT_WEB_PORT = void 0;
8
8
  exports.parseWebCliOptions = parseWebCliOptions;
9
- exports.DEFAULT_WEB_PORT = 3080;
9
+ /**
10
+ * M42 (Orion Nebula) — the local Web Workbench host binds this by default so
11
+ * `orion web` never collides with common dev-tool ports.
12
+ */
13
+ exports.DEFAULT_WEB_PORT = 4242;
10
14
  function parseWebCliOptions(args) {
11
15
  let port = exports.DEFAULT_WEB_PORT;
12
16
  let open = true;
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * The pidfile shape is intentionally tiny and human-readable:
11
11
  *
12
- * { "pid": 12345, "port": 3080, "url": "http://127.0.0.1:3080",
12
+ * { "pid": 12345, "port": 4242, "url": "http://127.0.0.1:4242",
13
13
  * "startedAt": 1725000000000, "workspace": "/abs/path" }
14
14
  */
15
15
  import { type ChildProcess } from 'child_process';
@@ -22,7 +22,7 @@ exports.stopBackgroundHost = stopBackgroundHost;
22
22
  *
23
23
  * The pidfile shape is intentionally tiny and human-readable:
24
24
  *
25
- * { "pid": 12345, "port": 3080, "url": "http://127.0.0.1:3080",
25
+ * { "pid": 12345, "port": 4242, "url": "http://127.0.0.1:4242",
26
26
  * "startedAt": 1725000000000, "workspace": "/abs/path" }
27
27
  */
28
28
  const child_process_1 = require("child_process");
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runOrionWeb = runOrionWeb;
4
+ const cli_options_1 = require("./cli-options");
4
5
  const child_process_1 = require("child_process");
5
6
  const server_1 = require("./server");
6
7
  const host_daemon_1 = require("./host-daemon");
@@ -8,7 +9,7 @@ async function runOrionWeb(options) {
8
9
  const stdout = options.stdout ?? process.stdout;
9
10
  const stderr = options.stderr ?? process.stderr;
10
11
  const isDaemonChild = process.env[host_daemon_1.HOST_DAEMON_CHILD_ENV] === '1';
11
- const port = options.port ?? 3080;
12
+ const port = options.port ?? cli_options_1.DEFAULT_WEB_PORT;
12
13
  if (options.background && !isDaemonChild) {
13
14
  // Parent side: launch detached and wait for its pidfile, then print the URL.
14
15
  const { pidfile } = await (0, host_daemon_1.spawnBackgroundHost)({
@@ -9,12 +9,13 @@ const version_1 = require("../product/version");
9
9
  const redaction_1 = require("../services/redaction");
10
10
  const protocol_1 = require("./protocol");
11
11
  const errors_1 = require("./errors");
12
+ const cli_options_1 = require("./cli-options");
12
13
  const terminal_server_1 = require("./terminal-server");
13
14
  const workbench_controller_1 = require("./workbench-controller");
14
15
  const HOST = '127.0.0.1';
15
16
  const API_PREFIX = '/api/v1';
16
17
  async function startOrionWebServer(options) {
17
- const requestedPort = options.port ?? 3080;
18
+ const requestedPort = options.port ?? cli_options_1.DEFAULT_WEB_PORT;
18
19
  if (!Number.isSafeInteger(requestedPort) || requestedPort < 0 || requestedPort > 65535) {
19
20
  throw new Error('Web port must be an integer from 0 through 65535.');
20
21
  }
@@ -1,4 +1,4 @@
1
- import{r as u,j as s,I as N}from"./index-Dv_uE9dk.js";function v(t){const n=[];let i;for(const r of t)r.startsWith("@@")?(i&&n.push(i),i={title:r,lines:[r]}):i&&i.lines.push(r);return i&&n.push(i),n}function D(t,n){const i={schemaVersion:1,type:"review_context",repositoryRevision:t.repositoryRevision,path:t.path,hunk:n.title},r=n.lines.join(`
1
+ import{r as u,j as s,I as N}from"./index-BlFUf8dG.js";function v(t){const n=[];let i;for(const r of t)r.startsWith("@@")?(i&&n.push(i),i={title:r,lines:[r]}):i&&i.lines.push(r);return i&&n.push(i),n}function D(t,n){const i={schemaVersion:1,type:"review_context",repositoryRevision:t.repositoryRevision,path:t.path,hunk:n.title},r=n.lines.join(`
2
2
  `).slice(0,12e3);return[`请审阅 ${t.path} 的这个 diff hunk,并指出正确性、安全性和测试风险:`,"","```review_context",JSON.stringify(i,null,2),"```","","```diff",r,"```"].join(`
3
3
  `)}function H({page:t,loading:n=!1,onLoadMore:i,onSendToComposer:r}){const a=u.useMemo(()=>v(t.lines),[t.lines]),[m,h]=u.useState(0),[f,p]=u.useState(!1),[x,k]=u.useState(!1),[b,y]=u.useState(""),d=Math.min(m,Math.max(0,a.length-1)),c=a[d];u.useEffect(()=>{h(0),p(!1),y("")},[t.fileId,t.repositoryRevision]);const j=(e,l)=>{let o=l;if(e.key==="ArrowRight"||e.key==="ArrowDown")o=(l+1)%a.length;else if(e.key==="ArrowLeft"||e.key==="ArrowUp")o=(l-1+a.length)%a.length;else if(e.key==="Home")o=0;else if(e.key==="End")o=a.length-1;else return;e.preventDefault(),h(o);const w=e.currentTarget.parentElement;window.requestAnimationFrame(()=>w?.querySelector(`[data-hunk-index="${o}"]`)?.focus())};return t.binary?s.jsxs("div",{className:"resource-empty compact",children:[s.jsx(N,{name:"code"}),s.jsx("strong",{children:"二进制差异"}),s.jsx("p",{children:"只展示变更事实,不返回 binary patch。"})]}):s.jsxs("div",{className:"diff-viewer",children:[s.jsxs("header",{children:[s.jsx("strong",{title:t.path,children:t.path}),s.jsx("span",{children:t.truncated?"受限预览":`${t.lines.length} 行`})]}),a.length>1?s.jsx("div",{className:"diff-hunk-nav",role:"tablist","aria-label":"Diff hunks",children:a.map((e,l)=>s.jsx("button",{type:"button",role:"tab","data-hunk-index":l,"aria-selected":d===l,tabIndex:d===l?0:-1,onClick:()=>h(l),onKeyDown:o=>j(o,l),children:e.title||`Hunk ${l+1}`},`${e.title}-${l}`))}):null,s.jsxs("div",{className:"diff-actions","aria-label":"Diff 显示选项",children:[c?s.jsx("button",{type:"button",className:"text-button","aria-expanded":!f,onClick:()=>p(e=>!e),children:f?"展开 Hunk":"折叠 Hunk"}):null,s.jsx("button",{type:"button",className:"text-button","aria-pressed":x,onClick:()=>k(e=>!e),children:"显示空白字符"}),c?s.jsx("button",{type:"button",className:"text-button",onClick:()=>{$(c.lines.join(`
4
4
  `),y)},children:"复制 Hunk"}):null]}),f?null:s.jsx("pre",{className:"diff-lines",tabIndex:0,"aria-label":`Diff ${t.path}`,children:(c?.lines??t.lines).map((e,l)=>s.jsxs("span",{className:e.startsWith("+")?"addition":e.startsWith("-")?"deletion":"",children:[S(e,x)||" ",`
@@ -1,2 +1,2 @@
1
- import{r as c,j as e,I as C,s as I,W as ee}from"./index-Dv_uE9dk.js";function ae({workspaceId:s,refreshEpoch:l,actions:i}){const[r,a]=c.useState({}),[m,j]=c.useState(new Set(["workspace-root"])),[o,f]=c.useState(null),[h,d]=c.useState(""),[N,$]=c.useState(null),[J,E]=c.useState(!1),[T,R]=c.useState(""),[B,g]=c.useState(""),[D,U]=c.useState(""),[M,X]=c.useState(!1),[K,Y]=c.useState("1"),[O,L]=c.useState({}),[P,F]=c.useState(""),W=c.useRef(null),x=c.useRef(0),k=c.useRef(0),w=async(t,n=!1,y=x.current)=>{if(y!==x.current)return;const p=r[t],v=n?p?.nextCursor:void 0;if(!(n&&!v)){a(u=>({...u,[t]:{items:p?.items??[],nextCursor:p?.nextCursor??null,revision:p?.revision??"",loading:!0}}));try{const u=await i.listFiles(t,v??void 0);if(y!==x.current)return;a(b=>({...b,[t]:{items:n?se(b[t]?.items??[],u.items):u.items,nextCursor:u.nextCursor,revision:u.revision,loading:!1}}))}catch(u){if(y!==x.current)return;if(n&&V(u)){g("目录已变化,已重新载入第一页。"),w(t,!1,y);return}a(b=>({...b,[t]:{items:b[t]?.items??[],nextCursor:b[t]?.nextCursor??null,revision:b[t]?.revision??"",loading:!1,error:G(u)}}))}}},_=async(t=x.current)=>{try{const n=await i.gitStatus();if(t!==x.current)return;L(re(n)),F(n.nextCursor?"Git 装饰仅显示首批 200 个变更;在 Git 面板继续分页查看。":"")}catch(n){if(t!==x.current)return;L({}),F(`Git 状态装饰不可用:${G(n)}`)}};c.useEffect(()=>{const t=x.current+1;x.current=t,k.current+=1,a({}),j(new Set(["workspace-root"])),f(null),d(""),$(null),E(!1),R(""),g(""),L({}),F(""),s&&(w("workspace-root",!1,t),_(t))},[l,s]);const S=async(t,n=!1,y=!1,p=x.current,v=k.current+1)=>{if(p===x.current&&!(!t.readable||t.sensitive||z(t))){k.current=v,f(t),R(""),n||(d(""),$(null),E(!1)),y||g("");try{const u=await i.readFileContent(t.id,n?N??void 0:void 0);if(p!==x.current||v!==k.current)return;E(u.binary),d(b=>n?`${b}${u.content??""}`:u.content??""),$(u.nextCursor),y&&g("文件已变化,已从第一页重新载入。")}catch(u){if(p!==x.current||v!==k.current)return;if(n&&V(u)){await S(t,!1,!0,p,v);return}R(G(u))}}},A=t=>{const n=new Set(m);n.has(t)?n.delete(t):(n.add(t),r[t]||w(t)),j(n)},Z=c.useMemo(()=>Object.values(r).flatMap(t=>t.items),[r]),Q=D.trim()?Z.filter(t=>t.name.toLocaleLowerCase().includes(D.toLocaleLowerCase())):null;return e.jsxs("div",{className:"work-resource-panel files-panel",children:[e.jsxs("div",{className:"resource-toolbar",children:[e.jsxs("label",{className:"resource-search",children:[e.jsx("span",{className:"sr-only",children:"搜索已加载文件"}),e.jsx(C,{name:"search",size:14}),e.jsx("input",{type:"search",value:D,onChange:t=>U(t.target.value),placeholder:"搜索已加载文件"})]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新文件树",onClick:()=>{w("workspace-root"),_()},children:e.jsx(C,{name:"refresh",size:15})})]}),e.jsxs("div",{className:"files-layout",children:[e.jsxs("section",{className:"file-tree","aria-label":"工作区文件",children:[P?e.jsx("p",{className:"resource-hint",role:"status",children:P}):null,Q?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"resource-hint",children:"搜索仅覆盖已加载的目录和文件。"}),e.jsx("ul",{role:"list",className:"file-node-list search-results",children:Q.map(t=>e.jsx(H,{node:t,depth:0,expanded:!1,selected:o?.id===t.id,gitLabels:O[t.displayPath]??[],onToggle:A,onSelect:n=>{S(n)}},t.id))})]}):e.jsx(q,{parentId:"workspace-root",depth:0,directories:r,expanded:m,selectedId:o?.id,gitDecorations:O,onToggle:A,onSelect:t=>{S(t)},onLoadMore:t=>{w(t,!0)}})]}),e.jsxs("section",{className:"file-preview","aria-label":"文件预览",children:[B?e.jsx("p",{className:"resource-notice",role:"status",children:B}):null,o?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:ne(o.sizeBytes??0)})]}),T?e.jsx("p",{className:"resource-error",role:"alert",children:T}):J?e.jsxs("div",{className:"resource-empty",children:[e.jsx(C,{name:"code"}),e.jsx("strong",{children:"二进制文件"}),e.jsx("p",{children:"出于安全和性能考虑,只显示元数据。"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"file-preview-actions",children:[e.jsxs("label",{children:[e.jsx("span",{className:"sr-only",children:"跳到行"}),e.jsx("input",{type:"number",min:"1",value:K,"aria-label":"跳到行",onChange:t=>Y(t.target.value)})]}),e.jsx("button",{type:"button",className:"text-button",onClick:()=>ie(W.current,K),children:"跳转"}),e.jsx("button",{type:"button",className:"text-button",onClick:()=>{le(h,g)},children:"复制"}),e.jsx("button",{type:"button",className:"text-button","aria-pressed":M,onClick:()=>X(t=>!t),children:"自动换行"})]}),e.jsx("pre",{ref:W,tabIndex:0,className:`file-code-view ${M?"wrap":""}`,"aria-label":`文件内容 ${o.name}`,children:I(h).split(`
1
+ import{r as c,j as e,I as C,s as I,W as ee}from"./index-BlFUf8dG.js";function ae({workspaceId:s,refreshEpoch:l,actions:i}){const[r,a]=c.useState({}),[m,j]=c.useState(new Set(["workspace-root"])),[o,f]=c.useState(null),[h,d]=c.useState(""),[N,$]=c.useState(null),[J,E]=c.useState(!1),[T,R]=c.useState(""),[B,g]=c.useState(""),[D,U]=c.useState(""),[M,X]=c.useState(!1),[K,Y]=c.useState("1"),[O,L]=c.useState({}),[P,F]=c.useState(""),W=c.useRef(null),x=c.useRef(0),k=c.useRef(0),w=async(t,n=!1,y=x.current)=>{if(y!==x.current)return;const p=r[t],v=n?p?.nextCursor:void 0;if(!(n&&!v)){a(u=>({...u,[t]:{items:p?.items??[],nextCursor:p?.nextCursor??null,revision:p?.revision??"",loading:!0}}));try{const u=await i.listFiles(t,v??void 0);if(y!==x.current)return;a(b=>({...b,[t]:{items:n?se(b[t]?.items??[],u.items):u.items,nextCursor:u.nextCursor,revision:u.revision,loading:!1}}))}catch(u){if(y!==x.current)return;if(n&&V(u)){g("目录已变化,已重新载入第一页。"),w(t,!1,y);return}a(b=>({...b,[t]:{items:b[t]?.items??[],nextCursor:b[t]?.nextCursor??null,revision:b[t]?.revision??"",loading:!1,error:G(u)}}))}}},_=async(t=x.current)=>{try{const n=await i.gitStatus();if(t!==x.current)return;L(re(n)),F(n.nextCursor?"Git 装饰仅显示首批 200 个变更;在 Git 面板继续分页查看。":"")}catch(n){if(t!==x.current)return;L({}),F(`Git 状态装饰不可用:${G(n)}`)}};c.useEffect(()=>{const t=x.current+1;x.current=t,k.current+=1,a({}),j(new Set(["workspace-root"])),f(null),d(""),$(null),E(!1),R(""),g(""),L({}),F(""),s&&(w("workspace-root",!1,t),_(t))},[l,s]);const S=async(t,n=!1,y=!1,p=x.current,v=k.current+1)=>{if(p===x.current&&!(!t.readable||t.sensitive||z(t))){k.current=v,f(t),R(""),n||(d(""),$(null),E(!1)),y||g("");try{const u=await i.readFileContent(t.id,n?N??void 0:void 0);if(p!==x.current||v!==k.current)return;E(u.binary),d(b=>n?`${b}${u.content??""}`:u.content??""),$(u.nextCursor),y&&g("文件已变化,已从第一页重新载入。")}catch(u){if(p!==x.current||v!==k.current)return;if(n&&V(u)){await S(t,!1,!0,p,v);return}R(G(u))}}},A=t=>{const n=new Set(m);n.has(t)?n.delete(t):(n.add(t),r[t]||w(t)),j(n)},Z=c.useMemo(()=>Object.values(r).flatMap(t=>t.items),[r]),Q=D.trim()?Z.filter(t=>t.name.toLocaleLowerCase().includes(D.toLocaleLowerCase())):null;return e.jsxs("div",{className:"work-resource-panel files-panel",children:[e.jsxs("div",{className:"resource-toolbar",children:[e.jsxs("label",{className:"resource-search",children:[e.jsx("span",{className:"sr-only",children:"搜索已加载文件"}),e.jsx(C,{name:"search",size:14}),e.jsx("input",{type:"search",value:D,onChange:t=>U(t.target.value),placeholder:"搜索已加载文件"})]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新文件树",onClick:()=>{w("workspace-root"),_()},children:e.jsx(C,{name:"refresh",size:15})})]}),e.jsxs("div",{className:"files-layout",children:[e.jsxs("section",{className:"file-tree","aria-label":"工作区文件",children:[P?e.jsx("p",{className:"resource-hint",role:"status",children:P}):null,Q?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"resource-hint",children:"搜索仅覆盖已加载的目录和文件。"}),e.jsx("ul",{role:"list",className:"file-node-list search-results",children:Q.map(t=>e.jsx(H,{node:t,depth:0,expanded:!1,selected:o?.id===t.id,gitLabels:O[t.displayPath]??[],onToggle:A,onSelect:n=>{S(n)}},t.id))})]}):e.jsx(q,{parentId:"workspace-root",depth:0,directories:r,expanded:m,selectedId:o?.id,gitDecorations:O,onToggle:A,onSelect:t=>{S(t)},onLoadMore:t=>{w(t,!0)}})]}),e.jsxs("section",{className:"file-preview","aria-label":"文件预览",children:[B?e.jsx("p",{className:"resource-notice",role:"status",children:B}):null,o?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:ne(o.sizeBytes??0)})]}),T?e.jsx("p",{className:"resource-error",role:"alert",children:T}):J?e.jsxs("div",{className:"resource-empty",children:[e.jsx(C,{name:"code"}),e.jsx("strong",{children:"二进制文件"}),e.jsx("p",{children:"出于安全和性能考虑,只显示元数据。"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"file-preview-actions",children:[e.jsxs("label",{children:[e.jsx("span",{className:"sr-only",children:"跳到行"}),e.jsx("input",{type:"number",min:"1",value:K,"aria-label":"跳到行",onChange:t=>Y(t.target.value)})]}),e.jsx("button",{type:"button",className:"text-button",onClick:()=>ie(W.current,K),children:"跳转"}),e.jsx("button",{type:"button",className:"text-button",onClick:()=>{le(h,g)},children:"复制"}),e.jsx("button",{type:"button",className:"text-button","aria-pressed":M,onClick:()=>X(t=>!t),children:"自动换行"})]}),e.jsx("pre",{ref:W,tabIndex:0,className:`file-code-view ${M?"wrap":""}`,"aria-label":`文件内容 ${o.name}`,children:I(h).split(`
2
2
  `).map((t,n)=>e.jsxs("span",{className:"file-code-line","data-line":n+1,children:[e.jsx("span",{className:"file-line-number","aria-hidden":"true",children:n+1}),e.jsx("span",{className:"file-line-content",children:t||" "})]},n))})]}),N?e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{S(o,!0)},children:"加载更多内容"}):null]}):e.jsxs("div",{className:"resource-empty",children:[e.jsx(C,{name:"workspace"}),e.jsx("strong",{children:"选择文件预览"}),e.jsx("p",{children:"敏感文件、工作区外链接和二进制正文不会返回浏览器。"})]})]})]})]})}function q({parentId:s,depth:l,directories:i,expanded:r,selectedId:a,gitDecorations:m,onToggle:j,onSelect:o,onLoadMore:f}){const h=i[s];return h?h.error?e.jsx("p",{className:"resource-error",role:"alert",children:h.error}):e.jsxs("ul",{role:"list",className:"file-node-list",children:[h.items.map(d=>{const N=r.has(d.id);return e.jsxs("li",{children:[e.jsx(H,{node:d,depth:l,expanded:N,selected:a===d.id,gitLabels:m[d.displayPath]??[],onToggle:j,onSelect:o}),z(d)&&N?e.jsx(q,{parentId:d.id,depth:l+1,directories:i,expanded:r,selectedId:a,gitDecorations:m,onToggle:j,onSelect:o,onLoadMore:f}):null]},d.id)}),h.loading?e.jsx("li",{className:"resource-loading",children:"正在读取…"}):null,h.nextCursor?e.jsx("li",{children:e.jsx("button",{type:"button",className:"text-button",onClick:()=>f(s),children:"加载更多"})}):null]}):e.jsx("p",{className:"resource-loading",children:"正在读取…"})}function H({node:s,depth:l,expanded:i,selected:r,gitLabels:a,onToggle:m,onSelect:j}){const o=s.sensitive||!s.readable,f=z(s);return e.jsxs("button",{type:"button",className:`file-node ${r?"selected":""} ${o?"blocked":""}`,style:{paddingInlineStart:`${8+l*15}px`},"aria-expanded":f?i:void 0,"aria-label":`${te(s)} ${s.name}${o?",不可读取":""}${a.length?`,Git ${a.join("、")}`:""}`,onClick:()=>f?m(s.id):j(s),disabled:o,children:[e.jsx(C,{name:f?"workspace":"code",size:14}),e.jsx("span",{children:s.name}),s.kind==="symlink"?e.jsx("small",{children:"链接"}):null,s.sensitive?e.jsx("small",{children:"敏感"}):null,a.length?e.jsx("small",{className:"file-git-status",title:`Git ${a.join("、")}`,children:a.join(" · ")}):null]})}function te(s){return s.kind==="directory"?"目录":s.kind==="symlink"?s.targetKind==="directory"?"符号链接目录":"符号链接":"文件"}function z(s){return s.kind==="directory"||s.kind==="symlink"&&s.targetKind==="directory"}function se(s,l){const i=new Map(s.map(r=>[r.id,r]));for(const r of l)i.set(r.id,r);return[...i.values()]}function re(s){if(!s.isRepository)return{};const l=new Map,i=(r,a)=>{const m=r.replace(/\\/gu,"/").replace(/^\.\//u,"");if(!m)return;const j=l.get(m)??new Set;j.add(a),l.set(m,j);const o=m.split("/");for(let f=1;f<o.length;f+=1){const h=o.slice(0,f).join("/"),d=l.get(h)??new Set;d.add("含变更"),l.set(h,d)}};return s.conflicted.forEach(r=>i(r.path,"冲突")),s.staged.forEach(r=>i(r.path,"已暂存")),s.unstaged.forEach(r=>i(r.path,"未暂存")),s.untracked.forEach(r=>i(r.path,"未跟踪")),Object.fromEntries([...l].map(([r,a])=>[r,Object.freeze([...a])]))}function ne(s){return s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(1)} MB`}function V(s){return s instanceof ee&&s.code==="file_revision_conflict"}function ie(s,l){const i=Number(l);!s||!Number.isSafeInteger(i)||i<1||(s.querySelector(`[data-line="${i}"]`)?.scrollIntoView({block:"center"}),s.focus())}async function le(s,l){try{await navigator.clipboard.writeText(s),l("已复制当前加载的文件内容。")}catch{l("浏览器未允许复制,请手动选择文本。")}}function G(s){return s instanceof Error?s.message:"文件请求失败。"}export{ae as FilesPanel};
@@ -1 +1 @@
1
- import{r as d,j as e,I as g,W as _}from"./index-Dv_uE9dk.js";import{D as W}from"./DiffViewer-MMhvMif-.js";function K({workspaceId:c,refreshEpoch:m,actions:u,onSendToComposer:o}){const[a,I]=d.useState(null),[j,k]=d.useState(null),[G,y]=d.useState(null),[v,N]=d.useState(null),[R,h]=d.useState(!1),[w,f]=d.useState(""),[E,p]=d.useState(""),n=d.useRef(0),x=d.useRef(0),b=async(t=n.current)=>{if(t===n.current){h(!0),f("");try{const[s,l]=await Promise.all([u.gitStatus(),u.gitLog()]);if(t!==n.current)return;I(s),k(l),y(null),N(null)}catch(s){if(t!==n.current)return;f(S(s))}finally{t===n.current&&h(!1)}}},$=()=>{const t=n.current+1;n.current=t,x.current+=1,p(""),b(t)};d.useEffect(()=>{const t=n.current+1;n.current=t,x.current+=1,I(null),k(null),y(null),N(null),f(""),p(""),c&&b(t)},[m,c]);const M=async(t,s,l=n.current,r=x.current+1)=>{if(l===n.current){x.current=r,s||(y(t),N(null)),h(!0),f("");try{const i=await u.gitDiff(t.fileId,s);if(l!==n.current||r!==x.current||i.fileId!==t.fileId)return;y(t),N(D=>s&&D&&D.fileId===i.fileId?{...i,lines:[...D.lines,...i.lines]}:i)}catch(i){if(l!==n.current||r!==x.current)return;if(L(i)){p("仓库已变化,已重新载入 Git 状态。"),await b(l);return}f(S(i))}finally{l===n.current&&r===x.current&&h(!1)}}},z=async()=>{const t=a?.nextCursor;if(!t||!a)return;const s=n.current,l=a.repositoryRevision;h(!0),f("");try{const r=await u.gitStatus(t);if(s!==n.current)return;if(r.repositoryRevision!==l)throw A();I(i=>!i||i.repositoryRevision!==l?i:{...r,conflicted:C(i.conflicted,r.conflicted),staged:C(i.staged,r.staged),unstaged:C(i.unstaged,r.unstaged),untracked:C(i.untracked,r.untracked)})}catch(r){if(s!==n.current)return;if(L(r)){p("仓库已变化,已重新载入 Git 状态。"),await b(s);return}f(S(r))}finally{s===n.current&&h(!1)}},F=async()=>{const t=j?.nextCursor;if(!t||!j)return;const s=n.current,l=j.repositoryRevision;h(!0),f("");try{const r=await u.gitLog(t);if(s!==n.current)return;if(r.repositoryRevision!==l)throw A();k(i=>!i||i.repositoryRevision!==l?i:{...r,items:V(i.items,r.items)})}catch(r){if(s!==n.current)return;if(L(r)){p("提交历史已变化,已重新载入第一页。"),await b(s);return}f(S(r))}finally{s===n.current&&h(!1)}};if(w&&!a)return e.jsx(H,{message:w,onRetry:$});if(!a)return e.jsx("p",{className:"resource-loading",children:"正在读取 Git 状态…"});if(!a.isRepository)return e.jsxs("div",{className:"resource-empty",children:[e.jsx(g,{name:"branch"}),e.jsx("strong",{children:"当前项目不是 Git 仓库"}),e.jsx("p",{children:"文件和 Agent 仍可使用;Git 面板保持只读空状态。"})]});const P=[{label:"冲突",tone:"conflict",items:a.conflicted},{label:"已暂存",tone:"staged",items:a.staged},{label:"未暂存",tone:"unstaged",items:a.unstaged},{label:"未跟踪",tone:"untracked",items:a.untracked}];return e.jsxs("div",{className:"work-resource-panel git-panel",children:[e.jsxs("div",{className:"git-summary",children:[e.jsxs("div",{children:[e.jsx(g,{name:"branch",size:15}),e.jsx("strong",{children:a.detached?`detached ${a.head??""}`:a.branch||"HEAD"})]}),e.jsxs("span",{children:[a.upstream||"无 upstream",a.ahead||a.behind?` · ↑${a.ahead} ↓${a.behind}`:""]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新 Git 状态",onClick:$,disabled:R,children:e.jsx(g,{name:"refresh",size:15})})]}),E?e.jsx("p",{className:"resource-notice",role:"status",children:E}):null,w?e.jsx("p",{className:"resource-error",role:"alert",children:w}):null,e.jsxs("div",{className:"git-layout",children:[e.jsxs("section",{className:"git-changes","aria-label":"Git 变更",children:[a.clean?e.jsxs("div",{className:"resource-empty compact",children:[e.jsx(g,{name:"check"}),e.jsx("strong",{children:"工作区干净"})]}):P.map(t=>t.items.length?e.jsxs("div",{className:"git-group",children:[e.jsxs("h3",{children:[t.label," ",e.jsx("span",{children:t.items.length})]}),t.items.map(s=>e.jsxs("button",{type:"button",className:G?.fileId===s.fileId?"selected":"",onClick:()=>{M(s)},children:[e.jsx("span",{className:`git-status-code ${t.tone}`,children:s.indexStatus.trim()||s.worktreeStatus.trim()||"?"}),e.jsx("span",{title:s.path,children:s.path})]},`${t.label}:${s.fileId}`))]},t.label):null),a.nextCursor?e.jsx("button",{type:"button",className:"text-button resource-load-more",onClick:()=>{z()},disabled:R,children:"加载更多变更"}):null,e.jsxs("div",{className:"git-history",children:[e.jsx("h3",{children:"提交历史"}),j?.items.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortId}),e.jsx("strong",{children:t.subject}),e.jsxs("span",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleDateString("zh-CN")]})]},t.id)),j?.nextCursor?e.jsx("button",{type:"button",className:"text-button resource-load-more",onClick:()=>{F()},disabled:R,children:"加载更多提交"}):null]})]}),e.jsx("section",{className:"git-diff","aria-label":"Git Diff",children:v?e.jsx(W,{page:v,loading:R,onLoadMore:v.nextCursor&&G?()=>{M(G,v.nextCursor??void 0)}:void 0,onSendToComposer:o}):e.jsxs("div",{className:"resource-empty",children:[e.jsx(g,{name:"code"}),e.jsx("strong",{children:"选择变更查看 Diff"}),e.jsx("p",{children:"Diff 来自受限 Git read model,不解析对话或工具输出。"})]})})]})]})}function H({message:c,onRetry:m}){return e.jsxs("div",{className:"resource-empty",role:"alert",children:[e.jsx(g,{name:"warning"}),e.jsx("strong",{children:"Git 状态读取失败"}),e.jsx("p",{children:c}),e.jsx("button",{type:"button",className:"secondary-button",onClick:m,children:"重试"})]})}function S(c){return c instanceof Error?c.message:"Git 请求失败。"}function L(c){return c instanceof _&&c.code==="git_revision_conflict"}function A(){return new _("仓库版本已变化。",409,"git_revision_conflict")}function C(c,m){const u=new Map(c.map(o=>[o.fileId,o]));for(const o of m)u.set(o.fileId,o);return[...u.values()]}function V(c,m){const u=new Map(c.map(o=>[o.id,o]));for(const o of m)u.set(o.id,o);return[...u.values()]}export{K as GitPanel};
1
+ import{r as d,j as e,I as g,W as _}from"./index-BlFUf8dG.js";import{D as W}from"./DiffViewer-BrE5tfZc.js";function K({workspaceId:c,refreshEpoch:m,actions:u,onSendToComposer:o}){const[a,I]=d.useState(null),[j,k]=d.useState(null),[G,y]=d.useState(null),[v,N]=d.useState(null),[R,h]=d.useState(!1),[w,f]=d.useState(""),[E,p]=d.useState(""),n=d.useRef(0),x=d.useRef(0),b=async(t=n.current)=>{if(t===n.current){h(!0),f("");try{const[s,l]=await Promise.all([u.gitStatus(),u.gitLog()]);if(t!==n.current)return;I(s),k(l),y(null),N(null)}catch(s){if(t!==n.current)return;f(S(s))}finally{t===n.current&&h(!1)}}},$=()=>{const t=n.current+1;n.current=t,x.current+=1,p(""),b(t)};d.useEffect(()=>{const t=n.current+1;n.current=t,x.current+=1,I(null),k(null),y(null),N(null),f(""),p(""),c&&b(t)},[m,c]);const M=async(t,s,l=n.current,r=x.current+1)=>{if(l===n.current){x.current=r,s||(y(t),N(null)),h(!0),f("");try{const i=await u.gitDiff(t.fileId,s);if(l!==n.current||r!==x.current||i.fileId!==t.fileId)return;y(t),N(D=>s&&D&&D.fileId===i.fileId?{...i,lines:[...D.lines,...i.lines]}:i)}catch(i){if(l!==n.current||r!==x.current)return;if(L(i)){p("仓库已变化,已重新载入 Git 状态。"),await b(l);return}f(S(i))}finally{l===n.current&&r===x.current&&h(!1)}}},z=async()=>{const t=a?.nextCursor;if(!t||!a)return;const s=n.current,l=a.repositoryRevision;h(!0),f("");try{const r=await u.gitStatus(t);if(s!==n.current)return;if(r.repositoryRevision!==l)throw A();I(i=>!i||i.repositoryRevision!==l?i:{...r,conflicted:C(i.conflicted,r.conflicted),staged:C(i.staged,r.staged),unstaged:C(i.unstaged,r.unstaged),untracked:C(i.untracked,r.untracked)})}catch(r){if(s!==n.current)return;if(L(r)){p("仓库已变化,已重新载入 Git 状态。"),await b(s);return}f(S(r))}finally{s===n.current&&h(!1)}},F=async()=>{const t=j?.nextCursor;if(!t||!j)return;const s=n.current,l=j.repositoryRevision;h(!0),f("");try{const r=await u.gitLog(t);if(s!==n.current)return;if(r.repositoryRevision!==l)throw A();k(i=>!i||i.repositoryRevision!==l?i:{...r,items:V(i.items,r.items)})}catch(r){if(s!==n.current)return;if(L(r)){p("提交历史已变化,已重新载入第一页。"),await b(s);return}f(S(r))}finally{s===n.current&&h(!1)}};if(w&&!a)return e.jsx(H,{message:w,onRetry:$});if(!a)return e.jsx("p",{className:"resource-loading",children:"正在读取 Git 状态…"});if(!a.isRepository)return e.jsxs("div",{className:"resource-empty",children:[e.jsx(g,{name:"branch"}),e.jsx("strong",{children:"当前项目不是 Git 仓库"}),e.jsx("p",{children:"文件和 Agent 仍可使用;Git 面板保持只读空状态。"})]});const P=[{label:"冲突",tone:"conflict",items:a.conflicted},{label:"已暂存",tone:"staged",items:a.staged},{label:"未暂存",tone:"unstaged",items:a.unstaged},{label:"未跟踪",tone:"untracked",items:a.untracked}];return e.jsxs("div",{className:"work-resource-panel git-panel",children:[e.jsxs("div",{className:"git-summary",children:[e.jsxs("div",{children:[e.jsx(g,{name:"branch",size:15}),e.jsx("strong",{children:a.detached?`detached ${a.head??""}`:a.branch||"HEAD"})]}),e.jsxs("span",{children:[a.upstream||"无 upstream",a.ahead||a.behind?` · ↑${a.ahead} ↓${a.behind}`:""]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新 Git 状态",onClick:$,disabled:R,children:e.jsx(g,{name:"refresh",size:15})})]}),E?e.jsx("p",{className:"resource-notice",role:"status",children:E}):null,w?e.jsx("p",{className:"resource-error",role:"alert",children:w}):null,e.jsxs("div",{className:"git-layout",children:[e.jsxs("section",{className:"git-changes","aria-label":"Git 变更",children:[a.clean?e.jsxs("div",{className:"resource-empty compact",children:[e.jsx(g,{name:"check"}),e.jsx("strong",{children:"工作区干净"})]}):P.map(t=>t.items.length?e.jsxs("div",{className:"git-group",children:[e.jsxs("h3",{children:[t.label," ",e.jsx("span",{children:t.items.length})]}),t.items.map(s=>e.jsxs("button",{type:"button",className:G?.fileId===s.fileId?"selected":"",onClick:()=>{M(s)},children:[e.jsx("span",{className:`git-status-code ${t.tone}`,children:s.indexStatus.trim()||s.worktreeStatus.trim()||"?"}),e.jsx("span",{title:s.path,children:s.path})]},`${t.label}:${s.fileId}`))]},t.label):null),a.nextCursor?e.jsx("button",{type:"button",className:"text-button resource-load-more",onClick:()=>{z()},disabled:R,children:"加载更多变更"}):null,e.jsxs("div",{className:"git-history",children:[e.jsx("h3",{children:"提交历史"}),j?.items.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortId}),e.jsx("strong",{children:t.subject}),e.jsxs("span",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleDateString("zh-CN")]})]},t.id)),j?.nextCursor?e.jsx("button",{type:"button",className:"text-button resource-load-more",onClick:()=>{F()},disabled:R,children:"加载更多提交"}):null]})]}),e.jsx("section",{className:"git-diff","aria-label":"Git Diff",children:v?e.jsx(W,{page:v,loading:R,onLoadMore:v.nextCursor&&G?()=>{M(G,v.nextCursor??void 0)}:void 0,onSendToComposer:o}):e.jsxs("div",{className:"resource-empty",children:[e.jsx(g,{name:"code"}),e.jsx("strong",{children:"选择变更查看 Diff"}),e.jsx("p",{children:"Diff 来自受限 Git read model,不解析对话或工具输出。"})]})})]})]})}function H({message:c,onRetry:m}){return e.jsxs("div",{className:"resource-empty",role:"alert",children:[e.jsx(g,{name:"warning"}),e.jsx("strong",{children:"Git 状态读取失败"}),e.jsx("p",{children:c}),e.jsx("button",{type:"button",className:"secondary-button",onClick:m,children:"重试"})]})}function S(c){return c instanceof Error?c.message:"Git 请求失败。"}function L(c){return c instanceof _&&c.code==="git_revision_conflict"}function A(){return new _("仓库版本已变化。",409,"git_revision_conflict")}function C(c,m){const u=new Map(c.map(o=>[o.fileId,o]));for(const o of m)u.set(o.fileId,o);return[...u.values()]}function V(c,m){const u=new Map(c.map(o=>[o.id,o]));for(const o of m)u.set(o.id,o);return[...u.values()]}export{K as GitPanel};
@@ -1 +1 @@
1
- import{r,j as e,I as o,S as $,W as F}from"./index-Dv_uE9dk.js";import{D as z}from"./DiffViewer-MMhvMif-.js";function W({workspaceId:c,refreshEpoch:D,actions:w,onSendToComposer:E}){const[t,b]=r.useState(null),[v,f]=r.useState(null),[h,x]=r.useState(null),[C,j]=r.useState(!1),[m,u]=r.useState(""),[S,g]=r.useState(""),n=r.useRef(0),i=r.useRef(0),N=async(s=n.current)=>{if(s===n.current){j(!0),u("");try{const l=await w.review();if(s!==n.current)return;b(l),f(null),x(null)}catch(l){if(s!==n.current)return;u(k(l))}finally{s===n.current&&j(!1)}}},I=()=>{const s=n.current+1;n.current=s,i.current+=1,g(""),N(s)};r.useEffect(()=>{const s=n.current+1;n.current=s,i.current+=1,b(null),f(null),x(null),u(""),g(""),c&&N(s)},[D,c]);const R=async(s,l,d=n.current,p=i.current+1)=>{if(d===n.current){i.current=p,l||(f(s),x(null)),j(!0),u("");try{const a=await w.gitDiff(s.fileId,l);if(d!==n.current||p!==i.current||a.fileId!==s.fileId)return;f(s),x(y=>l&&y&&y.fileId===a.fileId?{...a,lines:[...y.lines,...a.lines]}:a)}catch(a){if(d!==n.current||p!==i.current)return;if(A(a)){g("仓库已变化,已重新建立审阅快照。"),await N(d);return}u(k(a))}finally{d===n.current&&p===i.current&&j(!1)}}};return!t&&!m?e.jsx("p",{className:"resource-loading",children:"正在建立审阅快照…"}):t?e.jsxs("div",{className:"work-resource-panel review-panel",children:[e.jsxs("div",{className:"review-summary",children:[e.jsxs("div",{children:[e.jsx("span",{className:`review-score ${t.clean?"clean":"changed"}`,children:t.clean?e.jsx(o,{name:"check"}):e.jsx(o,{name:"edit"})}),e.jsxs("div",{children:[e.jsx("strong",{children:t.clean?"没有待审阅变更":`${t.totalChangedFiles} 个变更文件`}),e.jsxs("span",{children:[t.truncated?"当前显示 · ":"",t.stagedCount," staged · ",t.unstagedCount," unstaged ·"," ",t.untrackedCount," untracked · ",t.conflictCount," conflict"]})]})]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新审阅快照",disabled:C,onClick:I,children:e.jsx(o,{name:"refresh",size:15})})]}),t.truncated?e.jsxs("p",{className:"resource-notice",role:"status",children:["当前显示 ",t.changedFiles.length," / ",t.totalChangedFiles," ","个变更文件;分类计数仅覆盖当前显示范围。"]}):null,S?e.jsx("p",{className:"resource-notice",role:"status",children:S}):null,m?e.jsx("p",{className:"resource-error",role:"alert",children:m}):null,e.jsxs("div",{className:"review-layout",children:[e.jsxs("section",{className:"review-files","aria-label":"待审阅文件",children:[t.changedFiles.map(s=>e.jsxs("button",{type:"button",className:v?.fileId===s.fileId?"selected":"",onClick:()=>{R(s)},children:[e.jsx(o,{name:"code",size:14}),e.jsx("span",{title:s.path,children:s.path}),e.jsx("small",{children:`${s.indexStatus}${s.worktreeStatus}`.trim()||"?"})]},s.fileId)),e.jsxs("div",{className:"review-verification",children:[e.jsx("h3",{children:"验证证据"}),t.verification.length?t.verification.map(s=>e.jsxs("article",{children:[e.jsx($,{state:s.state}),e.jsxs("div",{children:[e.jsx("strong",{children:s.toolName}),e.jsxs("small",{children:[s.state," · ",s.outputBytes," B",s.hasArtifact?" · artifact":""]})]})]},`${s.callId}:${s.toolName}`)):e.jsx("p",{className:"muted-copy",children:"当前没有持久化验证结果。"})]})]}),e.jsx("section",{className:"review-diff","aria-label":"审阅 Diff",children:h?e.jsx(z,{page:h,loading:C,onLoadMore:h.nextCursor&&v?()=>{R(v,h.nextCursor??void 0)}:void 0,onSendToComposer:E}):e.jsxs("div",{className:"resource-empty",children:[e.jsx(o,{name:"edit"}),e.jsx("strong",{children:"选择文件开始审阅"}),e.jsx("p",{children:"你可以把某个 Hunk 作为草稿送回对话,提交前仍由你确认。"})]})})]})]}):e.jsxs("div",{className:"resource-empty",role:"alert",children:[e.jsx(o,{name:"warning"}),e.jsx("strong",{children:"无法读取审阅快照"}),e.jsx("p",{children:m}),e.jsx("button",{type:"button",className:"secondary-button",onClick:I,children:"重试"})]})}function k(c){return c instanceof Error?c.message:"审阅请求失败。"}function A(c){return c instanceof F&&c.code==="git_revision_conflict"}export{W as ReviewPanel};
1
+ import{r,j as e,I as o,S as $,W as F}from"./index-BlFUf8dG.js";import{D as z}from"./DiffViewer-BrE5tfZc.js";function W({workspaceId:c,refreshEpoch:D,actions:w,onSendToComposer:E}){const[t,b]=r.useState(null),[v,f]=r.useState(null),[h,x]=r.useState(null),[C,j]=r.useState(!1),[m,u]=r.useState(""),[S,g]=r.useState(""),n=r.useRef(0),i=r.useRef(0),N=async(s=n.current)=>{if(s===n.current){j(!0),u("");try{const l=await w.review();if(s!==n.current)return;b(l),f(null),x(null)}catch(l){if(s!==n.current)return;u(k(l))}finally{s===n.current&&j(!1)}}},I=()=>{const s=n.current+1;n.current=s,i.current+=1,g(""),N(s)};r.useEffect(()=>{const s=n.current+1;n.current=s,i.current+=1,b(null),f(null),x(null),u(""),g(""),c&&N(s)},[D,c]);const R=async(s,l,d=n.current,p=i.current+1)=>{if(d===n.current){i.current=p,l||(f(s),x(null)),j(!0),u("");try{const a=await w.gitDiff(s.fileId,l);if(d!==n.current||p!==i.current||a.fileId!==s.fileId)return;f(s),x(y=>l&&y&&y.fileId===a.fileId?{...a,lines:[...y.lines,...a.lines]}:a)}catch(a){if(d!==n.current||p!==i.current)return;if(A(a)){g("仓库已变化,已重新建立审阅快照。"),await N(d);return}u(k(a))}finally{d===n.current&&p===i.current&&j(!1)}}};return!t&&!m?e.jsx("p",{className:"resource-loading",children:"正在建立审阅快照…"}):t?e.jsxs("div",{className:"work-resource-panel review-panel",children:[e.jsxs("div",{className:"review-summary",children:[e.jsxs("div",{children:[e.jsx("span",{className:`review-score ${t.clean?"clean":"changed"}`,children:t.clean?e.jsx(o,{name:"check"}):e.jsx(o,{name:"edit"})}),e.jsxs("div",{children:[e.jsx("strong",{children:t.clean?"没有待审阅变更":`${t.totalChangedFiles} 个变更文件`}),e.jsxs("span",{children:[t.truncated?"当前显示 · ":"",t.stagedCount," staged · ",t.unstagedCount," unstaged ·"," ",t.untrackedCount," untracked · ",t.conflictCount," conflict"]})]})]}),e.jsx("button",{type:"button",className:"icon-button","aria-label":"刷新审阅快照",disabled:C,onClick:I,children:e.jsx(o,{name:"refresh",size:15})})]}),t.truncated?e.jsxs("p",{className:"resource-notice",role:"status",children:["当前显示 ",t.changedFiles.length," / ",t.totalChangedFiles," ","个变更文件;分类计数仅覆盖当前显示范围。"]}):null,S?e.jsx("p",{className:"resource-notice",role:"status",children:S}):null,m?e.jsx("p",{className:"resource-error",role:"alert",children:m}):null,e.jsxs("div",{className:"review-layout",children:[e.jsxs("section",{className:"review-files","aria-label":"待审阅文件",children:[t.changedFiles.map(s=>e.jsxs("button",{type:"button",className:v?.fileId===s.fileId?"selected":"",onClick:()=>{R(s)},children:[e.jsx(o,{name:"code",size:14}),e.jsx("span",{title:s.path,children:s.path}),e.jsx("small",{children:`${s.indexStatus}${s.worktreeStatus}`.trim()||"?"})]},s.fileId)),e.jsxs("div",{className:"review-verification",children:[e.jsx("h3",{children:"验证证据"}),t.verification.length?t.verification.map(s=>e.jsxs("article",{children:[e.jsx($,{state:s.state}),e.jsxs("div",{children:[e.jsx("strong",{children:s.toolName}),e.jsxs("small",{children:[s.state," · ",s.outputBytes," B",s.hasArtifact?" · artifact":""]})]})]},`${s.callId}:${s.toolName}`)):e.jsx("p",{className:"muted-copy",children:"当前没有持久化验证结果。"})]})]}),e.jsx("section",{className:"review-diff","aria-label":"审阅 Diff",children:h?e.jsx(z,{page:h,loading:C,onLoadMore:h.nextCursor&&v?()=>{R(v,h.nextCursor??void 0)}:void 0,onSendToComposer:E}):e.jsxs("div",{className:"resource-empty",children:[e.jsx(o,{name:"edit"}),e.jsx("strong",{children:"选择文件开始审阅"}),e.jsx("p",{children:"你可以把某个 Hunk 作为草稿送回对话,提交前仍由你确认。"})]})})]})]}):e.jsxs("div",{className:"resource-empty",role:"alert",children:[e.jsx(o,{name:"warning"}),e.jsx("strong",{children:"无法读取审阅快照"}),e.jsx("p",{children:m}),e.jsx("button",{type:"button",className:"secondary-button",onClick:I,children:"重试"})]})}function k(c){return c instanceof Error?c.message:"审阅请求失败。"}function A(c){return c instanceof F&&c.code==="git_revision_conflict"}export{W as ReviewPanel};
@@ -1,4 +1,4 @@
1
- var An=Object.defineProperty;var On=(e,t,i)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var _e=(e,t,i)=>On(e,typeof t!="symbol"?t+"":t,i);import{r as I,j as w,I as xt}from"./index-Dv_uE9dk.js";var Nn=2,In=1,Hn=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,c=r-h-t;return{cols:Math.max(Nn,Math.floor(c/e.css.cell.width)),rows:Math.max(In,Math.floor(l/e.css.cell.height))}}};var Or=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Wn=(e,t)=>{for(var i in t)Or(e,i,{get:t[i],enumerable:!0})},Q=(e,t,i,s)=>{for(var r=s>1?void 0:s?Fn(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Or(t,i,r),r},x=(e,t)=>(i,s)=>t(i,s,e),Ts="Terminal input",Li={get:()=>Ts,set:e=>Ts=e},Ps="Too much output to announce, navigate to rows manually to read",Ti={get:()=>Ps,set:e=>Ps=e};function zn(e){return e.replace(/\r?\n/g,"\r")}function $n(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Kn(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Un(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Nr(r,t,i,s)}}function Nr(e,t,i,s){e=zn(e),e=$n(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Ir(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function As(e,t,i,s,r){Ir(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function st(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _i(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var qn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Vn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let u=0,g;for(;(g=this.interim[++u]&63)&&u<4;)f<<=6,f|=g;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=b-u;for(;l<D;){if(l>=i)return 0;if(g=e[l++],(g&192)!==128){l--,_=!0;break}else this.interim[u++]=g,f<<=6,f|=g&63}_||(b===2?f<128?l--:t[s++]=f:b===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,d=l;for(;d<i;){for(;d<c&&!((r=e[d])&128)&&!((n=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Hr="",rt=" ",Kt=class Fr{constructor(){this.fg=0,this.bg=0,this.extended=new ai}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Fr;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ai=class Wr{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Wr(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oe=class zr extends Kt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ai,this.combinedData=""}static fromCharData(t){let i=new zr;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?st(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Os="di$target",Pi="di$dependencies",mi=new Map;function jn(e){return e[Pi]||[]}function ue(e){if(mi.has(e))return mi.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Yn(t,i,r)};return t._id=e,mi.set(e,t),t}function Yn(e,t,i){t[Os]===t?t[Pi].push({id:e,index:i}):(t[Pi]=[{id:e,index:i}],t[Os]=t)}var we=ue("BufferService"),$r=ue("CoreMouseService"),gt=ue("CoreService"),Xn=ue("CharsetService"),vs=ue("InstantiationService"),Kr=ue("LogService"),ye=ue("OptionsService"),Ur=ue("OscLinkService"),Gn=ue("UnicodeService"),Ut=ue("DecorationService"),Ai=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Oe,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let c=0;c<o;c++)if(!(h===-1&&!i.hasContent(c))){if(i.loadCell(c,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=c,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&c===o-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let _={start:{x:h+1,y:e},end:{x:c+(!l&&c===o-1?1:0),y:e}},f=!1;if(!r?.allowNonHttpProtocols)try{let u=new URL(d);["http:","https:"].includes(u.protocol)||(f=!0)}catch{f=!0}f||s.push({text:d,range:_,activate:(u,g)=>r?r.activate(u,g,_):Jn(u,g),hover:(u,g)=>r?.hover?.(u,g,_),leave:(u,g)=>r?.leave?.(u,g,_)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=c,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Ai=Q([x(0,we),x(1,ye),x(2,Ur)],Ai);function Jn(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ var An=Object.defineProperty;var On=(e,t,i)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var _e=(e,t,i)=>On(e,typeof t!="symbol"?t+"":t,i);import{r as I,j as w,I as xt}from"./index-BlFUf8dG.js";var Nn=2,In=1,Hn=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,c=r-h-t;return{cols:Math.max(Nn,Math.floor(c/e.css.cell.width)),rows:Math.max(In,Math.floor(l/e.css.cell.height))}}};var Or=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Wn=(e,t)=>{for(var i in t)Or(e,i,{get:t[i],enumerable:!0})},Q=(e,t,i,s)=>{for(var r=s>1?void 0:s?Fn(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Or(t,i,r),r},x=(e,t)=>(i,s)=>t(i,s,e),Ts="Terminal input",Li={get:()=>Ts,set:e=>Ts=e},Ps="Too much output to announce, navigate to rows manually to read",Ti={get:()=>Ps,set:e=>Ps=e};function zn(e){return e.replace(/\r?\n/g,"\r")}function $n(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Kn(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Un(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Nr(r,t,i,s)}}function Nr(e,t,i,s){e=zn(e),e=$n(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Ir(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function As(e,t,i,s,r){Ir(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function st(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _i(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var qn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Vn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let _=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let u=0,g;for(;(g=this.interim[++u]&63)&&u<4;)f<<=6,f|=g;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=b-u;for(;l<D;){if(l>=i)return 0;if(g=e[l++],(g&192)!==128){l--,_=!0;break}else this.interim[u++]=g,f<<=6,f|=g&63}_||(b===2?f<128?l--:t[s++]=f:b===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0)}let c=i-4,d=l;for(;d<i;){for(;d<c&&!((r=e[d])&128)&&!((n=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Hr="",rt=" ",Kt=class Fr{constructor(){this.fg=0,this.bg=0,this.extended=new ai}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Fr;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ai=class Wr{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Wr(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oe=class zr extends Kt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ai,this.combinedData=""}static fromCharData(t){let i=new zr;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?st(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Os="di$target",Pi="di$dependencies",mi=new Map;function jn(e){return e[Pi]||[]}function ue(e){if(mi.has(e))return mi.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Yn(t,i,r)};return t._id=e,mi.set(e,t),t}function Yn(e,t,i){t[Os]===t?t[Pi].push({id:e,index:i}):(t[Pi]=[{id:e,index:i}],t[Os]=t)}var we=ue("BufferService"),$r=ue("CoreMouseService"),gt=ue("CoreService"),Xn=ue("CharsetService"),vs=ue("InstantiationService"),Kr=ue("LogService"),ye=ue("OptionsService"),Ur=ue("OscLinkService"),Gn=ue("UnicodeService"),Ut=ue("DecorationService"),Ai=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Oe,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let c=0;c<o;c++)if(!(h===-1&&!i.hasContent(c))){if(i.loadCell(c,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=c,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&c===o-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let _={start:{x:h+1,y:e},end:{x:c+(!l&&c===o-1?1:0),y:e}},f=!1;if(!r?.allowNonHttpProtocols)try{let u=new URL(d);["http:","https:"].includes(u.protocol)||(f=!0)}catch{f=!0}f||s.push({text:d,range:_,activate:(u,g)=>r?r.activate(u,g,_):Jn(u,g),hover:(u,g)=>r?.hover?.(u,g,_),leave:(u,g)=>r?.leave?.(u,g,_)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=c,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Ai=Q([x(0,we),x(1,ye),x(2,Ur)],Ai);function Jn(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var fi=ue("CharSizeService"),Ge=ue("CoreBrowserService"),Ss=ue("MouseService"),Je=ue("RenderService"),Zn=ue("SelectionService"),qr=ue("CharacterJoinerService"),yt=ue("ThemeService"),Vr=ue("LinkProviderService"),Qn=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ns.isErrorNoTelemetry(e)?new Ns(e.message+`
4
4