mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-19 06:45:15 +00:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ad43e42c0 | ||
|
|
b72bdb6ab6 | ||
|
|
bbed041d64 | ||
|
|
41198e6a2c | ||
|
|
f5d27b7901 | ||
|
|
4e78d15bdc | ||
|
|
2327701497 | ||
|
|
a6da22f86a | ||
|
|
a8456ee63f | ||
|
|
cf91362af4 | ||
|
|
4663f3e40f | ||
|
|
51baa2beb8 | ||
|
|
31b6c2ebd3 | ||
|
|
3da26f32ab | ||
|
|
bcf52f93b1 | ||
|
|
d8c98400fb | ||
|
|
77392d3c1b | ||
|
|
8edccf0503 | ||
|
|
ac633eb096 | ||
|
|
25ff8adf06 | ||
|
|
09a15abb06 | ||
|
|
81fb9c03f6 |
@@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## 0.16.2 - 2026-11-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification ([#10092](https://github.com/getpaseo/paseo/pull/10092))
|
||||
- Fixed detached worktree commits getting lost when archiving a workspace ([#10009](https://github.com/getpaseo/paseo/pull/10009) by [@ragokan](https://github.com/ragokan))
|
||||
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it ([#10067](https://github.com/getpaseo/paseo/pull/10067))
|
||||
- Fixed daemons losing their Hub connection after execution permissions changed ([#10113](https://github.com/getpaseo/paseo/pull/10113))
|
||||
- Fixed saved hosts disappearing when one stored entry could not be read ([#9847](https://github.com/getpaseo/paseo/pull/9847) by [@ragokan](https://github.com/ragokan))
|
||||
- Fixed worktree creation timing out while scanning large ignored folders that `.worktreeinclude` does not name ([#10020](https://github.com/getpaseo/paseo/pull/10020) by [@mgranderath](https://github.com/mgranderath))
|
||||
- Fixed Steer cancelling a Claude compaction in progress ([#10028](https://github.com/getpaseo/paseo/pull/10028) by [@NightMachinery](https://github.com/NightMachinery))
|
||||
- Fixed agents getting stuck after a second Stop when the provider reused the cancelled turn ID ([#9774](https://github.com/getpaseo/paseo/pull/9774) by [@DAnaeto](https://github.com/DAnaeto))
|
||||
- Fixed Desktop staying blank after its renderer exited unexpectedly ([#10035](https://github.com/getpaseo/paseo/pull/10035))
|
||||
- Fixed failed file downloads taking over the app window on web and Desktop ([#9937](https://github.com/getpaseo/paseo/pull/9937) by [@panta82](https://github.com/panta82))
|
||||
- Fixed Import Session losing its scroll position when you select Load more ([#9974](https://github.com/getpaseo/paseo/pull/9974))
|
||||
- Fixed terminals failing to open when the home filesystem refuses Unix sockets, such as on AFS ([#9214](https://github.com/getpaseo/paseo/pull/9214) by [@bendavid](https://github.com/bendavid))
|
||||
- Fixed timed-out Git watchers repeatedly rescanning large repositories ([#9828](https://github.com/getpaseo/paseo/pull/9828) by [@Spshulem](https://github.com/Spshulem))
|
||||
- Fixed `paseo workspace create --path .` using the local daemon's directory instead of the caller's ([#10010](https://github.com/getpaseo/paseo/pull/10010))
|
||||
- Fixed MCP agent status and list responses omitting background work for idle agents ([#10022](https://github.com/getpaseo/paseo/pull/10022) by [@ortschun](https://github.com/ortschun))
|
||||
- Fixed the thinking selector showing an old level after OMP changes it ([#9841](https://github.com/getpaseo/paseo/pull/9841) by [@dsingal0](https://github.com/dsingal0))
|
||||
|
||||
## 0.16.1 - 2026-11-17
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## 0.16.2 - 2026-11-18
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复启用“折叠轮次”时,Claude 回复后续后台任务通知导致上一条已完成的回复被折叠的问题 ([#10092](https://github.com/getpaseo/paseo/pull/10092))
|
||||
- 修复归档工作区时丢失分离 HEAD 的 worktree 提交的问题 ([#10009](https://github.com/getpaseo/paseo/pull/10009),贡献者:[@ragokan](https://github.com/ragokan))
|
||||
- 修复 Desktop 更新后,由上一次 Desktop 会话启动的旧版 daemon 仍在运行的问题 ([#10067](https://github.com/getpaseo/paseo/pull/10067))
|
||||
- 修复更改执行权限后 daemon 与 Hub 断开连接的问题 ([#10113](https://github.com/getpaseo/paseo/pull/10113))
|
||||
- 修复一条已保存的主机记录无法读取时,其他主机也消失的问题 ([#9847](https://github.com/getpaseo/paseo/pull/9847),贡献者:[@ragokan](https://github.com/ragokan))
|
||||
- 修复创建 worktree 时,扫描 `.worktreeinclude` 未指定的大型忽略目录导致超时的问题 ([#10020](https://github.com/getpaseo/paseo/pull/10020),贡献者:[@mgranderath](https://github.com/mgranderath))
|
||||
- 修复发送引导消息时取消 Claude 正在进行的上下文压缩的问题 ([#10028](https://github.com/getpaseo/paseo/pull/10028),贡献者:[@NightMachinery](https://github.com/NightMachinery))
|
||||
- 修复 Provider 重用已取消的轮次 ID 时,再次停止导致 Agent 卡住的问题 ([#9774](https://github.com/getpaseo/paseo/pull/9774),贡献者:[@DAnaeto](https://github.com/DAnaeto))
|
||||
- 修复 Desktop 渲染进程意外退出后窗口一直空白的问题 ([#10035](https://github.com/getpaseo/paseo/pull/10035))
|
||||
- 修复 Web 和 Desktop 上文件下载失败时,错误页面占据应用窗口的问题 ([#9937](https://github.com/getpaseo/paseo/pull/9937),贡献者:[@panta82](https://github.com/panta82))
|
||||
- 修复在“导入会话”中选择“加载更多”时丢失滚动位置的问题 ([#9974](https://github.com/getpaseo/paseo/pull/9974))
|
||||
- 修复主目录所在的文件系统拒绝 Unix 套接字时无法打开终端的问题,例如 AFS ([#9214](https://github.com/getpaseo/paseo/pull/9214),贡献者:[@bendavid](https://github.com/bendavid))
|
||||
- 修复 Git 监视器设置超时后反复扫描大型仓库的问题 ([#9828](https://github.com/getpaseo/paseo/pull/9828),贡献者:[@Spshulem](https://github.com/Spshulem))
|
||||
- 修复 `paseo workspace create --path .` 使用本地 daemon 的目录而非命令所在目录的问题 ([#10010](https://github.com/getpaseo/paseo/pull/10010))
|
||||
- 修复针对空闲 Agent 查询 MCP 状态或列表时漏报后台任务的问题 ([#10022](https://github.com/getpaseo/paseo/pull/10022),贡献者:[@ortschun](https://github.com/ortschun))
|
||||
- 修复 OMP 更改思考级别后,选择器仍显示旧级别的问题 ([#9841](https://github.com/getpaseo/paseo/pull/9841),贡献者:[@dsingal0](https://github.com/dsingal0))
|
||||
|
||||
## 0.16.1 - 2026-11-17
|
||||
|
||||
### 修复
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ provider icon map. You do not need a core manifest entry or provider factory.
|
||||
|
||||
| Provider | Transport | Setup and limitations |
|
||||
| ----------- | ------------------------------------------ | ---------------------------------------------------------------- |
|
||||
| Antigravity | Installed `agy` CLI | [Antigravity](../public-docs/supported-providers/antigravity.md) |
|
||||
| Antigravity | ACP over the installed `agy acp` CLI | [Antigravity](../public-docs/supported-providers/antigravity.md) |
|
||||
| Muse Code | MSP over one `muse serve` host per session | [Muse Code](../public-docs/supported-providers/muse-code.md) |
|
||||
|
||||
## Provider-native session options
|
||||
@@ -50,8 +50,8 @@ or without a control.
|
||||
reject. A key the running session cannot apply (one the provider reads only when it opens) is
|
||||
rejected too, so a stored option always describes what runs. Claude reads most options when it
|
||||
starts its query, and replacing a started query would end its background work, so after the
|
||||
first prompt only Fast can change. Codex fixes its approval policy and sandbox when the thread
|
||||
starts, so it applies only `service_tier` and `plan_mode` live. A session with no
|
||||
first prompt only Fast and Ultracode can change. Codex fixes its approval policy and sandbox
|
||||
when the thread starts, so it applies only `service_tier` and `plan_mode` live. A session with no
|
||||
`applyOptions` rejects every patch; the daemon enforces this. The provider returns the options
|
||||
it ended up with when they differ from the request. The daemon stores the patch and that
|
||||
result in one step after the call resolves. Throwing rejects the whole patch and none of it is
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Fixed
|
||||
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
|
||||
- Fixed detached worktree commits getting lost when archiving a workspace
|
||||
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
|
||||
- Fixed daemons losing their Hub connection after execution permissions changed
|
||||
- Fixed saved hosts disappearing when one stored entry could not be read
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Fixed
|
||||
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
|
||||
- Fixed detached worktree commits getting lost when archiving a workspace
|
||||
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
|
||||
- Fixed daemons losing their Hub connection after execution permissions changed
|
||||
- Fixed saved hosts disappearing when one stored entry could not be read
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Fixed
|
||||
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
|
||||
- Fixed detached worktree commits getting lost when archiving a workspace
|
||||
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
|
||||
- Fixed daemons losing their Hub connection after execution permissions changed
|
||||
- Fixed saved hosts disappearing when one stored entry could not be read
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Fixed
|
||||
- Fixed Collapse turns hiding a finished reply when Claude answers a later background task notification
|
||||
- Fixed detached worktree commits getting lost when archiving a workspace
|
||||
- Fixed Desktop updates leaving an older daemon running when an earlier Desktop session started it
|
||||
- Fixed daemons losing their Hub connection after execution permissions changed
|
||||
- Fixed saved hosts disappearing when one stored entry could not be read
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
+1
-1
@@ -1 +1 @@
|
||||
sha256-k7+5S/4tyAmHdZmUdhpuZ7GOc7hp9cG8wUBFdJI32ng=
|
||||
sha256-yLTaVMgu3tc/dgngJ7RP0htJcWE0ZtQ4mouypevyv0s=
|
||||
|
||||
Generated
+28
-28
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -37468,7 +37468,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -39637,13 +39637,13 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/server": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/server": "0.16.2",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -39890,11 +39890,11 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/relay": "0.16.2",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
@@ -39906,7 +39906,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/cli": "*",
|
||||
@@ -40149,7 +40149,7 @@
|
||||
},
|
||||
"packages/expo-two-way-audio": {
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -40195,7 +40195,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -40225,7 +40225,7 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^1.4.0",
|
||||
@@ -40233,8 +40233,8 @@
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.2.3",
|
||||
@@ -40244,8 +40244,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"react": ">=19.1.0 <20",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -40267,7 +40267,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
@@ -40295,7 +40295,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^2.4.0",
|
||||
@@ -40517,17 +40517,17 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^0.17.1",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.326",
|
||||
"@anthropic-ai/sdk": "^0.104.2",
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/highlight": "0.16.1",
|
||||
"@getpaseo/plugin": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/highlight": "0.16.2",
|
||||
"@getpaseo/plugin": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/relay": "0.16.2",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
@@ -41474,7 +41474,7 @@
|
||||
},
|
||||
"packages/website": {
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.29.1",
|
||||
"@cloudflare/workers-types": "^4.20260317.1",
|
||||
@@ -43084,7 +43084,7 @@
|
||||
},
|
||||
"plugins": {
|
||||
"name": "@getpaseo/builtin-plugins",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"dependencies": {
|
||||
"@getpaseo/plugin": "*",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -2,9 +2,11 @@ import type { Locator } from "@playwright/test";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { expectAgentIdle, expectAgentReadyToInterrupt } from "../support/helpers/agent-stream";
|
||||
import {
|
||||
blurComposerInput,
|
||||
cancelAgent,
|
||||
fillComposerDraft,
|
||||
expectComposerDraft,
|
||||
expectComposerNotFocused,
|
||||
expectComposerVisible,
|
||||
submitMessage,
|
||||
} from "../support/helpers/composer";
|
||||
@@ -71,6 +73,7 @@ test.describe("Agent message rewind", () => {
|
||||
minDistanceFromBottom: 300,
|
||||
});
|
||||
await fillComposerDraft(page, preservedDraft);
|
||||
await blurComposerInput(page);
|
||||
rewindCompletion.clearTimelineStreamCount();
|
||||
|
||||
const rewind = rewindConversation(page, userMessage, rewoundPrompt);
|
||||
@@ -84,6 +87,7 @@ test.describe("Agent message rewind", () => {
|
||||
0,
|
||||
);
|
||||
await expectComposerDraft(page, preservedDraft);
|
||||
await expectComposerNotFocused(page);
|
||||
await expectNearBottom(page);
|
||||
} finally {
|
||||
await agent.cleanup();
|
||||
|
||||
@@ -26,7 +26,7 @@ test.use({
|
||||
},
|
||||
});
|
||||
|
||||
// Rendered light-theme colors: palette yellow 400 for Fast and Ultrafast, muted foreground for Normal.
|
||||
// The Speed icon highlights any explicit tier other than Normal.
|
||||
const ACTIVE_SPEED_COLOR = "rgb(251, 191, 36)";
|
||||
const NORMAL_SPEED_COLOR = "rgb(113, 113, 122)";
|
||||
|
||||
@@ -63,7 +63,7 @@ async function expectSpeedIconColor(page: Page, color: string): Promise<void> {
|
||||
}
|
||||
|
||||
async function expectSpeedChoices(page: Page, choices: string[]): Promise<void> {
|
||||
for (const choice of ["Normal", "Fast", "Ultrafast"]) {
|
||||
for (const choice of ["Normal", "Flex", "Fast", "Ultrafast"]) {
|
||||
const option = page.getByText(choice, { exact: true }).last();
|
||||
if (choices.includes(choice)) {
|
||||
await expect(option).toBeVisible();
|
||||
@@ -115,21 +115,24 @@ for (const viewport of [
|
||||
await expectSpeedIconColor(page, ACTIVE_SPEED_COLOR);
|
||||
await page.screenshot({ path: testInfo.outputPath(`${viewport.name}-fast-selected.png`) });
|
||||
await openSpeedSelector(page);
|
||||
await expectSpeedChoices(page, ["Normal", "Fast", "Ultrafast"]);
|
||||
await expectSpeedChoices(page, ["Normal", "Flex", "Fast", "Ultrafast"]);
|
||||
await page.screenshot({ path: testInfo.outputPath(`${viewport.name}-speed-options.png`) });
|
||||
await selectSpeed(page, "Ultrafast");
|
||||
await expectSpeedIconColor(page, ACTIVE_SPEED_COLOR);
|
||||
await openSpeedSelector(page);
|
||||
await expectSpeedChoices(page, ["Normal", "Fast", "Ultrafast"]);
|
||||
await expectSpeedChoices(page, ["Normal", "Flex", "Fast", "Ultrafast"]);
|
||||
await page.screenshot({
|
||||
path: testInfo.outputPath(`${viewport.name}-ultrafast-selected.png`),
|
||||
});
|
||||
await selectSpeed(page, "Flex");
|
||||
await expectSpeedIconColor(page, ACTIVE_SPEED_COLOR);
|
||||
await openSpeedSelector(page);
|
||||
await selectSpeed(page, "Normal");
|
||||
await expectSpeedIconColor(page, NORMAL_SPEED_COLOR);
|
||||
if (viewport.name === "desktop") {
|
||||
await switchAgentModel(agent.id, "gpt-6-sol");
|
||||
await openSpeedSelector(page);
|
||||
await expectSpeedChoices(page, ["Normal", "Fast"]);
|
||||
await expectSpeedChoices(page, ["Normal", "Flex", "Fast"]);
|
||||
await page.screenshot({ path: testInfo.outputPath("desktop-fast-only.png") });
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import type { FormPreferences } from "@/create-agent-preferences/preferences";
|
||||
import { closeCommandCenter, openCommandCenter } from "../support/helpers/command-center";
|
||||
import {
|
||||
closeCommandCenter,
|
||||
openCommandCenter,
|
||||
openCommandCenterWithShortcut,
|
||||
} from "../support/helpers/command-center";
|
||||
import {
|
||||
enterComposerFullscreen,
|
||||
exitComposerFullscreen,
|
||||
expectComposerVisible,
|
||||
fillComposerDraft,
|
||||
resizeComposerViewport,
|
||||
} from "../support/helpers/composer";
|
||||
import {
|
||||
applyCommandCenterAgentControls,
|
||||
chooseCommandCenterAgentControl,
|
||||
@@ -14,8 +25,18 @@ import {
|
||||
} from "../support/helpers/command-center-agent-controls";
|
||||
import { clickNewChat, gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import {
|
||||
assertNewWorkspaceSidebarAndHeader,
|
||||
connectNewWorkspaceDaemonClient,
|
||||
openGlobalNewWorkspaceComposer,
|
||||
selectNewWorkspaceProject,
|
||||
selectWorkspaceIsolation,
|
||||
submitNewWorkspacePrompt,
|
||||
} from "../support/helpers/new-workspace";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { expectAppRoute } from "../support/helpers/route-assertions";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { closeMobileAgentSidebar, openMobileAgentSidebar } from "../support/helpers/sidebar";
|
||||
import { buildSchedulesRoute } from "@/utils/host-routes";
|
||||
|
||||
const CREATE_AGENT_PREFERENCES_KEY = "@paseo:create-agent-preferences";
|
||||
@@ -30,7 +51,7 @@ async function seedMockDraftPreferences(page: import("@playwright/test").Page):
|
||||
providerPreferences: {
|
||||
mock: {
|
||||
model: "five-minute-stream",
|
||||
mode: "load-test",
|
||||
mode: "approval-test",
|
||||
},
|
||||
},
|
||||
} satisfies FormPreferences),
|
||||
@@ -221,6 +242,94 @@ test.describe("Command Center agent controls", () => {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("applies New workspace model and mode choices before the first message", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "command-center-new-workspace-controls-" });
|
||||
await seedMockDraftPreferences(page);
|
||||
const client = await connectNewWorkspaceDaemonClient();
|
||||
|
||||
try {
|
||||
const backgroundAgent = await workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.repoPath,
|
||||
workspaceId: workspace.workspaceId,
|
||||
title: "Background agent",
|
||||
model: "five-minute-stream",
|
||||
modeId: "approval-test",
|
||||
});
|
||||
await openAgentRoute(page, {
|
||||
workspaceId: workspace.workspaceId,
|
||||
agentId: backgroundAgent.id,
|
||||
});
|
||||
await openGlobalNewWorkspaceComposer(page);
|
||||
await selectNewWorkspaceProject(page, workspace);
|
||||
await selectWorkspaceIsolation(page, "local");
|
||||
|
||||
await applyCommandCenterAgentControls(page, DRAFT_AGENT_CONTROL_CHOICES);
|
||||
await closeCommandCenter(page);
|
||||
await submitNewWorkspacePrompt(page, "Create with Command Center choices");
|
||||
const created = await assertNewWorkspaceSidebarAndHeader(page, {
|
||||
serverId: getServerId(),
|
||||
client,
|
||||
previousWorkspaceId: workspace.workspaceId,
|
||||
projectDisplayName: workspace.projectDisplayName,
|
||||
});
|
||||
|
||||
await expectWorkspaceAgentConfiguration(
|
||||
{ client: workspace.client, workspaceId: created.workspaceId },
|
||||
{ provider: "mock", model: "ten-second-stream", modeId: "load-test" },
|
||||
);
|
||||
await expectWorkspaceAgentConfiguration(workspace, {
|
||||
id: backgroundAgent.id,
|
||||
provider: "mock",
|
||||
model: "five-minute-stream",
|
||||
modeId: "approval-test",
|
||||
});
|
||||
} finally {
|
||||
await client.close().catch(() => undefined);
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps draft settings searchable from the compact sidebar and fullscreen editor", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "command-center-fullscreen-draft-" });
|
||||
await seedMockDraftPreferences(page);
|
||||
|
||||
try {
|
||||
await openDraftComposer(page, workspace.workspaceId);
|
||||
await resizeComposerViewport(page, "portrait");
|
||||
await applyCompactComposerSettings(page);
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("applies compact sidebar and fullscreen settings to the running agent", async ({ page }) => {
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix: "command-center-fullscreen-agent-",
|
||||
title: "Compact Command Center settings",
|
||||
model: "five-minute-stream",
|
||||
modeId: "approval-test",
|
||||
});
|
||||
|
||||
try {
|
||||
await resizeComposerViewport(page, "portrait");
|
||||
await openAgentRoute(page, workspace);
|
||||
await applyCompactComposerSettings(page);
|
||||
await expectWorkspaceAgentConfiguration(workspace, {
|
||||
id: workspace.agentId,
|
||||
provider: "mock",
|
||||
model: "ten-second-stream",
|
||||
modeId: "load-test",
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const DRAFT_AGENT_CONTROL_CHOICES = [
|
||||
@@ -233,3 +342,22 @@ async function openDraftComposer(page: import("@playwright/test").Page, workspac
|
||||
await clickNewChat(page);
|
||||
await waitForDraftComposer(page);
|
||||
}
|
||||
|
||||
async function applyCompactComposerSettings(page: import("@playwright/test").Page): Promise<void> {
|
||||
const [model, mode] = DRAFT_AGENT_CONTROL_CHOICES;
|
||||
await expectComposerVisible(page);
|
||||
await openMobileAgentSidebar(page);
|
||||
await openCommandCenter(page);
|
||||
await chooseCommandCenterAgentControl({ page, ...mode });
|
||||
await closeMobileAgentSidebar(page);
|
||||
|
||||
await fillComposerDraft(page, "First line\nSecond line\nThird line");
|
||||
await enterComposerFullscreen(page);
|
||||
await openCommandCenterWithShortcut(page);
|
||||
await chooseCommandCenterAgentControl({ page, ...model });
|
||||
await exitComposerFullscreen(page);
|
||||
|
||||
await openCommandCenterWithShortcut(page);
|
||||
await expectCommandCenterAgentControlSelected({ page, ...model });
|
||||
await expectCommandCenterAgentControlSelected({ page, ...mode });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect } from "../support/fixtures";
|
||||
import { test, expect, type Page } from "../support/fixtures";
|
||||
import { openWorkspaceWithAgents } from "../support/helpers/archive-tab";
|
||||
import {
|
||||
composerLocator,
|
||||
@@ -311,3 +311,86 @@ test.describe("Composer trailing disc on a new chat", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const SHORTCUT_MOD = process.platform === "darwin" ? "Meta" : "Control";
|
||||
|
||||
async function toggleModelPickerFromComposer(page: Page) {
|
||||
await composerLocator(page).focus();
|
||||
await page.keyboard.press(`${SHORTCUT_MOD}+Slash`);
|
||||
}
|
||||
|
||||
async function expectModelPickerClosesFromSearch(page: Page) {
|
||||
const search = page.getByPlaceholder(/Search (all )?models/);
|
||||
await expect(search).toBeVisible();
|
||||
await search.focus();
|
||||
await page.keyboard.press(`${SHORTCUT_MOD}+Slash`);
|
||||
await expect(search).toBeHidden();
|
||||
}
|
||||
|
||||
async function cycleComposerEffort(page: Page) {
|
||||
await composerLocator(page).focus();
|
||||
await page.keyboard.press(`${SHORTCUT_MOD}+Shift+Slash`);
|
||||
}
|
||||
|
||||
function modelControl(page: Page) {
|
||||
return page.getByRole("button", { name: "Select model (Ten second stream)", exact: true });
|
||||
}
|
||||
|
||||
function thinkingControl(page: Page, effort: string) {
|
||||
return page.getByRole("button", { name: `Select thinking option (${effort})`, exact: true });
|
||||
}
|
||||
|
||||
async function expectShortcutHint(
|
||||
page: Page,
|
||||
control: ReturnType<typeof modelControl>,
|
||||
label: string,
|
||||
) {
|
||||
await control.hover();
|
||||
const tooltip = page.getByRole("tooltip").filter({ hasText: label });
|
||||
await expect(tooltip).toContainText("/");
|
||||
}
|
||||
|
||||
test.describe("Composer model and effort shortcuts", () => {
|
||||
test("opens and closes the model picker and wraps effort in toolbar order", async ({ page }) => {
|
||||
const agent = await seedMockAgentWorkspace({
|
||||
repoPrefix: "composer-shortcuts-",
|
||||
title: "Composer shortcuts",
|
||||
model: "ten-second-stream",
|
||||
thinkingOptionId: "high",
|
||||
});
|
||||
try {
|
||||
await openAgentRoute(page, agent);
|
||||
await expectComposerVisible(page);
|
||||
await expect(thinkingControl(page, "High")).toBeVisible();
|
||||
|
||||
await test.step("Show both shortcuts in the toolbar tooltips", async () => {
|
||||
await expectShortcutHint(page, modelControl(page), "Change model");
|
||||
await expectShortcutHint(page, thinkingControl(page, "High"), "Thinking mode");
|
||||
});
|
||||
|
||||
await test.step("Toggle the picker with its search field focused", async () => {
|
||||
await toggleModelPickerFromComposer(page);
|
||||
await expectModelPickerClosesFromSearch(page);
|
||||
});
|
||||
|
||||
await test.step("Wrap from High to Low and advance to Medium", async () => {
|
||||
await cycleComposerEffort(page);
|
||||
await expect(thinkingControl(page, "Low")).toBeVisible();
|
||||
await cycleComposerEffort(page);
|
||||
await expect(thinkingControl(page, "Medium")).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step("Toggle the folded picker and cycle effort in a compact window", async () => {
|
||||
await page.setViewportSize({ width: 480, height: 844 });
|
||||
const effortLabel = page.getByTestId("combined-model-selector-thinking-label");
|
||||
await expect(effortLabel).toHaveText("Medium");
|
||||
await toggleModelPickerFromComposer(page);
|
||||
await expectModelPickerClosesFromSearch(page);
|
||||
await cycleComposerEffort(page);
|
||||
await expect(effortLabel).toHaveText("High");
|
||||
});
|
||||
} finally {
|
||||
await agent.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -513,3 +513,37 @@ test("compact file sheets cover Explorer and return to its retained file list",
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
async function toggleCommentInMainEditor(page: Parameters<typeof ensureExplorerSidebar>[0]) {
|
||||
const editor = page.getByLabel("Source editor for comment.cs").getByRole("textbox");
|
||||
await expect(editor).toBeVisible();
|
||||
await editor.press(process.platform === "darwin" ? "Meta+Slash" : "Control+Slash");
|
||||
await expect(editor).toHaveText("// public class Example {}");
|
||||
}
|
||||
|
||||
test("keeps the comment shortcut in the editor beside an Explorer agent", async ({ page }) => {
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix: "explorer-comment-shortcut-",
|
||||
title: "Chat beside the editor",
|
||||
model: "ten-second-stream",
|
||||
});
|
||||
try {
|
||||
await writeFile(`${workspace.cwd}/comment.cs`, "public class Example {}");
|
||||
await openAgentRoute(page, workspace);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Select model (Ten second stream)" }),
|
||||
).toBeVisible();
|
||||
await ensureExplorerSidebar(page);
|
||||
await dragTabIntoExplorer(page, `agent_${workspace.agentId}`);
|
||||
await expect(
|
||||
explorerSidebar(page).getByRole("button", { name: "Select model (Ten second stream)" }),
|
||||
).toBeVisible();
|
||||
await openFilesPanel(page);
|
||||
await openFileFromExplorer(page, "comment.cs");
|
||||
await explorerSidebar(page).getByTestId(`workspace-tab-agent_${workspace.agentId}`).click();
|
||||
await toggleCommentInMainEditor(page);
|
||||
await expect(page.getByPlaceholder(/Search (all )?models/)).toBeHidden();
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,16 +1,29 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { installDaemonWebSocketGate } from "../support/helpers/daemon-websocket-gate";
|
||||
import { scrollChatAwayFromBottom } from "../support/helpers/agent-bottom-anchor";
|
||||
import {
|
||||
closeCommandCenter,
|
||||
openCommandCenter,
|
||||
selectCommandCenterTab,
|
||||
} from "../support/helpers/command-center";
|
||||
import { installDaemonWebSocketGate } from "../support/helpers/daemon-websocket-gate";
|
||||
import {
|
||||
attachComposerTestImage,
|
||||
composerLocator,
|
||||
expectComposerDraft,
|
||||
expectComposerFocused,
|
||||
expectComposerNotFocused,
|
||||
expectComposerVisible,
|
||||
fillComposerDraft,
|
||||
submitMessage,
|
||||
submitMessageWithButton,
|
||||
} from "../support/helpers/composer";
|
||||
import { readReplicaCache, writeReplicaCache } from "../support/helpers/replica-cache-storage";
|
||||
import {
|
||||
disconnectViewedTimeline,
|
||||
releaseHeldCatchUp,
|
||||
restoreViewedTimelineHoldingCatchUp,
|
||||
} from "../support/helpers/timeline-resume";
|
||||
|
||||
// UI plumbing contract against the dev mock provider. Real-provider behavior is tested in `daemon-e2e/*-rewind.real.e2e.test.ts`.
|
||||
|
||||
@@ -33,6 +46,17 @@ async function selectRewindOption(page: Page, name: string): Promise<void> {
|
||||
await option.click();
|
||||
}
|
||||
|
||||
async function searchRewindActions(page: Page): Promise<Locator> {
|
||||
const palette = await openCommandCenter(page);
|
||||
await selectCommandCenterTab(palette, "Actions");
|
||||
await palette.getByRole("textbox").fill("rewind last turn");
|
||||
return palette;
|
||||
}
|
||||
|
||||
function rewindAction(palette: Locator, name: string): Locator {
|
||||
return palette.getByRole("button", { name: `${name} This action cannot be undone`, exact: true });
|
||||
}
|
||||
|
||||
async function rewriteCachedMessageAsLegacyRow(
|
||||
page: Page,
|
||||
input: { prompt: string; agentId: string; workspaceId: string },
|
||||
@@ -199,10 +223,6 @@ test.describe("Rewind sheet", () => {
|
||||
await expectUserMessageCount(page, 2);
|
||||
await session.client.waitForFinish(session.agentId);
|
||||
|
||||
await scrollChatAwayFromBottom(page, {
|
||||
deltaY: -900,
|
||||
minDistanceFromBottom: 300,
|
||||
});
|
||||
await userMessage(page, firstPrompt).hover();
|
||||
await page.getByTestId("rewind-menu-trigger").first().click();
|
||||
const rewindSheet = page.getByTestId("rewind-menu-content");
|
||||
@@ -217,6 +237,7 @@ test.describe("Rewind sheet", () => {
|
||||
await expect(page.getByText("Cycle 1", { exact: true })).toHaveCount(0);
|
||||
await expectUserMessageCount(page, 1);
|
||||
await expectComposerDraft(page, firstPrompt);
|
||||
await expectComposerFocused(page);
|
||||
|
||||
await submitMessage(page, replacementPrompt);
|
||||
await expectUserMessageVisible(page, replacementPrompt);
|
||||
@@ -232,17 +253,7 @@ test.describe("Rewind sheet", () => {
|
||||
await selectRewindOption(page, "Rewind files");
|
||||
await expect(page.getByTestId("rewind-menu-content")).toHaveCount(0);
|
||||
await expectComposerDraft(page, "");
|
||||
await expectUserMessageCount(page, 2);
|
||||
|
||||
const preservedDraft = "Keep this human draft after rewind.";
|
||||
await fillComposerDraft(page, preservedDraft);
|
||||
await composerLocator(page).evaluate((element) => element.blur());
|
||||
await userMessage(page, replacementPrompt).hover();
|
||||
await page.getByTestId("rewind-menu-trigger").last().click();
|
||||
await expect(page.getByTestId("rewind-menu-content")).toBeVisible();
|
||||
await selectRewindOption(page, "Rewind files");
|
||||
await expect(page.getByTestId("rewind-menu-content")).toHaveCount(0);
|
||||
await expectComposerDraft(page, preservedDraft);
|
||||
await expectComposerNotFocused(page);
|
||||
await expectUserMessageCount(page, 2);
|
||||
|
||||
await fillComposerDraft(page, "");
|
||||
@@ -253,12 +264,109 @@ test.describe("Rewind sheet", () => {
|
||||
await selectRewindOption(page, "Rewind conversation and files");
|
||||
await expect(page.getByTestId("rewind-menu-content")).toHaveCount(0);
|
||||
await expectComposerDraft(page, replacementPrompt);
|
||||
await expectComposerFocused(page);
|
||||
await expectUserMessageCount(page, 1);
|
||||
} finally {
|
||||
await session.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("rewinds the latest turn from the Command Center", async ({ page }) => {
|
||||
const firstPrompt = "Keep this earlier turn.";
|
||||
const latestPrompt = "Edit this latest turn.";
|
||||
const session = await seedMockAgentWorkspace({
|
||||
repoPrefix: "rewind-command-center-e2e-",
|
||||
title: "Command Center rewind",
|
||||
initialPrompt: firstPrompt,
|
||||
});
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, session);
|
||||
await expectComposerVisible(page);
|
||||
await submitMessage(page, latestPrompt);
|
||||
await expectUserMessageVisible(page, latestPrompt);
|
||||
await session.client.waitForFinish(session.agentId);
|
||||
|
||||
const palette = await searchRewindActions(page);
|
||||
await expect(rewindAction(palette, "Rewind files")).toBeVisible();
|
||||
await expect(rewindAction(palette, "Rewind conversation and files")).toBeVisible();
|
||||
await rewindAction(palette, "Rewind conversation").click();
|
||||
|
||||
await expectUserMessageVisible(page, firstPrompt);
|
||||
await expect(userMessage(page, latestPrompt)).toHaveCount(0);
|
||||
await expectComposerDraft(page, latestPrompt);
|
||||
await expectComposerFocused(page);
|
||||
} finally {
|
||||
await session.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("waits for the latest prompt before offering Command Center rewind after reconnect", async ({
|
||||
page,
|
||||
}) => {
|
||||
const cachedPrompt = "Keep the prompt that was visible before reconnect.";
|
||||
const latestPrompt = "Rewind the prompt sent while the app was disconnected.";
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
const session = await seedMockAgentWorkspace({
|
||||
repoPrefix: "rewind-reconnect-e2e-",
|
||||
title: "Rewind after reconnect",
|
||||
initialPrompt: cachedPrompt,
|
||||
});
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, session);
|
||||
await expectUserMessageVisible(page, cachedPrompt);
|
||||
const initialPalette = await searchRewindActions(page);
|
||||
await expect(rewindAction(initialPalette, "Rewind conversation")).toBeVisible();
|
||||
await closeCommandCenter(page);
|
||||
|
||||
await disconnectViewedTimeline(page, gate);
|
||||
await session.client.sendAgentMessage(session.agentId, latestPrompt);
|
||||
await session.client.waitForFinish(session.agentId);
|
||||
await restoreViewedTimelineHoldingCatchUp(page, gate);
|
||||
|
||||
const palette = await searchRewindActions(page);
|
||||
await expect(palette.getByText("No matches", { exact: true })).toBeVisible();
|
||||
await releaseHeldCatchUp(page, gate);
|
||||
await rewindAction(palette, "Rewind conversation").click();
|
||||
|
||||
await expectUserMessageVisible(page, cachedPrompt);
|
||||
await expectComposerDraft(page, latestPrompt);
|
||||
} finally {
|
||||
gate.restore();
|
||||
await session.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("hides rewind when the latest prompt only contains an attachment", async ({ page }) => {
|
||||
const session = await seedMockAgentWorkspace({
|
||||
repoPrefix: "rewind-image-only-e2e-",
|
||||
title: "Rewind image-only prompt",
|
||||
initialPrompt: "Earlier text prompt.",
|
||||
});
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, session);
|
||||
await expectComposerVisible(page);
|
||||
const palette = await searchRewindActions(page);
|
||||
await expect(rewindAction(palette, "Rewind conversation")).toBeVisible();
|
||||
await closeCommandCenter(page);
|
||||
|
||||
await attachComposerTestImage(page);
|
||||
await submitMessageWithButton(page, "");
|
||||
const imagePrompt = page.getByTestId("user-message").filter({
|
||||
has: page.getByRole("button", { name: "Open image attachment" }),
|
||||
});
|
||||
await expect(imagePrompt).toHaveAttribute("aria-busy", "false");
|
||||
await session.client.waitForFinish(session.agentId);
|
||||
|
||||
const reopened = await searchRewindActions(page);
|
||||
await expect(reopened.getByText("No matches", { exact: true })).toBeVisible();
|
||||
} finally {
|
||||
await session.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("surfaces rewind failures without crashing the page", async ({ page }) => {
|
||||
const firstPrompt = "emit 1 coalesced agent stream updates for failed rewind turn.";
|
||||
const rewindError = "No file checkpoint found for message rewind-failure-e2e.";
|
||||
@@ -277,6 +385,10 @@ test.describe("Rewind sheet", () => {
|
||||
|
||||
await expectUserMessageVisible(page, firstPrompt);
|
||||
|
||||
const palette = await searchRewindActions(page);
|
||||
await rewindAction(palette, "Rewind conversation").click();
|
||||
await expect(page.getByTestId("app-toast-message")).toHaveText(rewindError);
|
||||
|
||||
await userMessage(page, firstPrompt).hover();
|
||||
await page.getByTestId("rewind-menu-trigger").first().click();
|
||||
const rewindSheet = page.getByTestId("rewind-menu-content");
|
||||
|
||||
@@ -24,7 +24,7 @@ function send(message) {
|
||||
function respond(method, params) {
|
||||
switch (method) {
|
||||
case "initialize":
|
||||
return {};
|
||||
return { userAgent: "codex/0.159.0" };
|
||||
case "model/list":
|
||||
return { data: models };
|
||||
case "config/read":
|
||||
|
||||
@@ -56,11 +56,20 @@ function inFlightTurn(page: Page) {
|
||||
return page.getByTestId("turn-working-indicator");
|
||||
}
|
||||
|
||||
/**
|
||||
* Presses a fork trigger until its menu shows.
|
||||
*
|
||||
* The in-flight turn's trigger sits below text that is still streaming in. While the chat is
|
||||
* shorter than the viewport, each new line moves the trigger down. A line that arrives between
|
||||
* the press and the release moves the trigger away from the pointer, so the press opens nothing,
|
||||
* and the next press lands on the trigger where it is now.
|
||||
*/
|
||||
async function openForkMenu(page: Page, trigger: ReturnType<Page["getByRole"]>): Promise<void> {
|
||||
await trigger.click();
|
||||
await expect(page.getByRole("menuitem", { name: "Fork in a new tab" })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
const forkInNewTab = page.getByRole("menuitem", { name: "Fork in a new tab" });
|
||||
await expect(async () => {
|
||||
await trigger.click({ timeout: 5_000 });
|
||||
await expect(forkInNewTab).toBeVisible({ timeout: 5_000 });
|
||||
}).toPass({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
export async function openMostRecentAssistantForkMenu(page: Page): Promise<void> {
|
||||
|
||||
@@ -23,6 +23,11 @@ export async function openCommandCenter(page: Page): Promise<Locator> {
|
||||
return panel;
|
||||
}
|
||||
|
||||
export async function openCommandCenterWithShortcut(page: Page): Promise<void> {
|
||||
await page.keyboard.press("ControlOrMeta+k");
|
||||
await expect(page.getByTestId("command-center-panel")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function closeCommandCenter(page: Page): Promise<void> {
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByTestId("command-center-panel")).not.toBeVisible();
|
||||
|
||||
@@ -2,6 +2,7 @@ import { buildSettingsHostSectionRoute } from "@/utils/host-routes";
|
||||
import { expect, type Page } from "../fixtures";
|
||||
import { getServerId } from "./server-id";
|
||||
import { expectAppRoute } from "./route-assertions";
|
||||
import { escapeRegex } from "./regex";
|
||||
|
||||
/**
|
||||
* Settings → Host → Plugins: the Installed and Browse tabs, the page menu, the install sheet and a
|
||||
@@ -28,8 +29,17 @@ function pluginSwitch(page: Page, name: string, action: "Disable" | "Enable") {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A toast that times out stays in the page while it fades, so the next toast can share the screen
|
||||
* with it, even when both have the same text. The pattern matches case, so "Installed x" does not
|
||||
* match "Uninstalled x".
|
||||
*/
|
||||
export async function expectToast(page: Page, message: string): Promise<void> {
|
||||
await expect(page.getByTestId("app-toast-message")).toContainText(message);
|
||||
const toast = page
|
||||
.getByTestId("app-toast-message")
|
||||
.filter({ hasText: new RegExp(escapeRegex(message)) })
|
||||
.first();
|
||||
await expect(toast).toBeVisible();
|
||||
}
|
||||
|
||||
// Tabs and search
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -30,6 +30,25 @@ function answer(
|
||||
}
|
||||
|
||||
describe("draft options model", () => {
|
||||
it("retains an Ultracode option only after the current host advertises it", () => {
|
||||
const model = openDraftOptions({ provider: "claude" });
|
||||
const legacy = { provider: "claude", cwd: "/repo", thinkingOptionId: "ultracode" };
|
||||
model.applyResolved(answer("claude", "old-host", {}, []));
|
||||
expect(model.retainResolvedOption("ultracode", "old-host")).toBeUndefined();
|
||||
expect(draftControlsRequest(model.getState(), legacy)).toEqual(legacy);
|
||||
|
||||
model.applyResolved(
|
||||
answer("claude", "new-host", { ultracode: true }, [
|
||||
{ type: "toggle", key: "ultracode", label: "Ultracode" },
|
||||
]),
|
||||
);
|
||||
expect(model.retainResolvedOption("ultracode", "old-host")).toBeUndefined();
|
||||
expect(model.retainResolvedOption("ultracode", "new-host")).toEqual({ ultracode: true });
|
||||
expect(
|
||||
draftControlsRequest(model.getState(), { ...legacy, thinkingOptionId: "high" }),
|
||||
).toMatchObject({ thinkingOptionId: "high", providerOptions: { ultracode: true } });
|
||||
});
|
||||
|
||||
it("draws a legacy Fast profile as the Fast tier the daemon resolved", () => {
|
||||
const model = openDraftOptions({ provider: "codex", seed: { service_tier: "fast" } });
|
||||
model.applyResolved(answer("codex", "k1", { service_tier: "priority" }));
|
||||
|
||||
@@ -47,6 +47,7 @@ export interface DraftOptionsModel {
|
||||
applyProfile: (profile: { provider: string; options: ProviderOptions }) => void;
|
||||
setRemembered: (remembered: ProviderOptions) => void;
|
||||
setOption: (key: string, value: unknown) => void;
|
||||
retainResolvedOption: (key: string, requestKey: string) => ProviderOptions | undefined;
|
||||
applyResolved: (resolved: ResolvedDraftOptions) => void;
|
||||
}
|
||||
|
||||
@@ -112,6 +113,17 @@ export function openDraftOptions(input: {
|
||||
: { ...current, edits: { ...current.edits, [key]: value } },
|
||||
);
|
||||
},
|
||||
retainResolvedOption: (key, requestKey) => {
|
||||
const resolved = state.resolved;
|
||||
if (resolved?.requestKey !== requestKey || key in state.edits) return undefined;
|
||||
const value = resolved.options[key];
|
||||
if (value === undefined || !resolved.controls.some((control) => control.key === key)) {
|
||||
return undefined;
|
||||
}
|
||||
const patch = { [key]: value };
|
||||
publish((current) => ({ ...current, edits: { ...current.edits, ...patch } }));
|
||||
return patch;
|
||||
},
|
||||
applyResolved: (resolved) =>
|
||||
publish((current) => ({
|
||||
...current,
|
||||
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
type ToolbarGlyph,
|
||||
} from "@/components/ui/control-geometry";
|
||||
|
||||
import { useKeyboardToggle, type KeyboardToggleAction } from "@/hooks/use-keyboard-toggle";
|
||||
|
||||
const EMPTY_COMBOBOX_OPTIONS: ComboboxOption[] = [];
|
||||
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
||||
|
||||
@@ -47,6 +49,7 @@ interface CombinedModelSelectorProps {
|
||||
hovered: boolean;
|
||||
pressed: boolean;
|
||||
}) => React.ReactNode;
|
||||
toggleAction?: KeyboardToggleAction;
|
||||
onOpen?: () => void;
|
||||
onClose?: () => void;
|
||||
onRetryProvider?: (provider: AgentProvider) => void;
|
||||
@@ -82,6 +85,7 @@ export function CombinedModelSelector({
|
||||
onCreateProfile,
|
||||
onEditProfile,
|
||||
renderTrigger,
|
||||
toggleAction,
|
||||
onOpen,
|
||||
onClose,
|
||||
onRetryProvider,
|
||||
@@ -147,6 +151,14 @@ export function CombinedModelSelector({
|
||||
handleOpenChange(!isOpen);
|
||||
}, [handleOpenChange, isOpen]);
|
||||
|
||||
useKeyboardToggle({
|
||||
action: toggleAction,
|
||||
disabled,
|
||||
open: isOpen,
|
||||
searchFocused: browser.isSearchFocused,
|
||||
onToggle: handleTriggerPress,
|
||||
});
|
||||
|
||||
const triggerStyle = useCallback(
|
||||
({ pressed, hovered }: PressableStateCallbackType & { hovered?: boolean }) => {
|
||||
if (triggerFill) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -215,6 +215,32 @@ describe("Mermaid sandbox runtime", () => {
|
||||
expect(widths).toEqual([240, 350, 900]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Agents often write a label that starts with a mention or holds an email address. Mermaid 11
|
||||
* read the text up to the "@" as an edge id, so these diagrams failed to parse.
|
||||
*/
|
||||
it.each([
|
||||
"flowchart LR\n F[@mention in any workspace] --> G[Look up token]",
|
||||
"flowchart LR\n A[ops@example.com] --> B",
|
||||
"flowchart LR\n A -->|@user approves| B",
|
||||
"graph TD\n A(@x) --> B{@x?}",
|
||||
])("renders a flowchart whose label contains an @: %s", async (source) => {
|
||||
const frame = await mountRuntime();
|
||||
|
||||
const result = await render(frame, { revision: 1, source });
|
||||
|
||||
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
|
||||
});
|
||||
|
||||
it("still renders a flowchart edge id", async () => {
|
||||
const frame = await mountRuntime();
|
||||
const source = "flowchart LR\n A[Start] e1@--> B[End]";
|
||||
|
||||
const result = await render(frame, { revision: 1, source });
|
||||
|
||||
expect(result).toMatchObject({ type: "rendered", revision: 1, source });
|
||||
});
|
||||
|
||||
it("coalesces queued input and never reports an obsolete result", async () => {
|
||||
const frame = await mountRuntime();
|
||||
const obsoleteSource = `flowchart TD\n${Array.from({ length: 250 }, (_, index) => `A${index} --> A${index + 1}`).join("\n")}`;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// @vitest-environment jsdom
|
||||
import type { ReactNode } from "react";
|
||||
import { cleanup, renderHook, waitFor } from "@testing-library/react";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { afterEach, beforeEach, expect, it } from "vitest";
|
||||
import type { FileReadResult } from "@getpaseo/client/internal/daemon-client";
|
||||
import { __setAttachmentStoreForTests } from "@/attachments/store";
|
||||
import type { AttachmentStore } from "@/attachments/types";
|
||||
import { useMarkdownSource, type MarkdownImageContext } from "./images";
|
||||
import { PENDING_MARKDOWN_IMAGE } from "./source";
|
||||
|
||||
const memoryStore: AttachmentStore = {
|
||||
storageType: "web-indexeddb",
|
||||
async save(input) {
|
||||
return {
|
||||
id: input.id ?? "att_chart",
|
||||
mimeType: input.mimeType ?? "image/png",
|
||||
storageType: "web-indexeddb",
|
||||
storageKey: input.id ?? "att_chart",
|
||||
fileName: input.fileName,
|
||||
createdAt: 1,
|
||||
};
|
||||
},
|
||||
async encodeBase64() {
|
||||
return "";
|
||||
},
|
||||
async resolvePreviewUrl() {
|
||||
return "blob:chart";
|
||||
},
|
||||
async releasePreviewUrl() {},
|
||||
async delete() {},
|
||||
async garbageCollect() {},
|
||||
};
|
||||
|
||||
function createHostFiles() {
|
||||
const reads: { cwd: string; path: string }[] = [];
|
||||
return {
|
||||
reads,
|
||||
async readFile(cwd: string, path: string): Promise<FileReadResult> {
|
||||
reads.push({ cwd, path });
|
||||
return {
|
||||
kind: "image",
|
||||
path,
|
||||
mime: "image/png",
|
||||
size: 4,
|
||||
modifiedAt: "2026-11-18T00:00:00.000Z",
|
||||
bytes: new Uint8Array([1, 2, 3, 4]),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
__setAttachmentStoreForTests(memoryStore);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
__setAttachmentStoreForTests(null);
|
||||
});
|
||||
|
||||
function renderMarkdownSource(text: string, initialProps: MarkdownImageContext) {
|
||||
// No retries: a failed read settles at once. For a host's Markdown this is the state once the
|
||||
// retries have run out on a host that is slow to connect.
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
);
|
||||
const rendered = renderHook((props: MarkdownImageContext) => useMarkdownSource(text, props), {
|
||||
wrapper,
|
||||
initialProps,
|
||||
});
|
||||
return { ...rendered, queryClient };
|
||||
}
|
||||
|
||||
it("waits for the host's client before reading a workspace image", async () => {
|
||||
const context = { serverId: "srv_test", workspaceRoot: "/repo" };
|
||||
const { result, rerender, queryClient } = renderMarkdownSource("", {
|
||||
...context,
|
||||
client: null,
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(queryClient.isFetching()).toBe(0);
|
||||
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe(
|
||||
"",
|
||||
);
|
||||
});
|
||||
|
||||
const files = createHostFiles();
|
||||
rerender({ ...context, client: files });
|
||||
|
||||
await waitFor(() => expect(result.current.imageSources).toEqual({ "blob:chart": "chart.png" }));
|
||||
expect(files.reads).toEqual([{ cwd: "/repo", path: "chart.png" }]);
|
||||
});
|
||||
|
||||
it("shows the alt text of a file image in Markdown that belongs to no host", async () => {
|
||||
const { result } = renderMarkdownSource("", {});
|
||||
|
||||
await waitFor(() =>
|
||||
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe("Chart"),
|
||||
);
|
||||
});
|
||||
@@ -81,7 +81,10 @@ export function useMarkdownSource(
|
||||
const results = useFetchQueries(
|
||||
acquisitions.map((acquisition, index) => ({
|
||||
queryKey: ["markdownImage", acquisition?.key ?? sources[index]],
|
||||
enabled: acquisition !== null,
|
||||
// A host that hasn't connected yet has no client. Its images stay pending until it does: the
|
||||
// key doesn't change when the client arrives, so a read that already failed would not run
|
||||
// again. Markdown with no host has no client to wait for and falls back to its alt text.
|
||||
enabled: acquisition !== null && (context.client != null || !context.serverId),
|
||||
immutableWhen: () => true,
|
||||
dataShape: "value",
|
||||
gcTime: 0,
|
||||
|
||||
@@ -11,8 +11,12 @@ import {
|
||||
} from "@/components/attachment-pill";
|
||||
import { MarkdownRenderer } from "@/components/markdown/renderer";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { RewindMenu, type RewindMode } from "@/components/rewind/rewind-menu";
|
||||
import { useRewindAgentMutation } from "@/components/rewind/use-rewind-agent-mutation";
|
||||
import {
|
||||
isRewindableMessage,
|
||||
RewindMenu,
|
||||
useRewindAgentMutation,
|
||||
type RewindMode,
|
||||
} from "@/components/rewind";
|
||||
import { TaskListRow } from "@/components/task-list-row";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
@@ -530,7 +534,7 @@ export const UserMessage = memo(function UserMessage({
|
||||
<Text style={userMessageStylesheet.timestampText} testID="user-message-timestamp">
|
||||
{formattedTimestamp}
|
||||
</Text>
|
||||
{capabilities && messageId ? (
|
||||
{capabilities && isRewindableMessage(messageId, message) ? (
|
||||
<RewindMenu
|
||||
capabilities={capabilities}
|
||||
isPending={rewindMutation.isPending}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Undo2 } from "lucide-react-native";
|
||||
import type { AgentCapabilityFlags } from "@getpaseo/protocol/agent-types";
|
||||
import type { CommandCenterContribution } from "@/command-center/contributions";
|
||||
import { getCommandCenterIcon } from "@/command-center/icon";
|
||||
import { useCommandCenterActions } from "@/command-center/provider";
|
||||
import { hasActiveMessageSubmission } from "@/composer/submission/model";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import type { AgentScreenReadySyncState } from "@/hooks/use-agent-screen-state-machine";
|
||||
import { selectAgentTimelineState, useSessionStore } from "@/stores/session-store";
|
||||
import { useRewindAgentMutation } from "./use-rewind-agent-mutation";
|
||||
import { isRewindableMessage, useRewindMenuItems } from "./use-rewind-capabilities";
|
||||
|
||||
export function RewindCommandCenterRegistration({
|
||||
serverId,
|
||||
agentId,
|
||||
capabilities,
|
||||
timelineSync,
|
||||
enabled,
|
||||
}: {
|
||||
serverId: string;
|
||||
agentId: string;
|
||||
capabilities: AgentCapabilityFlags | null | undefined;
|
||||
timelineSync: AgentScreenReadySyncState | null;
|
||||
enabled: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const canSelectLatestMessage = enabled && timelineSync?.status === "idle";
|
||||
const client = useSessionStore((state) => state.sessions[serverId]?.client);
|
||||
const message = useSessionStore((state) => {
|
||||
const session = state.sessions[serverId];
|
||||
if (
|
||||
!canSelectLatestMessage ||
|
||||
!session ||
|
||||
hasActiveMessageSubmission(session.messageSubmissions.get(agentId))
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
const timeline = selectAgentTimelineState(session, agentId);
|
||||
if (timeline.status !== "synced" || timeline.newer === "available") {
|
||||
return undefined;
|
||||
}
|
||||
return (
|
||||
session.agentStreamHead.get(agentId)?.findLast((item) => item.kind === "user_message") ??
|
||||
timeline.items.findLast((item) => item.kind === "user_message")
|
||||
);
|
||||
});
|
||||
const { rewindAgent, isPending } = useRewindAgentMutation({
|
||||
serverId,
|
||||
agentId,
|
||||
client,
|
||||
messageId: message?.messageId,
|
||||
});
|
||||
const items = useRewindMenuItems(capabilities);
|
||||
const actions = useMemo<CommandCenterContribution[]>(() => {
|
||||
if (!message || !isRewindableMessage(message.messageId, message.text)) return [];
|
||||
return items.map((item, rank) => ({
|
||||
id: `rewind:${item.mode}`,
|
||||
group: "rewind",
|
||||
groupRank: 1.5,
|
||||
rank,
|
||||
visibility: "query",
|
||||
keywords: ["rewind last turn", ...(item.mode === "files" ? [] : ["rewind chat"])],
|
||||
presentation: {
|
||||
kind: "action",
|
||||
title: item.label,
|
||||
subtitle: t("rewind.warning"),
|
||||
icon: getCommandCenterIcon(Undo2),
|
||||
},
|
||||
run: async () => {
|
||||
const dismiss = toast.show(`${item.label}…`, { durationMs: null });
|
||||
try {
|
||||
await rewindAgent({ mode: item.mode, rewoundText: message.text });
|
||||
} catch {
|
||||
// The mutation reports the failure through the app toast.
|
||||
} finally {
|
||||
dismiss();
|
||||
}
|
||||
},
|
||||
}));
|
||||
}, [items, message, rewindAgent, t, toast]);
|
||||
|
||||
useCommandCenterActions({
|
||||
sourceId: `rewind:${serverId}:${agentId}`,
|
||||
enabled: canSelectLatestMessage && Boolean(client) && !isPending,
|
||||
actions,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ interface RewindComposerRestoreContextValue {
|
||||
interface RewindComposerRestoreProviderProps {
|
||||
textSource: ComposerTextSource;
|
||||
setText: (text: string) => void;
|
||||
onRewindComplete: () => void;
|
||||
onRewindComplete: (restoredComposerText: boolean) => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
@@ -37,10 +37,11 @@ export function RewindComposerRestoreProvider({
|
||||
currentText: currentText,
|
||||
rewoundText,
|
||||
});
|
||||
if (nextText !== currentText) {
|
||||
const restoredComposerText = nextText !== currentText;
|
||||
if (restoredComposerText) {
|
||||
setText(nextText);
|
||||
}
|
||||
onRewindComplete();
|
||||
onRewindComplete(restoredComposerText);
|
||||
},
|
||||
[onRewindComplete, setText, textSource],
|
||||
);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export { RewindCommandCenterRegistration } from "./command-center-registration";
|
||||
export { RewindComposerRestoreProvider } from "./composer-restore";
|
||||
export { RewindMenu } from "./rewind-menu";
|
||||
export { useRewindAgentMutation } from "./use-rewind-agent-mutation";
|
||||
export { isRewindableMessage, type RewindMode } from "./use-rewind-capabilities";
|
||||
@@ -11,11 +11,9 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { type RewindMode, useRewindCapabilities } from "./use-rewind-capabilities";
|
||||
import { type RewindMode, useRewindMenuItems } from "./use-rewind-capabilities";
|
||||
import type { AgentCapabilityFlags } from "@getpaseo/protocol/agent-types";
|
||||
|
||||
export type { RewindMode };
|
||||
|
||||
interface RewindMenuProps {
|
||||
capabilities: AgentCapabilityFlags;
|
||||
rewoundText: string;
|
||||
@@ -44,15 +42,7 @@ export const RewindMenu = memo(function RewindMenu({
|
||||
}: RewindMenuProps) {
|
||||
const { theme } = useUnistyles();
|
||||
const { t } = useTranslation();
|
||||
const rewindLabels = useMemo(
|
||||
() => ({
|
||||
conversation: t("rewind.actions.conversation"),
|
||||
files: t("rewind.actions.files"),
|
||||
both: t("rewind.actions.both"),
|
||||
}),
|
||||
[t],
|
||||
);
|
||||
const items = useRewindCapabilities(capabilities, rewindLabels);
|
||||
const items = useRewindMenuItems(capabilities);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [pendingMode, setPendingMode] = useState<RewindMode | null>(null);
|
||||
const isLocked = isPendingProp || pendingMode !== null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { planTimelineTailFetch } from "@/timeline/timeline-sync-plan";
|
||||
import { useCallback } from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useIsMutating, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { RewindMode } from "./use-rewind-capabilities";
|
||||
@@ -29,7 +29,14 @@ export function useRewindAgentMutation(input: UseRewindAgentMutationInput): {
|
||||
const toast = useToast();
|
||||
const { t } = useTranslation();
|
||||
const composerRestore = useRewindComposerRestore();
|
||||
const { isPending, mutateAsync } = useMutation({
|
||||
const queryClient = useQueryClient();
|
||||
const mutationKey = useMemo(
|
||||
() => ["agent-rewind", input.serverId, input.agentId],
|
||||
[input.serverId, input.agentId],
|
||||
);
|
||||
const isPending = useIsMutating({ mutationKey, exact: true }) > 0;
|
||||
const { mutateAsync } = useMutation({
|
||||
mutationKey,
|
||||
mutationFn: async ({ mode }: RewindAgentInput) => {
|
||||
if (!input.client || !input.agentId || !input.messageId) {
|
||||
throw new Error(t("common.errors.daemonClientUnavailable"));
|
||||
@@ -61,12 +68,12 @@ export function useRewindAgentMutation(input: UseRewindAgentMutationInput): {
|
||||
|
||||
const rewindAgent = useCallback(
|
||||
async (rewindInput: RewindAgentInput) => {
|
||||
if (isPending) {
|
||||
if (queryClient.isMutating({ mutationKey, exact: true }) > 0) {
|
||||
return;
|
||||
}
|
||||
await mutateAsync(rewindInput);
|
||||
},
|
||||
[isPending, mutateAsync],
|
||||
[mutateAsync, mutationKey, queryClient],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { AgentCapabilityFlags } from "@getpaseo/protocol/agent-types";
|
||||
|
||||
export type RewindMode = "conversation" | "files" | "both";
|
||||
@@ -21,6 +22,10 @@ const DEFAULT_REWIND_MENU_LABELS: RewindMenuLabels = {
|
||||
both: "Rewind conversation and files",
|
||||
};
|
||||
|
||||
export function isRewindableMessage(messageId: string | undefined, text: string): boolean {
|
||||
return Boolean(messageId) && text.trim().length > 0;
|
||||
}
|
||||
|
||||
export function resolveRewindMenuItems(
|
||||
capabilities:
|
||||
| Pick<
|
||||
@@ -60,9 +65,17 @@ export function resolveRewindMenuItems(
|
||||
return items;
|
||||
}
|
||||
|
||||
export function useRewindCapabilities(
|
||||
export function useRewindMenuItems(
|
||||
capabilities: Parameters<typeof resolveRewindMenuItems>[0],
|
||||
labels?: Partial<RewindMenuLabels>,
|
||||
): RewindMenuItem[] {
|
||||
return useMemo(() => resolveRewindMenuItems(capabilities, labels), [capabilities, labels]);
|
||||
const { t } = useTranslation();
|
||||
return useMemo(
|
||||
() =>
|
||||
resolveRewindMenuItems(capabilities, {
|
||||
conversation: t("rewind.actions.conversation"),
|
||||
files: t("rewind.actions.files"),
|
||||
both: t("rewind.actions.both"),
|
||||
}),
|
||||
[capabilities, t],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import React, { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { ToastViewport, useToastHost, type ToastApi } from "@/components/toast-host";
|
||||
|
||||
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
||||
|
||||
let root: Root | null = null;
|
||||
let container: HTMLDivElement | null = null;
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root?.unmount());
|
||||
container?.remove();
|
||||
root = null;
|
||||
container = null;
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
function mountToastHost(): ToastApi {
|
||||
let api: ToastApi | null = null;
|
||||
function Host() {
|
||||
const host = useToastHost();
|
||||
api = host.api;
|
||||
return <ToastViewport toast={host.toast} onDismiss={host.dismiss} placement="sidebar" />;
|
||||
}
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
act(() =>
|
||||
root?.render(
|
||||
<SafeAreaProvider>
|
||||
<Host />
|
||||
</SafeAreaProvider>,
|
||||
),
|
||||
);
|
||||
if (!api) throw new Error("The toast host did not render");
|
||||
return api;
|
||||
}
|
||||
|
||||
function shownMessage(): string | null {
|
||||
return document.querySelector('[data-testid="app-toast-message"]')?.textContent ?? null;
|
||||
}
|
||||
|
||||
describe("ToastViewport", () => {
|
||||
it("keeps a new toast when the toast it replaced times out before the next render", () => {
|
||||
vi.useFakeTimers();
|
||||
const toast = mountToastHost();
|
||||
act(() => {
|
||||
toast.show("Installed review");
|
||||
});
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(2199);
|
||||
});
|
||||
|
||||
// The new toast is in state, but React has not rendered it, so the old toast's timer is
|
||||
// still scheduled when it expires.
|
||||
act(() => {
|
||||
toast.show("Reloaded review");
|
||||
vi.advanceTimersByTime(1);
|
||||
});
|
||||
|
||||
expect(shownMessage()).toBe("Reloaded review");
|
||||
act(() => {
|
||||
vi.advanceTimersByTime(2199);
|
||||
});
|
||||
expect(shownMessage()).toBe("Reloaded review");
|
||||
});
|
||||
});
|
||||
@@ -53,6 +53,12 @@ export interface ToastState {
|
||||
/** Dismisses the toast it was returned for; a no-op once another toast replaced it. */
|
||||
export type DismissToast = () => void;
|
||||
|
||||
/**
|
||||
* Dismisses the toast with this ID, and does nothing once another toast replaced it. Without an
|
||||
* ID, it dismisses whichever toast is shown.
|
||||
*/
|
||||
export type DismissToastById = (id?: number) => void;
|
||||
|
||||
export interface ToastApi {
|
||||
show: (content: ReactNode, options?: ToastShowOptions) => DismissToast;
|
||||
copied: (label?: string) => void;
|
||||
@@ -81,7 +87,7 @@ const errorIcon = (theme: Theme) => ({ color: theme.colors.destructive });
|
||||
export function useToastHost(): {
|
||||
api: ToastApi;
|
||||
toast: ToastState | null;
|
||||
dismiss: () => void;
|
||||
dismiss: DismissToastById;
|
||||
} {
|
||||
const { t } = useTranslation();
|
||||
const [toast, setToastState] = useState<ToastState | null>(null);
|
||||
@@ -96,6 +102,13 @@ export function useToastHost(): {
|
||||
previous?.onDismiss?.();
|
||||
}, []);
|
||||
|
||||
const dismiss = useCallback<DismissToastById>(
|
||||
(id) => {
|
||||
if (id === undefined || toastRef.current?.id === id) setToast(null);
|
||||
},
|
||||
[setToast],
|
||||
);
|
||||
|
||||
const show = useCallback(
|
||||
(content: ReactNode, options?: ToastShowOptions): DismissToast => {
|
||||
const nativeMessage = typeof content === "string" ? content.trim() : null;
|
||||
@@ -127,11 +140,9 @@ export function useToastHost(): {
|
||||
testID: options?.testID,
|
||||
onDismiss: options?.onDismiss,
|
||||
});
|
||||
return () => {
|
||||
if (toastRef.current?.id === id) setToast(null);
|
||||
};
|
||||
return () => dismiss(id);
|
||||
},
|
||||
[setToast],
|
||||
[dismiss, setToast],
|
||||
);
|
||||
|
||||
const api = useMemo<ToastApi>(
|
||||
@@ -147,10 +158,6 @@ export function useToastHost(): {
|
||||
[show, t],
|
||||
);
|
||||
|
||||
const dismiss = useCallback(() => {
|
||||
setToast(null);
|
||||
}, [setToast]);
|
||||
|
||||
return { api, toast, dismiss };
|
||||
}
|
||||
|
||||
@@ -161,7 +168,8 @@ export function ToastViewport({
|
||||
onBottomCoverageChange,
|
||||
}: {
|
||||
toast: ToastState | null;
|
||||
onDismiss: () => void;
|
||||
/** Called with the ID of the toast that timed out. */
|
||||
onDismiss: (id: number) => void;
|
||||
placement?: ToastViewportPlacement;
|
||||
/** Sidebar placement: reports the distance from the region's bottom edge to the toast's top. */
|
||||
onBottomCoverageChange?: (coverage: number) => void;
|
||||
@@ -180,7 +188,7 @@ export function ToastViewport({
|
||||
}, []);
|
||||
|
||||
const scheduleDismiss = useCallback(
|
||||
(durationMs: number | null) => {
|
||||
(id: number, durationMs: number | null) => {
|
||||
clearTimer();
|
||||
if (durationMs === null) {
|
||||
remainingDurationRef.current = 0;
|
||||
@@ -190,8 +198,10 @@ export function ToastViewport({
|
||||
const nextDurationMs = Math.max(0, durationMs);
|
||||
remainingDurationRef.current = nextDurationMs;
|
||||
dismissDeadlineRef.current = Date.now() + nextDurationMs;
|
||||
// A replacing toast is in the host before this viewport renders it and reschedules, so the
|
||||
// timer names its own toast rather than dismissing whichever one is current.
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
onDismiss();
|
||||
onDismiss(id);
|
||||
}, nextDurationMs);
|
||||
},
|
||||
[onDismiss, clearTimer],
|
||||
@@ -209,13 +219,14 @@ export function ToastViewport({
|
||||
if (!toast || toast.durationMs === null) {
|
||||
return;
|
||||
}
|
||||
scheduleDismiss(remainingDurationRef.current || toast.durationMs);
|
||||
scheduleDismiss(toast.id, remainingDurationRef.current || toast.durationMs);
|
||||
}, [scheduleDismiss, toast]);
|
||||
|
||||
const toastId = toast?.id;
|
||||
const durationMs = toast?.durationMs ?? null;
|
||||
useEffect(() => {
|
||||
scheduleDismiss(durationMs);
|
||||
if (toastId === undefined) return;
|
||||
scheduleDismiss(toastId, durationMs);
|
||||
return clearTimer;
|
||||
}, [clearTimer, durationMs, scheduleDismiss, toastId]);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { highlightDiffLines } from "@/utils/diff-highlight";
|
||||
import { hasMeaningfulToolCallDetail } from "@/utils/tool-call-detail-state";
|
||||
import { inlineUnistylesStyle } from "@/styles/unistyles-inline-style";
|
||||
import { CODE_SURFACE_DATASET } from "@/styles/code-surface";
|
||||
import { extensionFromPath, highlightToKeyedLines } from "@/utils/highlight-cache";
|
||||
import { highlightToKeyedLines } from "@/utils/highlight-cache";
|
||||
import { HighlightedLines } from "./highlighted-content";
|
||||
import { DiffViewer } from "./diff-viewer";
|
||||
import { getCodeInsets } from "./code-insets";
|
||||
@@ -226,7 +226,7 @@ function ScrollableTextSection({
|
||||
startLine,
|
||||
}: ScrollableContentProps) {
|
||||
const keyedLines = useMemo(
|
||||
() => (filePath ? highlightToKeyedLines(content, extensionFromPath(filePath)) : null),
|
||||
() => highlightToKeyedLines(content, filePath ?? null),
|
||||
[content, filePath],
|
||||
);
|
||||
const body = (
|
||||
|
||||
@@ -82,10 +82,10 @@ describe("ComposerControls", () => {
|
||||
expect(trigger.textContent).not.toContain("Large");
|
||||
});
|
||||
|
||||
it("flips a toggle on press in the toolbar", () => {
|
||||
it("keeps the toolbar toggle name and flips it on press", () => {
|
||||
const onChange = vi.fn();
|
||||
renderControls([{ ...base, type: "toggle", value: true, onChange }]);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Context" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Context$/ }));
|
||||
expect(onChange).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
@@ -94,6 +94,12 @@ describe("ComposerControls", () => {
|
||||
expect(screen.getByRole("button", { name: "Context" }).textContent).toContain("On");
|
||||
});
|
||||
|
||||
it("keeps the provider's tooltip for a toolbar toggle", () => {
|
||||
const tooltip = "Fast is enabled but does not apply to this model.";
|
||||
renderControls([{ ...base, type: "toggle", value: true, tooltip, onChange: () => undefined }]);
|
||||
expect(screen.getByRole("button", { name: tooltip })).toBeDefined();
|
||||
});
|
||||
|
||||
it("gives a sheet row's value the row's width, so a short value is not truncated", () => {
|
||||
const toast = createToast();
|
||||
render(
|
||||
@@ -157,6 +163,8 @@ describe("ComposerControls", () => {
|
||||
});
|
||||
|
||||
const FAST_ON = { fast_mode: true };
|
||||
const ULTRACODE_ON = { ultracode: true };
|
||||
const ignoreOption = () => undefined;
|
||||
|
||||
describe("provider option controls", () => {
|
||||
const fastMode: AgentOptionControl = {
|
||||
@@ -173,7 +181,11 @@ describe("provider option controls", () => {
|
||||
onSetOption: (key: string, value: unknown) => void;
|
||||
}) {
|
||||
const optionControls = React.useMemo(
|
||||
() => ({ controls: [fastMode], options, onSetOption }),
|
||||
() => ({
|
||||
controls: [fastMode, { key: "ultracode", label: "Ultracode", type: "toggle" as const }],
|
||||
options,
|
||||
onSetOption,
|
||||
}),
|
||||
[onSetOption, options],
|
||||
);
|
||||
const items = useAgentControlItems({
|
||||
@@ -197,4 +209,9 @@ describe("provider option controls", () => {
|
||||
fireEvent.click(screen.getByTestId("agent-feature-fast_mode"));
|
||||
expect(writes).toEqual([["fast_mode", false]]);
|
||||
});
|
||||
|
||||
it("announces the state of a provider toggle with no custom tooltip", () => {
|
||||
render(<OptionControls options={ULTRACODE_ON} onSetOption={ignoreOption} />);
|
||||
expect(screen.getByRole("button", { name: "Ultracode: On" })).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,6 +21,8 @@ import { ICON_SIZE } from "@/styles/theme";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { AgentControlTrigger } from "@/composer/agent-controls/control";
|
||||
import { useToast } from "@/contexts/toast-api-context";
|
||||
import { Shortcut } from "@/components/ui/shortcut";
|
||||
import type { ShortcutKey } from "@/utils/format-shortcut";
|
||||
import { toErrorMessage } from "@/utils/error-messages";
|
||||
|
||||
interface ComposerControlBase {
|
||||
@@ -28,7 +30,7 @@ interface ComposerControlBase {
|
||||
title: string;
|
||||
icon: AgentControlIcon;
|
||||
/** Tints the icon; muted when absent. */
|
||||
highlight?: "blue" | "green" | "yellow";
|
||||
highlight?: "blue" | "green" | "purple" | "yellow";
|
||||
/** Defaults to the title, or to "title: choice" on an icon-only select. */
|
||||
tooltip?: string;
|
||||
/** Defaults to the tooltip. */
|
||||
@@ -106,6 +108,7 @@ interface ComposerControlProps {
|
||||
disabled?: boolean;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
shortcutKeys?: ShortcutKey[][] | null;
|
||||
/** Runs after a toolbar toggle or action, so the composer can take focus back. */
|
||||
onActionComplete?: () => void;
|
||||
}
|
||||
@@ -217,6 +220,7 @@ export function ComposerControl({
|
||||
open,
|
||||
onOpenChange,
|
||||
onActionComplete,
|
||||
shortcutKeys,
|
||||
}: ComposerControlProps) {
|
||||
const { t } = useTranslation();
|
||||
const anchorRef = useRef<View>(null);
|
||||
@@ -279,7 +283,7 @@ export function ComposerControl({
|
||||
{trigger}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" align="center" offset={8}>
|
||||
<Text style={styles.tooltipText}>{view.tooltip}</Text>
|
||||
<ControlTooltipHint label={view.tooltip} shortcutKeys={shortcutKeys} />
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
@@ -349,6 +353,7 @@ interface ComposerControlsProps {
|
||||
items: readonly ComposerControlItem[];
|
||||
surface: ComposerControlSurface;
|
||||
disabled?: boolean;
|
||||
shortcutKeys?: ShortcutKey[][] | null;
|
||||
/** The id of the item whose list is open. */
|
||||
openId: string | null;
|
||||
onOpenIdChange: (id: string | null) => void;
|
||||
@@ -390,9 +395,30 @@ function ComposerControlSlot({
|
||||
return <ComposerControl item={item} open={open} onOpenChange={handleOpenChange} {...rest} />;
|
||||
}
|
||||
|
||||
export function ControlTooltipHint({
|
||||
label,
|
||||
shortcutKeys,
|
||||
}: {
|
||||
label: string;
|
||||
shortcutKeys?: ShortcutKey[][] | null;
|
||||
}) {
|
||||
return (
|
||||
<View style={styles.tooltipRow}>
|
||||
<Text style={styles.tooltipText}>{label}</Text>
|
||||
{shortcutKeys ? <Shortcut chord={shortcutKeys} /> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
tooltipRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
fieldIcon: { color: theme.colors.foregroundMuted },
|
||||
blue: { color: theme.colors.palette.blue[400] },
|
||||
purple: { color: theme.colors.palette.purple[500] },
|
||||
green: { color: theme.colors.palette.green[400] },
|
||||
yellow: { color: theme.colors.palette.yellow[400] },
|
||||
tooltipText: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useMemo } from "react";
|
||||
import { useId, useMemo } from "react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DensityIcon } from "@/components/ui/density-icon";
|
||||
@@ -19,6 +19,12 @@ import {
|
||||
import type { ComposerControlPresentation } from "@/composer/agent-controls/layout";
|
||||
import { getAgentControlHintKey, getFeatureHighlightColor } from "@/composer/agent-controls/utils";
|
||||
|
||||
import { useKeyboardActionHandler } from "@/hooks/use-keyboard-action-handler";
|
||||
import { useShortcutKeys } from "@/hooks/use-shortcut-keys";
|
||||
import { useComposerInput } from "@/composer/session";
|
||||
import { useComposerKeyboardScope } from "@/composer/keyboard-scope";
|
||||
import { resolveNextChoiceId } from "./mode";
|
||||
|
||||
const SEARCH_THRESHOLD = 6;
|
||||
|
||||
function getFeatureHighlight(
|
||||
@@ -33,6 +39,8 @@ function getFeatureHighlight(
|
||||
function toFeatureItem(
|
||||
control: AgentOptionControl,
|
||||
optionControls: ComposerOptionControls,
|
||||
surface: ComposerControlSurface,
|
||||
t: TFunction,
|
||||
): ComposerControlItem {
|
||||
const { options, onSetOption } = optionControls;
|
||||
const base = {
|
||||
@@ -43,11 +51,15 @@ function toFeatureItem(
|
||||
testID: `agent-feature-${control.key}`,
|
||||
};
|
||||
if (control.type === "toggle") {
|
||||
const enabled = readToggleOption(control, options);
|
||||
const stateLabel = enabled ? t("agentControls.features.on") : t("agentControls.features.off");
|
||||
return {
|
||||
...base,
|
||||
type: "toggle",
|
||||
tooltip: getControlTooltip(control),
|
||||
value: readToggleOption(control, options),
|
||||
tooltip:
|
||||
control.tooltip ??
|
||||
(surface === "toolbar" ? `${control.label}: ${stateLabel}` : control.label),
|
||||
value: enabled,
|
||||
onChange: (value) => onSetOption(control.key, value),
|
||||
};
|
||||
}
|
||||
@@ -71,6 +83,41 @@ interface ThinkingControl {
|
||||
displayLabel: string;
|
||||
}
|
||||
|
||||
export function useModelPickerShortcut(disabled: boolean) {
|
||||
const { isActiveComposer } = useComposerKeyboardScope();
|
||||
const input = useComposerInput();
|
||||
const action =
|
||||
isActiveComposer && !disabled && input
|
||||
? {
|
||||
id: "message-input.model-toggle" as const,
|
||||
canOpen: input.isFocused,
|
||||
}
|
||||
: undefined;
|
||||
const keys = useShortcutKeys(action ? "toggle-model-picker" : null);
|
||||
return { action, keys };
|
||||
}
|
||||
|
||||
export function useEffortCycleShortcut(thinking: ThinkingControl | null, disabled: boolean) {
|
||||
const { isActiveComposer } = useComposerKeyboardScope();
|
||||
const input = useComposerInput();
|
||||
const effortHandlerId = useId();
|
||||
const nextEffortId = resolveNextChoiceId(thinking?.options ?? [], thinking?.selectedId);
|
||||
const canCycleEffort = isActiveComposer && !disabled && nextEffortId !== null && input !== null;
|
||||
useKeyboardActionHandler({
|
||||
handlerId: effortHandlerId,
|
||||
actions: ["message-input.effort-cycle"],
|
||||
enabled: canCycleEffort,
|
||||
isActive: input?.isFocused,
|
||||
priority: 200,
|
||||
handle: () => {
|
||||
if (!thinking || nextEffortId === null) return false;
|
||||
thinking.onSelect(nextEffortId);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
return useShortcutKeys(canCycleEffort ? "cycle-effort" : null);
|
||||
}
|
||||
|
||||
/** The thinking select and the option controls, as the data `ComposerControl` draws. */
|
||||
export function useAgentControlItems({
|
||||
surface,
|
||||
@@ -92,9 +139,11 @@ export function useAgentControlItems({
|
||||
const features = useMemo(
|
||||
() =>
|
||||
optionControls
|
||||
? optionControls.controls.map((control) => toFeatureItem(control, optionControls))
|
||||
? optionControls.controls.map((control) =>
|
||||
toFeatureItem(control, optionControls, surface, t),
|
||||
)
|
||||
: [],
|
||||
[optionControls],
|
||||
[optionControls, surface, t],
|
||||
);
|
||||
return { thinking: thinkingItem, features };
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useTranslation } from "react-i18next";
|
||||
import { router } from "expo-router";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
Pressable,
|
||||
Keyboard,
|
||||
useWindowDimensions,
|
||||
@@ -62,6 +61,7 @@ import {
|
||||
useAgentControlCommandCenterActions,
|
||||
type AgentControlCommandCenterSource,
|
||||
} from "@/command-center/agent-control-registration";
|
||||
import { useShortcutKeys } from "@/hooks/use-shortcut-keys";
|
||||
import { useComposerKeyboardScope } from "@/composer/keyboard-scope";
|
||||
import {
|
||||
composerToolbarGeometry,
|
||||
@@ -74,9 +74,14 @@ import { ComposerControlLayoutProvider } from "@/composer/agent-controls/layout-
|
||||
import { ComposerToolbarGlyph } from "@/composer/agent-controls/glyph";
|
||||
import {
|
||||
ComposerControls,
|
||||
ControlTooltipHint,
|
||||
type ComposerControlItem,
|
||||
} from "@/composer/agent-controls/composer-control";
|
||||
import { useAgentControlItems } from "@/composer/agent-controls/control-items";
|
||||
import {
|
||||
useAgentControlItems,
|
||||
useEffortCycleShortcut,
|
||||
useModelPickerShortcut,
|
||||
} from "@/composer/agent-controls/control-items";
|
||||
import { CompactModelSheet } from "@/composer/agent-controls/model-sheet";
|
||||
import { useComposerSheetBridge } from "@/composer/agent-controls/sheet-bridge";
|
||||
import { draftComposerAgent } from "@/composer/draft/composer-agent";
|
||||
@@ -143,6 +148,7 @@ export interface DraftAgentControlsProps {
|
||||
onSelectMode: (modeId: string) => void;
|
||||
models: AgentModelDefinition[];
|
||||
selectedModel: string;
|
||||
effectiveModelId: string;
|
||||
onSelectModel: (modelId: string) => void;
|
||||
isModelLoading: boolean;
|
||||
modelSelectorProviders: ProviderSelectorProvider[];
|
||||
@@ -173,6 +179,7 @@ export interface DraftAgentControlsProps {
|
||||
}
|
||||
|
||||
interface AgentControlsProps {
|
||||
showToolbar: boolean;
|
||||
agentId: string;
|
||||
serverId: string;
|
||||
onDropdownClose?: () => void;
|
||||
@@ -188,10 +195,10 @@ function AgentControlCommandCenterRegistration({
|
||||
enabled: boolean;
|
||||
controls: AgentControlCommandCenterSource;
|
||||
}) {
|
||||
const { isActiveComposer } = useComposerKeyboardScope();
|
||||
const { isCommandCenterTarget } = useComposerKeyboardScope();
|
||||
useAgentControlCommandCenterActions({
|
||||
sourceId,
|
||||
enabled: enabled && isActiveComposer,
|
||||
enabled: enabled && isCommandCenterTarget,
|
||||
controls,
|
||||
});
|
||||
return null;
|
||||
@@ -583,6 +590,7 @@ function ControlledAgentControls({
|
||||
selectedThinkingOptionId,
|
||||
],
|
||||
);
|
||||
const effortKeys = useEffortCycleShortcut(thinking, disabled);
|
||||
const items = useAgentControlItems({
|
||||
surface: presentation.foldControls ? "sheet" : "toolbar",
|
||||
presentation,
|
||||
@@ -645,6 +653,7 @@ function ControlledAgentControls({
|
||||
provider={provider}
|
||||
selectedModelId={selectedModelId}
|
||||
thinkingItems={items.thinking}
|
||||
effortKeys={effortKeys}
|
||||
featureItems={items.features}
|
||||
onApplyAgentProfile={onApplyAgentProfile}
|
||||
onEditAgentProfiles={onEditAgentProfiles}
|
||||
@@ -677,6 +686,7 @@ function ControlledAgentControls({
|
||||
provider={provider}
|
||||
selectedModelId={selectedModelId}
|
||||
thinkingItems={items.thinking}
|
||||
effortKeys={effortKeys}
|
||||
featureItems={items.features}
|
||||
onApplyAgentProfile={onApplyAgentProfile}
|
||||
onEditAgentProfiles={onEditAgentProfiles}
|
||||
@@ -719,6 +729,7 @@ interface AgentControlsContentProps {
|
||||
provider: string;
|
||||
selectedModelId?: string;
|
||||
thinkingItems: ComposerControlItem[];
|
||||
effortKeys: ReturnType<typeof useShortcutKeys>;
|
||||
featureItems: ComposerControlItem[];
|
||||
onApplyAgentProfile?: (profileId: string) => void;
|
||||
onEditAgentProfiles?: () => void;
|
||||
@@ -758,6 +769,7 @@ function DesktopAgentControlsContent(props: DesktopAgentControlsContentProps) {
|
||||
provider,
|
||||
selectedModelId,
|
||||
thinkingItems,
|
||||
effortKeys,
|
||||
featureItems,
|
||||
onApplyAgentProfile,
|
||||
onEditAgentProfiles,
|
||||
@@ -785,6 +797,7 @@ function DesktopAgentControlsContent(props: DesktopAgentControlsContentProps) {
|
||||
handleCloseSheet,
|
||||
modelSelectorServerId,
|
||||
} = props;
|
||||
const { action: toggleAction, keys: modelKeys } = useModelPickerShortcut(disabled);
|
||||
const modelToolbar = useMemo(
|
||||
() => ({ glyph: glyphs.label, showCaret: presentation.showCarets }),
|
||||
[glyphs, presentation.showCarets],
|
||||
@@ -813,6 +826,7 @@ function DesktopAgentControlsContent(props: DesktopAgentControlsContentProps) {
|
||||
onEditProfile={onEditAgentProfile}
|
||||
isLoading={isModelLoading}
|
||||
disabled={disabled}
|
||||
toggleAction={toggleAction}
|
||||
onOpen={onModelSelectorOpen}
|
||||
onClose={onDropdownClose}
|
||||
onRetryProvider={onRetryModelProvider}
|
||||
@@ -825,13 +839,17 @@ function DesktopAgentControlsContent(props: DesktopAgentControlsContentProps) {
|
||||
</View>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" align="center" offset={8}>
|
||||
<Text style={styles.tooltipText}>{t(getAgentControlHintKey("model"))}</Text>
|
||||
<ControlTooltipHint
|
||||
label={t(getAgentControlHintKey("model"))}
|
||||
shortcutKeys={modelKeys}
|
||||
/>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
|
||||
<ComposerControls
|
||||
items={thinkingItems}
|
||||
shortcutKeys={effortKeys}
|
||||
surface="toolbar"
|
||||
disabled={disabled}
|
||||
openId={openSelector}
|
||||
@@ -902,6 +920,7 @@ function SheetAgentControlsContent(props: SheetAgentControlsContentProps) {
|
||||
provider,
|
||||
selectedModelId,
|
||||
thinkingItems,
|
||||
effortKeys,
|
||||
featureItems,
|
||||
onApplyAgentProfile,
|
||||
onEditAgentProfiles,
|
||||
@@ -956,6 +975,7 @@ function SheetAgentControlsContent(props: SheetAgentControlsContentProps) {
|
||||
selectedProvider={provider}
|
||||
selectedModel={selectedModelId ?? ""}
|
||||
thinkingLabel={displayThinking}
|
||||
effortKeys={effortKeys}
|
||||
onSelect={handleSheetModelSelect}
|
||||
profiles={agentProfiles}
|
||||
onApplyProfile={onApplyAgentProfile}
|
||||
@@ -992,6 +1012,7 @@ function useAgentOptionControls(
|
||||
}
|
||||
|
||||
export const AgentControls = memo(function AgentControls({
|
||||
showToolbar,
|
||||
agentId,
|
||||
serverId,
|
||||
onDropdownClose,
|
||||
@@ -1251,37 +1272,44 @@ export const AgentControls = memo(function AgentControls({
|
||||
return (
|
||||
<ComposerModelProvider value={composer}>
|
||||
{commandCenterRegistration}
|
||||
{profileEditor.element}
|
||||
<ControlledAgentControls
|
||||
provider={agent.provider}
|
||||
modelSelectorProviders={agentModelSelectorProviders}
|
||||
modelOptions={modelOptions}
|
||||
selectedModelId={modelSelection.activeModelId ?? undefined}
|
||||
onSelectModel={handleSelectModel}
|
||||
agentProfiles={agentProfiles}
|
||||
onApplyAgentProfile={agentProfiles?.applyProfile}
|
||||
onEditAgentProfiles={handleEditAgentProfiles}
|
||||
onCreateAgentProfile={profileActions.create}
|
||||
onEditAgentProfile={profileActions.edit}
|
||||
thinkingOptions={thinkingOptions.length > 0 ? thinkingOptions : undefined}
|
||||
selectedThinkingOptionId={modelSelection.selectedThinkingId ?? undefined}
|
||||
onSelectThinkingOption={handleSelectThinkingOption}
|
||||
optionControls={agentOptionControls}
|
||||
isModelLoading={snapshotIsLoading || selectedProviderIsLoading}
|
||||
onModelSelectorOpen={handleModelSelectorOpen}
|
||||
onRetryModelProvider={handleRetryModelProvider}
|
||||
isRetryingModelProvider={snapshotIsRefreshing}
|
||||
onDropdownClose={onDropdownClose}
|
||||
disabled={!client}
|
||||
modeControl={modeControl}
|
||||
modelSelectorServerId={serverId}
|
||||
isCompactLayout={isCompactLayout}
|
||||
/>
|
||||
{showToolbar ? (
|
||||
<>
|
||||
{profileEditor.element}
|
||||
<ControlledAgentControls
|
||||
provider={agent.provider}
|
||||
modelSelectorProviders={agentModelSelectorProviders}
|
||||
modelOptions={modelOptions}
|
||||
selectedModelId={modelSelection.activeModelId ?? undefined}
|
||||
onSelectModel={handleSelectModel}
|
||||
agentProfiles={agentProfiles}
|
||||
onApplyAgentProfile={agentProfiles?.applyProfile}
|
||||
onEditAgentProfiles={handleEditAgentProfiles}
|
||||
onCreateAgentProfile={profileActions.create}
|
||||
onEditAgentProfile={profileActions.edit}
|
||||
thinkingOptions={thinkingOptions.length > 0 ? thinkingOptions : undefined}
|
||||
selectedThinkingOptionId={modelSelection.selectedThinkingId ?? undefined}
|
||||
onSelectThinkingOption={handleSelectThinkingOption}
|
||||
optionControls={agentOptionControls}
|
||||
isModelLoading={snapshotIsLoading || selectedProviderIsLoading}
|
||||
onModelSelectorOpen={handleModelSelectorOpen}
|
||||
onRetryModelProvider={handleRetryModelProvider}
|
||||
isRetryingModelProvider={snapshotIsRefreshing}
|
||||
onDropdownClose={onDropdownClose}
|
||||
disabled={!client}
|
||||
modeControl={modeControl}
|
||||
modelSelectorServerId={serverId}
|
||||
isCompactLayout={isCompactLayout}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</ComposerModelProvider>
|
||||
);
|
||||
});
|
||||
|
||||
export function DraftAgentControls({
|
||||
showToolbar,
|
||||
draftId,
|
||||
serverId,
|
||||
providerDefinitions,
|
||||
selectedProvider,
|
||||
modeOptions,
|
||||
@@ -1289,6 +1317,7 @@ export function DraftAgentControls({
|
||||
onSelectMode,
|
||||
models,
|
||||
selectedModel,
|
||||
effectiveModelId,
|
||||
onSelectModel,
|
||||
isModelLoading: _isModelLoading,
|
||||
modelSelectorProviders,
|
||||
@@ -1311,13 +1340,12 @@ export function DraftAgentControls({
|
||||
context = "draft",
|
||||
metadata,
|
||||
onSetMetadata,
|
||||
}: DraftAgentControlsProps) {
|
||||
}: DraftAgentControlsProps & { draftId: string; serverId: string; showToolbar: boolean }) {
|
||||
const mappedThinkingOptions = useMemo<AgentControlOption[]>(() => {
|
||||
return toThinkingControlOptions(thinkingOptions);
|
||||
}, [thinkingOptions]);
|
||||
|
||||
const effectiveSelectedThinkingOption =
|
||||
selectedThinkingOptionId || mappedThinkingOptions[0]?.id || undefined;
|
||||
const effectiveSelectedThinkingOption = selectedThinkingOptionId || mappedThinkingOptions[0]?.id;
|
||||
|
||||
const modelOptions = useMemo<AgentControlOption[]>(
|
||||
() =>
|
||||
@@ -1420,36 +1448,83 @@ export function DraftAgentControls({
|
||||
[composerAgent, composerInput],
|
||||
);
|
||||
|
||||
const commandCenterControls = useMemo<AgentControlCommandCenterSource>(
|
||||
() => ({
|
||||
serverId,
|
||||
ownerKey: draftId,
|
||||
provider: selectedProvider,
|
||||
providerDefinitions,
|
||||
models: {
|
||||
providers: modelSelectorProviders,
|
||||
selectedProvider,
|
||||
selectedModelId: effectiveModelId,
|
||||
select: (provider, modelId) => {
|
||||
onSelectProviderAndModel(provider, modelId);
|
||||
},
|
||||
},
|
||||
thinking: {
|
||||
options: thinkingOptions,
|
||||
selectedId: selectedThinkingOptionId,
|
||||
select: onSelectThinkingOption,
|
||||
},
|
||||
modes: toCommandCenterModes(modeControl),
|
||||
optionControls: optionControls ?? null,
|
||||
}),
|
||||
[
|
||||
serverId,
|
||||
draftId,
|
||||
selectedProvider,
|
||||
providerDefinitions,
|
||||
modelSelectorProviders,
|
||||
effectiveModelId,
|
||||
onSelectProviderAndModel,
|
||||
thinkingOptions,
|
||||
selectedThinkingOptionId,
|
||||
onSelectThinkingOption,
|
||||
modeControl,
|
||||
optionControls,
|
||||
],
|
||||
);
|
||||
|
||||
return (
|
||||
<ComposerAgentProvider value={composerAgent}>
|
||||
<ComposerModelProvider value={composerModel}>
|
||||
{profileEditor.element}
|
||||
<ControlledAgentControls
|
||||
provider={selectedProvider ?? ""}
|
||||
modelSelectorProviders={modelSelectorProviders}
|
||||
modelOptions={modelOptions}
|
||||
selectedModelId={selectedModel}
|
||||
onSelectModel={onSelectModel}
|
||||
onSelectProviderAndModel={onSelectProviderAndModel}
|
||||
isModelLoading={isAllModelsLoading}
|
||||
agentProfiles={agentProfiles}
|
||||
onApplyAgentProfile={agentProfiles?.applyProfile}
|
||||
onEditAgentProfiles={handleEditAgentProfiles}
|
||||
onCreateAgentProfile={profileActions.create}
|
||||
onEditAgentProfile={profileActions.edit}
|
||||
thinkingOptions={mappedThinkingOptions.length > 0 ? mappedThinkingOptions : undefined}
|
||||
selectedThinkingOptionId={effectiveSelectedThinkingOption}
|
||||
onSelectThinkingOption={onSelectThinkingOption}
|
||||
optionControls={optionControls}
|
||||
onDropdownClose={onDropdownClose}
|
||||
onModelSelectorOpen={onModelSelectorOpen}
|
||||
onRetryModelProvider={onRetryModelProvider}
|
||||
isRetryingModelProvider={isRetryingModelProvider}
|
||||
disabled={disabled}
|
||||
modeControl={modeControl}
|
||||
modelSelectorServerId={modelSelectorServerId}
|
||||
isCompactLayout={isCompactLayout}
|
||||
<AgentControlCommandCenterRegistration
|
||||
sourceId={`draft:${serverId}:${draftId}`}
|
||||
enabled={!disabled}
|
||||
controls={commandCenterControls}
|
||||
/>
|
||||
{showToolbar ? (
|
||||
<>
|
||||
{profileEditor.element}
|
||||
<ControlledAgentControls
|
||||
provider={selectedProvider ?? ""}
|
||||
modelSelectorProviders={modelSelectorProviders}
|
||||
modelOptions={modelOptions}
|
||||
selectedModelId={selectedModel}
|
||||
onSelectModel={onSelectModel}
|
||||
onSelectProviderAndModel={onSelectProviderAndModel}
|
||||
isModelLoading={isAllModelsLoading}
|
||||
agentProfiles={agentProfiles}
|
||||
onApplyAgentProfile={agentProfiles?.applyProfile}
|
||||
onEditAgentProfiles={handleEditAgentProfiles}
|
||||
onCreateAgentProfile={profileActions.create}
|
||||
onEditAgentProfile={profileActions.edit}
|
||||
thinkingOptions={mappedThinkingOptions.length > 0 ? mappedThinkingOptions : undefined}
|
||||
selectedThinkingOptionId={effectiveSelectedThinkingOption}
|
||||
onSelectThinkingOption={onSelectThinkingOption}
|
||||
optionControls={optionControls}
|
||||
onDropdownClose={onDropdownClose}
|
||||
onModelSelectorOpen={onModelSelectorOpen}
|
||||
onRetryModelProvider={onRetryModelProvider}
|
||||
isRetryingModelProvider={isRetryingModelProvider}
|
||||
disabled={disabled}
|
||||
modeControl={modeControl}
|
||||
modelSelectorServerId={modelSelectorServerId}
|
||||
isCompactLayout={isCompactLayout}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
</ComposerModelProvider>
|
||||
</ComposerAgentProvider>
|
||||
);
|
||||
@@ -1479,11 +1554,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
backgroundColor: "transparent",
|
||||
borderRadius: theme.borderRadius.full,
|
||||
},
|
||||
tooltipText: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
lineHeight: theme.fontSize.base * 1.4,
|
||||
},
|
||||
combinedSheetControls: {
|
||||
gap: theme.spacing[1],
|
||||
},
|
||||
|
||||
@@ -25,6 +25,7 @@ describe("resolveAgentControlsMode", () => {
|
||||
onSelectMode: () => undefined,
|
||||
models: [],
|
||||
selectedModel: "",
|
||||
effectiveModelId: "",
|
||||
onSelectModel: () => true,
|
||||
isModelLoading: false,
|
||||
modelSelectorProviders: [],
|
||||
|
||||
@@ -8,12 +8,18 @@ export function resolveNextAgentModeId({
|
||||
modeOptions: readonly AgentMode[];
|
||||
selectedMode: string | null | undefined;
|
||||
}): string | null {
|
||||
if (modeOptions.length < 2) return null;
|
||||
return resolveNextChoiceId(modeOptions, selectedMode);
|
||||
}
|
||||
|
||||
const selectedIndex = modeOptions.findIndex((mode) => mode.id === selectedMode);
|
||||
export function resolveNextChoiceId(
|
||||
options: readonly { id: string }[],
|
||||
selectedId: string | null | undefined,
|
||||
): string | null {
|
||||
if (options.length < 2) return null;
|
||||
|
||||
const selectedIndex = options.findIndex((option) => option.id === selectedId);
|
||||
const currentIndex = selectedIndex >= 0 ? selectedIndex : 0;
|
||||
const nextIndex = (currentIndex + 1) % modeOptions.length;
|
||||
return modeOptions[nextIndex]?.id ?? null;
|
||||
return options[(currentIndex + 1) % options.length].id;
|
||||
}
|
||||
|
||||
export function resolveAgentControlsMode(agentControls?: DraftAgentControlsProps) {
|
||||
|
||||
@@ -31,7 +31,12 @@ import {
|
||||
toolbarSlot,
|
||||
type ToolbarGlyphs,
|
||||
} from "@/components/ui/control-geometry";
|
||||
import { shortModelLabel } from "./utils";
|
||||
import { getAgentControlHintKey, shortModelLabel } from "./utils";
|
||||
import { useShortcutKeys } from "@/hooks/use-shortcut-keys";
|
||||
import { useKeyboardToggle } from "@/hooks/use-keyboard-toggle";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { ControlTooltipHint } from "./composer-control";
|
||||
import { useModelPickerShortcut } from "./control-items";
|
||||
|
||||
const SNAP_POINTS = ["80%", "90%"];
|
||||
const MODEL_LIST_TOP_INSET = 4;
|
||||
@@ -45,6 +50,7 @@ interface CompactModelSheetProps {
|
||||
selectedProvider: string;
|
||||
selectedModel: string;
|
||||
thinkingLabel: string | null;
|
||||
effortKeys: ReturnType<typeof useShortcutKeys>;
|
||||
onSelect: (provider: string, modelId: string) => void;
|
||||
isLoading: boolean;
|
||||
profiles?: AgentProfilePicker | null;
|
||||
@@ -133,6 +139,7 @@ export function CompactModelSheet({
|
||||
selectedProvider,
|
||||
selectedModel,
|
||||
thinkingLabel,
|
||||
effortKeys,
|
||||
onSelect,
|
||||
isLoading,
|
||||
profiles = null,
|
||||
@@ -316,11 +323,13 @@ export function CompactModelSheet({
|
||||
glyphs={glyphs}
|
||||
iconOnly={!showLabels && hasSelectedProvider}
|
||||
isOpen={isOpen}
|
||||
searchFocused={rootBrowser.isSearchFocused || modelBrowser.isSearchFocused}
|
||||
disabled={disabled}
|
||||
onPress={toggle}
|
||||
accessibilityLabel={t("modelSelector.selectedModel", {
|
||||
model: rootBrowser.selectedModelLabel,
|
||||
})}
|
||||
effortKeys={effortKeys}
|
||||
/>
|
||||
|
||||
<AdaptiveModalSheet
|
||||
@@ -409,17 +418,7 @@ export function CompactModelSheet({
|
||||
* The folded model control in the toolbar: the provider glyph, then the model and thinking
|
||||
* labels for as long as they fit.
|
||||
*/
|
||||
function ModelSheetTrigger({
|
||||
ModelIcon,
|
||||
modelLabel,
|
||||
thinkingLabel,
|
||||
glyphs,
|
||||
iconOnly,
|
||||
isOpen,
|
||||
disabled,
|
||||
onPress,
|
||||
accessibilityLabel,
|
||||
}: {
|
||||
interface ModelSheetTriggerProps {
|
||||
/** The selected provider's glyph, or null before a provider is selected. */
|
||||
ModelIcon: ReturnType<typeof useProviderIcon> | null;
|
||||
modelLabel: string;
|
||||
@@ -427,10 +426,36 @@ function ModelSheetTrigger({
|
||||
glyphs: ToolbarGlyphs;
|
||||
iconOnly: boolean;
|
||||
isOpen: boolean;
|
||||
searchFocused: boolean;
|
||||
disabled: boolean;
|
||||
onPress: () => void;
|
||||
accessibilityLabel: string;
|
||||
}) {
|
||||
effortKeys: ReturnType<typeof useShortcutKeys>;
|
||||
}
|
||||
|
||||
function ModelSheetTrigger({
|
||||
ModelIcon,
|
||||
modelLabel,
|
||||
thinkingLabel,
|
||||
glyphs,
|
||||
iconOnly,
|
||||
isOpen,
|
||||
searchFocused,
|
||||
disabled,
|
||||
onPress,
|
||||
accessibilityLabel,
|
||||
effortKeys,
|
||||
}: ModelSheetTriggerProps) {
|
||||
const { t } = useTranslation();
|
||||
const { action: toggleAction, keys: modelKeys } = useModelPickerShortcut(disabled);
|
||||
useKeyboardToggle({
|
||||
action: toggleAction,
|
||||
disabled,
|
||||
open: isOpen,
|
||||
searchFocused,
|
||||
onToggle: onPress,
|
||||
});
|
||||
|
||||
const glyphRole = iconOnly ? "icon" : "label";
|
||||
const glyph = glyphs[glyphRole];
|
||||
const triggerLabels = useModelTriggerLabels({
|
||||
@@ -451,7 +476,7 @@ function ModelSheetTrigger({
|
||||
[disabled, iconOnly, isOpen],
|
||||
);
|
||||
|
||||
return (
|
||||
const trigger = (
|
||||
<View style={styles.triggerFrame} onLayout={triggerLabels.onFrameLayout}>
|
||||
<ComboboxTrigger
|
||||
collapsable={false}
|
||||
@@ -521,6 +546,23 @@ function ModelSheetTrigger({
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip delayDuration={0} enabledOnDesktop enabledOnMobile={false}>
|
||||
<TooltipTrigger asChild triggerRefProp="ref">
|
||||
{trigger}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" align="center" offset={8}>
|
||||
<ControlTooltipHint label={t(getAgentControlHintKey("model"))} shortcutKeys={modelKeys} />
|
||||
{effortKeys ? (
|
||||
<ControlTooltipHint
|
||||
label={t("settings.shortcuts.help.cycleEffort")}
|
||||
shortcutKeys={effortKeys}
|
||||
/>
|
||||
) : null}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
|
||||
@@ -20,6 +20,7 @@ describe("feature metadata helpers", () => {
|
||||
expect(getFeatureHighlightColor("fast_mode")).toBe("yellow");
|
||||
expect(getFeatureHighlightColor("service_tier")).toBe("yellow");
|
||||
expect(getFeatureHighlightColor("plan_mode")).toBe("blue");
|
||||
expect(getFeatureHighlightColor("ultracode")).toBe("purple");
|
||||
expect(getFeatureHighlightColor("other")).toBe("default");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "@/agent-controls/policy";
|
||||
|
||||
export type ExplainedAgentControl = "mode" | "model" | "thinking";
|
||||
export type FeatureHighlightColor = "blue" | "default" | "green" | "yellow";
|
||||
export type FeatureHighlightColor = "blue" | "default" | "green" | "purple" | "yellow";
|
||||
export type AgentControlHintKey =
|
||||
| "agentControls.hints.thinking"
|
||||
| "agentControls.hints.model"
|
||||
@@ -48,6 +48,8 @@ export function getFeatureHighlightColor(featureId: string): FeatureHighlightCol
|
||||
return "yellow";
|
||||
case "auto_accept":
|
||||
return "green";
|
||||
case "ultracode":
|
||||
return "purple";
|
||||
case PLAN_MODE_FEATURE_ID:
|
||||
return "blue";
|
||||
default:
|
||||
|
||||
@@ -21,6 +21,7 @@ export function resolveDraftKey(input: {
|
||||
|
||||
export function buildDraftAgentControls(input: {
|
||||
formState: UseAgentFormStateResult;
|
||||
effectiveModelId: string;
|
||||
optionControls?: DraftAgentControlsProps["optionControls"];
|
||||
options: DraftAgentControlsProps["options"];
|
||||
onSetOption: DraftAgentControlsProps["onSetOption"];
|
||||
@@ -49,6 +50,7 @@ export function buildDraftAgentControls(input: {
|
||||
onSelectMode: formState.setModeFromUser,
|
||||
models: formState.availableModels,
|
||||
selectedModel: formState.selectedModel,
|
||||
effectiveModelId: input.effectiveModelId,
|
||||
onSelectModel: formState.setModelFromUser,
|
||||
isModelLoading: formState.isModelLoading,
|
||||
modelSelectorProviders: formState.modelSelectorProviders,
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
resolveEffectiveComposerThinkingOptionId,
|
||||
type ProviderSelectionState,
|
||||
} from "@/provider-selection/provider-selection";
|
||||
import { findThinkingOptionReplacement } from "@/provider-selection/resolve-agent-form";
|
||||
import { useDraftStore, type DraftInput } from "@/stores/draft-store";
|
||||
import { AfterPaintPublication } from "@/composer/after-paint-publication";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
@@ -293,6 +294,7 @@ export function useAgentInputDraft(input: UseAgentInputDraftInput): AgentInputDr
|
||||
options: draftOptions,
|
||||
shownOptions: draftShownOptions,
|
||||
setOption: setDraftOption,
|
||||
retainLegacyUltracode,
|
||||
applyProfile: applyProfileOptions,
|
||||
} = useDraftProviderOptions({
|
||||
serverId: formState.selectedServerId,
|
||||
@@ -312,6 +314,11 @@ export function useAgentInputDraft(input: UseAgentInputDraftInput): AgentInputDr
|
||||
},
|
||||
[applyProfileOptions, formState],
|
||||
);
|
||||
const setDraftThinking = useCallback(
|
||||
(thinkingOptionId: string) =>
|
||||
formState.setThinkingOptionFromUser(thinkingOptionId, retainLegacyUltracode()),
|
||||
[formState, retainLegacyUltracode],
|
||||
);
|
||||
|
||||
const commandDraft = useMemo(
|
||||
() =>
|
||||
@@ -330,8 +337,18 @@ export function useAgentInputDraft(input: UseAgentInputDraftInput): AgentInputDr
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
// COMPAT(claudeUltracodePreference): added in v0.17.0, remove after 2027-05-18.
|
||||
const draftForm = {
|
||||
...formState,
|
||||
selectedThinkingOptionId:
|
||||
findThinkingOptionReplacement(
|
||||
formState.availableThinkingOptions,
|
||||
formState.selectedThinkingOptionId,
|
||||
) ?? formState.selectedThinkingOptionId,
|
||||
setThinkingOptionFromUser: setDraftThinking,
|
||||
};
|
||||
return {
|
||||
...draftForm,
|
||||
workingDir,
|
||||
effectiveModeId,
|
||||
effectiveModelId,
|
||||
@@ -339,7 +356,8 @@ export function useAgentInputDraft(input: UseAgentInputDraftInput): AgentInputDr
|
||||
providerOptions: draftOptions,
|
||||
metadata,
|
||||
agentControls: buildDraftAgentControls({
|
||||
formState,
|
||||
formState: draftForm,
|
||||
effectiveModelId,
|
||||
optionControls: draftOptionControls,
|
||||
options: draftShownOptions,
|
||||
onSetOption: setDraftOption,
|
||||
@@ -360,6 +378,7 @@ export function useAgentInputDraft(input: UseAgentInputDraftInput): AgentInputDr
|
||||
draftOptions,
|
||||
draftShownOptions,
|
||||
setDraftOption,
|
||||
setDraftThinking,
|
||||
applyDraftAgentProfile,
|
||||
formState,
|
||||
metadata,
|
||||
|
||||
@@ -21,7 +21,6 @@ import { useCreateFlowStore } from "@/stores/create-flow-store";
|
||||
import type { Agent } from "@/stores/session-store";
|
||||
import { useWorkspaceFields } from "@/stores/session-store-hooks";
|
||||
import { useWorkspaceDraftSubmissionStore } from "@/stores/workspace-draft-submission-store";
|
||||
import { useAgentControlCommandCenterActions } from "@/command-center/agent-control-registration";
|
||||
import { encodeImages } from "@/utils/encode-images";
|
||||
import { shouldAutoFocusWorkspaceDraftComposer } from "@/screens/workspace/workspace-draft-pane-focus";
|
||||
import {
|
||||
@@ -330,16 +329,6 @@ export function WorkspaceDraftComposer({
|
||||
throw new Error("Workspace draft composer state is required");
|
||||
}
|
||||
|
||||
const draftProvider = composerState.selectedProvider;
|
||||
const draftProviderDefinitions = composerState.providerDefinitions;
|
||||
const draftThinkingOptions = composerState.availableThinkingOptions;
|
||||
const draftSelectedThinkingId = composerState.selectedThinkingOptionId;
|
||||
const draftSetThinkingOption = composerState.setThinkingOptionFromUser;
|
||||
const draftModeOptions = composerState.modeOptions;
|
||||
const draftSelectedMode = composerState.selectedMode;
|
||||
const draftSetMode = composerState.setModeFromUser;
|
||||
const draftOptionControls = composerState.agentControls.optionControls;
|
||||
|
||||
const clearDraftInput = draftInput.clear;
|
||||
const replaceDraftText = draftInput.replaceText;
|
||||
const setDraftAttachments = draftInput.setAttachments;
|
||||
@@ -471,35 +460,6 @@ export function WorkspaceDraftComposer({
|
||||
onCreated(result);
|
||||
},
|
||||
});
|
||||
useAgentControlCommandCenterActions({
|
||||
sourceId: `draft:${serverId}:${tabId}`,
|
||||
enabled: isPaneFocused && !isSubmitting,
|
||||
controls: {
|
||||
serverId,
|
||||
ownerKey: tabId,
|
||||
provider: draftProvider,
|
||||
providerDefinitions: draftProviderDefinitions,
|
||||
models: {
|
||||
providers: composerState.modelSelectorProviders,
|
||||
selectedProvider: draftProvider,
|
||||
selectedModelId: composerState.effectiveModelId,
|
||||
select: (provider, modelId) => {
|
||||
composerState.setProviderAndModelFromUser(provider, modelId);
|
||||
},
|
||||
},
|
||||
thinking: {
|
||||
options: draftThinkingOptions,
|
||||
selectedId: draftSelectedThinkingId,
|
||||
select: draftSetThinkingOption,
|
||||
},
|
||||
modes: {
|
||||
options: draftModeOptions,
|
||||
selectedId: draftSelectedMode,
|
||||
select: draftSetMode,
|
||||
},
|
||||
optionControls: draftOptionControls ?? null,
|
||||
},
|
||||
});
|
||||
const isReadyForPendingAutoSubmit = Boolean(
|
||||
pendingAutoSubmit &&
|
||||
draftInput.isHydrated &&
|
||||
|
||||
@@ -45,6 +45,9 @@ export class ComposerEditingSession {
|
||||
if (this.editor === editor) this.editor = null;
|
||||
};
|
||||
}
|
||||
focus() {
|
||||
this.editor?.focus();
|
||||
}
|
||||
insertCommand(command: string) {
|
||||
const editor = this.editor;
|
||||
if (!editor) return;
|
||||
|
||||
@@ -313,13 +313,22 @@ interface RenderLeftContentArgs {
|
||||
focusInput: () => void;
|
||||
isCompactLayout: boolean;
|
||||
showAgentControls: boolean;
|
||||
showToolbar: boolean;
|
||||
}
|
||||
|
||||
function renderLeftContent(args: RenderLeftContentArgs): ReactElement | null {
|
||||
const { agentControls, agentId, serverId, focusInput, isCompactLayout } = args;
|
||||
const { agentControls, agentId, serverId, focusInput, isCompactLayout, showToolbar } = args;
|
||||
if (!args.showAgentControls) return null;
|
||||
if (resolveAgentControlsMode(agentControls) === "draft" && agentControls) {
|
||||
return <DraftAgentControls {...agentControls} isCompactLayout={isCompactLayout} />;
|
||||
return (
|
||||
<DraftAgentControls
|
||||
{...agentControls}
|
||||
draftId={agentId}
|
||||
serverId={serverId}
|
||||
isCompactLayout={isCompactLayout}
|
||||
showToolbar={showToolbar}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<AgentControls
|
||||
@@ -327,6 +336,7 @@ function renderLeftContent(args: RenderLeftContentArgs): ReactElement | null {
|
||||
serverId={serverId}
|
||||
onDropdownClose={focusInput}
|
||||
isCompactLayout={isCompactLayout}
|
||||
showToolbar={showToolbar}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1243,14 +1253,17 @@ export function Composer({ isPaneFocused, ...props }: ComposerProps) {
|
||||
// user's own pane: closing the panel does not bring focus back.
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const paneHost = usePaneHost();
|
||||
const overlayPanelRequested = usePanelStore((state) =>
|
||||
isMobilePanelCoveringHost(state.mobilePanel.target, paneHost),
|
||||
);
|
||||
const coveredByOverlayPanel = isCompact && overlayPanelRequested;
|
||||
const mobilePanelTarget = usePanelStore((state) => state.mobilePanel.target);
|
||||
const coveredByOverlayPanel = isCompact && isMobilePanelCoveringHost(mobilePanelTarget, paneHost);
|
||||
// Search from the sidebar uses the center pane as its context.
|
||||
const commandCenterPanel = mobilePanelTarget === "agent-list" ? "agent" : mobilePanelTarget;
|
||||
const coveredForCommandCenter =
|
||||
isCompact && isMobilePanelCoveringHost(commandCenterPanel, paneHost);
|
||||
return (
|
||||
<ComposerKeyboardScopeProvider
|
||||
isPaneFocused={isPaneFocused}
|
||||
isActiveComposer={isPaneFocused && !coveredByOverlayPanel}
|
||||
isCommandCenterTarget={isPaneFocused && !coveredForCommandCenter}
|
||||
>
|
||||
<OverlayDismissalScope>
|
||||
<RenderProfile id="ComposerContent">
|
||||
@@ -1514,6 +1527,7 @@ function ComposerContentImpl({
|
||||
isLive: isInputLive,
|
||||
revealed: inputRevealed,
|
||||
isRevealed: isInputRevealed,
|
||||
isFocused: () => messageInputRef.current?.isFocused() ?? false,
|
||||
focus: takeInputFocus,
|
||||
textSource,
|
||||
setText: replaceUserInput,
|
||||
@@ -2345,6 +2359,7 @@ function ComposerContentImpl({
|
||||
focusInput,
|
||||
isCompactLayout,
|
||||
showAgentControls: mode.showAgentControls,
|
||||
showToolbar: !isFullscreen,
|
||||
});
|
||||
return controls ? (
|
||||
<ComposerInputProvider value={composerInput}>{controls}</ComposerInputProvider>
|
||||
@@ -2355,6 +2370,7 @@ function ComposerContentImpl({
|
||||
composerInput,
|
||||
focusInput,
|
||||
isCompactLayout,
|
||||
isFullscreen,
|
||||
mode.showAgentControls,
|
||||
serverId,
|
||||
]);
|
||||
|
||||
@@ -2224,42 +2224,47 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
|
||||
);
|
||||
const toolbar = useMemo(
|
||||
() => (
|
||||
<View style={buttonRowStyle}>
|
||||
<View style={isFullscreen ? styles.hiddenToolbar : buttonRowStyle}>
|
||||
{/* Toolbar left: attachment button + agent controls */}
|
||||
<View style={styles.leftButtonGroup}>
|
||||
<AttachmentDropdown
|
||||
visible={mode.showAttachments}
|
||||
isConnected={isConnected}
|
||||
disabled={disabled}
|
||||
attachButtonStyle={attachButtonStyle}
|
||||
renderAttachButtonIcon={renderAttachButtonIcon}
|
||||
attachmentMenuItems={attachmentMenuItems}
|
||||
addAttachmentLabel={t("composer.input.addAttachment")}
|
||||
/>
|
||||
{!isFullscreen && (
|
||||
<AttachmentDropdown
|
||||
visible={mode.showAttachments}
|
||||
isConnected={isConnected}
|
||||
disabled={disabled}
|
||||
attachButtonStyle={attachButtonStyle}
|
||||
renderAttachButtonIcon={renderAttachButtonIcon}
|
||||
attachmentMenuItems={attachmentMenuItems}
|
||||
addAttachmentLabel={t("composer.input.addAttachment")}
|
||||
/>
|
||||
)}
|
||||
{leftContent}
|
||||
</View>
|
||||
|
||||
{/* Right: dictation, then the trailing action (voice mode, send or stop) */}
|
||||
<View style={styles.rightButtonGroup}>
|
||||
{beforeVoiceContent}
|
||||
<VoiceButtonTooltip
|
||||
visible={mode.showVoice}
|
||||
onVoicePress={handleVoicePress}
|
||||
isDictationStartEnabled={isDictationStartEnabled}
|
||||
voiceButtonAccessibilityLabel={voiceButtonAccessibilityLabel}
|
||||
voiceButtonStyle={voiceButtonStyle}
|
||||
renderVoiceButtonIcon={renderVoiceButtonIcon}
|
||||
voiceTooltipText={voiceTooltipText}
|
||||
isRealtimeVoiceForCurrentAgent={isRealtimeVoiceForCurrentAgent}
|
||||
voiceMuteToggleKeys={voiceMuteToggleKeys}
|
||||
dictationToggleKeys={dictationToggleKeys}
|
||||
/>
|
||||
<View style={styles.trailingDisc}>{sendButton}</View>
|
||||
</View>
|
||||
{!isFullscreen && (
|
||||
<View style={styles.rightButtonGroup}>
|
||||
{beforeVoiceContent}
|
||||
<VoiceButtonTooltip
|
||||
visible={mode.showVoice}
|
||||
onVoicePress={handleVoicePress}
|
||||
isDictationStartEnabled={isDictationStartEnabled}
|
||||
voiceButtonAccessibilityLabel={voiceButtonAccessibilityLabel}
|
||||
voiceButtonStyle={voiceButtonStyle}
|
||||
renderVoiceButtonIcon={renderVoiceButtonIcon}
|
||||
voiceTooltipText={voiceTooltipText}
|
||||
isRealtimeVoiceForCurrentAgent={isRealtimeVoiceForCurrentAgent}
|
||||
voiceMuteToggleKeys={voiceMuteToggleKeys}
|
||||
dictationToggleKeys={dictationToggleKeys}
|
||||
/>
|
||||
<View style={styles.trailingDisc}>{sendButton}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
),
|
||||
[
|
||||
buttonRowStyle,
|
||||
isFullscreen,
|
||||
mode.showAttachments,
|
||||
isConnected,
|
||||
disabled,
|
||||
@@ -2463,6 +2468,7 @@ const styles = StyleSheet.create((theme: Theme) => ({
|
||||
minHeight: MIN_INPUT_HEIGHT,
|
||||
color: theme.colors.foregroundMuted,
|
||||
},
|
||||
hiddenToolbar: { display: "none" },
|
||||
// The row keeps a full touch target's height; its disc-sized controls centre in it.
|
||||
buttonRow: {
|
||||
minHeight: TOOLBAR_CONTROL_HEIGHT,
|
||||
|
||||
@@ -126,7 +126,8 @@ export function ComposerInputPresentation({
|
||||
</Button>
|
||||
) : null}
|
||||
</View>
|
||||
{fullscreen ? null : toolbar}
|
||||
{/* Keep the agent controls mounted for composer commands in fullscreen. */}
|
||||
{toolbar}
|
||||
</View>
|
||||
</ComposerFullscreenBody>
|
||||
{fullscreen ? (
|
||||
|
||||
@@ -18,21 +18,25 @@ interface ComposerKeyboardScopeValue {
|
||||
* pane, which does not take pane focus.
|
||||
*/
|
||||
isActiveComposer: boolean;
|
||||
/** The composer whose settings appear in Command Center. */
|
||||
isCommandCenterTarget: boolean;
|
||||
}
|
||||
|
||||
const ComposerKeyboardScopeContext = createContext<ComposerKeyboardScopeValue>({
|
||||
isPaneFocused: false,
|
||||
isActiveComposer: false,
|
||||
isCommandCenterTarget: false,
|
||||
});
|
||||
|
||||
export function ComposerKeyboardScopeProvider({
|
||||
isPaneFocused,
|
||||
isActiveComposer,
|
||||
isCommandCenterTarget,
|
||||
children,
|
||||
}: PropsWithChildren<ComposerKeyboardScopeValue>): ReactElement {
|
||||
const value = useMemo(
|
||||
() => ({ isPaneFocused, isActiveComposer }),
|
||||
[isPaneFocused, isActiveComposer],
|
||||
() => ({ isPaneFocused, isActiveComposer, isCommandCenterTarget }),
|
||||
[isPaneFocused, isActiveComposer, isCommandCenterTarget],
|
||||
);
|
||||
return (
|
||||
<ComposerKeyboardScopeContext.Provider value={value}>
|
||||
|
||||
@@ -25,6 +25,7 @@ export interface ComposerInput {
|
||||
*/
|
||||
revealed: boolean;
|
||||
isRevealed: () => boolean;
|
||||
isFocused: () => boolean;
|
||||
focus: (options?: ComposerFocusOptions) => Promise<void>;
|
||||
textSource: ComposerTextSource;
|
||||
setText: (text: string) => void;
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
AgentMode,
|
||||
AgentModelDefinition,
|
||||
AgentProvider,
|
||||
ProviderOptions,
|
||||
ProviderSnapshotEntry,
|
||||
} from "@getpaseo/protocol/agent-types";
|
||||
import { buildProviderDefinitions } from "@/utils/provider-definitions";
|
||||
@@ -58,7 +59,7 @@ export interface UseAgentFormStateResult {
|
||||
selectedModel: string;
|
||||
setModelFromUser: (modelId: string) => void;
|
||||
selectedThinkingOptionId: string;
|
||||
setThinkingOptionFromUser: (thinkingOptionId: string) => void;
|
||||
setThinkingOptionFromUser: (thinkingOptionId: string, retainedOptions?: ProviderOptions) => void;
|
||||
workingDir: string;
|
||||
providerDefinitions: AgentProviderDefinition[];
|
||||
providerDefinitionMap: Map<AgentProvider, AgentProviderDefinition>;
|
||||
@@ -419,7 +420,7 @@ export function useAgentFormState(options: UseAgentFormStateOptions): UseAgentFo
|
||||
);
|
||||
|
||||
const setThinkingOptionFromUser = useCallback(
|
||||
(thinkingOptionId: string) => {
|
||||
(thinkingOptionId: string, retainedOptions?: ProviderOptions) => {
|
||||
dispatch({ type: "SET_THINKING_OPTION_FROM_USER", thinkingOptionId });
|
||||
const { provider, model: modelId } = formStore.getState().form;
|
||||
if (provider && modelId) {
|
||||
@@ -431,6 +432,7 @@ export function useAgentFormState(options: UseAgentFormStateOptions): UseAgentFo
|
||||
thinkingByModel: {
|
||||
[modelId]: thinkingOptionId,
|
||||
},
|
||||
options: retainedOptions,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -69,6 +69,14 @@ export function useDraftProviderOptions(input: {
|
||||
[draftConfig, serverId],
|
||||
);
|
||||
const requestKey = JSON.stringify(queryKey);
|
||||
// COMPAT(claudeUltracodePreference): added in v0.17.0, remove after 2027-05-18.
|
||||
const retainLegacyUltracode = useCallback(
|
||||
() =>
|
||||
thinkingOptionId === "ultracode"
|
||||
? model.retainResolvedOption("ultracode", requestKey)
|
||||
: undefined,
|
||||
[model, requestKey, thinkingOptionId],
|
||||
);
|
||||
|
||||
const { data } = useFetchQuery({
|
||||
queryKey,
|
||||
@@ -129,6 +137,7 @@ export function useDraftProviderOptions(input: {
|
||||
options: ownOptions,
|
||||
shownOptions,
|
||||
setOption,
|
||||
retainLegacyUltracode,
|
||||
applyProfile: model.applyProfile,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { useId } from "react";
|
||||
import { hasFocusedTextInput } from "@/keyboard";
|
||||
import type { KeyboardActionId } from "@/keyboard/keyboard-action-dispatcher";
|
||||
import { useKeyboardActionHandler } from "@/hooks/use-keyboard-action-handler";
|
||||
|
||||
export interface KeyboardToggleAction {
|
||||
id: KeyboardActionId;
|
||||
canOpen: () => boolean;
|
||||
}
|
||||
|
||||
/** Lets a trigger share its toggle with a keyboard action. */
|
||||
export function useKeyboardToggle({
|
||||
action,
|
||||
disabled,
|
||||
open,
|
||||
searchFocused,
|
||||
onToggle,
|
||||
}: {
|
||||
action: KeyboardToggleAction | undefined;
|
||||
disabled: boolean;
|
||||
open: boolean;
|
||||
searchFocused: boolean;
|
||||
onToggle: () => void;
|
||||
}) {
|
||||
const handlerId = useId();
|
||||
useKeyboardActionHandler({
|
||||
handlerId,
|
||||
actions: action ? [action.id] : [],
|
||||
enabled: action !== undefined && !disabled,
|
||||
priority: 200,
|
||||
isActive: () =>
|
||||
action?.canOpen() === true || (open && (searchFocused || !hasFocusedTextInput())),
|
||||
handle: () => {
|
||||
onToggle();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -2750,6 +2750,8 @@ export const ar: TranslationResources = {
|
||||
toggleFocusMode: "تبديل وضع التركيز",
|
||||
cycleTheme: "موضوع الدورة",
|
||||
focusMessageInput: "التركيز على إدخال الرسالة",
|
||||
toggleModelPicker: "فتح منتقي النموذج أو إغلاقه",
|
||||
cycleEffort: "التنقل بين مستويات الجهد",
|
||||
cycleAgentMode: "تبديل وضع الوكيل",
|
||||
toggleVoiceMode: "تبديل الوضع الصوتي",
|
||||
startStopDictation: "بدء إملاء /stop",
|
||||
|
||||
@@ -2844,6 +2844,8 @@ export const en = {
|
||||
toggleFocusMode: "Toggle focus mode",
|
||||
cycleTheme: "Cycle theme",
|
||||
focusMessageInput: "Focus message input",
|
||||
toggleModelPicker: "Toggle model picker",
|
||||
cycleEffort: "Cycle effort",
|
||||
cycleAgentMode: "Cycle agent mode",
|
||||
toggleVoiceMode: "Toggle voice mode",
|
||||
startStopDictation: "Start/stop dictation",
|
||||
|
||||
@@ -2773,6 +2773,8 @@ export const es: TranslationResources = {
|
||||
toggleFocusMode: "Alternar modo de enfoque",
|
||||
cycleTheme: "Tema del ciclo",
|
||||
focusMessageInput: "Entrada de mensaje de enfoque",
|
||||
toggleModelPicker: "Abrir o cerrar el selector de modelos",
|
||||
cycleEffort: "Alternar el nivel de esfuerzo",
|
||||
cycleAgentMode: "Alternar modo del agente",
|
||||
toggleVoiceMode: "Alternar modo de voz",
|
||||
startStopDictation: "Iniciar dictado/stop",
|
||||
|
||||
@@ -2775,6 +2775,8 @@ export const fr: TranslationResources = {
|
||||
toggleFocusMode: "Activer/désactiver le mode focus",
|
||||
cycleTheme: "Parcourir les thèmes",
|
||||
focusMessageInput: "Aller à la zone de saisie",
|
||||
toggleModelPicker: "Ouvrir ou fermer le sélecteur de modèle",
|
||||
cycleEffort: "Parcourir les niveaux d’effort",
|
||||
cycleAgentMode: "Parcourir les modes de l’agent",
|
||||
toggleVoiceMode: "Activer/désactiver le mode vocal",
|
||||
startStopDictation: "Démarrer/arrêter la dictée",
|
||||
|
||||
@@ -2739,6 +2739,8 @@ export const ja: TranslationResources = {
|
||||
toggleFocusMode: "フォーカスモードを切り替え",
|
||||
cycleTheme: "テーマを順に切り替え",
|
||||
focusMessageInput: "メッセージ入力にフォーカス",
|
||||
toggleModelPicker: "モデル選択を開く/閉じる",
|
||||
cycleEffort: "推論の強度を順に切り替え",
|
||||
cycleAgentMode: "エージェントモードを順に切り替え",
|
||||
toggleVoiceMode: "音声モードを切り替え",
|
||||
startStopDictation: "音声入力を開始/停止",
|
||||
|
||||
@@ -2728,6 +2728,8 @@ export const ko: TranslationResources = {
|
||||
toggleFocusMode: "집중 모드 토글",
|
||||
cycleTheme: "테마 순환",
|
||||
focusMessageInput: "메시지 입력란에 포커스",
|
||||
toggleModelPicker: "모델 선택기 열기 또는 닫기",
|
||||
cycleEffort: "추론 강도 순환",
|
||||
cycleAgentMode: "에이전트 모드 전환",
|
||||
toggleVoiceMode: "음성 모드 토글",
|
||||
startStopDictation: "받아쓰기 시작/중지",
|
||||
|
||||
@@ -2753,6 +2753,8 @@ export const ptBR: TranslationResources = {
|
||||
toggleFocusMode: "Alternar modo de foco",
|
||||
cycleTheme: "Alternar tema",
|
||||
focusMessageInput: "Focar entrada de mensagem",
|
||||
toggleModelPicker: "Abrir ou fechar o seletor de modelos",
|
||||
cycleEffort: "Alternar o nível de esforço",
|
||||
cycleAgentMode: "Alternar modo do agente",
|
||||
toggleVoiceMode: "Alternar modo de voz",
|
||||
startStopDictation: "Iniciar/parar ditado",
|
||||
|
||||
@@ -2761,6 +2761,8 @@ export const ru: TranslationResources = {
|
||||
toggleFocusMode: "Переключить режим фокусировки",
|
||||
cycleTheme: "Переключить тему",
|
||||
focusMessageInput: "Перейти к полю ввода сообщения",
|
||||
toggleModelPicker: "Открыть или закрыть выбор модели",
|
||||
cycleEffort: "Переключить уровень усилий",
|
||||
cycleAgentMode: "Переключить режим агента",
|
||||
toggleVoiceMode: "Переключить голосовой режим",
|
||||
startStopDictation: "Начать/остановить диктовку",
|
||||
|
||||
@@ -2684,6 +2684,8 @@ export const zhCN: TranslationResources = {
|
||||
toggleFocusMode: "切换专注模式",
|
||||
cycleTheme: "循环切换主题",
|
||||
focusMessageInput: "聚焦消息输入框",
|
||||
toggleModelPicker: "打开或关闭模型选择器",
|
||||
cycleEffort: "循环切换推理强度",
|
||||
cycleAgentMode: "循环切换代理模式",
|
||||
toggleVoiceMode: "切换语音模式",
|
||||
startStopDictation: "开始/停止听写",
|
||||
|
||||
@@ -14,7 +14,9 @@ export type MessageInputKeyboardActionKind =
|
||||
| "dictation-confirm"
|
||||
| "voice-toggle"
|
||||
| "voice-mute-toggle"
|
||||
| "mode-cycle";
|
||||
| "mode-cycle"
|
||||
| "model-toggle"
|
||||
| "effort-cycle";
|
||||
|
||||
export type KeyboardActionId =
|
||||
| "agent.interrupt"
|
||||
|
||||
@@ -7,6 +7,7 @@ export {
|
||||
getTopOverlayLayer,
|
||||
subscribeOverlays,
|
||||
} from "./internal/overlay-dispatch";
|
||||
export { hasFocusedTextInput } from "./internal/focused-text-input";
|
||||
export { useKeyboardFocusSurface } from "./internal/use-focus-surface";
|
||||
export { subscribeHardwareKeyboard } from "./internal/sources/hardware";
|
||||
export type { HardwareKeyboardEvent } from "./internal/sources/hardware";
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { resolveKeyboardFocusScope } from "../focus-scope";
|
||||
|
||||
export function hasFocusedTextInput(): boolean {
|
||||
return false;
|
||||
const scope = resolveKeyboardFocusScope({ target: null, commandCenterOpen: false });
|
||||
return scope === "editable" || scope === "message-input";
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ export type KeyboardActionId =
|
||||
| "message-input.voice-toggle"
|
||||
| "message-input.voice-mute-toggle"
|
||||
| "message-input.mode-cycle"
|
||||
| "message-input.model-toggle"
|
||||
| "message-input.effort-cycle"
|
||||
| "workspace.agent.new"
|
||||
| "workspace.tab.menu.open"
|
||||
| "workspace.tab.target.agent"
|
||||
@@ -67,6 +69,8 @@ export type KeyboardActionDefinition =
|
||||
| { id: "message-input.voice-toggle"; scope: KeyboardActionScope }
|
||||
| { id: "message-input.voice-mute-toggle"; scope: KeyboardActionScope }
|
||||
| { id: "message-input.mode-cycle"; scope: KeyboardActionScope }
|
||||
| { id: "message-input.model-toggle"; scope: KeyboardActionScope }
|
||||
| { id: "message-input.effort-cycle"; scope: KeyboardActionScope }
|
||||
| { id: "workspace.agent.new"; scope: KeyboardActionScope }
|
||||
| { id: "workspace.tab.menu.open"; scope: KeyboardActionScope }
|
||||
| { id: "workspace.tab.target.agent"; scope: KeyboardActionScope }
|
||||
|
||||
@@ -337,6 +337,27 @@ describe("keyboard-shortcuts", () => {
|
||||
action: "message-input.action",
|
||||
payload: { kind: "dictation-toggle" },
|
||||
},
|
||||
{
|
||||
name: "toggles the model picker from the composer",
|
||||
event: { key: "/", code: "Slash", metaKey: true },
|
||||
context: { isMac: true, focusScope: "message-input" },
|
||||
action: "message-input.action",
|
||||
payload: { kind: "model-toggle" },
|
||||
},
|
||||
{
|
||||
name: "toggles the model picker while its search field has focus",
|
||||
event: { key: "/", code: "Slash", metaKey: true },
|
||||
context: { isMac: true, focusScope: "editable" },
|
||||
action: "message-input.action",
|
||||
payload: { kind: "model-toggle" },
|
||||
},
|
||||
{
|
||||
name: "cycles effort with the shifted slash character",
|
||||
event: { key: "?", code: "Slash", metaKey: true, shiftKey: true },
|
||||
context: { isMac: true, focusScope: "message-input" },
|
||||
action: "message-input.action",
|
||||
payload: { kind: "effort-cycle" },
|
||||
},
|
||||
{
|
||||
name: "routes Shift+Tab to cycle agent mode from the message input",
|
||||
event: { key: "Tab", code: "Tab", shiftKey: true },
|
||||
@@ -751,6 +772,8 @@ describe("keyboard-shortcut help sections", () => {
|
||||
"workspace-pane-split-right": ["mod", "\\"],
|
||||
"workspace-pane-close": ["mod", "shift", "W"],
|
||||
"cycle-agent-mode": ["shift", "Tab"],
|
||||
"toggle-model-picker": ["mod", "/"],
|
||||
"cycle-effort": ["mod", "shift", "/"],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -197,6 +197,8 @@ export const SHORTCUT_HELP_ROW_ORDER: Record<ShortcutSectionId, readonly string[
|
||||
layout: ["toggle-left-sidebar", "toggle-right-sidebar", "toggle-both-sidebars", "toggle-focus"],
|
||||
"agent-input": [
|
||||
"focus-message-input",
|
||||
"toggle-model-picker",
|
||||
"cycle-effort",
|
||||
"cycle-agent-mode",
|
||||
"voice-toggle",
|
||||
"dictation-toggle",
|
||||
@@ -244,6 +246,8 @@ const SHORTCUT_HELP_LABEL_KEYS: Record<string, string> = {
|
||||
"toggle-focus": "settings.shortcuts.help.toggleFocusMode",
|
||||
"cycle-theme": "settings.shortcuts.help.cycleTheme",
|
||||
"focus-message-input": "settings.shortcuts.help.focusMessageInput",
|
||||
"toggle-model-picker": "settings.shortcuts.help.toggleModelPicker",
|
||||
"cycle-effort": "settings.shortcuts.help.cycleEffort",
|
||||
"cycle-agent-mode": "settings.shortcuts.help.cycleAgentMode",
|
||||
"voice-toggle": "settings.shortcuts.help.toggleVoiceMode",
|
||||
"dictation-toggle": "settings.shortcuts.help.startStopDictation",
|
||||
@@ -1149,6 +1153,33 @@ const SHORTCUT_BINDINGS: readonly ShortcutBinding[] = [
|
||||
label: "Focus message input",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "message-input-model-toggle-mod-slash",
|
||||
action: "message-input.action",
|
||||
combo: "Mod+/",
|
||||
repeat: false,
|
||||
// The handler checks that its composer or its own picker has focus.
|
||||
when: { commandCenter: false, focusScope: ["message-input", "editable", "other"] },
|
||||
payload: { type: "message-input", kind: "model-toggle" },
|
||||
help: {
|
||||
id: "toggle-model-picker",
|
||||
section: "agent-input",
|
||||
label: "Toggle model picker",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "message-input-effort-cycle-mod-shift-slash",
|
||||
action: "message-input.action",
|
||||
combo: "Mod+Shift+/",
|
||||
repeat: false,
|
||||
when: { commandCenter: false, focusScope: "message-input" },
|
||||
payload: { type: "message-input", kind: "effort-cycle" },
|
||||
help: {
|
||||
id: "cycle-effort",
|
||||
section: "agent-input",
|
||||
label: "Cycle effort",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "message-input-mode-cycle-shift-tab",
|
||||
action: "message-input.action",
|
||||
|
||||
@@ -304,6 +304,8 @@ describe("routeKeyboardShortcut — message-input.action", () => {
|
||||
["dictation-confirm", "message-input.dictation-confirm"],
|
||||
["voice-toggle", "message-input.voice-toggle"],
|
||||
["voice-mute-toggle", "message-input.voice-mute-toggle"],
|
||||
["model-toggle", "message-input.model-toggle"],
|
||||
["effort-cycle", "message-input.effort-cycle"],
|
||||
["mode-cycle", "message-input.mode-cycle"],
|
||||
] as const)("kind=%s → dispatch %s", (kind, id) => {
|
||||
expect(
|
||||
|
||||
@@ -85,6 +85,8 @@ const MESSAGE_INPUT_DISPATCH: Record<
|
||||
"dictation-confirm": { id: "message-input.dictation-confirm", scope: "message-input" },
|
||||
"voice-toggle": { id: "message-input.voice-toggle", scope: "message-input" },
|
||||
"voice-mute-toggle": { id: "message-input.voice-mute-toggle", scope: "message-input" },
|
||||
"model-toggle": { id: "message-input.model-toggle", scope: "message-input" },
|
||||
"effort-cycle": { id: "message-input.effort-cycle", scope: "message-input" },
|
||||
"mode-cycle": { id: "message-input.mode-cycle", scope: "message-input" },
|
||||
};
|
||||
|
||||
|
||||
@@ -39,9 +39,17 @@ import {
|
||||
resolveComposerTrackTailClearance,
|
||||
} from "@/composer/pill-styles";
|
||||
import { getActiveMessageSubmissions } from "@/composer/submission/model";
|
||||
import { RewindComposerRestoreProvider } from "@/components/rewind/composer-restore";
|
||||
import {
|
||||
RewindCommandCenterRegistration,
|
||||
RewindComposerRestoreProvider,
|
||||
} from "@/components/rewind";
|
||||
import { useAgentDescriptor } from "@/agent-presentation";
|
||||
import { useToastHost, type ToastApi, type ToastState } from "@/components/toast-host";
|
||||
import {
|
||||
useToastHost,
|
||||
type DismissToastById,
|
||||
type ToastApi,
|
||||
type ToastState,
|
||||
} from "@/components/toast-host";
|
||||
import type { WorkspaceComposerAttachment } from "@/attachments/types";
|
||||
import { useWorkspaceAttachmentScopeKey } from "@/attachments/workspace-attachments-store";
|
||||
import { COMPACT_CONTENT_WIDTH, useIsCompactFormFactor } from "@/constants/layout";
|
||||
@@ -57,6 +65,7 @@ import {
|
||||
type AgentScreenReadySyncState,
|
||||
} from "@/hooks/use-agent-screen-state-machine";
|
||||
import { useArchiveAgent } from "@/hooks/use-archive-agent";
|
||||
import { useStableEvent } from "@/hooks/use-stable-event";
|
||||
import { useContainerWidthBelow } from "@/hooks/use-container-width";
|
||||
import { reconcileMissingAgentStateWithPresentAgent } from "@/panels/agent-panel-load-state";
|
||||
import { TimelineSyncStatus } from "@/timeline/sync-status";
|
||||
@@ -864,10 +873,6 @@ function ChatAgentContent({
|
||||
streamViewRef.current?.scrollToBottom("message-sent");
|
||||
}, [agentId]);
|
||||
|
||||
const handleRewindComplete = useCallback(() => {
|
||||
streamViewRef.current?.scrollToBottom("rewind");
|
||||
}, []);
|
||||
|
||||
const retryAgentLoad = useCallback(() => {
|
||||
setMissingAgentState({ kind: "idle" });
|
||||
if (!agentId || !viewedTimelineSync) return;
|
||||
@@ -1022,7 +1027,6 @@ function ChatAgentContent({
|
||||
streamViewRef={streamViewRef}
|
||||
handleComposerHeightChange={handleComposerHeightChange}
|
||||
handleMessageSent={handleMessageSent}
|
||||
handleRewindComplete={handleRewindComplete}
|
||||
timelineSync={isPaneVisible && viewState.tag === "ready" ? viewState.sync : null}
|
||||
showHistorySyncOverlay={showHistorySyncOverlay}
|
||||
showHistorySyncError={showHistorySyncError}
|
||||
@@ -1054,7 +1058,6 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
streamViewRef,
|
||||
handleComposerHeightChange,
|
||||
handleMessageSent,
|
||||
handleRewindComplete,
|
||||
timelineSync,
|
||||
showHistorySyncOverlay,
|
||||
showHistorySyncError,
|
||||
@@ -1079,11 +1082,10 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
hasCachedHistory: boolean;
|
||||
toastApi: ToastApi;
|
||||
toast: ToastState | null;
|
||||
dismiss: () => void;
|
||||
dismiss: DismissToastById;
|
||||
streamViewRef: React.RefObject<AgentStreamViewHandle | null>;
|
||||
handleComposerHeightChange: (height: number) => void;
|
||||
handleMessageSent: () => void;
|
||||
handleRewindComplete: () => void;
|
||||
timelineSync: AgentScreenReadySyncState | null;
|
||||
showHistorySyncOverlay: boolean;
|
||||
showHistorySyncError: boolean;
|
||||
@@ -1102,6 +1104,22 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
const composerEditingSession = useComposerEditingSession("chat");
|
||||
const isComposerFullscreen = useComposerFullscreen(composerEditingSession);
|
||||
const hasActiveComposer = !agentState.archivedAt && !isArchivingCurrentAgent;
|
||||
const focusRestoredComposer = useStableEvent(() => {
|
||||
if (isPaneFocused && showsComposer && hasActiveComposer) {
|
||||
composerEditingSession.focus();
|
||||
}
|
||||
});
|
||||
const handleRewindComplete = useCallback(
|
||||
(restoredComposerText: boolean) => {
|
||||
streamViewRef.current?.scrollToBottom("rewind");
|
||||
if (restoredComposerText) {
|
||||
// Defer focus so the editor can apply the restored draft and the menu can start closing.
|
||||
requestAnimationFrame(focusRestoredComposer);
|
||||
}
|
||||
},
|
||||
[focusRestoredComposer, streamViewRef],
|
||||
);
|
||||
const hasAgentComposer = showsComposer && hasActiveComposer && !draft;
|
||||
const parentAgentId = useParentAgentId(serverId, agentId);
|
||||
// With a composer the parent is a pill above it; without one, the box takes the composer's place.
|
||||
const parentPillAgentId = showsComposer ? parentAgentId : null;
|
||||
@@ -1262,6 +1280,15 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
setText={agentInputDraft.replaceText}
|
||||
onRewindComplete={handleRewindComplete}
|
||||
>
|
||||
{hasAgentComposer ? (
|
||||
<RewindCommandCenterRegistration
|
||||
serverId={serverId}
|
||||
agentId={agentId}
|
||||
capabilities={agentState.capabilities}
|
||||
timelineSync={timelineSync}
|
||||
enabled={isPaneFocused}
|
||||
/>
|
||||
) : null}
|
||||
<View style={styles.root}>
|
||||
{dock}
|
||||
|
||||
@@ -1276,7 +1303,7 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
</RewindComposerRestoreProvider>
|
||||
);
|
||||
return wrapAgentCommandProvider({
|
||||
enabled: showsComposer && hasActiveComposer && !draft,
|
||||
enabled: hasAgentComposer,
|
||||
serverId,
|
||||
agentId,
|
||||
editingSession: composerEditingSession,
|
||||
|
||||
@@ -106,6 +106,7 @@ function fakeInput(initial: UserComposerAttachment[] = [], locked = false) {
|
||||
isLive: () => true,
|
||||
revealed: true,
|
||||
isRevealed: () => view.revealed,
|
||||
isFocused: () => false,
|
||||
focus: async (options) => {
|
||||
view.focused.push(options);
|
||||
},
|
||||
|
||||
@@ -167,6 +167,14 @@ function resolvePreferredThinkingOptionId(input: {
|
||||
return "";
|
||||
}
|
||||
|
||||
// COMPAT(claudeUltracodePreference): added in v0.17.0, remove after 2027-05-18.
|
||||
export function findThinkingOptionReplacement(
|
||||
options: NonNullable<AgentModelDefinition["thinkingOptions"]>,
|
||||
legacyId: string,
|
||||
): string | undefined {
|
||||
return options.find((option) => option.metadata?.replacesThinkingOptionId === legacyId)?.id;
|
||||
}
|
||||
|
||||
export function resolveThinkingOptionId(args: {
|
||||
availableModels: AgentModelDefinition[] | null;
|
||||
modelId: string;
|
||||
@@ -183,6 +191,9 @@ export function resolveThinkingOptionId(args: {
|
||||
) {
|
||||
return normalizedThinkingOptionId;
|
||||
}
|
||||
if (findThinkingOptionReplacement(thinkingOptions, normalizedThinkingOptionId)) {
|
||||
return normalizedThinkingOptionId;
|
||||
}
|
||||
|
||||
return effectiveModel?.defaultThinkingOptionId ?? thinkingOptions[0]?.id ?? "";
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ function scheduleOnHost(input: {
|
||||
serverName: string;
|
||||
cwd: string;
|
||||
model: string;
|
||||
provider?: string;
|
||||
thinkingOptionId?: string | null;
|
||||
cadence?: ScheduleSummary["cadence"];
|
||||
}): TestSchedule {
|
||||
@@ -109,7 +110,7 @@ function scheduleOnHost(input: {
|
||||
target: {
|
||||
type: "new-agent",
|
||||
config: {
|
||||
provider: "mock",
|
||||
provider: input.provider ?? "mock",
|
||||
cwd: input.cwd,
|
||||
model: input.model,
|
||||
modeId: "load-test",
|
||||
@@ -186,6 +187,56 @@ function applyPreferences(form: ReturnType<typeof open>, preferences: FormPrefer
|
||||
}
|
||||
|
||||
describe("schedule form model", () => {
|
||||
it("keeps Ultra Code available in the schedule effort picker", () => {
|
||||
const model = "claude-opus-4-8";
|
||||
const form = open({
|
||||
mode: "edit",
|
||||
schedule: scheduleOnHost({
|
||||
serverId: "host-a",
|
||||
serverName: "Host A",
|
||||
cwd: "/repo/a",
|
||||
provider: "claude",
|
||||
model,
|
||||
thinkingOptionId: "ultracode",
|
||||
}),
|
||||
defaults: { serverId: null, projectTargets: PROJECT_TARGETS, preferences: {} },
|
||||
});
|
||||
form.applyProviderSnapshot("host-a", {
|
||||
...providerSnapshot([]),
|
||||
entries: [
|
||||
{
|
||||
provider: "claude",
|
||||
status: "ready",
|
||||
enabled: true,
|
||||
models: [
|
||||
{
|
||||
provider: "claude",
|
||||
id: model,
|
||||
label: "Opus 4.8",
|
||||
thinkingOptions: [
|
||||
{ id: "high", label: "High" },
|
||||
{
|
||||
id: "xhigh",
|
||||
label: "Extra high",
|
||||
metadata: { replacesThinkingOptionId: "ultracode" },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(form.getState().selectedThinkingOptionId).toBe("ultracode");
|
||||
expect(form.getState().availableThinkingOptions.map((option) => option.id)).toContain(
|
||||
"ultracode",
|
||||
);
|
||||
form.setThinking("high");
|
||||
expect(form.getState().selectedThinkingOptionId).toBe("high");
|
||||
expect(form.getState().availableThinkingOptions.map((option) => option.id)).toContain(
|
||||
"ultracode",
|
||||
);
|
||||
});
|
||||
|
||||
it("opens edit from the schedule host snapshot and completes that host resolution", () => {
|
||||
const previous = open({
|
||||
mode: "edit",
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { filterSelectableModels, findModelByReference } from "@/provider-selection/model-catalog";
|
||||
import {
|
||||
buildProviderDefinitionMapForStatuses,
|
||||
findThinkingOptionReplacement,
|
||||
INITIAL_USER_MODIFIED,
|
||||
RESOLVABLE_PROVIDER_STATUSES,
|
||||
resolveDefaultModelId,
|
||||
@@ -273,7 +274,14 @@ function resolveThinkingOptions(
|
||||
modelId: string,
|
||||
): NonNullable<AgentModelDefinition["thinkingOptions"]> {
|
||||
const model = resolveEffectiveModel(resolveAvailableModels(entries, provider), modelId);
|
||||
return model?.thinkingOptions ?? [];
|
||||
const options = model?.thinkingOptions ?? [];
|
||||
// COMPAT(claudeUltracodePreference): added in v0.17.0, remove after 2027-05-18
|
||||
// once schedules edit the Ultracode option independently.
|
||||
// Schedules still use a single effort field.
|
||||
return findThinkingOptionReplacement(options, "ultracode") &&
|
||||
!options.some((option) => option.id === "ultracode")
|
||||
? [...options, { id: "ultracode", label: "Ultra Code" }]
|
||||
: options;
|
||||
}
|
||||
|
||||
function resolveModelDisplay(input: {
|
||||
|
||||
@@ -17,7 +17,7 @@ export function TimelineSyncStatus({
|
||||
}: {
|
||||
sync: AgentScreenReadySyncState | null;
|
||||
toast: ToastState | null;
|
||||
onDismiss: () => void;
|
||||
onDismiss: (id: number) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
let state: "reconnecting" | "updating" | null = null;
|
||||
|
||||
@@ -26,6 +26,16 @@ describe("highlightDiffLines", () => {
|
||||
expect(add?.tokens?.some((token) => token.style === "keyword")).toBe(true);
|
||||
});
|
||||
|
||||
it("highlights a Dockerfile diff using the filename", () => {
|
||||
const diff = buildLineDiff("FROM alpine:3.21", "FROM alpine:3.22");
|
||||
const result = highlightDiffLines(diff, "/repo/docker/Dockerfile");
|
||||
|
||||
expect(result.find((line) => line.type === "add")?.tokens).toContainEqual({
|
||||
text: "FROM",
|
||||
style: "keyword",
|
||||
});
|
||||
});
|
||||
|
||||
it("highlights a Codex-style unified diff with bare @@ headers (no line ranges)", () => {
|
||||
const unified = ["@@", "-const x = 1;", "+const x = 2;", " const y = 3;"].join("\n");
|
||||
const result = highlightDiffLines(parseUnifiedDiff(unified), "/repo/a.ts");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isLanguageSupported, type HighlightToken } from "@getpaseo/highlight";
|
||||
import { extensionFromPath, tokenizeToLines } from "@/utils/highlight-cache";
|
||||
import { tokenizeToLines } from "@/utils/highlight-cache";
|
||||
import type { DiffLine } from "@/utils/tool-call-parsers";
|
||||
|
||||
// The leading diff marker glyph for a line. The code on the line is the content
|
||||
@@ -30,7 +30,7 @@ function diffLineCode(line: DiffLine): string {
|
||||
}
|
||||
|
||||
// Attach syntax-highlight tokens to each diff line. Language comes from the file
|
||||
// path (extension only). We reconstruct the old and new document text from the
|
||||
// path. We reconstruct the old and new document text from the
|
||||
// diff lines by position — counting context/remove into "old" and context/add
|
||||
// into "new" — so this works regardless of whether the source diff carried real
|
||||
// `@@ -n,m +n,m @@` line ranges (Codex emits bare `@@`). Each document is
|
||||
@@ -41,11 +41,10 @@ export function highlightDiffLines(
|
||||
diffLines: DiffLine[],
|
||||
filePath: string | null | undefined,
|
||||
): DiffLine[] {
|
||||
const ext = extensionFromPath(filePath);
|
||||
// Gate on real grammar support: an unsupported language would tokenize to a
|
||||
// single style-less token per line, which would shadow the word-level change
|
||||
// segments the diff already computes. Better to keep those.
|
||||
if (!ext || diffLines.length === 0 || !isLanguageSupported(`x.${ext}`)) {
|
||||
if (!filePath || diffLines.length === 0 || !isLanguageSupported(filePath)) {
|
||||
return diffLines;
|
||||
}
|
||||
|
||||
@@ -72,8 +71,8 @@ export function highlightDiffLines(
|
||||
return { oldIndex: -1, newIndex: -1 };
|
||||
});
|
||||
|
||||
const oldTokens = oldCode.length > 0 ? tokenizeToLines(oldCode.join("\n"), ext) : null;
|
||||
const newTokens = newCode.length > 0 ? tokenizeToLines(newCode.join("\n"), ext) : null;
|
||||
const oldTokens = oldCode.length > 0 ? tokenizeToLines(oldCode.join("\n"), filePath) : null;
|
||||
const newTokens = newCode.length > 0 ? tokenizeToLines(newCode.join("\n"), filePath) : null;
|
||||
if (!oldTokens && !newTokens) {
|
||||
return diffLines;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
extensionFromPath,
|
||||
highlightToKeyedLines,
|
||||
MAX_HIGHLIGHT_CHARS,
|
||||
tokenizeToLines,
|
||||
} from "./highlight-cache";
|
||||
|
||||
describe("extensionFromPath", () => {
|
||||
it("extracts a lowercased extension regardless of absolute/relative path", () => {
|
||||
expect(extensionFromPath("/repo/src/Index.TS")).toBe("ts");
|
||||
expect(extensionFromPath("src/index.ts")).toBe("ts");
|
||||
expect(extensionFromPath("a.b/c.tsx")).toBe("tsx");
|
||||
});
|
||||
|
||||
it("returns null for paths without a usable extension", () => {
|
||||
expect(extensionFromPath(null)).toBeNull();
|
||||
expect(extensionFromPath(undefined)).toBeNull();
|
||||
expect(extensionFromPath("Makefile")).toBeNull();
|
||||
expect(extensionFromPath(".gitignore")).toBeNull();
|
||||
expect(extensionFromPath("trailingdot.")).toBeNull();
|
||||
});
|
||||
});
|
||||
import { highlightToKeyedLines, MAX_HIGHLIGHT_CHARS, tokenizeToLines } from "./highlight-cache";
|
||||
|
||||
describe("tokenizeToLines", () => {
|
||||
it("returns one token array per line for a supported language", () => {
|
||||
@@ -30,7 +9,7 @@ describe("tokenizeToLines", () => {
|
||||
expect(lines?.[0].some((token) => token.style === "keyword")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns null when there is no extension", () => {
|
||||
it("returns null when there is no filename", () => {
|
||||
expect(tokenizeToLines("whatever", null)).toBeNull();
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { highlightCode, type HighlightToken } from "@getpaseo/highlight";
|
||||
// Shared, theme-independent tokenization + cache for syntax highlighting.
|
||||
// Used by markdown code blocks, file preview, and tool-call detail blocks
|
||||
// (Edit diff / Write / Read). Colors are applied at render time, so the cache
|
||||
// key is just (extension, code) and one entry serves both light and dark.
|
||||
// key is just (filename, code) and one entry serves both light and dark.
|
||||
|
||||
export interface KeyedToken {
|
||||
key: string;
|
||||
@@ -44,18 +44,17 @@ class LRUCache<K, V> {
|
||||
|
||||
const tokenizationCache = new LRUCache<string, HighlightToken[][]>(200);
|
||||
|
||||
// Tokenize `code` to per-line tokens, cached. Returns null when the language is
|
||||
// unsupported, the input is over the size cap, or parsing throws — callers then
|
||||
// render plain text.
|
||||
export function tokenizeToLines(code: string, ext: string | null): HighlightToken[][] | null {
|
||||
if (!ext) return null;
|
||||
// Tokenize `code` to per-line tokens, cached. Returns null when the filename is absent,
|
||||
// the input exceeds the size cap, or parsing throws.
|
||||
export function tokenizeToLines(code: string, filename: string | null): HighlightToken[][] | null {
|
||||
if (!filename) return null;
|
||||
if (code.length > MAX_HIGHLIGHT_CHARS) return null;
|
||||
const cacheKey = `${ext}:${code}`;
|
||||
const cacheKey = `${filename.length}:${filename}${code}`;
|
||||
const cached = tokenizationCache.get(cacheKey);
|
||||
if (cached) return cached;
|
||||
let lines: HighlightToken[][];
|
||||
try {
|
||||
lines = highlightCode(code, `x.${ext}`);
|
||||
lines = highlightCode(code, filename);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -73,17 +72,7 @@ function toKeyedLine(tokens: HighlightToken[], lineIndex: number): KeyedLine {
|
||||
};
|
||||
}
|
||||
|
||||
export function highlightToKeyedLines(code: string, ext: string | null): KeyedLine[] | null {
|
||||
const lines = tokenizeToLines(code, ext);
|
||||
export function highlightToKeyedLines(code: string, filename: string | null): KeyedLine[] | null {
|
||||
const lines = tokenizeToLines(code, filename);
|
||||
return lines ? lines.map(toKeyedLine) : null;
|
||||
}
|
||||
|
||||
// Extension for grammar selection from a file path. We only need the suffix —
|
||||
// absolute vs relative paths are equivalent here.
|
||||
export function extensionFromPath(filePath: string | null | undefined): string | null {
|
||||
if (!filePath) return null;
|
||||
const name = filePath.split(/[\\/]/).pop() ?? filePath;
|
||||
const dot = name.lastIndexOf(".");
|
||||
if (dot <= 0 || dot === name.length - 1) return null;
|
||||
return name.slice(dot + 1).toLowerCase();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,11 @@ const pinnedTheme = {
|
||||
const testTheme = {
|
||||
...lightTheme,
|
||||
...pinnedTheme,
|
||||
colors: { ...lightTheme.colors, ...pinnedTheme.colors },
|
||||
colors: {
|
||||
...lightTheme.colors,
|
||||
...pinnedTheme.colors,
|
||||
palette: { ...lightTheme.colors.palette, ...pinnedTheme.colors.palette },
|
||||
},
|
||||
};
|
||||
|
||||
type StyleFactory<T> = (theme: typeof testTheme) => T;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo CLI - control your AI coding agents from the command line",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
@@ -29,9 +29,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/server": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/server": "0.16.2",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo client SDK package",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
@@ -49,8 +49,8 @@
|
||||
"measure:diff-materialization": "tsx scripts/measure-diff-materialization.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/relay": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@getpaseo/relay": "0.16.2",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
|
||||
@@ -368,6 +368,29 @@ async function waitForGuestActiveElement(client, browserId, elementId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A wait whose condition never matches must say which condition expired, not blame the host.
|
||||
async function verifyExpiredWaitNamesItsCondition(client, targetUrl) {
|
||||
const created = await callBrowserTool(client, "browser_new_tab", { url: targetUrl });
|
||||
const browserId = created.browserId;
|
||||
assert(typeof browserId === "string", "browser_new_tab returned no browserId for the wait page");
|
||||
try {
|
||||
await callBrowserTool(client, "browser_wait", { browserId, text: "Bridge target" });
|
||||
// The page title is not body text, so this wait expires.
|
||||
const response = await client.callTool({
|
||||
name: "browser_wait",
|
||||
args: { browserId, text: "Desktop browser target", timeoutMs: 1_000 },
|
||||
});
|
||||
const text = response.content?.[0]?.text;
|
||||
assert(
|
||||
response.structuredContent?.ok === false &&
|
||||
text === "Timed out waiting for browser text: Desktop browser target",
|
||||
`browser_wait did not name its expired condition: ${JSON.stringify(response.content)}`,
|
||||
);
|
||||
} finally {
|
||||
await callBrowserTool(client, "browser_close_tab", { browserId });
|
||||
}
|
||||
}
|
||||
|
||||
// A page whose Content Security Policy omits 'unsafe-eval' refuses eval(); the tools must still work.
|
||||
async function verifyEvaluateOnPageWithoutUnsafeEval(client, targetUrl) {
|
||||
const created = await callBrowserTool(client, "browser_new_tab", {
|
||||
@@ -791,6 +814,7 @@ async function runRegression({
|
||||
|
||||
await verifyReactFormFill((name, args) => callBrowserTool(client, name, args), targetUrl);
|
||||
await verifyEvaluateOnPageWithoutUnsafeEval(client, targetUrl);
|
||||
await verifyExpiredWaitNamesItsCondition(client, targetUrl);
|
||||
|
||||
const created = await callBrowserTool(client, "browser_new_tab", { url: targetUrl });
|
||||
const browserId = created.browserId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"private": true,
|
||||
"description": "Paseo desktop app (Electron wrapper)",
|
||||
"homepage": "https://paseo.sh",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Native module for two way audio streaming",
|
||||
"keywords": [
|
||||
"ExpoTwoWayAudio",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -34,6 +34,21 @@ describe("highlightCode", () => {
|
||||
expect(stringToken?.style).toBe("string");
|
||||
});
|
||||
|
||||
it.each(["scripts/build.sh", "build.bash", "build.zsh"])("highlights shell in %s", (path) => {
|
||||
const lines = highlightCode('export MESSAGE="hello"', path);
|
||||
expect(lines[0]).toContainEqual({ text: "export", style: "keyword" });
|
||||
expect(lines[0]).toContainEqual({ text: '"hello"', style: "string" });
|
||||
});
|
||||
|
||||
it.each(["Dockerfile", "docker/Dockerfile", "C:\\docker\\Dockerfile", "build.dockerfile"])(
|
||||
"highlights Docker instructions in %s",
|
||||
(path) => {
|
||||
const lines = highlightCode("FROM alpine\n# Build stage", path);
|
||||
expect(lines[0]).toContainEqual({ text: "FROM", style: "keyword" });
|
||||
expect(lines[1]).toEqual([{ text: "# Build stage", style: "comment" }]);
|
||||
},
|
||||
);
|
||||
|
||||
it("highlights Swift code", () => {
|
||||
const code = 'struct Greeter {\n let message = "hello"\n}';
|
||||
const result = highlightCode(code, "test.swift");
|
||||
|
||||
@@ -39,6 +39,8 @@ describe("isLanguageSupported", () => {
|
||||
|
||||
it("returns false for files without extensions", () => {
|
||||
expect(isLanguageSupported("Makefile")).toBe(false);
|
||||
expect(isLanguageSupported("src/ts")).toBe(false);
|
||||
expect(isLanguageSupported("bin/bash")).toBe(false);
|
||||
});
|
||||
|
||||
it("handles nested paths", () => {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { defineLanguageFacet, Language, StreamLanguage } from "@codemirror/language";
|
||||
import { dart } from "@codemirror/legacy-modes/mode/clike";
|
||||
import { dockerFile } from "@codemirror/legacy-modes/mode/dockerfile";
|
||||
import { shell } from "@codemirror/legacy-modes/mode/shell";
|
||||
import { swift } from "@codemirror/legacy-modes/mode/swift";
|
||||
import { parser as jsParser } from "@lezer/javascript";
|
||||
import { parser as jsonParser } from "@lezer/json";
|
||||
@@ -28,6 +30,9 @@ function language(parser: Parser): Language {
|
||||
return new Language(defineLanguageFacet(), parser);
|
||||
}
|
||||
|
||||
const shellLanguage = StreamLanguage.define(shell);
|
||||
const dockerfileLanguage = StreamLanguage.define(dockerFile);
|
||||
|
||||
const languagesByExtension: Record<string, Language> = {
|
||||
// JavaScript/TypeScript
|
||||
js: language(jsParser),
|
||||
@@ -75,6 +80,12 @@ const languagesByExtension: Record<string, Language> = {
|
||||
yml: language(yamlParser),
|
||||
// Rust
|
||||
rs: language(rustParser),
|
||||
// Shell
|
||||
sh: shellLanguage,
|
||||
bash: shellLanguage,
|
||||
zsh: shellLanguage,
|
||||
// Docker
|
||||
dockerfile: dockerfileLanguage,
|
||||
// Swift
|
||||
swift: StreamLanguage.define(swift),
|
||||
// Dart
|
||||
@@ -96,7 +107,16 @@ const languagesByExtension: Record<string, Language> = {
|
||||
};
|
||||
|
||||
export function getLanguageForFile(filename: string): Language | null {
|
||||
const ext = filename.split(".").pop()?.toLowerCase();
|
||||
const basename = filename.slice(
|
||||
Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\")) + 1,
|
||||
);
|
||||
if (basename.toLowerCase() === "dockerfile") return dockerfileLanguage;
|
||||
|
||||
const dot = basename.lastIndexOf(".");
|
||||
// Callers also pass bare language keys for code fences.
|
||||
if (dot === -1 && basename !== filename) return null;
|
||||
|
||||
const ext = basename.slice(dot + 1).toLowerCase();
|
||||
if (!ext) return null;
|
||||
return languagesByExtension[ext] ?? null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"description": "Paseo plugin SDK package",
|
||||
"license": "Apache-2.0",
|
||||
"files": [
|
||||
@@ -78,8 +78,8 @@
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.2.3",
|
||||
@@ -89,8 +89,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.16.1",
|
||||
"@getpaseo/protocol": "0.16.1",
|
||||
"@getpaseo/client": "0.16.2",
|
||||
"@getpaseo/protocol": "0.16.2",
|
||||
"react": ">=19.1.0 <20",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
@@ -207,9 +207,11 @@ async function dispatch(input: ProviderInput, state: AcpConnectionState): Promis
|
||||
case "session.open":
|
||||
await openSession(input, state);
|
||||
return;
|
||||
case "session.prompt":
|
||||
await requireSession(state, input.sessionId).runtime.prompt(input);
|
||||
case "session.prompt": {
|
||||
const session = requireSession(state, input.sessionId);
|
||||
await mutateSession(session, () => session.runtime.prompt(input));
|
||||
return;
|
||||
}
|
||||
case "session.interrupt":
|
||||
await requireSession(state, input.sessionId).runtime.interrupt();
|
||||
state.emit({ type: "request.completed", requestId: input.requestId });
|
||||
@@ -253,6 +255,7 @@ async function discover(
|
||||
options: state.options,
|
||||
launch: state.launch,
|
||||
boundarySessionId: "catalog",
|
||||
cwd: input.cwd,
|
||||
env: {},
|
||||
emit: state.emit,
|
||||
});
|
||||
@@ -309,6 +312,7 @@ async function openSession(
|
||||
options: state.options,
|
||||
launch: state.launch,
|
||||
boundarySessionId: input.sessionId,
|
||||
cwd: input.config.cwd,
|
||||
env: input.config.env,
|
||||
emit: state.emit,
|
||||
});
|
||||
@@ -323,6 +327,7 @@ async function openSession(
|
||||
capabilities,
|
||||
mutationLane: Promise.resolve(),
|
||||
});
|
||||
state.emit({ type: "session.ready", requestId: input.requestId, sessionId: input.sessionId });
|
||||
} catch (error) {
|
||||
await runtime.close();
|
||||
throw error;
|
||||
@@ -348,10 +353,17 @@ interface StartRuntimeOptions {
|
||||
launch?: ProviderLaunch;
|
||||
options: RunAcpProviderOptions;
|
||||
boundarySessionId: string;
|
||||
cwd?: string;
|
||||
env: Readonly<Record<string, string>>;
|
||||
emit(event: ProviderEvent): void;
|
||||
}
|
||||
|
||||
interface PendingPermission {
|
||||
request: RequestPermissionRequest;
|
||||
turnId: string | undefined;
|
||||
resolve(response: RequestPermissionResponse): void;
|
||||
}
|
||||
|
||||
class AcpRuntime {
|
||||
readonly connection: ClientSideConnection;
|
||||
agentCapabilities: AgentCapabilities = {};
|
||||
@@ -363,14 +375,12 @@ class AcpRuntime {
|
||||
// Running tool rows published by transformers; the turn's terminal closes any left open.
|
||||
private readonly vendorToolCalls = new Map<string, ToolCallTimelineItem>();
|
||||
private readonly pendingCompactions = new Set<string>();
|
||||
private readonly permissions = new Map<
|
||||
string,
|
||||
{ request: RequestPermissionRequest; resolve(response: RequestPermissionResponse): void }
|
||||
>();
|
||||
private readonly permissions = new Map<string, PendingPermission>();
|
||||
private readonly transformers: readonly AcpTransformer[];
|
||||
private configOptions: SessionConfigOption[] = [];
|
||||
private modes: NewSessionResponse["modes"] = null;
|
||||
private commandWaiter: (() => void) | null = null;
|
||||
private receivedInitialCommands = false;
|
||||
private messageSequence = 0;
|
||||
/**
|
||||
* Fallback ids for streamed chunks that carry no `messageId`, one per
|
||||
@@ -383,19 +393,20 @@ class AcpRuntime {
|
||||
string
|
||||
>();
|
||||
/**
|
||||
* Active while a persisted session loads. ACP agents replay the loaded
|
||||
* session's updates before session/load resolves; the value follows the
|
||||
* open request's history contract.
|
||||
* Replay updates count as history until the session reports ready.
|
||||
* Once ready, suppress late replay rows until the first prompt.
|
||||
*/
|
||||
private replayWindow: "replay" | "skip" | null = null;
|
||||
private lastLoadUpdateAt = 0;
|
||||
private closing = false;
|
||||
private processFailed = false;
|
||||
private configTransaction = false;
|
||||
private stagedTransformerConfig: ProviderConfigState | null = null;
|
||||
private readonly closeConnector: () => Promise<void>;
|
||||
private notificationLane: Promise<void> = Promise.resolve();
|
||||
private promptLane: Promise<void> = Promise.resolve();
|
||||
private activePrompt: { turnId: string; settled: Promise<void> } | null = null;
|
||||
private autoAccept = false;
|
||||
private activePrompt: { turnId: string; settled: Promise<void>; cancelling: boolean } | null =
|
||||
null;
|
||||
private lastUsage: ProviderUsage = {};
|
||||
|
||||
static async start(options: StartRuntimeOptions): Promise<AcpRuntime> {
|
||||
@@ -412,6 +423,7 @@ class AcpRuntime {
|
||||
env: process.env,
|
||||
};
|
||||
child = spawnProcess(launch.command, launch.args, {
|
||||
cwd: options.cwd,
|
||||
env: { ...launch.env, ...options.env },
|
||||
stdio: "pipe",
|
||||
});
|
||||
@@ -496,8 +508,8 @@ class AcpRuntime {
|
||||
connectionCapabilities: readonly ProviderCapability[],
|
||||
): Promise<readonly ProviderCapability[]> {
|
||||
const mcpServers = toAcpMcpServers(input.config);
|
||||
const nativeSessionId = readNativeSessionId(input.persistence);
|
||||
const metadata = {
|
||||
let nativeSessionId = readNativeSessionId(input.persistence);
|
||||
const metadata: Record<string, unknown> = {
|
||||
_paseo: {
|
||||
systemPrompt: input.config.systemPrompt,
|
||||
providerOptions: input.config.providerOptions,
|
||||
@@ -505,25 +517,31 @@ class AcpRuntime {
|
||||
persist: input.config.persist,
|
||||
},
|
||||
};
|
||||
for (const transformer of this.transformers) {
|
||||
const prepared = transformer.sessionOpen?.({
|
||||
persistence: input.persistence,
|
||||
systemPrompt: input.config.systemPrompt,
|
||||
agentMetadata: jsonValue(this.agentCapabilities._meta ?? null),
|
||||
});
|
||||
nativeSessionId ??= prepared?.sessionId ?? null;
|
||||
Object.assign(metadata, prepared?.metadata);
|
||||
}
|
||||
let response: Pick<NewSessionResponse, "modes" | "configOptions">;
|
||||
if (nativeSessionId) {
|
||||
// ACP agents replay the loaded session's updates before session/load resolves,
|
||||
// so the native id must be registered first for them to pass the session filter.
|
||||
this.nativeSessionId = nativeSessionId;
|
||||
this.replayWindow = input.history === "replay" ? "replay" : "skip";
|
||||
try {
|
||||
response = await this.call(
|
||||
this.connection.loadSession({
|
||||
sessionId: nativeSessionId,
|
||||
cwd: input.config.cwd,
|
||||
mcpServers,
|
||||
_meta: metadata,
|
||||
}),
|
||||
);
|
||||
await this.drainNotifications();
|
||||
} finally {
|
||||
this.replayWindow = null;
|
||||
}
|
||||
response = await this.call(
|
||||
this.connection.loadSession({
|
||||
sessionId: nativeSessionId,
|
||||
cwd: input.config.cwd,
|
||||
mcpServers,
|
||||
_meta: metadata,
|
||||
}),
|
||||
);
|
||||
await this.drainNotifications();
|
||||
if (!this.options.options.acpOptions?.loadReplayQuietPeriodMs) this.replayWindow = null;
|
||||
} else {
|
||||
const newSession = await this.call(
|
||||
this.connection.newSession({
|
||||
@@ -535,12 +553,13 @@ class AcpRuntime {
|
||||
response = newSession;
|
||||
this.nativeSessionId = newSession.sessionId;
|
||||
}
|
||||
this.modes = response.modes;
|
||||
this.modes = response.modes ?? null;
|
||||
this.configOptions = response.configOptions ?? [];
|
||||
await this.applyInitialConfig(input.config);
|
||||
const sessionCapabilities = connectionCapabilities.filter(
|
||||
(capability) =>
|
||||
capability !== "session.configure" ||
|
||||
this.options.options.acpOptions?.autoAcceptMode !== undefined ||
|
||||
this.modes !== null ||
|
||||
this.configOptions.length > 0 ||
|
||||
this.transformers.some((transformer) => transformer.configure !== undefined),
|
||||
@@ -559,7 +578,11 @@ class AcpRuntime {
|
||||
if (this.options.options.acpOptions?.waitForInitialCommands) {
|
||||
await this.waitForInitialCommands();
|
||||
}
|
||||
this.emit({ type: "session.ready", requestId: input.requestId, sessionId: input.sessionId });
|
||||
const quietPeriod = this.options.options.acpOptions?.loadReplayQuietPeriodMs;
|
||||
if (this.replayWindow && quietPeriod && quietPeriod > 0) {
|
||||
await this.waitForLoadReplay(quietPeriod);
|
||||
this.replayWindow = "skip";
|
||||
}
|
||||
return sessionCapabilities;
|
||||
}
|
||||
|
||||
@@ -571,26 +594,26 @@ class AcpRuntime {
|
||||
this.connection.newSession({ cwd: cwd ?? process.cwd(), mcpServers: [] }),
|
||||
);
|
||||
this.nativeSessionId = response.sessionId;
|
||||
this.modes = response.modes;
|
||||
this.modes = response.modes ?? null;
|
||||
this.configOptions = response.configOptions ?? [];
|
||||
return toProviderCatalog(response.modes, response.configOptions ?? []);
|
||||
const catalog = toProviderCatalog(this.modes, this.configOptions);
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
if (!autoAcceptMode) return catalog;
|
||||
return {
|
||||
...catalog,
|
||||
modes: [...catalog.modes, { ...autoAcceptMode.mode, isUnattended: true }],
|
||||
defaultMode: autoAcceptMode.default ? autoAcceptMode.mode.id : catalog.defaultMode,
|
||||
};
|
||||
}
|
||||
|
||||
prompt(input: Extract<ProviderInput, { type: "session.prompt" }>): Promise<void> {
|
||||
const admission = this.promptLane.then(() => this.admitPrompt(input));
|
||||
this.promptLane = admission.catch(() => undefined);
|
||||
return admission;
|
||||
}
|
||||
|
||||
private async admitPrompt(
|
||||
input: Extract<ProviderInput, { type: "session.prompt" }>,
|
||||
): Promise<void> {
|
||||
async prompt(input: Extract<ProviderInput, { type: "session.prompt" }>): Promise<void> {
|
||||
const active = this.activePrompt;
|
||||
if (active) {
|
||||
await this.interrupt();
|
||||
await active.settled;
|
||||
}
|
||||
const prompt = toAcpPrompt(input.prompt);
|
||||
this.replayWindow = null;
|
||||
const turnId = `acp:${input.prompt.clientMessageId}`;
|
||||
this.fallbackChunkIds.clear();
|
||||
this.emit({
|
||||
@@ -642,6 +665,7 @@ class AcpRuntime {
|
||||
const state = response.stopReason === "cancelled" ? "canceled" : "completed";
|
||||
this.fallbackChunkIds.clear();
|
||||
this.terminalizeTransientItems(state);
|
||||
this.finishTurnPermissions(turnId);
|
||||
this.emit({
|
||||
type: "session.turn",
|
||||
sessionId: this.options.boundarySessionId,
|
||||
@@ -654,6 +678,7 @@ class AcpRuntime {
|
||||
await this.drainNotifications();
|
||||
this.fallbackChunkIds.clear();
|
||||
this.terminalizeTransientItems("failed");
|
||||
this.finishTurnPermissions(turnId);
|
||||
this.emit({
|
||||
type: "session.turn",
|
||||
sessionId: this.options.boundarySessionId,
|
||||
@@ -664,14 +689,21 @@ class AcpRuntime {
|
||||
return undefined;
|
||||
},
|
||||
);
|
||||
this.activePrompt = { turnId, settled };
|
||||
this.activePrompt = { turnId, settled, cancelling: false };
|
||||
void settled.finally(() => {
|
||||
if (this.activePrompt?.turnId === turnId) this.activePrompt = null;
|
||||
});
|
||||
}
|
||||
|
||||
interrupt(): Promise<void> {
|
||||
return this.call(this.connection.cancel({ sessionId: this.nativeSessionId }));
|
||||
async interrupt(): Promise<void> {
|
||||
const active = this.activePrompt;
|
||||
if (active) active.cancelling = true;
|
||||
try {
|
||||
await this.call(this.connection.cancel({ sessionId: this.nativeSessionId }));
|
||||
} finally {
|
||||
// An agent may wait for its outstanding permission replies before ending the prompt.
|
||||
if (active) this.finishTurnPermissions(active.turnId);
|
||||
}
|
||||
}
|
||||
|
||||
listSessions(cwd?: string) {
|
||||
@@ -688,19 +720,37 @@ class AcpRuntime {
|
||||
response: Extract<ProviderInput, { type: "session.permission" }>["response"],
|
||||
): void {
|
||||
const pending = this.permissions.get(permissionId);
|
||||
if (!pending) throw new Error(`Unknown ACP permission: ${permissionId}`);
|
||||
if (!pending) return;
|
||||
const active = this.activePrompt;
|
||||
if (active?.cancelling && pending.turnId === active.turnId) return;
|
||||
const selected = selectPermissionOption(pending.request.options, response);
|
||||
if (response.selectedActionId !== undefined && !selected) {
|
||||
throw new Error(
|
||||
`ACP permission action '${response.selectedActionId}' does not exist or does not match '${response.behavior}' behavior`,
|
||||
);
|
||||
}
|
||||
this.permissions.delete(permissionId);
|
||||
pending.resolve({
|
||||
this.resolvePermission(permissionId, pending, {
|
||||
outcome: selected
|
||||
? { outcome: "selected", optionId: selected.optionId }
|
||||
: { outcome: "cancelled" },
|
||||
});
|
||||
}
|
||||
|
||||
private finishTurnPermissions(turnId: string): void {
|
||||
for (const [permissionId, pending] of this.permissions) {
|
||||
if (pending.turnId === turnId) {
|
||||
this.resolvePermission(permissionId, pending, { outcome: { outcome: "cancelled" } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private resolvePermission(
|
||||
permissionId: string,
|
||||
pending: PendingPermission,
|
||||
response: RequestPermissionResponse,
|
||||
): void {
|
||||
this.permissions.delete(permissionId);
|
||||
pending.resolve(response);
|
||||
this.emit({
|
||||
type: "session.permission_resolved",
|
||||
sessionId: this.options.boundarySessionId,
|
||||
@@ -711,6 +761,17 @@ class AcpRuntime {
|
||||
async configure(
|
||||
changes: Extract<ProviderInput, { type: "session.configure" }>["changes"],
|
||||
): Promise<void> {
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
if (
|
||||
autoAcceptMode &&
|
||||
changes.mode !== undefined &&
|
||||
(changes.mode === autoAcceptMode.mode.id) !== this.autoAccept &&
|
||||
(this.activePrompt || this.permissions.size > 0)
|
||||
) {
|
||||
throw new Error(
|
||||
`Finish or stop the current turn before switching to or from ${autoAcceptMode.mode.label}.`,
|
||||
);
|
||||
}
|
||||
const requested: AcpConfigChange[] = [];
|
||||
if (changes.model !== undefined) requested.push({ target: "model", value: changes.model });
|
||||
if (changes.mode !== undefined) requested.push({ target: "mode", value: changes.mode });
|
||||
@@ -721,6 +782,7 @@ class AcpRuntime {
|
||||
requested.push({ target: "setting", id, value });
|
||||
}
|
||||
const ordered = this.inAgentOrder(requested);
|
||||
const previousAutoAccept = this.autoAccept;
|
||||
const previousModes = this.modes ? structuredClone(this.modes) : null;
|
||||
const previousOptions = structuredClone(this.configOptions);
|
||||
this.configTransaction = true;
|
||||
@@ -746,6 +808,7 @@ class AcpRuntime {
|
||||
await this.close();
|
||||
throw failure;
|
||||
}
|
||||
this.autoAccept = previousAutoAccept;
|
||||
this.modes = previousModes;
|
||||
this.configOptions = previousOptions;
|
||||
this.stagedTransformerConfig = null;
|
||||
@@ -788,7 +851,9 @@ class AcpRuntime {
|
||||
private async applyInitialConfig(config: ProviderSessionConfig): Promise<void> {
|
||||
const requested: AcpConfigChange[] = [];
|
||||
if (config.model) requested.push({ target: "model", value: config.model });
|
||||
if (config.mode) requested.push({ target: "mode", value: config.mode });
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
const mode = config.mode ?? (autoAcceptMode?.default ? autoAcceptMode.mode.id : undefined);
|
||||
if (mode) requested.push({ target: "mode", value: mode });
|
||||
if (config.thinkingOption) {
|
||||
requested.push({ target: "thinking", value: config.thinkingOption });
|
||||
}
|
||||
@@ -815,23 +880,47 @@ class AcpRuntime {
|
||||
if (change.target === "thinking") {
|
||||
return this.configOptions.find((option) => option.category === "thought_level")?.id;
|
||||
}
|
||||
return this.configOptions.find((option) => option.category === "mode")?.id;
|
||||
return modeOption(this.configOptions)?.id;
|
||||
}
|
||||
|
||||
private async applyConfigChange(change: AcpConfigChange): Promise<void> {
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
if (
|
||||
change.target === "mode" &&
|
||||
autoAcceptMode &&
|
||||
(this.autoAccept || change.value === autoAcceptMode.mode.id)
|
||||
) {
|
||||
const enableAutoAccept = change.value === autoAcceptMode.mode.id;
|
||||
const nativeMode = enableAutoAccept ? autoAcceptMode.nativeMode : change.value;
|
||||
this.autoAccept = false;
|
||||
if (nativeMode !== this.nativeModeId()) {
|
||||
await this.applyNativeConfigChange({ target: "mode", value: nativeMode });
|
||||
}
|
||||
if (nativeMode !== this.nativeModeId()) {
|
||||
throw new Error(`ACP agent did not switch to mode '${nativeMode}'`);
|
||||
}
|
||||
this.autoAccept = enableAutoAccept;
|
||||
return;
|
||||
}
|
||||
const access = this.configAccess();
|
||||
for (const transformer of this.transformers) {
|
||||
if (
|
||||
(await transformer.configure?.(change, {
|
||||
sessionId: this.options.boundarySessionId,
|
||||
config: access,
|
||||
catalog: () => toProviderCatalog(this.modes, this.configOptions),
|
||||
apply: (nativeChange) => this.applyNativeConfigChange(nativeChange),
|
||||
})) === "handled"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (change.target === "mode") {
|
||||
if (!change.value || !this.modes) {
|
||||
await this.applyNativeConfigChange(change);
|
||||
}
|
||||
|
||||
private async applyNativeConfigChange(change: AcpConfigChange): Promise<void> {
|
||||
if (change.target === "mode" && this.modes && !modeOption(this.configOptions)) {
|
||||
if (!change.value) {
|
||||
throw new Error("ACP session does not expose mode configuration");
|
||||
}
|
||||
await this.call(
|
||||
@@ -886,7 +975,20 @@ class AcpRuntime {
|
||||
this.emitConfigSnapshot(toProviderConfigState(this.modes, this.configOptions));
|
||||
}
|
||||
|
||||
private nativeModeId(): string | undefined {
|
||||
return selectedValue(modeOption(this.configOptions)) ?? this.modes?.currentModeId;
|
||||
}
|
||||
|
||||
private emitConfigSnapshot(config: ProviderConfigState): void {
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
if (autoAcceptMode) {
|
||||
if (this.nativeModeId() !== autoAcceptMode.nativeMode) this.autoAccept = false;
|
||||
config = {
|
||||
...config,
|
||||
mode: this.autoAccept ? autoAcceptMode.mode.id : config.mode,
|
||||
modes: [...config.modes, { ...autoAcceptMode.mode, isUnattended: true }],
|
||||
};
|
||||
}
|
||||
this.emit({
|
||||
type: "session.config",
|
||||
sessionId: this.options.boundarySessionId,
|
||||
@@ -898,7 +1000,11 @@ class AcpRuntime {
|
||||
modes: NewSessionResponse["modes"],
|
||||
options: readonly SessionConfigOption[],
|
||||
): Promise<void> {
|
||||
if (modes?.currentModeId && this.modes?.currentModeId !== modes.currentModeId) {
|
||||
if (
|
||||
!modeOption(options) &&
|
||||
modes?.currentModeId &&
|
||||
this.modes?.currentModeId !== modes.currentModeId
|
||||
) {
|
||||
await this.call(
|
||||
this.connection.setSessionMode({
|
||||
sessionId: this.nativeSessionId,
|
||||
@@ -920,10 +1026,30 @@ class AcpRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
private requestPermission(request: RequestPermissionRequest): Promise<RequestPermissionResponse> {
|
||||
private async requestPermission(
|
||||
request: RequestPermissionRequest,
|
||||
): Promise<RequestPermissionResponse> {
|
||||
await this.notificationLane;
|
||||
if (this.closing || this.processFailed || this.activePrompt?.cancelling) {
|
||||
return { outcome: { outcome: "cancelled" } };
|
||||
}
|
||||
if (
|
||||
this.autoAccept &&
|
||||
request.sessionId === this.nativeSessionId &&
|
||||
this.nativeModeId() === this.options.options.acpOptions?.autoAcceptMode?.nativeMode
|
||||
) {
|
||||
const allowOptions = request.options.filter((option) => option.kind.startsWith("allow"));
|
||||
const allowOnce = allowOptions.find((option) => option.kind === "allow_once");
|
||||
if (
|
||||
allowOnce &&
|
||||
new Set(allowOptions.map((option) => option.kind)).size === allowOptions.length
|
||||
) {
|
||||
return { outcome: { outcome: "selected", optionId: allowOnce.optionId } };
|
||||
}
|
||||
}
|
||||
const permissionId = `permission:${request.toolCall.toolCallId}`;
|
||||
return new Promise((resolve) => {
|
||||
this.permissions.set(permissionId, { request, resolve });
|
||||
this.permissions.set(permissionId, { request, resolve, turnId: this.activePrompt?.turnId });
|
||||
this.emit({
|
||||
type: "session.permission",
|
||||
sessionId: this.options.boundarySessionId,
|
||||
@@ -945,7 +1071,19 @@ class AcpRuntime {
|
||||
|
||||
private sessionUpdate(notification: SessionNotification): void {
|
||||
if (notification.sessionId !== this.nativeSessionId) return;
|
||||
if (this.replayWindow === "skip") return;
|
||||
if (this.replayWindow) this.lastLoadUpdateAt = performance.now();
|
||||
if (this.replayWindow === "skip") {
|
||||
const update = notification.update;
|
||||
if (
|
||||
update.sessionUpdate === "available_commands_update" ||
|
||||
update.sessionUpdate === "config_option_update" ||
|
||||
update.sessionUpdate === "current_mode_update" ||
|
||||
update.sessionUpdate === "usage_update"
|
||||
) {
|
||||
this.reduceStateUpdate(update);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.replayWindow === "replay" &&
|
||||
notification.update.sessionUpdate === "user_message_chunk"
|
||||
@@ -1067,11 +1205,17 @@ class AcpRuntime {
|
||||
argumentHint: command.input?.hint,
|
||||
}));
|
||||
this.emit({ type: "session.commands", sessionId: this.options.boundarySessionId, commands });
|
||||
this.receivedInitialCommands = true;
|
||||
this.commandWaiter?.();
|
||||
this.commandWaiter = null;
|
||||
return;
|
||||
}
|
||||
if (update.sessionUpdate === "current_mode_update") {
|
||||
const option = modeOption(this.configOptions);
|
||||
if (option?.type === "select") {
|
||||
this.configOptions = this.configOptions.map((candidate) =>
|
||||
candidate === option ? { ...option, currentValue: update.currentModeId } : candidate,
|
||||
);
|
||||
}
|
||||
if (this.modes) this.modes = { ...this.modes, currentModeId: update.currentModeId };
|
||||
this.emitConfig();
|
||||
return;
|
||||
@@ -1236,16 +1380,28 @@ class AcpRuntime {
|
||||
}
|
||||
|
||||
private waitForInitialCommands(): Promise<void> {
|
||||
if (this.receivedInitialCommands) return Promise.resolve();
|
||||
const timeoutMs = this.options.options.acpOptions?.initialCommandsTimeoutMs ?? 1_000;
|
||||
const commands = new Promise<void>((resolve) => {
|
||||
this.commandWaiter = resolve;
|
||||
});
|
||||
const timeout = new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, timeoutMs);
|
||||
});
|
||||
return Promise.race([commands, timeout]).finally(() => {
|
||||
this.commandWaiter = null;
|
||||
});
|
||||
return withTimeout(commands, timeoutMs, "ACP agent did not publish initial commands")
|
||||
.catch(() => undefined)
|
||||
.finally(() => {
|
||||
this.commandWaiter = null;
|
||||
});
|
||||
}
|
||||
|
||||
private async waitForLoadReplay(quietPeriod: number): Promise<void> {
|
||||
const start = performance.now();
|
||||
const deadline = start + 5 * quietPeriod;
|
||||
while (!this.closing && !this.processFailed) {
|
||||
const idleAt = Math.max(start, this.lastLoadUpdateAt) + quietPeriod;
|
||||
const remaining = Math.min(deadline, idleAt) - performance.now();
|
||||
if (remaining <= 0) return;
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, remaining));
|
||||
await this.notificationLane;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1412,17 +1568,23 @@ function toProviderConfigState(
|
||||
): ProviderConfigState {
|
||||
const model = modelOption(options);
|
||||
const thinking = options.find((option) => option.category === "thought_level");
|
||||
const modeConfig = modeOption(options);
|
||||
return {
|
||||
model: selectedValue(model),
|
||||
mode: modes?.currentModeId,
|
||||
mode: selectedValue(modeConfig) ?? modes?.currentModeId,
|
||||
thinkingOption: selectedValue(thinking),
|
||||
models: selectOptions(model).map((option) => ({ id: option.value, label: option.label })),
|
||||
modes:
|
||||
modes?.availableModes.map((mode) => ({
|
||||
id: mode.id,
|
||||
label: mode.name,
|
||||
description: mode.description ?? undefined,
|
||||
})) ?? [],
|
||||
modes: modeConfig
|
||||
? selectOptions(modeConfig).map((option) => ({
|
||||
id: option.value,
|
||||
label: option.label,
|
||||
description: option.description,
|
||||
}))
|
||||
: (modes?.availableModes.map((mode) => ({
|
||||
id: mode.id,
|
||||
label: mode.name,
|
||||
description: mode.description ?? undefined,
|
||||
})) ?? []),
|
||||
thinkingOptions: selectOptions(thinking).map((option) => ({
|
||||
id: option.value,
|
||||
label: option.label,
|
||||
@@ -1430,9 +1592,7 @@ function toProviderConfigState(
|
||||
settings: options
|
||||
.filter(
|
||||
(option) =>
|
||||
option !== model &&
|
||||
option.category !== "thought_level" &&
|
||||
!(modes && option.category === "mode"),
|
||||
option !== model && option.category !== "thought_level" && option !== modeConfig,
|
||||
)
|
||||
.map(toProviderSetting),
|
||||
};
|
||||
@@ -1445,6 +1605,10 @@ function modelOption(options: readonly SessionConfigOption[]): SessionConfigOpti
|
||||
return candidates.find((option) => option.id === "model") ?? candidates[0];
|
||||
}
|
||||
|
||||
function modeOption(options: readonly SessionConfigOption[]): SessionConfigOption | undefined {
|
||||
return options.find((option) => option.category === "mode" && option.type === "select");
|
||||
}
|
||||
|
||||
function toProviderCatalog(
|
||||
modes: NewSessionResponse["modes"],
|
||||
options: readonly SessionConfigOption[],
|
||||
@@ -1476,18 +1640,28 @@ function toProviderSetting(option: SessionConfigOption): ProviderSetting {
|
||||
label: option.name,
|
||||
description: option.description ?? undefined,
|
||||
value: option.currentValue,
|
||||
options: selectOptions(option),
|
||||
options: selectOptions(option).map(({ label, value }) => ({ label, value })),
|
||||
};
|
||||
}
|
||||
|
||||
function selectOptions(
|
||||
option: SessionConfigOption | undefined,
|
||||
): Array<{ label: string; value: string }> {
|
||||
): Array<{ label: string; value: string; description?: string }> {
|
||||
if (!option || option.type === "boolean") return [];
|
||||
return option.options.flatMap((candidate) =>
|
||||
"group" in candidate
|
||||
? candidate.options.map((nested) => ({ label: nested.name, value: nested.value }))
|
||||
: [{ label: candidate.name, value: candidate.value }],
|
||||
? candidate.options.map((nested) => ({
|
||||
label: nested.name,
|
||||
value: nested.value,
|
||||
description: nested.description ?? undefined,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
label: candidate.name,
|
||||
value: candidate.value,
|
||||
description: candidate.description ?? undefined,
|
||||
},
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1506,16 +1680,18 @@ type ToolCallTimelineItem = Extract<ProviderTimelineItem, { type: "tool_call" }>
|
||||
function toolTimelineItem(snapshot: AcpToolCallSnapshot): ToolCallTimelineItem {
|
||||
const input = jsonRecord(snapshot.input);
|
||||
const isEdit = snapshot.kind === "edit" || snapshot.name?.toLowerCase().includes("edit") === true;
|
||||
const detail = isEdit
|
||||
? {
|
||||
type: "edit" as const,
|
||||
filePath:
|
||||
typeof input.filePath === "string" ? input.filePath : (snapshot.locations[0] ?? ""),
|
||||
oldString: typeof input.oldString === "string" ? input.oldString : undefined,
|
||||
newString: typeof input.newString === "string" ? input.newString : undefined,
|
||||
unifiedDiff: typeof input.unifiedDiff === "string" ? input.unifiedDiff : undefined,
|
||||
}
|
||||
: { type: "unknown" as const, input: snapshot.input, output: snapshot.output };
|
||||
const detail =
|
||||
snapshot.detail ??
|
||||
(isEdit
|
||||
? {
|
||||
type: "edit" as const,
|
||||
filePath:
|
||||
typeof input.filePath === "string" ? input.filePath : (snapshot.locations[0] ?? ""),
|
||||
oldString: typeof input.oldString === "string" ? input.oldString : undefined,
|
||||
newString: typeof input.newString === "string" ? input.newString : undefined,
|
||||
unifiedDiff: typeof input.unifiedDiff === "string" ? input.unifiedDiff : undefined,
|
||||
}
|
||||
: { type: "unknown" as const, input: snapshot.input, output: snapshot.output });
|
||||
const status =
|
||||
snapshot.status === "in_progress" || snapshot.status === "pending"
|
||||
? "running"
|
||||
|
||||
@@ -52,7 +52,7 @@ function openInput(
|
||||
type: "session.open",
|
||||
requestId: "open-1",
|
||||
sessionId: "session-1",
|
||||
config: { cwd: "/repo", env: {}, mcpServers: {}, settings, persist: true },
|
||||
config: { cwd: process.cwd(), env: {}, mcpServers: {}, settings, persist: true },
|
||||
history: "skip",
|
||||
};
|
||||
}
|
||||
@@ -226,6 +226,306 @@ lines.on("line", (line) => {
|
||||
});`;
|
||||
|
||||
describe("runAcpProvider", () => {
|
||||
it.each(["replay", "skip"] as const)(
|
||||
"handles trailing load updates with %s history",
|
||||
async (history) => {
|
||||
const sessionId = "connector-session";
|
||||
const notifyUpdate = (runtime: ConnectorInstance, update: unknown) =>
|
||||
runtime.notify("session/update", { sessionId, update });
|
||||
const { connector, instances } = connectorHarness({
|
||||
capabilities: { loadSession: true },
|
||||
handleRequest(runtime, request) {
|
||||
if (request.method !== "session/load") return false;
|
||||
notifyUpdate(runtime, {
|
||||
sessionUpdate: "available_commands_update",
|
||||
availableCommands: [{ name: "help", description: "Help" }],
|
||||
});
|
||||
runtime.respond(request, { configOptions: [] });
|
||||
setTimeout(() => {
|
||||
notifyUpdate(runtime, {
|
||||
sessionUpdate: "user_message_chunk",
|
||||
content: { type: "text", text: "previous question" },
|
||||
});
|
||||
notifyUpdate(runtime, {
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: { type: "text", text: "previous answer" },
|
||||
});
|
||||
}, 100);
|
||||
return true;
|
||||
},
|
||||
});
|
||||
const connection = await runAcpProvider({
|
||||
id: "load",
|
||||
label: "Load",
|
||||
connector,
|
||||
acpOptions: {
|
||||
waitForInitialCommands: true,
|
||||
initialCommandsTimeoutMs: 10_000,
|
||||
loadReplayQuietPeriodMs: 200,
|
||||
},
|
||||
}).connect({ versions: [1], capabilities: ["prompt.message", "session.persistence"] });
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
try {
|
||||
await connection.send({
|
||||
...openInput(),
|
||||
history,
|
||||
persistence: { version: 1, data: { sessionId } },
|
||||
});
|
||||
await waitForEvent(events, (event) => event.type === "session.ready");
|
||||
notifyUpdate(instances[1], {
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: { type: "text", text: "stale history outside the replay window" },
|
||||
});
|
||||
notifyUpdate(instances[1], {
|
||||
sessionUpdate: "available_commands_update",
|
||||
availableCommands: [{ name: "different", description: "Different" }],
|
||||
});
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) => event.type === "session.commands" && event.commands[0]?.name === "different",
|
||||
);
|
||||
const items = events
|
||||
.filter((event) => event.type === "timeline.item")
|
||||
.map((event) => event.item);
|
||||
expect(items).toEqual(
|
||||
history === "skip"
|
||||
? []
|
||||
: [
|
||||
expect.objectContaining({ type: "user_message", text: "previous question" }),
|
||||
expect.objectContaining({ type: "assistant_message", text: "previous answer" }),
|
||||
],
|
||||
);
|
||||
expect(events.some((event) => event.type === "session.turn")).toBe(false);
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("auto-accepts ordinary permissions only in the unattended mode and refuses to switch while busy", async () => {
|
||||
const modeConfig = {
|
||||
id: "mode",
|
||||
name: "Mode",
|
||||
category: "mode",
|
||||
type: "select",
|
||||
currentValue: "default",
|
||||
options: [
|
||||
{ value: "default", name: "Default" },
|
||||
{ value: "plan", name: "Plan" },
|
||||
],
|
||||
};
|
||||
const approval = {
|
||||
sessionId: "connector-session",
|
||||
toolCall: { toolCallId: "tool", title: "Write a file", rawInput: {} },
|
||||
options: [
|
||||
{ optionId: "always", name: "Always allow", kind: "allow_always" },
|
||||
{ optionId: "once", name: "Allow once", kind: "allow_once" },
|
||||
{ optionId: "deny", name: "Deny", kind: "reject_once" },
|
||||
],
|
||||
};
|
||||
let finishPrompt: (() => void) | undefined;
|
||||
let stopping = false;
|
||||
const outcomes: unknown[] = [];
|
||||
const { connector } = connectorHarness({
|
||||
configOptions: [modeConfig],
|
||||
handleMessage(_runtime, message) {
|
||||
if (!("method" in message) || message.method !== "session/cancel") return false;
|
||||
stopping = true;
|
||||
return true;
|
||||
},
|
||||
handleRequest(runtime, request) {
|
||||
if (request.method !== "session/prompt") return false;
|
||||
void runtime.request("session/request_permission", approval).then((outcome) => {
|
||||
outcomes.push(outcome);
|
||||
if (stopping) {
|
||||
stopping = false;
|
||||
runtime.respond(request, { stopReason: "cancelled" });
|
||||
} else {
|
||||
finishPrompt = () => runtime.respond(request, { stopReason: "end_turn" });
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
return true;
|
||||
},
|
||||
});
|
||||
const connection = await runAcpProvider({
|
||||
id: "unattended",
|
||||
label: "Unattended",
|
||||
connector,
|
||||
acpOptions: {
|
||||
autoAcceptMode: {
|
||||
mode: { id: "full-access", label: "Full access" },
|
||||
nativeMode: "default",
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
}).connect({
|
||||
versions: [1],
|
||||
capabilities: ["prompt.message", "session.configure", "permission"],
|
||||
});
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
const configure = async (requestId: string, mode: string) => {
|
||||
await connection.send({
|
||||
type: "session.configure",
|
||||
requestId,
|
||||
sessionId: "session-1",
|
||||
changes: { mode },
|
||||
});
|
||||
return waitForEvent(events, (event) => "requestId" in event && event.requestId === requestId);
|
||||
};
|
||||
const prompt = (id: string) =>
|
||||
connection.send({
|
||||
type: "session.prompt",
|
||||
sessionId: "session-1",
|
||||
prompt: {
|
||||
clientMessageId: id,
|
||||
delivery: "auto",
|
||||
input: { type: "message", content: [{ type: "text", text: id }] },
|
||||
},
|
||||
});
|
||||
try {
|
||||
await connection.send({ type: "catalog", requestId: "catalog" });
|
||||
expect(await waitForEvent(events, (event) => event.type === "catalog")).toMatchObject({
|
||||
catalog: {
|
||||
defaultMode: "full-access",
|
||||
modes: expect.arrayContaining([
|
||||
{ id: "full-access", label: "Full access", isUnattended: true },
|
||||
]),
|
||||
},
|
||||
});
|
||||
await connection.send(openInput());
|
||||
await waitForEvent(events, (event) => event.type === "session.ready");
|
||||
await prompt("unattended");
|
||||
await expect
|
||||
.poll(() => outcomes[0])
|
||||
.toEqual({ outcome: { outcome: "selected", optionId: "once" } });
|
||||
expect(events.some((event) => event.type === "session.permission")).toBe(false);
|
||||
expect(await configure("busy", "plan")).toMatchObject({ type: "request.failed" });
|
||||
finishPrompt!();
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) => event.type === "session.turn" && event.state === "completed",
|
||||
);
|
||||
expect(await configure("leave", "default")).toMatchObject({ type: "request.completed" });
|
||||
|
||||
await prompt("interactive");
|
||||
await waitForEvent(events, (event) => event.type === "session.permission");
|
||||
expect(await configure("pending", "full-access")).toMatchObject({ type: "request.failed" });
|
||||
expect(outcomes).toHaveLength(1);
|
||||
await connection.send({
|
||||
type: "session.interrupt",
|
||||
requestId: "stop",
|
||||
sessionId: "session-1",
|
||||
});
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) =>
|
||||
event.type === "session.turn" &&
|
||||
event.turnId === "acp:interactive" &&
|
||||
event.state === "canceled",
|
||||
);
|
||||
await expect.poll(() => outcomes[1]).toEqual({ outcome: { outcome: "cancelled" } });
|
||||
await connection.send({
|
||||
type: "session.permission",
|
||||
sessionId: "session-1",
|
||||
permissionId: "permission:tool",
|
||||
response: { behavior: "allow" },
|
||||
});
|
||||
expect(await configure("enter", "full-access")).toMatchObject({ type: "request.completed" });
|
||||
expect(events.some((event) => event.type === "session.runtime_failed")).toBe(false);
|
||||
expect(
|
||||
events.filter((event) => event.type === "session.config").map((event) => event.config.mode),
|
||||
).toEqual(["full-access", "default", "full-access"]);
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts a prompt as soon as the session reports ready", async () => {
|
||||
const { connector } = connectorHarness();
|
||||
const connection = await runAcpProvider({
|
||||
id: "ready-acp",
|
||||
label: "Ready ACP",
|
||||
connector,
|
||||
}).connect({ versions: [1], capabilities: ["prompt.message"] });
|
||||
try {
|
||||
const prompted = Promise.withResolvers<void>();
|
||||
connection.onEvent((event) => {
|
||||
if (event.type !== "session.ready") return;
|
||||
void connection
|
||||
.send({
|
||||
type: "session.prompt",
|
||||
sessionId: event.sessionId!,
|
||||
prompt: {
|
||||
clientMessageId: "first",
|
||||
delivery: "auto",
|
||||
input: { type: "message", content: [{ type: "text", text: "Hi" }] },
|
||||
},
|
||||
})
|
||||
.then(prompted.resolve, prompted.reject);
|
||||
});
|
||||
await connection.send(openInput());
|
||||
await prompted.promise;
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("uses config options for mode selection when the agent exposes no legacy modes", async () => {
|
||||
const { connector } = connectorHarness({
|
||||
configOptions: [
|
||||
{
|
||||
id: "permissions",
|
||||
category: "mode",
|
||||
name: "Permissions",
|
||||
type: "select",
|
||||
currentValue: "default",
|
||||
options: [
|
||||
{ value: "default", name: "Default" },
|
||||
{ value: "edit", name: "Accept edits" },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
const connection = await runAcpProvider({ id: "modes", label: "Modes", connector }).connect({
|
||||
versions: [1],
|
||||
capabilities: ["session.configure"],
|
||||
});
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
try {
|
||||
const input = openInput();
|
||||
input.config.mode = "edit";
|
||||
await connection.send(input);
|
||||
expect(
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) => event.type === "session.config" || event.type === "request.failed",
|
||||
),
|
||||
).toMatchObject({
|
||||
type: "session.config",
|
||||
config: { mode: "edit", modes: [{ id: "default" }, { id: "edit" }], settings: [] },
|
||||
});
|
||||
await waitForEvent(events, (event) => event.type === "session.ready");
|
||||
await connection.send({
|
||||
type: "session.configure",
|
||||
requestId: "default",
|
||||
sessionId: input.sessionId,
|
||||
changes: { mode: "default" },
|
||||
});
|
||||
expect(
|
||||
await waitForEvent(
|
||||
events,
|
||||
(event) => event.type === "session.config" && event.config.mode === "default",
|
||||
),
|
||||
).toBeDefined();
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("spawns the daemon-resolved launch for probes, catalogues, listing, and sessions", async () => {
|
||||
const executable = await fakeAcp(`
|
||||
if (process.env.LAUNCH_TOKEN !== "resolved" || process.env.CLAUDECODE || process.env.PASEO_NODE_ENV) process.exit(1);
|
||||
@@ -236,7 +536,7 @@ lines.on("line", (line) => {
|
||||
const message = JSON.parse(line);
|
||||
let result;
|
||||
if (message.method === "initialize") result = { protocolVersion: message.params.protocolVersion, agentCapabilities: { sessionCapabilities: { list: {} } } };
|
||||
else if (message.method === "session/new") result = { sessionId: "native", configOptions: [{ id: "model", name: "Model", category: "model", type: "select", currentValue: "resolved", options: [{ value: "resolved", name: process.env.SESSION_TOKEN || "probe" }] }] };
|
||||
else if (message.method === "session/new") result = { sessionId: "native", configOptions: [{ id: "model", name: "Model", category: "model", type: "select", currentValue: "resolved", options: [{ value: "resolved", name: require("node:fs").realpathSync(message.params.cwd) === process.cwd() ? (process.env.SESSION_TOKEN || "probe") : "wrong cwd" }] }] };
|
||||
else if (message.method === "session/list") result = { sessions: [] };
|
||||
else return;
|
||||
send({ jsonrpc: "2.0", id: message.id, result });
|
||||
@@ -254,7 +554,11 @@ lines.on("line", (line) => {
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
try {
|
||||
await connection.send({ type: "catalog", requestId: "catalog" });
|
||||
await connection.send({
|
||||
type: "catalog",
|
||||
requestId: "catalog",
|
||||
cwd: path.dirname(executable),
|
||||
});
|
||||
expect(await waitForEvent(events, (event) => event.type === "catalog")).toMatchObject({
|
||||
catalog: { models: [{ id: "resolved", label: "probe" }] },
|
||||
});
|
||||
@@ -264,6 +568,7 @@ lines.on("line", (line) => {
|
||||
});
|
||||
const input = openInput();
|
||||
input.config.env = { SESSION_TOKEN: "session" };
|
||||
input.config.cwd = path.dirname(executable);
|
||||
await connection.send(input);
|
||||
expect(await waitForEvent(events, (event) => event.type === "session.config")).toMatchObject({
|
||||
config: { models: [{ id: "resolved", label: "session" }] },
|
||||
|
||||
@@ -3,9 +3,12 @@ import type {
|
||||
ProviderCatalog,
|
||||
ProviderCommand,
|
||||
ProviderConfigState,
|
||||
ProviderMode,
|
||||
ProviderNotice,
|
||||
ProviderPersistence,
|
||||
ProviderRegistration,
|
||||
ProviderTimelineItem,
|
||||
ProviderToolCallDetail,
|
||||
} from "./provider.js";
|
||||
import { createAcpProviderConnection } from "./acp-internal/connection.js";
|
||||
|
||||
@@ -48,6 +51,14 @@ export interface AcpOptions {
|
||||
workspaceOnlyCatalog?: boolean;
|
||||
waitForInitialCommands?: boolean;
|
||||
initialCommandsTimeoutMs?: number;
|
||||
/** Allow delayed session/load updates before publishing the session as ready. */
|
||||
loadReplayQuietPeriodMs?: number;
|
||||
/** An unattended mode that approves ACP allow-once requests in the specified native mode. */
|
||||
autoAcceptMode?: {
|
||||
mode: Omit<ProviderMode, "isUnattended">;
|
||||
nativeMode: string;
|
||||
default?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AcpContext {
|
||||
@@ -65,6 +76,8 @@ export interface AcpDiscoveryContext extends AcpContext {
|
||||
|
||||
export interface AcpConfigureContext extends AcpContext {
|
||||
config: AcpConfigAccess;
|
||||
catalog(): ProviderCatalog;
|
||||
apply(change: AcpConfigChange): Promise<void>;
|
||||
}
|
||||
|
||||
export type AcpConfigChange =
|
||||
@@ -82,6 +95,7 @@ export interface AcpToolCallSnapshot {
|
||||
input: JsonValue;
|
||||
output: JsonValue;
|
||||
locations: readonly string[];
|
||||
detail?: ProviderToolCallDetail;
|
||||
}
|
||||
|
||||
export type AcpVendorUpdate =
|
||||
@@ -91,6 +105,13 @@ export type AcpVendorUpdate =
|
||||
| { type: "notice"; notice: ProviderNotice };
|
||||
|
||||
export interface AcpTransformer {
|
||||
/** Decode an older saved session and supply extension metadata for session/new or session/load. */
|
||||
sessionOpen?(context: {
|
||||
persistence?: ProviderPersistence;
|
||||
systemPrompt?: string;
|
||||
agentMetadata: JsonValue;
|
||||
}): { sessionId?: string; metadata?: Readonly<Record<string, JsonValue>> };
|
||||
|
||||
discover?(
|
||||
catalog: ProviderCatalog,
|
||||
context: AcpDiscoveryContext,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user