Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ The Superpowers plugin is disabled for this repository. Do not invoke or follow
- **实时 transcript 是单写者 store**(`singleWriterStore.js`,`commit(producer)` 唯一写入口,hook 内无 useState;排队输入同一个 store);回放去重只认 `replayed` 帧,`STREAM_NEUTRAL_EVENT_TYPES` 不 flush token;工具伪行按 call id 配对;尾部窗口 120 行、跟随时封顶 180,`pinned` 别去掉;卡住兜底三层(WS 心跳 / 事件游标带实例号 / `transcriptLiveWatchdog`)。详见 [docs/web-chat/transcript-state.md](docs/web-chat/transcript-state.md) 与归档:实时 transcript 状态是单写者、事件回放去重、工具伪行按 call id 配对、Transcript 尾部窗口、实时状态卡住的兜底。
- **流式渲染**:`renderMarkdownBlocks` 分块 + `useStreamingRenderThrottle` 100ms 降频,未闭合代码块不高亮;`.ace-chat-transcript-scroll` 关 overflow-anchor。归档:流式渲染防跳动。
- **对话内可视化与画图说明**:顶层 ```visual 代码块画在只有 `allow-scripts` 的 srcdoc iframe 里(CSP 只放行四个 CDN,本机 daemon 请求不到),同一组件从流式用到定稿,框内运行时被序列化进 iframe、**不能写中文字面量**;Chart.js 4 / d3 7 内置,由外层把本地代码递进框(不放宽 CSP);系统提示末尾的画图说明 mermaid 部分 TUI + Web 都有,visual 部分只在 daemon 且 `inline_visuals.enabled`,headless / 子会话 / 群聊代答不加,文本字节稳定;详细规范在内置技能 `inline-visuals`,改变量名、类名要与外壳一起改。见 [docs/inline-visuals.md](docs/inline-visuals.md)。
- **HTML 文件预览与可视化编辑**:文件详情打开 .html 默认渲染页面(srcdoc 隔离框只给 `allow-scripts allow-modals`,**绝不加 allow-same-origin**),相对路径资源走 `/api/html-site/<站点号>/…`(站点号即凭证、只服务网页资源扩展名、fetch 拿不到跨源许可);桌面版可编辑时 ⋯ 左边有编辑按钮,写回只做源码区间替换(元素编号只进框内副本、不进文件,不改动零字节差异),脚本生成的元素只能 AI 编辑。框内运行时不能写中文字面量。见 [docs/html-preview.md](docs/html-preview.md)。
- **Mermaid 源码闸门**(`lib/mermaidRenderer.js`):标签里像 HTML 标签的文字(`<cachePath>`、`List<String>`)改写成 Mermaid 实体码 `#lt;` / `#gt;` 再渲染,时序图消息 / 注释 / 分组标题里的 `;` `#` 转成 `#59;` `#35;`;URL 文字不拦,`url(` 只在 style / classDef / linkStyle 行拦。安全边界是 strict 配置 + `sanitizeMermaidSvg` 白名单 + `<img>` 显示;**不要**改回「见到尖括号 / URL 就整张退回源码」,讲代码的图几乎都会命中。行内只缩不放(窄图原始尺寸,宽图等比缩到对话栏宽,细节点开 `ImageLightbox` 缩放平移),别改回 1:1 加横向滚动条。
- **交互约定**:对话框键盘走 `components/Modal.jsx` + `lib/dialogKeyboard.js`(Esc / Tab 循环 / Enter 默认操作 / auto-repeat Enter 拦下),不要手写 `fixed inset-0` 遮罩;排队卡片在 transcript 外(`QueueCardList`),中断后队列暂停不自动出队;粘贴 ≥ 20 行 / 2000 字符折成卡片、≥ 128 KiB 落文件;`@` 会话引用有查询词必须走服务端 `q=`;侧栏拖进输入框 = @ 引用;Slate 选区在 compositionstart 前 `adoptDomSelection`。归档:对话框键盘约定、排队卡片栈、粘贴的文本块、`@` 会话引用、输入框光标。
- **新建会话的等待遮罩**:首页发送后建会话、首条消息里建 worktree 迟迟没完成(600 毫秒)才出遮罩,出现后至少停 400 毫秒,盖整个会话工作区、不盖左侧列表;出现之前不拦输入,靠 `submit` / `stopCurrentWork` 开头的 `sessionStartMask.isBlocking()` 早退;遮罩守焦点**不要**在 `focusin` 回调里同步抢回(Slate 会一直以为自己还有焦点,之后再也聚焦不上),要等事件结束;带建 worktree 意图的发送用 5 分钟超时(`WORKTREE_CREATE_TIMEOUT_MS`)。见 [docs/web-chat/session-start-mask.md](docs/web-chat/session-start-mask.md)。
- **右侧文件树多选**(「文件」页签):Shift / Ctrl 选区规则在 `lib/fileTreeSelection.js`(只算画出来的行,折叠 / 刷新后看不见的行从选区裁掉;还没有选区时预览中的文件算已选),交互在 `lib/useFileTreeSelection.js`;多选右键走 `data-desktop-context-menu-delegate="file-tree-selection"` 委托(点在选区外就退回单行菜单),菜单每项后面的数字是它实际处理的条数;拖动是自绘的指针拖动,**不要**改成 HTML5 拖放(桌面壳会当成系统文件拖放拦走),松手派发 `FILE_TREE_DROP_EVENT`(`lib/fileTreeDrop.js`):输入框在光标处插 @路径(目录和它里面的行一起选中时只给最外层),控制台贴加好引号的绝对路径。
- **搜索与批量**:`Ctrl+K` 快捷键只有一个定义点 `lib/searchPaletteShortcut.js`(xterm 要放行);前端纯聚合所有 workspace,后端零路由变更;侧栏多选批量操作只发一次 `POST /api/session-batch`。
- **git 感知**:`/api/git/info` 必须走 `gitInfoCache.js`(一次 spawn 5~7 个 git),`GitSessionPill` 用 `pillCouldRender` 在请求前短路;`src/domain/gitinfo/` 的 ref 名进 prompt / REST / argv 前过 `is_safe_ref_name`;SidePanel「变更」tab 在 git 仓库走 git 级视图。归档:git 感知三件套。
Expand All @@ -104,6 +106,7 @@ The Superpowers plugin is disabled for this repository. Do not invoke or follow
- **打开文件夹**(`aceDesktop_openInExplorer` 异步 bridge):Windows 文件走 `SHOpenFolderAndSelectItems`,**不要改回 `explorer.exe /select`**(每次另起一个不退出的 Explorer 宿主进程,约 1 秒);独立 STA 线程执行,窗口被压在后面才拉起,不抢用户已切走的焦点,不撤用户的置顶。见 [docs/desktop-shell/multi-workspace.md](docs/desktop-shell/multi-workspace.md)。
- **窗口细节**:启动浮窗由独立绘制线程播动画(`splash_animation.cpp` 纯函数);窗口位置跨启动记忆(`window_placement_win.cpp` + `place_saved_desktop_window`,普通边框口径);Win10 顶边 1px 线由宿主窗口自画(别用 `DwmExtendFrameIntoClientArea`,别画在网页里);Ctrl+滚轮缩放只走 `aceDesktop_zoomFactor`,WebView2 `IsZoomControlEnabled` 保持 FALSE;主题异形窗口全部挂在 `g_window_shape.chamfer` 上。归档:启动浮窗动画、主窗口位置跨启动记忆、Win10 顶边、Ctrl+滚轮页面缩放、异形窗口。
- **挂机 OOM 三层**:侧栏空闲刷新「内容没变就不 setState」(`structuralState.js`;React 18 相同值更新仍留队列);Sidebar / ChatView / App 里**不要再写 `useCallback(fn, [会变的状态或 props])`**,用 `useStableCallback`(三条边界见归档),`stableCallbacksArchitecture.test.js` 守着;webview 桥接 `_promises` 泄漏由 `kBridgeReplyCleanupScript` 接管;渲染进程退出自动 Reload(10 分钟最多 3 次)。归档:Desktop 挂机内存。
- **界面变白后的自动恢复**:页面最外层 `RootErrorBoundary`(渲染报错显示「重新加载」,按需加载块取不到时自动重载一次、60 秒内不循环);Windows 宿主在解锁 / 远程重连 / 休眠唤醒 / 渲染进程无响应后探活(`webview_health.hpp` 判定,`web_host_health.hpp` 接线),`#root` 为空就重载,没回音就**先结束渲染进程**再由「渲染进程退出」那条路径重载(实测页面脚本死循环时 `Reload` 无效,别改回直接重载),所有自动重载共用 10 分钟 3 次的限次,「活着但不出画面」只记日志不处置;浏览器主进程退出后控件无法就地修复,保留 daemon、重启桌面壳(`desktop_restart.cpp::finish_desktop_exit`),只在用户回到窗口时做,关机 / 注销时不做,自动重启跨进程限 10 分钟 2 次;托盘「重新加载界面」是不依赖页面的固定项。`web_host.cpp` / `main.cpp` 的行数余量很小,新逻辑放进上面这几个文件,别往那两个里加。**不要**加 Chromium 遮挡检测的启动参数当修法(没验证过)。日志对照表见 [docs/desktop-shell/webview-recovery.md](docs/desktop-shell/webview-recovery.md)。
- **水晶球桌宠**(`crystal_pet.js` WebGL2 + `desktop_pet_crystal_win.cpp`):Win11 上逐像素透明窗口不带 CAPTUREBLT 也会被 BitBlt 抓到,所以宠物窗口设 `WDA_EXCLUDEFROMCAPTURE`(截图 / 录屏里也看不到它),抓屏线程写 WebView2 共享内存、页面 `crystal-ack` 后才抓下一帧;远程会话撤销亲和性回退内置背景;`desktop_pet.cpp` 已到 999 行,改动往透镜文件里放。见 [docs/desktop-agent-office.md](docs/desktop-agent-office.md) 水晶球一节。
- **Agent Browser**:永久开发宽松浏览器(证书 / SmartScreen / 旧 TLS 一律静默放行,**没有开关没有提示**,边界由 `agentBrowserArchitecture.test.js` 扫整个 `src/`);导航状态按最终结果决定(`agent_browser_navigation_state.cpp`,重试全页最多一次);页面归属落在 host 的 `agent_browser_page_directory`,联结键只有 `session_id`,带 owner 的建页不改显示页;前端页签唯一来源 `agentBrowserPages.js`;Cookie 三档 shared / per_session / until_quit(until_quit 要隐藏保活 controller,切档不用 `Profile8::Delete`,跨进程状态在 `state.json` 的 `agent_browser` 段);新标签页推荐由 daemon 存 `agent_browser_top_sites.json`。全文 [docs/agent-browser.md](docs/agent-browser.md) 与归档:Agent Browser 四节。
- **iOS 模拟器**(仅 macOS):helper `acecode-ios-sim` 运行期 dlsym 私有框架、跑在 Seatbelt 里;Xcode 自动发现、不用 `xcrun`;帧缓冲必须同步加锁;HID 按 CoreSimulator 版本分 Indigo / dtuhid;Desktop 原生零拷贝视图只加载系统路径的 CoreSimulator。见 [docs/ios-simulator.md](docs/ios-simulator.md) 与归档:iOS 模拟器。别在用户 Mac 上跑 lldb。
Expand Down
3 changes: 3 additions & 0 deletions cmake/acecode_source_paths.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ set(ACECODE_MINI_PET_INPUT_SMOKE_SOURCES
set(ACECODE_RENDERER_RECOVERY_SMOKE_SOURCES
${CMAKE_SOURCE_DIR}/tests/desktop/helpers/renderer_recovery_smoke.cpp
${ACECODE_DESKTOP_WEB_HOST_SOURCE})
set(ACECODE_WEBVIEW_HEALTH_SMOKE_SOURCES
${CMAKE_SOURCE_DIR}/tests/desktop/helpers/webview_health_smoke.cpp
${ACECODE_DESKTOP_WEB_HOST_SOURCE})
set(ACECODE_WINDOWS_FILE_DROP_SMOKE_SOURCES
${CMAKE_SOURCE_DIR}/tests/desktop/helpers/windows_file_drop_smoke.cpp)
set(ACECODE_AGENT_BROWSER_POINTER_DEMO_SOURCES
Expand Down
41 changes: 41 additions & 0 deletions docs/daemon-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ download when nothing changed.
| GET | `/api/files/blob` | read previewable binary file |
| POST | `/api/files/export` | save a file through the native Save as dialog |
| GET / PUT | `/api/files/editable` | read or safely save a Desktop workspace text file |
| POST | `/api/files/html-site` | register the resource site for an HTML file preview |
| GET | `/api/html-site/<id>/<path>` | serve a page resource for the HTML preview iframe |
| GET | `/api/fs/roots` | browsable roots for the Web path picker |
| GET | `/api/fs/list` | list any absolute directory for the Web path picker |
| POST | `/api/fs/mkdir` | create one folder from the Web path picker |
Expand Down Expand Up @@ -2932,6 +2934,45 @@ path, invalidates Git snapshots, and clears the Agent file-read baseline so a
later Agent edit must read the human-authored version first. This route is not
registered on standalone Web daemons.

### `POST /api/files/html-site`

Authenticated. Registers a page-resource site for rendering an `.html` / `.htm`
file in the file detail view (see [html-preview.md](html-preview.md)). Body:
`{"cwd":"<abs>","path":"<rel-or-abs>"}`; the path resolves like
`/api/files/content`. When the file is inside a registered workspace the site
root is that workspace, otherwise it is the file's own directory.

```json
{ "id": "<32 hex>", "prefix": "/api/html-site/<id>/", "entry": "docs/report.html" }
```

`entry` is the file's path relative to the site root, percent-encoded per
segment. Registering the same root again returns the same id; the daemon keeps
the 64 most recently used roots in memory. Errors: 400 bad body or path, 404
missing file, 415 not an HTML file.

### `GET /api/html-site/<id>/<relative-path>`

Not token-authenticated: the preview iframe's subresource requests cannot send
`X-ACECode-Token`, so the random site id is the credential. Requests from
non-local clients are refused with 403 unless remote Web access is enabled.
The route is dispatched from the static catch-all (Crow's `<path>` template
breaks binding), and serves only regular files inside the registered root:

- path segments are percent-decoded; empty, `.`, `..`, backslash and `:`
segments are rejected, and the resolved target must stay inside the root;
- only web resource extensions are served (`html`, `css`, `js`/`mjs`, `json`,
`svg`, raster images, fonts, common audio/video, `wasm`, `txt`, `csv`,
`xml`, `map`); anything else (`.env`, keys, extensionless files) is 404;
- files are capped at 64 MiB and sent with `X-Content-Type-Options: nosniff`
and `Cache-Control: no-cache`; HTML/SVG/XML responses also carry
`Content-Security-Policy: sandbox allow-scripts allow-modals`;
- `Access-Control-Allow-Origin: *` is added only when `Sec-Fetch-Dest` is a
subresource destination (`script`, `style`, `font`, `image`, `audio`,
`video`, `track`, `worker`, `sharedworker`), so module scripts and fonts load
from the opaque-origin preview while page `fetch()`/XHR (`empty`) cannot read
file contents.

### `GET /api/fs/roots`

Browsable roots for the Web path picker (openspec `add-web-path-picker`). The
Expand Down
Loading
Loading