mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-26 03:03:04 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52d345db7f | ||
|
|
a50a476009 | ||
|
|
6ca001c3e4 | ||
|
|
78a0f093eb | ||
|
|
d7b7016cc9 |
@@ -1,5 +1,48 @@
|
||||
# Changelog
|
||||
|
||||
## 0.10.0-beta.1 - 2026-09-27
|
||||
|
||||
### Added
|
||||
|
||||
- Added OpenCode v2 support, selected automatically from the installed `opencode` version ([#5198](https://github.com/getpaseo/paseo/pull/5198) by [@karrots](https://github.com/karrots), [@dsingal0](https://github.com/dsingal0))
|
||||
- Added task lists from rpiv-todo, pi-goal-x, and Pi's example todo extension to Pi chats ([#5309](https://github.com/getpaseo/paseo/pull/5309))
|
||||
- Added subagent runs from pi-subagents, Tintinweb pi-subagents, and Gotgenes pi-subagents to the Subagents track ([#5309](https://github.com/getpaseo/paseo/pull/5309))
|
||||
- Added rpiv-ask-user-question dialogs to Pi chats as one question form ([#5309](https://github.com/getpaseo/paseo/pull/5309))
|
||||
- Added password checks to relay connections, rejecting an incorrect daemon password; a follow-up release will require the password ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Added a password field to Add host, pairing links, and QR pairing for password-protected daemons ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Added `relay://` connection strings to `paseo daemon pair` ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Added OMP Ask option descriptions to question cards on OMP 17.4.2 and newer ([#3628](https://github.com/getpaseo/paseo/pull/3628) by [@joeshull](https://github.com/joeshull))
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed the CLI and desktop app to connect to a password-protected daemon on the same machine without asking for the password ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Changed a host rejected for its password to show "Password required" or "Incorrect password" on the host and Connections pages ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Reorganized Settings into General, Sidebar, Chat, Terminal, Browser, and Open location pages ([#5459](https://github.com/getpaseo/paseo/pull/5459))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed direct connections failing when the daemon password contains spaces or characters such as `@` or `/` ([#5393](https://github.com/getpaseo/paseo/pull/5393))
|
||||
- Fixed existing OpenCode agents failing with `ECONNREFUSED` after the OpenCode server restarts ([#5338](https://github.com/getpaseo/paseo/pull/5338))
|
||||
- Fixed messages OpenCode adds on its own appearing in the chat as if the user typed them ([#5434](https://github.com/getpaseo/paseo/pull/5434))
|
||||
- Fixed the daemon stopping when `daemon.log` cannot be written, such as on a full disk ([#5445](https://github.com/getpaseo/paseo/pull/5445))
|
||||
- Fixed the daemon crashing when opening an archived ACP agent whose worktree was removed ([#5439](https://github.com/getpaseo/paseo/pull/5439) by [@qinkangdeid](https://github.com/qinkangdeid))
|
||||
- Fixed existing workspaces missing from the sidebar after the app starts, including after later restarts ([#5394](https://github.com/getpaseo/paseo/pull/5394))
|
||||
- Fixed agents on a custom Claude provider with its own `CLAUDE_CONFIG_DIR` opening with an empty chat after a daemon restart ([#5437](https://github.com/getpaseo/paseo/pull/5437))
|
||||
- Fixed a custom Codex provider's sessions missing from Import session ([#5446](https://github.com/getpaseo/paseo/pull/5446))
|
||||
- Fixed Update daemon and Restart in host settings failing when a provider's version check takes over 1.5s ([#5372](https://github.com/getpaseo/paseo/pull/5372))
|
||||
- Fixed `paseo --host <other daemon> run` failing with "Caller agent not found" from inside an agent session ([#5392](https://github.com/getpaseo/paseo/pull/5392))
|
||||
- Fixed a Pi chat rewind going back further than the picked message after an earlier rewind ([#5383](https://github.com/getpaseo/paseo/pull/5383))
|
||||
- Fixed a Pi chat rewind being undone when the daemon restarts ([#5432](https://github.com/getpaseo/paseo/pull/5432))
|
||||
- Fixed Pi agents started without a model ignoring Pi's configured default model ([#5343](https://github.com/getpaseo/paseo/pull/5343))
|
||||
- Fixed project skills in a new agent's `/` menu staying stale after the checkout switches branches ([#5415](https://github.com/getpaseo/paseo/pull/5415))
|
||||
- Fixed slash commands missing from a new agent's `/` menu on custom ACP providers ([#5411](https://github.com/getpaseo/paseo/pull/5411))
|
||||
- Fixed a parent agent receiving a child's finish notification twice after prompting the running child ([#5407](https://github.com/getpaseo/paseo/pull/5407))
|
||||
- Fixed a blocking `send_agent_prompt` that outlasts its 30s wait never notifying the caller when the child finishes ([#5347](https://github.com/getpaseo/paseo/pull/5347))
|
||||
- Fixed OSC 8 terminal links showing a navigation prompt and opening a blank Paseo window ([#5388](https://github.com/getpaseo/paseo/pull/5388) by [@liujin0506](https://github.com/liujin0506))
|
||||
- Fixed the Theme menu not scrolling when plugin themes overflow the window ([#5374](https://github.com/getpaseo/paseo/pull/5374))
|
||||
- Fixed a message from today's weekday last week showing only the weekday instead of its date ([#5341](https://github.com/getpaseo/paseo/pull/5341))
|
||||
- Fixed `paseo daemon set-password` exiting silently when stdin is not a terminal ([#5358](https://github.com/getpaseo/paseo/pull/5358))
|
||||
|
||||
## 0.9.2 - 2026-09-24
|
||||
|
||||
### Added
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ Authoritative terminology. UI label wins. Don't invent synonyms; use what's here
|
||||
- **MR** — GitLab merge request. UI label for GitLab change requests only; do not use MR for GitHub/Gitea/Forgejo.
|
||||
- **Worktree** — Paseo-managed git worktree (`~/.paseo/worktrees/{name}`); also a `workspaceKind` value. User-facing creation treats it as the `worktree` workspace isolation choice. Code and `paseo.json` retain worktree terminology for git lifecycle implementation. Forbidden: "Checkout" as a product synonym.
|
||||
- **Repository / Remote** — Internal Git observations. They may produce mutable kind, branch, and project-grouping metadata but never the host-local project ID, root, display name, or workspace membership. No UI label.
|
||||
- **Sidebar items** — The top-level rows at the head of the app sidebar: New workspace, History, Search, Schedules, and every plugin sidebar contribution. Order and visibility are one per-device preference (`AppSettings.sidebarNavItems`); all of them may be off. UI: the "Sidebar" section on the Appearance settings page. Code: `packages/app/src/sidebar-nav/model.ts` resolves the list, and both the sidebar (`components/sidebar/sidebar-nav-rows.tsx`) and the settings section (`screens/settings/appearance/sidebar-nav-section.tsx`) read it through `useSidebarNavItems`. Never hardcode one of these rows or add a second place that decides which ones show. Don't confuse with **Explorer sidebar**.
|
||||
- **Sidebar items** — The top-level rows at the head of the app sidebar: New workspace, History, Search, Schedules, and every plugin sidebar contribution. Order and visibility are one per-device preference (`AppSettings.sidebarNavItems`); all of them may be off. UI: the Sidebar settings page. Code: `packages/app/src/sidebar-nav/model.ts` resolves the list, and both the sidebar (`components/sidebar/sidebar-nav-rows.tsx`) and the settings section (`screens/settings/sidebar/sidebar-nav-section.tsx`) read it through `useSidebarNavItems`. Never hardcode one of these rows or add a second place that decides which ones show. Don't confuse with **Explorer sidebar**.
|
||||
- **Explorer sidebar** — The dedicated navigation dock containing the Files and Changes trees. UI: "Explorer sidebar". Code: `packages/app/src/workspace-tabs/explorer-sidebar.ts`; persisted pane identifiers retain the `explorer` spelling. See [explorer-sidebar.md](explorer-sidebar.md).
|
||||
- **Side pane** — An ordinary right-side workspace pane used for content opened beside the user's work. It closes and participates in workspace splits like every other main-host pane. See [explorer-sidebar.md](explorer-sidebar.md#side-pane). Forbidden: "Side panel".
|
||||
- **Directory-backed surface** — A right-sidebar surface whose content is determined by the workspace's `cwd`, so two workspaces on the same directory see identical content: git diff/status, forge change-request info, file preview/explorer contents. Keyed by `(serverId, cwd)`, never `workspaceId`. See [architecture.md](architecture.md#right-sidebar-boundary-directory-backed-vs-workspace-owned).
|
||||
|
||||
Generated
+51
-51
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -42,13 +42,6 @@
|
||||
"ws": "^8.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/7zip-bin": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.2.0.tgz",
|
||||
"integrity": "sha512-ukTPVhqG4jNzMro2qA9HSCSSVJN3aN7tlb+hfqYCt3ER0yWroeA2VR38MNrOHLQ/cVj+DaIMad0kFCtWWowh/A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@0no-co/graphql.web": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.2.0.tgz",
|
||||
@@ -14390,6 +14383,13 @@
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/7zip-bin": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.2.0.tgz",
|
||||
"integrity": "sha512-ukTPVhqG4jNzMro2qA9HSCSSVJN3aN7tlb+hfqYCt3ER0yWroeA2VR38MNrOHLQ/cVj+DaIMad0kFCtWWowh/A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/abab": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
|
||||
@@ -33341,6 +33341,23 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-length": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/string-length/-/string-length-5.0.1.tgz",
|
||||
@@ -33515,23 +33532,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/stringify-entities": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz",
|
||||
@@ -36410,7 +36410,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -37476,12 +37476,12 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/server": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/server": "0.10.0-beta.1",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -37728,10 +37728,10 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/relay": "0.9.2",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/relay": "0.10.0-beta.1",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -37742,7 +37742,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/cli": "*",
|
||||
@@ -37986,7 +37986,7 @@
|
||||
},
|
||||
"packages/expo-two-way-audio": {
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -38882,7 +38882,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
"@codemirror/legacy-modes": "^6.5.3",
|
||||
@@ -38911,14 +38911,14 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^1.4.0",
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.1.0",
|
||||
@@ -38928,8 +38928,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"react": "~19.1.0",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -38951,7 +38951,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -38978,7 +38978,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.5.1",
|
||||
"tweetnacl": "^1.0.3",
|
||||
@@ -39196,16 +39196,16 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^0.17.1",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.246",
|
||||
"@anthropic-ai/sdk": "^0.104.2",
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/highlight": "0.9.2",
|
||||
"@getpaseo/plugin": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/relay": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/highlight": "0.10.0-beta.1",
|
||||
"@getpaseo/plugin": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/relay": "0.10.0-beta.1",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
@@ -40110,7 +40110,7 @@
|
||||
},
|
||||
"packages/website": {
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.29.1",
|
||||
"@cloudflare/workers-types": "^4.20260317.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -83,7 +83,7 @@ export async function splitCurrentPanelRight(page: Page): Promise<void> {
|
||||
export async function disableChatOutlineFromAppearance(page: Page): Promise<void> {
|
||||
const timelineUrl = page.url();
|
||||
await openSettings(page);
|
||||
await openSettingsSection(page, "appearance");
|
||||
await openSettingsSection(page, "chat");
|
||||
await page.getByRole("switch", { name: "Chat outline" }).click();
|
||||
await page.goto(timelineUrl);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ async function openPluginScreen(page: Page) {
|
||||
await expect(page.getByRole("switch", { name: "Show metadata" })).toBeVisible();
|
||||
}
|
||||
export async function groupByWorkspace(page: Page) {
|
||||
await page.getByRole("button", { name: "Group agents by", exact: true }).click();
|
||||
await page.getByRole("button", { name: /^Group agents by:/ }).click();
|
||||
await page.getByRole("menuitem", { name: "Workspace", exact: true }).click();
|
||||
await expect(page.getByText("Grouped by workspace", { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,12 @@ interface SavedSettingsHostInput {
|
||||
|
||||
const SECTION_LABELS = {
|
||||
general: "General",
|
||||
chat: "Chat",
|
||||
appearance: "Appearance",
|
||||
sidebar: "Sidebar",
|
||||
editor: "Editor",
|
||||
terminal: "Terminal",
|
||||
browser: "Browser",
|
||||
shortcuts: "Shortcuts",
|
||||
integrations: "Integrations",
|
||||
permissions: "Permissions",
|
||||
|
||||
@@ -57,7 +57,7 @@ export async function seedSidebarNavPreferences(
|
||||
|
||||
export async function openSidebarNavSettings(page: Page): Promise<void> {
|
||||
await openSettings(page);
|
||||
await openSettingsSection(page, "appearance");
|
||||
await openSettingsSection(page, "sidebar");
|
||||
await expect(page.getByTestId("sidebar-nav-section")).toBeVisible({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { describe, expect, test } from "vitest";
|
||||
import {
|
||||
areQuestionsAnswered,
|
||||
buildQuestionFormAnswers,
|
||||
buildQuestionFormResponse,
|
||||
parseQuestionFormQuestions,
|
||||
questionShowsTextInput,
|
||||
resolveDismissLabel,
|
||||
@@ -148,44 +147,4 @@ describe("question form card core", () => {
|
||||
Response: "custom",
|
||||
});
|
||||
});
|
||||
test("submits each question's answer as structured labels so commas stay unambiguous", () => {
|
||||
const input = {
|
||||
questions: [
|
||||
{
|
||||
question: "Which colors?",
|
||||
header: "Colors",
|
||||
options: [{ label: "Red, bright" }, { label: "Blue" }],
|
||||
multiSelect: true,
|
||||
allowOther: true,
|
||||
},
|
||||
{
|
||||
question: "Which city?",
|
||||
header: "City",
|
||||
options: [{ label: "Paris, France" }, { label: "Rome" }],
|
||||
allowOther: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
const questions = parseQuestionFormQuestions(input);
|
||||
if (!questions) throw new Error("questions did not parse");
|
||||
|
||||
expect(
|
||||
buildQuestionFormResponse(
|
||||
input,
|
||||
questions,
|
||||
{ 0: new Set([0, 1]), 1: new Set([1]) },
|
||||
{ 0: " Green, dark ", 1: "Lyon, France" },
|
||||
),
|
||||
).toEqual({
|
||||
behavior: "allow",
|
||||
questionAnswers: [
|
||||
{ selected: ["Red, bright", "Blue"], text: "Green, dark" },
|
||||
{ selected: [], text: "Lyon, France" },
|
||||
],
|
||||
updatedInput: {
|
||||
...input,
|
||||
answers: { Colors: "Red, bright, Blue, Green, dark", City: "Lyon, France" },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { AgentPermissionResponse, AgentQuestionAnswer } from "@getpaseo/protocol/agent-types";
|
||||
|
||||
export interface QuestionOption {
|
||||
label: string;
|
||||
description?: string;
|
||||
@@ -103,60 +101,35 @@ export function areQuestionsAnswered(
|
||||
);
|
||||
}
|
||||
|
||||
export function buildQuestionFormResponse(
|
||||
input: Record<string, unknown> | undefined,
|
||||
questions: QuestionFormQuestion[],
|
||||
selections: QuestionSelections,
|
||||
otherTexts: QuestionOtherTexts,
|
||||
): AgentPermissionResponse {
|
||||
return {
|
||||
behavior: "allow",
|
||||
questionAnswers: buildQuestionAnswers(questions, selections, otherTexts),
|
||||
updatedInput: {
|
||||
...input,
|
||||
// COMPAT(questionAnswers): added in v0.9.3, remove after 2027-03-26 once daemon floor >= v0.9.3.
|
||||
// Older daemons read only these text answers; newer daemons derive them from questionAnswers.
|
||||
answers: buildQuestionFormAnswers(questions, selections, otherTexts),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildQuestionAnswers(
|
||||
questions: QuestionFormQuestion[],
|
||||
selections: QuestionSelections,
|
||||
otherTexts: QuestionOtherTexts,
|
||||
): AgentQuestionAnswer[] {
|
||||
return questions.map((q, i) => {
|
||||
const selected = selections[i];
|
||||
const otherText = otherTexts[i]?.trim();
|
||||
const labels = selected ? Array.from(selected).map((idx) => q.options[idx].label) : [];
|
||||
|
||||
if (questionShowsTextInput(q)) {
|
||||
if (otherText && otherText.length > 0) {
|
||||
// Multi-select keeps the checked options alongside the custom answer, the way
|
||||
// Claude Code's own AskUserQuestion UI does. Single-select replaces the option.
|
||||
return { selected: q.multiSelect ? labels : [], text: otherText };
|
||||
}
|
||||
if (q.allowEmpty && q.options.length === 0) {
|
||||
return { selected: [], text: "" };
|
||||
}
|
||||
}
|
||||
return { selected: labels };
|
||||
});
|
||||
}
|
||||
|
||||
export function buildQuestionFormAnswers(
|
||||
questions: QuestionFormQuestion[],
|
||||
selections: QuestionSelections,
|
||||
otherTexts: QuestionOtherTexts,
|
||||
): Record<string, string> {
|
||||
const answers: Record<string, string> = {};
|
||||
buildQuestionAnswers(questions, selections, otherTexts).forEach((answer, i) => {
|
||||
if (answer.selected.length === 0 && answer.text === undefined) return;
|
||||
answers[questions[i].header] = [...answer.selected, ...(answer.text ? [answer.text] : [])].join(
|
||||
", ",
|
||||
);
|
||||
});
|
||||
for (let i = 0; i < questions.length; i++) {
|
||||
const q = questions[i];
|
||||
const selected = selections[i];
|
||||
const otherText = otherTexts[i]?.trim();
|
||||
const labels = selected ? Array.from(selected).map((idx) => q.options[idx].label) : [];
|
||||
|
||||
if (questionShowsTextInput(q)) {
|
||||
if (otherText && otherText.length > 0) {
|
||||
// Multi-select keeps the checked options and appends the custom answer, the way
|
||||
// Claude Code's own AskUserQuestion UI does. Single-select replaces the option.
|
||||
answers[q.header] = q.multiSelect ? [...labels, otherText].join(", ") : otherText;
|
||||
continue;
|
||||
}
|
||||
if (q.allowEmpty && q.options.length === 0) {
|
||||
answers[q.header] = "";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (labels.length > 0) {
|
||||
answers[q.header] = labels.join(", ");
|
||||
}
|
||||
}
|
||||
return answers;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { EditingTextInput as TextInput } from "@/components/ui/text-input";
|
||||
import type { EditingTextInputHandle } from "@/components/ui/text-input/types";
|
||||
import {
|
||||
areQuestionsAnswered,
|
||||
buildQuestionFormResponse,
|
||||
buildQuestionFormAnswers,
|
||||
isQuestionAnswered,
|
||||
parseQuestionFormQuestions,
|
||||
questionShowsTextInput,
|
||||
@@ -402,9 +402,13 @@ export function QuestionFormCard({ permission, onRespond, isResponding }: Questi
|
||||
const handleSubmit = useCallback(() => {
|
||||
if (!questions || !allAnswered || isResponding) return;
|
||||
setRespondingAction("submit");
|
||||
onRespond(
|
||||
buildQuestionFormResponse(permission.request.input, questions, selections, otherTexts),
|
||||
);
|
||||
onRespond({
|
||||
behavior: "allow",
|
||||
updatedInput: {
|
||||
...permission.request.input,
|
||||
answers: buildQuestionFormAnswers(questions, selections, otherTexts),
|
||||
},
|
||||
});
|
||||
}, [
|
||||
questions,
|
||||
allAnswered,
|
||||
@@ -419,9 +423,13 @@ export function QuestionFormCard({ permission, onRespond, isResponding }: Questi
|
||||
if (!questions) return;
|
||||
setRespondingAction("dismiss");
|
||||
if (shouldSubmitEmptyOnDismiss(questions)) {
|
||||
onRespond(
|
||||
buildQuestionFormResponse(permission.request.input, questions, selections, otherTexts),
|
||||
);
|
||||
onRespond({
|
||||
behavior: "allow",
|
||||
updatedInput: {
|
||||
...permission.request.input,
|
||||
answers: buildQuestionFormAnswers(questions, selections, otherTexts),
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
onRespond({
|
||||
|
||||
@@ -117,17 +117,16 @@ export function SettingsSelect<Value extends string>({
|
||||
disabled,
|
||||
...row
|
||||
}: SettingsSelectProps<Value>) {
|
||||
const selectedLabel = options.find((option) => option.value === value)?.label ?? value;
|
||||
return (
|
||||
<SettingsRow {...row}>
|
||||
<DropdownMenu>
|
||||
<DropdownTrigger
|
||||
disabled={disabled}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={row.label}
|
||||
accessibilityLabel={`${row.label}: ${selectedLabel}`}
|
||||
>
|
||||
<Text style={styles.value}>
|
||||
{options.find((option) => option.value === value)?.label ?? value}
|
||||
</Text>
|
||||
{selectedLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={220}>
|
||||
{options.map((option) => (
|
||||
@@ -203,6 +202,5 @@ const styles = StyleSheet.create((theme) => ({
|
||||
},
|
||||
accessoryLabel: { flexShrink: 1, minWidth: 0 },
|
||||
control: { flexShrink: 1, maxWidth: "100%" },
|
||||
value: { color: theme.colors.foreground, fontSize: theme.fontSize.base },
|
||||
input: { minWidth: 180 },
|
||||
}));
|
||||
|
||||
@@ -24,7 +24,7 @@ interface SidebarHeaderRowProps {
|
||||
/**
|
||||
* "header" (default): a sidebar-height row with its own bottom separator —
|
||||
* the lone header at the top of a sidebar (settings "Back to workspace").
|
||||
* "compact": a workspace-row-height row with no separator, for entries that
|
||||
* "compact": a row with no separator, for entries that
|
||||
* sit in a header group whose wrapper owns the single divider.
|
||||
*/
|
||||
variant?: SidebarHeaderRowVariant;
|
||||
@@ -52,10 +52,9 @@ export function SidebarHeaderRow({
|
||||
const buttonStyle = useCallback(
|
||||
({ hovered }: PressableStateCallbackType & { hovered?: boolean }) => [
|
||||
styles.button,
|
||||
variant === "compact" && styles.buttonCompact,
|
||||
(Boolean(hovered) || isActive) && styles.buttonHovered,
|
||||
],
|
||||
[isActive, variant],
|
||||
[isActive],
|
||||
);
|
||||
|
||||
const renderChildren = useCallback(
|
||||
@@ -64,7 +63,7 @@ export function SidebarHeaderRow({
|
||||
return (
|
||||
<>
|
||||
<ThemedIcon
|
||||
size={ICON_SIZE.sm}
|
||||
size={variant === "compact" ? ICON_SIZE.sm : ICON_SIZE.md}
|
||||
uniProps={isHighlighted ? foregroundColorMapping : foregroundMutedColorMapping}
|
||||
/>
|
||||
<SidebarHeaderRowLabel label={label} isHighlighted={isHighlighted} />
|
||||
@@ -74,7 +73,7 @@ export function SidebarHeaderRow({
|
||||
</>
|
||||
);
|
||||
},
|
||||
[ThemedIcon, isActive, label, shortcutKeys],
|
||||
[ThemedIcon, isActive, label, shortcutKeys, variant],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -129,21 +128,14 @@ const styles = StyleSheet.create((theme) => ({
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
// Match the sidebar workspace-row shape (height, padding, radius) so the
|
||||
// compact header entries sit tight against the workspace list below.
|
||||
minHeight: 36,
|
||||
paddingVertical: theme.spacing[2],
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
},
|
||||
// Compact header entries (New workspace / History) sit tighter than the
|
||||
// workspace-row shape the base button mirrors.
|
||||
buttonCompact: {
|
||||
minHeight: 32,
|
||||
paddingVertical: theme.spacing[1.5],
|
||||
// Same row geometry as the settings sidebar items. Shorter than the header
|
||||
// strip so the hover highlight clears the strip's bottom separator.
|
||||
minHeight: 28,
|
||||
paddingVertical: theme.spacing[1],
|
||||
// Match the project rows' inner padding so the icons align on one vertical
|
||||
// edge with the workspace list below (base button uses a wider spacing[3]).
|
||||
// edge with the list below.
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
},
|
||||
buttonHovered: {
|
||||
backgroundColor: theme.colors.surfaceSidebarHover,
|
||||
|
||||
@@ -228,22 +228,22 @@ export function createControlGeometry(theme: Theme) {
|
||||
buttonXs: {
|
||||
minHeight: buttonControlHeight.xs,
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderRadius: theme.borderRadius.xl,
|
||||
},
|
||||
buttonSm: {
|
||||
minHeight: buttonControlHeight.sm,
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderRadius: theme.borderRadius.xl,
|
||||
},
|
||||
buttonMd: {
|
||||
minHeight: buttonControlHeight.md,
|
||||
paddingHorizontal: theme.spacing[4],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
borderRadius: theme.borderRadius["2xl"],
|
||||
},
|
||||
buttonLg: {
|
||||
minHeight: buttonControlHeight.lg,
|
||||
paddingHorizontal: theme.spacing[6],
|
||||
borderRadius: theme.borderRadius.xl,
|
||||
borderRadius: theme.borderRadius["2xl"],
|
||||
},
|
||||
buttonText: {
|
||||
fontSize: theme.fontSize.base,
|
||||
@@ -306,17 +306,17 @@ export function createControlGeometry(theme: Theme) {
|
||||
segmentedSegmentXs: {
|
||||
minHeight: CONTROL_HEIGHTS.tight - SEGMENTED_TIGHT_INSET * 2,
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderRadius: theme.borderRadius.xl,
|
||||
},
|
||||
segmentedSegmentSm: {
|
||||
minHeight: CONTROL_HEIGHTS.compact - SEGMENTED_COMPACT_INSET * 2,
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderRadius: theme.borderRadius.xl,
|
||||
},
|
||||
segmentedSegmentMd: {
|
||||
minHeight: CONTROL_HEIGHTS.field - SEGMENTED_FIELD_INSET * 2,
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
borderRadius: theme.borderRadius["2xl"],
|
||||
},
|
||||
segmentedLabelXs: {
|
||||
fontSize: theme.fontSize.sm,
|
||||
|
||||
@@ -1,48 +1,104 @@
|
||||
import type { ReactElement, ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
import { useCallback, useMemo, type ReactElement, type ReactNode } from "react";
|
||||
import { Text, View, type ViewStyle } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { ChevronDown } from "lucide-react-native";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import {
|
||||
buttonIconSize,
|
||||
createControlGeometry,
|
||||
type ButtonControlSize,
|
||||
} from "@/components/ui/control-geometry";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { DropdownMenuTrigger, type DropdownMenuTriggerProps } from "@/components/ui/dropdown-menu";
|
||||
|
||||
const ThemedChevronDown = withUnistyles(ChevronDown);
|
||||
|
||||
interface DropdownTriggerProps extends Omit<DropdownMenuTriggerProps, "children"> {
|
||||
children?: ReactNode;
|
||||
chevron?: ReactNode | null;
|
||||
}
|
||||
|
||||
const chevronColorMapping = (theme: Theme) => ({
|
||||
color: theme.colors.foregroundMuted,
|
||||
});
|
||||
|
||||
interface DropdownTriggerProps extends Omit<DropdownMenuTriggerProps, "children" | "style"> {
|
||||
/** The selected option's label. */
|
||||
children: string;
|
||||
/** Icon or swatch before the label. */
|
||||
leading?: ReactNode;
|
||||
size?: ButtonControlSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* A select-style menu trigger: the selected value plus a chevron, drawn with the
|
||||
* outline Button's chrome and size scale so a dropdown and a button in the same
|
||||
* row share one geometry. Callers pick a size; they don't style it.
|
||||
*/
|
||||
export function DropdownTrigger({
|
||||
children,
|
||||
chevron,
|
||||
leading,
|
||||
size = "sm",
|
||||
disabled,
|
||||
...props
|
||||
}: DropdownTriggerProps): ReactElement {
|
||||
let sizeStyle: ViewStyle;
|
||||
if (size === "xs") {
|
||||
sizeStyle = styles.xs;
|
||||
} else if (size === "md") {
|
||||
sizeStyle = styles.md;
|
||||
} else if (size === "lg") {
|
||||
sizeStyle = styles.lg;
|
||||
} else {
|
||||
sizeStyle = styles.sm;
|
||||
}
|
||||
const triggerStyle = useCallback(
|
||||
({ pressed }: { pressed: boolean }) => [
|
||||
styles.base,
|
||||
sizeStyle,
|
||||
pressed ? styles.pressed : null,
|
||||
disabled ? styles.disabled : null,
|
||||
],
|
||||
[disabled, sizeStyle],
|
||||
);
|
||||
const labelStyle = useMemo(() => [styles.label, size === "xs" && styles.labelXs], [size]);
|
||||
|
||||
return (
|
||||
<DropdownMenuTrigger {...props}>
|
||||
<View style={styles.row}>
|
||||
<DropdownMenuTrigger {...props} disabled={disabled} style={triggerStyle}>
|
||||
{leading}
|
||||
<Text style={labelStyle} numberOfLines={1}>
|
||||
{children}
|
||||
{chevron !== null &&
|
||||
(chevron ?? (
|
||||
<View style={styles.chevronContainer}>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={chevronColorMapping} />
|
||||
</View>
|
||||
))}
|
||||
</Text>
|
||||
<View style={styles.chevron}>
|
||||
<ThemedChevronDown size={buttonIconSize[size]} uniProps={chevronColorMapping} />
|
||||
</View>
|
||||
</DropdownMenuTrigger>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
row: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
},
|
||||
chevronContainer: {
|
||||
transform: [{ translateY: 1 }],
|
||||
},
|
||||
}));
|
||||
const styles = StyleSheet.create((theme) => {
|
||||
const geometry = createControlGeometry(theme);
|
||||
return {
|
||||
base: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.borderAccent,
|
||||
backgroundColor: "transparent",
|
||||
},
|
||||
xs: geometry.buttonXs,
|
||||
sm: geometry.buttonSm,
|
||||
md: geometry.buttonMd,
|
||||
lg: geometry.buttonLg,
|
||||
pressed: {
|
||||
opacity: 0.85,
|
||||
},
|
||||
disabled: {
|
||||
opacity: theme.opacity[50],
|
||||
},
|
||||
label: {
|
||||
flexShrink: 1,
|
||||
color: theme.colors.foreground,
|
||||
...geometry.buttonText,
|
||||
},
|
||||
labelXs: geometry.buttonTextXs,
|
||||
chevron: {
|
||||
transform: [{ translateY: 1 }],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -32,15 +32,32 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function parseColor(value: string): { rgb: string; alpha: number } {
|
||||
const channels = value.match(/[\d.]+/g)?.map(Number) ?? [];
|
||||
return { rgb: channels.slice(0, 3).join(","), alpha: channels[3] ?? 1 };
|
||||
}
|
||||
|
||||
describe("StatusBadge", () => {
|
||||
it.each(["success", "warning", "error", "muted"] as const)(
|
||||
"uses the semantic badge shell for the %s variant",
|
||||
it("uses the neutral badge shell for the muted variant", () => {
|
||||
const style = getComputedStyle(mountBadge("muted"));
|
||||
|
||||
expect(style.backgroundColor).toBe("rgb(228, 228, 231)");
|
||||
expect(style.borderColor).toBe("rgb(228, 228, 231)");
|
||||
});
|
||||
|
||||
it.each(["success", "warning", "error"] as const)(
|
||||
"fills the %s variant with a translucent tint of its own status color",
|
||||
(variant) => {
|
||||
const badge = mountBadge(variant);
|
||||
const style = getComputedStyle(badge);
|
||||
const text = badge.lastElementChild;
|
||||
if (!(text instanceof HTMLElement)) {
|
||||
throw new Error("StatusBadge did not render its label");
|
||||
}
|
||||
const fill = parseColor(getComputedStyle(badge).backgroundColor);
|
||||
|
||||
expect(style.backgroundColor).toBe("rgb(228, 228, 231)");
|
||||
expect(style.borderColor).toBe("rgb(228, 228, 231)");
|
||||
expect(fill.rgb).toBe(parseColor(getComputedStyle(text).color).rgb);
|
||||
expect(fill.alpha).toBeGreaterThan(0);
|
||||
expect(fill.alpha).toBeLessThan(0.5);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -11,6 +11,15 @@ interface StatusBadgeProps {
|
||||
}
|
||||
|
||||
export function StatusBadge({ label, variant = "muted", leading }: StatusBadgeProps) {
|
||||
const pillStyle = useMemo(
|
||||
() => [
|
||||
styles.pill,
|
||||
variant === "success" && styles.pillSuccess,
|
||||
variant === "warning" && styles.pillWarning,
|
||||
variant === "error" && styles.pillError,
|
||||
],
|
||||
[variant],
|
||||
);
|
||||
const textStyle = useMemo(
|
||||
() => [
|
||||
styles.pillText,
|
||||
@@ -22,7 +31,7 @@ export function StatusBadge({ label, variant = "muted", leading }: StatusBadgePr
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={styles.pill}>
|
||||
<View style={pillStyle}>
|
||||
{leading}
|
||||
<Text style={textStyle}>{label}</Text>
|
||||
</View>
|
||||
@@ -41,6 +50,18 @@ const styles = StyleSheet.create((theme) => ({
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
paddingVertical: 3,
|
||||
},
|
||||
pillSuccess: {
|
||||
backgroundColor: theme.colors.statusSuccessTint,
|
||||
borderColor: "transparent",
|
||||
},
|
||||
pillWarning: {
|
||||
backgroundColor: theme.colors.statusWarningTint,
|
||||
borderColor: "transparent",
|
||||
},
|
||||
pillError: {
|
||||
backgroundColor: theme.colors.statusDangerTint,
|
||||
borderColor: "transparent",
|
||||
},
|
||||
pillText: {
|
||||
fontSize: theme.fontSize.sm,
|
||||
fontWeight: theme.fontWeight.normal,
|
||||
|
||||
@@ -65,7 +65,7 @@ export function BrowserDataSection() {
|
||||
</Text>
|
||||
</View>
|
||||
<Button
|
||||
variant="destructive"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
loading={isClearing}
|
||||
disabled={isClearing}
|
||||
|
||||
@@ -1953,8 +1953,11 @@ export const ar: TranslationResources = {
|
||||
groupInfo: "حول{{title}}",
|
||||
sections: {
|
||||
general: "عام",
|
||||
chat: "الدردشة",
|
||||
appearance: "مظهر",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "الشريط الجانبي",
|
||||
terminal: "الطرفية",
|
||||
browser: "المتصفح",
|
||||
editor: "المحرر",
|
||||
shortcuts: "الاختصارات",
|
||||
integrations: "التكامل",
|
||||
@@ -2013,6 +2016,7 @@ export const ar: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "عام",
|
||||
sending: "الإرسال",
|
||||
browserData: {
|
||||
title: "بيانات المتصفح",
|
||||
siteData: "ملفات تعريف الارتباط وبيانات المواقع",
|
||||
@@ -2040,8 +2044,6 @@ export const ar: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "عناوين URL للخدمة",
|
||||
description: "مكان فتح عناوين URL من تشغيل البرامج النصية",
|
||||
options: {
|
||||
ask: "بسأل",
|
||||
inApp: "في Paseo",
|
||||
@@ -2060,7 +2062,6 @@ export const ar: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "عرض استدعاءات الأدوات",
|
||||
description: "كيفية ظهور استدعاءات الأدوات في المخطط الزمني",
|
||||
accessibilityLabel: "حدد عرض استدعاءات الأدوات ({{value}})",
|
||||
options: {
|
||||
overview: "ملخص",
|
||||
detailed: "التفاصيل الكاملة",
|
||||
|
||||
@@ -1978,9 +1978,12 @@ export const en = {
|
||||
groupInfo: "About {{title}}",
|
||||
sections: {
|
||||
general: "General",
|
||||
chat: "Chat",
|
||||
appearance: "Appearance",
|
||||
layout: "Layout",
|
||||
sidebar: "Sidebar",
|
||||
editor: "Editor",
|
||||
terminal: "Terminal",
|
||||
browser: "Browser",
|
||||
shortcuts: "Shortcuts",
|
||||
integrations: "Integrations",
|
||||
notifications: "Notifications",
|
||||
@@ -1998,29 +2001,32 @@ export const en = {
|
||||
},
|
||||
sources: {
|
||||
explorerFiles: {
|
||||
label: "Selecting a file in Explorer",
|
||||
label: "Clicking a file in the Explorer sidebar",
|
||||
description: "Open files selected in the Explorer sidebar beside your work",
|
||||
},
|
||||
diffs: {
|
||||
label: "Opening a diff",
|
||||
label: "Clicking a change in the Explorer sidebar or a chat",
|
||||
description: "Open diffs from Explorer and agent conversations beside your work",
|
||||
},
|
||||
chatFiles: {
|
||||
label: "Opening a file from an agent chat",
|
||||
label: "Clicking a file in an agent chat",
|
||||
description: "Open file links and tool-call files beside the conversation",
|
||||
},
|
||||
diffFiles: {
|
||||
label: "Opening a file from Changes",
|
||||
label: "Clicking a file in a diff",
|
||||
description: "Open source files selected from a diff beside it",
|
||||
},
|
||||
subagents: {
|
||||
label: "Opening a subagent",
|
||||
label: "Clicking a subagent in an agent chat",
|
||||
description: "Open subagents beside their parent agent",
|
||||
},
|
||||
pullRequests: {
|
||||
label: "Opening a pull request from Changes",
|
||||
label: "Clicking a pull request in the Explorer sidebar",
|
||||
description: "Open pull request details beside Changes",
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "Clicking a script's service URL",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2134,6 +2140,7 @@ export const en = {
|
||||
},
|
||||
general: {
|
||||
title: "General",
|
||||
sending: "Sending",
|
||||
browserData: {
|
||||
title: "Browser data",
|
||||
siteData: "Cookies and site data",
|
||||
@@ -2160,8 +2167,6 @@ export const en = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "Service URLs",
|
||||
description: "Where to open URLs from running scripts",
|
||||
options: {
|
||||
ask: "Ask",
|
||||
inApp: "In Paseo",
|
||||
@@ -2180,7 +2185,6 @@ export const en = {
|
||||
toolCallDetail: {
|
||||
label: "Tool call display",
|
||||
description: "How tool calls appear in the timeline",
|
||||
accessibilityLabel: "Select tool call display ({{value}})",
|
||||
options: {
|
||||
overview: "Summary",
|
||||
detailed: "Full detail",
|
||||
|
||||
@@ -2001,8 +2001,11 @@ export const es: TranslationResources = {
|
||||
groupInfo: "Acerca de{{title}}",
|
||||
sections: {
|
||||
general: "General",
|
||||
chat: "Chat",
|
||||
appearance: "Apariencia",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "Barra lateral",
|
||||
terminal: "Terminal",
|
||||
browser: "Navegador",
|
||||
editor: "Editor",
|
||||
shortcuts: "Atajos",
|
||||
integrations: "Integraciones",
|
||||
@@ -2061,6 +2064,7 @@ export const es: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "General",
|
||||
sending: "Envío",
|
||||
browserData: {
|
||||
title: "Datos del navegador",
|
||||
siteData: "Cookies y datos de sitios",
|
||||
@@ -2091,8 +2095,6 @@ export const es: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "URL de servicio",
|
||||
description: "Dónde abrir URL desde scripts en ejecución",
|
||||
options: {
|
||||
ask: "Preguntar",
|
||||
inApp: "EnPaseo",
|
||||
@@ -2112,7 +2114,6 @@ export const es: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "Visualización de llamadas a herramientas",
|
||||
description: "Cómo aparecen las llamadas a herramientas en la cronología",
|
||||
accessibilityLabel: "Seleccionar visualización de llamadas a herramientas ({{value}})",
|
||||
options: {
|
||||
overview: "Resumen",
|
||||
detailed: "Detalle completo",
|
||||
|
||||
@@ -2006,8 +2006,11 @@ export const fr: TranslationResources = {
|
||||
groupInfo: "À propos de{{title}}",
|
||||
sections: {
|
||||
general: "Général",
|
||||
chat: "Discussion",
|
||||
appearance: "Apparence",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "Barre latérale",
|
||||
terminal: "Terminal",
|
||||
browser: "Navigateur",
|
||||
editor: "Éditeur",
|
||||
shortcuts: "Raccourcis",
|
||||
integrations: "Intégrations",
|
||||
@@ -2066,6 +2069,7 @@ export const fr: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "Général",
|
||||
sending: "Envoi",
|
||||
browserData: {
|
||||
title: "Données du navigateur",
|
||||
siteData: "Cookies et données des sites",
|
||||
@@ -2095,8 +2099,6 @@ export const fr: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "URL de services",
|
||||
description: "Où ouvrir les URL à partir de scripts en cours d'exécution",
|
||||
options: {
|
||||
ask: "Demander",
|
||||
inApp: "DansPaseo",
|
||||
@@ -2115,7 +2117,6 @@ export const fr: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "Affichage des appels d’outils",
|
||||
description: "Comment les appels d’outils apparaissent dans la chronologie",
|
||||
accessibilityLabel: "Sélectionner l’affichage des appels d’outils ({{value}})",
|
||||
options: {
|
||||
overview: "Résumé",
|
||||
detailed: "Détails complets",
|
||||
|
||||
@@ -1973,8 +1973,11 @@ export const ja: TranslationResources = {
|
||||
groupInfo: "{{title}}について",
|
||||
sections: {
|
||||
general: "一般",
|
||||
chat: "チャット",
|
||||
appearance: "外観",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "サイドバー",
|
||||
terminal: "ターミナル",
|
||||
browser: "ブラウザ",
|
||||
editor: "エディター",
|
||||
shortcuts: "ショートカット",
|
||||
integrations: "連携",
|
||||
@@ -2033,6 +2036,7 @@ export const ja: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "一般",
|
||||
sending: "送信",
|
||||
browserData: {
|
||||
title: "ブラウザーデータ",
|
||||
siteData: "Cookie とサイトデータ",
|
||||
@@ -2059,8 +2063,6 @@ export const ja: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "サービスURL",
|
||||
description: "実行中のスクリプトからURLを開く場所",
|
||||
options: {
|
||||
ask: "確認する",
|
||||
inApp: "Paseoで",
|
||||
@@ -2079,7 +2081,6 @@ export const ja: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "ツール呼び出しの表示",
|
||||
description: "タイムラインでのツール呼び出しの表示方法",
|
||||
accessibilityLabel: "ツール呼び出しの表示を選択({{value}})",
|
||||
options: {
|
||||
overview: "要約",
|
||||
detailed: "すべての詳細",
|
||||
|
||||
@@ -1963,8 +1963,11 @@ export const ko: TranslationResources = {
|
||||
groupInfo: "{{title}} 정보",
|
||||
sections: {
|
||||
general: "일반",
|
||||
chat: "채팅",
|
||||
appearance: "모양",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "사이드바",
|
||||
terminal: "터미널",
|
||||
browser: "브라우저",
|
||||
editor: "편집기",
|
||||
shortcuts: "단축키",
|
||||
integrations: "통합",
|
||||
@@ -2023,6 +2026,7 @@ export const ko: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "일반",
|
||||
sending: "전송",
|
||||
browserData: {
|
||||
title: "브라우저 데이터",
|
||||
siteData: "쿠키 및 사이트 데이터",
|
||||
@@ -2051,8 +2055,6 @@ export const ko: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "서비스 URL",
|
||||
description: "실행 중인 스크립트의 URL을 열 위치",
|
||||
options: {
|
||||
ask: "물어보기",
|
||||
inApp: "Paseo에서",
|
||||
@@ -2071,7 +2073,6 @@ export const ko: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "도구 호출 표시",
|
||||
description: "타임라인에 도구 호출이 표시되는 방식",
|
||||
accessibilityLabel: "도구 호출 표시 선택({{value}})",
|
||||
options: {
|
||||
overview: "요약",
|
||||
detailed: "전체 세부정보",
|
||||
|
||||
@@ -1986,8 +1986,11 @@ export const ptBR: TranslationResources = {
|
||||
groupInfo: "Sobre {{title}}",
|
||||
sections: {
|
||||
general: "Geral",
|
||||
chat: "Chat",
|
||||
appearance: "Aparência",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "Barra lateral",
|
||||
terminal: "Terminal",
|
||||
browser: "Navegador",
|
||||
editor: "Editor",
|
||||
shortcuts: "Atalhos",
|
||||
integrations: "Integrações",
|
||||
@@ -2046,6 +2049,7 @@ export const ptBR: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "Geral",
|
||||
sending: "Envio",
|
||||
browserData: {
|
||||
title: "Dados do navegador",
|
||||
siteData: "Cookies e dados de sites",
|
||||
@@ -2074,8 +2078,6 @@ export const ptBR: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "URLs de serviço",
|
||||
description: "Onde abrir URLs de scripts em execução",
|
||||
options: {
|
||||
ask: "Perguntar",
|
||||
inApp: "No Paseo",
|
||||
@@ -2095,7 +2097,6 @@ export const ptBR: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "Exibição de chamadas de ferramentas",
|
||||
description: "Como as chamadas de ferramentas aparecem na linha do tempo",
|
||||
accessibilityLabel: "Selecionar exibição de chamadas de ferramentas ({{value}})",
|
||||
options: {
|
||||
overview: "Resumo",
|
||||
detailed: "Detalhes completos",
|
||||
|
||||
@@ -1986,8 +1986,11 @@ export const ru: TranslationResources = {
|
||||
groupInfo: "О разделе «{{title}}»",
|
||||
sections: {
|
||||
general: "Основные",
|
||||
chat: "Чат",
|
||||
appearance: "Оформление",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "Боковая панель",
|
||||
terminal: "Терминал",
|
||||
browser: "Браузер",
|
||||
editor: "Редактор",
|
||||
shortcuts: "Сочетания клавиш",
|
||||
integrations: "Интеграции",
|
||||
@@ -2046,6 +2049,7 @@ export const ru: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "Основные",
|
||||
sending: "Отправка",
|
||||
browserData: {
|
||||
title: "Данные браузера",
|
||||
siteData: "Файлы cookie и данные сайтов",
|
||||
@@ -2075,8 +2079,6 @@ export const ru: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "URL-адреса сервисов",
|
||||
description: "Где открывать URL-адреса запущенных скриптов",
|
||||
options: {
|
||||
ask: "Спрашивать",
|
||||
inApp: "В Paseo",
|
||||
@@ -2096,7 +2098,6 @@ export const ru: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "Отображение вызовов инструментов",
|
||||
description: "Как вызовы инструментов отображаются на временной шкале",
|
||||
accessibilityLabel: "Выбрать отображение вызовов инструментов ({{value}})",
|
||||
options: {
|
||||
overview: "Сводка",
|
||||
detailed: "Все подробности",
|
||||
|
||||
@@ -1932,8 +1932,11 @@ export const zhCN: TranslationResources = {
|
||||
groupInfo: "关于 {{title}}",
|
||||
sections: {
|
||||
general: "通用",
|
||||
chat: "聊天",
|
||||
appearance: "外观",
|
||||
layout: en.settings.sections.layout,
|
||||
sidebar: "侧边栏",
|
||||
terminal: "终端",
|
||||
browser: "浏览器",
|
||||
editor: "编辑器",
|
||||
shortcuts: "快捷键",
|
||||
integrations: "集成",
|
||||
@@ -1991,6 +1994,7 @@ export const zhCN: TranslationResources = {
|
||||
},
|
||||
general: {
|
||||
title: "通用",
|
||||
sending: "发送",
|
||||
browserData: {
|
||||
title: "浏览器数据",
|
||||
siteData: "Cookie 和网站数据",
|
||||
@@ -2016,8 +2020,6 @@ export const zhCN: TranslationResources = {
|
||||
},
|
||||
},
|
||||
serviceUrls: {
|
||||
label: "服务 URL",
|
||||
description: "运行脚本中的 URL 打开位置",
|
||||
options: {
|
||||
ask: "询问",
|
||||
inApp: "在 Paseo 中",
|
||||
@@ -2036,7 +2038,6 @@ export const zhCN: TranslationResources = {
|
||||
toolCallDetail: {
|
||||
label: "工具调用显示",
|
||||
description: "工具调用在时间线中的显示方式",
|
||||
accessibilityLabel: "选择工具调用显示方式({{value}})",
|
||||
options: {
|
||||
overview: "摘要",
|
||||
detailed: "完整详情",
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
View,
|
||||
type PressableStateCallbackType,
|
||||
} from "react-native";
|
||||
import { EditingTextInput as TextInput } from "@/components/ui/text-input";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
@@ -38,27 +37,27 @@ import {
|
||||
Smartphone,
|
||||
Sparkles,
|
||||
Blocks,
|
||||
PanelsTopLeft,
|
||||
Globe,
|
||||
PanelLeft,
|
||||
MessageSquare,
|
||||
ChevronRight,
|
||||
} from "lucide-react-native";
|
||||
import { DropdownTrigger } from "@/components/ui/dropdown-trigger";
|
||||
import { ComboboxTrigger } from "@/components/ui/combobox-trigger";
|
||||
import { SidebarHeaderRow } from "@/components/sidebar/sidebar-header-row";
|
||||
import { SidebarSeparator } from "@/components/sidebar/sidebar-separator";
|
||||
import { HostPicker as SharedHostPicker } from "@/components/hosts/host-picker";
|
||||
import { HostStatusDot } from "@/components/host-status-dot";
|
||||
import { ScreenTitle } from "@/components/headers/screen-title";
|
||||
import { HeaderIconBadge } from "@/components/headers/header-icon-badge";
|
||||
import { SettingsSection } from "@/components/settings/headings/settings-section";
|
||||
import { AppearanceSection } from "@/screens/settings/appearance/appearance-section";
|
||||
import { LayoutSection } from "@/screens/settings/layout/layout-section";
|
||||
import { OpenLocationSection } from "@/screens/settings/open-location/open-location-section";
|
||||
import { TerminalSection } from "@/screens/settings/terminal/terminal-section";
|
||||
import { ChatSection } from "@/screens/settings/chat/chat-section";
|
||||
import { SidebarNavSection } from "@/screens/settings/sidebar/sidebar-nav-section";
|
||||
import { SendingSection } from "@/screens/settings/general/sending-section";
|
||||
import {
|
||||
useAppSettings,
|
||||
useSettings,
|
||||
parseTerminalScrollbackLines,
|
||||
type AppSettings,
|
||||
type SendBehavior,
|
||||
type ServiceUrlBehavior,
|
||||
type Settings as EffectiveSettings,
|
||||
} from "@/hooks/use-settings";
|
||||
import { useHostRuntimeIsConnected, useHosts } from "@/runtime/host-runtime";
|
||||
@@ -114,7 +113,6 @@ import {
|
||||
HostWorkspacesPage,
|
||||
HostTerminalsPage,
|
||||
} from "@/screens/settings/host-page";
|
||||
import { resolvePluginIcon } from "@/plugins/icons";
|
||||
import { PluginSettingsContent } from "@/plugins/settings";
|
||||
import { useInstalledPlugins } from "@/plugins/registry";
|
||||
import { HostPluginsPage } from "@/screens/settings/plugins-page";
|
||||
@@ -144,48 +142,88 @@ import { isNative, isWeb } from "@/constants/platform";
|
||||
interface SidebarSectionItem {
|
||||
id: SettingsSectionSlug;
|
||||
labelKey: string;
|
||||
icon: ComponentType<{ size: number; color: string }>;
|
||||
icon: ComponentType<{ size: number; color: string; strokeWidth?: number }>;
|
||||
desktopOnly?: boolean;
|
||||
webOnly?: boolean;
|
||||
/** The page body, for pages that need nothing from the settings screen. */
|
||||
Content?: ComponentType;
|
||||
}
|
||||
|
||||
const SIDEBAR_SECTION_ITEMS: SidebarSectionItem[] = [
|
||||
{ id: "general", labelKey: "settings.sections.general", icon: Settings },
|
||||
{ id: "appearance", labelKey: "settings.sections.appearance", icon: Palette },
|
||||
{
|
||||
id: "layout",
|
||||
labelKey: "settings.sections.layout",
|
||||
icon: PanelsTopLeft,
|
||||
id: "appearance",
|
||||
labelKey: "settings.sections.appearance",
|
||||
icon: Palette,
|
||||
Content: AppearanceSection,
|
||||
},
|
||||
{
|
||||
id: "sidebar",
|
||||
labelKey: "settings.sections.sidebar",
|
||||
icon: PanelLeft,
|
||||
Content: SidebarNavSection,
|
||||
},
|
||||
{ id: "chat", labelKey: "settings.sections.chat", icon: MessageSquare, Content: ChatSection },
|
||||
{
|
||||
id: "terminal",
|
||||
labelKey: "settings.sections.terminal",
|
||||
icon: SquareTerminal,
|
||||
Content: TerminalSection,
|
||||
},
|
||||
{
|
||||
id: "browser",
|
||||
labelKey: "settings.sections.browser",
|
||||
icon: Globe,
|
||||
desktopOnly: true,
|
||||
Content: BrowserDataSection,
|
||||
},
|
||||
{
|
||||
id: "editor",
|
||||
labelKey: "settings.sections.editor",
|
||||
icon: Code2,
|
||||
webOnly: true,
|
||||
Content: EditorSection,
|
||||
},
|
||||
{
|
||||
id: "shortcuts",
|
||||
labelKey: "settings.sections.shortcuts",
|
||||
icon: Keyboard,
|
||||
desktopOnly: true,
|
||||
Content: KeyboardShortcutsSection,
|
||||
},
|
||||
{ id: "editor", labelKey: "settings.sections.editor", icon: Code2, webOnly: true },
|
||||
{ id: "shortcuts", labelKey: "settings.sections.shortcuts", icon: Keyboard, desktopOnly: true },
|
||||
{
|
||||
id: "integrations",
|
||||
labelKey: "settings.sections.integrations",
|
||||
icon: Puzzle,
|
||||
desktopOnly: true,
|
||||
Content: IntegrationsSection,
|
||||
},
|
||||
{
|
||||
id: "notifications",
|
||||
labelKey: "settings.sections.notifications",
|
||||
icon: Bell,
|
||||
desktopOnly: true,
|
||||
Content: DesktopNotificationsSection,
|
||||
},
|
||||
{
|
||||
id: "permissions",
|
||||
labelKey: "settings.sections.permissions",
|
||||
icon: Shield,
|
||||
desktopOnly: true,
|
||||
Content: DesktopPermissionsSection,
|
||||
},
|
||||
{ id: "diagnostics", labelKey: "settings.sections.diagnostics", icon: Stethoscope },
|
||||
{ id: "about", labelKey: "settings.sections.about", icon: Info },
|
||||
];
|
||||
|
||||
function isSectionAvailable(item: SidebarSectionItem, isDesktopApp: boolean): boolean {
|
||||
return (!item.desktopOnly || isDesktopApp) && (!item.webOnly || isWeb);
|
||||
}
|
||||
|
||||
interface HostSectionItem {
|
||||
id: HostSectionSlug;
|
||||
labelKey: string;
|
||||
icon: ComponentType<{ size: number; color: string }>;
|
||||
icon: ComponentType<{ size: number; color: string; strokeWidth?: number }>;
|
||||
}
|
||||
|
||||
const HOST_SECTION_ITEMS: HostSectionItem[] = [
|
||||
@@ -236,10 +274,6 @@ function renderHostSettingsContent(
|
||||
// Trigger + sidebar style helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function themeTriggerStyle({ pressed }: PressableStateCallbackType) {
|
||||
return [styles.themeTrigger, pressed && { opacity: 0.85 }];
|
||||
}
|
||||
|
||||
function sidebarItemStyle({ hovered }: PressableStateCallbackType & { hovered?: boolean }) {
|
||||
return [sidebarStyles.item, Boolean(hovered) && sidebarStyles.itemHovered];
|
||||
}
|
||||
@@ -252,82 +286,18 @@ function selectedSidebarItemStyle({ hovered }: PressableStateCallbackType & { ho
|
||||
];
|
||||
}
|
||||
|
||||
function getSendBehaviorOptions(t: TFunction) {
|
||||
return [
|
||||
{ value: "interrupt" as const, label: t("settings.general.defaultSend.options.interrupt") },
|
||||
{ value: "steer" as const, label: t("settings.general.defaultSend.options.steer") },
|
||||
{ value: "queue" as const, label: t("settings.general.defaultSend.options.queue") },
|
||||
];
|
||||
}
|
||||
|
||||
function getServiceUrlBehaviorLabel(t: TFunction, value: ServiceUrlBehavior): string {
|
||||
const labels: Record<ServiceUrlBehavior, string> = {
|
||||
ask: t("settings.general.serviceUrls.options.ask"),
|
||||
"in-app": t("settings.general.serviceUrls.options.inApp"),
|
||||
external: t("settings.general.serviceUrls.options.external"),
|
||||
};
|
||||
return labels[value];
|
||||
}
|
||||
|
||||
function getActiveLocale(language: string | undefined): SupportedLocale {
|
||||
const parsed = parseAppLanguage(language);
|
||||
return parsed && parsed !== "system" ? parsed : "en";
|
||||
}
|
||||
|
||||
const SERVICE_URL_BEHAVIOR_VALUES: ServiceUrlBehavior[] = ["ask", "in-app", "external"];
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Section components
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface GeneralSectionProps {
|
||||
settings: AppSettings;
|
||||
isDesktopApp: boolean;
|
||||
handleSendBehaviorChange: (behavior: SendBehavior) => void;
|
||||
handleServiceUrlBehaviorChange: (behavior: ServiceUrlBehavior) => void;
|
||||
handleLanguageChange: (language: AppLanguage) => void;
|
||||
handleTerminalScrollbackLinesChange: (lines: number) => void;
|
||||
}
|
||||
|
||||
interface ServiceUrlBehaviorMenuItemProps {
|
||||
value: ServiceUrlBehavior;
|
||||
label: string;
|
||||
selected: boolean;
|
||||
onChange: (value: ServiceUrlBehavior) => void;
|
||||
}
|
||||
|
||||
interface SendBehaviorMenuItemProps {
|
||||
value: SendBehavior;
|
||||
label: string;
|
||||
selected: boolean;
|
||||
onChange: (value: SendBehavior) => void;
|
||||
}
|
||||
|
||||
function SendBehaviorMenuItem({ value, label, selected, onChange }: SendBehaviorMenuItemProps) {
|
||||
const handleSelect = useCallback(() => {
|
||||
onChange(value);
|
||||
}, [onChange, value]);
|
||||
return (
|
||||
<DropdownMenuItem selected={selected} onSelect={handleSelect}>
|
||||
{label}
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
function ServiceUrlBehaviorMenuItem({
|
||||
value,
|
||||
label,
|
||||
selected,
|
||||
onChange,
|
||||
}: ServiceUrlBehaviorMenuItemProps) {
|
||||
const handleSelect = useCallback(() => {
|
||||
onChange(value);
|
||||
}, [onChange, value]);
|
||||
return (
|
||||
<DropdownMenuItem selected={selected} onSelect={handleSelect}>
|
||||
{label}
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
interface LanguageMenuItemProps {
|
||||
@@ -354,21 +324,9 @@ function LanguageMenuItem({ value, activeLocale, selected, onChange }: LanguageM
|
||||
);
|
||||
}
|
||||
|
||||
function GeneralSection({
|
||||
settings,
|
||||
isDesktopApp,
|
||||
handleSendBehaviorChange,
|
||||
handleServiceUrlBehaviorChange,
|
||||
handleLanguageChange,
|
||||
handleTerminalScrollbackLinesChange,
|
||||
}: GeneralSectionProps) {
|
||||
function GeneralSection({ settings, handleLanguageChange }: GeneralSectionProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const activeLocale = getActiveLocale(i18n.language);
|
||||
const sendBehaviorOptions = useMemo(() => getSendBehaviorOptions(t), [t]);
|
||||
const selectedSendBehaviorLabel =
|
||||
sendBehaviorOptions.find((option) => option.value === settings.sendBehavior)?.label ??
|
||||
settings.sendBehavior;
|
||||
const sendBehaviorDescriptionKey = `settings.general.defaultSend.descriptions.${settings.sendBehavior}`;
|
||||
const selectedLanguageOption = LANGUAGE_OPTIONS.find(
|
||||
(option) => option.value === settings.language,
|
||||
);
|
||||
@@ -379,72 +337,17 @@ function GeneralSection({
|
||||
t(selectedLanguageOption.labelKey),
|
||||
)
|
||||
: settings.language;
|
||||
const [terminalScrollbackValue, setTerminalScrollbackValue] = useState(
|
||||
String(settings.terminalScrollbackLines),
|
||||
);
|
||||
|
||||
const handleTerminalScrollbackChangeText = useCallback((value: string) => {
|
||||
setTerminalScrollbackValue(value.replace(/[^\d]/g, ""));
|
||||
}, []);
|
||||
|
||||
const commitTerminalScrollback = useCallback(() => {
|
||||
const parsed = parseTerminalScrollbackLines(terminalScrollbackValue);
|
||||
const nextValue = parsed ?? settings.terminalScrollbackLines;
|
||||
setTerminalScrollbackValue(String(nextValue));
|
||||
if (nextValue !== settings.terminalScrollbackLines) {
|
||||
handleTerminalScrollbackLinesChange(nextValue);
|
||||
}
|
||||
}, [
|
||||
handleTerminalScrollbackLinesChange,
|
||||
settings.terminalScrollbackLines,
|
||||
terminalScrollbackValue,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setTerminalScrollbackValue(String(settings.terminalScrollbackLines));
|
||||
}, [settings.terminalScrollbackLines]);
|
||||
|
||||
return (
|
||||
<SettingsSection title={t("settings.general.title")}>
|
||||
<View style={settingsStyles.card}>
|
||||
<View style={settingsStyles.row}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.general.defaultSend.label")}</Text>
|
||||
<Text style={settingsStyles.rowHint}>{t(sendBehaviorDescriptionKey)}</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownTrigger
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`${t("settings.general.defaultSend.label")}: ${selectedSendBehaviorLabel}`}
|
||||
style={themeTriggerStyle}
|
||||
>
|
||||
<Text style={styles.themeTriggerText}>{selectedSendBehaviorLabel}</Text>
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{sendBehaviorOptions.map((option) => (
|
||||
<SendBehaviorMenuItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
label={option.label}
|
||||
selected={settings.sendBehavior === option.value}
|
||||
onChange={handleSendBehaviorChange}
|
||||
/>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</View>
|
||||
<View style={[settingsStyles.row, settingsStyles.rowBorder]}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.general.language.label")}</Text>
|
||||
<Text style={settingsStyles.rowHint}>{t("settings.general.language.description")}</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownTrigger
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={selectedLanguageLabel}
|
||||
style={themeTriggerStyle}
|
||||
>
|
||||
<Text style={styles.themeTriggerText}>{selectedLanguageLabel}</Text>
|
||||
<DropdownTrigger accessibilityRole="button" accessibilityLabel={selectedLanguageLabel}>
|
||||
{selectedLanguageLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={300}>
|
||||
{LANGUAGE_OPTIONS.map((option) => (
|
||||
@@ -459,55 +362,6 @@ function GeneralSection({
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</View>
|
||||
{isDesktopApp ? (
|
||||
<View style={[settingsStyles.row, settingsStyles.rowBorder]}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.general.serviceUrls.label")}</Text>
|
||||
<Text style={settingsStyles.rowHint}>
|
||||
{t("settings.general.serviceUrls.description")}
|
||||
</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownTrigger style={themeTriggerStyle}>
|
||||
<Text style={styles.themeTriggerText}>
|
||||
{getServiceUrlBehaviorLabel(t, settings.serviceUrlBehavior)}
|
||||
</Text>
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{SERVICE_URL_BEHAVIOR_VALUES.map((value) => (
|
||||
<ServiceUrlBehaviorMenuItem
|
||||
key={value}
|
||||
value={value}
|
||||
label={getServiceUrlBehaviorLabel(t, value)}
|
||||
selected={settings.serviceUrlBehavior === value}
|
||||
onChange={handleServiceUrlBehaviorChange}
|
||||
/>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</View>
|
||||
) : null}
|
||||
<View style={[settingsStyles.row, settingsStyles.rowBorder]}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>
|
||||
{t("settings.general.terminalScrollback.label")}
|
||||
</Text>
|
||||
<Text style={settingsStyles.rowHint}>
|
||||
{t("settings.general.terminalScrollback.description")}
|
||||
</Text>
|
||||
</View>
|
||||
<TextInput
|
||||
initialValue={terminalScrollbackValue}
|
||||
onChangeText={handleTerminalScrollbackChangeText}
|
||||
onBlur={commitTerminalScrollback}
|
||||
onSubmitEditing={commitTerminalScrollback}
|
||||
keyboardType="number-pad"
|
||||
inputMode="numeric"
|
||||
selectTextOnFocus
|
||||
style={styles.terminalScrollbackInput}
|
||||
accessibilityLabel={t("settings.general.terminalScrollback.accessibilityLabel")}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
);
|
||||
@@ -889,11 +743,14 @@ function useSortedHosts(hosts: HostProfile[], localServerId: string | null): Hos
|
||||
interface SidebarSectionButtonProps {
|
||||
itemId: SettingsSectionSlug;
|
||||
label: string;
|
||||
icon: ComponentType<{ size: number; color: string }>;
|
||||
icon: ComponentType<{ size: number; color: string; strokeWidth?: number }>;
|
||||
isSelected: boolean;
|
||||
onSelect: (section: SettingsSectionSlug) => void;
|
||||
}
|
||||
|
||||
// Lighter than lucide's default 2px stroke so the nav reads quieter than the content.
|
||||
const SIDEBAR_ICON_STROKE_WIDTH = 1.5;
|
||||
|
||||
function SidebarSectionButton({
|
||||
itemId,
|
||||
label,
|
||||
@@ -920,6 +777,7 @@ function SidebarSectionButton({
|
||||
<IconComponent
|
||||
size={theme.iconSize.md}
|
||||
color={isSelected ? theme.colors.foreground : theme.colors.foregroundMuted}
|
||||
strokeWidth={SIDEBAR_ICON_STROKE_WIDTH}
|
||||
/>
|
||||
<Text style={labelStyle} numberOfLines={1}>
|
||||
{label}
|
||||
@@ -931,7 +789,7 @@ function SidebarSectionButton({
|
||||
interface SidebarHostSectionButtonProps {
|
||||
itemId: HostSectionSlug;
|
||||
label: string;
|
||||
icon: ComponentType<{ size: number; color: string }>;
|
||||
icon: ComponentType<{ size: number; color: string; strokeWidth?: number }>;
|
||||
isSelected: boolean;
|
||||
onSelect: (section: HostSectionSlug) => void;
|
||||
}
|
||||
@@ -963,6 +821,7 @@ function SidebarHostSectionButton({
|
||||
<IconComponent
|
||||
size={theme.iconSize.md}
|
||||
color={isSelected ? theme.colors.foreground : theme.colors.foregroundMuted}
|
||||
strokeWidth={SIDEBAR_ICON_STROKE_WIDTH}
|
||||
/>
|
||||
<Text style={labelStyle} numberOfLines={1}>
|
||||
{label}
|
||||
@@ -1082,9 +941,7 @@ function SettingsSidebar({
|
||||
const hasHosts = sortedHosts.length > 0;
|
||||
const enableBuiltInDaemonOption = useEnableBuiltInDaemonOption();
|
||||
const isDesktopApp = isElectronRuntime();
|
||||
const items = SIDEBAR_SECTION_ITEMS.filter(
|
||||
(item) => (!item.desktopOnly || isDesktopApp) && (!item.webOnly || isWeb),
|
||||
);
|
||||
const items = SIDEBAR_SECTION_ITEMS.filter((item) => isSectionAvailable(item, isDesktopApp));
|
||||
const insets = useSafeAreaInsets();
|
||||
const isDesktop = layout === "desktop";
|
||||
const outerContainerStyle = useMemo(
|
||||
@@ -1116,7 +973,6 @@ function SettingsSidebar({
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
<SidebarSeparator />
|
||||
{hasHosts ? (
|
||||
<View style={sidebarStyles.list}>
|
||||
<Text style={sidebarStyles.groupLabel}>{t("settings.groups.host")}</Text>
|
||||
@@ -1147,7 +1003,11 @@ function SettingsSidebar({
|
||||
testID="settings-add-host"
|
||||
style={sidebarItemStyle}
|
||||
>
|
||||
<Plus size={theme.iconSize.md} color={theme.colors.foregroundMuted} />
|
||||
<Plus
|
||||
size={theme.iconSize.md}
|
||||
color={theme.colors.foregroundMuted}
|
||||
strokeWidth={SIDEBAR_ICON_STROKE_WIDTH}
|
||||
/>
|
||||
<Text style={sidebarStyles.label} numberOfLines={1}>
|
||||
{t("settings.addHost")}
|
||||
</Text>
|
||||
@@ -1160,7 +1020,11 @@ function SettingsSidebar({
|
||||
testID="settings-enable-built-in-daemon"
|
||||
style={sidebarItemStyle}
|
||||
>
|
||||
<Server size={theme.iconSize.md} color={theme.colors.foregroundMuted} />
|
||||
<Server
|
||||
size={theme.iconSize.md}
|
||||
color={theme.colors.foregroundMuted}
|
||||
strokeWidth={SIDEBAR_ICON_STROKE_WIDTH}
|
||||
/>
|
||||
<Text style={sidebarStyles.label} numberOfLines={1}>
|
||||
{t("settings.enableBuiltInDaemon")}
|
||||
</Text>
|
||||
@@ -1216,7 +1080,6 @@ export interface SettingsScreenProps {
|
||||
|
||||
export default function SettingsScreen({ view, openAddHostIntent = null }: SettingsScreenProps) {
|
||||
const router = useRouter();
|
||||
const { theme } = useUnistyles();
|
||||
const { t } = useTranslation();
|
||||
const voiceAudioEngine = useVoiceAudioEngineOptional();
|
||||
const { settings, isLoading: settingsLoading, updateSettings } = useAppSettings();
|
||||
@@ -1265,20 +1128,6 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
|
||||
});
|
||||
}, [view, selectedSettingsHostServerId, localServerId, hosts, sortedHosts]);
|
||||
|
||||
const handleSendBehaviorChange = useCallback(
|
||||
(behavior: SendBehavior) => {
|
||||
void updateSettings({ sendBehavior: behavior });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleServiceUrlBehaviorChange = useCallback(
|
||||
(behavior: ServiceUrlBehavior) => {
|
||||
void updateSettings({ serviceUrlBehavior: behavior });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleLanguageChange = useCallback(
|
||||
(language: AppLanguage) => {
|
||||
void updateSettings({ language });
|
||||
@@ -1286,13 +1135,6 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleTerminalScrollbackLinesChange = useCallback(
|
||||
(terminalScrollbackLines: number) => {
|
||||
void updateSettings({ terminalScrollbackLines });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleUseLegacyTerminalRendererChange = useCallback(
|
||||
(useLegacyTerminalRenderer: boolean) => {
|
||||
void updateSettings({ useLegacyTerminalRenderer });
|
||||
@@ -1465,112 +1307,89 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
|
||||
const installedPlugins = useInstalledPlugins();
|
||||
const detailHeader = ((): {
|
||||
title: string;
|
||||
Icon: ComponentType<{ size: number; color: string }>;
|
||||
titleAccessory?: ReactNode;
|
||||
} | null => {
|
||||
if (view.kind === "plugin") {
|
||||
const screen = installedPlugins
|
||||
.find((plugin) => plugin.serverId === view.serverId && plugin.id === view.pluginId)
|
||||
?.settingsScreens.find((candidate) => candidate.id === view.screenId);
|
||||
return {
|
||||
title: `${view.pluginId} · ${screen?.title ?? t("settings.title")}`,
|
||||
Icon: screen ? resolvePluginIcon(screen.icon) : Blocks,
|
||||
};
|
||||
return { title: `${view.pluginId} · ${screen?.title ?? t("settings.title")}` };
|
||||
}
|
||||
if (view.kind === "host") {
|
||||
const item = HOST_SECTION_ITEMS.find((s) => s.id === view.section);
|
||||
if (!item) return null;
|
||||
return { title: t(item.labelKey), Icon: item.icon };
|
||||
return { title: t(item.labelKey) };
|
||||
}
|
||||
if (view.kind === "section") {
|
||||
const item = SIDEBAR_SECTION_ITEMS.find((s) => s.id === view.section);
|
||||
if (!item) return null;
|
||||
return { title: t(item.labelKey), Icon: item.icon };
|
||||
return { title: t(item.labelKey) };
|
||||
}
|
||||
if (view.kind === "project") {
|
||||
return { title: t("settings.projects"), Icon: FolderGit2 };
|
||||
return { title: t("settings.projects") };
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
let content: ReactNode;
|
||||
if (view.kind === "section" && view.section === "layout") {
|
||||
content = isDesktopApp ? <LayoutSection /> : null;
|
||||
} else {
|
||||
content = (() => {
|
||||
if (view.kind === "plugin")
|
||||
return (
|
||||
<PluginSettingsContent
|
||||
serverId={view.serverId}
|
||||
pluginId={view.pluginId}
|
||||
screenId={view.screenId}
|
||||
/>
|
||||
);
|
||||
if (view.kind === "host") {
|
||||
return renderHostSettingsContent(view, handleHostRemoved);
|
||||
const content: ReactNode = (() => {
|
||||
if (view.kind === "plugin")
|
||||
return (
|
||||
<PluginSettingsContent
|
||||
serverId={view.serverId}
|
||||
pluginId={view.pluginId}
|
||||
screenId={view.screenId}
|
||||
/>
|
||||
);
|
||||
if (view.kind === "host") {
|
||||
return renderHostSettingsContent(view, handleHostRemoved);
|
||||
}
|
||||
if (view.kind === "project") {
|
||||
return (
|
||||
<ProjectSettingsScreen
|
||||
serverId={view.serverId}
|
||||
projectId={view.projectId}
|
||||
onBackToProjects={handleBackFromDetail}
|
||||
showBackToProjects={!isCompactLayout}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (view.kind === "section") {
|
||||
const item = SIDEBAR_SECTION_ITEMS.find((candidate) => candidate.id === view.section);
|
||||
if (!item || !isSectionAvailable(item, isDesktopApp)) return null;
|
||||
switch (view.section) {
|
||||
case "general":
|
||||
return (
|
||||
<>
|
||||
<GeneralSection settings={settings} handleLanguageChange={handleLanguageChange} />
|
||||
<SendingSection />
|
||||
{isDesktopApp ? <OpenLocationSection /> : null}
|
||||
</>
|
||||
);
|
||||
case "diagnostics":
|
||||
return (
|
||||
<DiagnosticsSection
|
||||
useLegacyTerminalRenderer={settings.useLegacyTerminalRenderer}
|
||||
onUseLegacyTerminalRendererChange={handleUseLegacyTerminalRendererChange}
|
||||
voiceAudioEngine={voiceAudioEngine}
|
||||
isPlaybackTestRunning={isPlaybackTestRunning}
|
||||
playbackTestResult={playbackTestResult}
|
||||
handlePlaybackTest={handlePlaybackTest}
|
||||
/>
|
||||
);
|
||||
case "about":
|
||||
return (
|
||||
<AboutSection
|
||||
appVersion={appVersion}
|
||||
appVersionText={appVersionText}
|
||||
isDesktopApp={isDesktopApp}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return item.Content ? <item.Content /> : null;
|
||||
}
|
||||
if (view.kind === "project") {
|
||||
return (
|
||||
<ProjectSettingsScreen
|
||||
serverId={view.serverId}
|
||||
projectId={view.projectId}
|
||||
onBackToProjects={handleBackFromDetail}
|
||||
showBackToProjects={!isCompactLayout}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (view.kind === "section") {
|
||||
switch (view.section) {
|
||||
case "general":
|
||||
return (
|
||||
<>
|
||||
<GeneralSection
|
||||
settings={settings}
|
||||
isDesktopApp={isDesktopApp}
|
||||
handleSendBehaviorChange={handleSendBehaviorChange}
|
||||
handleServiceUrlBehaviorChange={handleServiceUrlBehaviorChange}
|
||||
handleLanguageChange={handleLanguageChange}
|
||||
handleTerminalScrollbackLinesChange={handleTerminalScrollbackLinesChange}
|
||||
/>
|
||||
{isDesktopApp ? <BrowserDataSection /> : null}
|
||||
</>
|
||||
);
|
||||
case "appearance":
|
||||
return <AppearanceSection />;
|
||||
case "editor":
|
||||
return isWeb ? <EditorSection /> : null;
|
||||
case "shortcuts":
|
||||
return isDesktopApp ? <KeyboardShortcutsSection /> : null;
|
||||
case "integrations":
|
||||
return isDesktopApp ? <IntegrationsSection /> : null;
|
||||
case "notifications":
|
||||
return isDesktopApp ? <DesktopNotificationsSection /> : null;
|
||||
case "permissions":
|
||||
return isDesktopApp ? <DesktopPermissionsSection /> : null;
|
||||
case "diagnostics":
|
||||
return (
|
||||
<DiagnosticsSection
|
||||
useLegacyTerminalRenderer={settings.useLegacyTerminalRenderer}
|
||||
onUseLegacyTerminalRendererChange={handleUseLegacyTerminalRendererChange}
|
||||
voiceAudioEngine={voiceAudioEngine}
|
||||
isPlaybackTestRunning={isPlaybackTestRunning}
|
||||
playbackTestResult={playbackTestResult}
|
||||
handlePlaybackTest={handlePlaybackTest}
|
||||
/>
|
||||
);
|
||||
case "about":
|
||||
return (
|
||||
<AboutSection
|
||||
appVersion={appVersion}
|
||||
appVersionText={appVersionText}
|
||||
isDesktopApp={isDesktopApp}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
if (settingsLoading) {
|
||||
return (
|
||||
@@ -1580,14 +1399,13 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
|
||||
);
|
||||
}
|
||||
|
||||
const desktopDetailHeaderLeft = detailHeader ? (
|
||||
<>
|
||||
<HeaderIconBadge>
|
||||
<detailHeader.Icon size={theme.iconSize.md} color={theme.colors.foregroundMuted} />
|
||||
</HeaderIconBadge>
|
||||
<ScreenTitle testID="settings-detail-header-title">{detailHeader.title}</ScreenTitle>
|
||||
const desktopPageTitle = detailHeader ? (
|
||||
<View style={styles.pageTitleRow}>
|
||||
<Text style={styles.pageTitle} testID="settings-detail-header-title">
|
||||
{detailHeader.title}
|
||||
</Text>
|
||||
{detailHeader.titleAccessory}
|
||||
</>
|
||||
</View>
|
||||
) : null;
|
||||
|
||||
const addHostModals = (
|
||||
@@ -1679,13 +1497,14 @@ export default function SettingsScreen({ view, openAddHostIntent = null }: Setti
|
||||
</WindowChromeRegion>
|
||||
<WindowChromeRegion corners="top-right">
|
||||
<View style={desktopStyles.contentPane} testID="settings-detail-pane">
|
||||
<ScreenHeader
|
||||
borderless={!detailHeader}
|
||||
left={desktopDetailHeaderLeft}
|
||||
leftStyle={desktopStyles.detailLeft}
|
||||
/>
|
||||
{/* Keeps the titlebar drag region and window controls; the page
|
||||
title lives in the content, like a document heading. */}
|
||||
<ScreenHeader borderless />
|
||||
<ScrollView style={styles.scrollView} contentContainerStyle={insetBottomStyle}>
|
||||
<View style={styles.content}>{content}</View>
|
||||
<View style={styles.content}>
|
||||
{desktopPageTitle}
|
||||
{content}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</WindowChromeRegion>
|
||||
@@ -1724,6 +1543,19 @@ const styles = StyleSheet.create((theme) => ({
|
||||
maxWidth: 720,
|
||||
alignSelf: "center",
|
||||
},
|
||||
pageTitleRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
// Line up with the section titles, which sit inset from their cards.
|
||||
marginLeft: theme.spacing[1],
|
||||
marginBottom: theme.spacing[6],
|
||||
},
|
||||
pageTitle: {
|
||||
fontSize: theme.fontSize["4xl"],
|
||||
fontWeight: theme.fontWeight.medium,
|
||||
color: theme.colors.foreground,
|
||||
},
|
||||
aboutValue: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.base,
|
||||
@@ -1744,33 +1576,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
themeTrigger: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
paddingVertical: theme.spacing[1],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.border,
|
||||
},
|
||||
themeTriggerText: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
terminalScrollbackInput: {
|
||||
width: 112,
|
||||
minHeight: 36,
|
||||
paddingVertical: theme.spacing[2],
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.border,
|
||||
backgroundColor: theme.colors.surface2,
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
textAlign: "right",
|
||||
},
|
||||
placeholder: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
@@ -1783,7 +1588,7 @@ const styles = StyleSheet.create((theme) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const desktopStyles = StyleSheet.create((theme) => ({
|
||||
const desktopStyles = StyleSheet.create({
|
||||
row: {
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
@@ -1791,10 +1596,7 @@ const desktopStyles = StyleSheet.create((theme) => ({
|
||||
contentPane: {
|
||||
flex: 1,
|
||||
},
|
||||
detailLeft: {
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
const sidebarStyles = StyleSheet.create((theme) => ({
|
||||
desktopContainer: {
|
||||
@@ -1816,12 +1618,12 @@ const sidebarStyles = StyleSheet.create((theme) => ({
|
||||
list: {
|
||||
paddingVertical: theme.spacing[2],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
gap: theme.spacing[1],
|
||||
gap: theme.spacing[0.5],
|
||||
},
|
||||
groupLabel: {
|
||||
fontSize: theme.fontSize.base,
|
||||
fontWeight: theme.fontWeight.medium,
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontWeight: theme.fontWeight.normal,
|
||||
color: theme.colors.foregroundExtraMuted,
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
paddingVertical: theme.spacing[1],
|
||||
},
|
||||
@@ -1829,8 +1631,8 @@ const sidebarStyles = StyleSheet.create((theme) => ({
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
minHeight: 36,
|
||||
paddingVertical: theme.spacing[2],
|
||||
minHeight: 28,
|
||||
paddingVertical: theme.spacing[1],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
},
|
||||
@@ -1850,8 +1652,8 @@ const sidebarStyles = StyleSheet.create((theme) => ({
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
minHeight: 36,
|
||||
paddingVertical: theme.spacing[2],
|
||||
minHeight: 28,
|
||||
paddingVertical: theme.spacing[1],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Fragment, useCallback, useEffect, useMemo, useState } from "react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Text, View, type PressableStateCallbackType } from "react-native";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { ChevronDown, Monitor, Moon, Sun } from "lucide-react-native";
|
||||
import { Monitor, Moon, Sun } from "lucide-react-native";
|
||||
import {
|
||||
SYNTAX_THEME_OPTIONS,
|
||||
type SyntaxThemeId,
|
||||
@@ -14,9 +14,8 @@ import {
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { SettingsCard, SettingsSwitch } from "@/components/settings";
|
||||
import { DropdownTrigger } from "@/components/ui/dropdown-trigger";
|
||||
import { SettingsSection } from "@/components/settings/headings/settings-section";
|
||||
import { useContributedThemes } from "@/appearance/provider";
|
||||
import { EditingTextInput as TextInput } from "@/components/ui/text-input";
|
||||
@@ -46,7 +45,6 @@ import { isNative } from "@/constants/platform";
|
||||
import type { PluginThemeOption } from "@/plugins/themes";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { AppearancePreview } from "./appearance-preview";
|
||||
import { SidebarNavSection } from "./sidebar-nav-section";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Theme-reactive leaf icons (withUnistyles + uniProps color mapping — no
|
||||
@@ -57,7 +55,6 @@ import { SidebarNavSection } from "./sidebar-nav-section";
|
||||
const ThemedSun = withUnistyles(Sun);
|
||||
const ThemedMoon = withUnistyles(Moon);
|
||||
const ThemedMonitor = withUnistyles(Monitor);
|
||||
const ThemedChevronDown = withUnistyles(ChevronDown);
|
||||
|
||||
const mutedColorMapping = (theme: Theme) => ({ color: theme.colors.foregroundMuted });
|
||||
|
||||
@@ -83,10 +80,6 @@ function sizeDraftToOverride(value: string): number | undefined {
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
|
||||
function dropdownTriggerStyle({ pressed }: PressableStateCallbackType) {
|
||||
return [styles.trigger, pressed ? styles.triggerPressed : null];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Theme picker
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -175,26 +168,29 @@ function ThemeRow({
|
||||
const selectedLabel = selectedPluginTheme
|
||||
? selectedPluginTheme.name
|
||||
: getThemeLabel(t, builtInValue);
|
||||
const leading = useMemo(
|
||||
() =>
|
||||
selectedPluginTheme ? (
|
||||
<ThemeSwatch color={selectedPluginTheme.swatch} />
|
||||
) : (
|
||||
<ThemeLeading themeValue={builtInValue} />
|
||||
),
|
||||
[builtInValue, selectedPluginTheme],
|
||||
);
|
||||
return (
|
||||
<View style={settingsStyles.row}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.appearance.theme.title")}</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
style={dropdownTriggerStyle}
|
||||
<DropdownTrigger
|
||||
accessibilityLabel={t("settings.appearance.theme.accessibilityLabel", {
|
||||
value: selectedLabel,
|
||||
})}
|
||||
leading={leading}
|
||||
>
|
||||
{selectedPluginTheme ? (
|
||||
<ThemeSwatch color={selectedPluginTheme.swatch} />
|
||||
) : (
|
||||
<ThemeLeading themeValue={builtInValue} />
|
||||
)}
|
||||
<Text style={styles.triggerText}>{selectedLabel}</Text>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</DropdownMenuTrigger>
|
||||
{selectedLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200} scrollable>
|
||||
{THEME_OPTIONS.map((option, index) => {
|
||||
const previousOption = THEME_OPTIONS[index - 1];
|
||||
@@ -226,109 +222,6 @@ function ThemeRow({
|
||||
);
|
||||
}
|
||||
|
||||
interface AutoExpandReasoningRowProps {
|
||||
value: boolean;
|
||||
onChange: (value: boolean) => void;
|
||||
}
|
||||
|
||||
function AutoExpandReasoningRow({ value, onChange }: AutoExpandReasoningRowProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<SettingsSwitch
|
||||
label={t("settings.general.autoExpandReasoning.label")}
|
||||
hint={t("settings.general.autoExpandReasoning.description")}
|
||||
value={value}
|
||||
onValueChange={onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface ChatOutlineRowProps {
|
||||
value: boolean;
|
||||
onChange: (value: boolean) => void;
|
||||
}
|
||||
|
||||
function ChatOutlineRow({ value, onChange }: ChatOutlineRowProps) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<SettingsSwitch
|
||||
label={t("settings.appearance.chatOutline.title")}
|
||||
hint={t("settings.appearance.chatOutline.description")}
|
||||
value={value}
|
||||
onValueChange={onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const TOOL_CALL_DETAIL_LEVELS: readonly AppSettings["toolCallDetailLevel"][] = [
|
||||
"detailed",
|
||||
"overview",
|
||||
];
|
||||
|
||||
function getToolCallDetailLevelLabel(
|
||||
t: TFunction,
|
||||
value: AppSettings["toolCallDetailLevel"],
|
||||
): string {
|
||||
return t(`settings.general.toolCallDetail.options.${value}`);
|
||||
}
|
||||
|
||||
interface ToolCallDetailMenuItemProps {
|
||||
value: AppSettings["toolCallDetailLevel"];
|
||||
selected: boolean;
|
||||
onChange: (value: AppSettings["toolCallDetailLevel"]) => void;
|
||||
}
|
||||
|
||||
function ToolCallDetailMenuItem({ value, selected, onChange }: ToolCallDetailMenuItemProps) {
|
||||
const { t } = useTranslation();
|
||||
const handleSelect = useCallback(() => onChange(value), [onChange, value]);
|
||||
return (
|
||||
<DropdownMenuItem selected={selected} onSelect={handleSelect}>
|
||||
{getToolCallDetailLevelLabel(t, value)}
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
interface ToolCallDetailRowProps {
|
||||
value: AppSettings["toolCallDetailLevel"];
|
||||
onChange: (value: AppSettings["toolCallDetailLevel"]) => void;
|
||||
}
|
||||
|
||||
function ToolCallDetailRow({ value, onChange }: ToolCallDetailRowProps) {
|
||||
const { t } = useTranslation();
|
||||
const selectedLabel = getToolCallDetailLevelLabel(t, value);
|
||||
return (
|
||||
<View style={settingsStyles.row}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.general.toolCallDetail.label")}</Text>
|
||||
<Text style={settingsStyles.rowHint}>
|
||||
{t("settings.general.toolCallDetail.description")}
|
||||
</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
style={dropdownTriggerStyle}
|
||||
accessibilityLabel={t("settings.general.toolCallDetail.accessibilityLabel", {
|
||||
value: selectedLabel,
|
||||
})}
|
||||
>
|
||||
<Text style={styles.triggerText}>{selectedLabel}</Text>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{TOOL_CALL_DETAIL_LEVELS.map((option) => (
|
||||
<ToolCallDetailMenuItem
|
||||
key={option}
|
||||
value={option}
|
||||
selected={value === option}
|
||||
onChange={onChange}
|
||||
/>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fonts: family text fields + numeric size fields (commit on blur/submit)
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -478,15 +371,13 @@ function SyntaxRow({ value, onChange }: SyntaxRowProps) {
|
||||
</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
style={dropdownTriggerStyle}
|
||||
<DropdownTrigger
|
||||
accessibilityLabel={t("settings.appearance.syntax.highlightThemeAccessibility", {
|
||||
value: selectedLabel,
|
||||
})}
|
||||
>
|
||||
<Text style={styles.triggerText}>{selectedLabel}</Text>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</DropdownMenuTrigger>
|
||||
{selectedLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{SYNTAX_THEME_OPTIONS.map((option) => (
|
||||
<SyntaxMenuItem
|
||||
@@ -556,27 +447,6 @@ export function AppearanceSection() {
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleAutoExpandReasoningChange = useCallback(
|
||||
(autoExpandReasoning: boolean) => {
|
||||
void updateSettings({ autoExpandReasoning });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleToolCallDetailLevelChange = useCallback(
|
||||
(toolCallDetailLevel: AppSettings["toolCallDetailLevel"]) => {
|
||||
void updateSettings({ toolCallDetailLevel });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const handleChatOutlineChange = useCallback(
|
||||
(chatOutlineEnabled: boolean) => {
|
||||
void updateSettings({ chatOutlineEnabled });
|
||||
},
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
const commitUiFontFamily = useCallback(
|
||||
(value: string) => {
|
||||
const sanitized = sanitizeFontFamily(value);
|
||||
@@ -680,25 +550,6 @@ export function AppearanceSection() {
|
||||
/>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
<SettingsSection title={t("settings.appearance.detailLevel.title")}>
|
||||
<SettingsCard>
|
||||
<AutoExpandReasoningRow
|
||||
value={settings.autoExpandReasoning}
|
||||
onChange={handleAutoExpandReasoningChange}
|
||||
/>
|
||||
<ToolCallDetailRow
|
||||
value={settings.toolCallDetailLevel}
|
||||
onChange={handleToolCallDetailLevelChange}
|
||||
/>
|
||||
{!isNative ? (
|
||||
<ChatOutlineRow
|
||||
value={settings.chatOutlineEnabled}
|
||||
onChange={handleChatOutlineChange}
|
||||
/>
|
||||
) : null}
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
<SidebarNavSection />
|
||||
<SettingsSection title={t("settings.appearance.fonts.title")}>
|
||||
<View style={settingsStyles.card}>
|
||||
{showInterfaceFontFamilyRow ? (
|
||||
@@ -777,23 +628,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
borderTopWidth: theme.borderWidth[1],
|
||||
borderTopColor: theme.colors.border,
|
||||
},
|
||||
trigger: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
paddingVertical: theme.spacing[1],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderWidth: theme.borderWidth[1],
|
||||
borderColor: theme.colors.border,
|
||||
},
|
||||
triggerPressed: {
|
||||
opacity: 0.85,
|
||||
},
|
||||
triggerText: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
swatch: {
|
||||
width: ICON_SIZE.md,
|
||||
height: ICON_SIZE.md,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { View } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
SettingsCard,
|
||||
SettingsSection,
|
||||
SettingsSelect,
|
||||
SettingsSwitch,
|
||||
} from "@/components/settings";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { useAppSettings, type AppSettings } from "@/hooks/use-settings";
|
||||
|
||||
const TOOL_CALL_DETAIL_LEVELS: readonly AppSettings["toolCallDetailLevel"][] = [
|
||||
"detailed",
|
||||
"overview",
|
||||
];
|
||||
|
||||
export function ChatSection() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings } = useAppSettings();
|
||||
|
||||
const toolCallDetailOptions = useMemo(
|
||||
() =>
|
||||
TOOL_CALL_DETAIL_LEVELS.map((value) => ({
|
||||
value,
|
||||
label: t(`settings.general.toolCallDetail.options.${value}`),
|
||||
})),
|
||||
[t],
|
||||
);
|
||||
|
||||
const changeToolCallDetailLevel = useCallback(
|
||||
(toolCallDetailLevel: AppSettings["toolCallDetailLevel"]) =>
|
||||
void updateSettings({ toolCallDetailLevel }),
|
||||
[updateSettings],
|
||||
);
|
||||
const changeAutoExpandReasoning = useCallback(
|
||||
(autoExpandReasoning: boolean) => void updateSettings({ autoExpandReasoning }),
|
||||
[updateSettings],
|
||||
);
|
||||
const changeChatOutline = useCallback(
|
||||
(chatOutlineEnabled: boolean) => void updateSettings({ chatOutlineEnabled }),
|
||||
[updateSettings],
|
||||
);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<SettingsSection title={t("settings.appearance.detailLevel.title")}>
|
||||
<SettingsCard>
|
||||
<SettingsSwitch
|
||||
label={t("settings.general.autoExpandReasoning.label")}
|
||||
hint={t("settings.general.autoExpandReasoning.description")}
|
||||
value={settings.autoExpandReasoning}
|
||||
onValueChange={changeAutoExpandReasoning}
|
||||
/>
|
||||
<SettingsSelect
|
||||
label={t("settings.general.toolCallDetail.label")}
|
||||
hint={t("settings.general.toolCallDetail.description")}
|
||||
value={settings.toolCallDetailLevel}
|
||||
options={toolCallDetailOptions}
|
||||
onValueChange={changeToolCallDetailLevel}
|
||||
/>
|
||||
{isNative ? null : (
|
||||
<SettingsSwitch
|
||||
label={t("settings.appearance.chatOutline.title")}
|
||||
hint={t("settings.appearance.chatOutline.description")}
|
||||
value={settings.chatOutlineEnabled}
|
||||
onValueChange={changeChatOutline}
|
||||
/>
|
||||
)}
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { SettingsCard, SettingsSection, SettingsSelect } from "@/components/settings";
|
||||
import { useAppSettings, type SendBehavior } from "@/hooks/use-settings";
|
||||
|
||||
const SEND_BEHAVIORS: readonly SendBehavior[] = ["interrupt", "steer", "queue"];
|
||||
|
||||
export function SendingSection() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings } = useAppSettings();
|
||||
const options = useMemo(
|
||||
() =>
|
||||
SEND_BEHAVIORS.map((value) => ({
|
||||
value,
|
||||
label: t(`settings.general.defaultSend.options.${value}`),
|
||||
})),
|
||||
[t],
|
||||
);
|
||||
const change = useCallback(
|
||||
(sendBehavior: SendBehavior) => void updateSettings({ sendBehavior }),
|
||||
[updateSettings],
|
||||
);
|
||||
return (
|
||||
<SettingsSection title={t("settings.general.sending")}>
|
||||
<SettingsCard>
|
||||
<SettingsSelect
|
||||
label={t("settings.general.defaultSend.label")}
|
||||
hint={t(`settings.general.defaultSend.descriptions.${settings.sendBehavior}`)}
|
||||
value={settings.sendBehavior}
|
||||
options={options}
|
||||
onValueChange={change}
|
||||
/>
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pressable, Text, View, type PressableStateCallbackType } from "react-native";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { ChevronDown, Pencil } from "lucide-react-native";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Pencil } from "lucide-react-native";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { DropdownTrigger } from "@/components/ui/dropdown-trigger";
|
||||
import { AdaptiveRenameModal } from "@/components/rename-modal";
|
||||
import { WorkspaceMetaRow } from "@/components/sidebar/workspace-meta-row";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
@@ -28,15 +24,10 @@ import { settingsStyles } from "@/styles/settings";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import type { HostProfile } from "@/types/host-connection";
|
||||
|
||||
const ThemedChevronDown = withUnistyles(ChevronDown);
|
||||
const ThemedPencil = withUnistyles(Pencil);
|
||||
|
||||
const mutedColorMapping = (theme: Theme) => ({ color: theme.colors.foregroundMuted });
|
||||
|
||||
function dropdownTriggerStyle({ pressed }: PressableStateCallbackType) {
|
||||
return pressed ? [styles.trigger, styles.triggerPressed] : styles.trigger;
|
||||
}
|
||||
|
||||
function HostRenameButton({ host }: { host: HostProfile }) {
|
||||
const { t } = useTranslation();
|
||||
const { renameHost } = useHostMutations();
|
||||
@@ -119,23 +110,22 @@ function ColorMenuItem({
|
||||
function ColorRow({ color, onChange }: { color: HostColor; onChange: (color: HostColor) => void }) {
|
||||
const { t } = useTranslation();
|
||||
const selectedLabel = colorLabel(t, color);
|
||||
const leading = useMemo(() => <ColorSwatch color={color} />, [color]);
|
||||
return (
|
||||
<View style={[settingsStyles.row, settingsStyles.rowBorder]}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.host.appearance.color.label")}</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
style={dropdownTriggerStyle}
|
||||
<DropdownTrigger
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={t("settings.host.appearance.color.accessibilityLabel", {
|
||||
value: selectedLabel,
|
||||
})}
|
||||
leading={leading}
|
||||
>
|
||||
<ColorSwatch color={color} />
|
||||
<Text style={styles.triggerText}>{selectedLabel}</Text>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</DropdownMenuTrigger>
|
||||
{selectedLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{HOST_COLORS.map((option) => (
|
||||
<ColorMenuItem
|
||||
@@ -166,17 +156,15 @@ function BadgeDisplayRow({
|
||||
<Text style={settingsStyles.rowTitle}>{t("settings.host.appearance.badge.label")}</Text>
|
||||
</View>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger
|
||||
<DropdownTrigger
|
||||
testID="host-appearance-badge-display"
|
||||
style={dropdownTriggerStyle}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={t("settings.host.appearance.badge.accessibilityLabel", {
|
||||
value: selectedLabel,
|
||||
})}
|
||||
>
|
||||
<Text style={styles.triggerText}>{selectedLabel}</Text>
|
||||
<ThemedChevronDown size={ICON_SIZE.sm} uniProps={mutedColorMapping} />
|
||||
</DropdownMenuTrigger>
|
||||
{selectedLabel}
|
||||
</DropdownTrigger>
|
||||
<DropdownMenuContent side="bottom" align="end" width={200}>
|
||||
{HOST_BADGE_DISPLAYS.map((option) => (
|
||||
<BadgeDisplayMenuItem
|
||||
@@ -312,23 +300,6 @@ export function HostAppearanceSection({ host }: { host: HostProfile }) {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
trigger: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
paddingVertical: theme.spacing[1],
|
||||
paddingHorizontal: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
borderWidth: theme.borderWidth[1],
|
||||
borderColor: theme.colors.border,
|
||||
},
|
||||
triggerPressed: {
|
||||
opacity: 0.85,
|
||||
},
|
||||
triggerText: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
swatch: {
|
||||
width: ICON_SIZE.md,
|
||||
height: ICON_SIZE.md,
|
||||
|
||||
@@ -375,12 +375,6 @@ export function HostSettingsPage({
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.daemonHeader}>
|
||||
<Text style={styles.daemonHeaderLabel} numberOfLines={1}>
|
||||
{host.label}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<HostStatusBadges serverId={serverId} />
|
||||
<HostConnectionError serverId={serverId} />
|
||||
|
||||
@@ -1714,18 +1708,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
marginHorizontal: theme.spacing[4],
|
||||
marginBottom: theme.spacing[4],
|
||||
},
|
||||
daemonHeader: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[1],
|
||||
marginBottom: theme.spacing[4],
|
||||
},
|
||||
daemonHeaderLabel: {
|
||||
flexShrink: 1,
|
||||
fontSize: theme.fontSize.base,
|
||||
fontWeight: theme.fontWeight.medium,
|
||||
color: theme.colors.foreground,
|
||||
},
|
||||
identityBadges: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
|
||||
+41
-8
@@ -5,6 +5,7 @@ import {
|
||||
useAppSettings,
|
||||
type OpenInSidePanePreferences,
|
||||
type PullRequestOpenLocation,
|
||||
type ServiceUrlBehavior,
|
||||
} from "@/hooks/use-settings";
|
||||
|
||||
const SOURCES = [
|
||||
@@ -15,18 +16,26 @@ const SOURCES = [
|
||||
"subagents",
|
||||
] as const satisfies readonly (keyof OpenInSidePanePreferences)[];
|
||||
|
||||
type LayoutPreferenceSource = keyof OpenInSidePanePreferences | "pullRequests";
|
||||
const SERVICE_URL_BEHAVIORS: readonly ServiceUrlBehavior[] = ["ask", "in-app", "external"];
|
||||
|
||||
function LayoutPreferenceRow({
|
||||
const SERVICE_URL_LABEL_KEYS: Record<ServiceUrlBehavior, string> = {
|
||||
ask: "settings.general.serviceUrls.options.ask",
|
||||
"in-app": "settings.general.serviceUrls.options.inApp",
|
||||
external: "settings.general.serviceUrls.options.external",
|
||||
};
|
||||
|
||||
type OpenLocationSource = keyof OpenInSidePanePreferences | "pullRequests";
|
||||
|
||||
function OpenLocationRow({
|
||||
source,
|
||||
destination,
|
||||
allowExplorer,
|
||||
onDestinationChange,
|
||||
}: {
|
||||
source: LayoutPreferenceSource;
|
||||
source: OpenLocationSource;
|
||||
destination: PullRequestOpenLocation;
|
||||
allowExplorer?: boolean;
|
||||
onDestinationChange(source: LayoutPreferenceSource, destination: PullRequestOpenLocation): void;
|
||||
onDestinationChange(source: OpenLocationSource, destination: PullRequestOpenLocation): void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const options = useMemo(() => {
|
||||
@@ -52,11 +61,34 @@ function LayoutPreferenceRow({
|
||||
);
|
||||
}
|
||||
|
||||
export function LayoutSection() {
|
||||
function ServiceUrlRow() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings } = useAppSettings();
|
||||
const options = useMemo(
|
||||
() =>
|
||||
SERVICE_URL_BEHAVIORS.map((value) => ({ value, label: t(SERVICE_URL_LABEL_KEYS[value]) })),
|
||||
[t],
|
||||
);
|
||||
const change = useCallback(
|
||||
(serviceUrlBehavior: ServiceUrlBehavior) => void updateSettings({ serviceUrlBehavior }),
|
||||
[updateSettings],
|
||||
);
|
||||
return (
|
||||
<SettingsSelect
|
||||
label={t("settings.layout.openInSidePane.sources.serviceUrls.label")}
|
||||
value={settings.serviceUrlBehavior}
|
||||
options={options}
|
||||
onValueChange={change}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Where things open: files, diffs, subagents, pull requests, and script URLs. Desktop only. */
|
||||
export function OpenLocationSection() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings } = useAppSettings();
|
||||
const handleDestinationChange = useCallback(
|
||||
(source: LayoutPreferenceSource, destination: PullRequestOpenLocation) => {
|
||||
(source: OpenLocationSource, destination: PullRequestOpenLocation) => {
|
||||
if (source === "pullRequests") {
|
||||
void updateSettings({ pullRequestOpenLocation: destination });
|
||||
return;
|
||||
@@ -71,19 +103,20 @@ export function LayoutSection() {
|
||||
<SettingsSection title={t("settings.layout.openInSidePane.title")}>
|
||||
<SettingsCard>
|
||||
{SOURCES.map((source) => (
|
||||
<LayoutPreferenceRow
|
||||
<OpenLocationRow
|
||||
key={source}
|
||||
source={source}
|
||||
destination={settings.openInSidePane[source] ? "side" : "main"}
|
||||
onDestinationChange={handleDestinationChange}
|
||||
/>
|
||||
))}
|
||||
<LayoutPreferenceRow
|
||||
<OpenLocationRow
|
||||
source="pullRequests"
|
||||
destination={settings.pullRequestOpenLocation}
|
||||
allowExplorer
|
||||
onDestinationChange={handleDestinationChange}
|
||||
/>
|
||||
<ServiceUrlRow />
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
);
|
||||
@@ -0,0 +1,67 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { SettingsSection } from "@/components/settings";
|
||||
import { FormTextInput } from "@/components/ui/form-field";
|
||||
import { parseTerminalScrollbackLines, useAppSettings } from "@/hooks/use-settings";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
|
||||
export function TerminalSection() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings } = useAppSettings();
|
||||
const [scrollbackValue, setScrollbackValue] = useState(String(settings.terminalScrollbackLines));
|
||||
|
||||
const handleChangeText = useCallback((value: string) => {
|
||||
setScrollbackValue(value.replace(/[^\d]/g, ""));
|
||||
}, []);
|
||||
|
||||
const commitScrollback = useCallback(() => {
|
||||
const nextValue =
|
||||
parseTerminalScrollbackLines(scrollbackValue) ?? settings.terminalScrollbackLines;
|
||||
setScrollbackValue(String(nextValue));
|
||||
if (nextValue !== settings.terminalScrollbackLines) {
|
||||
void updateSettings({ terminalScrollbackLines: nextValue });
|
||||
}
|
||||
}, [scrollbackValue, settings.terminalScrollbackLines, updateSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
setScrollbackValue(String(settings.terminalScrollbackLines));
|
||||
}, [settings.terminalScrollbackLines]);
|
||||
|
||||
return (
|
||||
<SettingsSection title={t("settings.sections.terminal")}>
|
||||
<View style={settingsStyles.card}>
|
||||
<View style={settingsStyles.row}>
|
||||
<View style={settingsStyles.rowContent}>
|
||||
<Text style={settingsStyles.rowTitle}>
|
||||
{t("settings.general.terminalScrollback.label")}
|
||||
</Text>
|
||||
<Text style={settingsStyles.rowHint}>
|
||||
{t("settings.general.terminalScrollback.description")}
|
||||
</Text>
|
||||
</View>
|
||||
<FormTextInput
|
||||
size="sm"
|
||||
initialValue={scrollbackValue}
|
||||
onChangeText={handleChangeText}
|
||||
onBlur={commitScrollback}
|
||||
onSubmitEditing={commitScrollback}
|
||||
keyboardType="number-pad"
|
||||
inputMode="numeric"
|
||||
selectTextOnFocus
|
||||
style={styles.scrollbackInput}
|
||||
accessibilityLabel={t("settings.general.terminalScrollback.accessibilityLabel")}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</SettingsSection>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
scrollbackInput: {
|
||||
width: 112,
|
||||
textAlign: "right",
|
||||
},
|
||||
});
|
||||
@@ -159,6 +159,20 @@ const darkStatusColors = {
|
||||
statusMerged: "#a890d5",
|
||||
};
|
||||
|
||||
// Status tints — the fill of a status badge. The status color itself at low opacity, so a
|
||||
// badge takes its state's hue from the same source as its text and never drifts from it.
|
||||
// Dark surfaces swallow more of the tint, so the dark band runs a little stronger.
|
||||
function statusTints(colors: typeof lightStatusColors, alphaHex: string) {
|
||||
return {
|
||||
statusSuccessTint: `${colors.statusSuccess}${alphaHex}`,
|
||||
statusDangerTint: `${colors.statusDanger}${alphaHex}`,
|
||||
statusWarningTint: `${colors.statusWarning}${alphaHex}`,
|
||||
};
|
||||
}
|
||||
|
||||
const lightStatusTints = statusTints(lightStatusColors, "1f"); // 12%
|
||||
const darkStatusTints = statusTints(darkStatusColors, "29"); // 16%
|
||||
|
||||
// Status *dot* colors — the small filled discs on a sidebar row, and the glyphs that stand in
|
||||
// for them. Same four hues and the same generation rule as the status colors above, but its
|
||||
// own band, because a dot is doing a different job than a check icon or a host badge.
|
||||
@@ -289,6 +303,7 @@ export function buildLightSemanticColors(tint: LightThemeConfig) {
|
||||
|
||||
...lightDiffColors,
|
||||
...lightStatusColors,
|
||||
...lightStatusTints,
|
||||
...lightStatusDotColors,
|
||||
|
||||
terminal: {
|
||||
@@ -420,6 +435,7 @@ export function buildDarkSemanticColors(tint: DarkThemeConfig) {
|
||||
|
||||
...darkDiffColors,
|
||||
...darkStatusColors,
|
||||
...darkStatusTints,
|
||||
...darkStatusDotColors,
|
||||
|
||||
terminal: {
|
||||
|
||||
@@ -492,7 +492,10 @@ export function resolveKnownHostRoute(input: {
|
||||
export const SETTINGS_SECTION_SLUGS = [
|
||||
"general",
|
||||
"appearance",
|
||||
"layout",
|
||||
"sidebar",
|
||||
"chat",
|
||||
"terminal",
|
||||
"browser",
|
||||
"editor",
|
||||
"shortcuts",
|
||||
"integrations",
|
||||
|
||||
@@ -7,6 +7,10 @@ const testTheme = {
|
||||
statusDanger: "#b91c1c",
|
||||
statusWarning: "#d97706",
|
||||
statusMerged: "#7c3aed",
|
||||
// Same rule as the real theme: the status color at 12%.
|
||||
statusSuccessTint: "#15803d1f",
|
||||
statusDangerTint: "#b91c1c1f",
|
||||
statusWarningTint: "#d977061f",
|
||||
// The light band's values, so a test can name the colour it expects.
|
||||
statusDotSuccess: "#299f51",
|
||||
statusDotDanger: "#f12e2f",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo CLI - control your AI coding agents from the command line",
|
||||
"bin": {
|
||||
"paseo": "bin/paseo"
|
||||
@@ -28,9 +28,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/server": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/server": "0.10.0-beta.1",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo client SDK package",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -39,8 +39,8 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/relay": "0.9.2",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/relay": "0.10.0-beta.1",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -9,7 +9,10 @@ const MAX_TRANSIENT_DETACHED_PANES = 2;
|
||||
const SETTINGS_DESTINATIONS = [
|
||||
"General",
|
||||
"Appearance",
|
||||
"Layout",
|
||||
"Sidebar",
|
||||
"Chat",
|
||||
"Terminal",
|
||||
"Browser",
|
||||
"Editor",
|
||||
"Shortcuts",
|
||||
"Integrations",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"private": true,
|
||||
"description": "Paseo desktop app (Electron wrapper)",
|
||||
"homepage": "https://paseo.sh",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Native module for two way audio streaming",
|
||||
"keywords": [
|
||||
"ExpoTwoWayAudio",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"files": [
|
||||
"dist",
|
||||
"!dist/**/*.map",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo plugin SDK package",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -65,8 +65,8 @@
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.1.0",
|
||||
@@ -76,8 +76,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"react": "~19.1.0",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo shared protocol schemas and wire types",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -466,22 +466,12 @@ export interface AgentPermissionRequest {
|
||||
metadata?: AgentMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* The answer to one question of a `question` permission request, aligned by index with
|
||||
* `input.questions`. `selected` holds the chosen option labels; `text` holds a typed answer.
|
||||
*/
|
||||
export interface AgentQuestionAnswer {
|
||||
selected: string[];
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export type AgentPermissionResponse =
|
||||
| {
|
||||
behavior: "allow";
|
||||
selectedActionId?: string;
|
||||
updatedInput?: AgentMetadata;
|
||||
updatedPermissions?: AgentPermissionUpdate[];
|
||||
questionAnswers?: AgentQuestionAnswer[];
|
||||
}
|
||||
| {
|
||||
behavior: "deny";
|
||||
|
||||
@@ -456,11 +456,6 @@ const AgentPermissionActionSchema = z.object({
|
||||
intent: z.enum(["implement", "implement_resume", "dismiss"]).optional(),
|
||||
});
|
||||
|
||||
const AgentQuestionAnswerSchema = z.object({
|
||||
selected: z.array(z.string()),
|
||||
text: z.string().optional(),
|
||||
});
|
||||
|
||||
export const AgentPermissionResponseSchema: z.ZodType<AgentPermissionResponse> =
|
||||
z.discriminatedUnion("behavior", [
|
||||
z.object({
|
||||
@@ -468,7 +463,6 @@ export const AgentPermissionResponseSchema: z.ZodType<AgentPermissionResponse> =
|
||||
selectedActionId: z.string().optional(),
|
||||
updatedInput: z.record(z.string(), z.unknown()).optional(),
|
||||
updatedPermissions: z.array(AgentPermissionUpdateSchema).optional(),
|
||||
questionAnswers: z.array(AgentQuestionAnswerSchema).optional(),
|
||||
}),
|
||||
z.object({
|
||||
behavior: z.literal("deny"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo relay for bridging daemon and client connections",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"description": "Paseo backend server",
|
||||
"files": [
|
||||
"dist/server",
|
||||
@@ -107,11 +107,11 @@
|
||||
"@agentclientprotocol/sdk": "^0.17.1",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.246",
|
||||
"@anthropic-ai/sdk": "^0.104.2",
|
||||
"@getpaseo/client": "0.9.2",
|
||||
"@getpaseo/highlight": "0.9.2",
|
||||
"@getpaseo/plugin": "0.9.2",
|
||||
"@getpaseo/protocol": "0.9.2",
|
||||
"@getpaseo/relay": "0.9.2",
|
||||
"@getpaseo/client": "0.10.0-beta.1",
|
||||
"@getpaseo/highlight": "0.10.0-beta.1",
|
||||
"@getpaseo/plugin": "0.10.0-beta.1",
|
||||
"@getpaseo/protocol": "0.10.0-beta.1",
|
||||
"@getpaseo/relay": "0.10.0-beta.1",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
|
||||
@@ -54,7 +54,6 @@ import {
|
||||
type ImportableProviderSession,
|
||||
type ListImportableSessionsOptions,
|
||||
} from "./agent-sdk-types.js";
|
||||
import { resolveQuestionAnswers } from "./question-answers.js";
|
||||
import { buildArchivedAgentRecord, type ArchivedStoredAgentRecord } from "./agent-archive.js";
|
||||
import type { StoredAgentRecord, AgentStorage } from "./agent-storage.js";
|
||||
import type { AgentOwner } from "./agent-owner.js";
|
||||
@@ -2982,11 +2981,7 @@ export class AgentManager {
|
||||
agent.inFlightPermissionResponses.add(requestId);
|
||||
|
||||
try {
|
||||
const request = agent.pendingPermissions.get(requestId);
|
||||
const result = await agent.session.respondToPermission(
|
||||
requestId,
|
||||
request ? resolveQuestionAnswers(request, response) : response,
|
||||
);
|
||||
const result = await agent.session.respondToPermission(requestId, response);
|
||||
agent.pendingPermissions.delete(requestId);
|
||||
|
||||
try {
|
||||
|
||||
@@ -504,22 +504,12 @@ export interface AgentPermissionRequest {
|
||||
metadata?: AgentMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* The answer to one question of a `question` permission request, aligned by index with
|
||||
* `input.questions`. `selected` holds the chosen option labels; `text` holds a typed answer.
|
||||
*/
|
||||
export interface AgentQuestionAnswer {
|
||||
selected: string[];
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export type AgentPermissionResponse =
|
||||
| {
|
||||
behavior: "allow";
|
||||
selectedActionId?: string;
|
||||
updatedInput?: AgentMetadata;
|
||||
updatedPermissions?: AgentPermissionUpdate[];
|
||||
questionAnswers?: AgentQuestionAnswer[];
|
||||
}
|
||||
| {
|
||||
behavior: "deny";
|
||||
|
||||
@@ -5042,7 +5042,6 @@ describe("Codex app-server provider", () => {
|
||||
|
||||
await session.respondToPermission("permission-call-question-2", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["Tea"] }],
|
||||
updatedInput: {
|
||||
answers: {
|
||||
Drink: "Tea",
|
||||
@@ -5062,7 +5061,6 @@ describe("Codex app-server provider", () => {
|
||||
requestId: "permission-call-question-2",
|
||||
resolution: {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["Tea"] }],
|
||||
updatedInput: {
|
||||
answers: {
|
||||
Drink: "Tea",
|
||||
@@ -5102,33 +5100,6 @@ describe("Codex app-server provider", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("answers multi-select questions with option labels that contain commas", async () => {
|
||||
const session = createSession();
|
||||
const pendingResponse = asInternals(session).handleToolApprovalRequest({
|
||||
itemId: "call-question-3",
|
||||
threadId: "thread-1",
|
||||
turnId: "turn-1",
|
||||
questions: [
|
||||
{
|
||||
id: "colors",
|
||||
header: "Colors",
|
||||
question: "Which colors?",
|
||||
multiSelect: true,
|
||||
options: [{ label: "Red, bright" }, { label: "Blue" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await session.respondToPermission("permission-call-question-3", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["Red, bright", "Blue"], text: "Green, dark" }],
|
||||
});
|
||||
|
||||
await expect(pendingResponse).resolves.toEqual({
|
||||
answers: { colors: { answers: ["Red, bright", "Blue", "Green, dark"] } },
|
||||
});
|
||||
});
|
||||
|
||||
test("emits a synthetic plan approval permission after a successful Codex plan turn", () => {
|
||||
const session = createSession({
|
||||
featureValues: { plan_mode: true, fast_mode: true },
|
||||
|
||||
@@ -38,7 +38,6 @@ import {
|
||||
type ProviderRefreshContext,
|
||||
type ResolveAgentDefaultModeInput,
|
||||
} from "../agent-sdk-types.js";
|
||||
import { questionAnswerValues } from "../question-answers.js";
|
||||
import { importSessionFromPersistence } from "../provider-session-import.js";
|
||||
import { runProviderRefreshActivity } from "../provider-refresh-deadline.js";
|
||||
import type { Logger } from "pino";
|
||||
@@ -1265,21 +1264,39 @@ export function mapCodexQuestionRequestToToolCall(params: {
|
||||
};
|
||||
}
|
||||
|
||||
function mapCodexQuestionResponse(params: {
|
||||
function mapCodexQuestionResponseByHeader(params: {
|
||||
questions: CodexQuestionPrompt[];
|
||||
response: AgentPermissionResponse;
|
||||
}): Record<string, { answers: string[] }> | null {
|
||||
if (params.response.behavior !== "allow" || !params.response.questionAnswers) {
|
||||
if (params.response.behavior !== "allow") {
|
||||
return null;
|
||||
}
|
||||
const questionAnswers = params.response.questionAnswers;
|
||||
const updatedInputRecord = toObjectRecord(params.response.updatedInput);
|
||||
const answersRecord = toObjectRecord(updatedInputRecord?.answers);
|
||||
if (!answersRecord) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const answers: Record<string, { answers: string[] }> = {};
|
||||
params.questions.forEach((question, index) => {
|
||||
const values = questionAnswerValues(questionAnswers[index]);
|
||||
for (const question of params.questions) {
|
||||
const rawAnswer = answersRecord[question.header];
|
||||
if (typeof rawAnswer !== "string") {
|
||||
continue;
|
||||
}
|
||||
const normalizedAnswer = rawAnswer.trim();
|
||||
if (!normalizedAnswer) {
|
||||
continue;
|
||||
}
|
||||
const values = question.multiSelect
|
||||
? normalizedAnswer
|
||||
.split(",")
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0)
|
||||
: [normalizedAnswer];
|
||||
if (values.length > 0) {
|
||||
answers[question.id] = { answers: values };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Object.keys(answers).length > 0 ? answers : null;
|
||||
}
|
||||
@@ -4587,7 +4604,7 @@ export class CodexAppServerAgentSession implements AgentSession {
|
||||
? pendingRequest.metadata.itemId
|
||||
: requestId;
|
||||
if (response.behavior === "allow") {
|
||||
const mappedAnswers = mapCodexQuestionResponse({
|
||||
const mappedAnswers = mapCodexQuestionResponseByHeader({
|
||||
questions,
|
||||
response,
|
||||
});
|
||||
|
||||
@@ -332,7 +332,7 @@ describe("OpenCode auto_accept feature", () => {
|
||||
|
||||
await session.respondToPermission("question-1", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["Proceed"] }],
|
||||
updatedInput: { answers: { Decision: "Proceed" } },
|
||||
});
|
||||
|
||||
expect(openCodeClient.calls.questionReply).toHaveLength(1);
|
||||
@@ -386,7 +386,7 @@ describe("OpenCode auto_accept feature", () => {
|
||||
|
||||
await session.respondToPermission("question-1", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: [], text: "Use another answer" }],
|
||||
updatedInput: { answers: { Decision: "Use another answer" } },
|
||||
});
|
||||
|
||||
expect(openCodeClient.calls.questionReply).toEqual([
|
||||
|
||||
@@ -5296,7 +5296,7 @@ describe("OpenCode provider subagent contract", () => {
|
||||
|
||||
await parent.respondToPermission("question_provider_child", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["A"] }],
|
||||
updatedInput: { answers: { Path: "A" } },
|
||||
});
|
||||
expect(parentClient.calls.questionReply).toContainEqual(
|
||||
expect.objectContaining({
|
||||
@@ -5308,50 +5308,6 @@ describe("OpenCode provider subagent contract", () => {
|
||||
await parent.close();
|
||||
});
|
||||
|
||||
test("replies to questions with option labels and custom answers that contain commas", async () => {
|
||||
const { parent, openCode } = await createParentSession("ses_parent_comma_question");
|
||||
openCode.emitEvent({
|
||||
type: "question.asked",
|
||||
properties: {
|
||||
id: "question_comma",
|
||||
sessionID: "ses_parent_comma_question",
|
||||
questions: [
|
||||
{
|
||||
question: "Which colors?",
|
||||
header: "Colors",
|
||||
multiple: true,
|
||||
options: [
|
||||
{ label: "Red, bright", description: "Warm" },
|
||||
{ label: "Blue", description: "Cool" },
|
||||
],
|
||||
},
|
||||
{
|
||||
question: "Which city?",
|
||||
header: "City",
|
||||
options: [{ label: "Paris, France", description: "Europe" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
await vi.waitFor(() => expect(parent.getPendingPermissions()).toHaveLength(1));
|
||||
|
||||
await parent.respondToPermission("question_comma", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [
|
||||
{ selected: ["Red, bright", "Blue"], text: "Green, dark" },
|
||||
{ selected: ["Paris, France"] },
|
||||
],
|
||||
});
|
||||
|
||||
expect(openCode.calls.questionReply).toContainEqual(
|
||||
expect.objectContaining({
|
||||
requestID: "question_comma",
|
||||
answers: [["Red, bright", "Blue", "Green, dark"], ["Paris, France"]],
|
||||
}),
|
||||
);
|
||||
await parent.close();
|
||||
});
|
||||
|
||||
test("emits the same child status when descriptor semantics change", async () => {
|
||||
const { parent, openCode } = await createParentSession("ses_parent_child_changed_status");
|
||||
const events: AgentStreamEvent[] = [];
|
||||
|
||||
@@ -57,7 +57,6 @@ import {
|
||||
type ToolCallDetail,
|
||||
type ToolCallTimelineItem,
|
||||
} from "../agent-sdk-types.js";
|
||||
import { questionAnswerValues } from "../question-answers.js";
|
||||
import { importSessionFromPersistence } from "../provider-session-import.js";
|
||||
import {
|
||||
raceProviderRefreshAbort,
|
||||
@@ -4958,10 +4957,19 @@ class OpenCodeAgentSession implements AgentSession {
|
||||
directory,
|
||||
});
|
||||
} else {
|
||||
const answersRecord = readOpenCodeRecord(response.updatedInput?.answers);
|
||||
const questions = Array.isArray(pending.input?.questions) ? pending.input.questions : [];
|
||||
const answers = questions.map((_, index) =>
|
||||
questionAnswerValues(response.questionAnswers?.[index]),
|
||||
);
|
||||
const answers = questions.map((item) => {
|
||||
const header = readNonEmptyString(readOpenCodeRecord(item)?.header);
|
||||
const rawAnswer = header ? readNonEmptyString(answersRecord?.[header]) : null;
|
||||
if (!rawAnswer) {
|
||||
return [];
|
||||
}
|
||||
return rawAnswer
|
||||
.split(",")
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0);
|
||||
});
|
||||
|
||||
await this.client.question.reply({
|
||||
requestID: requestId,
|
||||
|
||||
@@ -7,6 +7,60 @@ import { OpenCodeV2AgentClient } from "./agent.js";
|
||||
import { V2Harness } from "../test-utils/v2-harness.js";
|
||||
|
||||
describe("OpenCode v2 session lifecycle", () => {
|
||||
test("reconnects after a helper exits and restores session configuration on the next turn", async () => {
|
||||
const first = new V2Harness();
|
||||
const second = new V2Harness();
|
||||
let exit!: (error: Error) => void;
|
||||
const exited = new Promise<Error>((resolve) => {
|
||||
exit = resolve;
|
||||
});
|
||||
let acquisitions = 0;
|
||||
const client = new OpenCodeV2AgentClient({
|
||||
logger: createTestLogger(),
|
||||
runtime: {
|
||||
acquire: async () => {
|
||||
acquisitions += 1;
|
||||
return acquisitions === 1 ? { ...first.connection, exited } : second.connection;
|
||||
},
|
||||
shutdown: async () => undefined,
|
||||
},
|
||||
});
|
||||
first.wait = () => new Promise<void>(() => undefined);
|
||||
second.prompt = async (input) => {
|
||||
second.history.push({
|
||||
id: "answer",
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { providerID: "test", id: "model" },
|
||||
time: { created: 2 },
|
||||
content: [{ type: "text", text: "recovered" }],
|
||||
});
|
||||
second.prompts.push(input.text);
|
||||
};
|
||||
const session = await client.createSession(
|
||||
{
|
||||
provider: "opencode",
|
||||
cwd: "/tmp/project",
|
||||
mcpServers: { tools: { type: "stdio", command: "tools" } },
|
||||
},
|
||||
{ env: { TOKEN: "test" } },
|
||||
);
|
||||
const running = session.run("before exit");
|
||||
await expect.poll(() => first.prompts).toEqual(["before exit"]);
|
||||
exit(new Error("helper exited"));
|
||||
await expect(running).rejects.toThrow("helper exited");
|
||||
expect(acquisitions).toBe(1);
|
||||
try {
|
||||
expect((await session.run("after exit")).finalText).toBe("recovered");
|
||||
expect(second.prompts).toEqual(["after exit"]);
|
||||
expect(second.mcpAdds).toEqual(["tools"]);
|
||||
expect(second.environments).toEqual([{ sessionID: "session", variables: { TOKEN: "test" } }]);
|
||||
expect(first.releases).toBe(1);
|
||||
} finally {
|
||||
await session.close();
|
||||
}
|
||||
await expect(session.startTurn("after close")).rejects.toThrow("OpenCode session is closed");
|
||||
});
|
||||
test("fails initialization when the event stream ends before connecting", async () => {
|
||||
const harness = new V2Harness();
|
||||
harness.api.event.subscribe = async function* () {};
|
||||
|
||||
@@ -155,6 +155,11 @@ export class OpenCodeV2AgentClient implements AgentClient {
|
||||
launch: AgentLaunchContext | undefined,
|
||||
persist: boolean,
|
||||
) {
|
||||
const acquire = () =>
|
||||
this.runtime.acquire(
|
||||
requiresDedicatedV2Server(config, launch) ? { env: launch?.env, dedicated: true } : {},
|
||||
);
|
||||
let ownedConnection = connection;
|
||||
const unbind = this.options.bridge?.bindSession({
|
||||
sessionId: info.id,
|
||||
env: launch?.env ?? {},
|
||||
@@ -162,7 +167,7 @@ export class OpenCodeV2AgentClient implements AgentClient {
|
||||
});
|
||||
const bound = new Map<string, () => void>();
|
||||
const bindChild = (childId: string) => {
|
||||
this.connections.set(childId, connection);
|
||||
this.connections.set(childId, ownedConnection);
|
||||
if (bound.has(childId)) return;
|
||||
const childUnbind = this.options.bridge?.bindSession({
|
||||
sessionId: childId,
|
||||
@@ -176,7 +181,12 @@ export class OpenCodeV2AgentClient implements AgentClient {
|
||||
unbind?.();
|
||||
for (const cleanup of bound.values()) cleanup();
|
||||
for (const [id, owner] of this.connections)
|
||||
if (owner === connection) this.connections.delete(id);
|
||||
if (owner === ownedConnection) this.connections.delete(id);
|
||||
};
|
||||
const moved = (next: V2Connection) => {
|
||||
for (const [id, owner] of this.connections)
|
||||
if (owner === ownedConnection) this.connections.set(id, next);
|
||||
ownedConnection = next;
|
||||
};
|
||||
const session = new OpenCodeV2Session(
|
||||
connection,
|
||||
@@ -187,6 +197,8 @@ export class OpenCodeV2AgentClient implements AgentClient {
|
||||
Boolean(this.options.bridge),
|
||||
releaseBindings,
|
||||
bindChild,
|
||||
acquire,
|
||||
moved,
|
||||
);
|
||||
try {
|
||||
if (this.options.bridge) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { messages } from "./history.js";
|
||||
|
||||
import type { V2Api } from "./api.js";
|
||||
interface ChildrenOptions {
|
||||
client: V2Api;
|
||||
client(): V2Api;
|
||||
id: string;
|
||||
emit(event: AgentStreamEvent): void;
|
||||
reconcilePermissions(id: string): Promise<void>;
|
||||
@@ -34,14 +34,14 @@ export class SessionChildren {
|
||||
this.children.has(event.data.sessionID)
|
||||
) {
|
||||
await this.reconcileChild(
|
||||
await this.options.client.session.get({ sessionID: event.data.sessionID }),
|
||||
await this.options.client().session.get({ sessionID: event.data.sessionID }),
|
||||
);
|
||||
}
|
||||
}
|
||||
async reconcile(parentID: string) {
|
||||
let cursor: string | undefined;
|
||||
do {
|
||||
const page = await this.options.client.session.list({
|
||||
const page = await this.options.client().session.list({
|
||||
...(cursor ? { cursor } : { parentID }),
|
||||
limit: 100,
|
||||
});
|
||||
@@ -60,7 +60,7 @@ export class SessionChildren {
|
||||
this.children.set(info.id, timeline);
|
||||
this.options.bindChild?.(info.id);
|
||||
}
|
||||
const active = await this.options.client.session.active();
|
||||
const active = await this.options.client().session.active();
|
||||
let status: "running" | "failed" | "canceled" | "completed" = "completed";
|
||||
if (active[info.id]) status = "running";
|
||||
else if (info.outcome === "failed") status = "failed";
|
||||
@@ -79,7 +79,7 @@ export class SessionChildren {
|
||||
this.childStates.set(info.id, signature);
|
||||
this.options.emit({ type: "provider_subagent", provider: "opencode", event: presentation });
|
||||
}
|
||||
for (const event of timeline.messages(await messages(this.options.client, info.id))) {
|
||||
for (const event of timeline.messages(await messages(this.options.client(), info.id))) {
|
||||
if (event.type === "timeline")
|
||||
this.options.emit({
|
||||
type: "provider_subagent",
|
||||
|
||||
@@ -35,23 +35,17 @@ describe("OpenCode v2 questions", () => {
|
||||
});
|
||||
const session = await client.createSession({ provider: "opencode", cwd: "/tmp/project" });
|
||||
try {
|
||||
expect(session.getPendingPermissions()).toEqual([
|
||||
expect.objectContaining({
|
||||
input: {
|
||||
questions: expect.arrayContaining([
|
||||
expect.objectContaining({ header: "features", multiSelect: true }),
|
||||
]),
|
||||
},
|
||||
}),
|
||||
]);
|
||||
expect(session.getPendingPermissions()).toHaveLength(1);
|
||||
await session.respondToPermission("question", {
|
||||
behavior: "allow",
|
||||
questionAnswers: [
|
||||
{ selected: ["Blue"] },
|
||||
{ selected: ["Search"], text: "Web, images" },
|
||||
{ selected: [], text: "3" },
|
||||
{ selected: [], text: "false" },
|
||||
],
|
||||
updatedInput: {
|
||||
answers: {
|
||||
color: "Blue",
|
||||
features: ["Search"],
|
||||
count: "3",
|
||||
enabled: "false",
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(answers).toEqual([
|
||||
{
|
||||
@@ -59,7 +53,7 @@ describe("OpenCode v2 questions", () => {
|
||||
formID: "question",
|
||||
answer: {
|
||||
color: "blue-id",
|
||||
features: ["search-id", "Web, images"],
|
||||
features: ["search-id"],
|
||||
count: 3,
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
@@ -4,18 +4,16 @@ import type { V2Api } from "./api.js";
|
||||
import type {
|
||||
AgentPermissionRequest,
|
||||
AgentPermissionResponse,
|
||||
AgentQuestionAnswer,
|
||||
AgentSessionConfig,
|
||||
AgentStreamEvent,
|
||||
} from "../../../agent-sdk-types.js";
|
||||
import { questionAnswerValues } from "../../../question-answers.js";
|
||||
|
||||
export class SessionPermissions {
|
||||
private readonly pending = new Map<string, AgentPermissionRequest>();
|
||||
private readonly permissionOwners = new Map<string, string>();
|
||||
private readonly forms = new Map<string, FormInfo>();
|
||||
constructor(
|
||||
private readonly client: V2Api,
|
||||
private readonly getClient: () => V2Api,
|
||||
private readonly id: string,
|
||||
private readonly config: AgentSessionConfig,
|
||||
private readonly emit: (event: AgentStreamEvent) => void,
|
||||
@@ -39,16 +37,19 @@ export class SessionPermissions {
|
||||
const form = this.forms.get(requestId);
|
||||
if (form) {
|
||||
if (response.behavior === "deny")
|
||||
await this.client.session.form.cancel({ sessionID: form.sessionID, formID: form.id });
|
||||
await this.getClient().session.form.cancel({ sessionID: form.sessionID, formID: form.id });
|
||||
else {
|
||||
const answers = response.questionAnswers;
|
||||
const raw = response.updatedInput?.answers;
|
||||
const answer: Record<string, FormValue> = {};
|
||||
if (!answers) throw new Error("OpenCode question response requires answers");
|
||||
form.fields.forEach((field, index) => {
|
||||
const normalized = formAnswer(field, answers[index]);
|
||||
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
||||
throw new Error("OpenCode question response requires answers");
|
||||
for (const field of form.fields) {
|
||||
const value: unknown =
|
||||
Reflect.get(raw, field.key) ?? Reflect.get(raw, field.title ?? field.key);
|
||||
const normalized = formAnswer(field, value);
|
||||
if (normalized !== undefined) answer[field.key] = normalized;
|
||||
});
|
||||
await this.client.session.form.reply({
|
||||
}
|
||||
await this.getClient().session.form.reply({
|
||||
sessionID: form.sessionID,
|
||||
formID: form.id,
|
||||
answer,
|
||||
@@ -56,7 +57,7 @@ export class SessionPermissions {
|
||||
}
|
||||
this.forms.delete(requestId);
|
||||
} else {
|
||||
await this.client.permission.reply({
|
||||
await this.getClient().permission.reply({
|
||||
sessionID: this.permissionOwners.get(requestId) ?? this.id,
|
||||
requestID: requestId,
|
||||
decision: permissionReply(response),
|
||||
@@ -66,8 +67,8 @@ export class SessionPermissions {
|
||||
}
|
||||
async reconcile(sessionID: string) {
|
||||
const [permissions, forms] = await Promise.all([
|
||||
this.client.permission.list({ sessionID }),
|
||||
this.client.session.form.list({ sessionID }),
|
||||
this.getClient().permission.list({ sessionID }),
|
||||
this.getClient().session.form.list({ sessionID }),
|
||||
]);
|
||||
for (const request of permissions) {
|
||||
if (this.pending.has(request.id)) continue;
|
||||
@@ -102,7 +103,7 @@ export class SessionPermissions {
|
||||
header: field.key,
|
||||
question: field.title ?? field.key,
|
||||
options: "options" in field ? field.options : undefined,
|
||||
multiSelect: field.type === "multiselect",
|
||||
multiple: field.type === "multiselect",
|
||||
})),
|
||||
},
|
||||
};
|
||||
@@ -123,13 +124,9 @@ function permissionReply(response: AgentPermissionResponse): "reject" | "once" |
|
||||
return response.selectedActionId === "always" ? "always" : "once";
|
||||
}
|
||||
|
||||
function formAnswer(
|
||||
field: FormInfo["fields"][number],
|
||||
answer: AgentQuestionAnswer | undefined,
|
||||
): FormValue | undefined {
|
||||
const values = questionAnswerValues(answer);
|
||||
const [value] = values;
|
||||
if (value === undefined || field.type === "external") return undefined;
|
||||
function formAnswer(field: FormInfo["fields"][number], value: unknown): FormValue | undefined {
|
||||
if (value === undefined) return undefined;
|
||||
if (field.type === "external") return undefined;
|
||||
const labelValue = (label: string) => {
|
||||
const options = "options" in field ? field.options : undefined;
|
||||
return (
|
||||
@@ -139,15 +136,21 @@ function formAnswer(
|
||||
);
|
||||
};
|
||||
if (field.type === "multiselect") {
|
||||
return values.map(labelValue);
|
||||
} else if (field.type === "string") {
|
||||
if (Array.isArray(value) && value.every((item: unknown) => typeof item === "string"))
|
||||
return value.map(labelValue);
|
||||
} else if (field.type === "string" && typeof value === "string") {
|
||||
return labelValue(value);
|
||||
} else if (field.type === "boolean") {
|
||||
if (typeof value === "boolean") return value;
|
||||
if (value === "true") return true;
|
||||
if (value === "false") return false;
|
||||
} else if (field.type === "number" || field.type === "integer") {
|
||||
const numeric = value.trim() ? Number(value) : Number.NaN;
|
||||
if (Number.isFinite(numeric) && (field.type !== "integer" || Number.isInteger(numeric)))
|
||||
const numeric = typeof value === "string" && value.trim() ? Number(value) : value;
|
||||
if (
|
||||
typeof numeric === "number" &&
|
||||
Number.isFinite(numeric) &&
|
||||
(field.type !== "integer" || Number.isInteger(numeric))
|
||||
)
|
||||
return numeric;
|
||||
}
|
||||
throw new Error(`Invalid answer for OpenCode question ${field.key}`);
|
||||
|
||||
@@ -130,6 +130,14 @@ export class V2Runtime {
|
||||
private startTracked(env?: Record<string, string>): Promise<Generation> {
|
||||
const pending = this.start(env);
|
||||
this.starts.add(pending);
|
||||
void pending.then(
|
||||
(generation) =>
|
||||
generation.exited.then(() => {
|
||||
if (this.current === pending) this.current = null;
|
||||
return undefined;
|
||||
}),
|
||||
() => undefined,
|
||||
);
|
||||
void pending.then(
|
||||
() => this.starts.delete(pending),
|
||||
() => this.starts.delete(pending),
|
||||
|
||||
@@ -46,6 +46,10 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
private readonly turns: SessionTurns;
|
||||
private readonly children: SessionChildren;
|
||||
private stream: Promise<void> | null = null;
|
||||
private streamAbort = new AbortController();
|
||||
private exited = false;
|
||||
private reconnecting: Promise<void> | null = null;
|
||||
private launchEnv: Record<string, string> | undefined;
|
||||
private sync: Promise<void> = Promise.resolve();
|
||||
private dirty = false;
|
||||
private refreshTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
@@ -53,7 +57,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
private history: SessionMessageInfo[] = [];
|
||||
private modes: AgentMode[] = [];
|
||||
constructor(
|
||||
private readonly connection: V2Connection,
|
||||
private connection: V2Connection,
|
||||
private info: SessionInfo,
|
||||
private readonly config: AgentSessionConfig,
|
||||
private readonly logger: Logger,
|
||||
@@ -61,19 +65,24 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
private readonly requiresPaseoPlugin: boolean,
|
||||
private readonly unbind?: () => void,
|
||||
bindChild?: (id: string) => void,
|
||||
private readonly acquire?: () => Promise<V2Connection>,
|
||||
private readonly moved?: (connection: V2Connection) => void,
|
||||
) {
|
||||
this.permissions = new SessionPermissions(connection.client, info.id, config, (event) =>
|
||||
this.emit(event),
|
||||
this.permissions = new SessionPermissions(
|
||||
() => this.client,
|
||||
info.id,
|
||||
config,
|
||||
(event) => this.emit(event),
|
||||
);
|
||||
this.children = new SessionChildren({
|
||||
client: connection.client,
|
||||
client: () => this.client,
|
||||
id: info.id,
|
||||
emit: (event) => this.emit(event),
|
||||
reconcilePermissions: (id) => this.permissions.reconcile(id),
|
||||
bindChild,
|
||||
});
|
||||
this.turns = new SessionTurns({
|
||||
client: connection.client,
|
||||
client: () => this.client,
|
||||
id: info.id,
|
||||
cwd: config.cwd,
|
||||
signal: this.abort.signal,
|
||||
@@ -98,18 +107,31 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
return this.connection.client;
|
||||
}
|
||||
async initialize(launch?: AgentLaunchContext) {
|
||||
void this.connection.exited.then((error) => {
|
||||
if (this.closed) return;
|
||||
this.abort.abort(error);
|
||||
this.launchEnv = launch?.env;
|
||||
this.watchExit(this.connection);
|
||||
await this.configureConnection();
|
||||
const location = { directory: this.config.cwd };
|
||||
this.modes = modesFromV2((await this.client.agent.list({ location })).data);
|
||||
this.timeline.messages(await messages(this.client, this.id));
|
||||
await this.startStream();
|
||||
await this.children.reconcile(this.id);
|
||||
}
|
||||
private watchExit(connection: V2Connection) {
|
||||
void connection.exited.then((error) => {
|
||||
if (this.closed || this.connection !== connection) return undefined;
|
||||
this.exited = true;
|
||||
this.streamAbort.abort(error);
|
||||
this.turns.fail(error);
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
private async configureConnection() {
|
||||
const location = { directory: this.config.cwd };
|
||||
await waitForLocationReady({ client: this.client, location, signal: this.abort.signal });
|
||||
if (this.requiresPaseoPlugin)
|
||||
await awaitPaseoPlugin({ client: this.client, location, signal: this.abort.signal });
|
||||
if (launch?.env)
|
||||
await this.client.session.environment({ sessionID: this.id, variables: launch.env });
|
||||
if (this.launchEnv)
|
||||
await this.client.session.environment({ sessionID: this.id, variables: this.launchEnv });
|
||||
for (const [server, config] of Object.entries(this.config.mcpServers ?? {})) {
|
||||
await this.client.mcp.add({
|
||||
server,
|
||||
@@ -142,8 +164,8 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
key: "paseo",
|
||||
value: system,
|
||||
});
|
||||
this.modes = modesFromV2((await this.client.agent.list({ location })).data);
|
||||
this.timeline.messages(await messages(this.client, this.id));
|
||||
}
|
||||
private async startStream() {
|
||||
let ready!: () => void;
|
||||
let fail!: (error: unknown) => void;
|
||||
const first = new Promise<void>((resolve, reject) => {
|
||||
@@ -155,7 +177,41 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
AbortSignal.any([this.abort.signal, AbortSignal.timeout(30_000)]),
|
||||
first,
|
||||
);
|
||||
await this.children.reconcile(this.id);
|
||||
}
|
||||
private async reconnectIfExited() {
|
||||
if (this.closed) throw new Error("OpenCode session is closed");
|
||||
if (!this.exited) return;
|
||||
this.reconnecting ??= this.reconnect().finally(() => {
|
||||
this.reconnecting = null;
|
||||
});
|
||||
await this.reconnecting;
|
||||
}
|
||||
private async reconnect() {
|
||||
if (!this.acquire) throw new Error("OpenCode helper server exited");
|
||||
await this.stream;
|
||||
await this.sync.catch(() => undefined);
|
||||
const next = await this.acquire();
|
||||
if (this.closed) {
|
||||
await next.release();
|
||||
throw new Error("OpenCode session is closed");
|
||||
}
|
||||
const old = this.connection;
|
||||
this.connection = next;
|
||||
this.streamAbort = new AbortController();
|
||||
this.exited = false;
|
||||
this.watchExit(next);
|
||||
try {
|
||||
await this.configureConnection();
|
||||
await this.startStream();
|
||||
} catch (error) {
|
||||
this.connection = old;
|
||||
this.exited = true;
|
||||
this.streamAbort.abort();
|
||||
await next.release();
|
||||
throw error;
|
||||
}
|
||||
this.moved?.(next);
|
||||
await old.release();
|
||||
}
|
||||
subscribe(callback: (event: AgentStreamEvent) => void) {
|
||||
this.listeners.add(callback);
|
||||
@@ -186,10 +242,12 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
this.emit({ ...event, ...(this.turns.id ? { turnId: this.turns.id } : {}) });
|
||||
}
|
||||
async *streamHistory() {
|
||||
await this.reconnectIfExited();
|
||||
const history = new V2Timeline(false);
|
||||
yield* history.messages(await messages(this.client, this.id));
|
||||
}
|
||||
async getRuntimeInfo() {
|
||||
await this.reconnectIfExited();
|
||||
this.info = await this.client.session.get({ sessionID: this.id });
|
||||
return {
|
||||
provider: "opencode",
|
||||
@@ -206,6 +264,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
return this.info.agent ?? null;
|
||||
}
|
||||
async setMode(modeId: string) {
|
||||
await this.reconnectIfExited();
|
||||
await this.client.session.switchAgent({ sessionID: this.id, agent: modeId });
|
||||
this.info.agent = modeId;
|
||||
this.config.modeId = modeId;
|
||||
@@ -217,6 +276,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
});
|
||||
}
|
||||
async setModel(model: string | null) {
|
||||
await this.reconnectIfExited();
|
||||
const selected = model
|
||||
? modelRef(model, this.config.thinkingOptionId)
|
||||
: (await this.client.model.default({ location: { directory: this.config.cwd } })).data;
|
||||
@@ -237,6 +297,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
});
|
||||
}
|
||||
async setThinkingOption(variant: string | null) {
|
||||
await this.reconnectIfExited();
|
||||
const model = this.info.model;
|
||||
if (!model) throw new Error("Select an OpenCode model before changing its variant");
|
||||
await this.client.session.switchModel({
|
||||
@@ -257,6 +318,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
await this.respondToPermission(request.id, { behavior: "allow" });
|
||||
}
|
||||
async listCommands() {
|
||||
await this.reconnectIfExited();
|
||||
return commands(this.client, this.config.cwd);
|
||||
}
|
||||
describePersistence(): AgentPersistenceHandle {
|
||||
@@ -278,7 +340,8 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
item.type === "assistant_message" ? current + item.text : current,
|
||||
});
|
||||
}
|
||||
startTurn(prompt: AgentPromptInput, options?: AgentRunOptions) {
|
||||
async startTurn(prompt: AgentPromptInput, options?: AgentRunOptions) {
|
||||
await this.reconnectIfExited();
|
||||
return this.turns.startTurn(prompt, options);
|
||||
}
|
||||
steerActiveTurn(prompt: AgentPromptInput, options: SteerActiveTurnOptions): Promise<SteerResult> {
|
||||
@@ -289,6 +352,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
}
|
||||
async revertBoth(input: { messageId: string }) {
|
||||
await this.interrupt();
|
||||
await this.reconnectIfExited();
|
||||
await this.client.session.revert.stage({
|
||||
sessionID: this.id,
|
||||
messageID: input.messageId,
|
||||
@@ -300,6 +364,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
return [...this.permissions.list()];
|
||||
}
|
||||
async respondToPermission(requestId: string, response: AgentPermissionResponse) {
|
||||
await this.reconnectIfExited();
|
||||
await this.permissions.respondToPermission(requestId, response);
|
||||
}
|
||||
private async reconcileSnapshot() {
|
||||
@@ -377,11 +442,12 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
this.turns.observeActiveTurn();
|
||||
}
|
||||
private async consume(ready: () => void, fail: (error: unknown) => void) {
|
||||
const signal = AbortSignal.any([this.abort.signal, this.streamAbort.signal]);
|
||||
let connected = false;
|
||||
while (!this.closed && !this.abort.signal.aborted) {
|
||||
while (!this.closed && !signal.aborted) {
|
||||
try {
|
||||
for await (const event of this.client.event.subscribe({ signal: this.abort.signal })) {
|
||||
if (this.closed || this.abort.signal.aborted) return;
|
||||
for await (const event of this.client.event.subscribe({ signal })) {
|
||||
if (this.closed || signal.aborted) return;
|
||||
if (event.type === "server.connected") {
|
||||
this.timeline.resetStreams();
|
||||
await this.reconcileConnection();
|
||||
@@ -393,7 +459,7 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
}
|
||||
if (!connected) throw new Error("OpenCode event stream ended before connecting");
|
||||
} catch (error) {
|
||||
if (this.closed || this.abort.signal.aborted) return;
|
||||
if (this.closed || signal.aborted) return;
|
||||
if (!connected) {
|
||||
fail(error);
|
||||
return;
|
||||
@@ -403,15 +469,17 @@ export class OpenCodeV2Session implements AgentSession {
|
||||
"OpenCode event stream interrupted; reconciling on reconnect",
|
||||
);
|
||||
}
|
||||
await delay(100, undefined, { signal: this.abort.signal }).catch(() => undefined);
|
||||
await delay(100, undefined, { signal }).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
async close() {
|
||||
if (this.closed) return;
|
||||
this.closed = true;
|
||||
this.abort.abort();
|
||||
this.streamAbort.abort();
|
||||
if (this.refreshTimer) clearTimeout(this.refreshTimer);
|
||||
await this.stream;
|
||||
await this.reconnecting?.catch(() => undefined);
|
||||
await this.sync.catch(() => undefined);
|
||||
this.unbind?.();
|
||||
try {
|
||||
|
||||
@@ -25,7 +25,7 @@ interface TurnSnapshot {
|
||||
history: SessionMessageInfo[];
|
||||
}
|
||||
interface TurnOptions {
|
||||
client: V2Api;
|
||||
client(): V2Api;
|
||||
id: string;
|
||||
cwd: string;
|
||||
signal: AbortSignal;
|
||||
@@ -115,16 +115,16 @@ export class SessionTurns {
|
||||
) {
|
||||
const command = input.text.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);
|
||||
if (command?.[1] === "compact" || command?.[1] === "summarize") {
|
||||
await this.options.client.session.compact({ sessionID: this.options.id });
|
||||
await this.options.client().session.compact({ sessionID: this.options.id });
|
||||
return;
|
||||
}
|
||||
const selected = command
|
||||
? (await commands(this.options.client, this.options.cwd)).find(
|
||||
? (await commands(this.options.client(), this.options.cwd)).find(
|
||||
(item) => item.name === command[1],
|
||||
)
|
||||
: undefined;
|
||||
if (selected && selected.kind !== "skill") {
|
||||
await this.options.client.session.command({
|
||||
await this.options.client().session.command({
|
||||
sessionID: this.options.id,
|
||||
name: selected.name,
|
||||
text: command?.[2] ?? "",
|
||||
@@ -132,7 +132,7 @@ export class SessionTurns {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await this.options.client.session.prompt({
|
||||
await this.options.client().session.prompt({
|
||||
sessionID: this.options.id,
|
||||
...input,
|
||||
...(selected?.kind === "skill"
|
||||
@@ -148,10 +148,9 @@ export class SessionTurns {
|
||||
});
|
||||
}
|
||||
private async finish(id: string) {
|
||||
await this.options.client.session.wait(
|
||||
{ sessionID: this.options.id },
|
||||
{ signal: this.options.signal },
|
||||
);
|
||||
await this.options
|
||||
.client()
|
||||
.session.wait({ sessionID: this.options.id }, { signal: this.options.signal });
|
||||
const { info, history } = await this.options.reconcile();
|
||||
if (this.turn?.id !== id) return;
|
||||
if (info.outcome !== "failed" && info.outcome !== "interrupted")
|
||||
@@ -184,10 +183,12 @@ export class SessionTurns {
|
||||
}
|
||||
private async readExecutionError(): Promise<string> {
|
||||
let message = "OpenCode execution failed";
|
||||
for await (const event of this.options.client.session.log(
|
||||
{ sessionID: this.options.id, follow: false },
|
||||
{ signal: this.options.signal },
|
||||
)) {
|
||||
for await (const event of this.options
|
||||
.client()
|
||||
.session.log(
|
||||
{ sessionID: this.options.id, follow: false },
|
||||
{ signal: this.options.signal },
|
||||
)) {
|
||||
if (event.type === "session.execution.failed") message = event.data.error.message;
|
||||
}
|
||||
return message;
|
||||
@@ -209,7 +210,7 @@ export class SessionTurns {
|
||||
options: SteerActiveTurnOptions,
|
||||
): Promise<SteerResult> {
|
||||
if (this.turn?.id !== options.expectedTurnId || this.stopping) return { status: "unavailable" };
|
||||
await this.options.client.session.prompt({
|
||||
await this.options.client().session.prompt({
|
||||
sessionID: this.options.id,
|
||||
...this.promptInput(prompt),
|
||||
delivery: "steer",
|
||||
@@ -227,7 +228,7 @@ export class SessionTurns {
|
||||
const stop = (async () => {
|
||||
// A stop sent before the queued prompt is accepted would interrupt an idle session.
|
||||
await turn?.submitted;
|
||||
await this.options.client.session.interrupt({ sessionID: this.options.id });
|
||||
await this.options.client().session.interrupt({ sessionID: this.options.id });
|
||||
await turn?.completion;
|
||||
})();
|
||||
this.stopping = stop;
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
transformPiModels,
|
||||
} from "./agent.js";
|
||||
import { FakePi } from "./test-utils/fake-pi.js";
|
||||
import { HIDDEN_GOAL_CONTINUATION } from "./test-utils/hidden-custom-message.js";
|
||||
import { createPiExtensionHost } from "./extensions/index.js";
|
||||
import { PiExtensionHost } from "./extensions/host.js";
|
||||
import type { PiModel, PiThinkingLevel } from "./rpc-types.js";
|
||||
@@ -1081,17 +1080,6 @@ describe("PiRpcAgentSession", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("hides Pi custom messages that the extension marks display: false", async () => {
|
||||
const { pi, events } = await createSession();
|
||||
const fakeSession = pi.latestSession();
|
||||
|
||||
fakeSession.emit({ type: "agent_start" });
|
||||
fakeSession.emit({ type: "turn_start" });
|
||||
fakeSession.emit({ type: "message_end", message: HIDDEN_GOAL_CONTINUATION });
|
||||
|
||||
expect(events.timelineItems()).toEqual([]);
|
||||
});
|
||||
|
||||
test("canceling a silent Pi extension command leaves the session usable", async () => {
|
||||
const { pi, session, events } = await createSession();
|
||||
const fakeSession = pi.latestSession();
|
||||
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
toDiagnosticErrorMessage,
|
||||
} from "../diagnostic-utils.js";
|
||||
import {
|
||||
getCustomMessageText,
|
||||
getUserMessageText,
|
||||
streamPiHistory,
|
||||
type PiCapturedUserMessageEntry,
|
||||
} from "./history-mapper.js";
|
||||
@@ -2300,7 +2300,7 @@ export class PiRpcAgentSession implements AgentSession {
|
||||
if (event.message.role === "custom") {
|
||||
const customMapping = this.extensionHost.mapCustomMessage(event.message);
|
||||
this.emitExtensionOutput(customMapping, turnId);
|
||||
const text = getCustomMessageText(event.message);
|
||||
const text = getUserMessageText(event.message.content);
|
||||
if (text) {
|
||||
this.emit({
|
||||
type: "timeline",
|
||||
|
||||
+14
-25
@@ -15,18 +15,12 @@ const [start, ...rest] = fixture.frames;
|
||||
const dialogs = rest.filter((frame: { type: string }) => frame.type === "extension_ui_request");
|
||||
const end = rest.find((frame: { type: string }) => frame.type === "tool_execution_end");
|
||||
|
||||
const answers = [
|
||||
{ selected: ["Cookie"] },
|
||||
{ selected: ["Red", "Blue"] },
|
||||
{ selected: [], text: "Nebula" },
|
||||
];
|
||||
|
||||
function startedHost(args: unknown = start.args) {
|
||||
function startedHost() {
|
||||
const host = createPiExtensionHost();
|
||||
const permission = host.onToolStart({
|
||||
callId: start.toolCallId,
|
||||
toolName: start.toolName,
|
||||
args,
|
||||
args: start.args,
|
||||
status: "running",
|
||||
result: null,
|
||||
});
|
||||
@@ -53,7 +47,12 @@ test("real rpiv RPC dialogs use one form and preserve choices, multi-select, and
|
||||
});
|
||||
expect(host.mapDialog(dialogs[0], "pi")).toEqual({ type: "deferred" });
|
||||
expect(
|
||||
host.respondToPermission(permission, { behavior: "allow", questionAnswers: answers }),
|
||||
host.respondToPermission(permission, {
|
||||
behavior: "allow",
|
||||
updatedInput: {
|
||||
answers: { Snack: "Cookie", Colors: "Red, Blue", Project: "Nebula" },
|
||||
},
|
||||
}),
|
||||
).toEqual({ responses: [{ id: dialogs[0].id, response: { value: dialogs[0].options[1] } }] });
|
||||
expect(host.mapDialog(dialogs[1], "pi")).toEqual({
|
||||
type: "response",
|
||||
@@ -69,21 +68,6 @@ test("real rpiv RPC dialogs use one form and preserve choices, multi-select, and
|
||||
});
|
||||
});
|
||||
|
||||
test("multi-select labels containing a comma map back to their option numbers", () => {
|
||||
const args = structuredClone(start.args);
|
||||
args.questions[1].options[0].label = "Red, warm";
|
||||
const { host, permission } = startedHost(args);
|
||||
host.respondToPermission(permission, {
|
||||
behavior: "allow",
|
||||
questionAnswers: [answers[0], { selected: ["Red, warm", "Blue"] }, answers[2]],
|
||||
});
|
||||
host.mapDialog(dialogs[0], "pi");
|
||||
expect(host.mapDialog(dialogs[1], "pi")).toEqual({
|
||||
type: "response",
|
||||
response: { value: "1,2" },
|
||||
});
|
||||
});
|
||||
|
||||
test("cancellation declines each remaining real RPC dialog", () => {
|
||||
const { host, permission } = startedHost();
|
||||
expect(host.respondToPermission(permission, { behavior: "deny" })).toEqual({ responses: [] });
|
||||
@@ -169,7 +153,12 @@ test("the Pi agent releases a deferred captured dialog when the form is answered
|
||||
expect(permission.input?.questions).toHaveLength(3);
|
||||
runtime.emit(dialogs[0]);
|
||||
expect(runtime.extensionUiResponses).toEqual([]);
|
||||
await session.respondToPermission(permission.id, { behavior: "allow", questionAnswers: answers });
|
||||
await session.respondToPermission(permission.id, {
|
||||
behavior: "allow",
|
||||
updatedInput: {
|
||||
answers: { Snack: "Cookie", Colors: "Red, Blue", Project: "Nebula" },
|
||||
},
|
||||
});
|
||||
for (const dialog of dialogs.slice(1)) runtime.emit(dialog);
|
||||
expect(runtime.extensionUiResponses).toEqual([
|
||||
{ id: dialogs[0].id, response: { value: dialogs[0].options[1] } },
|
||||
|
||||
+23
-18
@@ -1,6 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { AgentPermissionRequest, AgentQuestionAnswer } from "../../../../agent-sdk-types.js";
|
||||
import { questionAnswerValues } from "../../../../question-answers.js";
|
||||
import type { AgentPermissionRequest } from "../../../../agent-sdk-types.js";
|
||||
import type { PiExtension, PiExtensionDialog, PiExtensionUiResponse } from "../contract.js";
|
||||
|
||||
const Params = z
|
||||
@@ -56,34 +55,38 @@ const Result = z.object({
|
||||
type Question = z.infer<typeof Params>["questions"][number];
|
||||
const PERMISSION_PREFIX = "rpiv-question:";
|
||||
|
||||
function answerFor(answers: Record<string, unknown>, question: Question): string | null {
|
||||
const answer = answers[question.header];
|
||||
return typeof answer === "string" ? answer : null;
|
||||
}
|
||||
|
||||
function replyToDialog(
|
||||
dialog: PiExtensionDialog,
|
||||
question: Question,
|
||||
answer: AgentQuestionAnswer,
|
||||
answer: string,
|
||||
customInput: boolean,
|
||||
): { response: PiExtensionUiResponse; customInput: boolean } {
|
||||
const options = z.array(z.string()).safeParse(dialog.options).data;
|
||||
const text = questionAnswerValues(answer).join(", ");
|
||||
if (customInput) return { response: { value: text }, customInput: false };
|
||||
if (customInput) return { response: { value: answer }, customInput: false };
|
||||
if (question.multiSelect) {
|
||||
const indices = answer.selected.map((label) =>
|
||||
const labels = answer.split(", ");
|
||||
const indices = labels.map((label) =>
|
||||
question.options.findIndex((option) => option.label === label),
|
||||
);
|
||||
if (!answer.text && indices.every((index) => index >= 0)) {
|
||||
if (indices.every((index) => index >= 0)) {
|
||||
return {
|
||||
response: { value: indices.map((index) => index + 1).join(",") },
|
||||
customInput: false,
|
||||
};
|
||||
}
|
||||
return { response: { value: text }, customInput: false };
|
||||
return { response: { value: answer }, customInput: false };
|
||||
}
|
||||
const [label] = answer.selected;
|
||||
const index = question.options.findIndex((option) => option.label === label);
|
||||
if (!answer.text && index >= 0) {
|
||||
const index = question.options.findIndex((option) => option.label === answer);
|
||||
if (index >= 0) {
|
||||
return {
|
||||
response: {
|
||||
value:
|
||||
options?.[index] ?? `${index + 1}. ${label} — ${question.options[index].description}`,
|
||||
options?.[index] ?? `${index + 1}. ${answer} — ${question.options[index].description}`,
|
||||
},
|
||||
customInput: false,
|
||||
};
|
||||
@@ -103,7 +106,7 @@ export const rpivAskUserQuestion: PiExtension = {
|
||||
let active: {
|
||||
callId: string;
|
||||
questions: Question[];
|
||||
answers: AgentQuestionAnswer[] | null;
|
||||
answers: Record<string, unknown> | null;
|
||||
cancelled: boolean;
|
||||
index: number;
|
||||
customInput: boolean;
|
||||
@@ -114,10 +117,8 @@ export const rpivAskUserQuestion: PiExtension = {
|
||||
if (!active || active.cancelled) return { cancelled: true };
|
||||
const question = active.questions[active.index];
|
||||
if (!question || !active.answers) return { cancelled: true };
|
||||
const answer = active.answers[active.index];
|
||||
if (!answer || (answer.selected.length === 0 && answer.text === undefined)) {
|
||||
return { cancelled: true };
|
||||
}
|
||||
const answer = answerFor(active.answers, question);
|
||||
if (answer === null) return { cancelled: true };
|
||||
const mapped = replyToDialog(dialog, question, answer, active.customInput);
|
||||
active.customInput = mapped.customInput;
|
||||
if (!active.customInput) active.index++;
|
||||
@@ -168,7 +169,11 @@ export const rpivAskUserQuestion: PiExtension = {
|
||||
},
|
||||
respondToPermission(request, response) {
|
||||
if (!active || request.id !== `${PERMISSION_PREFIX}${active.callId}`) return undefined;
|
||||
active.answers = (response.behavior === "allow" && response.questionAnswers) || null;
|
||||
const answers = response.behavior === "allow" ? response.updatedInput?.answers : undefined;
|
||||
active.answers =
|
||||
answers && typeof answers === "object" && !Array.isArray(answers)
|
||||
? (answers as Record<string, unknown>)
|
||||
: null;
|
||||
active.cancelled = response.behavior === "deny" || !active.answers;
|
||||
const deferred = active.deferred;
|
||||
active.deferred = null;
|
||||
|
||||
@@ -65,18 +65,16 @@ export async function verifySubagentFixture(
|
||||
});
|
||||
for (const message of fixture.messages) {
|
||||
if (message.role !== "custom" || typeof message.content !== "string") continue;
|
||||
const assistantText = expect.objectContaining({
|
||||
type: "timeline",
|
||||
item: { type: "assistant_message", text: message.content },
|
||||
});
|
||||
// Claimed notifications keep their text unless the extension hides it from the user.
|
||||
if (message.display === false) {
|
||||
expect(live).not.toContainEqual(assistantText);
|
||||
expect(replay).not.toContainEqual(assistantText);
|
||||
} else {
|
||||
expect(live).toContainEqual(assistantText);
|
||||
expect(replay).toContainEqual(assistantText);
|
||||
}
|
||||
const assistantText = {
|
||||
type: "assistant_message" as const,
|
||||
text: message.content,
|
||||
};
|
||||
expect(live).toContainEqual(
|
||||
expect.objectContaining({ type: "timeline", item: assistantText }),
|
||||
);
|
||||
expect(replay).toContainEqual(
|
||||
expect.objectContaining({ type: "timeline", item: assistantText }),
|
||||
);
|
||||
}
|
||||
const liveSubagents = live.filter((event) => event.type === "provider_subagent");
|
||||
const firstTimeline = liveSubagents.findIndex((event) => event.event.type === "timeline");
|
||||
|
||||
@@ -3,7 +3,6 @@ import { describe, expect, test } from "vitest";
|
||||
import type { AgentStreamEvent } from "../../agent-sdk-types.js";
|
||||
import { streamPiHistory, type PiCapturedUserMessageEntry } from "./history-mapper.js";
|
||||
import type { PiAgentMessage } from "./rpc-types.js";
|
||||
import { HIDDEN_GOAL_CONTINUATION } from "./test-utils/hidden-custom-message.js";
|
||||
|
||||
async function collectHistory(
|
||||
messages: PiAgentMessage[],
|
||||
@@ -141,10 +140,6 @@ describe("Pi history mapper", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("drops custom messages that the extension marks display: false", async () => {
|
||||
await expect(collectHistory([HIDDEN_GOAL_CONTINUATION])).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
test("uses Pi tree entry ids for replayed user messages", async () => {
|
||||
await expect(
|
||||
collectHistory(
|
||||
|
||||
@@ -20,6 +20,10 @@ export interface PiCapturedUserMessageEntry {
|
||||
}
|
||||
|
||||
export interface PiHistoryMapperHooks {
|
||||
mapCustomMessage?: (
|
||||
text: string,
|
||||
provider: string,
|
||||
) => Extract<AgentStreamEvent, { type: "timeline" }> | null;
|
||||
resolveToolCallId?: (toolCallId: string, toolCall: PiTrackedToolCall) => string;
|
||||
mapToolDetail?: (
|
||||
toolCall: PiTrackedToolCall,
|
||||
@@ -52,11 +56,6 @@ export function getUserMessageText(content: string | (PiTextContent | PiImageCon
|
||||
return textParts.join("\n\n");
|
||||
}
|
||||
|
||||
/** The text Pi shows for a custom message. Extensions hide model-only messages with `display: false`. */
|
||||
export function getCustomMessageText(message: Extract<PiAgentMessage, { role: "custom" }>): string {
|
||||
return message.display === false ? "" : getUserMessageText(message.content);
|
||||
}
|
||||
|
||||
export class PiHistoryMapper {
|
||||
private readonly pendingToolCalls = new Map<string, PiTrackedToolCall>();
|
||||
private readonly hydrations: Promise<AgentStreamEvent[]>[] = [];
|
||||
@@ -126,7 +125,11 @@ export class PiHistoryMapper {
|
||||
): AgentStreamEvent[] {
|
||||
const extensionMapping = this.extensionHost.mapCustomMessage(message);
|
||||
const extensionEvents = this.extensionEvents(extensionMapping);
|
||||
const text = getCustomMessageText(message);
|
||||
const text = getUserMessageText(message.content);
|
||||
const mappedEvent = text ? this.hooks.mapCustomMessage?.(text, this.provider) : null;
|
||||
if (mappedEvent) {
|
||||
return [...extensionEvents, mappedEvent];
|
||||
}
|
||||
return [
|
||||
...extensionEvents,
|
||||
...(text
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import type { PiAgentMessage } from "../rpc-types.js";
|
||||
|
||||
// A pi-goal-x 0.31.9 (2e8ad767) checkpoint continuation, captured verbatim from a real
|
||||
// `pi --mode rpc` run (Pi 0.84.4) on 2026-09-26. pi-goal-x sends it with `display: false`:
|
||||
// the marker is for the model, and Pi's TUI never renders it.
|
||||
export const HIDDEN_GOAL_CONTINUATION: PiAgentMessage = {
|
||||
role: "custom",
|
||||
customType: "pi-goal-event",
|
||||
content: '<pi_goal_continuation goal_id="muioeg51-6db1a7" kind="checkpoint" v="2"/>',
|
||||
display: false,
|
||||
details: {
|
||||
version: 3,
|
||||
generation: "13a8082c-e249-4df5-ac0e-fdc863ad289e",
|
||||
dispatchId: "a9c0ef02-d39c-42a2-8d5a-993a96b4e827",
|
||||
kind: "checkpoint",
|
||||
goalId: "muioeg51-6db1a7",
|
||||
status: "active",
|
||||
revision: 3,
|
||||
checkpointSeq: 1,
|
||||
timestamp: 1790444456255,
|
||||
},
|
||||
timestamp: 1790444456256,
|
||||
};
|
||||
@@ -1,89 +0,0 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { AgentPermissionRequest } from "./agent-sdk-types.js";
|
||||
import { resolveQuestionAnswers } from "./question-answers.js";
|
||||
|
||||
const request: AgentPermissionRequest = {
|
||||
id: "question-1",
|
||||
provider: "codex",
|
||||
name: "request_user_input",
|
||||
kind: "question",
|
||||
input: {
|
||||
questions: [
|
||||
{
|
||||
question: "Which colors?",
|
||||
header: "Colors",
|
||||
options: [{ label: "Red, bright" }, { label: "Blue" }],
|
||||
multiSelect: true,
|
||||
allowOther: true,
|
||||
},
|
||||
{
|
||||
question: "Which snack?",
|
||||
header: "Snack",
|
||||
options: [{ label: "Cookie" }, { label: "Apple" }],
|
||||
multiSelect: false,
|
||||
allowOther: true,
|
||||
},
|
||||
{ question: "Anything else?", header: "Notes", options: [], allowEmpty: true },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
describe("resolveQuestionAnswers", () => {
|
||||
test("keeps structured answers and derives the header-keyed text answers", () => {
|
||||
const resolved = resolveQuestionAnswers(request, {
|
||||
behavior: "allow",
|
||||
questionAnswers: [
|
||||
{ selected: ["Red, bright", "Blue"], text: "Green, dark" },
|
||||
{ selected: ["Cookie"] },
|
||||
{ selected: [], text: "" },
|
||||
],
|
||||
});
|
||||
|
||||
expect(resolved).toEqual({
|
||||
behavior: "allow",
|
||||
questionAnswers: [
|
||||
{ selected: ["Red, bright", "Blue"], text: "Green, dark" },
|
||||
{ selected: ["Cookie"] },
|
||||
{ selected: [], text: "" },
|
||||
],
|
||||
updatedInput: {
|
||||
answers: { Colors: "Red, bright, Blue, Green, dark", Snack: "Cookie", Notes: "" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("reads text answers from clients without structured answers by matching option labels", () => {
|
||||
const resolved = resolveQuestionAnswers(request, {
|
||||
behavior: "allow",
|
||||
updatedInput: {
|
||||
answers: { Colors: "Red, bright, Blue, Green", Snack: "Pretzel", Notes: "" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolved).toMatchObject({
|
||||
questionAnswers: [
|
||||
{ selected: ["Red, bright", "Blue"], text: "Green" },
|
||||
{ selected: [], text: "Pretzel" },
|
||||
{ selected: [], text: "" },
|
||||
],
|
||||
updatedInput: {
|
||||
answers: { Colors: "Red, bright, Blue, Green", Snack: "Pretzel", Notes: "" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects structured answers that do not line up with the questions", () => {
|
||||
expect(() =>
|
||||
resolveQuestionAnswers(request, {
|
||||
behavior: "allow",
|
||||
questionAnswers: [{ selected: ["Blue"] }],
|
||||
}),
|
||||
).toThrow("3 questions");
|
||||
});
|
||||
|
||||
test("leaves denials and non-question requests unchanged", () => {
|
||||
expect(resolveQuestionAnswers(request, { behavior: "deny" })).toEqual({ behavior: "deny" });
|
||||
const tool = { ...request, kind: "tool" as const };
|
||||
expect(resolveQuestionAnswers(tool, { behavior: "allow" })).toEqual({ behavior: "allow" });
|
||||
});
|
||||
});
|
||||
@@ -1,114 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import type {
|
||||
AgentPermissionRequest,
|
||||
AgentPermissionResponse,
|
||||
AgentQuestionAnswer,
|
||||
} from "./agent-sdk-types.js";
|
||||
|
||||
// Every provider publishes `question` requests in the shape the app's question form reads.
|
||||
const QuestionsSchema = z.array(
|
||||
z
|
||||
.object({
|
||||
header: z.string(),
|
||||
options: z.array(z.object({ label: z.string() }).passthrough()).optional(),
|
||||
multiSelect: z.boolean().optional(),
|
||||
})
|
||||
.passthrough(),
|
||||
);
|
||||
type Question = z.infer<typeof QuestionsSchema>[number];
|
||||
|
||||
const TextAnswersSchema = z.record(z.string(), z.unknown());
|
||||
|
||||
// Text answers join a multi-select's labels and typed answer with this separator.
|
||||
const TEXT_SEPARATOR = ", ";
|
||||
|
||||
/**
|
||||
* Gives an answered `question` request both answer forms before it reaches the provider:
|
||||
* `questionAnswers`, one structured answer per question, and `updatedInput.answers`, the
|
||||
* header-keyed text that Claude's AskUserQuestion and plugin providers read. Clients that
|
||||
* send only text (the CLI, MCP, and apps before structured answers) are parsed by option label.
|
||||
*/
|
||||
export function resolveQuestionAnswers(
|
||||
request: AgentPermissionRequest,
|
||||
response: AgentPermissionResponse,
|
||||
): AgentPermissionResponse {
|
||||
if (request.kind !== "question" || response.behavior !== "allow") return response;
|
||||
const parsed = QuestionsSchema.safeParse(request.input?.questions);
|
||||
if (!parsed.success) return response;
|
||||
const questions = parsed.data;
|
||||
|
||||
if (response.questionAnswers && response.questionAnswers.length !== questions.length) {
|
||||
throw new Error(
|
||||
`Question answers must answer all ${questions.length} questions; received ${response.questionAnswers.length}`,
|
||||
);
|
||||
}
|
||||
const textAnswers = TextAnswersSchema.safeParse(response.updatedInput?.answers).data;
|
||||
const questionAnswers =
|
||||
response.questionAnswers ??
|
||||
(textAnswers ? questions.map((question) => parseTextAnswer(question, textAnswers)) : null);
|
||||
if (!questionAnswers) return response;
|
||||
|
||||
return {
|
||||
...response,
|
||||
questionAnswers,
|
||||
updatedInput: {
|
||||
...response.updatedInput,
|
||||
answers: textAnswers ?? formatTextAnswers(questions, questionAnswers),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** The chosen option labels followed by the typed answer, if there is one. */
|
||||
export function questionAnswerValues(answer: AgentQuestionAnswer | undefined): string[] {
|
||||
if (!answer) return [];
|
||||
const text = answer.text?.trim();
|
||||
return text ? [...answer.selected, text] : answer.selected;
|
||||
}
|
||||
|
||||
function parseTextAnswer(
|
||||
question: Question,
|
||||
textAnswers: Record<string, unknown>,
|
||||
): AgentQuestionAnswer {
|
||||
const raw = textAnswers[question.header];
|
||||
if (Array.isArray(raw)) return { selected: raw.filter((item) => typeof item === "string") };
|
||||
if (typeof raw === "number" || typeof raw === "boolean") {
|
||||
return { selected: [], text: String(raw) };
|
||||
}
|
||||
if (typeof raw !== "string") return { selected: [] };
|
||||
const text = raw.trim();
|
||||
const labels = new Set(question.options?.map((option) => option.label));
|
||||
if (!question.multiSelect) {
|
||||
return labels.has(text) ? { selected: [text] } : { selected: [], text };
|
||||
}
|
||||
|
||||
// Labels can contain the separator, so match the longest run of segments that is a label.
|
||||
const segments = text.split(TEXT_SEPARATOR);
|
||||
const selected: string[] = [];
|
||||
const typed: string[] = [];
|
||||
let start = 0;
|
||||
while (start < segments.length) {
|
||||
let end = segments.length;
|
||||
while (end > start && !labels.has(segments.slice(start, end).join(TEXT_SEPARATOR))) end--;
|
||||
if (end > start) {
|
||||
selected.push(segments.slice(start, end).join(TEXT_SEPARATOR));
|
||||
start = end;
|
||||
} else {
|
||||
typed.push(segments[start]);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
return typed.length > 0 ? { selected, text: typed.join(TEXT_SEPARATOR) } : { selected };
|
||||
}
|
||||
|
||||
function formatTextAnswers(
|
||||
questions: Question[],
|
||||
questionAnswers: AgentQuestionAnswer[],
|
||||
): Record<string, string> {
|
||||
const answers: Record<string, string> = {};
|
||||
questions.forEach((question, index) => {
|
||||
const answer = questionAnswers[index];
|
||||
if (answer.selected.length === 0 && answer.text === undefined) return;
|
||||
answers[question.header] = questionAnswerValues(answer).join(TEXT_SEPARATOR);
|
||||
});
|
||||
return answers;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.9.2",
|
||||
"version": "0.10.0-beta.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user