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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| 工具 | 推荐版本 | 来源与用途 |
| :--- | :--- | :--- |
| **Go** | 遵循 [go.mod](go.mod),当前 1.26.10 | 核心控制平面、CLI、TUI、HTTP API 与 SQLite 状态机 |
| **Go** | 遵循 [go.mod](go.mod),当前 1.26.11 | 核心控制平面、CLI、TUI、HTTP API 与 SQLite 状态机 |
| **Node.js** | 24+ | 前端管理界面(`web/` 目录下的 React 19 + Vite) |
| **Git** | 2.41+ | 源码版本管理 |
| **Rust** *(可选)* | 1.97.1+ | 仅在修改或验证 `analyzers/` 目录下的 WASI 代码分析器时需要 |
Expand Down
51 changes: 51 additions & 0 deletions docs/acceptance/2026-11-07-new-conversation-image-notices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# New-conversation image recovery notices

Base: `f1982fa88e207263e30a490216fd44e501ef1b84`. Windows Chromium, real Go API
and production Web assets. Display projection is enabled only on the new
conversation route with a confirmed workspace, where the draft's image-discard
controls are mounted.

A damaged image record previously appeared three times: a generic creation
warning, a global storage toast, and the actionable image row. The current
draft's known invalid image records now appear once, in that existing row.
Storage validation and send guards retain every failure. The projection only
filters `invalid` and invalid-format `read` warnings with the exact current
workspace/empty-thread image prefix. Other workspaces, other Threads, denied
storage reads, unassignable keys, unsaved drafts and operation failures remain
visible. Equal messages from different sources still notify observers.

Creation recovery checks its own journal before the global storage guard, so a
bad creation request has its own visible error even beside a bad image. The
real mixed-record journey leaves that request intact, discards only the image,
then attempts to send and verifies zero creation POSTs and the unchanged draft.

The journeys insert synthetic damaged journal records into actual localStorage;
they do not mock HTTP responses or use user images. Both new assertions fail
on the base build: two generic alerts remain, and the bad creation is masked by
the image's storage error. Both pass after the change. The existing stored-image
response-loss and single-record discard journeys also pass.

Screenshots are unmodified viewport captures. Desktop is 1280 × 800; narrow is
390 × 844. The mixed case contains both a bad image and a bad creation record.

| Case / theme / viewport | Before | After |
| --- | --- | --- |
| Image / Light / 1280 | [Before](../images/image-recovery-notices/before-single-light-1280.png) | [After](../images/image-recovery-notices/after-single-light-1280.png) |
| Image / Dark / 1280 | [Before](../images/image-recovery-notices/before-single-dark-1280.png) | [After](../images/image-recovery-notices/after-single-dark-1280.png) |
| Image / Light / 390 | [Before](../images/image-recovery-notices/before-single-light-390.png) | [After](../images/image-recovery-notices/after-single-light-390.png) |
| Image / Dark / 390 | [Before](../images/image-recovery-notices/before-single-dark-390.png) | [After](../images/image-recovery-notices/after-single-dark-390.png) |
| Mixed / Light / 1280 | [Before](../images/image-recovery-notices/before-mixed-light-1280.png) | [After](../images/image-recovery-notices/after-mixed-light-1280.png) |
| Mixed / Dark / 1280 | [Before](../images/image-recovery-notices/before-mixed-dark-1280.png) | [After](../images/image-recovery-notices/after-mixed-dark-1280.png) |
| Mixed / Light / 390 | [Before](../images/image-recovery-notices/before-mixed-light-390.png) | [After](../images/image-recovery-notices/after-mixed-light-390.png) |
| Mixed / Dark / 390 | [Before](../images/image-recovery-notices/before-mixed-dark-390.png) | [After](../images/image-recovery-notices/after-mixed-dark-390.png) |

Verification: production build/strict TypeScript; four focused test files
(69 tests); four real Go/Chromium journeys; and `git diff --check` passed.
Focused cases cover another scope with the same warning text, another workspace,
leaving the projected scope, denied reads, unsaved data, bad creation plus bad
image, retaining the second bad record after discard, and blocking creation.

OCR delegate selected app, recovery storage and creation recovery. Storage was
read in full; app around route/render ownership and creation around the journal,
load, operation and notice paths; changed tests and captured screenshots were
reviewed. The existing recovery registry and persisted formats are unchanged.
4 changes: 2 additions & 2 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ successful aggregate result. Unclassified build inputs select full checks.

## Go security baseline

The supported build toolchain is Go **1.26.10**, pinned by `go.mod`. Both central
The supported build toolchain is Go **1.26.11**, pinned by `go.mod`. Both central
CI and release builders read that exact version with `go-version-file`.
This avoids selecting an older patch while the setup-go version catalog lags
behind a new Go security release. Local desktop builders require the same
version; set `GOTOOLCHAIN=go1.26.10` when another Go toolchain is installed.
version; set `GOTOOLCHAIN=go1.26.11` when another Go toolchain is installed.
The module's minimum version alone cannot exclude vulnerable newer release
branches, such as Go 1.27.0 and 1.27.1; a larger version is not security evidence.
The Windows fixed-toolchain fixture must match the exact version selected by
Expand Down
9 changes: 5 additions & 4 deletions docs/convergence/protocol-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This document is generated from [`protocols/registry.json`](../../protocols/regi
| [desktop-risk-restart-session](#desktop-risk-restart-session) | `ephemeral` | Desktop shell lifecycle maintainers | 2 | false |
| [desktop-terminal-settings](#desktop-terminal-settings) | `internal-durable` | Desktop terminal maintainers | 1 | true |
| [desktop-verification-settings](#desktop-verification-settings) | `internal-durable` | Desktop verification settings maintainers | 1 | true |
| [desktop-web-presentation-state](#desktop-web-presentation-state) | `projection` | Desktop and React workbench maintainers | 25 | true |
| [desktop-web-presentation-state](#desktop-web-presentation-state) | `projection` | Desktop and React workbench maintainers | 26 | true |
| [docker-attach-process-session](#docker-attach-process-session) | `ephemeral` | Docker runtime transport maintainers | 1 | false |
| [exported-evidence-and-handoff](#exported-evidence-and-handoff) | `external-durable` | Evidence, verification, report, and handoff maintainers | 35 | true |
| [extension-package-contracts](#extension-package-contracts) | `external-durable` | Skill, Plugin, Hook, and extension maintainers | 48 | true |
Expand Down Expand Up @@ -803,11 +803,11 @@ This document is generated from [`protocols/registry.json`](../../protocols/regi
- Retirement gate (`rebuild-from-source`): Rebuild source remains retained and independently verifiable; Replacement preserves ordering, cursor, invalidation, and redaction behavior; Retirement evidence proves a complete rebuild from the named source
- Rebuild source: Go Application DTOs plus explicitly user-owned local presentation settings.
- Writers:
- `desktop-web-presentation-state-writer` (`v1`, write-current) at `web/src`
- `desktop-web-presentation-state-writer` (`v1, v2`, write-current) at `web/src`
- Readers:
- `desktop-web-presentation-state-reader` (`v1`, active) at `web/src`
- `desktop-web-presentation-state-reader` (`v1, v2`, active) at `web/src`

<details><summary>25 active identifiers</summary>
<details><summary>26 active identifiers</summary>

- `desktop_chat_resource.v1`
- `desktop_clipboard_files.v1`
Expand All @@ -833,6 +833,7 @@ This document is generated from [`protocols/registry.json`](../../protocols/regi
- `universal-code.specialist-continuation.v1`
- `universal-code.turn-notifications.v1`
- `universal-code.workspace-tabs.v1`
- `universal-code.workspace-tabs.v2`
- `v2_file_upload.v1`

</details>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/macos-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For newer candidates, use a successful Desktop release run for the matching arch

## 构建与核验

本机源码构建需要 Xcode Command Line Tools、[go.mod](../go.mod) 固定的 Go(当前 1.26.10)、Node.js 24(CI 为 24.22.1)和 CGO。在仓库根目录运行:
本机源码构建需要 Xcode Command Line Tools、[go.mod](../go.mod) 固定的 Go(当前 1.26.11)、Node.js 24(CI 为 24.22.1)和 CGO。在仓库根目录运行:

```sh
CGO_ENABLED=1 bash scripts/build-desktop-darwin.sh -Version v1.0.0-dev
Expand Down
2 changes: 1 addition & 1 deletion docs/windows-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For newer test candidates, select a successful Desktop release run and check its

### 从源码构建与启动 / Build and launch from source

在仓库根目录使用 PowerShell、[go.mod](../go.mod) 固定的 Go(当前 1.26.10)与 Node.js 24(CI 为 24.22.1):
在仓库根目录使用 PowerShell、[go.mod](../go.mod) 固定的 Go(当前 1.26.11)与 Node.js 24(CI 为 24.22.1):

```powershell
.\scripts\build-desktop.ps1 -Version v1.0.0-dev
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module cyberagent-workbench

go 1.26.10
go 1.26.11

require (
github.com/Microsoft/go-winio v0.6.4
Expand Down
4 changes: 3 additions & 1 deletion internal/app/edit_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ func flagWasSet(fs *flag.FlagSet, name string) bool {
}

func readEditContent(path string) (string, error) {
path = strings.TrimSpace(path)
if path != strings.TrimSpace(path) {
return "", errors.New("content file path cannot contain surrounding whitespace")
}
if path == "" {
return "", errors.New("content file path is required")
}
Expand Down
19 changes: 19 additions & 0 deletions internal/app/edit_command_path_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package app

import (
"os"
"path/filepath"
"testing"
)

func TestReadEditContentRejectsSurroundingWhitespace(t *testing.T) {
path := filepath.Join(t.TempDir(), "content.txt")
if err := os.WriteFile(path, []byte("original"), 0600); err != nil {
t.Fatal(err)
}
for _, requested := range []string{" " + path, path + " ", "\t" + path} {
if content, err := readEditContent(requested); err == nil {
t.Errorf("readEditContent(%q) silently read %q", requested, content)
}
}
}
4 changes: 3 additions & 1 deletion internal/fileedit/fileedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ func (m *Manager) fail(ctx context.Context, edit Edit, cause error) (Edit, error
}

func normalizePath(path string) (string, error) {
path = strings.TrimSpace(path)
if path != strings.TrimSpace(path) {
return "", errors.New("file path cannot contain surrounding whitespace")
}
if path == "" || path == "." {
return "", errors.New("file path is required")
}
Expand Down
11 changes: 11 additions & 0 deletions internal/fileedit/path_identity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fileedit

import "testing"

func TestNormalizePathRejectsSurroundingWhitespace(t *testing.T) {
for _, path := range []string{" file.txt", "file.txt ", "\tfile.txt"} {
if got, err := normalizePath(path); err == nil {
t.Errorf("normalizePath(%q) redirected to %q instead of rejecting it", path, got)
}
}
}
10 changes: 7 additions & 3 deletions internal/tools/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (t ListWorkspaceTool) Run(ctx context.Context, call Call) (Result, error) {
return interruptedResult(err), err
}
fs := t.FS.withFallback(call.WorkingDir)
path := strings.TrimSpace(call.Args["path"])
path := call.Args["path"]
if path == "" {
path = "."
}
Expand Down Expand Up @@ -168,7 +168,9 @@ func (fs WorkspaceFS) resolveForWrite(requested string, allowMissingParents bool
if strings.TrimSpace(fs.Root) == "" {
return "", errors.New("workspace root is required")
}
requested = strings.TrimSpace(requested)
if requested != strings.TrimSpace(requested) {
return "", errors.New("file path cannot contain surrounding whitespace")
}
if requested == "" || requested == "." {
return "", errors.New("file path is required")
}
Expand Down Expand Up @@ -282,7 +284,9 @@ func (fs WorkspaceFS) resolveExisting(requested string) (string, error) {
if strings.TrimSpace(fs.Root) == "" {
return "", errors.New("workspace root is required")
}
requested = strings.TrimSpace(requested)
if requested != strings.TrimSpace(requested) {
return "", errors.New("workspace path cannot contain surrounding whitespace")
}
if requested == "" {
requested = "."
}
Expand Down
24 changes: 24 additions & 0 deletions internal/tools/path_identity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tools

import (
"os"
"path/filepath"
"testing"
)

func TestWorkspaceFSRejectsSurroundingWhitespaceWithoutRedirecting(t *testing.T) {
root := t.TempDir()
if err := os.WriteFile(filepath.Join(root, "file.txt"), []byte("original"), 0o600); err != nil {
t.Fatal(err)
}
fs := NewWorkspaceFS(root)
for _, path := range []string{" file.txt", "file.txt ", "\tfile.txt"} {
for name, resolve := range map[string]func(string) (string, error){
"read": fs.ResolveFileForRead, "write": fs.ResolveForWrite, "create": fs.ResolveForCreate,
} {
if got, err := resolve(path); err == nil {
t.Errorf("%s(%q) redirected to %q instead of rejecting it", name, path, got)
}
}
}
}
4 changes: 2 additions & 2 deletions packaging/macos/LOCAL-TEST-GUIDE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Start-Prayu-Operator-Preview.command 只是同一默认入口的兼容快捷方

Node 版本不符时脚本会在前端检查前明确报错;如果 web/dist 已经构建好,
也可以用 -SkipFrontend 跳过前端步骤。构建还需要 Xcode 命令行工具
(codesign)和 Go 1.26.10。
(codesign)和 Go 1.26.11。

首次接入真实模型
----------------
Expand Down Expand Up @@ -127,7 +127,7 @@ then run:

A mismatched Node version fails fast before the frontend checks; use
-SkipFrontend when web/dist is already built. Building also requires the
Xcode command line tools (codesign) and Go 1.26.10.
Xcode command line tools (codesign) and Go 1.26.11.

Connect a real model
--------------------
Expand Down
7 changes: 5 additions & 2 deletions protocols/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,8 @@
"id": "desktop-web-presentation-state-writer",
"source": "web/src",
"versions": [
1
1,
2
],
"mode": "write-current"
}
Expand All @@ -1310,7 +1311,8 @@
"id": "desktop-web-presentation-state-reader",
"source": "web/src",
"versions": [
1
1,
2
],
"status": "active"
}
Expand Down Expand Up @@ -1352,6 +1354,7 @@
"universal-code.specialist-continuation.v1",
"universal-code.turn-notifications.v1",
"universal-code.workspace-tabs.v1",
"universal-code.workspace-tabs.v2",
"v2_file_upload.v1"
],
"retired_identifiers": [
Expand Down
68 changes: 68 additions & 0 deletions web/e2e/image-recovery-notices.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { expect, test } from "@playwright/test";

for (const mode of ["single", "mixed"] as const) {
test(`new conversation image recovery notices: ${mode}`, async ({ page }, info) => {
const origin = process.env.WORKBENCH_JOURNEY_URL!;
const metadata = JSON.parse(process.env.WORKBENCH_JOURNEY_METADATA!);
const connect = async () => {
await page.getByLabel(/查看令牌|Read access token/u).fill(metadata.read_token);
await page.getByLabel(/操作令牌|Control access token/u).fill(metadata.control_token);
await page.getByRole("button", { name: "连接", exact: true }).click();
};
await page.goto(origin); await connect();
await page.getByRole("button", { name: "新对话", exact: true }).click();
await page.getByRole("button", { name: "接入项目", exact: true }).click();
await page.getByRole("button", { name: "添加", exact: true }).click();
await page.getByRole("textbox", { name: "项目文件夹路径", exact: true }).fill(metadata.workspace);
await page.getByRole("button", { name: "添加", exact: true }).click();
await page.getByRole("button", { name: "创建项目", exact: true }).click();
await page.getByRole("button", { name: "切换为纯文本编辑", exact: true }).click();
const composer = page.getByRole("textbox", { name: "开始新对话", exact: true });
const text = "Keep this draft while discarding only the damaged image";
await composer.fill(text);
const workspaces = await page.request.get(`${origin}/api/v1/workspaces`, { headers: { Authorization: `Bearer ${metadata.read_token}` } });
const workspaceID = (await workspaces.json()).data[0].id;
const record = await page.evaluate(({ workspaceID, mixed }) => {
const existing = Object.keys(localStorage).find((key) => key.startsWith("v2_recovery.v1:"))!;
const prefix = existing.slice(0, existing.lastIndexOf(":") + 1);
const imageKey = prefix + encodeURIComponent(`image-upload:${JSON.stringify([workspaceID, ""])}:v2-image-upload-notice`);
const image = JSON.stringify({ version: "v2_recovery.v1", value: { version: "v2_image_upload.v1", operationKey: "v2-image-upload-notice",
name: "damaged-test-image.png", sha256: "damaged", byteSize: 135, mimeType: "image/png" } });
const creationKey = prefix + encodeURIComponent("creation:invalid-notice-fixture");
const creation = JSON.stringify({ version: "v2_recovery.v1", value: { damaged: true } });
localStorage.setItem(imageKey, image);
if (mixed) localStorage.setItem(creationKey, creation);
return { imageKey, image, creationKey, creation };
}, { workspaceID, mixed: mode === "mixed" });
for (const theme of ["light", "dark"] as const) {
await page.evaluate((value) => localStorage.setItem("prayu.theme", value), theme);
await page.reload(); await connect();
await expect(page.getByRole("button", { name: "丢弃记录", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "发送消息", exact: true })).toBeDisabled();
for (const [width, height] of [[1280, 800], [390, 844]]) {
await page.setViewportSize({ width, height });
if (width === 390) await expect(page.getByRole("navigation", { name: "对话导航", exact: true })).toBeHidden();
await page.waitForTimeout(400);
await page.screenshot({ path: info.outputPath(`${mode}-${theme}-${width}.png`) });
}
}
await expect(page.getByRole("alert")).toHaveCount(mode === "single" ? 0 : 1);
if (mode === "mixed") await expect(page.getByRole("alert")).toContainText("原创建请求无法可靠核对");
await page.getByRole("button", { name: "丢弃记录", exact: true }).click();
await expect(composer).toHaveValue(text);
expect(await page.evaluate((key) => localStorage.getItem(key), record.imageKey)).toBeNull();
if (mode === "single") {
await expect(page.getByRole("alert")).toHaveCount(0);
await expect(page.getByRole("button", { name: "发送消息", exact: true })).toBeEnabled();
} else {
await expect(page.getByRole("alert")).toContainText("原创建请求无法可靠核对");
let creations = 0;
page.on("request", (request) => { if (request.method() === "POST" && new URL(request.url()).pathname === "/api/v1/threads") creations++; });
await page.getByRole("button", { name: "发送消息", exact: true }).click();
await expect(page.locator(".v2-composer-error")).toContainText("原创建请求无法可靠核对");
expect(creations).toBe(0);
expect(await page.evaluate((key) => localStorage.getItem(key), record.creationKey)).toBe(record.creation);
await expect(composer).toHaveValue(text);
}
});
}
1 change: 1 addition & 0 deletions web/src/lib/local-ui-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const messages: Record<string, string> = {
"保存的工作目录请求无法读取,原记录已保留。": "The saved working directory request could not be read. The original record is preserved.",
"最新工作记录存在未读取的间隔,请重试同步。": "There is an unread gap in the latest work records. Retry syncing.",
"工作记录分页游标未推进,已有记录已保留。": "Work record pagination did not advance. Existing records are kept.",
"无法保存工作区标签;当前状态仅保留在本窗口。": "Workspace tabs could not be saved. The current state is kept only in this window.",
"已达到 12 个工作区标签上限,请先关闭暂不使用的标签。": "Maximum of 12 workspace tabs reached. Please close unused tabs before opening new ones.",
};

Expand Down
Loading
Loading