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
34 changes: 34 additions & 0 deletions docs/tasks/T-1200/T-1266-screen-panel-polish/brief.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## 运行环境(云沙箱,必读)
- 开工先在 worktree 根目录运行 依赖准备脚本(镜像自带,把预装依赖链进 node_modules),之后 `pnpm exec tsc` 才可用。
- 这里没有 systemd、Docker,`systemd-run --scope ... --` 前缀一律去掉直接运行;一次只跑一个测试文件。
- 报告只写三样:改了什么(文件列表与 git status 一致)、为什么、测试命令与结果摘要。
- 不提交 git。
- 本仓库是公开仓库:代码、注释、报告里不得出现内部域名、IP、邮箱、人名、真实钥匙、沙箱主目录绝对路径。

# T-1266:Cry Bot 屏幕面板三处小问题(T-1253 上线截图发现)

## 现象(共用电脑模式:`config.localVm.mode === "shared"` 且屏数 > 1;智能体工作位置选「vm」但还没分到屏)
1. 「这个智能体目前没有分配屏幕。」出现两次:`src/components/AssignLocalVmScreen.tsx` 在按钮上方有一行 `role="status"` 提示,同时下面的预览框(`src/components/ComputerPanel.tsx` 约 1300 行一带,`vm-waiting` 阶段的空态)里又显示同一句。
2. 「现在分配屏幕」按钮底边紧贴下面的预览框,没有间距,手机 390 宽度更明显。
3. 下方「工作位置」卡里,选中的「vm」选项仍叫「私有桌面」,卡片底部说明仍是 `place.view.vm.line`「本设备上的私有 Linux 桌面,与你自己的屏幕分开。」。共用模式下智能体用的是共用电脑里的一块屏,这个叫法和说明都不对。T-1248 只把网格里的小字描述换成了 `computer.dest.vmScreenDesc`(见 `src/lib/place.ts` 的 `vmDescriptionKey`),标题和底部说明漏了。

## 要改的
1. 去重:未分配屏幕时这句话只出现一次。保留预览框里的空态提示或按钮上方那行二选一(建议保留按钮上方那行,因为排队位置、出错提示也在那里;预览框在这种状态下不要再重复这句话,可以只留图标或换成不重复的简短说明)。排队中(有 queue_position)的提示照常。
2. 间距:「现在分配屏幕」按钮(含出错提示)与下面预览框之间留出和面板其他块一致的间距(例如 mb-3 / gap-3 一类),桌面和 390/360 手机都不能贴边。
3. 共用模式叫法:与 `vmDescriptionKey` 同一判定口径(抽成一个共用的判定函数,不要再写一份字符串比较),共用模式下:
- 工作位置网格里 vm 选项的标题改用新文案键(中文「共用电脑」,英文「Shared computer」);
- 卡片底部说明(place view 的 vm 那行,`shared/place-view.ts` / `src/lib/place-view.ts`)改用新说明(中文「共用电脑里分给它的一块屏幕,与你自己的屏幕分开。」,英文对应);短说明同理如有显示。
- 面板里其他在共用模式下仍会显示「私有桌面」的地方(例如 `remote-desktop-panel.tsx` 266 行、`ComputerPanel.tsx` 1297 行在未分到屏号时的回退文字),一并按同一判定改成共用叫法。
- 非共用模式(按智能体私有桌面、单屏共享)保持现状不变。
- 新文案键按仓库现有规矩补齐 zh/en、`src/locales/source-hashes.json` 及相关文案测试;iOS 端若用到同一键,按仓库已有做法同步。
4. 不改服务端逻辑,不改分配/排队流程。

## 测试(沉淀进仓库)
- `AssignLocalVmScreen` / `ComputerPanel` 现有测试(如 `src/components/ComputerPanel.takeover.test.ts`、`src/components/remote-desktop-panel.screen.test.ts`)里补用例:未分配屏幕时那句话在渲染结果里只出现一次;排队提示不受影响。
- `WorksOnGrid` / place view 相关单测补用例:共用多屏模式 vm 选项标题与底部说明为共用叫法;按智能体模式仍为「私有桌面」。
- 跑改动相关的测试文件和 `pnpm exec tsc`,报告里写结果摘要。

## 验收
- 共用多屏模式、智能体未分屏:提示只出现一次;按钮与预览框之间有明显间距(1440 桌面、390、360 手机)。
- 共用多屏模式:工作位置卡选中项显示「共用电脑」,底部说明不再出现「私有 Linux 桌面」。
- 按智能体模式下文案与之前一致。
18 changes: 18 additions & 0 deletions docs/tasks/T-1200/T-1266-screen-panel-polish/r2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## 运行环境(云沙箱,必读)
- 开工先在 worktree 根目录运行 依赖准备脚本(镜像自带,把预装依赖链进 node_modules),之后 `pnpm exec vitest` / `pnpm exec tsc` 才可用。
- 这里**没有** systemd、Docker,说明里出现的 `systemd-run --scope ... --` 前缀一律去掉直接运行;机器 8G/4 核,一次只跑一个测试文件。
- 若本轮沙箱已放开(能联网、能监听端口),交回前必须把改动相关的测试全部跑过,包括需要端口的 e2e;涉及的 e2e 连跑 3 次都要过。跑不了的写明原因。
- 报告只写三样:改了什么(文件列表与 git status 一致)、为什么、测试命令与结果摘要。不要写长篇分析;完整输出放 verification 文本文件即可。
- 不提交 git。

# T-1266 第 2 轮返工:补齐两处共用模式叫法

分支已有第 1 轮改动(已提交),在此基础上继续改,不要回退已有改动。原说明见 `docs/tasks/T-1200/T-1266-screen-panel-polish/brief.md` 第 3 条:面板里其他在共用模式下仍会显示「私有桌面」的地方一并按同一判定改成共用叫法。审核发现还有两处漏了:

1. `src/components/bot-panel/ComputerTab.tsx` 约 62 行 `placeLabel`:vm 选项标题走 `worksOnSimpleLabel(place, platform)`,共用多屏模式下仍是「私有桌面」。改为与 `src/lib/place.ts` 的 `vmLabelKey(config)` 同一判定(用 `state.config`),非共用模式不变。
2. `src/components/PlaceChip.tsx` 约 84 行:菜单项 `label: t(placeLabelKey(place))` 与 `place.followBotDetail` 里的 `placeLabelKey(botDefault)`,vm 在共用多屏模式下应使用 `vmLabelKey(state.config)`;非共用模式不变。
3. 再全仓搜一遍前端里 vm 标题(`placeLabelKey`、`worksOnSimpleLabel` 等对 vm 的取名)在共用多屏模式下仍会显示「私有桌面」的入口,同样处理;不改服务端、不改分配/排队流程。

## 测试
- 给 ComputerTab、PlaceChip 补用例:共用多屏模式 vm 显示「共用电脑」,按智能体模式仍为「私有桌面」。
- 跑改动相关测试文件、`pnpm exec tsc`、`pnpm i18n:check`,报告写结果摘要。
17 changes: 17 additions & 0 deletions docs/tasks/T-1200/T-1266-screen-panel-polish/r3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## 运行环境(云沙箱,必读)
- 开工先在 worktree 根目录运行 依赖准备脚本(镜像自带,把预装依赖链进 node_modules),之后 `pnpm exec vitest` / `pnpm exec tsc` 才可用。
- 这里**没有** systemd、Docker,说明里出现的 `systemd-run --scope ... --` 前缀一律去掉直接运行;机器 8G/4 核,一次只跑一个测试文件。
- 若本轮沙箱已放开(能联网、能监听端口),交回前必须把改动相关的测试全部跑过,包括需要端口的 e2e;涉及的 e2e 连跑 3 次都要过。跑不了的写明原因。
- 报告只写三样:改了什么(文件列表与 git status 一致)、为什么、测试命令与结果摘要。不要写长篇分析;完整输出放 verification 文本文件即可。
- 不提交 git。

# T-1266 第 3 轮返工:设置页智能体桌面目的地摘要漏改

分支已有第 1、2 轮改动(已提交),在此基础上继续改,不要回退已有改动。原说明见 `docs/tasks/T-1200/T-1266-screen-panel-polish/brief.md` 第 3 条及 `r2.md`。第 2 轮审核发现还有一处漏改:

1. `src/components/LocalComputerSection.tsx` 约 138–141 行 `destinationLabelKeys.vm` 固定为 `"vm.dest.vm"`,约 580 行 `vm.perBot.destination` 用它显示每个智能体的目的地摘要。共用多屏模式下应显示「共用电脑」:vm 改用 `src/lib/place.ts` 的 `vmLabelKey(config)`(取组件已有的配置,没有就从 store 的 `state.config` 取),非共用模式仍为「私有桌面」。其他目的地不变。
2. 改完再全仓搜一遍 `"vm.dest.vm"` 的直接使用,确认除 `vmLabelKey` 本身及非共用分支的静态表外,没有共用多屏模式下仍会显示「私有桌面」的前端入口;不改服务端、不改分配/排队流程。

## 测试
- 给 LocalComputerSection 补用例:共用多屏模式目的地摘要显示「共用电脑」,按智能体模式仍为「私有桌面」。
- 跑改动相关测试文件、`pnpm exec tsc`、`pnpm i18n:check`,报告只写结果摘要(不要把完整输出写进 docs/)。
17 changes: 17 additions & 0 deletions shared/place-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,20 @@ it("omits Boat setup and team desktop hints under provider lock while retaining
expect(placeView(facts({ providerLock: true, backend: "vps" })).state).toBe("vps");
expect(placeView(facts({ providerLock: true, place: "vm" })).state).toBe("vm");
});


it("describes shared VM screens without changing the private desktop view", () => {
const shared = placeView(facts({ place: "vm", sharedVmScreen: true }));
expect(shared).toMatchObject({
state: "vm", short: "A screen in a shared computer",
line: "A screen assigned to this bot in a shared computer, separate from your own screen.",
});
expect(shared.action).toEqual({ id: "open-vm-settings", label: "Shared computer settings" });
for (const sharedVmScreen of [false, undefined]) {
expect(placeView(facts({ place: "vm", sharedVmScreen }))).toMatchObject({
short: en["place.view.vm.short"], line: en["place.view.vm.line"], action: { id: "open-vm-settings", label: en["place.action.openVmSettings"] },
});
}
expect(placeView(facts({ place: "vm", sharedVmScreen: true, engine: { ...facts().engine, computer: false } })).line)
.toContain("can't use a shared computer");
});
17 changes: 13 additions & 4 deletions shared/place-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export type ServerKind = "my-cloud" | "mac" | "pc" | "linux" | "remote";
export interface PlaceFacts {
/** The place to describe: Auto, Off, or one of the four places. */
place: Place | "auto" | "off";
/** The local desktop is one of multiple screens in a shared computer. */
sharedVmScreen?: boolean;
server: ServerKind;
bot: string;
/** Desktop only: signed in to a paid Cry Bot Cloud plan (the desktop bridge). */
Expand Down Expand Up @@ -174,6 +176,10 @@ export const PLACE_EN = {
"place.view.local.line": "Uses your screen, mouse, and keyboard.",
"place.view.localUnavailable.short": "Can't use it yet",
"place.view.localUnavailable.line": "{reason}",
"place.action.openSharedVmSettings": "Shared computer settings",
"place.view.vmScreen.short": "A screen in a shared computer",
"place.view.vmScreen.line": "A screen assigned to this bot in a shared computer, separate from your own screen.",
"place.view.vmScreenCannot.line": "{model} can't use a shared computer. Choose a model that supports computer use.",
"place.view.vm.short": "Separate from your screen",
"place.view.vm.line": "A private Linux desktop on this device, separate from your own screen.",
"place.view.vmCannot.short": "Not with this model",
Expand Down Expand Up @@ -396,6 +402,8 @@ function templateParams(params: PlaceParams, locale: string): Record<string, str
}

export interface PlaceContext {
/** Describe the local desktop as a screen in a shared computer. */
sharedVmScreen?: boolean;
server?: ServerKind;
role: "admin" | "user";
mode?: "simple" | "advanced";
Expand All @@ -410,8 +418,9 @@ export interface PlaceContext {
export function placeViewOf(state: PlaceState, params: PlaceParams, context: PlaceContext): PlaceView {
const translate = context.translate ?? english;
const values = templateParams(params, context.locale ?? "en");
const segment = STATE[state].key;
let line = translate(lineKey(state, params, context.server), values);
const sharedVm = context.sharedVmScreen && (state === "vm" || state === "vm-cannot");
const segment = sharedVm && state === "vm" ? "vmScreen" : STATE[state].key;
let line = translate(sharedVm ? state === "vm" ? "place.view.vmScreen.line" : "place.view.vmScreenCannot.line" : lineKey(state, params, context.server), values);
let action: PlaceActionId | null = context.source && PASSING.has(state) ? sourceAction(context.source, state) : STATE[state].action;
// A failed row never offers what only the panel can do on the spot.
if (context.source && (action === "start" || action === "wake" || action === "watch")) action = null;
Expand All @@ -428,7 +437,7 @@ export function placeViewOf(state: PlaceState, params: PlaceParams, context: Pla
const label = !action ? null
: action === "clear-pin" && context.mode === "simple" && context.worksOnLabel
? translate("place.action.usePlace", { place: context.worksOnLabel })
: translate(ACTION_KEY[action], values);
: translate(action === "open-vm-settings" && context.sharedVmScreen ? "place.action.openSharedVmSettings" : ACTION_KEY[action], values);
return {
state,
params,
Expand All @@ -441,7 +450,7 @@ export function placeViewOf(state: PlaceState, params: PlaceParams, context: Pla
/** The view of a place from its facts. */
export function placeView(facts: PlaceFacts, options: { translate?: PlaceTranslate; locale?: string } = {}): PlaceView {
const { state, params } = placeState(facts);
return placeViewOf(state, params, { server: facts.providerLock && facts.server === "my-cloud" ? "linux" : facts.server, role: facts.role, mode: facts.mode, ...options });
return placeViewOf(state, params, { server: facts.providerLock && facts.server === "my-cloud" ? "linux" : facts.server, role: facts.role, mode: facts.mode, sharedVmScreen: facts.sharedVmScreen, ...options });
}

/** A stored failed-turn row, worded for this reader. */
Expand Down
2 changes: 1 addition & 1 deletion src/components/AssignLocalVmScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function AssignLocalVmScreen({ path, position, visible = true, onAssigned
await poll(true);
};
if (!visible && !pending && !error) return null;
return <div>
return <div className="mb-3">
<p role="status" className="mb-3 rounded-lg bg-card p-3 text-[13px] text-ink-secondary">
{queuePosition ? t("vm.screens.queued", { position: queuePosition }) : t(pending ? "settings.updates.opening" : "vm.screens.unassignedBot")}
{queuePosition ? ` ${t("vm.screens.queueDetail")}` : null}
Expand Down
24 changes: 24 additions & 0 deletions src/components/BotSettingsDialog.simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Children, createElement, isValidElement, type ReactElement, type ReactN
import { renderToStaticMarkup } from "react-dom/server";
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";

import { setLocale } from "@/lib/i18n";
import type { Routine } from "@/lib/routines";
import type { MemoryDoc } from "@/lib/memory";
import type { Bot, BotSettingsSection, InstanceInfo } from "@/state/store";
Expand Down Expand Up @@ -1001,6 +1002,29 @@ describe("the Where it works page", () => {
expect(where(makeBot()).html).toContain('role="radiogroup"');
});

it.each([
["shared", 4, true],
["shared", 1, false],
["shared", undefined, false],
["per-bot", 4, false],
] as const)("names the VM in the choices, summary and live location for %s / %s", (mode, screens, shared) => {
fixture.storeState = { ...fixture.storeState, config: { localVm: { mode, screens, maxInstances: 1 } } };
try {
for (const locale of ["en", "zh"] as const) {
setLocale(locale);
const label = locale === "zh" ? shared ? "共用电脑" : "私有桌面" : shared ? "Shared computer" : "Private desktop";
const bot = makeBot({ computer: "vm" });
expect(find(where(bot), "data-panel-choice", "vm").props.title).toBe(label);
expect(find(computer(bot), "data-panel-page", "where").props.value).toBe(label);
const liveBot = makeBot({ computer: "cloud", tasks: [{ threadId: "thread-scout", title: "Main", surface: "vm" }] as Bot["tasks"] });
expect(where(liveBot).html).toContain(label);
expect(find(computer(liveBot), "data-panel-page", "where").props.hint).toContain(label);
}
} finally {
setLocale("en");
}
});

it("saves each place through the bot patch, and sends nothing for the place already chosen", () => {
const rendered = where(makeBot());
choose(rendered, "cloud");
Expand Down
22 changes: 19 additions & 3 deletions src/components/ChatView.screen.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { afterAll, describe, expect, it, vi } from "vitest";
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
import type { AppState, Bot, InstanceInfo, Message } from "@/state/store";

vi.hoisted(() => {
const fixture = vi.hoisted(() => {
vi.stubGlobal("window", {});
vi.stubGlobal("localStorage", { getItem: () => null, setItem: () => {} });
return { config: null as AppState["config"] };
});
vi.mock("@/state/store", async (importOriginal) => {
const original = await importOriginal<typeof import("@/state/store")>();
return { ...original, useStore: () => ({
state: { ...original.initialState, instances: [{ instanceId: "test", driverKind: "codex", displayName: "Test" } as InstanceInfo] },
state: { ...original.initialState, config: fixture.config, instances: [{ instanceId: "test", driverKind: "codex", displayName: "Test" } as InstanceInfo] },
dispatch: vi.fn(),
}) };
});
Expand All @@ -24,6 +25,7 @@ vi.mock("./ModelPicker", () => ({ ModelPicker: () => null }));
const { ChatView } = await import("./ChatView");
const { initialState, reducer } = await import("@/state/store");
afterAll(() => vi.unstubAllGlobals());
afterEach(() => { fixture.config = null; });

const IMAGE = 'src="/api/threads/t1/messages/shot/image"';
const greeting: Message = { id: "hi", role: "bot", kind: "text", text: "Hello", at: 1 };
Expand Down Expand Up @@ -62,3 +64,17 @@ describe("ChatView screenshot", () => {
expect(markup).not.toContain("/messages/shot/image");
});
});


it.each([
["shared", 4, "Shared computer"],
["shared", 1, "Private desktop"],
["per-bot", 4, "Private desktop"],
] as const)("passes the VM name to transcript tool icons for %s / %s", (mode, screens, label) => {
fixture.config = { features: { showToolCalls: true }, localVm: { mode, screens, maxInstances: 1 } } as AppState["config"];
const markup = render({ ...bot([greeting, {
id: "tool", parentId: "hi", role: "bot", kind: "activity", at: 2, tool: { name: "screenshot", ok: true },
}]), computer: "vm" });
expect(markup).toContain('data-testid="tool-place"');
expect(markup).toContain(`aria-label="${label}"`);
});
Loading
Loading