mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-04 14:16:49 +00:00
Compare commits
76
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdec809d91 | ||
|
|
89d7895fa2 | ||
|
|
40ccec39c1 | ||
|
|
c4d1348be4 | ||
|
|
54e4c15912 | ||
|
|
b7c877129d | ||
|
|
abbbecc8a3 | ||
|
|
3484943a7e | ||
|
|
55bba06161 | ||
|
|
4863e7e761 | ||
|
|
ad9073dc8a | ||
|
|
35f0ff6ff1 | ||
|
|
b31565fbf7 | ||
|
|
8302319f54 | ||
|
|
8b0c22ca31 | ||
|
|
26175ed408 | ||
|
|
41e21d8d5f | ||
|
|
5700dc3ea1 | ||
|
|
aabb5764d3 | ||
|
|
4fe15a6918 | ||
|
|
32a5dd8bad | ||
|
|
70f374f269 | ||
|
|
e31ee658c2 | ||
|
|
acde63e614 | ||
|
|
25d9ed2985 | ||
|
|
b947c229c6 | ||
|
|
2e3d9b375a | ||
|
|
9cb4726c30 | ||
|
|
1544282593 | ||
|
|
61d2ad1585 | ||
|
|
512f21ba64 | ||
|
|
646b65e617 | ||
|
|
302afe1104 | ||
|
|
b14f61ce27 | ||
|
|
6b808bc67b | ||
|
|
624c26aa91 | ||
|
|
476ad7f414 | ||
|
|
b1a9fe8950 | ||
|
|
fe70975e89 | ||
|
|
4df3da2c4e | ||
|
|
e2d6dc9f70 | ||
|
|
ea96a126af | ||
|
|
f3fc583a76 | ||
|
|
32cae04627 | ||
|
|
a73e1c6a5b | ||
|
|
0cdaa292f0 | ||
|
|
39d37e1e16 | ||
|
|
7eb6ea9882 | ||
|
|
cb9dbce82d | ||
|
|
ee21a56c7f | ||
|
|
15ea9d0f03 | ||
|
|
99b0b5e1ed | ||
|
|
9f3ac9aca5 | ||
|
|
eca1149db0 | ||
|
|
078dcfb1ab | ||
|
|
8d87e400b0 | ||
|
|
ca2de1d741 | ||
|
|
e60cd200e8 | ||
|
|
005c3c4e65 | ||
|
|
f2e5d0d982 | ||
|
|
8ebe37558d | ||
|
|
dcd10a6029 | ||
|
|
5e16d70aaa | ||
|
|
b89eae1eff | ||
|
|
32496c489e | ||
|
|
da51ac3d64 | ||
|
|
0ec89b5623 | ||
|
|
12d28ddbc8 | ||
|
|
f621e31f3e | ||
|
|
c9ba30194c | ||
|
|
fa185cb063 | ||
|
|
723df269d2 | ||
|
|
f86c58b42b | ||
|
|
1cfadda498 | ||
|
|
776210b72b | ||
|
|
80bcbdc931 |
+13
-2
@@ -72,7 +72,7 @@ browser:
|
||||
- "packages/server/src/server/agent/providers/codex-app-server-agent.ts"
|
||||
- "packages/server/src/server/agent/providers/claude/agent.ts"
|
||||
- "packages/server/src/server/agent/plugin-provider.ts"
|
||||
- "packages/server/src/server/plugins/{index,plugin-process,plugin-process-protocol,runtime}.ts"
|
||||
- "packages/server/src/server/plugins/{index,managed-source,plugin-process,plugin-process-protocol,runtime}.ts"
|
||||
- "packages/server/src/executable-resolution/**"
|
||||
- "packages/plugin/src/server/provider.ts"
|
||||
- "packages/app/src/!(desktop)/**"
|
||||
@@ -88,9 +88,20 @@ browser:
|
||||
relay:
|
||||
- "packages/relay/**"
|
||||
|
||||
website:
|
||||
- "packages/website/**"
|
||||
- "packages/protocol/**"
|
||||
- "public-docs/**"
|
||||
- "CHANGELOG.md"
|
||||
- "CHANGELOG.zh-CN.md"
|
||||
- "README*.md"
|
||||
- "assets/brand/**"
|
||||
- "packages/app/assets/images/editor-apps/finder.png"
|
||||
|
||||
# cli-tests is also a daemon end-to-end suite: it drives a real daemon, built-in
|
||||
# plugins included, so daemon changes run it too.
|
||||
# plugins and the plugin runtime included, so their changes run it too.
|
||||
cli:
|
||||
- "packages/cli/**"
|
||||
- "packages/server/**"
|
||||
- "packages/plugin/**"
|
||||
- "plugins/**"
|
||||
|
||||
+32
-10
@@ -43,6 +43,7 @@ jobs:
|
||||
browser: ${{ steps.filter.outputs.browser }}
|
||||
relay: ${{ steps.filter.outputs.relay }}
|
||||
cli: ${{ steps.filter.outputs.cli }}
|
||||
website: ${{ steps.filter.outputs.website }}
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
with:
|
||||
@@ -163,12 +164,11 @@ jobs:
|
||||
- name: Run plugin SDK tests
|
||||
run: npm run test --workspace=@getpaseo/plugin
|
||||
|
||||
# The locked Playwright installers do not support ubuntu-latest's Ubuntu 26.04.
|
||||
typecheck:
|
||||
name: typecheck
|
||||
needs: changes
|
||||
if: ${{ !cancelled() && (needs.changes.outputs.full != 'false' || needs.changes.outputs.quality != 'false') }}
|
||||
runs-on: ubuntu-24.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -195,6 +195,32 @@ jobs:
|
||||
- name: Typecheck all packages
|
||||
run: npm run typecheck
|
||||
|
||||
- name: Verify public package contents
|
||||
run: |
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/protocol
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/client
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/server
|
||||
|
||||
# The locked Playwright installers do not support ubuntu-latest's Ubuntu 26.04.
|
||||
website-tests:
|
||||
name: website-tests
|
||||
needs: changes
|
||||
if: ${{ !cancelled() && (needs.changes.outputs.full != 'false' || needs.changes.outputs.website != 'false') }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "npm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: node scripts/npm-retry.mjs ci
|
||||
|
||||
- name: Build protocol
|
||||
run: npm run build:protocol
|
||||
|
||||
- name: Run website tests
|
||||
run: npx vitest run packages/website/src --bail=1
|
||||
|
||||
@@ -222,7 +248,7 @@ jobs:
|
||||
cp "${archive_debs[@]}" ~/website-browser-debs/
|
||||
fi
|
||||
|
||||
- name: Verify website mockups
|
||||
- name: Run website E2E tests
|
||||
run: npm run test:e2e --workspace=@getpaseo/website
|
||||
|
||||
- name: Upload website test artifacts
|
||||
@@ -230,16 +256,12 @@ jobs:
|
||||
if: failure()
|
||||
with:
|
||||
name: website-playwright-results
|
||||
path: packages/website/test-results/
|
||||
path: |
|
||||
packages/website/test-results/
|
||||
packages/website/playwright-report/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 7
|
||||
|
||||
- name: Verify public package contents
|
||||
run: |
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/protocol
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/client
|
||||
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/server
|
||||
|
||||
server-tests-ubuntu:
|
||||
name: server-tests (ubuntu-latest)
|
||||
needs: changes
|
||||
|
||||
+59
-19
@@ -1,22 +1,45 @@
|
||||
# Changelog
|
||||
|
||||
## 0.19.0-beta.1 - 2026-12-02
|
||||
## 0.19.1 - 2026-12-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed agent messages and subagent finish notifications to default to `steer`, falling back to `queue` on providers that cannot steer mid-turn instead of interrupting the active turn ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed direct `steer` and `interrupt` prompts clearing queued messages and finish notifications from the queue ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
- Fixed queued message batches being dropped instead of held after transient dispatch errors or run-start timeouts ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
- Fixed parent agents missing the follow-up completion notice when Claude runs a queued steer as a separate turn ([#11872](https://github.com/getpaseo/paseo/pull/11872))
|
||||
|
||||
## 0.19.0 - 2026-12-03
|
||||
|
||||
- **Switch providers mid-chat:** Switch a chat to another provider and keep the conversation, with chat history now stored on the host. ([#11410](https://github.com/getpaseo/paseo/pull/11410))
|
||||
- **Queue survives restarts:** Queued messages now live on the host, so they survive app reloads, device switches and daemon restarts. ([#11424](https://github.com/getpaseo/paseo/pull/11424), [#11566](https://github.com/getpaseo/paseo/pull/11566), [#11740](https://github.com/getpaseo/paseo/pull/11740))
|
||||
- **One switch for agent tools:** Agent tools now sit behind one Enable tools setting with orchestration, schedules, PR watching and browser groups, and are on by default. ([#11189](https://github.com/getpaseo/paseo/pull/11189))
|
||||
- **Connected devices list:** Settings → Devices now shows which clients and hosts are connected and what each one can access. ([#11209](https://github.com/getpaseo/paseo/pull/11209))
|
||||
- **Plugin scorecards:** Plugin pages in the app and on paseo.sh show a scorecard, update history, related plugins and sponsor links. ([#11563](https://github.com/getpaseo/paseo/pull/11563), [#11674](https://github.com/getpaseo/paseo/pull/11674), [#11691](https://github.com/getpaseo/paseo/pull/11691))
|
||||
- **Plugin approval prompt:** The app now asks once per host before it runs a plugin's code, and a General setting turns the prompt off. ([#11717](https://github.com/getpaseo/paseo/pull/11717))
|
||||
- **Share services through tunnels:** Share a running workspace service at a public URL from the Scripts menu, and dev servers keep their live-reload connections. Services now open at `localhost:<port>`, and `*.localhost` service URLs are removed. ([#11490](https://github.com/getpaseo/paseo/pull/11490))
|
||||
- **Lower CPU while agents run:** Running agents use far less CPU, GPU and battery, with lighter status rings, loaders and tool-call animations. ([#11456](https://github.com/getpaseo/paseo/pull/11456), [#11474](https://github.com/getpaseo/paseo/pull/11474), [#11564](https://github.com/getpaseo/paseo/pull/11564), [#11586](https://github.com/getpaseo/paseo/pull/11586), [#11591](https://github.com/getpaseo/paseo/pull/11591) by [@djbclark](https://github.com/djbclark), [@luoph](https://github.com/luoph), [@mariotaku](https://github.com/mariotaku))
|
||||
- **Steadier streaming replies:** Streaming replies show their final formatting as they arrive, and long replies no longer get slower to render as they grow. ([#11572](https://github.com/getpaseo/paseo/pull/11572), [#11582](https://github.com/getpaseo/paseo/pull/11582) by [@luoph](https://github.com/luoph))
|
||||
- **Faster mobile launch:** The mobile app shows your last workspace sooner after a cold launch, about 0.7 seconds on Android. ([#11390](https://github.com/getpaseo/paseo/pull/11390) by [@luoph](https://github.com/luoph), [@maci0](https://github.com/maci0))
|
||||
- **Desktop browser profiles:** Desktop browser tabs can use separate colored profiles, so you can stay signed in to two accounts on one site. ([#10357](https://github.com/getpaseo/paseo/pull/10357) by [@clkao](https://github.com/clkao))
|
||||
- **Desktop browser profiles:** Desktop browser tabs can use separate colored profiles, so you can stay signed in to two accounts on one site. ([#10357](https://github.com/getpaseo/paseo/pull/10357), [#11772](https://github.com/getpaseo/paseo/pull/11772) by [@clkao](https://github.com/clkao))
|
||||
- **Swipe away the iOS keyboard:** Drag the chat down to hide the iOS keyboard, and chat controls now work on the first tap while it is open. ([#11625](https://github.com/getpaseo/paseo/pull/11625))
|
||||
|
||||
### Breaking
|
||||
|
||||
- Paseo CLI and daemon now require Node.js 22.16.0 or later ([#11410](https://github.com/getpaseo/paseo/pull/11410))
|
||||
- Relay connections now require [protected end-to-end encryption](https://paseo.sh/docs/security) by default, so apps older than 0.13.0 cannot connect through the relay ([#11864](https://github.com/getpaseo/paseo/pull/11864))
|
||||
|
||||
### Security
|
||||
|
||||
- Denied camera, microphone, location, notification and device access to pages in the desktop browser by default ([#11837](https://github.com/getpaseo/paseo/pull/11837))
|
||||
- Blocked client file access to the daemon's own state in the Paseo home directory, and warned when a saved host's daemon key changes ([#11452](https://github.com/getpaseo/paseo/pull/11452))
|
||||
- Restricted loopback origin matching to `localhost`, `127.0.0.1` and `::1` for daemon WebSocket and HTTP requests ([#11686](https://github.com/getpaseo/paseo/pull/11686))
|
||||
- Stopped images in pull request comments and reviews from loading files from the host ([#11699](https://github.com/getpaseo/paseo/pull/11699))
|
||||
- Stopped `.worktreeinclude` from copying local files into worktrees from fork pull requests ([#11709](https://github.com/getpaseo/paseo/pull/11709))
|
||||
- Rejected schedule IDs that point outside the schedules directory ([#11727](https://github.com/getpaseo/paseo/pull/11727))
|
||||
|
||||
### Added
|
||||
|
||||
@@ -37,6 +60,7 @@
|
||||
- Served the desktop app's web UI with Brotli and gzip compression instead of an uncompressed 25 MB bundle ([#10635](https://github.com/getpaseo/paseo/pull/10635) by [@djbclark](https://github.com/djbclark))
|
||||
- Changed chat loading to one steady spinner that reveals the chat and composer together, without an Updating messages flash ([#11575](https://github.com/getpaseo/paseo/pull/11575))
|
||||
- Kept the Restoring screen up until a restored workspace is ready ([#11486](https://github.com/getpaseo/paseo/pull/11486))
|
||||
- Resized the mobile app icon to match other Home Screen icons, with Android themed icons and iOS Liquid Glass ([#11851](https://github.com/getpaseo/paseo/pull/11851))
|
||||
- Showed a spinner on a worktree row while archive checks for uncommitted changes ([#11519](https://github.com/getpaseo/paseo/pull/11519), [#11574](https://github.com/getpaseo/paseo/pull/11574) by [@cxroop](https://github.com/cxroop))
|
||||
- Showed each host's icon with a status dot on host selectors ([#11568](https://github.com/getpaseo/paseo/pull/11568))
|
||||
- Sent the prompt with hardware-keyboard Return on iPhone, as on iPad ([#11537](https://github.com/getpaseo/paseo/pull/11537))
|
||||
@@ -45,12 +69,29 @@
|
||||
### Changed
|
||||
|
||||
- Changed archiving to keep a worktree that has uncommitted changes unless you confirm removal ([#11430](https://github.com/getpaseo/paseo/pull/11430))
|
||||
- Changed Import session on the New workspace screen to create a new workspace ([#11845](https://github.com/getpaseo/paseo/pull/11845))
|
||||
- Changed closing a New Agent tab with an unsent draft to ask before discarding it ([#11660](https://github.com/getpaseo/paseo/pull/11660))
|
||||
- Changed Cmd/Ctrl+click on a sidebar workspace to open it instead of entering select mode ([#11472](https://github.com/getpaseo/paseo/pull/11472))
|
||||
- Changed agents that already reported to their caller with `send_agent_prompt` to skip the extra finished notice ([#11583](https://github.com/getpaseo/paseo/pull/11583))
|
||||
|
||||
### Plugins
|
||||
|
||||
- Added a workspace layout API so plugins can open, move and close panes and tabs ([#11328](https://github.com/getpaseo/paseo/pull/11328))
|
||||
- Added `ProviderIcon` so plugins can show Paseo's provider icons ([#4664](https://github.com/getpaseo/paseo/pull/4664) by [@omercnet](https://github.com/omercnet))
|
||||
- Added `requirements.app` to set a separate minimum app version from the daemon's ([#11494](https://github.com/getpaseo/paseo/pull/11494) by [@mcowger](https://github.com/mcowger))
|
||||
- Fixed a plugin error in a press handler or timer closing the iOS and Android app ([#11412](https://github.com/getpaseo/paseo/pull/11412))
|
||||
- Fixed plugin popovers on web and desktop loading their content twice on each open ([#11748](https://github.com/getpaseo/paseo/pull/11748) by [@tomgrin10](https://github.com/tomgrin10))
|
||||
- Fixed the desktop app keeping every replaced plugin version in memory after plugin reloads ([#11800](https://github.com/getpaseo/paseo/pull/11800))
|
||||
- Fixed plugin operations deleting plugin entries added to `config.json` by hand ([#11501](https://github.com/getpaseo/paseo/pull/11501) by [@matchy233](https://github.com/matchy233))
|
||||
- Fixed registry plugin installs failing with Missing npm artifact when npm leaves registry URLs out of lockfiles ([#11656](https://github.com/getpaseo/paseo/pull/11656) by [@Brandon168](https://github.com/Brandon168))
|
||||
- Fixed local plugin reloads taking 12 to 21 seconds when the daemon runs under a large directory ([#11653](https://github.com/getpaseo/paseo/pull/11653))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed thinking level, mode and model changes on a running agent snapping back to the old value ([#11850](https://github.com/getpaseo/paseo/pull/11850))
|
||||
- Fixed finished agents flashing back to running for a moment ([#11764](https://github.com/getpaseo/paseo/pull/11764))
|
||||
- Fixed Send now on a queued message cancelling the running turn instead of steering it ([#11827](https://github.com/getpaseo/paseo/pull/11827))
|
||||
- Fixed a failed or finished send replacing a follow-up draft typed while it was sending ([#11448](https://github.com/getpaseo/paseo/pull/11448) by [@suniceman](https://github.com/suniceman))
|
||||
- Fixed an attached image over 2000 px breaking every later turn in its chat ([#5119](https://github.com/getpaseo/paseo/pull/5119) by [@RUIIIOVO](https://github.com/RUIIIOVO))
|
||||
- Fixed voice mode agents never speaking back when Paseo tools were off ([#11161](https://github.com/getpaseo/paseo/pull/11161))
|
||||
- Fixed turning off voice mode without a daemon connection leaving the microphone on ([#11587](https://github.com/getpaseo/paseo/pull/11587) by [@luoph](https://github.com/luoph), [@RRD-dev](https://github.com/RRD-dev))
|
||||
@@ -61,18 +102,25 @@
|
||||
- Fixed terminal output stopping after a reconnect reused its subscription ([#10433](https://github.com/getpaseo/paseo/pull/10433) by [@chirag127](https://github.com/chirag127))
|
||||
- Fixed Files showing Host is not connected when the app launched before the host connected ([#11679](https://github.com/getpaseo/paseo/pull/11679))
|
||||
- Fixed Created and Last prompt sorting disappearing while a host is offline ([#11728](https://github.com/getpaseo/paseo/pull/11728))
|
||||
- Fixed sideways swipes on horizontal scroll areas opening or closing the side panels on iOS and Android ([#11841](https://github.com/getpaseo/paseo/pull/11841))
|
||||
- Fixed iOS header taps scrolling the chat, Explorer or workspace list to the top ([#11262](https://github.com/getpaseo/paseo/pull/11262) by [@yzim](https://github.com/yzim))
|
||||
- Fixed a file sheet dismissed while opening leaving an invisible backdrop that blocked taps ([#11317](https://github.com/getpaseo/paseo/pull/11317) by [@LiebeLee](https://github.com/LiebeLee))
|
||||
- Fixed bottom sheets staying open when dismissed before their open animation started ([#11632](https://github.com/getpaseo/paseo/pull/11632))
|
||||
- Fixed Android attaching nothing when the app was recreated during image selection ([#7734](https://github.com/getpaseo/paseo/pull/7734))
|
||||
- Fixed middle-clicking a tab on Linux pasting the selection into the terminal ([#11818](https://github.com/getpaseo/paseo/pull/11818))
|
||||
- Fixed Find dropping the first keys typed right after Cmd/Ctrl+F ([#11812](https://github.com/getpaseo/paseo/pull/11812))
|
||||
- Fixed pasting a file into the web composer inserting its path instead of attaching it ([#11718](https://github.com/getpaseo/paseo/pull/11718))
|
||||
- Fixed Content font size not applying to existing user messages in web chat ([#11469](https://github.com/getpaseo/paseo/pull/11469) by [@bearyjd](https://github.com/bearyjd))
|
||||
- Fixed `<br>` in a Markdown table cell splitting the table row ([#9587](https://github.com/getpaseo/paseo/pull/9587) by [@apple-ouyang](https://github.com/apple-ouyang))
|
||||
- Fixed hidden chat rows shifting the reading position on web ([#11538](https://github.com/getpaseo/paseo/pull/11538) by [@kogekiplay](https://github.com/kogekiplay))
|
||||
- Fixed links to outside folders without a trailing slash opening as a broken file tab ([#11786](https://github.com/getpaseo/paseo/pull/11786))
|
||||
- Fixed the Scripts menu staying stale after `paseo.json` changes ([#11768](https://github.com/getpaseo/paseo/pull/11768) by [@odoo-mvds](https://github.com/odoo-mvds))
|
||||
- Fixed the empty tool call details text touching the screen edge ([#9129](https://github.com/getpaseo/paseo/pull/9129) by [@ilteoood](https://github.com/ilteoood))
|
||||
- Fixed a plugin slash command with an attachment being sent to the agent as a message ([#11483](https://github.com/getpaseo/paseo/pull/11483) by [@suniceman](https://github.com/suniceman))
|
||||
- Fixed Archive finished subagents skipping closed subagents ([#10865](https://github.com/getpaseo/paseo/pull/10865) by [@sbhas2k](https://github.com/sbhas2k))
|
||||
- Fixed Import Session missing the newest ACP sessions ([#10675](https://github.com/getpaseo/paseo/pull/10675))
|
||||
- Fixed Import Session hiding the provider error while Retry runs ([#11654](https://github.com/getpaseo/paseo/pull/11654))
|
||||
- Fixed Import session failing to open chats from older custom Codex providers ([#11852](https://github.com/getpaseo/paseo/pull/11852))
|
||||
- Fixed setup dropping project suggestions from providers that answer after 60 seconds ([#11438](https://github.com/getpaseo/paseo/pull/11438) by [@suniceman](https://github.com/suniceman))
|
||||
- Fixed Open in file manager showing for workspaces on remote hosts ([#11463](https://github.com/getpaseo/paseo/pull/11463) by [@sleroq](https://github.com/sleroq))
|
||||
- Fixed Reveal in Finder for workspaces rooted at `/` ([#11206](https://github.com/getpaseo/paseo/pull/11206) by [@suniceman](https://github.com/suniceman))
|
||||
@@ -85,6 +133,7 @@
|
||||
- Fixed turns Claude starts on its own staying hidden in reopened chats until Reload ([#11405](https://github.com/getpaseo/paseo/pull/11405))
|
||||
- Fixed Claude Code system notices being dropped from the chat ([#11419](https://github.com/getpaseo/paseo/pull/11419) by [@minamorl](https://github.com/minamorl))
|
||||
- Fixed Claude Code's Goal set reply missing from imported chats ([#11733](https://github.com/getpaseo/paseo/pull/11733))
|
||||
- Fixed Claude Code Stop hook warnings telling you to press a shortcut that opens Add project in Paseo ([#11792](https://github.com/getpaseo/paseo/pull/11792))
|
||||
- Fixed listing commands in an archived Claude chat starting Claude Code ([#11521](https://github.com/getpaseo/paseo/pull/11521) by [@RawSalmon69](https://github.com/RawSalmon69))
|
||||
- Fixed Stop failing on unresponsive Pi and OMP agents ([#11618](https://github.com/getpaseo/paseo/pull/11618) by [@LouisDeconinck](https://github.com/LouisDeconinck))
|
||||
- Fixed Pi turns never finishing when an extension handles the prompt ([#10572](https://github.com/getpaseo/paseo/pull/10572) by [@jsilhan](https://github.com/jsilhan))
|
||||
@@ -92,12 +141,16 @@
|
||||
- Fixed Pi showing the prompt twice when an extension sends context before the reply ([#11533](https://github.com/getpaseo/paseo/pull/11533) by [@Stelath](https://github.com/Stelath))
|
||||
- Fixed Pi chats skipping project skills and settings in trusted workspaces ([#11527](https://github.com/getpaseo/paseo/pull/11527) by [@patrick-motard](https://github.com/patrick-motard))
|
||||
- Fixed new Pi agents failing with an old extension error after the conflict was fixed ([#11642](https://github.com/getpaseo/paseo/pull/11642))
|
||||
- Fixed Pi receiving a cancellation when an agent approved its prompt with a chosen option ([#11814](https://github.com/getpaseo/paseo/pull/11814) by [@djbclark](https://github.com/djbclark))
|
||||
- Fixed the OMP Fast toggle missing before the first prompt ([#11553](https://github.com/getpaseo/paseo/pull/11553))
|
||||
- Fixed finished OMP form questions losing the question and chosen answer ([#11697](https://github.com/getpaseo/paseo/pull/11697), [#11706](https://github.com/getpaseo/paseo/pull/11706) by [@luoph](https://github.com/luoph), [@RRD-dev](https://github.com/RRD-dev))
|
||||
- Fixed a failed Codex startup crashing the daemon ([#11847](https://github.com/getpaseo/paseo/pull/11847) by [@xilinshancun](https://github.com/xilinshancun))
|
||||
- Fixed idle Codex agents never releasing their resources after Codex exits ([#11839](https://github.com/getpaseo/paseo/pull/11839) by [@michaelmwu](https://github.com/michaelmwu))
|
||||
- Fixed Codex sends reporting failure after 60 seconds while Codex was still starting ([#11547](https://github.com/getpaseo/paseo/pull/11547) by [@nonononull](https://github.com/nonononull))
|
||||
- Fixed Codex features staying hidden behind a wrapper command such as `env codex` ([#11221](https://github.com/getpaseo/paseo/pull/11221) by [@suniceman](https://github.com/suniceman))
|
||||
- Fixed answers to Codex async questions being rejected ([#11225](https://github.com/getpaseo/paseo/pull/11225) by [@suniceman](https://github.com/suniceman))
|
||||
- Fixed reopening a Codex chat resetting its last-activity time ([#10760](https://github.com/getpaseo/paseo/pull/10760) by [@Juns-g](https://github.com/Juns-g))
|
||||
- Fixed OpenCode reply paragraphs running together ([#11745](https://github.com/getpaseo/paseo/pull/11745))
|
||||
- Fixed Antigravity subagent tool calls splitting streamed replies mid-word ([#11535](https://github.com/getpaseo/paseo/pull/11535) by [@Suhail](https://github.com/Suhail))
|
||||
- Fixed Antigravity turns ending as completed after an internal executor error ([#10885](https://github.com/getpaseo/paseo/pull/10885) by [@vecyang1](https://github.com/vecyang1), [@luoph](https://github.com/luoph))
|
||||
- Fixed ACP chats failing to reopen when the provider rejects the saved thinking level ([#10333](https://github.com/getpaseo/paseo/pull/10333))
|
||||
@@ -123,27 +176,14 @@
|
||||
- Fixed a queued message running in the mode of a prompt sent after it ([#11722](https://github.com/getpaseo/paseo/pull/11722))
|
||||
- Fixed `paseo ls --json` dropping timestamps and background work ([#11423](https://github.com/getpaseo/paseo/pull/11423) by [@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- Fixed `paseo inspect` and `paseo ls` hiding the model for Cursor Auto ([#11693](https://github.com/getpaseo/paseo/pull/11693))
|
||||
- Fixed `paseo ls --label` with a malformed label listing every agent ([#11707](https://github.com/getpaseo/paseo/pull/11707) by [@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- Fixed `paseo terminal capture` and `paseo terminal send-keys` ignoring `--json` ([#11710](https://github.com/getpaseo/paseo/pull/11710) by [@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- Fixed `paseo terminal create --workspace` failing for workspaces past the first ten ([#11799](https://github.com/getpaseo/paseo/pull/11799) by [@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- Fixed `paseo schedule update --model` failing unless the provider was repeated ([#11796](https://github.com/getpaseo/paseo/pull/11796) by [@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- Fixed `paseo workspace ls` reporting a wrong password as a stopped daemon ([#11676](https://github.com/getpaseo/paseo/pull/11676) by [@chirag127](https://github.com/chirag127))
|
||||
- Fixed `paseo daemon status` leaving out unconfirmed terminal cleanup ([#11658](https://github.com/getpaseo/paseo/pull/11658) by [@chirag127](https://github.com/chirag127))
|
||||
- Fixed CLI archive, detach and reload scanning all agent history for a full agent ID ([#11617](https://github.com/getpaseo/paseo/pull/11617) by [@maci0](https://github.com/maci0))
|
||||
|
||||
### Security
|
||||
|
||||
- Blocked client file access to the daemon's own state in the Paseo home directory, and warned when a saved host's daemon key changes ([#11452](https://github.com/getpaseo/paseo/pull/11452))
|
||||
- Restricted loopback origin matching to `localhost`, `127.0.0.1` and `::1` for daemon WebSocket and HTTP requests ([#11686](https://github.com/getpaseo/paseo/pull/11686))
|
||||
- Stopped images in pull request comments and reviews from loading files from the host ([#11699](https://github.com/getpaseo/paseo/pull/11699))
|
||||
- Stopped `.worktreeinclude` from copying local files into worktrees from fork pull requests ([#11709](https://github.com/getpaseo/paseo/pull/11709))
|
||||
- Rejected schedule IDs that point outside the schedules directory ([#11727](https://github.com/getpaseo/paseo/pull/11727))
|
||||
|
||||
### Plugins
|
||||
|
||||
- Added a workspace layout API so plugins can open, move and close panes and tabs ([#11328](https://github.com/getpaseo/paseo/pull/11328))
|
||||
- Added `requirements.app` to set a separate minimum app version from the daemon's ([#11494](https://github.com/getpaseo/paseo/pull/11494) by [@mcowger](https://github.com/mcowger))
|
||||
- Fixed a plugin error in a press handler or timer closing the iOS and Android app ([#11412](https://github.com/getpaseo/paseo/pull/11412))
|
||||
- Fixed plugin operations deleting plugin entries added to `config.json` by hand ([#11501](https://github.com/getpaseo/paseo/pull/11501) by [@matchy233](https://github.com/matchy233))
|
||||
- Fixed registry plugin installs failing with Missing npm artifact when npm leaves registry URLs out of lockfiles ([#11656](https://github.com/getpaseo/paseo/pull/11656) by [@Brandon168](https://github.com/Brandon168))
|
||||
- Fixed local plugin reloads taking 12 to 21 seconds when the daemon runs under a large directory ([#11653](https://github.com/getpaseo/paseo/pull/11653))
|
||||
|
||||
## 0.18.2 - 2026-11-30
|
||||
|
||||
- **Redesigned model picker:** Pick models from a two-pane desktop view with cross-provider search, an in-place phone drawer with a thinking slider, and per-provider model lists in settings. ([#11186](https://github.com/getpaseo/paseo/pull/11186), [#11280](https://github.com/getpaseo/paseo/pull/11280), [#11295](https://github.com/getpaseo/paseo/pull/11295), [#11371](https://github.com/getpaseo/paseo/pull/11371), [#11313](https://github.com/getpaseo/paseo/pull/11313))
|
||||
|
||||
+59
-19
@@ -1,22 +1,45 @@
|
||||
# Changelog
|
||||
|
||||
## 0.19.0-beta.1 - 2026-12-02
|
||||
## 0.19.1 - 2026-12-03
|
||||
|
||||
### 变更
|
||||
|
||||
- 将 Agent 消息和子 Agent 完成通知的默认行为改为 `steer`,在不支持运行中转向的 Provider 上回退到 `queue` 而不中断当前轮次 ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复直接发送 `steer` 或 `interrupt` 消息时清空队列中的消息和完成通知的问题 ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
- 修复排队消息批次在临时派发错误或启动超时后被丢弃而不是保留的问题 ([#11915](https://github.com/getpaseo/paseo/pull/11915))
|
||||
- 修复 Claude 将排队的 steer 作为独立轮次执行后,父 Agent 漏收后续完成通知的问题 ([#11872](https://github.com/getpaseo/paseo/pull/11872))
|
||||
|
||||
## 0.19.0 - 2026-12-03
|
||||
|
||||
- **对话中切换 Provider**:可将对话切换到其他 Provider 并保留对话内容,对话记录现在存储在主机上。([#11410](https://github.com/getpaseo/paseo/pull/11410))
|
||||
- **排队消息重启不丢失**:排队消息现在保存在主机上,应用重新加载、切换设备或 daemon 重启后都不会丢失。([#11424](https://github.com/getpaseo/paseo/pull/11424), [#11566](https://github.com/getpaseo/paseo/pull/11566), [#11740](https://github.com/getpaseo/paseo/pull/11740))
|
||||
- **一键开关 Agent 工具**:Agent 工具现在由一个 **启用工具** 设置统一控制,包含编排、定时任务、PR 监控和浏览器分组,并默认开启。([#11189](https://github.com/getpaseo/paseo/pull/11189))
|
||||
- **已连接设备列表**:**设置 → 设备** 现在会显示哪些客户端和主机已连接,以及各自可以访问的内容。([#11209](https://github.com/getpaseo/paseo/pull/11209))
|
||||
- **插件评分卡**:应用和 paseo.sh 上的插件页面现在会显示评分卡、更新历史、相关插件和赞助链接。([#11563](https://github.com/getpaseo/paseo/pull/11563), [#11674](https://github.com/getpaseo/paseo/pull/11674), [#11691](https://github.com/getpaseo/paseo/pull/11691))
|
||||
- **插件运行确认**:应用现在会在首次运行某个主机上插件的代码前询问一次,也可以在 **通用** 设置中关闭此提示。([#11717](https://github.com/getpaseo/paseo/pull/11717))
|
||||
- **通过隧道共享服务**:可从 Scripts 菜单将正在运行的工作区服务共享到公网地址,开发服务器也会保留实时重载连接。服务现在通过 `localhost:<port>` 打开,`*.localhost` 服务地址已移除。([#11490](https://github.com/getpaseo/paseo/pull/11490))
|
||||
- **Agent 运行时更省资源**:运行中的 Agent 占用的 CPU、GPU 和电量大幅减少,状态环、加载指示器和工具调用动画也更轻量。([#11456](https://github.com/getpaseo/paseo/pull/11456), [#11474](https://github.com/getpaseo/paseo/pull/11474), [#11564](https://github.com/getpaseo/paseo/pull/11564), [#11586](https://github.com/getpaseo/paseo/pull/11586), [#11591](https://github.com/getpaseo/paseo/pull/11591),贡献者:[@djbclark](https://github.com/djbclark), [@luoph](https://github.com/luoph), [@mariotaku](https://github.com/mariotaku))
|
||||
- **更稳定的流式回复**:流式回复在到达时即显示最终格式,长回复的渲染也不再随长度增长而变慢。([#11572](https://github.com/getpaseo/paseo/pull/11572), [#11582](https://github.com/getpaseo/paseo/pull/11582),贡献者:[@luoph](https://github.com/luoph))
|
||||
- **更快的移动端启动**:移动端冷启动后会更快显示上次的工作区,在 Android 上约快 0.7 秒。([#11390](https://github.com/getpaseo/paseo/pull/11390),贡献者:[@luoph](https://github.com/luoph), [@maci0](https://github.com/maci0))
|
||||
- **桌面端浏览器配置文件**:桌面端浏览器标签页可以使用不同颜色的独立配置文件,便于在同一网站上同时登录两个账号。([#10357](https://github.com/getpaseo/paseo/pull/10357),贡献者:[@clkao](https://github.com/clkao))
|
||||
- **桌面端浏览器配置文件**:桌面端浏览器标签页可以使用不同颜色的独立配置文件,便于在同一网站上同时登录两个账号。([#10357](https://github.com/getpaseo/paseo/pull/10357), [#11772](https://github.com/getpaseo/paseo/pull/11772),贡献者:[@clkao](https://github.com/clkao))
|
||||
- **下滑收起 iOS 键盘**:向下拖动对话即可收起 iOS 键盘,键盘打开时对话控件首次点击即可生效。([#11625](https://github.com/getpaseo/paseo/pull/11625))
|
||||
|
||||
### 破坏性变更
|
||||
|
||||
- Paseo CLI 和 daemon 现在需要 Node.js 22.16.0 或更高版本 ([#11410](https://github.com/getpaseo/paseo/pull/11410))
|
||||
- 中继连接现在默认要求[受保护的端到端加密](https://paseo.sh/zh-CN/docs/security),因此 0.13.0 之前的应用无法再通过中继连接 ([#11864](https://github.com/getpaseo/paseo/pull/11864))
|
||||
|
||||
### 安全
|
||||
|
||||
- 桌面端浏览器中的网页默认禁止访问摄像头、麦克风、位置、通知和设备 ([#11837](https://github.com/getpaseo/paseo/pull/11837))
|
||||
- 阻止客户端访问 Paseo 主目录中 daemon 自身的状态文件,并在已保存主机的 daemon 密钥变化时发出警告 ([#11452](https://github.com/getpaseo/paseo/pull/11452))
|
||||
- 将 daemon WebSocket 和 HTTP 请求的回环来源匹配限制为 `localhost`、`127.0.0.1` 和 `::1` ([#11686](https://github.com/getpaseo/paseo/pull/11686))
|
||||
- 禁止 PR 评论和审查中的图片读取主机上的文件 ([#11699](https://github.com/getpaseo/paseo/pull/11699))
|
||||
- 禁止 `.worktreeinclude` 将本地文件复制到来自 fork PR 的 worktree 中 ([#11709](https://github.com/getpaseo/paseo/pull/11709))
|
||||
- 拒绝指向定时任务目录之外的定时任务 ID ([#11727](https://github.com/getpaseo/paseo/pull/11727))
|
||||
|
||||
### 新增
|
||||
|
||||
@@ -37,6 +60,7 @@
|
||||
- 桌面应用的网页界面改用 Brotli 和 gzip 压缩传输,不再发送未压缩的 25 MB 包 ([#10635](https://github.com/getpaseo/paseo/pull/10635),贡献者:[@djbclark](https://github.com/djbclark))
|
||||
- 对话加载改为显示一个稳定的加载指示器,并同时显示对话和 Composer,不再闪现 **正在更新消息** ([#11575](https://github.com/getpaseo/paseo/pull/11575))
|
||||
- 恢复工作区时保持 Restoring 界面,直到工作区就绪 ([#11486](https://github.com/getpaseo/paseo/pull/11486))
|
||||
- 调整移动端应用图标大小,使其与主屏幕上的其他图标一致,并支持 Android 主题图标和 iOS Liquid Glass ([#11851](https://github.com/getpaseo/paseo/pull/11851))
|
||||
- 归档检查未提交的更改时,在 worktree 行上显示加载指示器 ([#11519](https://github.com/getpaseo/paseo/pull/11519), [#11574](https://github.com/getpaseo/paseo/pull/11574),贡献者:[@cxroop](https://github.com/cxroop))
|
||||
- 在主机选择器上显示各主机的图标和状态圆点 ([#11568](https://github.com/getpaseo/paseo/pull/11568))
|
||||
- iPhone 上按硬件键盘的 Return 键即可发送提示词,与 iPad 一致 ([#11537](https://github.com/getpaseo/paseo/pull/11537))
|
||||
@@ -45,12 +69,29 @@
|
||||
### 变更
|
||||
|
||||
- 归档时如果 worktree 有未提交的更改,除非确认删除,否则保留该 worktree ([#11430](https://github.com/getpaseo/paseo/pull/11430))
|
||||
- **新建工作区** 界面中的 **导入会话** 改为创建新的工作区 ([#11845](https://github.com/getpaseo/paseo/pull/11845))
|
||||
- 关闭带有未发送草稿的 **新建 Agent** 标签页时,会先询问是否丢弃草稿 ([#11660](https://github.com/getpaseo/paseo/pull/11660))
|
||||
- 在侧边栏中 Cmd/Ctrl+点击工作区改为打开该工作区,而不再进入选择模式 ([#11472](https://github.com/getpaseo/paseo/pull/11472))
|
||||
- 已通过 `send_agent_prompt` 向调用方汇报的 Agent 不再额外发送完成通知 ([#11583](https://github.com/getpaseo/paseo/pull/11583))
|
||||
|
||||
### 插件
|
||||
|
||||
- 新增工作区布局 API,插件可以打开、移动和关闭面板与标签页 ([#11328](https://github.com/getpaseo/paseo/pull/11328))
|
||||
- 新增 `ProviderIcon`,插件可以显示 Paseo 的 Provider 图标 ([#4664](https://github.com/getpaseo/paseo/pull/4664),贡献者:[@omercnet](https://github.com/omercnet))
|
||||
- 新增 `requirements.app`,可单独设置与 daemon 不同的最低应用版本 ([#11494](https://github.com/getpaseo/paseo/pull/11494),贡献者:[@mcowger](https://github.com/mcowger))
|
||||
- 修复插件在按下处理函数或定时器中出错导致 iOS 和 Android 应用关闭的问题 ([#11412](https://github.com/getpaseo/paseo/pull/11412))
|
||||
- 修复网页端和桌面端插件弹出框每次打开都加载两次内容的问题 ([#11748](https://github.com/getpaseo/paseo/pull/11748),贡献者:[@tomgrin10](https://github.com/tomgrin10))
|
||||
- 修复桌面应用在插件重新加载后仍在内存中保留每个被替换插件版本的问题 ([#11800](https://github.com/getpaseo/paseo/pull/11800))
|
||||
- 修复插件操作删除手动添加到 `config.json` 中插件条目的问题 ([#11501](https://github.com/getpaseo/paseo/pull/11501),贡献者:[@matchy233](https://github.com/matchy233))
|
||||
- 修复 npm 在锁文件中省略 registry 地址时,注册表插件安装报 Missing npm artifact 错误的问题 ([#11656](https://github.com/getpaseo/paseo/pull/11656),贡献者:[@Brandon168](https://github.com/Brandon168))
|
||||
- 修复 daemon 运行在大型目录下时,本地插件重新加载耗时 12 至 21 秒的问题 ([#11653](https://github.com/getpaseo/paseo/pull/11653))
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复更改运行中 Agent 的思考强度、模式和模型后又跳回旧值的问题 ([#11850](https://github.com/getpaseo/paseo/pull/11850))
|
||||
- 修复已完成的 Agent 短暂闪回运行中状态的问题 ([#11764](https://github.com/getpaseo/paseo/pull/11764))
|
||||
- 修复对排队消息使用 **立即发送** 时取消正在运行的轮次、而不是引导该轮次的问题 ([#11827](https://github.com/getpaseo/paseo/pull/11827))
|
||||
- 修复发送失败或完成后,覆盖发送期间输入的后续草稿的问题 ([#11448](https://github.com/getpaseo/paseo/pull/11448),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
- 修复附加超过 2000 px 的图片后,该对话之后的每一轮都失败的问题 ([#5119](https://github.com/getpaseo/paseo/pull/5119),贡献者:[@RUIIIOVO](https://github.com/RUIIIOVO))
|
||||
- 修复关闭 Paseo 工具时语音模式 Agent 始终不回话的问题 ([#11161](https://github.com/getpaseo/paseo/pull/11161))
|
||||
- 修复在没有 daemon 连接时关闭语音模式后麦克风仍保持开启的问题 ([#11587](https://github.com/getpaseo/paseo/pull/11587),贡献者:[@luoph](https://github.com/luoph), [@RRD-dev](https://github.com/RRD-dev))
|
||||
@@ -61,18 +102,25 @@
|
||||
- 修复重连复用订阅后终端输出停止的问题 ([#10433](https://github.com/getpaseo/paseo/pull/10433),贡献者:[@chirag127](https://github.com/chirag127))
|
||||
- 修复应用在主机连接前启动时 **文件** 显示 **Host 未连接** 的问题 ([#11679](https://github.com/getpaseo/paseo/pull/11679))
|
||||
- 修复主机离线时 **创建时间** 和 **最近提示词** 排序选项消失的问题 ([#11728](https://github.com/getpaseo/paseo/pull/11728))
|
||||
- 修复在 iOS 和 Android 上横向滑动水平滚动区域时打开或关闭侧边面板的问题 ([#11841](https://github.com/getpaseo/paseo/pull/11841))
|
||||
- 修复在 iOS 上点击标题栏会将对话、Explorer 或工作区列表滚动到顶部的问题 ([#11262](https://github.com/getpaseo/paseo/pull/11262),贡献者:[@yzim](https://github.com/yzim))
|
||||
- 修复文件面板在打开过程中被关闭后,留下阻挡点击的不可见遮罩的问题 ([#11317](https://github.com/getpaseo/paseo/pull/11317),贡献者:[@LiebeLee](https://github.com/LiebeLee))
|
||||
- 修复底部面板在打开动画开始前被关闭后仍保持打开的问题 ([#11632](https://github.com/getpaseo/paseo/pull/11632))
|
||||
- 修复 Android 在选择图片期间重建应用后未附加任何内容的问题 ([#7734](https://github.com/getpaseo/paseo/pull/7734))
|
||||
- 修复在 Linux 上中键点击标签页时将选中内容粘贴到终端的问题 ([#11818](https://github.com/getpaseo/paseo/pull/11818))
|
||||
- 修复按下 Cmd/Ctrl+F 后立即输入时 **查找** 丢失前几个按键的问题 ([#11812](https://github.com/getpaseo/paseo/pull/11812))
|
||||
- 修复在网页版 Composer 中粘贴文件时插入文件路径而不是添加附件的问题 ([#11718](https://github.com/getpaseo/paseo/pull/11718))
|
||||
- 修复 **内容字体大小** 未应用到网页端对话中已有用户消息的问题 ([#11469](https://github.com/getpaseo/paseo/pull/11469),贡献者:[@bearyjd](https://github.com/bearyjd))
|
||||
- 修复 Markdown 表格单元格中的 `<br>` 拆分表格行的问题 ([#9587](https://github.com/getpaseo/paseo/pull/9587),贡献者:[@apple-ouyang](https://github.com/apple-ouyang))
|
||||
- 修复网页端隐藏的对话行导致阅读位置偏移的问题 ([#11538](https://github.com/getpaseo/paseo/pull/11538),贡献者:[@kogekiplay](https://github.com/kogekiplay))
|
||||
- 修复不带结尾斜杠的工作区外文件夹链接被打开为损坏的文件标签页的问题 ([#11786](https://github.com/getpaseo/paseo/pull/11786))
|
||||
- 修复 `paseo.json` 变更后 Scripts 菜单未更新的问题 ([#11768](https://github.com/getpaseo/paseo/pull/11768),贡献者:[@odoo-mvds](https://github.com/odoo-mvds))
|
||||
- 修复工具调用详情的空状态文字紧贴屏幕边缘的问题 ([#9129](https://github.com/getpaseo/paseo/pull/9129),贡献者:[@ilteoood](https://github.com/ilteoood))
|
||||
- 修复带附件的插件斜杠命令被当作消息发送给 Agent 的问题 ([#11483](https://github.com/getpaseo/paseo/pull/11483),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
- 修复 **归档已完成的 subagent** 跳过已关闭子 Agent 的问题 ([#10865](https://github.com/getpaseo/paseo/pull/10865),贡献者:[@sbhas2k](https://github.com/sbhas2k))
|
||||
- 修复 **导入会话** 遗漏最新 ACP 会话的问题 ([#10675](https://github.com/getpaseo/paseo/pull/10675))
|
||||
- 修复 **导入会话** 在 **重试** 期间隐藏 Provider 错误的问题 ([#11654](https://github.com/getpaseo/paseo/pull/11654))
|
||||
- 修复 **导入会话** 无法打开旧版自定义 Codex Provider 对话的问题 ([#11852](https://github.com/getpaseo/paseo/pull/11852))
|
||||
- 修复设置时丢弃 60 秒后才响应的 Provider 所给出的项目建议的问题 ([#11438](https://github.com/getpaseo/paseo/pull/11438),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
- 修复远程主机上的工作区显示 Open in file manager 的问题 ([#11463](https://github.com/getpaseo/paseo/pull/11463),贡献者:[@sleroq](https://github.com/sleroq))
|
||||
- 修复根目录为 `/` 的工作区无法使用 Reveal in Finder 的问题 ([#11206](https://github.com/getpaseo/paseo/pull/11206),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
@@ -85,6 +133,7 @@
|
||||
- 修复 Claude 自行开始的轮次在重新打开的对话中被隐藏、直到 **重新加载** 才显示的问题 ([#11405](https://github.com/getpaseo/paseo/pull/11405))
|
||||
- 修复 Claude Code 系统通知从对话中丢失的问题 ([#11419](https://github.com/getpaseo/paseo/pull/11419),贡献者:[@minamorl](https://github.com/minamorl))
|
||||
- 修复导入的 Claude Code 对话中缺少 Goal set 回复的问题 ([#11733](https://github.com/getpaseo/paseo/pull/11733))
|
||||
- 修复 Claude Code Stop hook 警告提示按下一个在 Paseo 中会打开 **添加项目** 的快捷键的问题 ([#11792](https://github.com/getpaseo/paseo/pull/11792))
|
||||
- 修复在已归档的 Claude 对话中列出命令时启动 Claude Code 的问题 ([#11521](https://github.com/getpaseo/paseo/pull/11521),贡献者:[@RawSalmon69](https://github.com/RawSalmon69))
|
||||
- 修复 **停止** 对无响应的 Pi 和 OMP Agent 无效的问题 ([#11618](https://github.com/getpaseo/paseo/pull/11618),贡献者:[@LouisDeconinck](https://github.com/LouisDeconinck))
|
||||
- 修复扩展处理提示词时 Pi 轮次永远无法结束的问题 ([#10572](https://github.com/getpaseo/paseo/pull/10572),贡献者:[@jsilhan](https://github.com/jsilhan))
|
||||
@@ -92,12 +141,16 @@
|
||||
- 修复扩展在回复前发送上下文时 Pi 重复显示提示词的问题 ([#11533](https://github.com/getpaseo/paseo/pull/11533),贡献者:[@Stelath](https://github.com/Stelath))
|
||||
- 修复在受信任的工作区中 Pi 对话跳过项目技能和设置的问题 ([#11527](https://github.com/getpaseo/paseo/pull/11527),贡献者:[@patrick-motard](https://github.com/patrick-motard))
|
||||
- 修复冲突解决后新建 Pi Agent 仍报旧扩展错误的问题 ([#11642](https://github.com/getpaseo/paseo/pull/11642))
|
||||
- 修复 Agent 以所选选项批准 Pi 提示时 Pi 收到取消的问题 ([#11814](https://github.com/getpaseo/paseo/pull/11814),贡献者:[@djbclark](https://github.com/djbclark))
|
||||
- 修复首次发送提示词前缺少 OMP **快速** 开关的问题 ([#11553](https://github.com/getpaseo/paseo/pull/11553))
|
||||
- 修复已完成的 OMP 表单提问不再显示提问内容和所选答案的问题 ([#11697](https://github.com/getpaseo/paseo/pull/11697), [#11706](https://github.com/getpaseo/paseo/pull/11706),贡献者:[@luoph](https://github.com/luoph), [@RRD-dev](https://github.com/RRD-dev))
|
||||
- 修复 Codex 启动失败导致 daemon 崩溃的问题 ([#11847](https://github.com/getpaseo/paseo/pull/11847),贡献者:[@xilinshancun](https://github.com/xilinshancun))
|
||||
- 修复 Codex 退出后空闲的 Codex Agent 始终不释放资源的问题 ([#11839](https://github.com/getpaseo/paseo/pull/11839),贡献者:[@michaelmwu](https://github.com/michaelmwu))
|
||||
- 修复 Codex 仍在启动时发送消息于 60 秒后报告失败的问题 ([#11547](https://github.com/getpaseo/paseo/pull/11547),贡献者:[@nonononull](https://github.com/nonononull))
|
||||
- 修复通过 `env codex` 等包装命令启动时 Codex 功能被隐藏的问题 ([#11221](https://github.com/getpaseo/paseo/pull/11221),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
- 修复 Codex 异步提问的回答被拒绝的问题 ([#11225](https://github.com/getpaseo/paseo/pull/11225),贡献者:[@suniceman](https://github.com/suniceman))
|
||||
- 修复重新打开 Codex 对话时重置其最近活动时间的问题 ([#10760](https://github.com/getpaseo/paseo/pull/10760),贡献者:[@Juns-g](https://github.com/Juns-g))
|
||||
- 修复 OpenCode 回复的段落连在一起的问题 ([#11745](https://github.com/getpaseo/paseo/pull/11745))
|
||||
- 修复 Antigravity 子 Agent 工具调用将流式回复从单词中间截断的问题 ([#11535](https://github.com/getpaseo/paseo/pull/11535),贡献者:[@Suhail](https://github.com/Suhail))
|
||||
- 修复 Antigravity 轮次在内部执行器出错后仍以完成状态结束的问题 ([#10885](https://github.com/getpaseo/paseo/pull/10885),贡献者:[@vecyang1](https://github.com/vecyang1), [@luoph](https://github.com/luoph))
|
||||
- 修复 Provider 拒绝已保存的思考强度时 ACP 对话无法重新打开的问题 ([#10333](https://github.com/getpaseo/paseo/pull/10333))
|
||||
@@ -123,27 +176,14 @@
|
||||
- 修复排队消息以之后发送的提示词的模式运行的问题 ([#11722](https://github.com/getpaseo/paseo/pull/11722))
|
||||
- 修复 `paseo ls --json` 丢失时间戳和后台任务的问题 ([#11423](https://github.com/getpaseo/paseo/pull/11423),贡献者:[@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- 修复 `paseo inspect` 和 `paseo ls` 隐藏 Cursor Auto 模型的问题 ([#11693](https://github.com/getpaseo/paseo/pull/11693))
|
||||
- 修复 `paseo ls --label` 使用格式错误的标签时列出所有 Agent 的问题 ([#11707](https://github.com/getpaseo/paseo/pull/11707),贡献者:[@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- 修复 `paseo terminal capture` 和 `paseo terminal send-keys` 忽略 `--json` 的问题 ([#11710](https://github.com/getpaseo/paseo/pull/11710),贡献者:[@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- 修复 `paseo terminal create --workspace` 对排在前十个之后的工作区失败的问题 ([#11799](https://github.com/getpaseo/paseo/pull/11799),贡献者:[@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- 修复 `paseo schedule update --model` 必须重复指定 Provider 才能成功的问题 ([#11796](https://github.com/getpaseo/paseo/pull/11796),贡献者:[@KiritoXDone](https://github.com/KiritoXDone))
|
||||
- 修复 `paseo workspace ls` 将密码错误报告为 daemon 已停止的问题 ([#11676](https://github.com/getpaseo/paseo/pull/11676),贡献者:[@chirag127](https://github.com/chirag127))
|
||||
- 修复 `paseo daemon status` 遗漏未确认的终端清理的问题 ([#11658](https://github.com/getpaseo/paseo/pull/11658),贡献者:[@chirag127](https://github.com/chirag127))
|
||||
- 修复 CLI 归档、分离和重新加载时为匹配完整 Agent ID 而扫描全部 Agent 历史记录的问题 ([#11617](https://github.com/getpaseo/paseo/pull/11617),贡献者:[@maci0](https://github.com/maci0))
|
||||
|
||||
### 安全
|
||||
|
||||
- 阻止客户端访问 Paseo 主目录中 daemon 自身的状态文件,并在已保存主机的 daemon 密钥变化时发出警告 ([#11452](https://github.com/getpaseo/paseo/pull/11452))
|
||||
- 将 daemon WebSocket 和 HTTP 请求的回环来源匹配限制为 `localhost`、`127.0.0.1` 和 `::1` ([#11686](https://github.com/getpaseo/paseo/pull/11686))
|
||||
- 禁止 PR 评论和审查中的图片读取主机上的文件 ([#11699](https://github.com/getpaseo/paseo/pull/11699))
|
||||
- 禁止 `.worktreeinclude` 将本地文件复制到来自 fork PR 的 worktree 中 ([#11709](https://github.com/getpaseo/paseo/pull/11709))
|
||||
- 拒绝指向定时任务目录之外的定时任务 ID ([#11727](https://github.com/getpaseo/paseo/pull/11727))
|
||||
|
||||
### 插件
|
||||
|
||||
- 新增工作区布局 API,插件可以打开、移动和关闭面板与标签页 ([#11328](https://github.com/getpaseo/paseo/pull/11328))
|
||||
- 新增 `requirements.app`,可单独设置与 daemon 不同的最低应用版本 ([#11494](https://github.com/getpaseo/paseo/pull/11494),贡献者:[@mcowger](https://github.com/mcowger))
|
||||
- 修复插件在按下处理函数或定时器中出错导致 iOS 和 Android 应用关闭的问题 ([#11412](https://github.com/getpaseo/paseo/pull/11412))
|
||||
- 修复插件操作删除手动添加到 `config.json` 中插件条目的问题 ([#11501](https://github.com/getpaseo/paseo/pull/11501),贡献者:[@matchy233](https://github.com/matchy233))
|
||||
- 修复 npm 在锁文件中省略 registry 地址时,注册表插件安装报 Missing npm artifact 错误的问题 ([#11656](https://github.com/getpaseo/paseo/pull/11656),贡献者:[@Brandon168](https://github.com/Brandon168))
|
||||
- 修复 daemon 运行在大型目录下时,本地插件重新加载耗时 12 至 21 秒的问题 ([#11653](https://github.com/getpaseo/paseo/pull/11653))
|
||||
|
||||
## 0.18.2 - 2026-11-30
|
||||
|
||||
- **重新设计的模型选择器**:桌面端采用支持跨 Provider 搜索的双栏视图,手机端合并为带思考强度滑块的单层抽屉,并支持在设置中按 Provider 筛选常用模型。([#11186](https://github.com/getpaseo/paseo/pull/11186), [#11280](https://github.com/getpaseo/paseo/pull/11280), [#11295](https://github.com/getpaseo/paseo/pull/11295), [#11371](https://github.com/getpaseo/paseo/pull/11371), [#11313](https://github.com/getpaseo/paseo/pull/11313))
|
||||
|
||||
+23
-20
@@ -154,15 +154,15 @@ Users can also detach an existing subagent from the subagents track. Detach is d
|
||||
|
||||
Agent-originated messages and automatic notifications share a recipient-daemon delivery module. The daemon saves a queued message, then acknowledges it with a receipt, before provider dispatch. The module keeps one ordered queue per recipient, and the recipient reads its prompts in the order the daemon admitted them. Nothing overtakes an older queued message. A prompt takes its place when the daemon admits it, even while the provider is still starting an earlier turn, and a message stays in the queue until the turn that carries it starts. The turn has started when the agent manager acknowledges the run start; a turn that fails after that point is not delivered again.
|
||||
|
||||
Any sender picks `queue`, `steer`, or `interrupt` with `activeTurnBehavior`. Agent senders default to `queue`; non-agent senders (app, CLI, plugins, Hub, top-level MCP) default to `interrupt`. Each kind of prompt is released this way:
|
||||
Any sender picks `queue`, `steer`, or `interrupt` with `activeTurnBehavior`. Agent senders and finish notifications default to `steer` (falling back to `queue` on providers without `steerActiveTurn`); non-agent senders (app, CLI, plugins, Hub, top-level MCP) default to `interrupt` (or `steer` in composer settings). Each kind of prompt is released this way:
|
||||
|
||||
- **`queue`** waits for any running or starting turn (including compaction) to end on its own or fail, then delivers the queued prompts together. The daemon releases it when it observes the recipient settle; a two-second timer also retries. On an idle recipient, agent messages wait two quiet seconds (steady arrivals cannot hold that window open past ten seconds); a non-agent queued message skips that quiet window and starts a turn at once. A non-agent queued message is sent unwrapped when dispatched alone, and in a `kind="user-message"` envelope when it shares a prompt with other messages. Finish notifications and change-request updates always queue.
|
||||
- **`steer`** waits for neither the quiet window nor the turn. It is dispatched at admission as one prompt that enters the running turn: the messages queued before it, then the steer. A provider that cannot steer, or that refuses this steer, gets the prompt as a replacing turn instead, the same as a person's steer.
|
||||
- **`interrupt`** is dispatched at admission the same way, as one prompt that replaces the running turn. An older queued message cannot start a turn after the newer `interrupt` that countermands it.
|
||||
- **A person's direct prompt** (`steer` or `interrupt` from app, CLI, plugins, Hub, or top-level MCP) is dispatched directly and takes the queue along the same way: the messages admitted before it first, then the person's text, in one provider prompt. Messages admitted after it follow it. The person's text keeps its own transcript row. When the turn does not start, the messages return to the queue in their place. That covers a start the provider rejects and a start that is not acknowledged within 60 seconds; a provider that starts the turn after those 60 seconds receives the messages twice.
|
||||
- **Stop** (the stop button, Escape, `cancel_agent`, a Hub interrupt) starts nothing. Messages admitted before the Stop are held, not dropped, including an interrupt whose turn had not started yet. They go ahead of the recipient's next prompt, in that prompt's turn: a person's prompt, or an agent message or notification admitted after the Stop. A held steer or interrupt no longer enters the turn; it waits like a queued message. A queue step or dispatch decided before the Stop is void, and the queue is held again when the message that reopened it is withdrawn. A replacing prompt, a reload, and a rewind are not a Stop. Neither is `cancel_agent` on a recipient with no running or starting turn: it stops nothing, reports that it canceled no run, and a queued message keeps its quiet window.
|
||||
- **`queue`** waits for any running or starting turn (including compaction) to end on its own or fail, then delivers the queued prompts together. The daemon releases it when it observes the recipient settle; a two-second timer also retries. On an idle recipient, agent messages wait two quiet seconds (steady arrivals cannot hold that window open past ten seconds); a non-agent queued message skips that quiet window and starts a turn at once. A non-agent queued message is sent unwrapped when dispatched alone, and in a `kind="user-message"` envelope when it shares a prompt with other messages.
|
||||
- **`steer`** from an agent sender enters the running turn without cutting it, carrying earlier agent-queued messages ahead of it while leaving human-queued items untouched in the queue. Finish notifications batch across the two-second quiet window before steering so parallel completions arrive together. If the provider cannot steer (`canSteer` is false, e.g., ACP agents) or rejects steering mid-turn without ending the turn, the daemon keeps the message queued until the turn ends rather than interrupting it.
|
||||
- **`interrupt`** is dispatched at admission the same way, replacing the running turn and carrying earlier non-human-queued messages ahead of it.
|
||||
- **A person's direct prompt** (`steer` or `interrupt` from app, CLI, plugins, Hub, or top-level MCP) runs immediately by itself and does **not** sweep queued messages. Queued messages stay intact in the queue track and dispatch once the turn settles, unless the queue is behind a staged provider switch (where the switch queues behind items meant for the current provider). When a non-command, non-resume direct human prompt succeeds on a held queue (after Stop or a refused start), it reopens the held queue so remaining queued items resume after the turn ends.
|
||||
- **Stop** (the stop button, Escape, `cancel_agent`, a Hub interrupt) starts nothing. Messages admitted before the Stop are held, not dropped, including an interrupt whose turn had not started yet. Held items wait until reopened by a direct non-command prompt, a newly admitted message, or explicit Send now (`promote`). A queue step or dispatch decided before the Stop is void, and the queue is held again when the message that reopened it is withdrawn. A replacing prompt, a reload, and a rewind are not a Stop. Neither is `cancel_agent` on a recipient with no running or starting turn: it stops nothing, reports that it canceled no run, and a queued message keeps its quiet window.
|
||||
|
||||
The queued receipt carries the applied behavior and guidance text for the sender. The text comes from two facts known at admission: whether the recipient has a running turn, and whether its provider can steer (`AgentManager.canSteer`, which is true when the session offers `steerActiveTurn`). It does not wait for the outcome. Guidance for a message queued behind a running turn tells the sender to send a short `steer` or `interrupt` follow-up instead of resending, because the follow-up carries the queued message ahead of it and a resend would be read twice. The MCP tool, the WebSocket `send_agent_message_response`, the CLI, and the connected-host path all relay this one text.
|
||||
The queued receipt carries the applied behavior and guidance text for the sender. The text comes from two facts known at admission: whether the recipient has a running turn, and whether its provider can steer (`AgentManager.canSteer`, which is true when the session offers `steerActiveTurn`). It does not wait for the outcome. Guidance for a message queued behind a running turn tells the sender to send a short `steer` or `interrupt` follow-up instead of resending, because an agent follow-up carries earlier agent-queued messages ahead of it. On non-steering providers, queued `steer` reports as `queue` and notes that `steer` waits until the turn ends. The MCP tool, the WebSocket `send_agent_message_response`, the CLI, and the connected-host path all relay this one text.
|
||||
|
||||
Older CLIs and connected hosts send an explicit `steer` for every default agent send. The daemon reads an agent sender's `steer` as `queue` unless the client advertises the `agent_active_turn_behaviors` capability. A new client talking to a daemon without `server_info.features.agentActiveTurnBehaviors` sends no behavior for `queue` and refuses a `steer`. A new client talking to a daemon without `server_info.features.nonAgentMessageQueue` refuses a non-agent `queue` before sending.
|
||||
|
||||
@@ -173,8 +173,8 @@ One provider prompt has one session mode. A batch released by a steer, an interr
|
||||
A provider switch can wait in the queue too (`agent.provider.switch.request` with
|
||||
`activeTurnBehavior: "queue"`). The message carries the target provider and settings, shares a prompt
|
||||
with nothing, and divides the queue: what is ahead of it goes to the current provider, and it and
|
||||
what follows go to the target. A direct prompt therefore takes along only the queued rows ahead of
|
||||
the switch. Promoting the switch cuts the running turn once the target is known to be usable. A chat
|
||||
what follows go to the target. A direct provider switch queues right behind any items queued for
|
||||
the current provider so those items dispatch first. Promoting the switch cuts the running turn once the target is known to be usable. A chat
|
||||
already on the target takes the message and its settings as a plain prompt. A switch that fails keeps
|
||||
the message and holds the queue; the reason is in the daemon log.
|
||||
|
||||
@@ -184,10 +184,10 @@ queue holds references. An empty message is refused, and a recipient holds at mo
|
||||
messages.
|
||||
|
||||
A message is marked `dispatching` before the provider can receive it and removed when the provider
|
||||
admits it. A dispatch that is not admitted returns the message to its place. A refused turn start
|
||||
also holds the queue: retrying by itself would be refused again and would add the prompt to the
|
||||
history each time. A message that cannot be sent is removed so that it does not block the ones
|
||||
behind it.
|
||||
admits it. A dispatch that fails transiently (busy/non-steering turn, run-start timeout, mode/RPC
|
||||
error, or rejected start) returns the batch to the queue rather than deleting it; non-busy failures
|
||||
also hold the queue until the next prompt reopens it. Only pre-dispatch unresolvable payloads (such
|
||||
as missing local attachments) or rejected out-of-band commands are discarded so they do not block later messages.
|
||||
|
||||
Shutdown does not send the queue. It waits only for dispatches already in flight, and everything
|
||||
else stays saved, held messages included. Closing an idle runtime keeps the queue. Archiving or
|
||||
@@ -232,9 +232,11 @@ at-least-once wakeup, without turn attribution or exactly-once delivery.
|
||||
A turn end is not always a settled child. A child can end its turn with work that will start its next
|
||||
turn by itself: a running turn, queued messages, a pending provider wake-up
|
||||
(`AgentSession.hasPendingWakeup`: Claude background tasks, task notifications, and one-shot
|
||||
wake-ups), or the child's own outstanding finish subscriptions as a caller. Heartbeats, recurring
|
||||
crons, change-request watches, and other daemon background items never count: they are external
|
||||
triggers, not work the caller is waiting for.
|
||||
wake-ups), or the child's own outstanding finish subscriptions as a caller. Queued finish notices
|
||||
(`agent-notification`) and turns started only by finish notices do not count as pending work
|
||||
unless a real prompt is batched into or steered into the turn. Heartbeats, recurring crons,
|
||||
change-request watches, and other daemon background items never count: they are external triggers,
|
||||
not work the caller is waiting for.
|
||||
|
||||
Every turn end reports `finished` at once, unless the child already sent an agent message to its
|
||||
caller during that turn and started no further tool work afterwards. In that case the child's
|
||||
@@ -243,8 +245,9 @@ ends silently, and a watch with pending work keeps following silently until a la
|
||||
the work drains. Starting another non-reporting tool call or a new turn clears that mark (plain text output after the
|
||||
message does not), and errors, permission requests, cancellations, and closes are never suppressed. When work is still
|
||||
pending on an unreported turn end, the notice names it and the subscription follows the child: each
|
||||
later turn end reports `finished` again, and the child settling with nothing pending sends a final
|
||||
`finished` and removes the subscription, even when the work drains without another turn. Reporting
|
||||
later turn end reports `finished` again, except that a turn started only by finish notices while
|
||||
already following keeps following without another interim notice; the child settling with nothing
|
||||
pending still sends the final `finished` and removes the subscription, even when the work drains without another turn. Reporting
|
||||
at once keeps a long-lived task, such as a dev server, from leaving the caller without the child's
|
||||
reply. Following is what lets the caller hear the reply a background task wakes up later
|
||||
([#6346](https://github.com/getpaseo/paseo/issues/6346)). A work change that leaves work pending
|
||||
@@ -456,8 +459,8 @@ Rows take these commands:
|
||||
already started sending the row, the draft stays as it is.
|
||||
- **Cancel** withdraws the row.
|
||||
|
||||
A message you send directly (`steer` or `interrupt`) takes the queued rows with it, ahead of your
|
||||
text.
|
||||
A message you send directly (`steer` or `interrupt`) runs right away without sweeping the queue track;
|
||||
queued rows stay visible in place and dispatch after the turn ends (unless held by Stop).
|
||||
|
||||
A message sent mid-turn with a staged provider switch is queued whatever the send behavior, and its
|
||||
row names the target.
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ Authoritative terminology. UI label wins. Don't invent synonyms; use what's here
|
||||
- **Agent controls** — Provider, model, mode, thinking, and provider-feature controls for an agent or draft agent. Code: `AgentControls` / `DraftAgentControls` (`packages/app/src/composer/agent-controls/index.tsx`). Forbidden: "Agent status bar".
|
||||
- **Composer footer** — Optional area rendered below the composer input but still inside the keyboard-shifted composer layout. Code: `Composer.footer` (`packages/app/src/composer/index.tsx`).
|
||||
- **Composer track** — A contextual lane at the foot of a pane, by the composer input. Specific tracks use the `<thing> track` form: **Queue track**, **Subagents track**, **Tasks track**. The subagents and tasks tracks are pills floating over the transcript, each opening a panel with its rows; the [queue track](agent-lifecycle.md#the-queue-track) is a lane inside the composer itself. Code: `ComposerQueueTrack` (`packages/app/src/composer/queue/track.tsx`), pill and panel frame in `packages/app/src/composer/tracks.tsx`, `SubagentsTrack` (`packages/app/src/subagents/track.tsx`), `AgentTaskList` (`packages/app/src/composer/task-list/index.tsx`).
|
||||
- **Steer** — A follow-up admitted into an agent's already-running turn instead of interrupting it. Interrupting the turn discards steers the provider has not read yet; there is no take-back short of that, and no provider offers one. The stop button and Escape both interrupt. A steer the provider never read keeps its transcript row, matching Codex. Sending while the agent waits on a permission denies that request first, so the message reaches the same turn instead of stalling behind it. UI: "Send and steer". Code: `steerActiveTurn` (`packages/server/src/server/agent/agent-sdk-types.ts`). Don't confuse with **Queue track**, which lists the messages the host holds until the turn ends. A queued message does not enter the running turn. An agent sender's `activeTurnBehavior: "steer"` (CLI `--behavior steer`) means the same as a person's steer. Agent senders default to `queue` instead: the daemon holds the message until the running turn ends, as it does for a person's queued message. Forbidden: "Delivery", "Queued prompt".
|
||||
- **Steer** — A follow-up admitted into an agent's already-running turn instead of interrupting it. Interrupting the turn discards steers the provider has not read yet; there is no take-back short of that, and no provider offers one. The stop button and Escape both interrupt. A steer the provider never read keeps its transcript row, matching Codex. Sending while the agent waits on a permission denies that request first, so the message reaches the same turn instead of stalling behind it. UI: "Send and steer". Code: `steerActiveTurn` (`packages/server/src/server/agent/agent-sdk-types.ts`). Don't confuse with **Queue track**, which lists the messages the host holds until the turn ends. A queued message does not enter the running turn, and a person's direct steer leaves queued rows in the queue track. Agent senders and finish notifications default to `steer` (falling back to `queue` when the provider cannot steer) and never sweep human-queued items. Forbidden: "Delivery", "Queued prompt".
|
||||
- **Subagent** — User-facing term for an agent session related to a parent agent session. Use **subagents** in UI copy and docs. Internal daemon/provider plumbing may say "child agent" or `child_session`, especially for provider-managed imports; do not surface "child agent" as a product term.
|
||||
- **Attachment tray** — The selected-attachments row inside the composer input, above the text input. Code: `renderAttachmentTray` (`packages/app/src/composer/index.tsx`). Forbidden: "Attachment bar".
|
||||
- **Fork** — Starting a NEW agent session seeded with a copy of another session's curated chat history. The history rides along as a `chat_history` composer attachment on a draft; the fork does **not** resume or branch the provider-side session, and the source session keeps running untouched. Two targets, one surface, one RPC (`agent.fork_context`, gated on the `agentForkContext` host feature). UI: the fork menu lives in the assistant turn footer and offers "Fork in a new tab" / "Fork in a new workspace". On a **completed** turn it sits beside the copy button and pins a boundary to that turn, so the fork stops where the turn ended. On the **in-flight** turn it sits beside the progress loader and elapsed timer, and omits the boundary entirely — `selectForkContextRows` projects the whole timeline when no boundary is given, so the fork captures everything **up to now**, including the response still streaming. That omission is what makes mid-run forking work; pinning a boundary there would silently drop the live response. Forbidden on provider-subagent (read-only) panes. Code: `useForkAgent` (`packages/app/src/hooks/use-fork-agent.ts`), `selectForkContextRows` (`packages/server/src/server/agent/activity-curator.ts`). Don't confuse with: git fork (unrelated; Paseo has no such concept), **Worktree** (filesystem isolation, not history copying).
|
||||
|
||||
+18
-4
@@ -433,7 +433,9 @@ query cache. Explicit SDK targets follow the [host API contract](../public-docs/
|
||||
|
||||
Workspace panels, Command Center items, and client slash commands are client contributions. The
|
||||
daemon transports their compiled bundle without interpreting placement or callbacks. Panel props
|
||||
contain workspace and agent IDs. Required-selector hooks read normalized client state synchronously
|
||||
carry `workspaceId`, validated read-only `params` (with host-enforced `agentId` on agent panels),
|
||||
`revision`, and `tab`; optional `identity(params)` sets the coalescing key on the persisted
|
||||
`plugin` target. Required-selector hooks read normalized client state synchronously
|
||||
and use shallow equality, so a panel does not subscribe to fields it does not render. Command
|
||||
callbacks materialize their snapshots only when invoked. Contribution discovery and panel opening
|
||||
never fetch active context through plugin RPC. Snapshot DTOs are deeply readonly and frozen at
|
||||
@@ -442,8 +444,18 @@ runtime so plugin code cannot mutate normalized app state or a memoized selectio
|
||||
current installed-plugin catalog. A missing contribution renders unavailable inside the tab.
|
||||
Panels declare `locations: ["workspace", "explorer"]` to opt into Explorer hosting; omission means
|
||||
workspace only. Location controls hosting, not context. An agent panel target keeps its `agentId`
|
||||
when moved between hosts. Explorer configuration can create workspace-context panels and remove
|
||||
existing agent-context instances, but it cannot create an agent panel without an agent-aware command.
|
||||
and `params` when moved between hosts. UI launchers only offer workspace-context panels whose
|
||||
`params` schema accepts `{}`.
|
||||
|
||||
`AgentChat` renders the agent tab's own chain (`AgentPanelContent` in
|
||||
`packages/app/src/panels/agent-panel.tsx`) through `packages/app/src/agent-embed`. The chain takes
|
||||
a `ConversationSurface` instead of reading the pane: a pane has a tab to retarget and a pill track,
|
||||
an embed has neither, so its composer handles `/clear` by opening the agent's workspace and the
|
||||
track is never mounted. The embed publishes itself as a viewer with `useViewedAgent`, the hook the
|
||||
workspace sheet uses, so the tab and every embed of one agent share the sync's single observation.
|
||||
`controls: "none"` is the composer's `message` input mode (`composer/input-mode.ts`). Key focus
|
||||
follows the pane rule: the embed the user last pressed owns Escape and send, while its pane or
|
||||
screen is in front.
|
||||
|
||||
Command Center callbacks use the selected host's existing `PaseoApi` for normal Paseo operations.
|
||||
They use typed plugin RPC only for plugin-specific backend work. Surface and panel navigation
|
||||
@@ -482,7 +494,9 @@ configuration; `agent.open.before` contributes launch-only `env`, `tools`, `mcpS
|
||||
`packages/server/src/server/plugins/session-attachments.ts` records what each plugin contributed to
|
||||
each live session. A plugin start, stop, or reload reruns only that plugin's callback per session,
|
||||
swaps its tools in place, and reopens a session only when its launch would differ. A reopen closes
|
||||
the provider process, so a reload must not reopen agents the plugin does not change.
|
||||
the provider process, so a reload must not reopen agents the plugin does not change, and a changed
|
||||
launch waits until the agent's provider subagents and background work end. If the provider cannot
|
||||
confirm that its runtime is safe to stop, the session stays open for the prompt.
|
||||
|
||||
### Launch wrap
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Two contracts follow from it.
|
||||
|
||||
A schema change must not break parsing in either direction. An old app still parses messages from a new daemon. A new daemon still parses messages from an old app.
|
||||
|
||||
`hello` carries an optional credential. The daemon accepts a client protocol version from its minimum through newer client versions, selects the lower of client and daemon maximum, and reports it as optional `server_info.protocolVersion`. A `hello.rejected` frame precedes an auth close only when the client sent `hello.auth` or advertised `hello_rejection`; older clients receive the existing WebSocket close code and reason. This avoids sending them a new top-level message their validator does not recognize.
|
||||
`hello` carries an optional credential. The daemon accepts a client protocol version from its minimum through newer client versions, selects the lower of client and daemon maximum, and reports it as optional `server_info.protocolVersion`. A `hello.rejected` frame precedes a refusal close only when the client sent `hello.auth` or advertised `hello_rejection` or `evolvable_hello_rejection`; older clients receive only the WebSocket close code and reason so their validator does not reject an unknown top-level envelope. Clients advertising `evolvable_hello_rejection` accept open `reason`, optional `accepts`, and optional `message` fields and halt reconnects on any refusal. Reserve `hello.rejected` for refusals that require user or client-version action; transient restarts and temporary unavailability close the socket without `hello.rejected` so clients reconnect automatically. For `hello_rejection`-only clients, the daemon downgrades unknown reasons to `password_required` (when `accepts` includes `"password"`) or `incompatible_protocol`, restricts `accepts` to `["password"]` or `[]`, and omits `message`.
|
||||
|
||||
- New fields are `.optional()` with a sensible default.
|
||||
- Never flip optional to required, remove a field, or narrow a type. `string` to `enum` and nullable to non-null are both narrowing.
|
||||
|
||||
@@ -971,6 +971,8 @@ question.
|
||||
you got wrong, rank every highlight again, and then edit the file. Moving only the named item
|
||||
leaves the same mistake in the others.
|
||||
|
||||
Order sections as `Breaking`, `Security`, `Added`, `Improved`, `Changed`, `Plugins`, `Fixed` (omitting empty sections) so `Security` and `Plugins` stay visible above a long `Fixed` list.
|
||||
|
||||
Bullets within each section (Added, Changed, Fixed) follow this order:
|
||||
|
||||
1. **User-facing features and changes first** — things users will notice, want to try, or that change their workflow.
|
||||
|
||||
@@ -97,13 +97,19 @@ Two more reasons the stylesheet route does not work here:
|
||||
- Unistyles owns style conversion on web, so React Native Web's `animationKeyframes` is ignored.
|
||||
- React Native Web's `StyleSheet.create` validation deletes `animationName` in development.
|
||||
|
||||
Indicators that must move together use `phase: "shared"`, which starts the loop at the document
|
||||
timeline's origin instead of at mount. Every ring and every loader is then at the same point of its
|
||||
Indicators that must move together use `phase: "shared"`, which starts the loop at the step
|
||||
grid's origin instead of at mount. Every ring and every loader is then at the same point of its
|
||||
cycle wherever and whenever it mounted. `phase: "own"` starts the loop at the beginning of the
|
||||
current grid step, so its steps still turn over with the shared loops. A stepped animation sets its easing on the keyframes:
|
||||
`step-end` to hold each keyframe until the next, `steps(n)` to cross between two keyframes in `n`
|
||||
even steps. The compositor then draws a frame when a step changes and none in between.
|
||||
|
||||
The grid's origin is 2.5 µs after the document timeline's, not at it. Browsers stamp frames on
|
||||
whole microseconds, and each loop computes a step boundary from its own duration. A boundary that
|
||||
falls exactly on a frame's stamp can then round to before that frame for the ring and after it for
|
||||
the shimmer, so they turn over on consecutive frames. With the origin at 0, every third boundary is
|
||||
a whole millisecond and lands on a stamp. Off by 2.5 µs, no boundary does.
|
||||
|
||||
## Native
|
||||
|
||||
Reanimated commits a cloned shadow tree on the UI thread for every frame a shared value changes.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- Switch providers mid-chat: Switch a chat to another provider and keep the conversation, with chat history now stored on the host.
|
||||
- Queue survives restarts: Queued messages now live on the host, so they survive app reloads, device switches and daemon restarts.
|
||||
- One switch for agent tools: Agent tools now sit behind one Enable tools setting with orchestration, schedules, PR watching and browser groups, and are on by default.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Switch providers mid-chat: Switch a chat to another provider and keep the conversation, with chat history now stored on the host.
|
||||
- Queue survives restarts: Queued messages now live on the host, so they survive app reloads, device switches and daemon restarts.
|
||||
- One switch for agent tools: Agent tools now sit behind one Enable tools setting with orchestration, schedules, PR watching and browser groups, and are on by default.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Switch providers mid-chat: Switch a chat to another provider and keep the conversation, with chat history now stored on the host.
|
||||
- Queue survives restarts: Queued messages now live on the host, so they survive app reloads, device switches and daemon restarts.
|
||||
- One switch for agent tools: Agent tools now sit behind one Enable tools setting with orchestration, schedules, PR watching and browser groups, and are on by default.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Switch providers mid-chat: Switch a chat to another provider and keep the conversation, with chat history now stored on the host.
|
||||
- Queue survives restarts: Queued messages now live on the host, so they survive app reloads, device switches and daemon restarts.
|
||||
- One switch for agent tools: Agent tools now sit behind one Enable tools setting with orchestration, schedules, PR watching and browser groups, and are on by default.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Changed
|
||||
- Changed agent messages and subagent finish notifications to default to steer, falling back to queue on providers that cannot steer mid-turn instead of interrupting the active turn
|
||||
|
||||
Fixed
|
||||
- Fixed direct steer and interrupt prompts clearing queued messages and finish notifications from the queue
|
||||
- Fixed queued message batches being dropped instead of held after transient dispatch errors or run-start timeouts
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Changed
|
||||
- Changed agent messages and subagent finish notifications to default to steer, falling back to queue on providers that cannot steer mid-turn instead of interrupting the active turn
|
||||
|
||||
Fixed
|
||||
- Fixed direct steer and interrupt prompts clearing queued messages and finish notifications from the queue
|
||||
- Fixed queued message batches being dropped instead of held after transient dispatch errors or run-start timeouts
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Changed
|
||||
- Changed agent messages and subagent finish notifications to default to steer, falling back to queue on providers that cannot steer mid-turn instead of interrupting the active turn
|
||||
|
||||
Fixed
|
||||
- Fixed direct steer and interrupt prompts clearing queued messages and finish notifications from the queue
|
||||
- Fixed queued message batches being dropped instead of held after transient dispatch errors or run-start timeouts
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,8 @@
|
||||
Changed
|
||||
- Changed agent messages and subagent finish notifications to default to steer, falling back to queue on providers that cannot steer mid-turn instead of interrupting the active turn
|
||||
|
||||
Fixed
|
||||
- Fixed direct steer and interrupt prompts clearing queued messages and finish notifications from the queue
|
||||
- Fixed queued message batches being dropped instead of held after transient dispatch errors or run-start timeouts
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
+1
-1
@@ -1 +1 @@
|
||||
sha256-oBd6CQ8+BhzMHhrpRIwzojuFPUwqXpgc3ZAPqKPs5QQ=
|
||||
sha256-xt1xi8llKklgr6gn21Ae+Jmdke4bjMZ0F+CnR1bh8UE=
|
||||
|
||||
Generated
+29
-29
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -37552,7 +37552,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -39705,13 +39705,13 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.19.0-beta.1",
|
||||
"@getpaseo/protocol": "0.19.0-beta.1",
|
||||
"@getpaseo/server": "0.19.0-beta.1",
|
||||
"@getpaseo/client": "0.19.1",
|
||||
"@getpaseo/protocol": "0.19.1",
|
||||
"@getpaseo/server": "0.19.1",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -39961,11 +39961,11 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.19.0-beta.1",
|
||||
"@getpaseo/relay": "0.19.0-beta.1",
|
||||
"@getpaseo/protocol": "0.19.1",
|
||||
"@getpaseo/relay": "0.19.1",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
@@ -39977,7 +39977,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/cli": "*",
|
||||
@@ -40221,7 +40221,7 @@
|
||||
},
|
||||
"packages/expo-two-way-audio": {
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -40267,7 +40267,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -40297,7 +40297,7 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^1.4.0",
|
||||
@@ -40305,8 +40305,8 @@
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.19.0-beta.1",
|
||||
"@getpaseo/protocol": "0.19.0-beta.1",
|
||||
"@getpaseo/client": "0.19.1",
|
||||
"@getpaseo/protocol": "0.19.1",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.2.3",
|
||||
@@ -40316,8 +40316,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.19.0-beta.1",
|
||||
"@getpaseo/protocol": "0.19.0-beta.1",
|
||||
"@getpaseo/client": "0.19.1",
|
||||
"@getpaseo/protocol": "0.19.1",
|
||||
"react": ">=19.1.0 <20",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -40339,7 +40339,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
@@ -40366,7 +40366,7 @@
|
||||
}
|
||||
},
|
||||
"packages/react-native-enriched-markdown": {
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
@@ -40382,7 +40382,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^2.4.0",
|
||||
@@ -40604,17 +40604,17 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^0.17.1",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.326",
|
||||
"@anthropic-ai/sdk": "^0.104.2",
|
||||
"@getpaseo/client": "0.19.0-beta.1",
|
||||
"@getpaseo/highlight": "0.19.0-beta.1",
|
||||
"@getpaseo/plugin": "0.19.0-beta.1",
|
||||
"@getpaseo/protocol": "0.19.0-beta.1",
|
||||
"@getpaseo/relay": "0.19.0-beta.1",
|
||||
"@getpaseo/client": "0.19.1",
|
||||
"@getpaseo/highlight": "0.19.1",
|
||||
"@getpaseo/plugin": "0.19.1",
|
||||
"@getpaseo/protocol": "0.19.1",
|
||||
"@getpaseo/relay": "0.19.1",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/node": "2.1.2",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
@@ -41579,7 +41579,7 @@
|
||||
},
|
||||
"packages/website": {
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.29.1",
|
||||
"@cloudflare/workers-types": "^4.20260317.1",
|
||||
@@ -43205,7 +43205,7 @@
|
||||
},
|
||||
"plugins": {
|
||||
"name": "@getpaseo/builtin-plugins",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"dependencies": {
|
||||
"@getpaseo/plugin": "*",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -745,7 +745,8 @@ async function recordDelayedRunningTransition(
|
||||
|
||||
const prompt = "Second prompt keeps streaming.";
|
||||
gate.holdNextAgentStreamEvent("turn_started");
|
||||
gate.holdNextAgentUpdate(agent.agentId, "running");
|
||||
// Hold every running snapshot until release so the prompt-commit emitState does not leak early.
|
||||
gate.holdAgentUpdates(agent.agentId, "running");
|
||||
gate.holdNextServerMessage("send_agent_message_response");
|
||||
gate.setAgentStreamSuppressed(true);
|
||||
await recordTurnFrames(page, prompt);
|
||||
@@ -773,7 +774,7 @@ async function recordDelayedRunningTransition(
|
||||
await expect(page.getByTestId("turn-working-elapsed")).toBeVisible();
|
||||
gate.releaseHeldServerMessage("send_agent_message_response");
|
||||
responseReleased = true;
|
||||
gate.releaseHeldAgentUpdate(agent.agentId, "running");
|
||||
gate.releaseHeldAgentUpdates(agent.agentId, "running");
|
||||
snapshotReleased = true;
|
||||
} else if (releaseOrder === "response-before-turn") {
|
||||
gate.releaseHeldServerMessage("send_agent_message_response");
|
||||
@@ -782,13 +783,13 @@ async function recordDelayedRunningTransition(
|
||||
gate.releaseHeldAgentStreamEvent("turn_started");
|
||||
turnReleased = true;
|
||||
await expect(page.getByTestId("turn-working-elapsed")).toBeVisible();
|
||||
gate.releaseHeldAgentUpdate(agent.agentId, "running");
|
||||
gate.releaseHeldAgentUpdates(agent.agentId, "running");
|
||||
snapshotReleased = true;
|
||||
} else {
|
||||
gate.releaseHeldServerMessage("send_agent_message_response");
|
||||
responseReleased = true;
|
||||
await recordPaintsFor(page, 80);
|
||||
gate.releaseHeldAgentUpdate(agent.agentId, "running");
|
||||
gate.releaseHeldAgentUpdates(agent.agentId, "running");
|
||||
snapshotReleased = true;
|
||||
await expect(page.getByTestId("turn-working-elapsed")).toBeVisible();
|
||||
gate.releaseHeldAgentStreamEvent("turn_started");
|
||||
@@ -804,7 +805,7 @@ async function recordDelayedRunningTransition(
|
||||
return { frames, checkpoints };
|
||||
} finally {
|
||||
if (!turnReleased) gate.releaseHeldAgentStreamEvent("turn_started");
|
||||
if (!snapshotReleased) gate.releaseHeldAgentUpdate(agent.agentId, "running");
|
||||
if (!snapshotReleased) gate.releaseHeldAgentUpdates(agent.agentId, "running");
|
||||
if (!responseReleased) gate.releaseHeldServerMessage("send_agent_message_response");
|
||||
gate.setAgentStreamSuppressed(false);
|
||||
}
|
||||
|
||||
@@ -1370,7 +1370,7 @@ test.describe("Agent message submission", () => {
|
||||
).toHaveCount(0);
|
||||
});
|
||||
|
||||
await test.step("tapping Send still steers and takes the queued row along", async () => {
|
||||
await test.step("tapping Send still steers without sweeping the queued row", async () => {
|
||||
const steeredPrompt = "Steer this turn with a tap.";
|
||||
await fillComposerDraft(page, steeredPrompt);
|
||||
await page.getByRole("button", { name: "Send and steer", exact: true }).click();
|
||||
@@ -1379,13 +1379,13 @@ test.describe("Agent message submission", () => {
|
||||
expect(request.text).toBe(steeredPrompt);
|
||||
expect(request.activeTurnBehavior).toBe("steer");
|
||||
gate.accept(1);
|
||||
await expect(
|
||||
page.getByTestId("user-message").filter({ hasText: steeredPrompt }),
|
||||
).toHaveCount(1);
|
||||
await expect(page.getByRole("button", { name: "Send queued message now" })).toHaveCount(0);
|
||||
const steeredMessage = page.getByTestId("user-message").filter({ hasText: steeredPrompt });
|
||||
await expect(steeredMessage).toHaveCount(1);
|
||||
await expect(steeredMessage).toHaveAttribute("aria-busy", "false");
|
||||
await expect(page.getByRole("button", { name: "Send queued message now" })).toHaveCount(1);
|
||||
await expect(
|
||||
page.getByTestId("user-message").filter({ hasText: queuedPrompt }),
|
||||
).toHaveCount(1);
|
||||
).toHaveCount(0);
|
||||
});
|
||||
} finally {
|
||||
await agent.cleanup();
|
||||
|
||||
@@ -20,6 +20,9 @@ import {
|
||||
readTerminalProcessIds,
|
||||
} from "../support/helpers/daemon-lifecycle";
|
||||
|
||||
// Page setup takes up to 30 s, then a restart can take DAEMON_RESTART_TIMEOUT_MS to confirm.
|
||||
test.describe.configure({ timeout: 120_000 });
|
||||
|
||||
test("settings restart waits for a replacement worker while retaining the supervisor", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
|
||||
@@ -51,16 +51,18 @@ test("lists connected clients with scopes and navigates Pair a device → Relay
|
||||
});
|
||||
try {
|
||||
await openDevicesPage(page, daemon);
|
||||
await expectConnectedClientRow(page, "This device", "Full access");
|
||||
await expandConnectedClientRow(page, "This device");
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("devices-connected-clients-card")
|
||||
.getByText("access.manage", { exact: true }),
|
||||
).toBeVisible();
|
||||
await expectConnectedClientRow(page, /^Chrome on /, "Full access");
|
||||
await expandConnectedClientRow(page, /^Chrome on /);
|
||||
const card = page.getByTestId("devices-connected-clients-card");
|
||||
await expect(card.getByText("IP address", { exact: true })).toBeVisible();
|
||||
await expect(card.getByText("127.0.0.1", { exact: true })).toBeVisible();
|
||||
await expect(card.getByText("access.manage", { exact: true })).toHaveCount(0);
|
||||
|
||||
await viewer.connect();
|
||||
await expectConnectedClientRow(page, "Test Phone", "Read-only");
|
||||
await expandConnectedClientRow(page, "Test Phone");
|
||||
await expect(card.getByText("daemon.read", { exact: true })).toBeVisible();
|
||||
await expect(card.getByText("workspace.read", { exact: true })).toBeVisible();
|
||||
|
||||
await openPairDeviceModal(page);
|
||||
await expectPairingOffer(page);
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { openCommandCenter } from "../support/helpers/command-center";
|
||||
import {
|
||||
openAgentRoute,
|
||||
seedMockAgentWorkspace,
|
||||
type MockAgentWorkspace,
|
||||
} from "../support/helpers/mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
|
||||
const PLUGIN_ID = "agent-chat-focus-e2e";
|
||||
const SCREEN_TITLE = "Embeds";
|
||||
const PHONE = { width: 390, height: 844 };
|
||||
|
||||
interface EmbedComposer {
|
||||
controls?: "all" | "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* A screen with one `AgentChat` per agent under a header of its own, plus a client slash command
|
||||
* that a full composer runs and a `controls: "none"` composer sends as text. A button opens the
|
||||
* first agent's chat in a plugin modal too, and a workspace panel shows the same chats side by side.
|
||||
*/
|
||||
function pluginSource(input: { agentIds: string[]; composer: EmbedComposer }): string {
|
||||
return `import { useCallback } from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { AgentChat, Modal, SidebarRow } from "@getpaseo/plugin/client/ui";
|
||||
import { useState } from "react";
|
||||
|
||||
const AGENT_IDS = ${JSON.stringify(input.agentIds)};
|
||||
const COMPOSER = ${JSON.stringify(input.composer)};
|
||||
|
||||
function Embeds() {
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Text testID="plugin-header" style={{ padding: 8 }}>Embedded agents</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => setModalOpen(true)}>
|
||||
<Text>Open in modal</Text>
|
||||
</Pressable>
|
||||
<Modal title="Agent in a modal" open={modalOpen} onOpenChange={setModalOpen}>
|
||||
<Modal.Content scrollable={false}>
|
||||
<AgentChat agentId={AGENT_IDS[0]} composer={COMPOSER} testID="modal-embed" />
|
||||
</Modal.Content>
|
||||
</Modal>
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
{AGENT_IDS.map((agentId) => (
|
||||
<View key={agentId} style={{ flex: 1, minWidth: 0 }}>
|
||||
<AgentChat agentId={agentId} composer={COMPOSER} testID={"embed-" + agentId} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function Board() {
|
||||
return (
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
{AGENT_IDS.map((agentId) => (
|
||||
<View key={agentId} style={{ flex: 1, minWidth: 0 }}>
|
||||
<AgentChat agentId={agentId} composer={COMPOSER} testID={"panel-embed-" + agentId} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function EmbedsItem({ currentScreen, openScreen }) {
|
||||
const open = useCallback(() => openScreen({ screenId: "main" }), [openScreen]);
|
||||
return <SidebarRow icon="Bot" active={currentScreen?.screenId === "main"} onPress={open} />;
|
||||
}
|
||||
|
||||
export default function contribute(plugin) {
|
||||
plugin.addScreen({ id: "main", title: "${SCREEN_TITLE}", Component: Embeds });
|
||||
plugin.addSidebarHeaderItem({ id: "main", title: "${SCREEN_TITLE}", Component: EmbedsItem });
|
||||
plugin.addWorkspacePanel({ id: "board", title: "Board", icon: "Bot", context: "workspace", Component: Board });
|
||||
plugin.addCommandCenterItem({
|
||||
id: "board",
|
||||
title: "Open embeds board",
|
||||
icon: "Bot",
|
||||
context: "workspace",
|
||||
onSelect({ openPanel }) {
|
||||
openPanel("board");
|
||||
},
|
||||
});
|
||||
plugin.addSlashCommand({
|
||||
name: "stamp",
|
||||
context: "agent",
|
||||
description: "Stamp the agent",
|
||||
argumentHint: "",
|
||||
onSubmit() {},
|
||||
});
|
||||
return () => {};
|
||||
}`;
|
||||
}
|
||||
|
||||
interface Scenario {
|
||||
agents: MockAgentWorkspace[];
|
||||
embed(agentId: string): ReturnType<Page["getByTestId"]>;
|
||||
}
|
||||
|
||||
async function withEmbeds(
|
||||
page: Page,
|
||||
input: { agents: { title: string; model: string; prompt: string }[]; composer: EmbedComposer },
|
||||
run: (scenario: Scenario) => Promise<void>,
|
||||
): Promise<void> {
|
||||
const agents: MockAgentWorkspace[] = [];
|
||||
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
|
||||
const previous = await client.getDaemonConfig();
|
||||
const directory = await mkdtemp(path.join(tmpdir(), "paseo-agent-chat-focus-"));
|
||||
try {
|
||||
for (const agent of input.agents) {
|
||||
agents.push(
|
||||
await seedMockAgentWorkspace({
|
||||
repoPrefix: "agent-chat-focus-",
|
||||
title: agent.title,
|
||||
model: agent.model,
|
||||
initialPrompt: agent.prompt,
|
||||
}),
|
||||
);
|
||||
}
|
||||
await writeFile(
|
||||
path.join(directory, "paseo-plugin.json"),
|
||||
JSON.stringify({ id: PLUGIN_ID, requirements: pluginRequirements }),
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.client.tsx"),
|
||||
pluginSource({ agentIds: agents.map((agent) => agent.agentId), composer: input.composer }),
|
||||
);
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.getByRole("button", { name: SCREEN_TITLE, exact: true }).click();
|
||||
const embed = (agentId: string) => page.getByTestId(`embed-${agentId}`);
|
||||
for (const agent of agents) {
|
||||
await expect(embed(agent.agentId).getByTestId("user-message").first()).toBeVisible({
|
||||
timeout: 30_000,
|
||||
});
|
||||
}
|
||||
await run({ agents, embed });
|
||||
} finally {
|
||||
await client.removePlugin(PLUGIN_ID).catch(() => undefined);
|
||||
await client
|
||||
.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled ?? false })
|
||||
.catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
for (const agent of agents) await agent.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
async function agentStatus(agent: MockAgentWorkspace): Promise<string | null> {
|
||||
const fetched = await agent.client.fetchAgent({ agentId: agent.agentId });
|
||||
return fetched?.agent.status ?? null;
|
||||
}
|
||||
|
||||
/** Clicks land on text, not on a field, so Escape routes as the interrupt shortcut. */
|
||||
async function expectEscapeInterruptsOnlyTheFocusedEmbed(
|
||||
page: Page,
|
||||
input: { left: MockAgentWorkspace; right: MockAgentWorkspace; embed: Scenario["embed"] },
|
||||
): Promise<void> {
|
||||
const { left, right, embed } = input;
|
||||
await test.step("Escape after a click outside the embeds interrupts neither", async () => {
|
||||
await page.getByTestId("plugin-header").click();
|
||||
await page.keyboard.press("Escape");
|
||||
});
|
||||
await test.step("Escape after a click in the left embed interrupts only it", async () => {
|
||||
await embed(left.agentId).getByTestId("user-message").first().click();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect.poll(() => agentStatus(left), { timeout: 15_000 }).toBe("idle");
|
||||
// Interrupts go out in order, so a stray one from the first Escape has landed by now.
|
||||
expect(await agentStatus(right)).toBe("running");
|
||||
});
|
||||
await test.step("Escape after a click in the right embed interrupts it", async () => {
|
||||
await embed(right.agentId).getByTestId("user-message").first().click();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect.poll(() => agentStatus(right), { timeout: 15_000 }).toBe("idle");
|
||||
});
|
||||
}
|
||||
|
||||
test('controls: "none" sends a plugin slash command to the agent as typed', async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [{ title: "Slash agent", model: "e2e-fast-stream", prompt: "Say hello." }],
|
||||
composer: { controls: "none" },
|
||||
},
|
||||
async ({ agents: [agent], embed }) => {
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
const box = embed(agent.agentId).getByRole("textbox", { name: "Message agent..." });
|
||||
await box.fill("/stamp the invoices");
|
||||
await box.press("Enter");
|
||||
await expect(embed(agent.agentId).getByTestId("user-message").last()).toContainText(
|
||||
"/stamp the invoices",
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("Escape interrupts only the embed that has focus", async ({ page }) => {
|
||||
test.setTimeout(240_000);
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [
|
||||
{ title: "Left agent", model: "one-minute-stream", prompt: "Keep running left." },
|
||||
{ title: "Right agent", model: "one-minute-stream", prompt: "Keep running right." },
|
||||
],
|
||||
composer: { controls: "none" },
|
||||
},
|
||||
async ({ agents: [left, right], embed }) => {
|
||||
await expect.poll(() => agentStatus(left), { timeout: 15_000 }).toBe("running");
|
||||
await expect.poll(() => agentStatus(right), { timeout: 15_000 }).toBe("running");
|
||||
|
||||
await expectEscapeInterruptsOnlyTheFocusedEmbed(page, { left, right, embed });
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("a phone-width plugin modal shows an agent's chat", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [{ title: "Modal agent", model: "e2e-fast-stream", prompt: "Say hello." }],
|
||||
composer: { controls: "none" },
|
||||
},
|
||||
async () => {
|
||||
// At phone width the modal is a bottom sheet whose body renders under the app's root
|
||||
// portal host, outside the plugin screen's React tree.
|
||||
await page.setViewportSize(PHONE);
|
||||
await page.getByRole("button", { name: "Open in modal", exact: true }).click();
|
||||
await expect(page.getByText("Agent in a modal", { exact: true })).toBeVisible();
|
||||
const modalEmbed = page.getByTestId("modal-embed");
|
||||
await expect(modalEmbed.getByTestId("user-message").first()).toContainText("Say hello.", {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(modalEmbed.getByRole("textbox", { name: "Message agent..." })).toBeVisible();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
/** Picks the embed's current mode again from its picker, which draws at the overlay root. */
|
||||
async function pickCurrentMode(page: Page, embed: ReturnType<Page["getByTestId"]>): Promise<void> {
|
||||
const trigger = embed.getByRole("button", { name: /^Select agent mode \(/ });
|
||||
const label = /^Select agent mode \((.+)\)$/.exec(
|
||||
(await trigger.getAttribute("aria-label")) ?? "",
|
||||
)?.[1];
|
||||
expect(label).toBeTruthy();
|
||||
await trigger.click();
|
||||
const popup = page.getByTestId("combobox-desktop-container").last();
|
||||
await expect(popup).toBeVisible({ timeout: 10_000 });
|
||||
await popup.getByRole("button", { name: label, exact: true }).click();
|
||||
await expect(page.getByTestId("combobox-desktop-container")).toHaveCount(0);
|
||||
}
|
||||
|
||||
test("a full-composer embed applies a slash suggestion picked with the pointer", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [{ title: "Suggestion agent", model: "e2e-fast-stream", prompt: "Say hello." }],
|
||||
composer: {},
|
||||
},
|
||||
async ({ agents: [agent], embed }) => {
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
const box = embed(agent.agentId).getByRole("textbox", { name: "Message agent..." });
|
||||
await box.click();
|
||||
await box.pressSequentially("/sta");
|
||||
// The list draws in the floating-panel portal, outside the embed's own nodes.
|
||||
const suggestion = page
|
||||
.getByTestId("composer-autocomplete-popover")
|
||||
.getByText("/stamp", { exact: true });
|
||||
await expect(suggestion).toBeVisible({ timeout: 30_000 });
|
||||
await suggestion.click();
|
||||
await expect(box).toHaveValue(/^\/stamp\s*$/);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("a portaled mode picker keeps its embed focused for Escape", async ({ page }) => {
|
||||
test.setTimeout(240_000);
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [
|
||||
{ title: "Left agent", model: "one-minute-stream", prompt: "Keep running left." },
|
||||
{ title: "Right agent", model: "one-minute-stream", prompt: "Keep running right." },
|
||||
],
|
||||
composer: {},
|
||||
},
|
||||
async ({ agents: [left, right], embed }) => {
|
||||
await expect.poll(() => agentStatus(left), { timeout: 15_000 }).toBe("running");
|
||||
await expect.poll(() => agentStatus(right), { timeout: 15_000 }).toBe("running");
|
||||
|
||||
await pickCurrentMode(page, embed(left.agentId));
|
||||
await page.keyboard.press("Escape");
|
||||
await expect.poll(() => agentStatus(left), { timeout: 15_000 }).toBe("idle");
|
||||
expect(await agentStatus(right)).toBe("running");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("embeds in one workspace panel keep their own composers", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await withEmbeds(
|
||||
page,
|
||||
{
|
||||
agents: [
|
||||
{ title: "Left agent", model: "e2e-fast-stream", prompt: "Say hello left." },
|
||||
{ title: "Right agent", model: "e2e-fast-stream", prompt: "Say hello right." },
|
||||
],
|
||||
composer: {},
|
||||
},
|
||||
async ({ agents: [left, right] }) => {
|
||||
await openAgentRoute(page, left);
|
||||
const commands = await openCommandCenter(page);
|
||||
await commands.getByTestId("command-center-input").fill("Open embeds board");
|
||||
await commands.getByRole("button", { name: "Open embeds board", exact: true }).click();
|
||||
const leftEmbed = page.getByTestId(`panel-embed-${left.agentId}`);
|
||||
const rightEmbed = page.getByTestId(`panel-embed-${right.agentId}`);
|
||||
await expect(leftEmbed.getByTestId("user-message").first()).toBeVisible({ timeout: 30_000 });
|
||||
await expect(rightEmbed.getByTestId("user-message").first()).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
// The fullscreen control shows on a phone once the draft runs past two lines.
|
||||
await page.setViewportSize(PHONE);
|
||||
await leftEmbed
|
||||
.getByRole("textbox", { name: "Message agent..." })
|
||||
.fill("First line\nSecond line\nThird line\nFourth line");
|
||||
await leftEmbed.getByRole("button", { name: "Fullscreen", exact: true }).click();
|
||||
await expect(leftEmbed.getByTestId("composer-fullscreen")).toBeVisible();
|
||||
await expect(rightEmbed.getByTestId("composer-fullscreen")).toHaveCount(0);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,120 @@
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
|
||||
const PLUGIN_ID = "agent-chat-example";
|
||||
const AGENT_TITLE = "Billing retries";
|
||||
const FIRST_PROMPT = "Summarize the billing retry failures.";
|
||||
|
||||
function embed(page: Page) {
|
||||
return page.getByTestId("example-agent-chat");
|
||||
}
|
||||
|
||||
async function openAgentInEmbed(page: Page): Promise<void> {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.getByRole("button", { name: "Agents", exact: true }).click();
|
||||
await page
|
||||
.getByTestId("example-agent-list")
|
||||
.getByRole("button", { name: AGENT_TITLE, exact: true })
|
||||
.click();
|
||||
}
|
||||
|
||||
async function sendFromEmbed(page: Page, text: string): Promise<void> {
|
||||
const box = embed(page).getByRole("textbox", { name: "Message agent..." });
|
||||
await box.fill(text);
|
||||
await box.press("Enter");
|
||||
}
|
||||
|
||||
test.describe("AgentChat", () => {
|
||||
test("a plugin screen embeds an agent's chat with the composer it chose", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
const agent = await seedMockAgentWorkspace({
|
||||
repoPrefix: "plugin-agent-chat-",
|
||||
title: AGENT_TITLE,
|
||||
initialPrompt: FIRST_PROMPT,
|
||||
});
|
||||
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
|
||||
const previous = await client.getDaemonConfig();
|
||||
const example = await copyPluginExample("agent-chat");
|
||||
try {
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await openAgentInEmbed(page);
|
||||
|
||||
await test.step("controls: none is a message box and Send", async () => {
|
||||
await expect(embed(page).getByTestId("user-message")).toContainText(FIRST_PROMPT);
|
||||
await expect(embed(page).getByTestId("assistant-message").first()).toBeVisible();
|
||||
await expect(
|
||||
embed(page).getByRole("textbox", { name: "Message agent..." }),
|
||||
).toHaveAttribute("placeholder", "Message this agent");
|
||||
await expect(embed(page).getByTestId("agent-controls-toolbar")).toHaveCount(0);
|
||||
await expect(embed(page).getByTestId("message-input-attach-button")).toHaveCount(0);
|
||||
await expect(embed(page).getByTestId("context-window-meter")).toHaveCount(0);
|
||||
const choices = await page.getByTestId("example-composer-choices").boundingBox();
|
||||
const chat = await embed(page).boundingBox();
|
||||
expect(chat!.y).toBeGreaterThanOrEqual(choices!.y + choices!.height);
|
||||
});
|
||||
|
||||
await test.step("a message sent from the embed streams into it", async () => {
|
||||
await sendFromEmbed(page, "Check the invoice PDFs next.");
|
||||
await expect(embed(page).getByTestId("user-message").last()).toContainText(
|
||||
"Check the invoice PDFs next.",
|
||||
);
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
});
|
||||
|
||||
await test.step("slash text in the simple box reaches the agent as typed", async () => {
|
||||
await sendFromEmbed(page, "/exit");
|
||||
await expect(embed(page).getByTestId("user-message").last()).toContainText("/exit");
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
const fetched = await agent.client.fetchAgent({ agentId: agent.agentId });
|
||||
expect(fetched?.agent.archivedAt ?? null).toBeNull();
|
||||
});
|
||||
|
||||
await test.step("the full composer is the agent tab's", async () => {
|
||||
await page.getByRole("button", { name: "Full", exact: true }).click();
|
||||
await expect(embed(page).getByTestId("agent-controls-toolbar")).toBeVisible();
|
||||
await expect(embed(page).getByTestId("message-input-attach-button")).toBeVisible();
|
||||
await expect(embed(page).getByTestId("context-window-meter")).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step("composer={false} shows the conversation without a composer", async () => {
|
||||
await page.getByRole("button", { name: "No composer", exact: true }).click();
|
||||
await expect(embed(page).getByTestId("user-message").first()).toContainText(FIRST_PROMPT);
|
||||
await expect(embed(page).getByRole("textbox", { name: "Message agent..." })).toHaveCount(0);
|
||||
});
|
||||
|
||||
await test.step("the agent's tab and the embed stay live together", async () => {
|
||||
await page.getByRole("button", { name: "Simple", exact: true }).click();
|
||||
const tab = await context.newPage();
|
||||
await openAgentRoute(tab, { workspaceId: agent.workspaceId, agentId: agent.agentId });
|
||||
const tabBox = tab.getByRole("textbox", { name: "Message agent..." }).first();
|
||||
await tabBox.fill("Sent from the tab.");
|
||||
await tabBox.press("Enter");
|
||||
await expect(embed(page).getByTestId("user-message").last()).toContainText(
|
||||
"Sent from the tab.",
|
||||
);
|
||||
await sendFromEmbed(page, "Sent from the embed.");
|
||||
await expect(tab.getByTestId("user-message").last()).toContainText("Sent from the embed.");
|
||||
await tab.close();
|
||||
});
|
||||
} finally {
|
||||
await client.removePlugin(PLUGIN_ID).catch(() => undefined);
|
||||
await client
|
||||
.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled ?? false })
|
||||
.catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
await example.cleanup();
|
||||
await agent.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,350 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { openCommandCenter } from "../support/helpers/command-center";
|
||||
import { buildAgentRoute } from "../support/helpers/mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
|
||||
const PLUGIN_ID = "composer-pill-items-e2e";
|
||||
const WIDE = { width: 1440, height: 900 };
|
||||
const COMPACT = { width: 390, height: 844 };
|
||||
|
||||
function pluginSource(workspaceId: string, agentId: string): string {
|
||||
return `import React from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { useWorkspace } from "@getpaseo/plugin/client";
|
||||
import { ComposerPill } from "@getpaseo/plugin/client/ui";
|
||||
|
||||
function InboxScreen({ theme, params }) {
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 24, gap: 8 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>Inbox screen for {params.agentId}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function InboxPopover({ theme, layout, close, openScreen }) {
|
||||
const workspaceName = useWorkspace(${JSON.stringify(workspaceId)}, (w) => w.name);
|
||||
return (
|
||||
<View style={{ gap: 10 }}>
|
||||
<Text style={{ color: theme.colors.foreground, fontSize: 16 }}>Inbox decisions</Text>
|
||||
<Text style={{ color: theme.colors.foregroundMuted }}>Workspace: {workspaceName}</Text>
|
||||
<Text style={{ color: theme.colors.foregroundMuted }}>
|
||||
Presentation: {layout.compact ? "compact" : "wide"}
|
||||
</Text>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Open inbox screen"
|
||||
onPress={() => openScreen({ screenId: "inbox", params: { agentId: ${JSON.stringify(agentId)} } })}
|
||||
>
|
||||
<Text style={{ color: theme.colors.foreground }}>Open screen</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Close inbox popover"
|
||||
onPress={close}
|
||||
>
|
||||
<Text style={{ color: theme.colors.foreground }}>Done</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function LivePopover({ theme, close }) {
|
||||
return (
|
||||
<View style={{ gap: 8 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>Live popover content</Text>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Trigger live update"
|
||||
onPress={() => updateLivePopover?.()}
|
||||
>
|
||||
<Text style={{ color: theme.colors.foreground }}>Update</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel="Close live popover"
|
||||
onPress={close}
|
||||
>
|
||||
<Text style={{ color: theme.colors.foreground }}>Close</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
let updateLivePopover = null;
|
||||
|
||||
function QuietPill({ workspaceId }) {
|
||||
const name = useWorkspace(workspaceId, (w) => w.name);
|
||||
if (name !== "Show quiet pill") return null;
|
||||
return <ComposerPill icon="Sparkles" label="Quiet" onPress={() => {}} />;
|
||||
}
|
||||
|
||||
let finishAction = () => {};
|
||||
let actionAttempts = 0;
|
||||
|
||||
function ActionPill() {
|
||||
const [checks, setChecks] = React.useState(0);
|
||||
return (
|
||||
<ComposerPill
|
||||
icon="Play"
|
||||
label={checks === 0 ? "Run check" : "Checks · " + checks}
|
||||
title="Run check action"
|
||||
onPress={async () => {
|
||||
actionAttempts += 1;
|
||||
if (actionAttempts === 1) throw new Error("Action check failed");
|
||||
await new Promise((resolve) => {
|
||||
finishAction = resolve;
|
||||
});
|
||||
setChecks((n) => n + 1);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function InboxPill({ openPopover }) {
|
||||
return (
|
||||
<ComposerPill
|
||||
icon="Inbox"
|
||||
label="2 decisions"
|
||||
onPress={() => openPopover(InboxPopover)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default function contribute(client) {
|
||||
const workspaceId = ${JSON.stringify(workspaceId)};
|
||||
const agentId = ${JSON.stringify(agentId)};
|
||||
client.addScreen({ id: "inbox", title: "Inbox Screen", Component: InboxScreen });
|
||||
const removeQuiet = client.addComposerPillItem({ id: "quiet", title: "Quiet", Component: QuietPill });
|
||||
const removeAction = client.addComposerPillItem({ id: "action", title: "Run check", Component: ActionPill });
|
||||
const removeInbox = client.addComposerPillItem({ id: "inbox", title: "Inbox decisions", Component: InboxPill });
|
||||
|
||||
const live = client.addComposerPill({
|
||||
id: "live-popover",
|
||||
workspaceId,
|
||||
agentId,
|
||||
button: {
|
||||
title: "Live popover",
|
||||
icon: "Eye",
|
||||
label: "Live",
|
||||
behavior: { kind: "popover", Content: LivePopover },
|
||||
},
|
||||
});
|
||||
|
||||
const dynamicMenu = client.addComposerPill({
|
||||
id: "dynamic-menu",
|
||||
workspaceId,
|
||||
agentId,
|
||||
button: {
|
||||
title: "Dynamic menu",
|
||||
icon: "List",
|
||||
label: "Decisions",
|
||||
behavior: {
|
||||
kind: "menu",
|
||||
items: [
|
||||
{
|
||||
kind: "item",
|
||||
id: "D42",
|
||||
title: "Decision D42",
|
||||
behavior: {
|
||||
kind: "action",
|
||||
onPress() {
|
||||
dynamicMenu.update({ label: "Picked D42" });
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
client.addCommandCenterItem({
|
||||
id: "finish-check",
|
||||
title: "Finish check action",
|
||||
icon: "Check",
|
||||
context: "workspace",
|
||||
onSelect: () => finishAction(),
|
||||
});
|
||||
updateLivePopover = () =>
|
||||
live.update({
|
||||
label: "Live · 2",
|
||||
behavior: { kind: "popover", Content: LivePopover },
|
||||
});
|
||||
|
||||
return () => {
|
||||
finishAction();
|
||||
removeQuiet();
|
||||
removeAction();
|
||||
removeInbox();
|
||||
live.remove();
|
||||
dynamicMenu.remove();
|
||||
};
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
async function runCommand(page: Page, title: string) {
|
||||
const panel = await openCommandCenter(page);
|
||||
await panel.getByTestId("command-center-input").fill(title);
|
||||
await panel.getByRole("button", { name: title, exact: true }).click();
|
||||
await expect(panel).not.toBeVisible();
|
||||
}
|
||||
|
||||
async function expectStill(subject: Locator) {
|
||||
let previous: Buffer | null = null;
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const current = await subject.screenshot();
|
||||
const still = previous !== null && current.equals(previous);
|
||||
previous = current;
|
||||
return still;
|
||||
},
|
||||
{ intervals: [150] },
|
||||
)
|
||||
.toBe(true);
|
||||
}
|
||||
|
||||
async function qaScreenshot(page: Page, name: string) {
|
||||
const directory = process.env.PASEO_QA_SCREENSHOT_DIR;
|
||||
if (!directory) return;
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({ path: path.join(directory, `${name}.png`) });
|
||||
}
|
||||
|
||||
test("declarative addComposerPillItem + ComposerPill and imperative pill fixes work end-to-end", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(180_000);
|
||||
const workspace = await seedWorkspace({ repoPrefix: "composer-pill-items-" });
|
||||
const agent = await workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.repoPath,
|
||||
workspaceId: workspace.workspaceId,
|
||||
title: "Declarative composer pills",
|
||||
model: "e2e-fast-stream",
|
||||
modeId: "load-test",
|
||||
});
|
||||
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
|
||||
const config = await client.getDaemonConfig();
|
||||
const directory = await mkdtemp(path.join(tmpdir(), "paseo-pill-items-"));
|
||||
try {
|
||||
await writeFile(
|
||||
path.join(directory, "paseo-plugin.json"),
|
||||
JSON.stringify({ id: PLUGIN_ID, requirements: pluginRequirements }),
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.client.tsx"),
|
||||
pluginSource(workspace.workspaceId, agent.id),
|
||||
);
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.goto(buildAgentRoute(workspace.workspaceId, agent.id));
|
||||
|
||||
const actionPill = page.getByRole("button", { name: "Run check action", exact: true });
|
||||
const inboxPill = page.getByRole("button", { name: "2 decisions", exact: true });
|
||||
await expect(actionPill).toBeVisible();
|
||||
await expect(inboxPill).toBeVisible();
|
||||
|
||||
await test.step("null items leave no empty gap in the composer track", async () => {
|
||||
await expect(page.getByRole("button", { name: "Quiet", exact: true })).toHaveCount(0);
|
||||
const actionBox = (await actionPill.boundingBox())!;
|
||||
const inboxBox = (await inboxPill.boundingBox())!;
|
||||
expect(Math.abs(actionBox.y - inboxBox.y)).toBeLessThan(2);
|
||||
expect(actionBox.height).toBeGreaterThanOrEqual(32);
|
||||
expect(inboxBox.height).toBeGreaterThanOrEqual(32);
|
||||
// 4px track gap between adjacent pills with no empty wrapper gap in between.
|
||||
expect(inboxBox.x - (actionBox.x + actionBox.width)).toBeLessThanOrEqual(8);
|
||||
await qaScreenshot(page, "01-desktop-track");
|
||||
});
|
||||
|
||||
await test.step("ComposerPill shows error toast on rejection, enters pending busy state, and recovers", async () => {
|
||||
await actionPill.click();
|
||||
await expect(page.getByText("Action check failed", { exact: true })).toBeVisible();
|
||||
await expect(actionPill).toBeEnabled();
|
||||
|
||||
await actionPill.click();
|
||||
await expect(actionPill).toBeDisabled();
|
||||
await expect(actionPill).toHaveAttribute("aria-busy", "true");
|
||||
await qaScreenshot(page, "02-desktop-pill-pending");
|
||||
|
||||
await runCommand(page, "Finish check action");
|
||||
await expect(actionPill).toBeEnabled();
|
||||
await expect(actionPill).toContainText("Checks · 1");
|
||||
});
|
||||
|
||||
await test.step("openPopover anchors above the pill on desktop, dismisses cleanly, and openScreen navigates", async () => {
|
||||
await inboxPill.click();
|
||||
const popoverTitle = page.getByText("Inbox decisions", { exact: true });
|
||||
await expect(popoverTitle).toBeInViewport();
|
||||
await expect(page.getByText("Presentation: wide", { exact: true })).toBeVisible();
|
||||
await expectStill(popoverTitle);
|
||||
|
||||
const pillBox = (await inboxPill.boundingBox())!;
|
||||
const popoverBox = (await page
|
||||
.getByTestId(`plugin-composer-pill-${PLUGIN_ID}-inbox-popover`)
|
||||
.boundingBox())!;
|
||||
expect(popoverBox.y + popoverBox.height).toBeLessThanOrEqual(pillBox.y + 1);
|
||||
expect(Math.abs(popoverBox.x - pillBox.x)).toBeLessThan(80);
|
||||
await qaScreenshot(page, "03-desktop-popover");
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popoverTitle).toHaveCount(0);
|
||||
|
||||
await inboxPill.click();
|
||||
await expect(popoverTitle).toBeVisible();
|
||||
await page.getByRole("button", { name: "Open inbox screen", exact: true }).click();
|
||||
await expect(popoverTitle).toHaveCount(0);
|
||||
await expect(page.getByText(`Inbox screen for ${agent.id}`, { exact: true })).toBeVisible();
|
||||
await page.getByTestId("plugin-surface-close").click();
|
||||
await expect(inboxPill).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step("imperative PluginButtonStore fixes: same-Content popover stays open on update and dynamic menu IDs work", async () => {
|
||||
const livePill = page.getByRole("button", { name: "Live popover", exact: true });
|
||||
await livePill.click();
|
||||
await expect(page.getByText("Live popover content", { exact: true })).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Trigger live update", exact: true }).click();
|
||||
await expect(livePill).toContainText("Live · 2");
|
||||
await expect(page.getByText("Live popover content", { exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Close live popover", exact: true }).click();
|
||||
await expect(page.getByText("Live popover content", { exact: true })).toHaveCount(0);
|
||||
|
||||
const menuPill = page.getByRole("button", { name: "Dynamic menu", exact: true });
|
||||
await menuPill.click();
|
||||
await page.getByRole("menuitem", { name: "Decision D42", exact: true }).click();
|
||||
await expect(menuPill).toContainText("Picked D42");
|
||||
});
|
||||
|
||||
await test.step("on compact layouts openPopover renders a bottom sheet and dismisses cleanly", async () => {
|
||||
await page.setViewportSize(COMPACT);
|
||||
await expect(inboxPill).toBeVisible();
|
||||
await inboxPill.click();
|
||||
const compactLabel = page.getByText("Presentation: compact", { exact: true });
|
||||
await expect(compactLabel).toBeInViewport();
|
||||
const sheetBox = (await compactLabel.boundingBox())!;
|
||||
expect(sheetBox.y).toBeGreaterThan(COMPACT.height / 2);
|
||||
await qaScreenshot(page, "04-compact-sheet");
|
||||
await page.getByRole("button", { name: "Close inbox popover", exact: true }).click();
|
||||
await expect(compactLabel).toHaveCount(0);
|
||||
});
|
||||
} finally {
|
||||
await client.removePlugin(PLUGIN_ID).catch(() => undefined);
|
||||
await client.patchDaemonConfig({ pluginsEnabled: config.config.pluginsEnabled });
|
||||
await client.close();
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
@@ -27,7 +27,10 @@ import {
|
||||
} from "@getpaseo/plugin/client";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { DocumentFrame, Loading } from "@getpaseo/plugin/client/ui";
|
||||
function Pdf({ file, workspaceId }) {
|
||||
function FileDetailsScreen({ params }) {
|
||||
return <View><Text>File screen: {params.file}</Text></View>;
|
||||
}
|
||||
function Pdf({ file, workspaceId, openScreen }) {
|
||||
usePaseo();
|
||||
useQueryClient();
|
||||
const workspace = useWorkspace(workspaceId, value => ({ id: value.id }));
|
||||
@@ -44,6 +47,9 @@ function Pdf({ file, workspaceId }) {
|
||||
<Text>Path {file.path}</Text>
|
||||
<Text>Bytes {bytes.bytes.length}; URL bytes {urlBytes}</Text>
|
||||
<Text>Workspace {workspace?.id}</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => openScreen({ screenId: "details", params: { file: file.name } })}>
|
||||
<Text>Open screen from file panel</Text>
|
||||
</Pressable>
|
||||
<DocumentFrame url={href} testID="plugin-pdf-frame" />
|
||||
</View>;
|
||||
}
|
||||
@@ -69,6 +75,7 @@ function Markdown({ file, tab }) {
|
||||
</View>;
|
||||
}
|
||||
export default function contribute(client) {
|
||||
client.addScreen({ id: "details", title: "File details", Component: FileDetailsScreen });
|
||||
client.addFilePanel({ id: "pdf", title: "PDF", icon: "FileText",
|
||||
files: { extensions: ["pdf", "txt"] }, Component: Pdf });
|
||||
client.addFilePanel({ id: "markdown", title: "Plugin Markdown", icon: "FileText",
|
||||
@@ -92,6 +99,16 @@ async function associateMarkdownWithPlugin(page: Page) {
|
||||
async function editMarkdownThroughPlugin(page: Page) {
|
||||
await page.getByRole("button", { name: "Edit Markdown through plugin", exact: true }).click();
|
||||
}
|
||||
async function openFileDetailsScreenFromPanel(page: Page, name: string) {
|
||||
await page.getByRole("button", { name: "Open screen from file panel", exact: true }).click();
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(`/plugin/${PLUGIN_ID}/surface/details\\?param\\.file=${encodeURIComponent(name)}$`),
|
||||
);
|
||||
await expect(page.getByText(`File screen: ${name}`, { exact: true })).toBeVisible();
|
||||
await page.getByTestId("plugin-surface-close").click();
|
||||
await expect(page.getByText(`PDF plugin: ${name}`, { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
/** Opens the tab with Paseo's Markdown panel from "Open with…" and shows its Source view. */
|
||||
async function openBuiltinMarkdownSource(page: Page, name: string) {
|
||||
await page.getByTestId(`workspace-tab-file_${name}`).first().click({ button: "right" });
|
||||
@@ -152,6 +169,7 @@ test("directory plugins render PDF bytes and write Markdown through the file han
|
||||
const pdfScreenshot = testInfo.outputPath("plugin-pdf-web.png");
|
||||
await page.screenshot({ path: pdfScreenshot });
|
||||
await testInfo.attach("plugin-pdf-web", { path: pdfScreenshot, contentType: "image/png" });
|
||||
await openFileDetailsScreenFromPanel(page, "report.pdf");
|
||||
|
||||
// A plugin panel claiming a text file competes with Source, so Paseo asks over the plugin.
|
||||
await openWorkspaceFile(page, "bytes.txt");
|
||||
|
||||
@@ -690,16 +690,20 @@ async function updateGitPlugin(page: Page, repository: string) {
|
||||
async function failUpdateFromPluginPage(page: Page, repository: string) {
|
||||
await publishGitPluginChange(repository, "Git plugin v3");
|
||||
await page.reload();
|
||||
const update = page.getByTestId("plugin-update").filter({ visible: true });
|
||||
await expect(update).toHaveText("Update");
|
||||
// Rewriting the commit the page checked leaves its update pointing at a commit the remote no
|
||||
// longer serves. The next check offers the rewritten commit.
|
||||
const update = page.getByRole("button", { name: "Update", exact: true });
|
||||
await expect(update).toBeVisible();
|
||||
// Remove the advertised commit from the fixture. A file:// remote can still serve an
|
||||
// amended-away commit by SHA while its object remains in the repository.
|
||||
execFileSync("git", ["commit", "--amend", "-m", "Git plugin v3, amended"], {
|
||||
cwd: repository,
|
||||
stdio: "ignore",
|
||||
});
|
||||
execFileSync("git", ["-c", "gc.reflogExpireUnreachable=now", "gc", "--prune=now"], {
|
||||
cwd: repository,
|
||||
stdio: "ignore",
|
||||
});
|
||||
await update.click();
|
||||
await expect(update).toHaveText("Retry");
|
||||
await expect(page.getByRole("button", { name: "Retry", exact: true })).toBeVisible();
|
||||
await expect(page.getByText(/Git command failed/)).toBeVisible();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import type { Locator, TestInfo } from "@playwright/test";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { openCommandCenter } from "../support/helpers/command-center";
|
||||
import { openFileExplorer, openFileFromExplorer } from "../support/helpers/file-explorer";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
|
||||
const PLUGIN_ID = "tab-set-title-e2e";
|
||||
const WIDE = { width: 1440, height: 900 };
|
||||
|
||||
const CLIENT_SOURCE = `import React from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import type {
|
||||
PluginAgentPanelProps,
|
||||
PluginClientContext,
|
||||
PluginFilePanelProps,
|
||||
PluginWorkspacePanelProps,
|
||||
} from "@getpaseo/plugin/client";
|
||||
|
||||
function TitleControls({
|
||||
prefix,
|
||||
nextTitle,
|
||||
tab,
|
||||
}: {
|
||||
prefix: string;
|
||||
nextTitle: string;
|
||||
tab: PluginWorkspacePanelProps["tab"];
|
||||
}) {
|
||||
return (
|
||||
<View style={{ padding: 16, gap: 8 }}>
|
||||
<Text>{prefix} panel</Text>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => tab.setTitle(" " + nextTitle + " ")}
|
||||
>
|
||||
<Text>Set {prefix} title</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => tab.setTitle(" ")}
|
||||
>
|
||||
<Text>Whitespace {prefix} title</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => tab.setTitle(null)}
|
||||
>
|
||||
<Text>Reset {prefix} title</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusPanel({ tab }: PluginWorkspacePanelProps) {
|
||||
return <TitleControls prefix="status" nextTitle="Status (3)" tab={tab} />;
|
||||
}
|
||||
|
||||
function ExplorerStatusPanel({ tab }: PluginWorkspacePanelProps) {
|
||||
return <TitleControls prefix="explorer" nextTitle="Explorer (7)" tab={tab} />;
|
||||
}
|
||||
|
||||
function InspectorPanel({ tab }: PluginAgentPanelProps) {
|
||||
return <TitleControls prefix="agent" nextTitle="Inspector: live" tab={tab} />;
|
||||
}
|
||||
|
||||
function NotesTxtPanel({ tab }: PluginFilePanelProps) {
|
||||
return <TitleControls prefix="file" nextTitle="Readout" tab={tab} />;
|
||||
}
|
||||
|
||||
export default function contribute(client: PluginClientContext) {
|
||||
client.addWorkspacePanel({
|
||||
id: "status",
|
||||
title: "Status",
|
||||
icon: "PanelsTopLeft",
|
||||
locations: ["workspace", "explorer"],
|
||||
Component: StatusPanel,
|
||||
});
|
||||
client.addWorkspacePanel({
|
||||
id: "explorer-status",
|
||||
title: "Explorer status",
|
||||
icon: "PanelsTopLeft",
|
||||
locations: ["workspace", "explorer"],
|
||||
Component: ExplorerStatusPanel,
|
||||
});
|
||||
client.addAgentPanel({
|
||||
id: "inspector",
|
||||
title: "Inspector",
|
||||
icon: "Scan",
|
||||
locations: ["workspace", "explorer"],
|
||||
Component: InspectorPanel,
|
||||
});
|
||||
client.addFilePanel({
|
||||
id: "txt-viewer",
|
||||
title: "Custom TXT",
|
||||
icon: "FileText",
|
||||
files: { extensions: ["txt"] },
|
||||
Component: NotesTxtPanel,
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-status",
|
||||
title: "Open status panel",
|
||||
icon: "PanelsTopLeft",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "status" });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-explorer-status",
|
||||
title: "Open explorer status panel",
|
||||
icon: "PanelsTopLeft",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "explorer-status" }, { placement: { type: "explorer" } });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-inspector",
|
||||
title: "Open inspector panel",
|
||||
icon: "Scan",
|
||||
context: "agent",
|
||||
onSelect({ workspaceLayout, agent }) {
|
||||
workspaceLayout.open({ panelId: "inspector", params: { agentId: agent.id } });
|
||||
},
|
||||
});
|
||||
return () => {};
|
||||
}
|
||||
`;
|
||||
|
||||
async function runCommand(page: Page, title: string): Promise<void> {
|
||||
const panel = await openCommandCenter(page);
|
||||
await panel.getByTestId("command-center-input").fill(title);
|
||||
await panel.getByRole("button", { name: title, exact: true }).click();
|
||||
await expect(panel).not.toBeVisible();
|
||||
}
|
||||
|
||||
function mainPane(page: Page): Locator {
|
||||
return page.locator('[data-testid^="workspace-pane-"]').filter({ visible: true }).first();
|
||||
}
|
||||
|
||||
function explorer(page: Page): Locator {
|
||||
return page.getByTestId("workspace-explorer-sidebar");
|
||||
}
|
||||
|
||||
function tabChip(scope: Locator, idPart: string): Locator {
|
||||
return scope
|
||||
.locator(
|
||||
`[data-testid^="workspace-tab-"][data-testid*="${idPart}"]:not([data-testid^="workspace-tab-tooltip"]):not([data-testid^="workspace-tab-modified"])`,
|
||||
)
|
||||
.first();
|
||||
}
|
||||
|
||||
async function capture(page: Page, testInfo: TestInfo, name: string): Promise<void> {
|
||||
const screenshot = testInfo.outputPath(`${name}.png`);
|
||||
await page.screenshot({ path: screenshot });
|
||||
await testInfo.attach(name, { path: screenshot, contentType: "image/png" });
|
||||
}
|
||||
|
||||
test("PluginTab.setTitle updates and resets tab labels in main pane, Explorer, agent, and file panels", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
test.setTimeout(180_000);
|
||||
const directory = await mkdtemp(path.join(tmpdir(), "paseo-plugin-tab-set-title-"));
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix: "plugin-tab-set-title-",
|
||||
title: "Tab Title Agent",
|
||||
repo: {
|
||||
files: [{ path: "notes.txt", content: "Sample notes\n" }],
|
||||
},
|
||||
});
|
||||
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
|
||||
const previousConfig = await client.getDaemonConfig();
|
||||
|
||||
await writeFile(
|
||||
path.join(directory, "paseo-plugin.json"),
|
||||
JSON.stringify({ id: PLUGIN_ID, requirements: pluginRequirements }),
|
||||
);
|
||||
await writeFile(path.join(directory, "index.client.tsx"), CLIENT_SOURCE);
|
||||
|
||||
try {
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await openAgentRoute(page, {
|
||||
workspaceId: workspace.workspaceId,
|
||||
agentId: workspace.agentId,
|
||||
});
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
|
||||
await test.step("main pane workspace panel sets, trims, clears, and resets title + tooltip", async () => {
|
||||
await runCommand(page, "Open status panel");
|
||||
const tab = tabChip(mainPane(page), "_status");
|
||||
await expect(tab).toContainText("Status");
|
||||
await expect(tab).toHaveAttribute("aria-label", "Status");
|
||||
|
||||
await page.getByRole("button", { name: "Set status title", exact: true }).click();
|
||||
await expect(tab).toContainText("Status (3)");
|
||||
await expect(tab).toHaveAttribute("aria-label", "Status (3)");
|
||||
await expect.poll(() => page.title()).toBe("Status (3)");
|
||||
await tab.hover();
|
||||
await expect(page.getByText("Status (3)").last()).toBeVisible();
|
||||
await capture(page, testInfo, "main-pane-title-override");
|
||||
|
||||
await page.getByRole("button", { name: "Whitespace status title", exact: true }).click();
|
||||
await expect(tab).toContainText("Status");
|
||||
await expect(tab).toHaveAttribute("aria-label", "Status");
|
||||
|
||||
await page.getByRole("button", { name: "Set status title", exact: true }).click();
|
||||
await expect(tab).toContainText("Status (3)");
|
||||
|
||||
await page.getByRole("button", { name: "Reset status title", exact: true }).click();
|
||||
await expect(tab).toContainText("Status");
|
||||
await expect.poll(() => page.title()).toBe("Status");
|
||||
});
|
||||
|
||||
await test.step("Explorer workspace panel sets and resets title", async () => {
|
||||
await runCommand(page, "Open explorer status panel");
|
||||
const explorerTab = tabChip(explorer(page), "explorer-status");
|
||||
await expect(explorerTab).toContainText("Explorer status");
|
||||
await expect(explorerTab).toHaveAttribute("aria-label", "Explorer status");
|
||||
|
||||
await page.getByRole("button", { name: "Set explorer title", exact: true }).click();
|
||||
await expect(explorerTab).toContainText("Explorer (7)");
|
||||
await expect(explorerTab).toHaveAttribute("aria-label", "Explorer (7)");
|
||||
await capture(page, testInfo, "explorer-title-override");
|
||||
|
||||
await page.getByRole("button", { name: "Reset explorer title", exact: true }).click();
|
||||
await expect(explorerTab).toContainText("Explorer status");
|
||||
await expect(explorerTab).toHaveAttribute("aria-label", "Explorer status");
|
||||
});
|
||||
|
||||
await test.step("agent panel sets and resets title", async () => {
|
||||
await mainPane(page).getByTestId(`workspace-tab-agent_${workspace.agentId}`).click();
|
||||
await runCommand(page, "Open inspector panel");
|
||||
const agentTab = tabChip(mainPane(page), "inspector");
|
||||
await expect(agentTab).toContainText("Inspector");
|
||||
|
||||
await page.getByRole("button", { name: "Set agent title", exact: true }).click();
|
||||
await expect(agentTab).toContainText("Inspector: live");
|
||||
|
||||
await page.getByRole("button", { name: "Reset agent title", exact: true }).click();
|
||||
await expect(agentTab).toContainText("Inspector");
|
||||
});
|
||||
|
||||
await test.step("file panel sets and resets title", async () => {
|
||||
await openFileExplorer(page);
|
||||
await openFileFromExplorer(page, "notes.txt");
|
||||
await expect(page.getByText("Open .txt files with", { exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByText("Open .txt files with", { exact: true })).toBeHidden();
|
||||
|
||||
const fileTab = mainPane(page).getByTestId("workspace-tab-file_notes.txt");
|
||||
await expect(fileTab).toContainText("notes.txt");
|
||||
|
||||
await page.getByRole("button", { name: "Set file title", exact: true }).click();
|
||||
await expect(fileTab).toContainText("Readout");
|
||||
await expect(fileTab).toHaveAttribute("aria-label", "Readout");
|
||||
|
||||
await page.getByRole("button", { name: "Reset file title", exact: true }).click();
|
||||
await expect(fileTab).toContainText("notes.txt");
|
||||
await expect(fileTab).toHaveAttribute("aria-label", "notes.txt");
|
||||
});
|
||||
|
||||
await test.step("removing the plugin clears active title override to Plugin unavailable", async () => {
|
||||
await tabChip(mainPane(page), "_status").click();
|
||||
await page.getByRole("button", { name: "Set status title", exact: true }).click();
|
||||
const tab = tabChip(mainPane(page), "_status");
|
||||
await expect(tab).toContainText("Status (3)");
|
||||
|
||||
await client.removePlugin(PLUGIN_ID);
|
||||
await expect(tab).toContainText("Plugin unavailable", { timeout: 30_000 });
|
||||
await expect(tab).toHaveAttribute("aria-label", "This plugin panel is unavailable");
|
||||
});
|
||||
} finally {
|
||||
await client.removePlugin(PLUGIN_ID).catch(() => undefined);
|
||||
await client
|
||||
.patchDaemonConfig({ pluginsEnabled: previousConfig.config.pluginsEnabled ?? false })
|
||||
.catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
await workspace.cleanup().catch(() => undefined);
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
@@ -326,3 +326,286 @@ test("a file a plugin opens in another workspace waits there on a phone", async
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const PARAMS_AND_IDENTITY_ENTRY = `import {
|
||||
type PluginClientContext,
|
||||
type PluginWorkspacePanelProps,
|
||||
useTabState,
|
||||
useWorkspaceLayout,
|
||||
} from "@getpaseo/plugin/client";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { z } from "zod";
|
||||
|
||||
const decisionParams = z.object({ decisionId: z.string() });
|
||||
const decisionStateSchema = z.object({ note: z.string() });
|
||||
|
||||
function DecisionsPanel({
|
||||
params,
|
||||
revision,
|
||||
tab,
|
||||
theme,
|
||||
}: PluginWorkspacePanelProps<z.infer<typeof decisionParams>>) {
|
||||
const [state, setState] = useTabState(tab, decisionStateSchema, { note: "initial" });
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 16, gap: 8 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>
|
||||
{\`decision:\${params.decisionId}|rev:\${revision}|state:\${state.note}\`}
|
||||
</Text>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
onPress={() => setState({ note: "pinned" })}
|
||||
>
|
||||
<Text style={{ color: theme.colors.foreground }}>Pin decision state</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const prParams = z.object({
|
||||
prNumber: z.number(),
|
||||
commentId: z.string().optional(),
|
||||
});
|
||||
|
||||
function PrPanel({
|
||||
workspaceId,
|
||||
params,
|
||||
revision,
|
||||
theme,
|
||||
}: PluginWorkspacePanelProps<z.infer<typeof prParams>>) {
|
||||
const readBack = useWorkspaceLayout(workspaceId, (layout) => {
|
||||
const found = layout.tabs.find((entry) => entry.panelId === "workspace-layout/pr" && entry.params.prNumber === params.prNumber);
|
||||
return found ? JSON.stringify(found.params) : "missing";
|
||||
});
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 16, gap: 8 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>
|
||||
{\`pr:\${params.prNumber}|comment:\${params.commentId ?? "none"}|rev:\${revision}\`}
|
||||
</Text>
|
||||
<Text style={{ color: theme.colors.foregroundMuted }}>
|
||||
{\`readback:\${params.prNumber}:\${readBack}\`}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function StaticPanel({ theme }: PluginWorkspacePanelProps) {
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 16 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>Static parameterless panel</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default function contribute(client: PluginClientContext) {
|
||||
client.addWorkspacePanel({
|
||||
id: "decisions",
|
||||
title: "Decisions",
|
||||
icon: "ListChecks",
|
||||
locations: ["explorer"],
|
||||
params: decisionParams,
|
||||
Component: DecisionsPanel,
|
||||
});
|
||||
client.addWorkspacePanel({
|
||||
id: "pr",
|
||||
title: "PR",
|
||||
icon: "GitPullRequest",
|
||||
params: prParams,
|
||||
identity: (p) => String(p.prNumber),
|
||||
Component: PrPanel,
|
||||
});
|
||||
client.addWorkspacePanel({
|
||||
id: "static",
|
||||
title: "Static",
|
||||
icon: "Square",
|
||||
locations: ["workspace", "explorer"],
|
||||
Component: StaticPanel,
|
||||
});
|
||||
|
||||
client.addCommandCenterItem({
|
||||
id: "open-decision-d1",
|
||||
title: "Open decision D1",
|
||||
icon: "ListChecks",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "decisions", params: { decisionId: "D1" } });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-decision-d2",
|
||||
title: "Open decision D2",
|
||||
icon: "ListChecks",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "decisions", params: { decisionId: "D2" } });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-pr-1a",
|
||||
title: "Open PR 1 comment a",
|
||||
icon: "GitPullRequest",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "pr", params: { prNumber: 1, commentId: "a" } });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-pr-2x",
|
||||
title: "Open PR 2 comment x",
|
||||
icon: "GitPullRequest",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "pr", params: { prNumber: 2, commentId: "x" } });
|
||||
},
|
||||
});
|
||||
client.addCommandCenterItem({
|
||||
id: "open-pr-1b",
|
||||
title: "Open PR 1 comment b",
|
||||
icon: "GitPullRequest",
|
||||
context: "workspace",
|
||||
onSelect({ workspaceLayout }) {
|
||||
workspaceLayout.open({ panelId: "pr", params: { prNumber: 1, commentId: "b" } });
|
||||
},
|
||||
});
|
||||
|
||||
return () => {};
|
||||
}
|
||||
`;
|
||||
|
||||
async function expectNewTabLauncherPanelAvailability(
|
||||
page: Page,
|
||||
input: { present: readonly string[]; absent: readonly string[] },
|
||||
): Promise<void> {
|
||||
await mainPanes(page).first().getByTestId("workspace-new-tab-button").click();
|
||||
const menu = page.getByTestId("workspace-new-tab-menu").filter({ visible: true });
|
||||
for (const label of input.present) {
|
||||
await expect(menu.getByText(label, { exact: true })).toBeVisible();
|
||||
}
|
||||
for (const label of input.absent) {
|
||||
await expect(menu.getByText(label, { exact: true })).toHaveCount(0);
|
||||
}
|
||||
await page.keyboard.press("Escape");
|
||||
}
|
||||
|
||||
async function expectDecisionsPanel(
|
||||
page: Page,
|
||||
input: { tabs: number; decisionId: string; revision: number; stateNote: string },
|
||||
): Promise<void> {
|
||||
await expect(
|
||||
explorer(page)
|
||||
.getByTestId("workspace-tabs-row")
|
||||
.getByRole("button", { name: "Decisions", exact: true }),
|
||||
).toHaveCount(input.tabs);
|
||||
await expect(
|
||||
explorer(page).getByText(
|
||||
`decision:${input.decisionId}|rev:${input.revision}|state:${input.stateNote}`,
|
||||
{ exact: true },
|
||||
),
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
async function pinDecisionState(page: Page): Promise<void> {
|
||||
await explorer(page).getByRole("button", { name: "Pin decision state" }).click();
|
||||
}
|
||||
|
||||
async function expectPrPanel(
|
||||
page: Page,
|
||||
input: {
|
||||
tabs: number;
|
||||
prNumber: number;
|
||||
commentId: string;
|
||||
revision: number;
|
||||
persistedParams?: { prNumber: number; commentId: string };
|
||||
},
|
||||
): Promise<void> {
|
||||
await expect(
|
||||
mainPanes(page)
|
||||
.first()
|
||||
.getByTestId("workspace-tabs-row")
|
||||
.getByRole("button", { name: "PR", exact: true }),
|
||||
).toHaveCount(input.tabs);
|
||||
await expect(
|
||||
page.getByText(`pr:${input.prNumber}|comment:${input.commentId}|rev:${input.revision}`, {
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
if (input.persistedParams) {
|
||||
await expect(
|
||||
page.getByText(`readback:${input.prNumber}:${JSON.stringify(input.persistedParams)}`, {
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
test("reused Explorer panels and keyed workspace panels deliver params, identity, revision, and tab state", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(180_000);
|
||||
const example = await copyPluginExample("workspace-layout");
|
||||
await writeFile(path.join(example.directory, "index.client.tsx"), PARAMS_AND_IDENTITY_ENTRY);
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix: "plugin-params-identity-",
|
||||
title: AGENT_TITLE,
|
||||
repo: { files: REPO_FILES },
|
||||
});
|
||||
try {
|
||||
await withPluginInstalled(example.directory, async () => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await openAgentRoute(page, workspace);
|
||||
await approveClientPluginsInUi(page, ["workspace-layout"]);
|
||||
|
||||
await test.step("parameterless launcher hides panels with required params and keeps parameterless ones", async () => {
|
||||
await expectNewTabLauncherPanelAvailability(page, {
|
||||
present: ["Static"],
|
||||
absent: ["PR", "Decisions"],
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("reused Explorer panel updates params in place, bumps revision, and preserves tab.state", async () => {
|
||||
await runCommand(page, "Open decision D1");
|
||||
await expectDecisionsPanel(page, {
|
||||
tabs: 1,
|
||||
decisionId: "D1",
|
||||
revision: 1,
|
||||
stateNote: "initial",
|
||||
});
|
||||
|
||||
await pinDecisionState(page);
|
||||
await expectDecisionsPanel(page, {
|
||||
tabs: 1,
|
||||
decisionId: "D1",
|
||||
revision: 1,
|
||||
stateNote: "pinned",
|
||||
});
|
||||
|
||||
await runCommand(page, "Open decision D2");
|
||||
await expectDecisionsPanel(page, {
|
||||
tabs: 1,
|
||||
decisionId: "D2",
|
||||
revision: 2,
|
||||
stateNote: "pinned",
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("keyed panel opens separate tabs per identity key and updates hint params on reveal", async () => {
|
||||
await runCommand(page, "Open PR 1 comment a");
|
||||
await expectPrPanel(page, { tabs: 1, prNumber: 1, commentId: "a", revision: 1 });
|
||||
|
||||
await runCommand(page, "Open PR 2 comment x");
|
||||
await expectPrPanel(page, { tabs: 2, prNumber: 2, commentId: "x", revision: 1 });
|
||||
|
||||
await runCommand(page, "Open PR 1 comment b");
|
||||
await expectPrPanel(page, {
|
||||
tabs: 2,
|
||||
prNumber: 1,
|
||||
commentId: "b",
|
||||
revision: 2,
|
||||
persistedParams: { prNumber: 1, commentId: "b" },
|
||||
});
|
||||
});
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
await example.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -42,17 +42,40 @@ import { useAgent, useWorkspace, openExternalUrl } from "@getpaseo/plugin/client
|
||||
import { ExternalLink } from "@getpaseo/plugin/client/ui";
|
||||
import { recordComposerOpen } from "./shared/rpc";
|
||||
|
||||
function WorkspacePanel({ workspaceId, host, layout }) {
|
||||
function WorkspacePanel({ workspaceId, host, layout, openScreen }) {
|
||||
const workspace = useWorkspace(workspaceId, (value) => ({ id: value.id }));
|
||||
const renderCount = useRef(0);
|
||||
renderCount.current += 1;
|
||||
return <View><Text>Workspace bridge {workspace?.id}</Text><Text>Workspace renders {renderCount.current}</Text><Text>Host {host.id}</Text><Text>Layout {layout.compact ? "compact" : "wide"}</Text></View>;
|
||||
return <View>
|
||||
<Text>Workspace bridge {workspace?.id}</Text>
|
||||
<Text>Workspace renders {renderCount.current}</Text>
|
||||
<Text>Host {host.id}</Text>
|
||||
<Text>Layout {layout.compact ? "compact" : "wide"}</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => openScreen({ screenId: "details", params: { source: "workspace-panel", item: workspaceId } })}><Text>Open screen from workspace panel</Text></Pressable>
|
||||
</View>;
|
||||
}
|
||||
|
||||
function AgentPanel({ workspaceId, agentId, host, layout }) {
|
||||
function AgentPanel({ workspaceId, agentId, host, layout, openScreen }) {
|
||||
const workspace = useWorkspace(workspaceId, (value) => ({ id: value.id }));
|
||||
const agent = useAgent(agentId, (value) => ({ id: value.id }));
|
||||
return <View><Text>Agent bridge {agent?.id}</Text><Text>Workspace {workspace?.id}</Text><Text>Host {host.id}</Text><Text>Layout {layout.compact ? "compact" : "wide"}</Text></View>;
|
||||
return <View>
|
||||
<Text>Agent bridge {agent?.id}</Text>
|
||||
<Text>Workspace {workspace?.id}</Text>
|
||||
<Text>Host {host.id}</Text>
|
||||
<Text>Layout {layout.compact ? "compact" : "wide"}</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => openScreen({ screenId: "details", params: { source: "agent-panel", item: agentId } })}><Text>Open screen from agent panel</Text></Pressable>
|
||||
</View>;
|
||||
}
|
||||
|
||||
function DetailsScreen({ params, openScreen }) {
|
||||
return <View>
|
||||
<Text>{"Details screen: " + params.source + " / " + params.item}</Text>
|
||||
<Pressable accessibilityRole="button" onPress={() => openScreen({ screenId: "chained", params: { from: params.source ?? "" } })}><Text>Open chained screen</Text></Pressable>
|
||||
</View>;
|
||||
}
|
||||
|
||||
function ChainedScreen({ params }) {
|
||||
return <View><Text>{"Chained screen from " + params.from}</Text></View>;
|
||||
}
|
||||
|
||||
function DirectCollisionSurface({ navigation }) {
|
||||
@@ -127,6 +150,8 @@ function contributeClient(client) {
|
||||
}
|
||||
|
||||
export default function contribute(client) {
|
||||
client.addScreen({ id: "details", title: (params) => "Details: " + (params.source ?? ""), Component: DetailsScreen });
|
||||
client.addScreen({ id: "chained", title: "Chained", Component: ChainedScreen });
|
||||
client.addSurface("collision", DirectCollisionSurface);
|
||||
client.addSurface("sidebar-destination", SidebarCollisionSurface);
|
||||
client.addSidebarItem({ id: "collision", title: "Collision sidebar", icon: "Blocks", surface: "sidebar-destination" });
|
||||
@@ -252,6 +277,34 @@ async function openCompactSidebar(page: Page): Promise<void> {
|
||||
await expect(page.getByTestId("sidebar-search")).toBeVisible();
|
||||
}
|
||||
|
||||
async function openPluginScreenFromButton(
|
||||
page: Page,
|
||||
input: {
|
||||
buttonName: string;
|
||||
screenId: string;
|
||||
params: Record<string, string>;
|
||||
expectedText: string;
|
||||
},
|
||||
): Promise<void> {
|
||||
await page.getByRole("button", { name: input.buttonName, exact: true }).click();
|
||||
const query = Object.entries(input.params)
|
||||
.map(([key, value]) => `${encodeURIComponent(`param.${key}`)}=${encodeURIComponent(value)}`)
|
||||
.join("&");
|
||||
await expect(page).toHaveURL(
|
||||
new RegExp(`/plugin/${PLUGIN_ID}/surface/${input.screenId}\\?${query.replaceAll(".", "\\.")}$`),
|
||||
);
|
||||
await expect(page.getByText(input.expectedText, { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
async function closeTopPluginScreen(
|
||||
page: Page,
|
||||
options: { compact?: boolean; expectedText: string },
|
||||
): Promise<void> {
|
||||
const testId = options.compact ? "header-back-button" : "plugin-surface-close";
|
||||
await page.getByTestId(testId).filter({ visible: true }).last().click();
|
||||
await expect(page.getByText(options.expectedText, { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
async function capture(page: Page, testInfo: TestInfo, name: string): Promise<void> {
|
||||
const screenshot = testInfo.outputPath(`${name}.png`);
|
||||
await page.screenshot({ path: screenshot });
|
||||
@@ -338,6 +391,24 @@ test.describe("plugin workspace panels and Command Center", () => {
|
||||
await expect(page.getByText(`Host ${getServerId()}`, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("Layout wide", { exact: true })).toBeVisible();
|
||||
await capture(page, testInfo, "plugin-workspace-panel-wide");
|
||||
await openPluginScreenFromButton(page, {
|
||||
buttonName: "Open screen from workspace panel",
|
||||
screenId: "details",
|
||||
params: { source: "workspace-panel", item: primary.workspaceId },
|
||||
expectedText: `Details screen: workspace-panel / ${primary.workspaceId}`,
|
||||
});
|
||||
await openPluginScreenFromButton(page, {
|
||||
buttonName: "Open chained screen",
|
||||
screenId: "chained",
|
||||
params: { from: "workspace-panel" },
|
||||
expectedText: "Chained screen from workspace-panel",
|
||||
});
|
||||
await closeTopPluginScreen(page, {
|
||||
expectedText: `Details screen: workspace-panel / ${primary.workspaceId}`,
|
||||
});
|
||||
await closeTopPluginScreen(page, {
|
||||
expectedText: `Workspace bridge ${primary.workspaceId}`,
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("plugin links open browser tabs and in-app browsing is unavailable", async () => {
|
||||
@@ -475,6 +546,16 @@ test.describe("plugin workspace panels and Command Center", () => {
|
||||
).toBeVisible();
|
||||
await expect(page.getByText(`Host ${getServerId()}`, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText("Layout compact", { exact: true })).toBeVisible();
|
||||
await openPluginScreenFromButton(page, {
|
||||
buttonName: "Open screen from agent panel",
|
||||
screenId: "details",
|
||||
params: { source: "agent-panel", item: agent.id },
|
||||
expectedText: `Details screen: agent-panel / ${agent.id}`,
|
||||
});
|
||||
await closeTopPluginScreen(page, {
|
||||
compact: true,
|
||||
expectedText: `Agent bridge ${agent.id}`,
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("removing the active plugin renders the panel unavailable", async () => {
|
||||
|
||||
@@ -131,6 +131,11 @@ test.describe("Running indicators", () => {
|
||||
test.setTimeout(180_000);
|
||||
const scene = await openIdleChatBesideRunningAgent(page);
|
||||
try {
|
||||
// Once the chat has settled, nothing but rings is moving, so every frame drawn is a ring's.
|
||||
// A 200 ms border-colour transition in the composer can still be running as the chat opens.
|
||||
await expect
|
||||
.poll(async () => new Set(await readAnimatingTargets(page)))
|
||||
.toEqual(new Set(["status-ring"]));
|
||||
const animating = await readAnimatingTargets(page);
|
||||
const activity = await measureSteadyStateActivity({
|
||||
browser,
|
||||
@@ -143,8 +148,6 @@ test.describe("Running indicators", () => {
|
||||
JSON.stringify({ animating, activity, angles }, null, 2),
|
||||
);
|
||||
|
||||
// Nothing but rings is moving, so every frame drawn is a ring's.
|
||||
expect.soft(new Set(animating)).toEqual(new Set(["status-ring"]));
|
||||
expect
|
||||
.soft(activity.compositorFramesPerSecond)
|
||||
.toBeLessThan(RING_ONLY_FRAMES_PER_SECOND_BUDGET);
|
||||
|
||||
@@ -33,9 +33,13 @@ import {
|
||||
expectHostPageVisible,
|
||||
seedSavedSettingsHosts,
|
||||
selectSettingsHost,
|
||||
expectHostRejectedWithReAddGuidance,
|
||||
expectNoHostPasswordControls,
|
||||
removeHostFromHostPage,
|
||||
expectNoHostRefusalSheet,
|
||||
expectHostRefusalSheet,
|
||||
dismissHostRefusalSheet,
|
||||
expectHostPasswordRefusalInline,
|
||||
reopenHostPasswordRefusalSheet,
|
||||
submitHostRefusalPassword,
|
||||
expectHostRefusalPasswordError,
|
||||
addDirectHostFromSettings,
|
||||
expectAddHostFieldDrawnAsInput,
|
||||
selectHostConnectionType,
|
||||
@@ -111,7 +115,7 @@ test.describe("Settings host page", () => {
|
||||
await expect(updateButton).toBeEnabled();
|
||||
});
|
||||
|
||||
test("a host rejected for its password reconnects after being removed and added again with it", async ({
|
||||
test("a saved host rejected for its password reconnects in place from its settings page", async ({
|
||||
page,
|
||||
}) => {
|
||||
const password = "e2e host password";
|
||||
@@ -133,16 +137,29 @@ test.describe("Settings host page", () => {
|
||||
]);
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await openClientHostSettings(page, daemon.serverId);
|
||||
|
||||
await test.step("the host page shows the reason and the re-add guidance, with no password UI", async () => {
|
||||
await expectHostRejectedWithReAddGuidance(page, "Password required");
|
||||
await expectNoHostPasswordControls(page);
|
||||
await test.step("background refusal stays quiet until the host page is opened", async () => {
|
||||
await expectNoHostRefusalSheet(page);
|
||||
await openClientHostSettings(page, daemon.serverId);
|
||||
await expectHostRefusalSheet(page, {
|
||||
title: "Password required",
|
||||
hostLabel: "Password host",
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("removing the host and adding it again with the password brings it online", async () => {
|
||||
await removeHostFromHostPage(page, daemon.serverId);
|
||||
await addDirectHostFromSettings(page, { host: "127.0.0.1", port: daemon.port, password });
|
||||
await test.step("dismissing leaves an inline password prompt that reopens the sheet", async () => {
|
||||
await dismissHostRefusalSheet(page);
|
||||
await expectHostPasswordRefusalInline(page, "Password required");
|
||||
await reopenHostPasswordRefusalSheet(page);
|
||||
});
|
||||
|
||||
await test.step("a wrong password stays inline and the right password brings the host online", async () => {
|
||||
await submitHostRefusalPassword(page, "wrong password");
|
||||
await expectHostRefusalPasswordError(page, "Incorrect password");
|
||||
await submitHostRefusalPassword(page, password);
|
||||
await expectNoHostRefusalSheet(page);
|
||||
await expect(page.getByTestId("host-connection-error")).toHaveCount(0);
|
||||
await selectSettingsHost(page, daemon.serverId);
|
||||
await openHostSection(page, daemon.serverId, "daemon");
|
||||
await expectHostOnlineWithoutError(page);
|
||||
});
|
||||
@@ -337,6 +354,20 @@ test("Add host draws its text fields as bordered inputs", async ({ page }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Space toggles the focused Use SSL checkbox in the direct host form", async ({ page }) => {
|
||||
await gotoAppShell(page);
|
||||
await openSidebarAddHost(page);
|
||||
await selectHostConnectionType(page, "direct");
|
||||
const checkbox = page.getByRole("checkbox", { name: "Use SSL", exact: true });
|
||||
const initial = await checkbox.isChecked();
|
||||
await checkbox.focus();
|
||||
await checkbox.press("Space");
|
||||
await expect(checkbox).toBeChecked({ checked: !initial });
|
||||
await expect(checkbox).toBeFocused();
|
||||
await checkbox.press("Space");
|
||||
await expect(checkbox).toBeChecked({ checked: initial });
|
||||
});
|
||||
|
||||
test("sidebar Add host completes without navigating", async ({ page }) => {
|
||||
await gotoAppShell(page);
|
||||
await expect(page).toHaveURL(/\/open-project$/);
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { PNG } from "pngjs";
|
||||
|
||||
// Generate resolution-chart.png in an Android test workspace with the "fixture" command.
|
||||
// Open it from Files on a 1080 x 2400 emulator, pinch out by 4x at (540, 1250),
|
||||
// then pass the zoomed screenshot from adb exec-out screencap -p to the "check" command.
|
||||
// Generate a 6,000 x 5,000 PNG with "fixture-large" to exercise Android's bitmap size
|
||||
// limit. Open it from Files at fit and pass the screenshot to the same "check" command.
|
||||
// Pass the width and height from Expo Image's onLoad event to "check-decode" on an
|
||||
// emulator with the default 100 MiB canvas limit.
|
||||
const [command, path, height] = process.argv.slice(2);
|
||||
assert.ok(
|
||||
path && ["fixture", "fixture-large", "check", "check-decode"].includes(command),
|
||||
"Use fixture <png>, fixture-large <png>, check <png>, or check-decode <width> <height>",
|
||||
);
|
||||
|
||||
if (command === "check-decode") {
|
||||
const width = Number(path);
|
||||
const decodedHeight = Number(height);
|
||||
assert.ok(width > 0 && decodedHeight > 0, "Provide the positive decoded dimensions");
|
||||
assert.ok(
|
||||
width * decodedHeight * 4 <= 100 * 1024 * 1024,
|
||||
`Decoded bitmap exceeds 100 MiB at ${width} × ${decodedHeight}`,
|
||||
);
|
||||
} else if (command === "fixture" || command === "fixture-large") {
|
||||
const size =
|
||||
command === "fixture-large" ? { width: 6000, height: 5000 } : { width: 4000, height: 3000 };
|
||||
const chart = new PNG(size);
|
||||
const stripeWidth = command === "fixture-large" ? 240 : 3;
|
||||
for (let x = 0; x < chart.width; x++) {
|
||||
const shade = Math.floor(x / stripeWidth) % 2 === 0 ? 0 : 255;
|
||||
chart.data.set([shade, shade, shade, 255], x * 4);
|
||||
}
|
||||
for (let y = 1; y < chart.height; y++) {
|
||||
chart.data.copy(chart.data, y * chart.width * 4, 0, chart.width * 4);
|
||||
}
|
||||
writeFileSync(path, PNG.sync.write(chart));
|
||||
} else {
|
||||
const screenshot = PNG.sync.read(readFileSync(path));
|
||||
assert.equal(screenshot.width, 1080, "Use a 1080 x 2400 emulator");
|
||||
assert.equal(screenshot.height, 2400, "Use a 1080 x 2400 emulator");
|
||||
|
||||
// The center of each stripe should be nearly black or white. Antialiased edges
|
||||
// may stay gray, so sample a wide span and allow for those pixels.
|
||||
const row = 1200;
|
||||
let dark = 0;
|
||||
let light = 0;
|
||||
for (let x = 340; x < 740; x++) {
|
||||
const shade = screenshot.data[(row * screenshot.width + x) * 4];
|
||||
if (shade < 35) dark++;
|
||||
if (shade > 220) light++;
|
||||
}
|
||||
|
||||
assert.ok(
|
||||
dark >= 80 && light >= 80,
|
||||
`Fine stripes lost contrast (${dark} dark, ${light} light pixels)`,
|
||||
);
|
||||
}
|
||||
@@ -33,16 +33,20 @@ export async function restartDaemonInSettings(
|
||||
await expect(page.getByRole("button", { name: "Restarting...", exact: true })).toBeDisabled();
|
||||
}
|
||||
|
||||
// The app reads the replacement worker only after it reconnects. Reconnect attempts back off
|
||||
// (1.5 s doubling to a 30 s cap), so the result can trail a ready worker by up to 30 s.
|
||||
export const DAEMON_RESTART_TIMEOUT_MS = 75_000;
|
||||
|
||||
export async function expectDaemonRestartFailed(page: Page, text: string) {
|
||||
const error = page.getByTestId("host-page-restart-error");
|
||||
await expect(error).toBeVisible({ timeout: 30_000 });
|
||||
await expect(error).toBeVisible({ timeout: DAEMON_RESTART_TIMEOUT_MS });
|
||||
await expect(error).toContainText(text);
|
||||
await expect(page.getByRole("button", { name: "Restart", exact: true })).toBeEnabled();
|
||||
}
|
||||
|
||||
export async function expectDaemonRestartComplete(page: Page) {
|
||||
await expect(page.getByRole("button", { name: "Restart", exact: true })).toBeEnabled({
|
||||
timeout: 30_000,
|
||||
timeout: DAEMON_RESTART_TIMEOUT_MS,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ interface HeldServerMessage {
|
||||
interface PendingServerMessageHold {
|
||||
matches: (message: ClientRequest | null) => boolean;
|
||||
blockAgentStreamFollowers?: boolean;
|
||||
keepHolding?: boolean;
|
||||
}
|
||||
|
||||
function readSessionMessage(message: string | Buffer): ClientRequest | null {
|
||||
@@ -412,7 +413,7 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
);
|
||||
if (!matchedHold) return suppressed;
|
||||
const [key, hold] = matchedHold;
|
||||
pendingServerMessageHolds.delete(key);
|
||||
if (!hold.keepHolding) pendingServerMessageHolds.delete(key);
|
||||
heldServerMessages.push({
|
||||
browser: input.browser,
|
||||
message: input.message,
|
||||
@@ -550,6 +551,23 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
});
|
||||
});
|
||||
|
||||
const sendHeldServerMessage = (heldServerMessage: HeldServerMessage): void => {
|
||||
heldServerMessage.browser.send(heldServerMessage.message);
|
||||
for (const follower of heldServerMessage.agentStreamFollowers) {
|
||||
heldServerMessage.browser.send(follower);
|
||||
}
|
||||
};
|
||||
|
||||
const releaseFirstHeldMessage = (
|
||||
predicate: (message: HeldServerMessage) => boolean,
|
||||
errorMessage: string,
|
||||
): void => {
|
||||
const index = heldServerMessages.findIndex(predicate);
|
||||
const [heldServerMessage] = index >= 0 ? heldServerMessages.splice(index, 1) : [];
|
||||
if (!heldServerMessage) throw new Error(errorMessage);
|
||||
sendHeldServerMessage(heldServerMessage);
|
||||
};
|
||||
|
||||
return {
|
||||
waitForFileSubscription(path: string): Promise<void> {
|
||||
if (subscribedFilePaths.has(path)) return Promise.resolve();
|
||||
@@ -661,6 +679,13 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
matches: (message) => matchesAgentUpdate(message, heldAgentUpdate),
|
||||
});
|
||||
},
|
||||
holdAgentUpdates(agentId: string, status: string): void {
|
||||
const heldAgentUpdate = { agentId, status };
|
||||
pendingServerMessageHolds.set(agentUpdateKey(agentId, status), {
|
||||
matches: (message) => matchesAgentUpdate(message, heldAgentUpdate),
|
||||
keepHolding: true,
|
||||
});
|
||||
},
|
||||
holdNextAgentStreamEvent(type: string): void {
|
||||
pendingServerMessageHolds.set(agentStreamEventKey(type), {
|
||||
matches: (message) => readAgentStreamEventType(message) === type,
|
||||
@@ -690,13 +715,10 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
},
|
||||
releaseHeldServerMessage(type?: string): void {
|
||||
const key = type ? serverMessageKey(type) : null;
|
||||
const index = heldServerMessages.findIndex((message) => key === null || message.key === key);
|
||||
const [heldServerMessage] = index >= 0 ? heldServerMessages.splice(index, 1) : [];
|
||||
if (!heldServerMessage) throw new Error("No held server message to release");
|
||||
heldServerMessage.browser.send(heldServerMessage.message);
|
||||
for (const follower of heldServerMessage.agentStreamFollowers) {
|
||||
heldServerMessage.browser.send(follower);
|
||||
}
|
||||
releaseFirstHeldMessage(
|
||||
(message) => key === null || message.key === key,
|
||||
"No held server message to release",
|
||||
);
|
||||
},
|
||||
async waitForHeldAgentUpdate(agentId: string, status: string): Promise<void> {
|
||||
const key = agentUpdateKey(agentId, status);
|
||||
@@ -706,12 +728,20 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
},
|
||||
releaseHeldAgentUpdate(agentId: string, status: string): void {
|
||||
const key = agentUpdateKey(agentId, status);
|
||||
const index = heldServerMessages.findIndex((message) => message.key === key);
|
||||
const [heldServerMessage] = index >= 0 ? heldServerMessages.splice(index, 1) : [];
|
||||
if (!heldServerMessage) throw new Error("No held agent update to release");
|
||||
heldServerMessage.browser.send(heldServerMessage.message);
|
||||
for (const follower of heldServerMessage.agentStreamFollowers) {
|
||||
heldServerMessage.browser.send(follower);
|
||||
releaseFirstHeldMessage((message) => message.key === key, "No held agent update to release");
|
||||
},
|
||||
releaseHeldAgentUpdates(agentId: string, status: string): void {
|
||||
const key = agentUpdateKey(agentId, status);
|
||||
pendingServerMessageHolds.delete(key);
|
||||
const matching: HeldServerMessage[] = [];
|
||||
for (let index = heldServerMessages.length - 1; index >= 0; index -= 1) {
|
||||
if (heldServerMessages[index]?.key === key) {
|
||||
matching.unshift(...heldServerMessages.splice(index, 1));
|
||||
}
|
||||
}
|
||||
if (matching.length === 0) throw new Error("No held agent update to release");
|
||||
for (const heldServerMessage of matching) {
|
||||
sendHeldServerMessage(heldServerMessage);
|
||||
}
|
||||
},
|
||||
async waitForHeldAgentStreamEvent(type: string): Promise<void> {
|
||||
@@ -722,13 +752,10 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
},
|
||||
releaseHeldAgentStreamEvent(type: string): void {
|
||||
const key = agentStreamEventKey(type);
|
||||
const index = heldServerMessages.findIndex((message) => message.key === key);
|
||||
const [heldServerMessage] = index >= 0 ? heldServerMessages.splice(index, 1) : [];
|
||||
if (!heldServerMessage) throw new Error("No held agent stream event to release");
|
||||
heldServerMessage.browser.send(heldServerMessage.message);
|
||||
for (const follower of heldServerMessage.agentStreamFollowers) {
|
||||
heldServerMessage.browser.send(follower);
|
||||
}
|
||||
releaseFirstHeldMessage(
|
||||
(message) => message.key === key,
|
||||
"No held agent stream event to release",
|
||||
);
|
||||
},
|
||||
async waitForHeldAgentStreamItem(type: string): Promise<void> {
|
||||
const key = agentStreamItemKey(type);
|
||||
@@ -738,13 +765,10 @@ export async function installDaemonWebSocketGate(page: Page, options: { port?: n
|
||||
},
|
||||
releaseHeldAgentStreamItem(type: string): void {
|
||||
const key = agentStreamItemKey(type);
|
||||
const index = heldServerMessages.findIndex((message) => message.key === key);
|
||||
const [heldServerMessage] = index >= 0 ? heldServerMessages.splice(index, 1) : [];
|
||||
if (!heldServerMessage) throw new Error("No held agent stream item to release");
|
||||
heldServerMessage.browser.send(heldServerMessage.message);
|
||||
for (const follower of heldServerMessage.agentStreamFollowers) {
|
||||
heldServerMessage.browser.send(follower);
|
||||
}
|
||||
releaseFirstHeldMessage(
|
||||
(message) => message.key === key,
|
||||
"No held agent stream item to release",
|
||||
);
|
||||
},
|
||||
requestTimelineTail(agentId: string): void {
|
||||
if (!latestServer) throw new Error("No daemon WebSocket is connected");
|
||||
|
||||
@@ -76,19 +76,21 @@ export async function openDevicesPage(page: Page, daemon: PairingHost): Promise<
|
||||
|
||||
export async function expectConnectedClientRow(
|
||||
page: Page,
|
||||
title: string,
|
||||
title: string | RegExp,
|
||||
scopeLabel: string,
|
||||
): Promise<void> {
|
||||
const card = page.getByTestId("devices-connected-clients-card");
|
||||
const row = card.getByRole("button", { name: title, exact: true });
|
||||
const row = card.getByRole("button", { name: title, exact: typeof title === "string" });
|
||||
await expect(row).toBeVisible();
|
||||
await expect(card.getByText(scopeLabel, { exact: true }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expandConnectedClientRow(page: Page, title: string): Promise<void> {
|
||||
export async function expandConnectedClientRow(page: Page, title: string | RegExp): Promise<void> {
|
||||
const card = page.getByTestId("devices-connected-clients-card");
|
||||
await card.getByRole("button", { name: title, exact: true }).click();
|
||||
await expect(card.getByText("Permissions", { exact: true })).toBeVisible();
|
||||
const toggle = card.getByRole("button", { name: title, exact: typeof title === "string" });
|
||||
await toggle.click();
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(card.getByText("Access", { exact: true }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function returnFromRelayToWaysToConnect(page: Page): Promise<void> {
|
||||
|
||||
@@ -188,7 +188,12 @@ export interface SeedDaemonClient {
|
||||
archiveAgent(agentId: string): Promise<{ archivedAt: string }>;
|
||||
refreshAgent(agentId: string): Promise<unknown>;
|
||||
fetchAgent(options: { agentId: string }): Promise<{
|
||||
agent: { id: string; archivedAt?: string | null; pendingPermissions: Array<{ id: string }> };
|
||||
agent: {
|
||||
id: string;
|
||||
status: string;
|
||||
archivedAt?: string | null;
|
||||
pendingPermissions: Array<{ id: string }>;
|
||||
};
|
||||
} | null>;
|
||||
getLastServerInfoMessage(): {
|
||||
features?: {
|
||||
|
||||
@@ -712,27 +712,47 @@ export async function expectLocalHostEntryFirst(page: Page, _serverId: string):
|
||||
await expect(picker.getByText(TEST_HOST_LABEL, { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectHostRejectedWithReAddGuidance(
|
||||
export async function expectNoHostRefusalSheet(page: Page): Promise<void> {
|
||||
await expect(page.getByTestId("host-refusal-sheet")).toHaveCount(0);
|
||||
}
|
||||
|
||||
export async function expectHostRefusalSheet(
|
||||
page: Page,
|
||||
reason: string,
|
||||
expected: { title: string; hostLabel: string },
|
||||
): Promise<void> {
|
||||
const sheet = page.getByTestId("host-refusal-sheet");
|
||||
await expect(sheet).toBeVisible();
|
||||
await expect(sheet.getByTestId("host-refusal-sheet-title")).toHaveText(expected.title);
|
||||
await expect(sheet.getByTestId("host-refusal-sheet-host")).toHaveText(expected.hostLabel);
|
||||
}
|
||||
|
||||
export async function dismissHostRefusalSheet(page: Page): Promise<void> {
|
||||
await page.getByTestId("host-refusal-sheet-dismiss").click();
|
||||
await expectNoHostRefusalSheet(page);
|
||||
}
|
||||
|
||||
export async function expectHostPasswordRefusalInline(page: Page, reason: string): Promise<void> {
|
||||
const error = page.getByTestId("host-connection-error");
|
||||
await expect(error).toContainText(reason);
|
||||
await expect(error).toContainText(
|
||||
"Remove this host and add it again with the password this daemon asks for.",
|
||||
);
|
||||
await expect(error.getByRole("button", { name: "Enter password", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectNoHostPasswordControls(page: Page): Promise<void> {
|
||||
await expect(page.getByText("Password", { exact: true })).toHaveCount(0);
|
||||
await expect(page.locator('input[type="password"]')).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: /password/i })).toHaveCount(0);
|
||||
export async function reopenHostPasswordRefusalSheet(page: Page): Promise<void> {
|
||||
await page
|
||||
.getByTestId("host-connection-error")
|
||||
.getByRole("button", { name: "Enter password", exact: true })
|
||||
.click();
|
||||
await expect(page.getByTestId("host-refusal-sheet")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function removeHostFromHostPage(page: Page, serverId: string): Promise<void> {
|
||||
await page.getByTestId("host-page-remove-host-button").click();
|
||||
await page.getByTestId("remove-host-confirm").click();
|
||||
await expect(page).not.toHaveURL(new RegExp(`/settings/(hosts|device-hosts)/${serverId}`));
|
||||
export async function submitHostRefusalPassword(page: Page, password: string): Promise<void> {
|
||||
await page.getByTestId("host-password-input").fill(password);
|
||||
await page.getByTestId("host-refusal-sheet-submit").click();
|
||||
}
|
||||
|
||||
export async function expectHostRefusalPasswordError(page: Page, message: string): Promise<void> {
|
||||
await expect(page.getByTestId("host-refusal-sheet")).toBeVisible();
|
||||
await expect(page.getByTestId("host-password-field")).toContainText(message);
|
||||
}
|
||||
|
||||
export async function expectHostOnlineWithoutError(page: Page): Promise<void> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.19.0-beta.1",
|
||||
"version": "0.19.1",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -51,35 +51,61 @@
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
button,
|
||||
a,
|
||||
input,
|
||||
textarea,
|
||||
select,
|
||||
[role="button"],
|
||||
[role="link"],
|
||||
[role="textbox"],
|
||||
[role="combobox"],
|
||||
[role="tab"],
|
||||
[role="switch"],
|
||||
[role="checkbox"],
|
||||
[role="slider"],
|
||||
[role="menuitem"],
|
||||
[tabindex],
|
||||
/* Only interactive controls that can overlap a window drag surface
|
||||
emit -webkit-app-region: no-drag. Controls in ordinary window content
|
||||
rely on normal DOM hit testing so scrolled viewports and parked
|
||||
browser webviews never emit unclipped no-drag boxes over the titlebar. */
|
||||
:is(
|
||||
[data-window-drag-region] ~ *,
|
||||
[style*="-webkit-app-region: drag"],
|
||||
[style*="-webkit-app-region:drag"],
|
||||
#overlay-root,
|
||||
[data-window-overlay-host],
|
||||
[role="dialog"],
|
||||
[aria-modal="true"]
|
||||
)
|
||||
:is(
|
||||
button,
|
||||
a,
|
||||
input,
|
||||
textarea,
|
||||
select,
|
||||
[role="button"],
|
||||
[role="link"],
|
||||
[role="textbox"],
|
||||
[role="combobox"],
|
||||
[role="tab"],
|
||||
[role="switch"],
|
||||
[role="checkbox"],
|
||||
[role="slider"],
|
||||
[role="menuitem"],
|
||||
[tabindex],
|
||||
[contenteditable="true"]
|
||||
),
|
||||
[data-window-drag-region]
|
||||
~ :is(
|
||||
button,
|
||||
a,
|
||||
input,
|
||||
textarea,
|
||||
select,
|
||||
[role="button"],
|
||||
[role="link"],
|
||||
[role="textbox"],
|
||||
[role="combobox"],
|
||||
[role="tab"],
|
||||
[role="switch"],
|
||||
[role="checkbox"],
|
||||
[role="slider"],
|
||||
[role="menuitem"],
|
||||
[tabindex],
|
||||
[contenteditable="true"]
|
||||
),
|
||||
[data-window-no-drag],
|
||||
[contenteditable="true"] {
|
||||
[data-window-no-drag] * {
|
||||
-webkit-app-region: no-drag !important;
|
||||
}
|
||||
|
||||
/* Electron does not clip app-region rectangles to scroll viewports.
|
||||
Content-only viewports emit no window regions, including from their
|
||||
controls. Visible controls here use normal DOM hit testing.
|
||||
Use initial: Blink parses the explicit value none as no-drag. */
|
||||
[data-window-content],
|
||||
[data-window-content] * {
|
||||
-webkit-app-region: initial !important;
|
||||
}
|
||||
|
||||
/* Suppress the browser's default focus outline — it appears on mouse
|
||||
clicks and looks out of place against our themed surfaces. Keep a
|
||||
themed ring for keyboard users via :focus-visible. The ring is the active
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import type { View, ViewProps } from "react-native";
|
||||
import type { RefObject } from "react";
|
||||
|
||||
/**
|
||||
* Native: a touch that starts in the embed claims it, as a touch claims a workspace pane. The
|
||||
* capture handler declines the responder, so the touch still reaches what was pressed.
|
||||
*/
|
||||
export function useClaimFocusProps(
|
||||
claim: () => void,
|
||||
): Pick<ViewProps, "onStartShouldSetResponderCapture"> & { ref?: RefObject<View | null> } {
|
||||
const handleTouch = useCallback(() => {
|
||||
claim();
|
||||
return false;
|
||||
}, [claim]);
|
||||
return useMemo(() => ({ onStartShouldSetResponderCapture: handleTouch }), [handleTouch]);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useEffect, useMemo, useRef, type RefObject } from "react";
|
||||
import type { View, ViewProps } from "react-native";
|
||||
|
||||
/**
|
||||
* Web: a pointer press or focus move in the embed's DOM claims it, as one claims a workspace pane
|
||||
* (`split-container`). Pickers and menus the embed opens draw outside its DOM, so pressing them
|
||||
* leaves the claim where it is.
|
||||
*/
|
||||
export function useClaimFocusProps(
|
||||
claim: () => void,
|
||||
): Pick<ViewProps, "onStartShouldSetResponderCapture"> & { ref?: RefObject<View | null> } {
|
||||
const ref = useRef<View | null>(null);
|
||||
useEffect(() => {
|
||||
const node: unknown = ref.current;
|
||||
if (!(node instanceof HTMLElement)) return undefined;
|
||||
node.addEventListener("pointerdown", claim, true);
|
||||
node.addEventListener("focusin", claim, true);
|
||||
return () => {
|
||||
node.removeEventListener("pointerdown", claim, true);
|
||||
node.removeEventListener("focusin", claim, true);
|
||||
};
|
||||
}, [claim]);
|
||||
return useMemo(() => ({ ref }), []);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { useCallback, useContext, useEffect, useSyncExternalStore } from "react";
|
||||
import { NavigationContext } from "expo-router/react-navigation";
|
||||
import { useEnclosingPaneFocus } from "@/panels/pane-context";
|
||||
|
||||
/**
|
||||
* Which embed owns the composer's key handlers (Escape interrupts, send, mode cycling). Embeds
|
||||
* follow the workspace's pane rule: the embed the user last pressed or focused owns them until
|
||||
* the user presses another embed. A press elsewhere, such as in the plugin's own UI or in a
|
||||
* picker the embed opened, leaves the owner as it is.
|
||||
*/
|
||||
let focusedEmbedId: string | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
}
|
||||
|
||||
function setFocusedEmbed(next: string | null): void {
|
||||
if (focusedEmbedId === next) return;
|
||||
focusedEmbedId = next;
|
||||
for (const listener of listeners) listener();
|
||||
}
|
||||
|
||||
/** The embed's key focus, and the claim its root calls on a press or focus move inside it. */
|
||||
export function useEmbedFocus(embedId: string): { isFocused: boolean; claim: () => void } {
|
||||
const read = useCallback(() => focusedEmbedId === embedId, [embedId]);
|
||||
const isFocused = useSyncExternalStore(subscribe, read, read);
|
||||
const claim = useCallback(() => setFocusedEmbed(embedId), [embedId]);
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (focusedEmbedId === embedId) setFocusedEmbed(null);
|
||||
},
|
||||
[embedId],
|
||||
);
|
||||
return { isFocused, claim };
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the surface around the embed is the one the user is on: the pane it sits in, or else
|
||||
* the screen. A plugin screen stays mounted under the next one, and its embeds must not keep the
|
||||
* keys there. Outside any screen (a modal at the app root) the surface counts as shown.
|
||||
*/
|
||||
export function useEmbedSurfaceActive(): boolean {
|
||||
const pane = useEnclosingPaneFocus();
|
||||
const navigation = useContext(NavigationContext);
|
||||
const subscribeToRoute = useCallback(
|
||||
(listener: () => void) => {
|
||||
if (!navigation) return () => {};
|
||||
const removeFocus = navigation.addListener("focus", listener);
|
||||
const removeBlur = navigation.addListener("blur", listener);
|
||||
return () => {
|
||||
removeFocus();
|
||||
removeBlur();
|
||||
};
|
||||
},
|
||||
[navigation],
|
||||
);
|
||||
const readRoute = useCallback(() => navigation?.isFocused() ?? true, [navigation]);
|
||||
const isRouteFocused = useSyncExternalStore(subscribeToRoute, readRoute, readRoute);
|
||||
return pane ? pane.isInteractive : isRouteFocused;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { useId, useMemo } from "react";
|
||||
import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { LocalComposerEditingScope } from "@/composer/editing-session";
|
||||
import {
|
||||
AgentPanelContent,
|
||||
type ConversationSurface,
|
||||
type EmbeddedComposer,
|
||||
} from "@/panels/agent-panel";
|
||||
import { createPaneFocusContextValue, PaneFocusProvider } from "@/panels/pane-context";
|
||||
import { RetainedChatContent } from "@/panels/retained-chat-content";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { useViewedAgent } from "@/timeline/use-viewed-agent";
|
||||
import { useClaimFocusProps } from "./claim-focus";
|
||||
import { useEmbedFocus, useEmbedSurfaceActive } from "./focus";
|
||||
|
||||
export type { EmbeddedComposer } from "@/panels/agent-panel";
|
||||
|
||||
export interface AgentEmbedProps {
|
||||
serverId: string;
|
||||
agentId: string;
|
||||
/** `null` shows the conversation without a composer. */
|
||||
composer: EmbeddedComposer | null;
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An agent's conversation outside the workspace: the agent tab's own chain, with its loading,
|
||||
* catch-up, error and archived states, and no tab chrome.
|
||||
*
|
||||
* The embed is a viewer like the workspace sheet, so the agent's timeline stays live while it is
|
||||
* mounted and shares the tab's observation when the agent is also open in a tab.
|
||||
*
|
||||
* Several embeds can share a screen. Like workspace panes, the one the user last pressed owns the
|
||||
* composer's key handlers, and only while its pane or screen is the one in front. Each embed edits
|
||||
* in its own composer session, even inside a workspace panel that has one of its own.
|
||||
*/
|
||||
export function AgentEmbed({ serverId, agentId, composer, testID }: AgentEmbedProps) {
|
||||
const viewerId = `embed:${useId()}`;
|
||||
useViewedAgent({ sourceId: viewerId, serverId, agentId });
|
||||
const isSurfaceActive = useEmbedSurfaceActive();
|
||||
const { isFocused, claim } = useEmbedFocus(viewerId);
|
||||
const claimProps = useClaimFocusProps(claim);
|
||||
const isPaneFocused = composer !== null && isSurfaceActive && isFocused;
|
||||
const surface = useMemo<ConversationSurface>(
|
||||
() => ({ kind: "embed", id: viewerId, composer, isActive: isSurfaceActive }),
|
||||
[composer, isSurfaceActive, viewerId],
|
||||
);
|
||||
const focus = useMemo(
|
||||
() => createPaneFocusContextValue({ isWorkspaceFocused: isSurfaceActive, isPaneFocused }),
|
||||
[isPaneFocused, isSurfaceActive],
|
||||
);
|
||||
const target = useMemo(() => ({ kind: "agent" as const, agentId }), [agentId]);
|
||||
const workspaceId = useSessionStore((state) => {
|
||||
const session = state.sessions[serverId];
|
||||
return (
|
||||
session?.agents.get(agentId)?.workspaceId ??
|
||||
session?.agentDetails.get(agentId)?.workspaceId ??
|
||||
""
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<View {...claimProps} style={styles.root} testID={testID}>
|
||||
<PaneFocusProvider value={focus}>
|
||||
{/* Keyed like a pane's session, which follows its target. */}
|
||||
<LocalComposerEditingScope key={agentId}>
|
||||
<RetainedChatContent>
|
||||
<AgentPanelContent
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
target={target}
|
||||
surface={surface}
|
||||
isPaneFocused={isPaneFocused}
|
||||
/>
|
||||
</RetainedChatContent>
|
||||
</LocalComposerEditingScope>
|
||||
</PaneFocusProvider>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: { flex: 1, minHeight: 0 },
|
||||
});
|
||||
@@ -948,3 +948,46 @@ it.each([false, true])(
|
||||
expect(opened.groupsByHostId.size).toBe(0);
|
||||
},
|
||||
);
|
||||
|
||||
it("folds a completed turn whose plugin replaces every tool and reasoning row", () => {
|
||||
const present = createStreamPresentation();
|
||||
const timestamp = new Date();
|
||||
const tail: StreamItem[] = [
|
||||
{ kind: "user_message", id: "prompt", text: "Work", timestamp },
|
||||
{ kind: "thought", id: "reasoning", text: "Plan", status: "ready", timestamp },
|
||||
toolCall("one", "Bash"),
|
||||
{ kind: "assistant_message", id: "reply", text: "Done", timestamp },
|
||||
];
|
||||
const toolPlugin = installedTransform(installProbe("tool_call"));
|
||||
const reasoningPlugin = installedTransform(installProbe("reasoning"));
|
||||
const input = {
|
||||
...presentationOptions,
|
||||
tail,
|
||||
head: [],
|
||||
display: "collapseTurns" as const,
|
||||
isTurnActive: false,
|
||||
};
|
||||
const transform: TimelineItemTransform = (item) =>
|
||||
toolPlugin(item)?.flatMap((card) => [card, { ...card, id: `${card.id}/detail` }]) ??
|
||||
reasoningPlugin(item);
|
||||
const control = present({ ...input, transform: undefined });
|
||||
expect(control.tail.map((item) => item.kind)).toEqual([
|
||||
"user_message",
|
||||
"turn_summary",
|
||||
"assistant_message",
|
||||
]);
|
||||
const closed = present({ ...input, transform });
|
||||
expect(closed.tail.map((item) => item.kind)).toEqual(control.tail.map((item) => item.kind));
|
||||
expect(closed.turns.summaryRowsByHostId.get("prompt")?.tools).toEqual(
|
||||
control.turns.summaryRowsByHostId.get("prompt")?.tools,
|
||||
);
|
||||
const opened = present({ ...input, transform, expandedTurnHostIds: new Set(["prompt"]) });
|
||||
expect(opened.tail.map((item) => item.kind)).toEqual([
|
||||
"user_message",
|
||||
"turn_summary",
|
||||
"plugin",
|
||||
"plugin",
|
||||
"plugin",
|
||||
"assistant_message",
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1702,7 +1702,7 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool
|
||||
!liveAuxiliary;
|
||||
|
||||
return (
|
||||
<div style={viewportStyle} data-window-content>
|
||||
<div style={viewportStyle}>
|
||||
<div
|
||||
ref={handleScrollContainerRef}
|
||||
// Let clicks focus the feed for browser keyboard scrolling without adding a Tab stop.
|
||||
|
||||
@@ -45,9 +45,14 @@ function summarizeTurn(
|
||||
getGroupedCalls: CollapseTurnsInput["getGroupedCalls"],
|
||||
): OverviewSummary {
|
||||
const calls: (ToolCallItem | ThoughtItem)[] = [];
|
||||
const countedSources = new Set<string>();
|
||||
for (const item of items) {
|
||||
if ((item.kind === "tool_call" || item.kind === "thought") && !isTurnTrigger(item))
|
||||
calls.push(...(getGroupedCalls(item.id) ?? [item]));
|
||||
const source = item.kind === "plugin" ? item.source : item;
|
||||
if (!source || (source.kind !== "tool_call" && source.kind !== "thought")) continue;
|
||||
if (isTurnTrigger(source) || countedSources.has(source.id)) continue;
|
||||
// One source tool call can render as several plugin cards.
|
||||
countedSources.add(source.id);
|
||||
calls.push(...(getGroupedCalls(source.id) ?? [source]));
|
||||
}
|
||||
return summarizeToolCalls(calls);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
resolveDesktopDivisionLayout,
|
||||
} from "@/window-layout";
|
||||
import { AddHostProvider, AddHostFlowHost } from "@/hosts/add-host";
|
||||
import { HostRefusalSheetHost } from "@/hosts/host-refusal-sheet";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useActiveWorkspaceSelection } from "@/stores/navigation-active-workspace-store";
|
||||
import { useIsExplorerSidebarOpen } from "@/workspace-tabs/explorer-sidebar";
|
||||
@@ -53,6 +54,7 @@ import { AppearanceStyleBoundary } from "@/components/appearance-style-boundary"
|
||||
import { LeftSidebar } from "@/components/left-sidebar";
|
||||
import { WindowSidebarMenuToggle } from "@/components/headers/sidebar-menu-toggle";
|
||||
import { DesktopWindowControls } from "@/components/desktop/window-controls";
|
||||
import { WINDOW_OVERLAY_HOST_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
import { SidebarModelProvider } from "@/components/sidebar/sidebar-model";
|
||||
import { WorkspacePinShortcutHandler } from "@/components/workspace-pin-shortcut-handler";
|
||||
import { WorkspaceArchiveShortcutHandler } from "@/components/workspace-archive-shortcut-handler";
|
||||
@@ -531,6 +533,7 @@ function AppContainer({ children, chromeEnabled: chromeEnabledOverride }: AppCon
|
||||
<View style={layoutStyles.surfaceFill}>
|
||||
{workspaceChrome}
|
||||
<AddHostFlowHost />
|
||||
<HostRefusalSheetHost />
|
||||
<WorkspaceArchiveShortcutHandler />
|
||||
<AppearanceStyleBoundary>
|
||||
{!isCompactLayout && appChromeLayout.sidebarToggleOwner === "window" ? (
|
||||
@@ -604,6 +607,7 @@ function CompactSidebarHost({
|
||||
return (
|
||||
<View
|
||||
collapsable={false}
|
||||
dataSet={visible ? WINDOW_OVERLAY_HOST_DATASET : undefined}
|
||||
style={[
|
||||
layoutStyles.compactSidebarHost,
|
||||
{ opacity: visible ? 1 : 0 },
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||
import { useLocalSearchParams, useRouter, type Href } from "expo-router";
|
||||
import { useIsFocused } from "expo-router/react-navigation";
|
||||
import { HostRouteBootstrapBoundary } from "@/components/host-route-bootstrap-boundary";
|
||||
import { useFetchQuery } from "@/data/query";
|
||||
import { resolveAgentRoute, type AgentRouteLookup } from "@/navigation/agent-route-resolution";
|
||||
import { AgentRouteResolutionView } from "@/navigation/agent-route-resolution-view";
|
||||
import { useActiveRefusalHost } from "@/hosts/host-refusal-sheet-state";
|
||||
import { useHasHydratedWorkspaces } from "@/stores/session-store-hooks";
|
||||
import { useDirectoryDemand } from "@/hooks/use-directory-demand";
|
||||
import { useWorkspaceLayoutStoreHydrated } from "@/stores/workspace-layout-store";
|
||||
@@ -23,13 +25,14 @@ export default function HostAgentReadyRoute() {
|
||||
|
||||
function HostAgentReadyRouteContent() {
|
||||
const router = useRouter();
|
||||
const isRouteFocused = useIsFocused();
|
||||
const params = useLocalSearchParams<{
|
||||
serverId?: string;
|
||||
agentId?: string;
|
||||
}>();
|
||||
const handledNavigationRef = useRef<string | null>(null);
|
||||
const serverId = typeof params.serverId === "string" ? params.serverId : "";
|
||||
const agentId = typeof params.agentId === "string" ? params.agentId : "";
|
||||
const serverId = readStringParam(params.serverId);
|
||||
const agentId = readStringParam(params.agentId);
|
||||
const hosts = useHosts();
|
||||
const runtimeSnapshot = useHostRuntimeSnapshot(serverId);
|
||||
const client = runtimeSnapshot?.client ?? null;
|
||||
@@ -47,9 +50,13 @@ function HostAgentReadyRouteContent() {
|
||||
.prepareAgentRoute(serverId, agentId)
|
||||
.catch(() => undefined);
|
||||
}, [agentId, agentWorkspaceId, serverId]);
|
||||
const shouldLookupAgent = Boolean(
|
||||
serverId && agentId && client && connectionStatus === "online" && !agentWorkspaceId,
|
||||
);
|
||||
const shouldLookupAgent = canLookupAgentRoute({
|
||||
serverId,
|
||||
agentId,
|
||||
hasClient: client !== null,
|
||||
connectionStatus,
|
||||
agentWorkspaceId,
|
||||
});
|
||||
const lookupQuery = useFetchQuery({
|
||||
queryKey: ["agentRouteResolution", serverId, agentId, runtimeSnapshot?.clientGeneration ?? 0],
|
||||
queryFn: async () => {
|
||||
@@ -98,16 +105,10 @@ function HostAgentReadyRouteContent() {
|
||||
connectionStatus,
|
||||
lookup,
|
||||
});
|
||||
useActiveRefusalHost(serverId, isRouteFocused && isVisibleAgentRouteResolution(resolution));
|
||||
|
||||
useEffect(() => {
|
||||
let navigationKey: string | null = null;
|
||||
if (resolution.kind === "invalid") {
|
||||
navigationKey = "invalid";
|
||||
} else if (resolution.kind === "resolved") {
|
||||
navigationKey = `workspace:${resolution.workspaceId}`;
|
||||
} else if (resolution.kind === "notFound") {
|
||||
navigationKey = "not-found";
|
||||
}
|
||||
const navigationKey = resolveAgentRouteNavigationKey(resolution);
|
||||
if (!navigationKey || handledNavigationRef.current === navigationKey) {
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +127,7 @@ function HostAgentReadyRouteContent() {
|
||||
return;
|
||||
}
|
||||
if (serverId) {
|
||||
void getHostRuntimeStore().runProbeCycleNow(serverId);
|
||||
void getHostRuntimeStore().runProbeCycleNow(serverId, { clearRefusals: true });
|
||||
}
|
||||
}, [lookupQuery, resolution.kind, serverId]);
|
||||
const handleManageHost = useCallback(() => {
|
||||
@@ -142,18 +143,16 @@ function HostAgentReadyRouteContent() {
|
||||
router.replace(serverId ? buildHostRootRoute(serverId) : ("/" as Href));
|
||||
}, [router, serverId]);
|
||||
|
||||
if (
|
||||
resolution.kind === "waitingForHost" ||
|
||||
resolution.kind === "fetchingAgent" ||
|
||||
resolution.kind === "lookupError"
|
||||
) {
|
||||
if (isVisibleAgentRouteResolution(resolution)) {
|
||||
// Agent URLs intentionally omit workspaceId. Keep this route mounted while the target host
|
||||
// reconnects, then resolve the workspace from the authoritative agent record.
|
||||
return (
|
||||
<AgentRouteResolutionView
|
||||
serverId={serverId}
|
||||
resolution={resolution}
|
||||
hostName={hostName}
|
||||
lastHostError={runtimeSnapshot?.lastError ?? null}
|
||||
helloRejection={runtimeSnapshot?.helloRejection ?? null}
|
||||
onRetry={handleRetry}
|
||||
onManageHost={handleManageHost}
|
||||
onBack={handleBack}
|
||||
@@ -163,3 +162,45 @@ function HostAgentReadyRouteContent() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function readStringParam(value: string | undefined): string {
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
function canLookupAgentRoute(input: {
|
||||
serverId: string;
|
||||
agentId: string;
|
||||
hasClient: boolean;
|
||||
connectionStatus: string;
|
||||
agentWorkspaceId: string | null;
|
||||
}): boolean {
|
||||
return Boolean(
|
||||
input.serverId &&
|
||||
input.agentId &&
|
||||
input.hasClient &&
|
||||
input.connectionStatus === "online" &&
|
||||
!input.agentWorkspaceId,
|
||||
);
|
||||
}
|
||||
|
||||
function resolveAgentRouteNavigationKey(
|
||||
resolution: ReturnType<typeof resolveAgentRoute>,
|
||||
): string | null {
|
||||
if (resolution.kind === "invalid") return "invalid";
|
||||
if (resolution.kind === "resolved") return `workspace:${resolution.workspaceId}`;
|
||||
if (resolution.kind === "notFound") return "not-found";
|
||||
return null;
|
||||
}
|
||||
|
||||
function isVisibleAgentRouteResolution(
|
||||
resolution: ReturnType<typeof resolveAgentRoute>,
|
||||
): resolution is Extract<
|
||||
ReturnType<typeof resolveAgentRoute>,
|
||||
{ kind: "waitingForHost" | "fetchingAgent" | "lookupError" }
|
||||
> {
|
||||
return (
|
||||
resolution.kind === "waitingForHost" ||
|
||||
resolution.kind === "fetchingAgent" ||
|
||||
resolution.kind === "lookupError"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,4 +84,19 @@ describe("direct connection failure copy", () => {
|
||||
}),
|
||||
).toMatchObject({ detail: message, raw: message });
|
||||
});
|
||||
|
||||
it("preserves non-password hello rejections without falling back to generic unableToConnect", () => {
|
||||
const message = "Incompatible protocol version";
|
||||
expect(
|
||||
buildConnectionFailureCopy({
|
||||
endpoint: "example.test:6767",
|
||||
error: new DaemonConnectionTestError(message, {
|
||||
reason: message,
|
||||
lastError: message,
|
||||
helloRejection: { reason: "incompatible_protocol", accepts: [] },
|
||||
}),
|
||||
labels,
|
||||
}),
|
||||
).toMatchObject({ detail: message, raw: message });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
DaemonConnectionTestError,
|
||||
getConnectionAuthFailureReason,
|
||||
getConnectionHelloRejection,
|
||||
} from "@/utils/test-daemon-connection";
|
||||
|
||||
interface ConnectionFailureLabels {
|
||||
@@ -73,7 +73,7 @@ export function buildConnectionFailureCopy(input: {
|
||||
const rawLower = raw?.toLowerCase() ?? "";
|
||||
let detail: string | null = null;
|
||||
|
||||
if (getConnectionAuthFailureReason(error)) {
|
||||
if (getConnectionHelloRejection(error)) {
|
||||
detail = error instanceof Error ? error.message : raw;
|
||||
} else if (rawLower.includes("timed out")) {
|
||||
detail = labels.timedOut;
|
||||
|
||||
@@ -10,23 +10,23 @@ import { isNative } from "@/constants/platform";
|
||||
* - titlebarpart.css:249-260 → top-edge resizer, no-drag, 4px
|
||||
*
|
||||
* VS Code's drag region is a static DOM element — no z-index, no pointer-events,
|
||||
* no state, no event listeners. Interactive elements get no-drag from their own
|
||||
* CSS (global backstop in index.html). The drag region never re-renders.
|
||||
* no state, no event listeners. Interactive controls only receive no-drag when
|
||||
* they sit inside a drag container, an overlay/modal host, or an explicit
|
||||
* window-owned chrome slot (see public/index.html). Controls in ordinary window
|
||||
* content emit no app regions and use normal DOM hit testing, so scrolled
|
||||
* viewports and parked browser webviews cannot subtract unclipped rects from
|
||||
* the titlebar.
|
||||
*
|
||||
* The resizer is Windows/Linux only (titlebarpart.css:249 scopes to .windows/.linux).
|
||||
* On macOS, Electron handles edge resize natively.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marks a scroll viewport as window content: it and its descendants emit no window
|
||||
* regions, because Electron does not clip app-region rects to scroll viewports.
|
||||
* See the `[data-window-content]` rule in public/index.html.
|
||||
*/
|
||||
export const WINDOW_CONTENT_DATASET = { "window-content": "" };
|
||||
|
||||
/** Reserves a clickable area for a control mounted outside the titlebar rail. */
|
||||
/** Reserves a clickable area for a window-owned control mounted outside a drag container. */
|
||||
export const WINDOW_NO_DRAG_DATASET = { "window-no-drag": "" };
|
||||
|
||||
/** Marks an in-app overlay/portal host whose interactive controls can float over the titlebar. */
|
||||
export const WINDOW_OVERLAY_HOST_DATASET = { "window-overlay-host": "" };
|
||||
|
||||
export const titlebarDragSurfaceStyle: React.CSSProperties = {
|
||||
cursor: "default",
|
||||
// @ts-expect-error — WebkitAppRegion is not in CSSProperties
|
||||
@@ -46,6 +46,7 @@ const DRAG_OVERLAY_STYLE: React.CSSProperties = {
|
||||
const TOP_RESIZER_STYLE: React.CSSProperties = {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: 4,
|
||||
// @ts-expect-error — WebkitAppRegion is not in CSSProperties
|
||||
@@ -64,7 +65,7 @@ export function TitlebarDragRegion() {
|
||||
return (
|
||||
<>
|
||||
{/* Drag overlay — VS Code .titlebar-drag-region (titlebarpart.css:57-64) */}
|
||||
<div style={DRAG_OVERLAY_STYLE} />
|
||||
<div data-window-drag-region="" style={DRAG_OVERLAY_STYLE} />
|
||||
{/* Top-edge resizer — VS Code .resizer (titlebarpart.css:249-256) */}
|
||||
<div style={TOP_RESIZER_STYLE} />
|
||||
</>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getDesktopWindowControlsPresentation,
|
||||
type DesktopWindowControlsPresentation,
|
||||
} from "@/desktop/window-chrome-presentation";
|
||||
import { WINDOW_NO_DRAG_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
import { useCustomDesktopWindowControls } from "@/utils/desktop-window";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
|
||||
@@ -143,6 +144,7 @@ export function DesktopWindowControls() {
|
||||
|
||||
return (
|
||||
<View
|
||||
dataSet={WINDOW_NO_DRAG_DATASET}
|
||||
style={[styles.controls, { height: presentation.controlHeight }]}
|
||||
testID="desktop-window-controls"
|
||||
>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createContext, useContext, useCallback, useState, useId, type ReactNode
|
||||
import { View, type LayoutChangeEvent } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { Portal, PortalHost } from "@gorhom/portal";
|
||||
import { WINDOW_OVERLAY_HOST_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { EdgeFade } from "@/components/ui/edge-fade";
|
||||
|
||||
@@ -74,7 +75,11 @@ export function FloatingHeaderLayout({ header, floating, children }: FloatingHea
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
<View style={styles.statusOverlay} pointerEvents="box-none">
|
||||
<View
|
||||
style={styles.statusOverlay}
|
||||
dataSet={WINDOW_OVERLAY_HOST_DATASET}
|
||||
pointerEvents="box-none"
|
||||
>
|
||||
<PortalHost name={overlayHostName} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { router } from "expo-router";
|
||||
import { ArrowLeft } from "lucide-react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { HeaderToggleButton } from "@/components/headers/header-toggle-button";
|
||||
import { SidebarMenuToggle } from "@/components/headers/sidebar-menu-toggle";
|
||||
import {
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
HEADER_INNER_HEIGHT_MOBILE,
|
||||
HEADER_TOP_PADDING_MOBILE,
|
||||
} from "@/constants/layout";
|
||||
import { WindowChromeSafeArea } from "@/utils/desktop-window";
|
||||
import type { ShortcutKey } from "@/utils/format-shortcut";
|
||||
import { useTopBand } from "@/window-layout";
|
||||
|
||||
@@ -75,27 +77,30 @@ export function CompactHeader({
|
||||
|
||||
return (
|
||||
<IconButtonChromeProvider value="header-island">
|
||||
<View style={rootStyle}>
|
||||
<View
|
||||
style={[
|
||||
usesTitlebarHeight ? styles.titlebarRow : styles.row,
|
||||
inDesktopTitlebar && styles.desktopTitlebarDividerSpace,
|
||||
]}
|
||||
>
|
||||
<View style={styles.island}>
|
||||
{navigation === "menu" ? <SidebarMenuToggle /> : <BackButton onBack={onBack} />}
|
||||
<WindowChromeSafeArea placement="inline" style={styles.chromeContainer}>
|
||||
<TitlebarDragRegion />
|
||||
<View style={rootStyle}>
|
||||
<View
|
||||
style={[
|
||||
usesTitlebarHeight ? styles.titlebarRow : styles.row,
|
||||
inDesktopTitlebar && styles.desktopTitlebarDividerSpace,
|
||||
]}
|
||||
>
|
||||
<View style={styles.island}>
|
||||
{navigation === "menu" ? <SidebarMenuToggle /> : <BackButton onBack={onBack} />}
|
||||
</View>
|
||||
<View style={styles.titleGroup}>
|
||||
<CompactHeaderTitle
|
||||
loading={loading}
|
||||
title={title}
|
||||
titleTestID={titleTestID}
|
||||
subtitle={subtitle}
|
||||
/>
|
||||
</View>
|
||||
{actions ? <View style={styles.island}>{actions}</View> : null}
|
||||
</View>
|
||||
<View style={styles.titleGroup}>
|
||||
<CompactHeaderTitle
|
||||
loading={loading}
|
||||
title={title}
|
||||
titleTestID={titleTestID}
|
||||
subtitle={subtitle}
|
||||
/>
|
||||
</View>
|
||||
{actions ? <View style={styles.island}>{actions}</View> : null}
|
||||
</View>
|
||||
</View>
|
||||
</WindowChromeSafeArea>
|
||||
</IconButtonChromeProvider>
|
||||
);
|
||||
}
|
||||
@@ -154,6 +159,9 @@ function BackButton({ onBack }: { onBack?: () => void }) {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
chromeContainer: {
|
||||
position: "relative",
|
||||
},
|
||||
root: {
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { PanelLeft } from "lucide-react-native";
|
||||
import { WINDOW_NO_DRAG_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
import { HeaderToggleButton, headerIconSlotStyle } from "./header-toggle-button";
|
||||
import { selectIsAgentListOpen, usePanelStore } from "@/stores/panel-store";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
@@ -50,10 +51,12 @@ function SidebarMenuToggleButton({
|
||||
tooltipSide = "right",
|
||||
testID = "menu-button",
|
||||
nativeID = "menu-button",
|
||||
dataSet,
|
||||
}: Omit<SidebarMenuToggleProps, "style"> & {
|
||||
isMobile: boolean;
|
||||
extraMutedIdleIcon?: boolean;
|
||||
resolvedStyle: StyleProp<ViewStyle>;
|
||||
dataSet?: Record<string, string>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const isOpen = usePanelStore((state) => selectIsAgentListOpen(state, { isCompact: isMobile }));
|
||||
@@ -77,6 +80,7 @@ function SidebarMenuToggleButton({
|
||||
tooltipSide={tooltipSide}
|
||||
testID={testID}
|
||||
nativeID={nativeID}
|
||||
dataSet={dataSet}
|
||||
style={resolvedStyle}
|
||||
accessible
|
||||
accessibilityRole="button"
|
||||
@@ -128,6 +132,7 @@ export function WindowSidebarMenuToggle({ style, ...props }: SidebarMenuTogglePr
|
||||
{...props}
|
||||
isMobile={false}
|
||||
extraMutedIdleIcon
|
||||
dataSet={WINDOW_NO_DRAG_DATASET}
|
||||
resolvedStyle={resolvedStyle}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { View } from "react-native";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
import { STATUS_RING_PERIOD_MS, STATUS_RING_STEPS } from "@/components/status-ring/geometry";
|
||||
import { type IndicatorLoop, useIndicatorLoop } from "./loop.web";
|
||||
import { INDICATOR_STEP_MS } from "./steps";
|
||||
|
||||
// A ring and a shimmer: two stepped loops of different lengths on the step grid, one counted from
|
||||
// the timeline's origin and one from the step it started in.
|
||||
const RING: IndicatorLoop = {
|
||||
keyframes: [
|
||||
{ transform: "rotate(0deg)", easing: `steps(${STATUS_RING_STEPS})` },
|
||||
{ transform: "rotate(360deg)" },
|
||||
],
|
||||
durationMs: STATUS_RING_PERIOD_MS,
|
||||
phase: "shared",
|
||||
};
|
||||
const SHIMMER_STEPS = 42;
|
||||
const SHIMMER: IndicatorLoop = {
|
||||
keyframes: [
|
||||
{ transform: "translateX(-100px)", easing: `steps(${SHIMMER_STEPS})` },
|
||||
{ transform: "translateX(300px)" },
|
||||
],
|
||||
durationMs: SHIMMER_STEPS * INDICATOR_STEP_MS,
|
||||
phase: "own",
|
||||
};
|
||||
|
||||
function Indicators() {
|
||||
const ringRef = useIndicatorLoop(RING);
|
||||
const shimmerRef = useIndicatorLoop(SHIMMER);
|
||||
return (
|
||||
<>
|
||||
<View ref={ringRef} testID="ring" />
|
||||
<View ref={shimmerRef} testID="shimmer" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
let root: Root | null = null;
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root?.unmount());
|
||||
root = null;
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
function mountIndicators(): { ring: Animation; shimmer: Animation } {
|
||||
const container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
act(() => root!.render(<Indicators />));
|
||||
const animationOf = (testId: string) => {
|
||||
const element = container.querySelector(`[data-testid="${testId}"]`);
|
||||
const animation = element?.getAnimations()[0];
|
||||
if (!animation) throw new Error(`${testId} is not animating`);
|
||||
return animation;
|
||||
};
|
||||
return { ring: animationOf("ring"), shimmer: animationOf("shimmer") };
|
||||
}
|
||||
|
||||
/**
|
||||
* Steps through every timeline time, on the microsecond marks a browser stamps frames at, around
|
||||
* each of the grid's next `boundaries` step boundaries. Reports how often each loop turned over and
|
||||
* the times at which one of the two turned over and the other did not.
|
||||
*/
|
||||
function sweepBoundaries(
|
||||
loops: { ring: Animation; shimmer: Animation },
|
||||
boundaries: number,
|
||||
): { ringTurnovers: number; shimmerTurnovers: number; turningOneLoop: number[] } {
|
||||
const elements = {
|
||||
ring: loops.ring.effect as KeyframeEffect,
|
||||
shimmer: loops.shimmer.effect as KeyframeEffect,
|
||||
};
|
||||
const startTimes = {
|
||||
ring: Number(loops.ring.startTime),
|
||||
shimmer: Number(loops.shimmer.startTime),
|
||||
};
|
||||
loops.ring.pause();
|
||||
loops.shimmer.pause();
|
||||
const showAt = (timelineMs: number) => {
|
||||
loops.ring.currentTime = timelineMs - startTimes.ring;
|
||||
loops.shimmer.currentTime = timelineMs - startTimes.shimmer;
|
||||
return {
|
||||
ring: getComputedStyle(elements.ring.target!).transform,
|
||||
shimmer: getComputedStyle(elements.shimmer.target!).transform,
|
||||
};
|
||||
};
|
||||
|
||||
const firstStep = Math.ceil(startTimes.shimmer / INDICATOR_STEP_MS) + 1;
|
||||
const turnovers = { ringTurnovers: 0, shimmerTurnovers: 0, turningOneLoop: [] as number[] };
|
||||
for (let step = firstStep; step < firstStep + boundaries; step += 1) {
|
||||
const boundaryUs = Math.round(step * INDICATOR_STEP_MS * 1000);
|
||||
let previous = showAt((boundaryUs - 20) / 1000);
|
||||
for (let frameUs = boundaryUs - 19; frameUs <= boundaryUs + 20; frameUs += 1) {
|
||||
const current = showAt(frameUs / 1000);
|
||||
const ringTurned = current.ring !== previous.ring;
|
||||
const shimmerTurned = current.shimmer !== previous.shimmer;
|
||||
if (ringTurned) turnovers.ringTurnovers += 1;
|
||||
if (shimmerTurned) turnovers.shimmerTurnovers += 1;
|
||||
if (ringTurned !== shimmerTurned) {
|
||||
turnovers.turningOneLoop.push(frameUs / 1000);
|
||||
}
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
return turnovers;
|
||||
}
|
||||
|
||||
it("turns loops of different lengths over on the same frame, whenever the frame is stamped", () => {
|
||||
const loops = mountIndicators();
|
||||
|
||||
// Each loop turns over once at every boundary, and never on a frame without the other.
|
||||
expect(sweepBoundaries(loops, 300)).toEqual({
|
||||
ringTurnovers: 300,
|
||||
shimmerTurnovers: 300,
|
||||
turningOneLoop: [],
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,14 @@ import { useLayoutEffect, useRef, type RefObject } from "react";
|
||||
import type { View } from "react-native";
|
||||
import { INDICATOR_STEP_MS } from "./steps";
|
||||
|
||||
const TIMELINE_ORIGIN_MS = 0;
|
||||
// Where the step grid starts on the document timeline. Browsers stamp a frame at a whole number of
|
||||
// microseconds, often coarsened to 5 or 100. Each loop works out a step boundary from its own
|
||||
// duration, so floating-point rounding can put a boundary that falls exactly on a frame's stamp
|
||||
// before that frame for one loop and after it for another: the two then turn over on consecutive
|
||||
// frames, and the window draws one more. Every third boundary of a grid from 0 is a whole number of
|
||||
// milliseconds and so falls on a stamp. Starting the grid 2.5 µs in keeps every boundary at least
|
||||
// a sixth of a microsecond from any stamp, far beyond the rounding.
|
||||
const STEP_GRID_ORIGIN_MS = 0.0025;
|
||||
|
||||
export interface IndicatorLoop {
|
||||
/** One cycle. Keep the array's identity stable: a new array restarts the loop. */
|
||||
@@ -10,7 +17,7 @@ export interface IndicatorLoop {
|
||||
durationMs: number;
|
||||
/**
|
||||
* `shared` puts every instance at the same point of the cycle, wherever and whenever it mounted:
|
||||
* the loop counts from the document timeline's origin instead of from its own start. `own` starts
|
||||
* the loop counts from the step grid's origin instead of from its own start. `own` starts
|
||||
* the cycle at the step of the indicator step grid the loop starts in, so a stepped loop turns
|
||||
* over with every other; see `steps.ts`.
|
||||
*/
|
||||
@@ -19,8 +26,8 @@ export interface IndicatorLoop {
|
||||
|
||||
// The start of the step of the indicator step grid the document timeline is in now.
|
||||
function currentStepStartMs(): number {
|
||||
const now = Number(document.timeline.currentTime ?? 0);
|
||||
return Math.floor(now / INDICATOR_STEP_MS) * INDICATOR_STEP_MS;
|
||||
const sinceOrigin = Number(document.timeline.currentTime ?? 0) - STEP_GRID_ORIGIN_MS;
|
||||
return STEP_GRID_ORIGIN_MS + Math.floor(sinceOrigin / INDICATOR_STEP_MS) * INDICATOR_STEP_MS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +54,7 @@ export function useIndicatorLoop(loop: IndicatorLoop | null): RefObject<View | n
|
||||
iterations: Number.POSITIVE_INFINITY,
|
||||
});
|
||||
// An explicit start also keeps loops that start in the same commit exactly together.
|
||||
animation.startTime = loop.phase === "shared" ? TIMELINE_ORIGIN_MS : currentStepStartMs();
|
||||
animation.startTime = loop.phase === "shared" ? STEP_GRID_ORIGIN_MS : currentStepStartMs();
|
||||
return () => {
|
||||
animation.cancel();
|
||||
};
|
||||
|
||||
@@ -37,10 +37,7 @@ import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from "react-nativ
|
||||
import { scheduleOnRN } from "react-native-worklets";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
||||
import {
|
||||
TitlebarDragRegion,
|
||||
WINDOW_CONTENT_DATASET,
|
||||
} from "@/components/desktop/titlebar-drag-region";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { SidebarCloseButton } from "@/components/headers/sidebar-close-button";
|
||||
import {
|
||||
resolveDesktopSidebarInsetLeft,
|
||||
@@ -698,15 +695,13 @@ function MobileSidebar({
|
||||
|
||||
interface SidebarNavScrollProps {
|
||||
closeGestureRef: RefObject<GestureType | undefined>;
|
||||
/** Web only: the viewport emits no window regions (see WINDOW_CONTENT_DATASET). */
|
||||
windowContent?: boolean;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
// The capped, scrolling nav block shared by the mobile and desktop sidebars, with the
|
||||
// divider below it. The divider is a sibling because Unistyles does not patch the
|
||||
// gesture-handler ScrollView.
|
||||
function SidebarNavScroll({ closeGestureRef, windowContent, children }: SidebarNavScrollProps) {
|
||||
function SidebarNavScroll({ closeGestureRef, children }: SidebarNavScrollProps) {
|
||||
return (
|
||||
<>
|
||||
{platformIsNative ? (
|
||||
@@ -723,7 +718,6 @@ function SidebarNavScroll({ closeGestureRef, windowContent, children }: SidebarN
|
||||
</GHScrollView>
|
||||
) : (
|
||||
<ScrollView
|
||||
dataSet={windowContent ? WINDOW_CONTENT_DATASET : undefined}
|
||||
style={styles.navScroll}
|
||||
showsVerticalScrollIndicator={false}
|
||||
alwaysBounceVertical={false}
|
||||
@@ -899,11 +893,8 @@ function DesktopSidebar({
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{/* The drag overlay stays above this viewport: Electron does not clip
|
||||
app-region rects to scroll viewports, so a scrolled-out row would
|
||||
still claim its no-drag rect. */}
|
||||
{hasNavRows ? (
|
||||
<SidebarNavScroll closeGestureRef={closeGestureRef} windowContent>
|
||||
<SidebarNavScroll closeGestureRef={closeGestureRef}>
|
||||
<SidebarNavRows style={styles.sidebarHeaderGroup} onBeforeNavigate={closeSidebar} />
|
||||
</SidebarNavScroll>
|
||||
) : null}
|
||||
|
||||
@@ -497,6 +497,30 @@ it("recognizes forge references in prose but not in code, links or paths", async
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
["见 src/app/main.ts,还有", ["src/app/main.ts"]],
|
||||
["改了 src/a/b/c,然后", ["src/a/b/c"]],
|
||||
["src/foo.ts、src/bar.ts", ["src/foo.ts", "src/bar.ts"]],
|
||||
["查看:docs/说明.md:12。", ["docs/说明.md:12"]],
|
||||
["see src/app/main.ts, ok", ["src/app/main.ts"]],
|
||||
])("recognizes bare file paths next to sentence punctuation: %s", async (source, expected) => {
|
||||
const prepared = prepareMarkdownSource(source, "/repo");
|
||||
const tree = recognizeTextLinks(
|
||||
await parseMarkdown(prepared.render(), { latexMath: false }),
|
||||
prepared.linkRecognition.text,
|
||||
prepared.linkRecognition.inlineCode,
|
||||
);
|
||||
const parts = tree.children?.[0]?.children ?? [];
|
||||
expect(parts.map((node) => node.content ?? node.children?.[0]?.content).join("")).toBe(source);
|
||||
expect(parts.filter((node) => node.type === "Link").map((node) => node.attributes?.url)).toEqual(
|
||||
expected,
|
||||
);
|
||||
expect(toNativeLinkRecognition(prepared.linkRecognition).text).toMatchObject({
|
||||
isDisabled: false,
|
||||
isDefault: false,
|
||||
});
|
||||
});
|
||||
|
||||
describe("bare URL sentence punctuation", () => {
|
||||
it.each([".", ",", ";", ":", "!", "?", ")", ").", "...", "?!"])(
|
||||
"leaves %s outside the link and preserves the rendered sentence",
|
||||
@@ -1227,6 +1251,18 @@ it.each([
|
||||
).toEqual([token]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["更正此前的进度说明:A/B/C/D 主实验", ["A/B/C/D"]],
|
||||
["修改:src/index.ts,然后提交。", ["src/index.ts"]],
|
||||
["见(docs/说明.md)。", ["docs/说明.md"]],
|
||||
["参考「src/index.ts:12」、「README.md」", ["src/index.ts:12", "README.md"]],
|
||||
["“./scripts/run”…", ["./scripts/run"]],
|
||||
["文档在 docs/说明.md 里", ["docs/说明.md"]],
|
||||
])("ends prose paths at CJK and typographic punctuation: %s", (source, expected) => {
|
||||
const { linkRecognition } = prepareMarkdownSource(source, "/repo");
|
||||
expect([...source.matchAll(linkRecognition.text)].map(([text]) => text)).toEqual(expected);
|
||||
});
|
||||
|
||||
it.each([
|
||||
"before/after",
|
||||
"and/or",
|
||||
|
||||
@@ -9,11 +9,56 @@ import { decodeString } from "micromark-util-decode-string";
|
||||
import { fromMarkdown } from "mdast-util-from-markdown";
|
||||
import type { Link, Nodes, Paragraph, PhrasingContent, Root } from "mdast";
|
||||
|
||||
// CJK, fullwidth and typographic punctuation (、。,:()【】「」“”…) ends bare URLs and prose
|
||||
// paths; CJK letters do not.
|
||||
const PUNCTUATION_BOUNDARY_RANGES: readonly (readonly [number, number])[] = [
|
||||
[0x2018, 0x2019],
|
||||
[0x201c, 0x201d],
|
||||
[0x2026, 0x2026],
|
||||
[0x3000, 0x3003],
|
||||
[0x3008, 0x3011],
|
||||
[0x3014, 0x301f],
|
||||
[0xff01, 0xff0f],
|
||||
[0xff1a, 0xff20],
|
||||
[0xff3b, 0xff40],
|
||||
[0xff5b, 0xff65],
|
||||
];
|
||||
|
||||
function formatCharacterRanges(ranges: readonly (readonly [number, number])[]): string {
|
||||
const escape = (codePoint: number) =>
|
||||
`\\u${codePoint.toString(16).toUpperCase().padStart(4, "0")}`;
|
||||
return ranges
|
||||
.map(([start, end]) => (start === end ? escape(start) : `${escape(start)}-${escape(end)}`))
|
||||
.join("");
|
||||
}
|
||||
|
||||
/** The parts of `from`..`to` that no excluded range covers. */
|
||||
function subtractCharacterRanges(
|
||||
from: number,
|
||||
to: number,
|
||||
excluded: readonly (readonly [number, number])[],
|
||||
): [number, number][] {
|
||||
const kept: [number, number][] = [];
|
||||
let next = from;
|
||||
for (const [start, end] of excluded) {
|
||||
if (start > next) kept.push([next, start - 1]);
|
||||
next = end + 1;
|
||||
}
|
||||
if (next <= to) kept.push([next, to]);
|
||||
return kept;
|
||||
}
|
||||
|
||||
const URL_BOUNDARY = formatCharacterRanges(PUNCTUATION_BOUNDARY_RANGES);
|
||||
// Non-ASCII characters a path can contain: everything from U+0080 except boundary punctuation.
|
||||
const PATH_NON_ASCII = formatCharacterRanges(
|
||||
subtractCharacterRanges(0x80, 0xffff, PUNCTUATION_BOUNDARY_RANGES),
|
||||
);
|
||||
|
||||
// Keep this regex in the syntax shared by JavaScript, ICU and java.util.regex.
|
||||
// The Unicode flag makes Metro expand it to escapes rejected by native engines.
|
||||
const PATH_CHARACTER = String.raw`[a-zA-Z0-9\u0080-\uFFFF_@.%+-]`;
|
||||
const PATH_CHARACTER = String.raw`[a-zA-Z0-9${PATH_NON_ASCII}_@.%+-]`;
|
||||
const PATH_LETTER = String.raw`[a-zA-Z]`;
|
||||
const PATH_SEGMENT = String.raw`${PATH_CHARACTER}*[a-zA-Z0-9\u0080-\uFFFF_@%+-]`;
|
||||
const PATH_SEGMENT = String.raw`${PATH_CHARACTER}*[a-zA-Z0-9${PATH_NON_ASCII}_@%+-]`;
|
||||
const LINE_SUFFIX = String.raw`(?::\d+(?::\d+)?(?:-\d+(?::\d+)?)?)?`;
|
||||
const FILE_EXTENSIONS = [...ASSISTANT_FILE_EXTENSIONS]
|
||||
.map((extension) => extension.replace(/[a-z]/g, (letter) => `[${letter}${letter.toUpperCase()}]`))
|
||||
@@ -30,16 +75,13 @@ function createTextPattern(path: string, forgeReferencePattern?: string): RegExp
|
||||
const forgeReference = forgeReferencePattern ? `|${forgeReferencePattern}` : "";
|
||||
// The native adapter mistakes a literal + in lookbehind for a quantifier; use its hex escape.
|
||||
return new RegExp(
|
||||
String.raw`(?:${BARE_URL}${forgeReference}|(?<![a-zA-Z0-9\u0080-\uFFFF_@.%\x2b~:/\\-])(?:${path}|${FILE_NAME})${LINE_SUFFIX}(?![a-zA-Z0-9\u0080-\uFFFF_@%+:/\\-]|\.${PATH_CHARACTER}))`,
|
||||
String.raw`(?:${BARE_URL}${forgeReference}|(?<![a-zA-Z0-9${PATH_NON_ASCII}_@.%\x2b~:/\\-])(?:${path}|${FILE_NAME})${LINE_SUFFIX}(?![a-zA-Z0-9${PATH_NON_ASCII}_@%+:/\\-]|\.${PATH_CHARACTER}))`,
|
||||
"g",
|
||||
);
|
||||
}
|
||||
|
||||
// Matches bare URLs that MD4C does not autolink, like single-label or bracketed hosts.
|
||||
// Quotes and unbalanced closing parentheses end the URL. Trailing sentence punctuation stays outside.
|
||||
// CJK, fullwidth and typographic punctuation (、。,()【】「」“”…) also ends it; CJK letters do not.
|
||||
const URL_BOUNDARY =
|
||||
"\\u2018\\u2019\\u201C\\u201D\\u2026\\u3000-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\uFF01-\\uFF0F\\uFF1A-\\uFF20\\uFF3B-\\uFF40\\uFF5B-\\uFF65";
|
||||
const URL_CHARACTER = String.raw`[^\s<>()"'\x60${URL_BOUNDARY}]`;
|
||||
const URL_GROUP = String.raw`\(${URL_CHARACTER}*\)`;
|
||||
const BARE_URL = String.raw`https?://(?:${URL_CHARACTER}|${URL_GROUP})*(?:[^\s<>()"'\x60.,;:!?${URL_BOUNDARY}]|${URL_GROUP})`;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useCallback, type ReactNode, type RefObject } from "react";
|
||||
import type { View } from "react-native";
|
||||
import { MenuRoot, useMenuContext } from "@/components/ui/menu";
|
||||
import { PluginPopoverSurface } from "@/plugins/popover";
|
||||
import type { ReactNode } from "react";
|
||||
import { MenuRoot } from "@/components/ui/menu";
|
||||
import { PluginPopoverSurface, usePluginPopoverAnchor } from "@/plugins/popover";
|
||||
import type { SidebarSection } from "@/sidebar-nav/model";
|
||||
|
||||
/**
|
||||
@@ -26,41 +25,7 @@ export function SidebarPopoverRoot({
|
||||
);
|
||||
}
|
||||
|
||||
function assignRef(ref: RefObject<View | null>, node: View | null) {
|
||||
Object.assign(ref, { current: node });
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the popover anchors. `anchorTo` moves it to an element, such as the row just pressed;
|
||||
* `offerAnchor` sets it only when nothing is anchored; `releaseAnchor` drops an element that is
|
||||
* going away; `anchorToFallback` covers an item that anchored nothing.
|
||||
*/
|
||||
export function useSidebarPopoverAnchor(name: string): {
|
||||
anchorTo: (node: View | null) => void;
|
||||
offerAnchor: (node: View | null) => void;
|
||||
releaseAnchor: (node: View | null) => void;
|
||||
anchorToFallback: (fallback: RefObject<View | null>) => void;
|
||||
} {
|
||||
const { triggerRef } = useMenuContext(name);
|
||||
const anchorTo = useCallback((node: View | null) => assignRef(triggerRef, node), [triggerRef]);
|
||||
const offerAnchor = useCallback(
|
||||
(node: View | null) => {
|
||||
if (!triggerRef.current) assignRef(triggerRef, node);
|
||||
},
|
||||
[triggerRef],
|
||||
);
|
||||
const releaseAnchor = useCallback(
|
||||
(node: View | null) => {
|
||||
if (triggerRef.current === node) assignRef(triggerRef, null);
|
||||
},
|
||||
[triggerRef],
|
||||
);
|
||||
const anchorToFallback = useCallback(
|
||||
(fallback: RefObject<View | null>) => offerAnchor(fallback.current),
|
||||
[offerAnchor],
|
||||
);
|
||||
return { anchorTo, offerAnchor, releaseAnchor, anchorToFallback };
|
||||
}
|
||||
export const useSidebarPopoverAnchor = usePluginPopoverAnchor;
|
||||
|
||||
const PLACEMENT = {
|
||||
header: { side: "right", align: "start" },
|
||||
|
||||
@@ -252,13 +252,7 @@ export function SplitContainer({
|
||||
const renderRoot = useMemo(() => wrapRootPaneForStableMount(splitRoot.root), [splitRoot.root]);
|
||||
const panesShareWorkspaceHeader = hasMultipleVisiblePanes(splitRoot.root);
|
||||
const sharedCompactHeader = useMemo(
|
||||
() =>
|
||||
panesShareWorkspaceHeader ? (
|
||||
<WindowChromeSafeArea placement="inline">
|
||||
<TitlebarDragRegion />
|
||||
{renderCompactHeader(null)}
|
||||
</WindowChromeSafeArea>
|
||||
) : null,
|
||||
() => (panesShareWorkspaceHeader ? renderCompactHeader(null) : null),
|
||||
[panesShareWorkspaceHeader, renderCompactHeader],
|
||||
);
|
||||
return (
|
||||
@@ -800,16 +794,13 @@ const SplitPaneView = memo(function SplitPaneView({
|
||||
});
|
||||
const compactHeader = useMemo(
|
||||
() =>
|
||||
ownsWorkspaceHeader ? (
|
||||
<WindowChromeSafeArea placement="inline">
|
||||
<TitlebarDragRegion />
|
||||
{renderCompactHeader({
|
||||
ownsWorkspaceHeader
|
||||
? renderCompactHeader({
|
||||
tabs: paneTabs,
|
||||
activeTabKey: activeTabDescriptor?.key ?? "",
|
||||
actions: compactHeaderActions,
|
||||
})}
|
||||
</WindowChromeSafeArea>
|
||||
) : null,
|
||||
})
|
||||
: null,
|
||||
[
|
||||
ownsWorkspaceHeader,
|
||||
renderCompactHeader,
|
||||
|
||||
@@ -18,6 +18,21 @@ export function Checkbox({ checked }: { checked: boolean }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** React Native Web checkboxes need an explicit Space handler when built on Pressable. */
|
||||
export function useCheckboxSpaceKey(onToggle: () => void, disabled: boolean) {
|
||||
return useMemo(() => {
|
||||
if (!isWeb || disabled) return {};
|
||||
return {
|
||||
onKeyDown: (event: { key?: string; preventDefault?: () => void }) => {
|
||||
if (event.key === " " || event.key === "Spacebar") {
|
||||
event.preventDefault?.();
|
||||
onToggle();
|
||||
}
|
||||
},
|
||||
};
|
||||
}, [disabled, onToggle]);
|
||||
}
|
||||
|
||||
interface HoverState {
|
||||
hovered?: boolean;
|
||||
}
|
||||
@@ -48,18 +63,7 @@ export function CheckboxRow({
|
||||
({ hovered }: HoverState) => [style, hovered && !disabled ? styles.hovered : null],
|
||||
[disabled, style],
|
||||
);
|
||||
const keyProps = useMemo(() => {
|
||||
if (!isWeb || disabled) return {};
|
||||
return {
|
||||
// React Native Web's Pressable activates Space only for role="button", not checkbox.
|
||||
onKeyDown: (event: { key?: string; preventDefault?: () => void }) => {
|
||||
if (event.key === " " || event.key === "Spacebar") {
|
||||
event.preventDefault?.();
|
||||
onToggle();
|
||||
}
|
||||
},
|
||||
};
|
||||
}, [disabled, onToggle]);
|
||||
const keyProps = useCheckboxSpaceKey(onToggle, disabled);
|
||||
|
||||
return (
|
||||
<PressHighlight
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "react";
|
||||
import { StyleSheet, View } from "react-native";
|
||||
import { PortalHost } from "@gorhom/portal";
|
||||
import { WINDOW_OVERLAY_HOST_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
import {
|
||||
createFloatingPanelHosts,
|
||||
type FloatingPanelHostRect,
|
||||
@@ -57,7 +58,13 @@ export function FloatingPanelPortalHost({
|
||||
}, [name]);
|
||||
|
||||
return (
|
||||
<View ref={hostRef} collapsable={false} pointerEvents="box-none" style={styles.host}>
|
||||
<View
|
||||
ref={hostRef}
|
||||
collapsable={false}
|
||||
dataSet={WINDOW_OVERLAY_HOST_DATASET}
|
||||
pointerEvents="box-none"
|
||||
style={styles.host}
|
||||
>
|
||||
<PortalHost name={name} />
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Image } from "expo-image";
|
||||
import { View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { Platform, View, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import type { ViewportFitOptions, ViewportSize } from "./geometry";
|
||||
import { measureImage } from "./image-size";
|
||||
@@ -84,7 +84,9 @@ export function ZoomableImage({
|
||||
<ViewportImage
|
||||
// No transition, so the image appears together with its toolbar.
|
||||
transition={null}
|
||||
contentFit="contain"
|
||||
// The viewport already fits the image's aspect ratio. On Android, fill selects
|
||||
// Expo Image's bitmap size cap while preserving detail below that cap for zoom.
|
||||
contentFit={Platform.OS === "android" ? "fill" : "contain"}
|
||||
onError={onError}
|
||||
onLoad={handleLoad}
|
||||
source={source}
|
||||
|
||||
@@ -185,6 +185,13 @@ export function ComposerEditingScope({
|
||||
const scope = useMemo(() => ({ tabId, targetKey }), [tabId, targetKey]);
|
||||
return <ScopeContext.Provider value={scope}>{children}</ScopeContext.Provider>;
|
||||
}
|
||||
/**
|
||||
* Composers inside edit in sessions of their own, apart from the workspace tab around them: a
|
||||
* plugin's `AgentChat` in a panel must not share the panel's fullscreen, caret or command target.
|
||||
*/
|
||||
export function LocalComposerEditingScope({ children }: { children: ReactNode }) {
|
||||
return <ScopeContext.Provider value={null}>{children}</ScopeContext.Provider>;
|
||||
}
|
||||
export function useComposerEditingSession(
|
||||
purpose: ComposerInputMode,
|
||||
provided?: ComposerEditingSession,
|
||||
|
||||
@@ -80,6 +80,7 @@ interface SearchCall {
|
||||
}
|
||||
|
||||
interface HarnessInput {
|
||||
enabled?: boolean;
|
||||
initialAttachments?: UserComposerAttachment[];
|
||||
initialCwd?: string;
|
||||
initialText?: string;
|
||||
@@ -137,6 +138,7 @@ function useHarness(client: ForgeSearchClient, input: HarnessInput = {}) {
|
||||
input.initialAttachments ?? [],
|
||||
);
|
||||
const autoAttach = useComposerForgeAutoAttach({
|
||||
enabled: input.enabled ?? true,
|
||||
text,
|
||||
remoteUrl: input.remote ?? remoteUrl,
|
||||
attachments,
|
||||
@@ -190,6 +192,27 @@ describe("useComposerForgeAutoAttach", () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("leaves pasted links as text in a composer that takes no attachments", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = createSearchClient([pr101]);
|
||||
const onChangeRequestDetected = vi.fn();
|
||||
const { result } = renderHook(
|
||||
() => useHarness(client, { enabled: false, onChangeRequestDetected }),
|
||||
{ wrapper: createWrapper() },
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.setText("Please review https://github.com/acme/paseo/pull/101");
|
||||
});
|
||||
expect(result.current.isResolving).toBe(false);
|
||||
await flushDebounce();
|
||||
|
||||
expect(result.current.attachments).toEqual([]);
|
||||
expect(onChangeRequestDetected).not.toHaveBeenCalled();
|
||||
expect(client.calls).toEqual([]);
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("adds a matching pasted GitLab MR URL as a composer attachment", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = createSearchClient([gitlabMr73]);
|
||||
|
||||
@@ -19,6 +19,8 @@ import { forgeItemKey } from "./attachments/forge-item-key";
|
||||
const AUTO_ATTACH_DEBOUNCE_MS = 300;
|
||||
|
||||
interface ComposerForgeAutoAttachInput {
|
||||
/** Whether links in the text become attachments: off for a composer that takes none. */
|
||||
enabled: boolean;
|
||||
text: string;
|
||||
remoteUrl: string | null | undefined;
|
||||
attachments: UserComposerAttachment[];
|
||||
@@ -164,6 +166,11 @@ export function useComposerForgeAutoAttach(
|
||||
);
|
||||
}
|
||||
|
||||
/** The forge links in the text that auto-attach would act on. */
|
||||
function linkedForgeRefs(params: ComposerForgeAutoAttachInput): ForgeRef[] {
|
||||
return params.enabled ? extractForgeRefs(params.text, params.remoteUrl) : [];
|
||||
}
|
||||
|
||||
function getLookupCandidateKey(
|
||||
params: ComposerForgeAutoAttachInput,
|
||||
removedRefKeys: ReadonlySet<string>,
|
||||
@@ -175,7 +182,7 @@ function getLookupCandidateRefs(
|
||||
params: ComposerForgeAutoAttachInput,
|
||||
removedRefKeys: ReadonlySet<string>,
|
||||
): ForgeRef[] {
|
||||
return extractForgeRefs(params.text, params.remoteUrl).filter((ref) => {
|
||||
return linkedForgeRefs(params).filter((ref) => {
|
||||
const key = forgeRefKey(ref);
|
||||
return !removedRefKeys.has(key) && !hasForgeAttachment(params.attachments, ref);
|
||||
});
|
||||
@@ -196,7 +203,7 @@ function getLookupRelevanceKey(
|
||||
params: ComposerForgeAutoAttachInput,
|
||||
removedRefKeys: ReadonlySet<string>,
|
||||
): string {
|
||||
return extractForgeRefs(params.text, params.remoteUrl)
|
||||
return linkedForgeRefs(params)
|
||||
.map(forgeRefKey)
|
||||
.filter((key) => !removedRefKeys.has(key))
|
||||
.sort()
|
||||
@@ -204,7 +211,7 @@ function getLookupRelevanceKey(
|
||||
}
|
||||
|
||||
function getPresentChangeRequestKey(params: ComposerForgeAutoAttachInput): string {
|
||||
return extractForgeRefs(params.text, params.remoteUrl)
|
||||
return linkedForgeRefs(params)
|
||||
.filter((ref) => ref.kind === "change_request")
|
||||
.map(forgeRefKey)
|
||||
.sort()
|
||||
@@ -248,7 +255,7 @@ function suppressRefsCarriedAcrossTargets({
|
||||
previousTargetRef.current = { serverId: params.serverId, cwd: params.cwd };
|
||||
if (!targetChanged) return;
|
||||
|
||||
for (const ref of extractForgeRefs(params.text, params.remoteUrl)) {
|
||||
for (const ref of linkedForgeRefs(params)) {
|
||||
removedRefKeys.add(forgeRefKey(ref));
|
||||
}
|
||||
}
|
||||
@@ -261,7 +268,7 @@ function notifyNewChangeRequestRefs({
|
||||
presentChangeRequestKeysRef: RefObject<Set<string>>;
|
||||
}): void {
|
||||
const currentKeys = new Set(
|
||||
extractForgeRefs(params.text, params.remoteUrl)
|
||||
linkedForgeRefs(params)
|
||||
.filter((ref) => ref.kind === "change_request")
|
||||
.map(forgeRefKey),
|
||||
);
|
||||
@@ -449,7 +456,7 @@ function refsReadyForLookup({
|
||||
return [];
|
||||
}
|
||||
|
||||
return extractForgeRefs(params.text, params.remoteUrl).filter((ref) => {
|
||||
return linkedForgeRefs(params).filter((ref) => {
|
||||
const key = forgeRefKey(ref);
|
||||
return (
|
||||
!removedRefKeys.has(key) &&
|
||||
@@ -489,9 +496,7 @@ async function fetchForgeRefSearch({
|
||||
}
|
||||
|
||||
function isRefStillPresent(ref: ForgeRef, params: ComposerForgeAutoAttachInput): boolean {
|
||||
return extractForgeRefs(params.text, params.remoteUrl).some(
|
||||
(candidate) => forgeRefKey(candidate) === forgeRefKey(ref),
|
||||
);
|
||||
return linkedForgeRefs(params).some((candidate) => forgeRefKey(candidate) === forgeRefKey(ref));
|
||||
}
|
||||
|
||||
function isSameLookupTarget(
|
||||
|
||||
@@ -123,7 +123,10 @@ import { useShortcutKeys } from "@/hooks/use-shortcut-keys";
|
||||
import { AutocompletePopover } from "@/components/ui/autocomplete-popover";
|
||||
import type { AutocompleteOption } from "@/components/ui/autocomplete";
|
||||
import { useAgentAutocomplete } from "@/hooks/use-agent-autocomplete";
|
||||
import { usePluginClientSlashCommands } from "@/plugins/client-slash-commands";
|
||||
import {
|
||||
type PluginClientSlashCommand,
|
||||
usePluginClientSlashCommands,
|
||||
} from "@/plugins/client-slash-commands";
|
||||
import {
|
||||
executePluginClientSlashCommand,
|
||||
resolvePluginClientSlashCommand,
|
||||
@@ -226,6 +229,7 @@ type AttachmentListUpdater =
|
||||
| ((prev: UserComposerAttachment[]) => UserComposerAttachment[]);
|
||||
|
||||
const EMPTY_ATTACHMENT_SCOPE_KEYS: readonly string[] = [];
|
||||
const NO_PLUGIN_CLIENT_SLASH_COMMANDS: PluginClientSlashCommand[] = [];
|
||||
|
||||
function noop() {}
|
||||
const noopCallback = () => {};
|
||||
@@ -1402,6 +1406,8 @@ function ComposerContentImpl({
|
||||
const [isForgeResolving, setIsForgeResolving] = useState(false);
|
||||
const forgeConfiguration = useMemo(
|
||||
() => ({
|
||||
// A mode without attachments sends text as written, so links stay text.
|
||||
enabled: mode.showAttachments,
|
||||
remoteUrl: resolveCheckoutRemoteUrl(checkoutStatusQuery.status),
|
||||
attachments,
|
||||
client,
|
||||
@@ -1414,6 +1420,7 @@ function ComposerContentImpl({
|
||||
onChangeRequestAdded: onForgeChangeRequestAutoAttach,
|
||||
}),
|
||||
[
|
||||
mode.showAttachments,
|
||||
checkoutStatusQuery.status,
|
||||
attachments,
|
||||
client,
|
||||
@@ -1456,11 +1463,16 @@ function ComposerContentImpl({
|
||||
onChangeAttachments: setSelectedAttachments,
|
||||
anchorRef: attachButtonRef,
|
||||
});
|
||||
const pluginClientSlashCommands = usePluginClientSlashCommands({
|
||||
const installedPluginClientSlashCommands = usePluginClientSlashCommands({
|
||||
serverId,
|
||||
workspaceId,
|
||||
agentId,
|
||||
});
|
||||
// One switch for every client-side command, built-in or plugin, on the send and queue paths.
|
||||
const handlesClientCommands = mode.runsClientCommands;
|
||||
const pluginClientSlashCommands = handlesClientCommands
|
||||
? installedPluginClientSlashCommands
|
||||
: NO_PLUGIN_CLIENT_SLASH_COMMANDS;
|
||||
const isComposerLocked = resolveIsComposerLocked(submitBehavior, isSubmitLoading);
|
||||
const keyboardHandlerIdRef = useRef(
|
||||
`message-input:${serverId}:${agentId}:${Math.random().toString(36).slice(2)}`,
|
||||
@@ -1569,6 +1581,7 @@ function ComposerContentImpl({
|
||||
|
||||
const runClientSlashCommand = useCallback(
|
||||
(command: ClientSlashCommand): boolean => {
|
||||
if (!handlesClientCommands) return false;
|
||||
if (command.execution !== "immediate" || !onClientSlashCommand) {
|
||||
return false;
|
||||
}
|
||||
@@ -1595,6 +1608,7 @@ function ComposerContentImpl({
|
||||
[
|
||||
blurOnSubmit,
|
||||
clearDraft,
|
||||
handlesClientCommands,
|
||||
onClientSlashCommand,
|
||||
resetSuppression,
|
||||
setSelectedAttachments,
|
||||
@@ -1631,6 +1645,22 @@ function ComposerContentImpl({
|
||||
[blurOnSubmit, clearDraft, replaceUserInput, resetSuppression, setSelectedAttachments, t],
|
||||
);
|
||||
|
||||
/** Runs `text` as a client command when it is one; false sends it to the agent. */
|
||||
const runComposerClientCommand = useCallback(
|
||||
(text: string, hasAttachments: boolean): boolean => {
|
||||
const clientSlashCommand = resolveClientSlashCommand({ text, hasAttachments });
|
||||
if (clientSlashCommand && runClientSlashCommand(clientSlashCommand)) return true;
|
||||
const pluginSlashCommand = resolvePluginClientSlashCommand({
|
||||
text,
|
||||
commands: pluginClientSlashCommands,
|
||||
});
|
||||
if (!pluginSlashCommand) return false;
|
||||
runPluginClientSlashCommand(pluginSlashCommand, hasAttachments);
|
||||
return true;
|
||||
},
|
||||
[pluginClientSlashCommands, runClientSlashCommand, runPluginClientSlashCommand],
|
||||
);
|
||||
|
||||
const { pickImages } = useImageAttachmentPicker();
|
||||
const { pickFiles } = useFilePicker();
|
||||
const agentIdRef = useRef(agentId);
|
||||
@@ -1923,21 +1953,7 @@ function ComposerContentImpl({
|
||||
const handleSubmit = useCallback(
|
||||
(payload: MessagePayload) => {
|
||||
const outgoingAttachments = buildOutgoingAttachments(attachments);
|
||||
const clientSlashCommand = resolveClientSlashCommand({
|
||||
text: payload.text,
|
||||
hasAttachments: outgoingAttachments.length > 0,
|
||||
});
|
||||
if (clientSlashCommand && runClientSlashCommand(clientSlashCommand)) {
|
||||
return;
|
||||
}
|
||||
const pluginSlashCommand = resolvePluginClientSlashCommand({
|
||||
text: payload.text,
|
||||
commands: pluginClientSlashCommands,
|
||||
});
|
||||
if (pluginSlashCommand) {
|
||||
runPluginClientSlashCommand(pluginSlashCommand, outgoingAttachments.length > 0);
|
||||
return;
|
||||
}
|
||||
if (runComposerClientCommand(payload.text, outgoingAttachments.length > 0)) return;
|
||||
|
||||
if (blurOnSubmit) {
|
||||
messageInputRef.current?.blur();
|
||||
@@ -1948,9 +1964,7 @@ function ComposerContentImpl({
|
||||
attachments,
|
||||
blurOnSubmit,
|
||||
buildOutgoingAttachments,
|
||||
runClientSlashCommand,
|
||||
pluginClientSlashCommands,
|
||||
runPluginClientSlashCommand,
|
||||
runComposerClientCommand,
|
||||
sendMessageWithContent,
|
||||
],
|
||||
);
|
||||
@@ -2191,31 +2205,10 @@ function ComposerContentImpl({
|
||||
const handleQueue = useCallback(
|
||||
(payload: MessagePayload) => {
|
||||
const outgoingAttachments = buildOutgoingAttachments(attachments);
|
||||
const clientSlashCommand = resolveClientSlashCommand({
|
||||
text: payload.text,
|
||||
hasAttachments: outgoingAttachments.length > 0,
|
||||
});
|
||||
if (clientSlashCommand && runClientSlashCommand(clientSlashCommand)) {
|
||||
return;
|
||||
}
|
||||
const pluginSlashCommand = resolvePluginClientSlashCommand({
|
||||
text: payload.text,
|
||||
commands: pluginClientSlashCommands,
|
||||
});
|
||||
if (pluginSlashCommand) {
|
||||
runPluginClientSlashCommand(pluginSlashCommand, outgoingAttachments.length > 0);
|
||||
return;
|
||||
}
|
||||
if (runComposerClientCommand(payload.text, outgoingAttachments.length > 0)) return;
|
||||
void sendMessageWithContent(payload.text, outgoingAttachments);
|
||||
},
|
||||
[
|
||||
attachments,
|
||||
buildOutgoingAttachments,
|
||||
pluginClientSlashCommands,
|
||||
runClientSlashCommand,
|
||||
runPluginClientSlashCommand,
|
||||
sendMessageWithContent,
|
||||
],
|
||||
[attachments, buildOutgoingAttachments, runComposerClientCommand, sendMessageWithContent],
|
||||
);
|
||||
|
||||
// An open autocomplete owns the arrows; otherwise they may recall sent messages.
|
||||
@@ -2305,9 +2298,10 @@ function ComposerContentImpl({
|
||||
],
|
||||
);
|
||||
|
||||
const showsUsage = mode.showUsage;
|
||||
const beforeVoiceContent = useMemo(
|
||||
() =>
|
||||
hasAgent ? (
|
||||
hasAgent && showsUsage ? (
|
||||
<View style={styles.contextWindowMeterSlot}>
|
||||
<ContextWindowMeter
|
||||
serverId={serverId}
|
||||
@@ -2322,6 +2316,7 @@ function ComposerContentImpl({
|
||||
) : null,
|
||||
[
|
||||
hasAgent,
|
||||
showsUsage,
|
||||
serverId,
|
||||
agentId,
|
||||
agentState.contextWindowMaxTokens,
|
||||
@@ -2615,7 +2610,8 @@ function ComposerContentImpl({
|
||||
onGenericFiles: handleGenericFilesDropped,
|
||||
onWorkspaceFile: handleWorkspaceFileDropped,
|
||||
},
|
||||
{ disabled: isSubmitLoadingVisible },
|
||||
// A mode without attachments refuses files by any route, not only the button.
|
||||
{ disabled: isSubmitLoadingVisible || !mode.showAttachments },
|
||||
);
|
||||
|
||||
// Focusing the composer on a touch screen raises the on-screen keyboard over the conversation.
|
||||
@@ -2713,9 +2709,9 @@ function ComposerContentImpl({
|
||||
cwd={cwd}
|
||||
attachmentMenuItems={attachmentMenuItems}
|
||||
onAttachButtonRef={handleAttachButtonRef}
|
||||
onAddImages={addImages}
|
||||
onPasteFiles={handlePasteFiles}
|
||||
onPasteImages={handleNativePasteImages}
|
||||
onAddImages={mode.showAttachments ? addImages : undefined}
|
||||
onPasteFiles={mode.showAttachments ? handlePasteFiles : undefined}
|
||||
onPasteImages={mode.showAttachments ? handleNativePasteImages : undefined}
|
||||
client={client}
|
||||
isReadyForDictation={isDictationReady}
|
||||
placeholder={messagePlaceholder}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
* What a composer is being used for. `Composer` and `MessageInput` are one
|
||||
* component with two jobs, not two components: a terminal prompt still wants
|
||||
* component with several jobs, not several components: a terminal prompt still wants
|
||||
* the same bordered surface, grow-on-newline, submit button, focus handling,
|
||||
* and keyboard shift that a chat message gets.
|
||||
*
|
||||
* `message` is a chat composer reduced to a text box and Send: what the user types
|
||||
* reaches the agent as written, with nothing the app interprets on the way.
|
||||
*
|
||||
* Callers pick a mode and nothing else. What a mode implies lives here, so the
|
||||
* two presentations cannot drift apart one prop at a time.
|
||||
* presentations cannot drift apart one prop at a time.
|
||||
*/
|
||||
export type ComposerInputMode = "chat" | "terminal";
|
||||
export type ComposerInputMode = "chat" | "message" | "terminal";
|
||||
|
||||
export interface ComposerInputModePresentation {
|
||||
/** Attachments, dictation/voice, slash-and-@ autocomplete, and the model/mode
|
||||
@@ -16,6 +19,11 @@ export interface ComposerInputModePresentation {
|
||||
showVoice: boolean;
|
||||
showAutocomplete: boolean;
|
||||
showAgentControls: boolean;
|
||||
/** The context window and cost meter beside Send. */
|
||||
showUsage: boolean;
|
||||
/** Client slash commands, built-in (`/exit`, `/clear`) and plugin, run in the
|
||||
* app instead of being sent. */
|
||||
runsClientCommands: boolean;
|
||||
/** Argv is read character by character, so it gets the terminal's own font. */
|
||||
isMonospace: boolean;
|
||||
/** i18n key for the text input's accessible name. */
|
||||
@@ -28,6 +36,18 @@ const PRESENTATION_BY_MODE: Record<ComposerInputMode, ComposerInputModePresentat
|
||||
showVoice: true,
|
||||
showAutocomplete: true,
|
||||
showAgentControls: true,
|
||||
showUsage: true,
|
||||
runsClientCommands: true,
|
||||
isMonospace: false,
|
||||
accessibilityLabelKey: "composer.input.accessibilityLabel",
|
||||
},
|
||||
message: {
|
||||
showAttachments: false,
|
||||
showVoice: false,
|
||||
showAutocomplete: false,
|
||||
showAgentControls: false,
|
||||
showUsage: false,
|
||||
runsClientCommands: false,
|
||||
isMonospace: false,
|
||||
accessibilityLabelKey: "composer.input.accessibilityLabel",
|
||||
},
|
||||
@@ -36,6 +56,8 @@ const PRESENTATION_BY_MODE: Record<ComposerInputMode, ComposerInputModePresentat
|
||||
showVoice: false,
|
||||
showAutocomplete: false,
|
||||
showAgentControls: false,
|
||||
showUsage: false,
|
||||
runsClientCommands: true,
|
||||
isMonospace: true,
|
||||
accessibilityLabelKey: "composer.input.terminalAccessibilityLabel",
|
||||
},
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { useCallback, useMemo, useState, type ReactElement, type ReactNode } from "react";
|
||||
import {
|
||||
useCallback,
|
||||
useMemo,
|
||||
useState,
|
||||
type ReactElement,
|
||||
type ReactNode,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { GestureDetector } from "react-native-gesture-handler";
|
||||
import Animated from "react-native-reanimated";
|
||||
@@ -42,12 +49,18 @@ import { COMPOSER_PILL_CLEARANCE, composerPillStyles } from "./pill-styles";
|
||||
* or without pills: that keeps the final footer clear, and pills that come and go every turn do not
|
||||
* move the transcript.
|
||||
*/
|
||||
export function ComposerTrackBar({ children }: { children: ReactNode }): ReactElement {
|
||||
export function ComposerTrackBar({
|
||||
children,
|
||||
trackViewportRef,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
trackViewportRef?: RefObject<View | null>;
|
||||
}): ReactElement {
|
||||
const scrollGesture = usePanelAwareHorizontalScrollGesture();
|
||||
const scrollBoundary = useHorizontalScrollBoundary();
|
||||
return (
|
||||
<View style={styles.bar} dataSet={CHAT_COLUMN_RAIL_DATASET} pointerEvents="box-none">
|
||||
<View style={styles.trackViewport} pointerEvents="box-none">
|
||||
<View ref={trackViewportRef} style={styles.trackViewport} pointerEvents="box-none">
|
||||
<GestureDetector gesture={scrollGesture}>
|
||||
<Animated.ScrollView
|
||||
testID="composer-track-scroll"
|
||||
|
||||
@@ -2,8 +2,9 @@ import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import type { SessionInboundMessage, SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
||||
import { createJSONStorage, type StateStorage } from "zustand/middleware";
|
||||
import { mountBrowserAutomationHandler, type BrowserAutomationHandlerOptions } from "./handler";
|
||||
import type { DesktopHostBridge } from "@/desktop/host";
|
||||
import type { DesktopAutomationExecutionContext, DesktopHostBridge } from "@/desktop/host";
|
||||
import { useBrowserStore } from "@/desktop/browser/store";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { findPaneById } from "@/stores/workspace-layout-actions";
|
||||
import { useWorkspaceLayoutStore } from "@/stores/workspace-layout-store";
|
||||
import { buildWorkspaceTabPersistenceKey } from "@/workspace-tabs/model";
|
||||
@@ -72,9 +73,11 @@ class FakeDaemonClient {
|
||||
|
||||
class FakeBrowserBridge {
|
||||
public readonly executedRequests: BrowserAutomationExecuteRequest[] = [];
|
||||
public readonly executedContexts: DesktopAutomationExecutionContext[] = [];
|
||||
public readonly unregisteredWorkspaceBrowsers: string[] = [];
|
||||
public readonly activeWorkspaceBrowsers: Array<{
|
||||
browserId: string | null;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}> = [];
|
||||
public response: BrowserAutomationResponsePayload | null = null;
|
||||
@@ -82,8 +85,10 @@ class FakeBrowserBridge {
|
||||
|
||||
public executeAutomationCommand = async (
|
||||
request: BrowserAutomationExecuteRequest,
|
||||
context: DesktopAutomationExecutionContext,
|
||||
): Promise<BrowserAutomationResponsePayload> => {
|
||||
this.executedRequests.push(request);
|
||||
this.executedContexts.push(context);
|
||||
if (this.thrownError) {
|
||||
throw this.thrownError;
|
||||
}
|
||||
@@ -96,6 +101,7 @@ class FakeBrowserBridge {
|
||||
|
||||
public setWorkspaceActiveBrowser = async (input: {
|
||||
browserId: string | null;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}): Promise<void> => {
|
||||
this.activeWorkspaceBrowsers.push(input);
|
||||
@@ -105,6 +111,7 @@ class FakeBrowserBridge {
|
||||
class FakeResidentBrowser {
|
||||
public readonly ensuredWebviews: Array<{
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
url: string;
|
||||
partition?: string;
|
||||
@@ -112,6 +119,7 @@ class FakeResidentBrowser {
|
||||
|
||||
public ensure = (input: {
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
url: string;
|
||||
partition?: string;
|
||||
@@ -131,20 +139,22 @@ class BrowserAutomationHandlerHarness {
|
||||
input: {
|
||||
serverId?: string;
|
||||
host?: DesktopHostBridge | null;
|
||||
readHostBrowserRouting?: BrowserAutomationHandlerOptions["readHostBrowserRouting"];
|
||||
readHostBrowserRouting?: BrowserAutomationHandlerOptions["readHostBrowserRouting"] | null;
|
||||
prepareHostBrowserPartition?: BrowserAutomationHandlerOptions["prepareHostBrowserPartition"];
|
||||
registrationWaitTimeoutMs?: number;
|
||||
registrationPollIntervalMs?: number;
|
||||
} = {},
|
||||
): void {
|
||||
const readHostBrowserRouting =
|
||||
input.readHostBrowserRouting === null
|
||||
? undefined
|
||||
: (input.readHostBrowserRouting ?? (() => ({ kind: "local" as const })));
|
||||
this.unsubscribe = mountBrowserAutomationHandler({
|
||||
client: this.client,
|
||||
...(input.serverId ? { serverId: input.serverId } : {}),
|
||||
getHost: () => (input.host === undefined ? { browser: this.browser } : input.host),
|
||||
ensureResidentBrowserWebview: this.resident.ensure,
|
||||
...(input.readHostBrowserRouting
|
||||
? { readHostBrowserRouting: input.readHostBrowserRouting }
|
||||
: {}),
|
||||
...(readHostBrowserRouting ? { readHostBrowserRouting } : {}),
|
||||
...(input.prepareHostBrowserPartition
|
||||
? { prepareHostBrowserPartition: input.prepareHostBrowserPartition }
|
||||
: {}),
|
||||
@@ -167,10 +177,14 @@ class BrowserAutomationHandlerHarness {
|
||||
}
|
||||
}
|
||||
|
||||
function browserAutomationRequest(): BrowserAutomationExecuteRequest {
|
||||
function browserAutomationRequest(input?: {
|
||||
workspaceId?: string;
|
||||
}): BrowserAutomationExecuteRequest {
|
||||
const workspaceId = input && "workspaceId" in input ? input.workspaceId : "wks_workspace_a";
|
||||
return {
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-1",
|
||||
...(workspaceId ? { workspaceId } : {}),
|
||||
command: { command: "list_tabs", args: {} },
|
||||
};
|
||||
}
|
||||
@@ -294,6 +308,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
browserAutomationStorage.clear();
|
||||
useBrowserStore.setState({ browsersById: {} });
|
||||
useWorkspaceLayoutStore.setState({ layoutByWorkspace: {} });
|
||||
useSessionStore.setState({ sessions: {} });
|
||||
});
|
||||
|
||||
test("browser_new_tab creates a workspace browser tab without stealing focus", async () => {
|
||||
@@ -338,6 +353,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
expect(browser.resident.ensuredWebviews).toEqual([
|
||||
{
|
||||
browserId: result.browserId,
|
||||
serverId: "server-1",
|
||||
workspaceId: "wks_workspace_a",
|
||||
url: "https://example.com",
|
||||
},
|
||||
@@ -543,13 +559,14 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
ok: true,
|
||||
result: { command: "list_tabs", tabs: [] },
|
||||
};
|
||||
browser.mount();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
const request = browserAutomationRequest();
|
||||
|
||||
browser.receive(request);
|
||||
await flushAsyncWork();
|
||||
|
||||
expect(browser.browser.executedRequests).toEqual([request]);
|
||||
expect(browser.browser.executedContexts).toEqual([{ serverId: "server-1", uploadRoot: null }]);
|
||||
expect(browser.client.sentResponses).toEqual([
|
||||
{
|
||||
type: "browser.automation.execute.response",
|
||||
@@ -564,7 +581,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
|
||||
test("missing desktop bridge sends browser_unsupported", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount({ host: null });
|
||||
browser.mount({ serverId: "server-1", host: null });
|
||||
|
||||
browser.receive(browserAutomationRequest());
|
||||
await flushAsyncWork();
|
||||
@@ -592,7 +609,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
message: "Browser tab browser-1 was not found.",
|
||||
retryable: false,
|
||||
};
|
||||
browser.mount();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
|
||||
browser.receive(browserAutomationRequest());
|
||||
await flushAsyncWork();
|
||||
@@ -618,7 +635,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
browser.browser.thrownError = new Error(
|
||||
'No handler registered for "paseo:browser:execute-automation-command"',
|
||||
);
|
||||
browser.mount();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
|
||||
browser.receive(browserAutomationRequest());
|
||||
await flushAsyncWork();
|
||||
@@ -641,7 +658,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
|
||||
test("unsubscribe stops handling browser automation requests", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
|
||||
browser.unmount();
|
||||
browser.receive(browserAutomationRequest());
|
||||
@@ -680,6 +697,7 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
expect(browser.resident.ensuredWebviews).toEqual([
|
||||
{
|
||||
browserId: result.browserId,
|
||||
serverId: "remote-1",
|
||||
workspaceId: "wks_workspace_a",
|
||||
url: "http://localhost:5173",
|
||||
partition: "persist:paseo-browser-host-0123456789abcdef",
|
||||
@@ -687,6 +705,165 @@ describe("mountBrowserAutomationHandler", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("browser_resize fails closed when workspaceId is omitted", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
|
||||
browser.receive(browserNewTabRequest());
|
||||
await vi.waitFor(() => expect(browser.client.sentResponses).toHaveLength(1));
|
||||
const result = newTabResultFrom(browser.client.payloadAt(0));
|
||||
|
||||
browser.receive({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-resize-no-ws",
|
||||
agentId: "agent-1",
|
||||
command: {
|
||||
command: "resize",
|
||||
args: { browserId: result.browserId, width: 800, height: 600 },
|
||||
},
|
||||
});
|
||||
await flushAsyncWork();
|
||||
|
||||
expect(browser.client.payloadAt(1)).toEqual({
|
||||
requestId: "req-resize-no-ws",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_denied",
|
||||
message: expect.stringMatching(/workspace/i),
|
||||
retryable: false,
|
||||
},
|
||||
});
|
||||
expect(useBrowserStore.getState().browsersById[result.browserId]?.viewport).toEqual({
|
||||
mode: "responsive",
|
||||
});
|
||||
});
|
||||
|
||||
test("forwarded commands fail closed when workspaceId is omitted", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount({ serverId: "server-1" });
|
||||
|
||||
browser.receive(browserAutomationRequest({ workspaceId: "" }));
|
||||
await flushAsyncWork();
|
||||
|
||||
expect(browser.browser.executedRequests).toEqual([]);
|
||||
expect(browser.client.payloadAt(0)).toEqual({
|
||||
requestId: "req-1",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_denied",
|
||||
message: expect.stringMatching(/workspace/i),
|
||||
retryable: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("passes uploadRoot from session-store for local hosts and null for remote hosts", async () => {
|
||||
const store = useSessionStore.getState();
|
||||
store.initializeSession("local-1", null);
|
||||
store.mergeWorkspaces("local-1", [
|
||||
{
|
||||
id: "wks_workspace_a",
|
||||
projectId: "proj-1",
|
||||
projectDisplayName: "Project",
|
||||
projectRootPath: "/Users/dev/project",
|
||||
workspaceDirectory: "/Users/dev/project",
|
||||
projectKind: "git",
|
||||
workspaceKind: "directory",
|
||||
name: "Project",
|
||||
title: "Project",
|
||||
status: "done",
|
||||
statusEnteredAt: null,
|
||||
createdAt: null,
|
||||
lastUserMessageAt: null,
|
||||
archivingAt: null,
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
},
|
||||
]);
|
||||
store.initializeSession("remote-1", null);
|
||||
store.mergeWorkspaces("remote-1", [
|
||||
{
|
||||
id: "wks_workspace_a",
|
||||
projectId: "proj-2",
|
||||
projectDisplayName: "Remote Project",
|
||||
projectRootPath: "/home/remote/project",
|
||||
workspaceDirectory: "/home/remote/project",
|
||||
projectKind: "git",
|
||||
workspaceKind: "directory",
|
||||
name: "Remote Project",
|
||||
title: "Remote Project",
|
||||
status: "done",
|
||||
statusEnteredAt: null,
|
||||
createdAt: null,
|
||||
lastUserMessageAt: null,
|
||||
archivingAt: null,
|
||||
diffStat: null,
|
||||
scripts: [],
|
||||
},
|
||||
]);
|
||||
|
||||
const uploadRequest: BrowserAutomationExecuteRequest = {
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: "req-upload",
|
||||
workspaceId: "wks_workspace_a",
|
||||
cwd: "/Users/dev/project",
|
||||
command: {
|
||||
command: "upload",
|
||||
args: {
|
||||
browserId: "11111111-1111-4111-8111-111111111111",
|
||||
ref: "@e1",
|
||||
filePaths: ["a.txt"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const localHarness = new BrowserAutomationHandlerHarness();
|
||||
localHarness.mount({
|
||||
serverId: "local-1",
|
||||
readHostBrowserRouting: () => ({ kind: "local" }),
|
||||
});
|
||||
localHarness.receive(uploadRequest);
|
||||
await flushAsyncWork();
|
||||
expect(localHarness.browser.executedContexts).toEqual([
|
||||
{ serverId: "local-1", uploadRoot: "/Users/dev/project" },
|
||||
]);
|
||||
|
||||
const remoteHarness = new BrowserAutomationHandlerHarness();
|
||||
remoteHarness.mount({
|
||||
serverId: "remote-1",
|
||||
readHostBrowserRouting: () => ({
|
||||
kind: "remote",
|
||||
support: "supported",
|
||||
target: "tcp://10.0.0.5:6767",
|
||||
}),
|
||||
});
|
||||
remoteHarness.receive(uploadRequest);
|
||||
await flushAsyncWork();
|
||||
expect(remoteHarness.browser.executedContexts).toEqual([
|
||||
{ serverId: "remote-1", uploadRoot: null },
|
||||
]);
|
||||
});
|
||||
|
||||
test("browser_new_tab on an unhydrated host fails closed without opening a local webview", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount({
|
||||
serverId: "unhydrated-host-id",
|
||||
readHostBrowserRouting: null,
|
||||
});
|
||||
|
||||
browser.receive(browserNewTabRequest({ url: "http://localhost:5173" }));
|
||||
await flushAsyncWork();
|
||||
|
||||
expect(browser.resident.ensuredWebviews).toEqual([]);
|
||||
expect(browser.client.payloadAt(0)).toMatchObject({
|
||||
requestId: "req-new",
|
||||
ok: false,
|
||||
error: {
|
||||
code: "browser_unsupported",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("remote agent browser_new_tab fails closed without creating a webview when host proxy cannot prepare", async () => {
|
||||
const browser = new BrowserAutomationHandlerHarness();
|
||||
browser.mount({
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { BROWSER_AUTOMATION_COMMAND_NAMES } from "@getpaseo/protocol/browser-automation/rpc-schemas";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { SessionInboundMessage, SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
||||
import { getDesktopHost, type DesktopHostBridge } from "@/desktop/host";
|
||||
import {
|
||||
getDesktopHost,
|
||||
type DesktopAutomationExecutionContext,
|
||||
type DesktopHostBridge,
|
||||
} from "@/desktop/host";
|
||||
import {
|
||||
ensureResidentBrowserWebview as ensureResidentBrowserWebviewDefault,
|
||||
removeResidentBrowserWebview,
|
||||
@@ -20,6 +24,7 @@ import {
|
||||
useBrowserStore,
|
||||
waitForBrowserHydration,
|
||||
} from "@/desktop/browser/store";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { collectAllTabs, useWorkspaceLayoutStore } from "@/stores/workspace-layout-store";
|
||||
import { buildWorkspaceTabPersistenceKey } from "@/workspace-tabs/model";
|
||||
|
||||
@@ -213,17 +218,70 @@ async function handleBrowserAutomationRequest(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendBrowserAutomationExecuteResponse({
|
||||
type: "browser.automation.execute.response",
|
||||
payload: await forwardAutomationRequest({
|
||||
request,
|
||||
serverId,
|
||||
executeAutomationCommand,
|
||||
readHostBrowserRouting,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
function resolveWorkspaceUploadRoot(input: {
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
readHostBrowserRouting: typeof readHostBrowserRoutingDefault;
|
||||
}): string | null {
|
||||
if (input.readHostBrowserRouting(input.serverId).kind !== "local") {
|
||||
return null;
|
||||
}
|
||||
const directory = useSessionStore
|
||||
.getState()
|
||||
.sessions[input.serverId]?.workspaces.get(input.workspaceId)
|
||||
?.workspaceDirectory?.trim();
|
||||
return directory || null;
|
||||
}
|
||||
|
||||
async function forwardAutomationRequest(params: {
|
||||
request: BrowserAutomationExecuteRequest;
|
||||
serverId?: string;
|
||||
executeAutomationCommand: NonNullable<DesktopHostBridge["browser"]>["executeAutomationCommand"];
|
||||
readHostBrowserRouting: typeof readHostBrowserRoutingDefault;
|
||||
}): Promise<BrowserAutomationResponsePayload> {
|
||||
const { request, serverId, executeAutomationCommand, readHostBrowserRouting } = params;
|
||||
const normalizedServerId = serverId?.trim();
|
||||
const normalizedWorkspaceId = request.workspaceId?.trim();
|
||||
if (!normalizedServerId || !normalizedWorkspaceId) {
|
||||
return browserAutomationFailure({
|
||||
requestId: request.requestId,
|
||||
code: "browser_denied",
|
||||
message: "Browser automation requires a server and workspace context.",
|
||||
});
|
||||
}
|
||||
if (!executeAutomationCommand) {
|
||||
return browserAutomationFailure({
|
||||
requestId: request.requestId,
|
||||
code: "browser_unsupported",
|
||||
message: "Browser automation is not available in this app runtime.",
|
||||
});
|
||||
}
|
||||
|
||||
const uploadRoot = resolveWorkspaceUploadRoot({
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
readHostBrowserRouting,
|
||||
});
|
||||
|
||||
try {
|
||||
const payload = await executeAutomationCommand(request);
|
||||
client.sendBrowserAutomationExecuteResponse({
|
||||
type: "browser.automation.execute.response",
|
||||
payload: normalizeBridgePayload(request.requestId, payload),
|
||||
const payload = await executeAutomationCommand(request, {
|
||||
serverId: normalizedServerId,
|
||||
uploadRoot,
|
||||
});
|
||||
return normalizeBridgePayload(request.requestId, payload);
|
||||
} catch (error) {
|
||||
client.sendBrowserAutomationExecuteResponse({
|
||||
type: "browser.automation.execute.response",
|
||||
payload: normalizeThrownBridgeError(request.requestId, error),
|
||||
});
|
||||
return normalizeThrownBridgeError(request.requestId, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,16 +295,24 @@ function resizeBrowserTabForRequest(params: {
|
||||
{ command: "resize" }
|
||||
>;
|
||||
const browserId = command.args.browserId;
|
||||
if (!getBrowserRecord(browserId)) {
|
||||
const normalizedServerId = serverId?.trim();
|
||||
const normalizedWorkspaceId = request.workspaceId?.trim();
|
||||
if (!normalizedServerId || !normalizedWorkspaceId) {
|
||||
return browserAutomationFailure({
|
||||
requestId: request.requestId,
|
||||
code: "browser_tab_not_found",
|
||||
message: `No browser tab found for ID: ${browserId}`,
|
||||
code: "browser_denied",
|
||||
message: "Cannot resize a browser tab without a workspace context.",
|
||||
});
|
||||
}
|
||||
|
||||
const workspaceId = request.workspaceId;
|
||||
if (serverId && workspaceId && !findWorkspaceBrowserTab({ serverId, workspaceId, browserId })) {
|
||||
if (
|
||||
!findWorkspaceBrowserTab({
|
||||
serverId: normalizedServerId,
|
||||
workspaceId: normalizedWorkspaceId,
|
||||
browserId,
|
||||
}) ||
|
||||
!getBrowserRecord(browserId)
|
||||
) {
|
||||
return browserAutomationFailure({
|
||||
requestId: request.requestId,
|
||||
code: "browser_tab_not_found",
|
||||
@@ -434,6 +500,7 @@ async function openBrowserTabForRequest(params: {
|
||||
try {
|
||||
ensureResidentBrowserWebview({
|
||||
browserId,
|
||||
serverId,
|
||||
workspaceId,
|
||||
url: normalizedUrl,
|
||||
...(targetPartition ? { partition: targetPartition } : {}),
|
||||
@@ -441,6 +508,7 @@ async function openBrowserTabForRequest(params: {
|
||||
registered = await waitForBrowserRegistration({
|
||||
request,
|
||||
browserId,
|
||||
serverId,
|
||||
workspaceId,
|
||||
executeAutomationCommand: browserHost.executeAutomationCommand,
|
||||
...(registrationWaitTimeoutMs !== undefined
|
||||
@@ -473,23 +541,31 @@ async function openBrowserTabForRequest(params: {
|
||||
async function waitForBrowserRegistration(params: {
|
||||
request: BrowserAutomationExecuteRequest;
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
executeAutomationCommand: (
|
||||
request: BrowserAutomationExecuteRequest,
|
||||
context: DesktopAutomationExecutionContext,
|
||||
) => Promise<BrowserAutomationResponsePayload>;
|
||||
timeoutMs?: number;
|
||||
pollIntervalMs?: number;
|
||||
}): Promise<boolean> {
|
||||
const deadline = Date.now() + (params.timeoutMs ?? 5_000);
|
||||
while (Date.now() < deadline) {
|
||||
const payload = await params.executeAutomationCommand({
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: `${params.request.requestId}:list_tabs`,
|
||||
agentId: params.request.agentId,
|
||||
cwd: params.request.cwd,
|
||||
workspaceId: params.workspaceId,
|
||||
command: { command: "list_tabs", args: {} },
|
||||
});
|
||||
const payload = await params.executeAutomationCommand(
|
||||
{
|
||||
type: "browser.automation.execute.request",
|
||||
requestId: `${params.request.requestId}:list_tabs`,
|
||||
agentId: params.request.agentId,
|
||||
cwd: params.request.cwd,
|
||||
workspaceId: params.workspaceId,
|
||||
command: { command: "list_tabs", args: {} },
|
||||
},
|
||||
{
|
||||
serverId: params.serverId,
|
||||
uploadRoot: null,
|
||||
},
|
||||
);
|
||||
if (payload.ok && payload.result.command === "list_tabs") {
|
||||
if (payload.result.tabs.some((tab) => tab.browserId === params.browserId)) {
|
||||
return true;
|
||||
|
||||
@@ -774,6 +774,7 @@ function deviceSizeIdForViewport(viewport: BrowserViewport): DeviceSizeId | null
|
||||
|
||||
function acquirePartitionedWebview(input: {
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
partition: string;
|
||||
initialUrl: string;
|
||||
@@ -791,6 +792,7 @@ function acquirePartitionedWebview(input: {
|
||||
const webview = document.createElement("webview") as ElectronWebview;
|
||||
prepareBrowserWebview(webview, {
|
||||
browserId: input.browserId,
|
||||
serverId: input.serverId,
|
||||
workspaceId: input.workspaceId,
|
||||
initialUrl: input.initialUrl,
|
||||
partition: input.partition,
|
||||
@@ -985,6 +987,7 @@ export function BrowserPane({
|
||||
);
|
||||
const webview = acquirePartitionedWebview({
|
||||
browserId,
|
||||
serverId,
|
||||
workspaceId,
|
||||
partition: activePartition,
|
||||
initialUrl: initialUnsafeNavigationMessage ? "about:blank" : currentUrl,
|
||||
|
||||
@@ -173,6 +173,27 @@ describe("classifyHostBrowserRouting", () => {
|
||||
).toEqual({ kind: "remote", support: "host_connecting" });
|
||||
});
|
||||
|
||||
it.each([
|
||||
["idle", "host_connecting"],
|
||||
["connecting", "host_connecting"],
|
||||
["offline", "host_offline"],
|
||||
] as const)(
|
||||
"fails closed when host profile has no saved connections and is %s",
|
||||
(connectionStatus, expectedSupport) => {
|
||||
expect(
|
||||
classifyHostBrowserRouting({
|
||||
serverId: "unhydrated-host",
|
||||
connections: [],
|
||||
activeConnection: null,
|
||||
activeConnectionId: null,
|
||||
connectionStatus,
|
||||
features: null,
|
||||
origin: null,
|
||||
}),
|
||||
).toEqual({ kind: "remote", support: expectedSupport });
|
||||
},
|
||||
);
|
||||
|
||||
it("routes only loopback URLs on supported remote hosts in Electron to a proxied browser tab", () => {
|
||||
const supportedRemote = {
|
||||
kind: "remote" as const,
|
||||
|
||||
@@ -216,9 +216,9 @@ export function classifyHostBrowserRouting(
|
||||
if (originServerId) {
|
||||
return classifyRoutedHost(host, originServerId, origin);
|
||||
}
|
||||
} else if (connections.length === 0 || connections.some(isLocalHostConnection)) {
|
||||
// No active connection yet (connecting/offline). Distinguish local hosts from remote
|
||||
// hosts using saved connection definitions so remote tabs fail closed during startup.
|
||||
} else if (connections.some(isLocalHostConnection)) {
|
||||
// No active connection yet (connecting/offline). Classify as local only when saved
|
||||
// connections positively identify a local host; unhydrated or unknown hosts fail closed.
|
||||
return { kind: "local" };
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
const RESIDENT_HOST_ID = "paseo-browser-resident-webviews";
|
||||
const attachedBrowsers: Array<{
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
partition: string;
|
||||
webContentsId: number;
|
||||
}> = [];
|
||||
const profileHost: BrowserWebviewProfileHost = {
|
||||
@@ -32,11 +34,13 @@ const profileHost: BrowserWebviewProfileHost = {
|
||||
|
||||
function ensureTestBrowser(input: {
|
||||
browserId: string;
|
||||
serverId?: string;
|
||||
workspaceId: string;
|
||||
url: string;
|
||||
}): HTMLElement | null {
|
||||
return ensureResidentBrowserWebview({
|
||||
partition: "persist:paseo-browser",
|
||||
serverId: "server-a",
|
||||
...input,
|
||||
profileHost,
|
||||
});
|
||||
@@ -44,9 +48,14 @@ function ensureTestBrowser(input: {
|
||||
|
||||
function prepareTestBrowser(
|
||||
webview: HTMLElement,
|
||||
input: { browserId: string; workspaceId: string; initialUrl?: string | null },
|
||||
input: { browserId: string; serverId?: string; workspaceId: string; initialUrl?: string | null },
|
||||
): void {
|
||||
prepareBrowserWebview(webview, { partition: "persist:paseo-browser", ...input, profileHost });
|
||||
prepareBrowserWebview(webview, {
|
||||
partition: "persist:paseo-browser",
|
||||
serverId: "server-a",
|
||||
...input,
|
||||
profileHost,
|
||||
});
|
||||
}
|
||||
|
||||
function residentHost(): HTMLElement {
|
||||
@@ -230,7 +239,13 @@ describe("resident browser webviews", () => {
|
||||
});
|
||||
|
||||
it("reuses a resident browser on the same partition and replaces it when the partition changes", () => {
|
||||
const input = { browserId: "first", workspaceId: "workspace", url: "about:blank", profileHost };
|
||||
const input = {
|
||||
browserId: "first",
|
||||
serverId: "server-a",
|
||||
workspaceId: "workspace",
|
||||
url: "about:blank",
|
||||
profileHost,
|
||||
};
|
||||
const first = ensureTestBrowser(input);
|
||||
expect(ensureResidentBrowserWebview({ ...input, partition: "persist:paseo-browser" })).toBe(
|
||||
first,
|
||||
@@ -275,12 +290,14 @@ describe("resident browser webviews", () => {
|
||||
expect(attachedBrowsers).toEqual([
|
||||
{
|
||||
browserId: "browser-first",
|
||||
serverId: "server-a",
|
||||
workspaceId: "workspace-a",
|
||||
partition: "persist:paseo-browser",
|
||||
webContentsId: 101,
|
||||
},
|
||||
{
|
||||
browserId: "browser-second",
|
||||
serverId: "server-a",
|
||||
workspaceId: "workspace-b",
|
||||
partition: "persist:paseo-browser",
|
||||
webContentsId: 202,
|
||||
|
||||
@@ -25,6 +25,7 @@ interface BrowserWebviewElement extends HTMLElement {
|
||||
interface BrowserWebviewIdentity {
|
||||
partition: string;
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
@@ -80,6 +81,7 @@ function registerBrowserWhenAttached(
|
||||
await browser.registerAttachedBrowser({
|
||||
partition: identity.partition,
|
||||
browserId: identity.browserId,
|
||||
serverId: identity.serverId,
|
||||
workspaceId: identity.workspaceId,
|
||||
webContentsId,
|
||||
});
|
||||
@@ -327,6 +329,7 @@ export function prepareBrowserWebview(
|
||||
webview: HTMLElement,
|
||||
input: {
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
initialUrl?: string | null;
|
||||
partition?: string;
|
||||
@@ -348,6 +351,7 @@ export function prepareBrowserWebview(
|
||||
{
|
||||
partition: targetPartition,
|
||||
browserId: input.browserId,
|
||||
serverId: input.serverId,
|
||||
workspaceId: input.workspaceId,
|
||||
},
|
||||
browser,
|
||||
@@ -360,6 +364,7 @@ export function getResidentBrowserWebviewPartition(webview: HTMLElement): string
|
||||
|
||||
export function ensureResidentBrowserWebview(input: {
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
url: string;
|
||||
partition?: string;
|
||||
@@ -400,6 +405,7 @@ export function ensureResidentBrowserWebview(input: {
|
||||
const webview = ownerDocument.createElement("webview") as BrowserWebviewElement;
|
||||
prepareBrowserWebview(webview, {
|
||||
browserId,
|
||||
serverId: input.serverId,
|
||||
workspaceId: input.workspaceId,
|
||||
initialUrl: input.url,
|
||||
partition: desiredPartition,
|
||||
|
||||
@@ -145,10 +145,16 @@ export interface DesktopBrowserNewTabRequestEvent {
|
||||
export interface DesktopAttachedBrowserRegistration {
|
||||
partition: string;
|
||||
browserId: string;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
webContentsId: number;
|
||||
}
|
||||
|
||||
export interface DesktopAutomationExecutionContext {
|
||||
serverId: string;
|
||||
uploadRoot: string | null;
|
||||
}
|
||||
|
||||
export type BrowserProfileColor = IdentityColorName;
|
||||
|
||||
export interface BrowserProfileEntry {
|
||||
@@ -206,6 +212,7 @@ export interface DesktopBrowserBridge {
|
||||
registerAttachedBrowser?: (input: DesktopAttachedBrowserRegistration) => Promise<void>;
|
||||
unregisterWorkspaceBrowser?: (browserId: string) => Promise<void>;
|
||||
setWorkspaceActiveBrowser?: (input: {
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
browserId: string | null;
|
||||
}) => Promise<void>;
|
||||
@@ -232,6 +239,7 @@ export interface DesktopBrowserBridge {
|
||||
}) => Promise<void>;
|
||||
executeAutomationCommand?: (
|
||||
request: BrowserAutomationExecuteRequest,
|
||||
context: DesktopAutomationExecutionContext,
|
||||
) => Promise<BrowserAutomationExecuteResponse["payload"]>;
|
||||
acknowledgeFocusGuard?: (input: { token: string; composing: boolean }) => void;
|
||||
/** Capture a PNG screenshot of the guest viewport cropped to `rect`. */
|
||||
@@ -249,6 +257,8 @@ export interface DesktopInvokeBridge {
|
||||
|
||||
export interface DesktopHostBridge {
|
||||
platform?: string;
|
||||
deviceName?: string;
|
||||
osVersion?: string;
|
||||
windowChromeMode?: string;
|
||||
browserHostLabel?: string;
|
||||
browserHostInstanceId?: string;
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
import type { HelloClientInfo, HelloClientPlatform } from "@getpaseo/protocol/daemon-clients";
|
||||
|
||||
export interface AppClientIdentity {
|
||||
clientType: "mobile" | "browser";
|
||||
clientInfo: HelloClientInfo;
|
||||
}
|
||||
|
||||
export interface DesktopIdentityInput {
|
||||
platform?: string;
|
||||
deviceName?: string;
|
||||
osVersion?: string;
|
||||
browserHostLabel?: string;
|
||||
}
|
||||
|
||||
export interface WebNavigatorUserAgentData {
|
||||
platform?: string;
|
||||
brands?: ReadonlyArray<{ brand: string; version?: string }>;
|
||||
}
|
||||
|
||||
export interface WebIdentityInput {
|
||||
userAgent?: string;
|
||||
userAgentData?: WebNavigatorUserAgentData;
|
||||
}
|
||||
|
||||
export interface NativePlatformConstantsInput {
|
||||
Model?: string;
|
||||
Manufacturer?: string;
|
||||
Brand?: string;
|
||||
Release?: string;
|
||||
systemName?: string;
|
||||
osVersion?: string;
|
||||
interfaceIdiom?: string;
|
||||
}
|
||||
|
||||
export interface NativeIdentityInput {
|
||||
os: string;
|
||||
version?: string | number;
|
||||
constants?: NativePlatformConstantsInput;
|
||||
deviceName?: string | null;
|
||||
}
|
||||
|
||||
const LEGACY_WINDOW_SUFFIX_PATTERN = /\s*·\s*Window\s+\d+(?:\s*\([0-9A-Fa-f]+\))?$/;
|
||||
|
||||
function mapDesktopPlatform(raw: string | undefined): HelloClientPlatform {
|
||||
const normalized = raw?.toLowerCase();
|
||||
if (normalized === "darwin" || normalized === "macos") return "macos";
|
||||
if (normalized === "linux") return "linux";
|
||||
if (normalized === "win32" || normalized === "windows") return "windows";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function osNameForDesktopPlatform(platform: HelloClientPlatform): string | undefined {
|
||||
if (platform === "macos") return "macOS";
|
||||
if (platform === "linux") return "Linux";
|
||||
if (platform === "windows") return "Windows";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function normalizeNonEmpty(
|
||||
value: string | null | undefined,
|
||||
maxLength: number,
|
||||
): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
return trimmed ? trimmed.slice(0, maxLength) : undefined;
|
||||
}
|
||||
|
||||
function cleanDesktopName(desktop: DesktopIdentityInput): string | undefined {
|
||||
const explicit = normalizeNonEmpty(desktop.deviceName, 128);
|
||||
if (explicit) return explicit;
|
||||
// COMPAT(legacyBrowserHostLabel): added in v0.19.x, strip window suffix from older Electron preloads without --paseo-device-name; remove after 2027-06-15.
|
||||
const stripped = desktop.browserHostLabel?.replace(LEGACY_WINDOW_SUFFIX_PATTERN, "").trim();
|
||||
return stripped ? stripped.slice(0, 128) : undefined;
|
||||
}
|
||||
|
||||
export function resolveDesktopClientIdentity(desktop: DesktopIdentityInput): AppClientIdentity {
|
||||
const platform = mapDesktopPlatform(desktop.platform);
|
||||
const osName = osNameForDesktopPlatform(platform);
|
||||
const name = cleanDesktopName(desktop);
|
||||
const osVersion = normalizeNonEmpty(desktop.osVersion, 48);
|
||||
|
||||
return {
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "desktop",
|
||||
platform,
|
||||
...(name ? { name } : {}),
|
||||
...(osName ? { osName } : {}),
|
||||
...(osVersion ? { osVersion } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function parseBrowserNameFromBrands(
|
||||
brands: ReadonlyArray<{ brand: string; version?: string }> | undefined,
|
||||
): string | undefined {
|
||||
if (!brands || brands.length === 0) return undefined;
|
||||
const names = brands.map((entry) => entry.brand);
|
||||
if (names.some((brand) => /Microsoft Edge/i.test(brand))) return "Edge";
|
||||
if (names.some((brand) => /Opera/i.test(brand))) return "Opera";
|
||||
if (names.some((brand) => /Brave/i.test(brand))) return "Brave";
|
||||
if (names.some((brand) => /Google Chrome/i.test(brand))) return "Chrome";
|
||||
if (names.some((brand) => /Chromium/i.test(brand))) return "Chrome";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseBrowserNameFromUserAgent(userAgent: string | undefined): string | undefined {
|
||||
if (!userAgent) return undefined;
|
||||
if (/Edg(?:A|iOS)?\//.test(userAgent)) return "Edge";
|
||||
if (/OPR\//.test(userAgent)) return "Opera";
|
||||
if (/(?:Firefox|FxiOS)\//.test(userAgent)) return "Firefox";
|
||||
if (/(?:Chrome|CriOS)\//.test(userAgent) && !/Edg(?:A|iOS)?\//.test(userAgent)) return "Chrome";
|
||||
if (/Safari\//.test(userAgent) && !/(?:Chrome|CriOS)\//.test(userAgent)) return "Safari";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseOsNameFromPlatformHint(platform: string | undefined): string | undefined {
|
||||
if (!platform) return undefined;
|
||||
const normalized = platform.trim().toLowerCase();
|
||||
if (normalized === "macos" || normalized === "mac os" || normalized === "macintel")
|
||||
return "macOS";
|
||||
if (normalized === "windows" || normalized === "win32") return "Windows";
|
||||
if (normalized === "linux") return "Linux";
|
||||
if (normalized === "android") return "Android";
|
||||
if (normalized === "ios") return "iOS";
|
||||
if (normalized === "chrome os" || normalized === "chromeos") return "ChromeOS";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseOsNameFromUserAgent(userAgent: string | undefined): string | undefined {
|
||||
if (!userAgent) return undefined;
|
||||
if (/iPhone|iPad|iPod/.test(userAgent)) return "iOS";
|
||||
if (/Android/.test(userAgent)) return "Android";
|
||||
if (/CrOS/.test(userAgent)) return "ChromeOS";
|
||||
if (/Windows NT|Win64|WOW64/.test(userAgent)) return "Windows";
|
||||
if (/Macintosh|Mac OS X/.test(userAgent)) return "macOS";
|
||||
if (/Linux|X11/.test(userAgent)) return "Linux";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function resolveWebClientIdentity(input: WebIdentityInput): AppClientIdentity {
|
||||
const browserName =
|
||||
parseBrowserNameFromBrands(input.userAgentData?.brands) ??
|
||||
parseBrowserNameFromUserAgent(input.userAgent);
|
||||
const osName =
|
||||
parseOsNameFromPlatformHint(input.userAgentData?.platform) ??
|
||||
parseOsNameFromUserAgent(input.userAgent);
|
||||
const name = browserName && osName ? `${browserName} on ${osName}` : browserName;
|
||||
|
||||
return {
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
...(name ? { name: name.slice(0, 128) } : {}),
|
||||
...(browserName ? { browserName: browserName.slice(0, 48) } : {}),
|
||||
...(osName ? { osName: osName.slice(0, 48) } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function cleanAndroidModel(
|
||||
manufacturer: string | undefined,
|
||||
model: string | undefined,
|
||||
): string | undefined {
|
||||
const cleanModel = model?.trim();
|
||||
if (!cleanModel) return undefined;
|
||||
const cleanManufacturer = manufacturer?.trim();
|
||||
if (
|
||||
!cleanManufacturer ||
|
||||
cleanModel.toLowerCase().startsWith(cleanManufacturer.toLowerCase()) ||
|
||||
cleanModel.toLowerCase().startsWith("pixel")
|
||||
) {
|
||||
return cleanModel.slice(0, 96);
|
||||
}
|
||||
const formattedManufacturer =
|
||||
cleanManufacturer === cleanManufacturer.toLowerCase()
|
||||
? `${cleanManufacturer[0]?.toUpperCase() ?? ""}${cleanManufacturer.slice(1)}`
|
||||
: cleanManufacturer;
|
||||
return `${formattedManufacturer} ${cleanModel}`.slice(0, 96);
|
||||
}
|
||||
|
||||
function resolveAndroidClientIdentity(
|
||||
input: NativeIdentityInput,
|
||||
explicitName: string | undefined,
|
||||
): AppClientIdentity {
|
||||
const constants = input.constants;
|
||||
const deviceModel = cleanAndroidModel(
|
||||
constants?.Manufacturer ?? constants?.Brand,
|
||||
constants?.Model,
|
||||
);
|
||||
const rawVersion =
|
||||
constants?.Release ?? (input.version !== undefined ? String(input.version) : undefined);
|
||||
const osVersion = normalizeNonEmpty(rawVersion, 48);
|
||||
const name = explicitName ?? deviceModel;
|
||||
return {
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "android",
|
||||
osName: "Android",
|
||||
...(osVersion ? { osVersion } : {}),
|
||||
...(deviceModel ? { deviceModel } : {}),
|
||||
...(name ? { name } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function resolveIosClientIdentity(
|
||||
input: NativeIdentityInput,
|
||||
explicitName: string | undefined,
|
||||
): AppClientIdentity {
|
||||
const constants = input.constants;
|
||||
const isPad = constants?.interfaceIdiom === "pad";
|
||||
const deviceModel = isPad ? "iPad" : "iPhone";
|
||||
const osName = normalizeNonEmpty(constants?.systemName, 48) ?? (isPad ? "iPadOS" : "iOS");
|
||||
const rawVersion =
|
||||
constants?.osVersion ?? (input.version !== undefined ? String(input.version) : undefined);
|
||||
const osVersion = normalizeNonEmpty(rawVersion, 48);
|
||||
const name = explicitName ?? deviceModel;
|
||||
return {
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "ios",
|
||||
osName,
|
||||
...(osVersion ? { osVersion } : {}),
|
||||
deviceModel,
|
||||
...(name ? { name } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveNativeClientIdentity(input: NativeIdentityInput): AppClientIdentity {
|
||||
const explicitName = normalizeNonEmpty(input.deviceName, 128);
|
||||
if (input.os === "android") {
|
||||
return resolveAndroidClientIdentity(input, explicitName);
|
||||
}
|
||||
if (input.os === "ios") {
|
||||
return resolveIosClientIdentity(input, explicitName);
|
||||
}
|
||||
return {
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "unknown",
|
||||
...(explicitName ? { name: explicitName } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
import Constants from "expo-constants";
|
||||
import { Platform } from "react-native";
|
||||
import type { HelloClientInfo, HelloClientPlatform } from "@getpaseo/protocol/daemon-clients";
|
||||
import {
|
||||
resolveNativeClientIdentity,
|
||||
type AppClientIdentity,
|
||||
type NativePlatformConstantsInput,
|
||||
} from "./client-info-parsers";
|
||||
|
||||
function mapNativePlatform(os: string): HelloClientPlatform {
|
||||
if (os === "ios") return "ios";
|
||||
if (os === "android") return "android";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
export function resolveAppClientIdentity(): {
|
||||
clientType: "mobile" | "browser";
|
||||
clientInfo: HelloClientInfo;
|
||||
} {
|
||||
const deviceName = Constants.deviceName?.trim();
|
||||
return {
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
platform: mapNativePlatform(Platform.OS),
|
||||
...(deviceName ? { name: deviceName.slice(0, 128) } : {}),
|
||||
},
|
||||
};
|
||||
export function resolveAppClientIdentity(): AppClientIdentity {
|
||||
return resolveNativeClientIdentity({
|
||||
os: Platform.OS,
|
||||
version: Platform.Version,
|
||||
constants: Platform.constants as NativePlatformConstantsInput | undefined,
|
||||
deviceName: Constants.deviceName,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveAppClientIdentity } from "./client-info";
|
||||
import { resolveNativeClientIdentity } from "./client-info-parsers";
|
||||
|
||||
describe("resolveAppClientIdentity (Electron and Web)", () => {
|
||||
it("identifies Electron Desktop on macOS, Linux, and Windows with clean deviceName and osVersion", () => {
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: {
|
||||
platform: "darwin",
|
||||
deviceName: "MacBook Pro",
|
||||
osVersion: "15.3.1",
|
||||
browserHostLabel: "MacBook Pro · Window 1 (ABCDEF)",
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "desktop",
|
||||
platform: "macos",
|
||||
name: "MacBook Pro",
|
||||
osName: "macOS",
|
||||
osVersion: "15.3.1",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: {
|
||||
platform: "linux",
|
||||
deviceName: "workstation",
|
||||
osVersion: "Ubuntu 24.04.1 LTS",
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "desktop",
|
||||
platform: "linux",
|
||||
name: "workstation",
|
||||
osName: "Linux",
|
||||
osVersion: "Ubuntu 24.04.1 LTS",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: {
|
||||
platform: "win32",
|
||||
deviceName: "DEV-PC",
|
||||
osVersion: "10.0.22631",
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "desktop",
|
||||
platform: "windows",
|
||||
name: "DEV-PC",
|
||||
osName: "Windows",
|
||||
osVersion: "10.0.22631",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("strips legacy Window N (HEX) suffix if older Electron preload only provides browserHostLabel", () => {
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: {
|
||||
platform: "linux",
|
||||
browserHostLabel: "devbox · Window 2 (9F0A1B)",
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "desktop",
|
||||
platform: "linux",
|
||||
name: "devbox",
|
||||
osName: "Linux",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("identifies web browsers and operating systems from userAgent and userAgentData", () => {
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: null,
|
||||
userAgent:
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
browserName: "Chrome",
|
||||
osName: "macOS",
|
||||
name: "Chrome on macOS",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: null,
|
||||
userAgent:
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0",
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
browserName: "Firefox",
|
||||
osName: "Windows",
|
||||
name: "Firefox on Windows",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: null,
|
||||
userAgent:
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15",
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
browserName: "Safari",
|
||||
osName: "macOS",
|
||||
name: "Safari on macOS",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveAppClientIdentity({
|
||||
desktop: null,
|
||||
userAgent:
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
|
||||
userAgentData: {
|
||||
platform: "Linux",
|
||||
brands: [{ brand: "Microsoft Edge", version: "131" }],
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
browserName: "Edge",
|
||||
osName: "Linux",
|
||||
name: "Edge on Linux",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveNativeClientIdentity (Android and iOS)", () => {
|
||||
it("extracts Android model, manufacturer, and release from RN Platform.constants", () => {
|
||||
expect(
|
||||
resolveNativeClientIdentity({
|
||||
os: "android",
|
||||
constants: {
|
||||
Manufacturer: "Google",
|
||||
Model: "Pixel 9 Pro",
|
||||
Release: "15",
|
||||
},
|
||||
deviceName: undefined,
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "android",
|
||||
osName: "Android",
|
||||
osVersion: "15",
|
||||
deviceModel: "Pixel 9 Pro",
|
||||
name: "Pixel 9 Pro",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveNativeClientIdentity({
|
||||
os: "android",
|
||||
constants: {
|
||||
Manufacturer: "samsung",
|
||||
Model: "SM-S928B",
|
||||
Release: "14",
|
||||
},
|
||||
deviceName: "Mo's Galaxy",
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "android",
|
||||
osName: "Android",
|
||||
osVersion: "14",
|
||||
deviceModel: "Samsung SM-S928B",
|
||||
name: "Mo's Galaxy",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts iOS and iPadOS metadata from RN Platform.constants", () => {
|
||||
expect(
|
||||
resolveNativeClientIdentity({
|
||||
os: "ios",
|
||||
constants: {
|
||||
systemName: "iOS",
|
||||
osVersion: "18.3",
|
||||
interfaceIdiom: "phone",
|
||||
},
|
||||
deviceName: "iPhone",
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "ios",
|
||||
osName: "iOS",
|
||||
osVersion: "18.3",
|
||||
deviceModel: "iPhone",
|
||||
name: "iPhone",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveNativeClientIdentity({
|
||||
os: "ios",
|
||||
constants: {
|
||||
systemName: "iPadOS",
|
||||
osVersion: "18.3",
|
||||
interfaceIdiom: "pad",
|
||||
},
|
||||
deviceName: undefined,
|
||||
}),
|
||||
).toEqual({
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
appKind: "mobile",
|
||||
platform: "ios",
|
||||
osName: "iPadOS",
|
||||
osVersion: "18.3",
|
||||
deviceModel: "iPad",
|
||||
name: "iPad",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,47 +1,48 @@
|
||||
import type { HelloClientInfo, HelloClientPlatform } from "@getpaseo/protocol/daemon-clients";
|
||||
import { getIsElectron } from "@/constants/platform";
|
||||
import { getDesktopHost } from "@/desktop/host";
|
||||
import {
|
||||
resolveDesktopClientIdentity,
|
||||
resolveWebClientIdentity,
|
||||
type AppClientIdentity,
|
||||
type DesktopIdentityInput,
|
||||
type WebNavigatorUserAgentData,
|
||||
} from "./client-info-parsers";
|
||||
|
||||
function mapDesktopPlatform(raw: string | undefined): HelloClientPlatform {
|
||||
const normalized = raw?.toLowerCase();
|
||||
if (normalized === "darwin" || normalized === "macos") return "macos";
|
||||
if (normalized === "linux") return "linux";
|
||||
if (normalized === "win32" || normalized === "windows") return "windows";
|
||||
return "unknown";
|
||||
interface WebRuntimeEnv {
|
||||
desktop?: DesktopIdentityInput | null;
|
||||
userAgent?: string;
|
||||
userAgentData?: WebNavigatorUserAgentData;
|
||||
}
|
||||
|
||||
function parseBrowserName(userAgent: string | undefined): string | undefined {
|
||||
if (!userAgent) return undefined;
|
||||
if (/Edg\//.test(userAgent)) return "Edge";
|
||||
if (/Firefox\//.test(userAgent)) return "Firefox";
|
||||
if (/Chrome\//.test(userAgent) && !/Edg\//.test(userAgent)) return "Chrome";
|
||||
if (/Safari\//.test(userAgent) && !/Chrome\//.test(userAgent)) return "Safari";
|
||||
return undefined;
|
||||
function readNavigatorUserAgentData(): WebNavigatorUserAgentData | undefined {
|
||||
if (typeof navigator === "undefined") return undefined;
|
||||
const candidate = (navigator as Navigator & { userAgentData?: WebNavigatorUserAgentData })
|
||||
.userAgentData;
|
||||
return candidate && typeof candidate === "object" ? candidate : undefined;
|
||||
}
|
||||
|
||||
export function resolveAppClientIdentity(): {
|
||||
clientType: "mobile" | "browser";
|
||||
clientInfo: HelloClientInfo;
|
||||
} {
|
||||
if (getIsElectron()) {
|
||||
const desktop = getDesktopHost();
|
||||
const label = desktop?.browserHostLabel?.trim();
|
||||
return {
|
||||
clientType: "mobile",
|
||||
clientInfo: {
|
||||
platform: mapDesktopPlatform(desktop?.platform),
|
||||
...(label ? { name: label.slice(0, 128) } : {}),
|
||||
},
|
||||
};
|
||||
function resolveDesktopInput(env?: WebRuntimeEnv): DesktopIdentityInput | null {
|
||||
if (env && "desktop" in env) {
|
||||
return env.desktop ?? null;
|
||||
}
|
||||
return getIsElectron() ? getDesktopHost() : null;
|
||||
}
|
||||
|
||||
function resolveUserAgentInput(env?: WebRuntimeEnv): string | undefined {
|
||||
if (env && "userAgent" in env) {
|
||||
return env.userAgent;
|
||||
}
|
||||
return typeof navigator !== "undefined" ? navigator.userAgent : undefined;
|
||||
}
|
||||
|
||||
export function resolveAppClientIdentity(env?: WebRuntimeEnv): AppClientIdentity {
|
||||
const desktop = resolveDesktopInput(env);
|
||||
if (desktop) {
|
||||
return resolveDesktopClientIdentity(desktop);
|
||||
}
|
||||
|
||||
const browserName =
|
||||
typeof navigator !== "undefined" ? parseBrowserName(navigator.userAgent) : undefined;
|
||||
return {
|
||||
clientType: "browser",
|
||||
clientInfo: {
|
||||
platform: "web",
|
||||
...(browserName ? { name: browserName } : {}),
|
||||
},
|
||||
};
|
||||
return resolveWebClientIdentity({
|
||||
userAgent: resolveUserAgentInput(env),
|
||||
userAgentData: env && "userAgentData" in env ? env.userAgentData : readNavigatorUserAgentData(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
@@ -6,23 +6,32 @@ import type { TFunction } from "i18next";
|
||||
import type {
|
||||
DaemonClientsSnapshot,
|
||||
DaemonSessionSummary,
|
||||
DaemonSessionTransport,
|
||||
WSClientType,
|
||||
} from "@getpaseo/protocol/daemon-clients";
|
||||
import type { DaemonPermission } from "@getpaseo/protocol/messages";
|
||||
import type { HostDirectory, HostSummary } from "@getpaseo/protocol/hosts";
|
||||
import {
|
||||
SettingsCard,
|
||||
SettingsCollapsibleRow,
|
||||
SettingsDetailRow,
|
||||
SettingsRow,
|
||||
SettingsSection,
|
||||
} from "@/components/settings";
|
||||
import { StatusBadge } from "@/components/ui/status-badge";
|
||||
import { useHostRuntimeClient, useHostRuntimeSnapshot } from "@/runtime/host-runtime";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { useSessionStore, type DaemonServerInfo } from "@/stores/session-store";
|
||||
import {
|
||||
formatAppDetail,
|
||||
formatAuthMethodLabel,
|
||||
formatDeviceDetail,
|
||||
formatSessionHint,
|
||||
formatSessionTitle,
|
||||
formatTransportLabel,
|
||||
} from "./device-display";
|
||||
import { formatConnectedDuration, summarizePermissions } from "./scope-summary";
|
||||
import { DaemonPasswordSheet } from "./daemon-password-sheet";
|
||||
|
||||
const UPDATES_DOCS_URL = "https://paseo.sh/docs/updates";
|
||||
const RELATIVE_TIME_REFRESH_MS = 60_000;
|
||||
|
||||
type StatusDotTone = "online" | "warning" | "error" | "offline";
|
||||
|
||||
@@ -49,6 +58,17 @@ const STATUS_DOTS: Record<StatusDotTone, React.ReactNode> = {
|
||||
offline: <StatusDot tone="offline" />,
|
||||
};
|
||||
|
||||
function useMinuteTick(): number {
|
||||
const [nowMs, setNowMs] = useState(() => Date.now());
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setNowMs(Date.now());
|
||||
}, RELATIVE_TIME_REFRESH_MS);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
return nowMs;
|
||||
}
|
||||
|
||||
function ScopePill({ permissions, t }: { permissions: readonly DaemonPermission[]; t: TFunction }) {
|
||||
const summary = summarizePermissions(permissions);
|
||||
let label: string;
|
||||
@@ -64,15 +84,23 @@ function ScopePill({ permissions, t }: { permissions: readonly DaemonPermission[
|
||||
return <StatusBadge label={label} variant="muted" size="xs" />;
|
||||
}
|
||||
|
||||
function PermissionPillsRow({
|
||||
function AccessDetailRow({
|
||||
permissions,
|
||||
t,
|
||||
}: {
|
||||
permissions: readonly DaemonPermission[];
|
||||
t: TFunction;
|
||||
}) {
|
||||
const summary = summarizePermissions(permissions);
|
||||
if (summary.kind === "full") {
|
||||
return (
|
||||
<SettingsRow label={t("devices.details.access")}>
|
||||
<Text style={styles.nestedValue}>{t("devices.scopes.fullAccess")}</Text>
|
||||
</SettingsRow>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<SettingsRow label={t("devices.details.permissions")}>
|
||||
<SettingsRow label={t("devices.details.access")}>
|
||||
<View style={styles.scopePills}>
|
||||
{permissions.length > 0 ? (
|
||||
permissions.map((permission) => (
|
||||
@@ -86,9 +114,13 @@ function PermissionPillsRow({
|
||||
);
|
||||
}
|
||||
|
||||
function formatDurationLabel(isoTimestamp: string | null | undefined, t: TFunction): string | null {
|
||||
function formatDurationLabel(
|
||||
isoTimestamp: string | null | undefined,
|
||||
nowMs: number,
|
||||
t: TFunction,
|
||||
): string | null {
|
||||
if (!isoTimestamp) return null;
|
||||
const duration = formatConnectedDuration(isoTimestamp);
|
||||
const duration = formatConnectedDuration(isoTimestamp, nowMs);
|
||||
if (!duration) return null;
|
||||
if (duration.kind === "just_now") return t("devices.time.justNow");
|
||||
if (duration.kind === "minutes") return t("devices.time.minutesAgo", { count: duration.count });
|
||||
@@ -96,77 +128,26 @@ function formatDurationLabel(isoTimestamp: string | null | undefined, t: TFuncti
|
||||
return t("devices.time.daysAgo", { count: duration.count });
|
||||
}
|
||||
|
||||
function formatTransportLabel(
|
||||
transport: DaemonSessionTransport,
|
||||
viaHostName: string | null,
|
||||
t: TFunction,
|
||||
): string {
|
||||
switch (transport) {
|
||||
case "local_ipc":
|
||||
case "local":
|
||||
return t("devices.transport.local");
|
||||
case "tailscale":
|
||||
return t("devices.transport.tailscale");
|
||||
case "relay":
|
||||
return t("devices.transport.relay");
|
||||
case "hub":
|
||||
return t("devices.transport.hub");
|
||||
case "via":
|
||||
return viaHostName
|
||||
? t("devices.transport.via", { host: viaHostName })
|
||||
: t("devices.transport.viaHost");
|
||||
case "direct":
|
||||
return t("devices.transport.direct");
|
||||
}
|
||||
}
|
||||
|
||||
function formatClientPlatformLabel(
|
||||
clientType: WSClientType,
|
||||
platform: string | null,
|
||||
t: TFunction,
|
||||
): string {
|
||||
if (platform === "ios") return "iOS";
|
||||
if (platform === "android") return "Android";
|
||||
if (platform === "macos" || platform === "linux" || platform === "windows") {
|
||||
return t("devices.kind.desktop");
|
||||
}
|
||||
if (clientType === "browser" || platform === "web") return t("devices.kind.web");
|
||||
if (clientType === "mobile") return t("devices.kind.mobile");
|
||||
if (clientType === "hub") return t("devices.kind.hub");
|
||||
if (clientType === "cli") return "CLI";
|
||||
return "MCP";
|
||||
}
|
||||
|
||||
function formatSessionTitle(session: DaemonSessionSummary, t: TFunction): string {
|
||||
if (session.isCurrentSession) return t("devices.connected.thisDevice");
|
||||
if (session.name) return session.name;
|
||||
return formatClientPlatformLabel(session.clientType, session.platform, t);
|
||||
}
|
||||
|
||||
function formatSessionHint(
|
||||
session: DaemonSessionSummary,
|
||||
viaHostName: string | null,
|
||||
t: TFunction,
|
||||
): string {
|
||||
const transport = formatTransportLabel(session.transport, viaHostName, t);
|
||||
const platform = formatClientPlatformLabel(session.clientType, session.platform, t);
|
||||
const detail = session.appVersion ? `${platform} ${session.appVersion}` : platform;
|
||||
return detail === transport ? transport : `${transport} · ${detail}`;
|
||||
}
|
||||
|
||||
function ConnectedClientRow({
|
||||
session,
|
||||
viaHostName,
|
||||
nowMs,
|
||||
}: {
|
||||
session: DaemonSessionSummary;
|
||||
viaHostName: string | null;
|
||||
nowMs: number;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tone: StatusDotTone = session.socketCount > 0 ? "online" : "warning";
|
||||
const connectedLabel = formatDurationLabel(session.connectedAt, t);
|
||||
const isReconnecting = session.socketCount === 0;
|
||||
const tone: StatusDotTone = isReconnecting ? "warning" : "online";
|
||||
const deviceDetail = formatDeviceDetail(session);
|
||||
const appDetail = formatAppDetail(session, t);
|
||||
const connectionLabel = formatTransportLabel(session.transport, viaHostName, t);
|
||||
const authLabel = formatAuthMethodLabel(session.authMethod, t);
|
||||
const connectedLabel = formatDurationLabel(session.connectedAt, nowMs, t);
|
||||
const trailing = useMemo(
|
||||
() => <ScopePill permissions={session.permissions} t={t} />,
|
||||
[session.permissions, t],
|
||||
() => (isReconnecting ? undefined : <ScopePill permissions={session.permissions} t={t} />),
|
||||
[isReconnecting, session.permissions, t],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -174,20 +155,37 @@ function ConnectedClientRow({
|
||||
label={formatSessionTitle(session, t)}
|
||||
leading={STATUS_DOTS[tone]}
|
||||
hint={formatSessionHint(session, viaHostName, t)}
|
||||
summary={isReconnecting ? t("devices.status.reconnecting") : undefined}
|
||||
trailing={trailing}
|
||||
testID={`devices-client-${session.sessionId}`}
|
||||
>
|
||||
<PermissionPillsRow permissions={session.permissions} t={t} />
|
||||
{deviceDetail ? (
|
||||
<SettingsRow label={t("devices.details.device")}>
|
||||
<Text style={styles.nestedValue}>{deviceDetail}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
<SettingsRow label={t("devices.details.app")}>
|
||||
<Text style={styles.nestedValue}>{appDetail}</Text>
|
||||
</SettingsRow>
|
||||
<SettingsRow label={t("devices.details.connection")}>
|
||||
<Text style={styles.nestedValue}>{connectionLabel}</Text>
|
||||
</SettingsRow>
|
||||
{session.remoteIp ? (
|
||||
<SettingsRow label={t("devices.details.ipAddress")}>
|
||||
<Text style={styles.nestedMonoValue}>{session.remoteIp}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
{authLabel ? (
|
||||
<SettingsRow label={t("devices.details.auth")}>
|
||||
<Text style={styles.nestedValue}>{authLabel}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
<AccessDetailRow permissions={session.permissions} t={t} />
|
||||
{connectedLabel ? (
|
||||
<SettingsRow label={t("devices.details.connected")}>
|
||||
<Text style={styles.nestedValue}>{connectedLabel}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
{session.socketCount === 0 ? (
|
||||
<SettingsRow label={t("devices.details.status")}>
|
||||
<Text style={styles.nestedValue}>{t("devices.status.reconnecting")}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
</SettingsCollapsibleRow>
|
||||
);
|
||||
}
|
||||
@@ -195,22 +193,25 @@ function ConnectedClientRow({
|
||||
function InboundDaemonRow({
|
||||
daemon,
|
||||
routedSessions,
|
||||
nowMs,
|
||||
}: {
|
||||
daemon: DaemonSessionSummary;
|
||||
routedSessions: readonly DaemonSessionSummary[];
|
||||
nowMs: number;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tone: StatusDotTone = daemon.socketCount > 0 ? "online" : "warning";
|
||||
const isReconnecting = daemon.socketCount === 0;
|
||||
const tone: StatusDotTone = isReconnecting ? "warning" : "online";
|
||||
const label = daemon.name ?? t("devices.hosts.unnamed");
|
||||
const transport = formatTransportLabel(daemon.transport, null, t);
|
||||
const hintParts = [t("devices.hosts.inbound"), transport];
|
||||
if (routedSessions.length > 0) {
|
||||
hintParts.push(t("devices.hosts.routedCount", { count: routedSessions.length }));
|
||||
}
|
||||
const connectedLabel = formatDurationLabel(daemon.connectedAt, t);
|
||||
const connectedLabel = formatDurationLabel(daemon.connectedAt, nowMs, t);
|
||||
const trailing = useMemo(
|
||||
() => <ScopePill permissions={daemon.permissions} t={t} />,
|
||||
[daemon.permissions, t],
|
||||
() => (isReconnecting ? undefined : <ScopePill permissions={daemon.permissions} t={t} />),
|
||||
[daemon.permissions, isReconnecting, t],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -218,10 +219,11 @@ function InboundDaemonRow({
|
||||
label={label}
|
||||
leading={STATUS_DOTS[tone]}
|
||||
hint={hintParts.join(" · ")}
|
||||
summary={isReconnecting ? t("devices.status.reconnecting") : undefined}
|
||||
trailing={trailing}
|
||||
testID={`devices-inbound-host-${daemon.sessionId}`}
|
||||
>
|
||||
<PermissionPillsRow permissions={daemon.permissions} t={t} />
|
||||
<AccessDetailRow permissions={daemon.permissions} t={t} />
|
||||
{routedSessions.map((routed) => (
|
||||
<SettingsRow
|
||||
key={routed.sessionId}
|
||||
@@ -231,6 +233,11 @@ function InboundDaemonRow({
|
||||
<ScopePill permissions={routed.permissions} t={t} />
|
||||
</SettingsRow>
|
||||
))}
|
||||
{daemon.remoteIp ? (
|
||||
<SettingsRow label={t("devices.details.ipAddress")}>
|
||||
<Text style={styles.nestedMonoValue}>{daemon.remoteIp}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
{daemon.appVersion ? (
|
||||
<SettingsRow label={t("devices.details.version")}>
|
||||
<Text style={styles.nestedValue}>{daemon.appVersion}</Text>
|
||||
@@ -241,11 +248,6 @@ function InboundDaemonRow({
|
||||
<Text style={styles.nestedValue}>{connectedLabel}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
{daemon.socketCount === 0 ? (
|
||||
<SettingsRow label={t("devices.details.status")}>
|
||||
<Text style={styles.nestedValue}>{t("devices.status.reconnecting")}</Text>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
</SettingsCollapsibleRow>
|
||||
);
|
||||
}
|
||||
@@ -279,13 +281,13 @@ function outboundHostStatusLabel(status: HostSummary["status"], t: TFunction): s
|
||||
}
|
||||
}
|
||||
|
||||
function OutboundHostRow({ host }: { host: HostSummary }) {
|
||||
function OutboundHostRow({ host, nowMs }: { host: HostSummary; nowMs: number }) {
|
||||
const { t } = useTranslation();
|
||||
const tone = outboundHostTone(host.status);
|
||||
const label = host.label ?? host.serverId ?? host.targetDescription;
|
||||
const hintParts = [t("devices.hosts.outbound"), host.targetDescription];
|
||||
const statusSummary = outboundHostStatusLabel(host.status, t);
|
||||
const connectedLabel = formatDurationLabel(host.connectedAt ?? host.lastOnlineAt, t);
|
||||
const connectedLabel = formatDurationLabel(host.connectedAt ?? host.lastOnlineAt, nowMs, t);
|
||||
const trailing = useMemo(
|
||||
() =>
|
||||
host.status === "online" && host.permissions ? (
|
||||
@@ -304,7 +306,7 @@ function OutboundHostRow({ host }: { host: HostSummary }) {
|
||||
trailing={trailing}
|
||||
testID={`devices-outbound-host-${host.registrationId}`}
|
||||
>
|
||||
{host.permissions ? <PermissionPillsRow permissions={host.permissions} t={t} /> : null}
|
||||
{host.permissions ? <AccessDetailRow permissions={host.permissions} t={t} /> : null}
|
||||
{host.error ? (
|
||||
<SettingsRow label={t("devices.details.error")}>
|
||||
<Text style={styles.nestedError}>{host.error.message}</Text>
|
||||
@@ -426,6 +428,7 @@ function ConnectedClientsCardBody({
|
||||
clientsState,
|
||||
connectedClients,
|
||||
hostNameBySessionId,
|
||||
nowMs,
|
||||
}: {
|
||||
isOnline: boolean;
|
||||
hasServerInfo: boolean;
|
||||
@@ -434,6 +437,7 @@ function ConnectedClientsCardBody({
|
||||
clientsState: ConnectedClientsLoadState;
|
||||
connectedClients: readonly DaemonSessionSummary[];
|
||||
hostNameBySessionId: ReadonlyMap<string, string | null>;
|
||||
nowMs: number;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const updateLink = useMemo(
|
||||
@@ -484,14 +488,84 @@ function ConnectedClientsCardBody({
|
||||
viaHostName={
|
||||
entry.viaSessionId ? (hostNameBySessionId.get(entry.viaSessionId) ?? null) : null
|
||||
}
|
||||
nowMs={nowMs}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function DevicesAccessSection({
|
||||
serverId,
|
||||
isOnline,
|
||||
serverInfo,
|
||||
}: {
|
||||
serverId: string;
|
||||
isOnline: boolean;
|
||||
serverInfo: DaemonServerInfo | null;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [passwordSheetMode, setPasswordSheetMode] = useState<"set" | "change" | null>(null);
|
||||
const passwordConfigured = serverInfo?.passwordConfigured === true;
|
||||
const passwordManagedByEnv = serverInfo?.passwordManagedByEnv === true;
|
||||
const handleOpenPasswordSheet = useCallback(() => {
|
||||
setPasswordSheetMode(passwordConfigured ? "change" : "set");
|
||||
}, [passwordConfigured]);
|
||||
const handleClosePasswordSheet = useCallback(() => {
|
||||
setPasswordSheetMode(null);
|
||||
}, []);
|
||||
|
||||
// COMPAT(daemonPasswordManagement): added in v0.19.x, remove gate after 2027-06-15.
|
||||
const supportsPasswordManagement = serverInfo?.features?.daemonPasswordManagement === true;
|
||||
const canManagePassword =
|
||||
!serverInfo?.permissions ||
|
||||
(serverInfo.permissions.includes("daemon.manage") &&
|
||||
serverInfo.permissions.includes("access.manage"));
|
||||
|
||||
if (!isOnline || !supportsPasswordManagement || !canManagePassword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let passwordSummary: string;
|
||||
let passwordHint: string;
|
||||
if (passwordManagedByEnv) {
|
||||
passwordSummary = t("devices.access.passwordEnvSummary");
|
||||
passwordHint = t("devices.access.passwordEnvHint");
|
||||
} else if (passwordConfigured) {
|
||||
passwordSummary = t("devices.access.passwordSetSummary");
|
||||
passwordHint = t("devices.access.passwordSetHint");
|
||||
} else {
|
||||
passwordSummary = t("devices.access.passwordNotSetSummary");
|
||||
passwordHint = t("devices.access.passwordNotSetHint");
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsSection title={t("devices.access.title")}>
|
||||
<SettingsCard testID="devices-access-card">
|
||||
<SettingsDetailRow
|
||||
label={t("devices.access.passwordLabel")}
|
||||
summary={passwordSummary}
|
||||
hint={passwordHint}
|
||||
disabled={passwordManagedByEnv}
|
||||
onPress={handleOpenPasswordSheet}
|
||||
testID="devices-password-row"
|
||||
/>
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
<DaemonPasswordSheet
|
||||
serverId={serverId}
|
||||
visible={passwordSheetMode !== null}
|
||||
initialMode={passwordSheetMode ?? "set"}
|
||||
onClose={handleClosePasswordSheet}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConnectedDevicesView({ serverId }: { serverId: string }) {
|
||||
const { t } = useTranslation();
|
||||
const nowMs = useMinuteTick();
|
||||
const connectionStatus = useHostRuntimeSnapshot(serverId)?.connectionStatus;
|
||||
const serverInfo = useSessionStore((state) => state.sessions[serverId]?.serverInfo ?? null);
|
||||
|
||||
@@ -538,6 +612,8 @@ export function ConnectedDevicesView({ serverId }: { serverId: string }) {
|
||||
|
||||
return (
|
||||
<View>
|
||||
<DevicesAccessSection serverId={serverId} isOnline={isOnline} serverInfo={serverInfo} />
|
||||
|
||||
<SettingsSection title={t("devices.connected.title")}>
|
||||
<SettingsCard testID="devices-connected-clients-card">
|
||||
<ConnectedClientsCardBody
|
||||
@@ -548,6 +624,7 @@ export function ConnectedDevicesView({ serverId }: { serverId: string }) {
|
||||
clientsState={clientsState}
|
||||
connectedClients={connectedClients}
|
||||
hostNameBySessionId={hostNameBySessionId}
|
||||
nowMs={nowMs}
|
||||
/>
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
@@ -560,10 +637,11 @@ export function ConnectedDevicesView({ serverId }: { serverId: string }) {
|
||||
key={daemon.sessionId}
|
||||
daemon={daemon}
|
||||
routedSessions={routedByHostSessionId.get(daemon.sessionId) ?? EMPTY_SESSIONS}
|
||||
nowMs={nowMs}
|
||||
/>
|
||||
))}
|
||||
{outboundHosts.map((host) => (
|
||||
<OutboundHostRow key={host.registrationId} host={host} />
|
||||
<OutboundHostRow key={host.registrationId} host={host} nowMs={nowMs} />
|
||||
))}
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
@@ -605,6 +683,11 @@ const styles = StyleSheet.create((theme) => ({
|
||||
fontSize: theme.fontSize.sm,
|
||||
color: theme.colors.foregroundMuted,
|
||||
},
|
||||
nestedMonoValue: {
|
||||
fontSize: theme.fontSize.sm,
|
||||
fontFamily: theme.fontFamily.mono,
|
||||
color: theme.colors.foregroundMuted,
|
||||
},
|
||||
nestedError: {
|
||||
fontSize: theme.fontSize.sm,
|
||||
color: theme.colors.statusDanger,
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import {
|
||||
DAEMON_PASSWORD_MAX_BYTES,
|
||||
DAEMON_PASSWORD_MIN_CHARS,
|
||||
openDaemonPasswordForm,
|
||||
shouldSyncHostProfilePassword,
|
||||
} from "./daemon-password-form-model";
|
||||
|
||||
describe("daemon password form model", () => {
|
||||
test("set mode validates min 8 chars, max 72 UTF-8 bytes, and confirmation match", () => {
|
||||
const form = openDaemonPasswordForm({
|
||||
mode: "set",
|
||||
isLocalCredential: false,
|
||||
});
|
||||
expect(form.getState()).toMatchObject({
|
||||
step: "set",
|
||||
isLocalCredential: false,
|
||||
submitting: false,
|
||||
});
|
||||
|
||||
// 7 chars fails min length.
|
||||
form.setNewPassword("1234567");
|
||||
form.setConfirmPassword("1234567");
|
||||
expect(form.beginSubmit()).toEqual({ valid: false });
|
||||
expect(form.getState().fieldErrors.newPassword).toBe("too_short");
|
||||
|
||||
// 8 chars with mismatch fails confirm.
|
||||
form.setNewPassword("12345678");
|
||||
form.setConfirmPassword("87654321");
|
||||
expect(form.beginSubmit()).toEqual({ valid: false });
|
||||
expect(form.getState().fieldErrors.newPassword).toBeNull();
|
||||
expect(form.getState().fieldErrors.confirmPassword).toBe("mismatch");
|
||||
|
||||
// 73 UTF-8 bytes fails (including multibyte UTF-8 under 72 chars).
|
||||
const over72Bytes = "🔐".repeat(19); // 76 UTF-8 bytes
|
||||
expect(over72Bytes.length).toBeLessThan(DAEMON_PASSWORD_MAX_BYTES);
|
||||
form.setNewPassword(over72Bytes);
|
||||
form.setConfirmPassword(over72Bytes);
|
||||
expect(form.beginSubmit()).toEqual({ valid: false });
|
||||
expect(form.getState().fieldErrors.newPassword).toBe("too_long");
|
||||
|
||||
// Exact 72 UTF-8 bytes succeeds.
|
||||
const exact72 = "a".repeat(DAEMON_PASSWORD_MAX_BYTES);
|
||||
form.setNewPassword(exact72);
|
||||
form.setConfirmPassword(exact72);
|
||||
expect(form.beginSubmit()).toEqual({
|
||||
valid: true,
|
||||
payload: { password: exact72 },
|
||||
});
|
||||
expect(form.getState().submitting).toBe(true);
|
||||
form.finishSubmitSuccess();
|
||||
expect(form.getState().submitting).toBe(false);
|
||||
|
||||
// Exact 8 chars succeeds.
|
||||
const exact8 = "a".repeat(DAEMON_PASSWORD_MIN_CHARS);
|
||||
form.setNewPassword(exact8);
|
||||
form.setConfirmPassword(exact8);
|
||||
expect(form.beginSubmit()).toEqual({
|
||||
valid: true,
|
||||
payload: { password: exact8 },
|
||||
});
|
||||
});
|
||||
|
||||
test("change mode requires current password on remote sessions and maps server incorrect_password to field error", () => {
|
||||
const form = openDaemonPasswordForm({
|
||||
mode: "change",
|
||||
isLocalCredential: false,
|
||||
});
|
||||
|
||||
form.setNewPassword("new-secret-123");
|
||||
form.setConfirmPassword("new-secret-123");
|
||||
expect(form.beginSubmit()).toEqual({ valid: false });
|
||||
expect(form.getState().fieldErrors.currentPassword).toBe("current_password_required");
|
||||
|
||||
form.setCurrentPassword("wrong-current");
|
||||
expect(form.beginSubmit()).toEqual({
|
||||
valid: true,
|
||||
payload: { password: "new-secret-123", currentPassword: "wrong-current" },
|
||||
});
|
||||
|
||||
form.finishSubmitError({
|
||||
code: "incorrect_password",
|
||||
message: "Current password is incorrect",
|
||||
});
|
||||
expect(form.getState().submitting).toBe(false);
|
||||
expect(form.getState().fieldErrors.currentPassword).toBe("incorrect_password");
|
||||
expect(form.getState().submitError).toBeNull();
|
||||
// Preserves inputs so the user does not retype.
|
||||
expect(form.getState().newPassword).toBe("new-secret-123");
|
||||
expect(form.getState().confirmPassword).toBe("new-secret-123");
|
||||
|
||||
// Network/generic error goes to submitError.
|
||||
form.finishSubmitError({ message: "Network timeout" });
|
||||
expect(form.getState().submitError).toBe("Network timeout");
|
||||
});
|
||||
|
||||
test("change mode omits currentPassword on local-credential sessions", () => {
|
||||
const form = openDaemonPasswordForm({
|
||||
mode: "change",
|
||||
isLocalCredential: true,
|
||||
});
|
||||
|
||||
form.setNewPassword("recovered-secret");
|
||||
form.setConfirmPassword("recovered-secret");
|
||||
expect(form.beginSubmit()).toEqual({
|
||||
valid: true,
|
||||
payload: { password: "recovered-secret" },
|
||||
});
|
||||
});
|
||||
|
||||
test("remote remove step seeds currentPassword from change step and submits password=null", () => {
|
||||
const form = openDaemonPasswordForm({
|
||||
mode: "change",
|
||||
isLocalCredential: false,
|
||||
});
|
||||
form.setCurrentPassword("my-current-pw");
|
||||
form.enterRemoveStep();
|
||||
expect(form.getState().step).toBe("remove");
|
||||
expect(form.getState().currentPassword).toBe("my-current-pw");
|
||||
|
||||
expect(form.beginSubmit()).toEqual({
|
||||
valid: true,
|
||||
payload: { password: null, currentPassword: "my-current-pw" },
|
||||
});
|
||||
|
||||
form.finishSubmitError({
|
||||
code: "incorrect_password",
|
||||
message: "Current password is incorrect",
|
||||
});
|
||||
expect(form.getState().fieldErrors.currentPassword).toBe("incorrect_password");
|
||||
|
||||
form.backToChangeStep();
|
||||
expect(form.getState().step).toBe("change");
|
||||
});
|
||||
|
||||
test("shouldSyncHostProfilePassword skips persisting password on local-only profiles when using localCredentialAuth", () => {
|
||||
expect(
|
||||
shouldSyncHostProfilePassword({
|
||||
localCredentialAuth: true,
|
||||
connections: [
|
||||
{ id: "socket:/tmp/paseo.sock", type: "directSocket", path: "/tmp/paseo.sock" },
|
||||
],
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
shouldSyncHostProfilePassword({
|
||||
localCredentialAuth: true,
|
||||
connections: [
|
||||
{ id: "direct:127.0.0.1:6767", type: "directTcp", endpoint: "127.0.0.1:6767" },
|
||||
],
|
||||
}),
|
||||
).toBe(false);
|
||||
|
||||
// Local desktop profile that also has a relay or remote route DOES sync so remote routes stay usable.
|
||||
expect(
|
||||
shouldSyncHostProfilePassword({
|
||||
localCredentialAuth: true,
|
||||
connections: [
|
||||
{ id: "direct:127.0.0.1:6767", type: "directTcp", endpoint: "127.0.0.1:6767" },
|
||||
{
|
||||
id: "relay:relay.paseo.sh:443",
|
||||
type: "relay",
|
||||
relayEndpoint: "relay.paseo.sh:443",
|
||||
daemonPublicKeyB64: "pk",
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
// Non-local browser session always syncs even on localhost so reload stays authenticated.
|
||||
expect(
|
||||
shouldSyncHostProfilePassword({
|
||||
localCredentialAuth: false,
|
||||
connections: [
|
||||
{ id: "direct:127.0.0.1:6767", type: "directTcp", endpoint: "127.0.0.1:6767" },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,269 @@
|
||||
import { isLoopbackEndpoint } from "@/hosts/connection-display";
|
||||
import type { HostConnection } from "@/types/host-connection";
|
||||
|
||||
export const DAEMON_PASSWORD_MIN_CHARS = 8;
|
||||
export const DAEMON_PASSWORD_MAX_BYTES = 72;
|
||||
|
||||
export type DaemonPasswordFormStep = "set" | "change" | "remove";
|
||||
|
||||
export type DaemonPasswordFieldErrorCode =
|
||||
| "current_password_required"
|
||||
| "incorrect_password"
|
||||
| "too_short"
|
||||
| "too_long"
|
||||
| "mismatch"
|
||||
| "invalid_password";
|
||||
|
||||
export interface DaemonPasswordFormFieldErrors {
|
||||
currentPassword: DaemonPasswordFieldErrorCode | null;
|
||||
newPassword: DaemonPasswordFieldErrorCode | null;
|
||||
confirmPassword: DaemonPasswordFieldErrorCode | null;
|
||||
}
|
||||
|
||||
export interface DaemonPasswordFormState {
|
||||
step: DaemonPasswordFormStep;
|
||||
isLocalCredential: boolean;
|
||||
currentPassword: string;
|
||||
newPassword: string;
|
||||
confirmPassword: string;
|
||||
showCurrentPassword: boolean;
|
||||
showNewPassword: boolean;
|
||||
showConfirmPassword: boolean;
|
||||
submitting: boolean;
|
||||
fieldErrors: DaemonPasswordFormFieldErrors;
|
||||
submitError: string | null;
|
||||
}
|
||||
|
||||
export interface DaemonPasswordFormSnapshot {
|
||||
mode: "set" | "change";
|
||||
isLocalCredential: boolean;
|
||||
}
|
||||
|
||||
export type DaemonPasswordSubmitResult =
|
||||
| { valid: false }
|
||||
| { valid: true; payload: { password: string | null; currentPassword?: string } };
|
||||
|
||||
export interface DaemonPasswordFormModel {
|
||||
getState(): DaemonPasswordFormState;
|
||||
subscribe(listener: () => void): () => void;
|
||||
setCurrentPassword(value: string): void;
|
||||
setNewPassword(value: string): void;
|
||||
setConfirmPassword(value: string): void;
|
||||
toggleShowCurrentPassword(): void;
|
||||
toggleShowNewPassword(): void;
|
||||
toggleShowConfirmPassword(): void;
|
||||
enterRemoveStep(): void;
|
||||
backToChangeStep(): void;
|
||||
beginSubmit(): DaemonPasswordSubmitResult;
|
||||
finishSubmitSuccess(): void;
|
||||
finishSubmitError(error: { code?: string; message: string }): void;
|
||||
}
|
||||
|
||||
const textEncoder = new TextEncoder();
|
||||
|
||||
export function utf8ByteLength(value: string): number {
|
||||
return textEncoder.encode(value).byteLength;
|
||||
}
|
||||
|
||||
export function isLocalOnlyHostConnection(connection: HostConnection): boolean {
|
||||
if (connection.type === "directSocket" || connection.type === "directPipe") {
|
||||
return true;
|
||||
}
|
||||
if (connection.type === "directTcp") {
|
||||
return isLoopbackEndpoint(connection.endpoint);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function shouldSyncHostProfilePassword(input: {
|
||||
localCredentialAuth: boolean;
|
||||
connections: readonly HostConnection[];
|
||||
}): boolean {
|
||||
if (!input.localCredentialAuth) {
|
||||
return true;
|
||||
}
|
||||
return input.connections.some((connection) => !isLocalOnlyHostConnection(connection));
|
||||
}
|
||||
|
||||
const EMPTY_FIELD_ERRORS: DaemonPasswordFormFieldErrors = {
|
||||
currentPassword: null,
|
||||
newPassword: null,
|
||||
confirmPassword: null,
|
||||
};
|
||||
|
||||
export function openDaemonPasswordForm(
|
||||
snapshot: DaemonPasswordFormSnapshot,
|
||||
): DaemonPasswordFormModel {
|
||||
const listeners = new Set<() => void>();
|
||||
let state: DaemonPasswordFormState = {
|
||||
step: snapshot.mode,
|
||||
isLocalCredential: snapshot.isLocalCredential,
|
||||
currentPassword: "",
|
||||
newPassword: "",
|
||||
confirmPassword: "",
|
||||
showCurrentPassword: false,
|
||||
showNewPassword: false,
|
||||
showConfirmPassword: false,
|
||||
submitting: false,
|
||||
fieldErrors: { ...EMPTY_FIELD_ERRORS },
|
||||
submitError: null,
|
||||
};
|
||||
|
||||
const publish = (next: DaemonPasswordFormState) => {
|
||||
state = next;
|
||||
for (const listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
getState: () => state,
|
||||
|
||||
subscribe(listener) {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
};
|
||||
},
|
||||
|
||||
setCurrentPassword(value) {
|
||||
publish({
|
||||
...state,
|
||||
currentPassword: value,
|
||||
fieldErrors: { ...state.fieldErrors, currentPassword: null },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
setNewPassword(value) {
|
||||
publish({
|
||||
...state,
|
||||
newPassword: value,
|
||||
fieldErrors: { ...state.fieldErrors, newPassword: null, confirmPassword: null },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
setConfirmPassword(value) {
|
||||
publish({
|
||||
...state,
|
||||
confirmPassword: value,
|
||||
fieldErrors: { ...state.fieldErrors, confirmPassword: null },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
toggleShowCurrentPassword() {
|
||||
publish({ ...state, showCurrentPassword: !state.showCurrentPassword });
|
||||
},
|
||||
|
||||
toggleShowNewPassword() {
|
||||
publish({ ...state, showNewPassword: !state.showNewPassword });
|
||||
},
|
||||
|
||||
toggleShowConfirmPassword() {
|
||||
publish({ ...state, showConfirmPassword: !state.showConfirmPassword });
|
||||
},
|
||||
|
||||
enterRemoveStep() {
|
||||
if (state.step !== "change" || state.submitting) return;
|
||||
publish({
|
||||
...state,
|
||||
step: "remove",
|
||||
fieldErrors: { ...EMPTY_FIELD_ERRORS },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
backToChangeStep() {
|
||||
if (state.step !== "remove" || state.submitting) return;
|
||||
publish({
|
||||
...state,
|
||||
step: "change",
|
||||
fieldErrors: { ...EMPTY_FIELD_ERRORS },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
beginSubmit() {
|
||||
if (state.submitting) {
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
const fieldErrors: DaemonPasswordFormFieldErrors = { ...EMPTY_FIELD_ERRORS };
|
||||
const needsCurrentPassword =
|
||||
(state.step === "change" || state.step === "remove") && !state.isLocalCredential;
|
||||
|
||||
if (needsCurrentPassword && state.currentPassword.length === 0) {
|
||||
fieldErrors.currentPassword = "current_password_required";
|
||||
}
|
||||
|
||||
if (state.step !== "remove") {
|
||||
if (state.newPassword.length < DAEMON_PASSWORD_MIN_CHARS) {
|
||||
fieldErrors.newPassword = "too_short";
|
||||
} else if (utf8ByteLength(state.newPassword) > DAEMON_PASSWORD_MAX_BYTES) {
|
||||
fieldErrors.newPassword = "too_long";
|
||||
} else if (state.confirmPassword !== state.newPassword) {
|
||||
fieldErrors.confirmPassword = "mismatch";
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
fieldErrors.currentPassword !== null ||
|
||||
fieldErrors.newPassword !== null ||
|
||||
fieldErrors.confirmPassword !== null
|
||||
) {
|
||||
publish({
|
||||
...state,
|
||||
fieldErrors,
|
||||
submitError: null,
|
||||
});
|
||||
return { valid: false };
|
||||
}
|
||||
|
||||
publish({
|
||||
...state,
|
||||
submitting: true,
|
||||
fieldErrors: { ...EMPTY_FIELD_ERRORS },
|
||||
submitError: null,
|
||||
});
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
payload: {
|
||||
password: state.step === "remove" ? null : state.newPassword,
|
||||
...(needsCurrentPassword ? { currentPassword: state.currentPassword } : {}),
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
finishSubmitSuccess() {
|
||||
publish({
|
||||
...state,
|
||||
submitting: false,
|
||||
fieldErrors: { ...EMPTY_FIELD_ERRORS },
|
||||
submitError: null,
|
||||
});
|
||||
},
|
||||
|
||||
finishSubmitError(error) {
|
||||
const fieldErrors: DaemonPasswordFormFieldErrors = { ...EMPTY_FIELD_ERRORS };
|
||||
let submitError: string | null = null;
|
||||
if (error.code === "incorrect_password") {
|
||||
fieldErrors.currentPassword = "incorrect_password";
|
||||
} else if (error.code === "current_password_required") {
|
||||
fieldErrors.currentPassword = "current_password_required";
|
||||
} else if (error.code === "invalid_password") {
|
||||
fieldErrors.newPassword = "invalid_password";
|
||||
} else {
|
||||
submitError = error.message;
|
||||
}
|
||||
publish({
|
||||
...state,
|
||||
submitting: false,
|
||||
fieldErrors,
|
||||
submitError,
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
import { useCallback, useMemo, useState, useSyncExternalStore } from "react";
|
||||
import { View } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import { Eye, EyeOff } from "lucide-react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { DaemonRpcError } from "@getpaseo/client";
|
||||
import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-modal-sheet";
|
||||
import { Alert } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FormTextInput } from "@/components/ui/form-field";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import { useHostMutations, useHostRuntimeClient, useHosts } from "@/runtime/host-runtime";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { confirmDialog } from "@/utils/confirm-dialog";
|
||||
import {
|
||||
openDaemonPasswordForm,
|
||||
shouldSyncHostProfilePassword,
|
||||
type DaemonPasswordFieldErrorCode,
|
||||
type DaemonPasswordFormModel,
|
||||
} from "./daemon-password-form-model";
|
||||
|
||||
const FLEX_ONE_STYLE = { flex: 1 } as const;
|
||||
const SNAP_POINTS: string[] = ["72%", "92%"];
|
||||
|
||||
function translateFieldError(
|
||||
code: DaemonPasswordFieldErrorCode | null,
|
||||
t: TFunction,
|
||||
): string | null {
|
||||
switch (code) {
|
||||
case "current_password_required":
|
||||
return t("devices.password.errors.currentRequired");
|
||||
case "incorrect_password":
|
||||
return t("devices.password.errors.currentIncorrect");
|
||||
case "too_short":
|
||||
return t("devices.password.errors.tooShort");
|
||||
case "too_long":
|
||||
case "invalid_password":
|
||||
return t("devices.password.errors.tooLong");
|
||||
case "mismatch":
|
||||
return t("devices.password.errors.mismatch");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function formatSuccessToast(
|
||||
action: "set" | "change" | "remove",
|
||||
disconnectedSessionCount: number,
|
||||
t: TFunction,
|
||||
): string {
|
||||
if (action === "remove") {
|
||||
return t("devices.password.toast.removed");
|
||||
}
|
||||
if (action === "set") {
|
||||
if (disconnectedSessionCount === 1) {
|
||||
return t("devices.password.toast.setDisconnectedOne");
|
||||
}
|
||||
if (disconnectedSessionCount > 1) {
|
||||
return t("devices.password.toast.setDisconnectedOther", { count: disconnectedSessionCount });
|
||||
}
|
||||
return t("devices.password.toast.set");
|
||||
}
|
||||
if (disconnectedSessionCount === 1) {
|
||||
return t("devices.password.toast.updatedDisconnectedOne");
|
||||
}
|
||||
if (disconnectedSessionCount > 1) {
|
||||
return t("devices.password.toast.updatedDisconnectedOther", {
|
||||
count: disconnectedSessionCount,
|
||||
});
|
||||
}
|
||||
return t("devices.password.toast.updated");
|
||||
}
|
||||
|
||||
function extractRpcError(
|
||||
error: unknown,
|
||||
fallbackMessage: string,
|
||||
): {
|
||||
code?: string;
|
||||
message: string;
|
||||
} {
|
||||
if (error instanceof DaemonRpcError) {
|
||||
return { code: error.code, message: error.userMessage || error.message };
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
return { message: error.message || fallbackMessage };
|
||||
}
|
||||
return { message: fallbackMessage };
|
||||
}
|
||||
|
||||
function resolvePrimaryButtonLabel(
|
||||
step: "set" | "change" | "remove",
|
||||
submitting: boolean,
|
||||
t: TFunction,
|
||||
): string {
|
||||
if (step === "set") {
|
||||
return submitting ? t("devices.password.setting") : t("devices.password.setAction");
|
||||
}
|
||||
if (step === "change") {
|
||||
return submitting ? t("devices.password.saving") : t("devices.password.saveAction");
|
||||
}
|
||||
return submitting ? t("devices.password.removing") : t("devices.password.removeAction");
|
||||
}
|
||||
|
||||
function DaemonPasswordStepBanner({
|
||||
step,
|
||||
t,
|
||||
}: {
|
||||
step: "set" | "change" | "remove";
|
||||
t: TFunction;
|
||||
}) {
|
||||
if (step === "remove") {
|
||||
return (
|
||||
<Alert
|
||||
size="sm"
|
||||
variant="warning"
|
||||
description={t("devices.password.removeWarning")}
|
||||
testID="daemon-password-remove-warning"
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Alert
|
||||
size="sm"
|
||||
variant="info"
|
||||
description={
|
||||
step === "set" ? t("devices.password.setInfo") : t("devices.password.changeInfo")
|
||||
}
|
||||
testID="daemon-password-info"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface PasswordInputFieldProps {
|
||||
label: string;
|
||||
initialValue: string;
|
||||
showPassword: boolean;
|
||||
onChangeText: (value: string) => void;
|
||||
onToggleShow: () => void;
|
||||
onSubmitEditing?: () => void;
|
||||
error: string | null;
|
||||
disabled: boolean;
|
||||
autoFocus?: boolean;
|
||||
size: "sm" | "md";
|
||||
returnKeyType?: "next" | "done";
|
||||
testID: string;
|
||||
}
|
||||
|
||||
function PasswordInputField({
|
||||
label,
|
||||
initialValue,
|
||||
showPassword,
|
||||
onChangeText,
|
||||
onToggleShow,
|
||||
onSubmitEditing,
|
||||
error,
|
||||
disabled,
|
||||
autoFocus,
|
||||
size,
|
||||
returnKeyType = "next",
|
||||
testID,
|
||||
}: PasswordInputFieldProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Field label={label} error={error} testID={`${testID}-field`}>
|
||||
<View style={styles.passwordRow}>
|
||||
<View style={styles.passwordInputWrap}>
|
||||
<FormTextInput
|
||||
initialValue={initialValue}
|
||||
onChangeText={onChangeText}
|
||||
onSubmitEditing={onSubmitEditing}
|
||||
secureTextEntry={!showPassword}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
autoComplete="off"
|
||||
autoFocus={autoFocus}
|
||||
editable={!disabled}
|
||||
invalid={Boolean(error)}
|
||||
size={size}
|
||||
returnKeyType={returnKeyType}
|
||||
testID={testID}
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
variant="outline"
|
||||
size={size}
|
||||
leftIcon={showPassword ? EyeOff : Eye}
|
||||
onPress={onToggleShow}
|
||||
disabled={disabled}
|
||||
accessibilityLabel={
|
||||
showPassword ? t("devices.password.hide") : t("devices.password.show")
|
||||
}
|
||||
testID={`${testID}-toggle`}
|
||||
/>
|
||||
</View>
|
||||
</Field>
|
||||
);
|
||||
}
|
||||
|
||||
export interface DaemonPasswordFormContentProps {
|
||||
serverId: string;
|
||||
initialMode: "set" | "change";
|
||||
model?: DaemonPasswordFormModel;
|
||||
onCancel: () => void;
|
||||
onCompleted: () => void;
|
||||
}
|
||||
|
||||
export function DaemonPasswordFormContent({
|
||||
serverId,
|
||||
initialMode,
|
||||
model: externalModel,
|
||||
onCancel,
|
||||
onCompleted,
|
||||
}: DaemonPasswordFormContentProps) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const fieldSize = isCompact ? "md" : "sm";
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const hosts = useHosts();
|
||||
const { setHostPassword } = useHostMutations();
|
||||
const serverInfo = useSessionStore((state) => state.sessions[serverId]?.serverInfo ?? null);
|
||||
const host = useMemo(
|
||||
() => hosts.find((item) => item.serverId === serverId) ?? null,
|
||||
[hosts, serverId],
|
||||
);
|
||||
const isLocalCredential = serverInfo?.localCredentialAuth === true;
|
||||
|
||||
const [internalModel] = useState(() =>
|
||||
openDaemonPasswordForm({
|
||||
mode: initialMode,
|
||||
isLocalCredential,
|
||||
}),
|
||||
);
|
||||
const model = externalModel ?? internalModel;
|
||||
const state = useSyncExternalStore(model.subscribe, model.getState, model.getState);
|
||||
|
||||
const syncProfilePasswordIfNeeded = useCallback(
|
||||
async (nextPassword: string | null) => {
|
||||
if (
|
||||
!shouldSyncHostProfilePassword({
|
||||
localCredentialAuth: serverInfo?.localCredentialAuth === true,
|
||||
connections: host?.connections ?? [],
|
||||
})
|
||||
) {
|
||||
return;
|
||||
}
|
||||
await setHostPassword(serverId, nextPassword ?? "");
|
||||
},
|
||||
[host?.connections, serverId, serverInfo?.localCredentialAuth, setHostPassword],
|
||||
);
|
||||
|
||||
const executeMutation = useCallback(
|
||||
async (
|
||||
action: "set" | "change" | "remove",
|
||||
payload: {
|
||||
password: string | null;
|
||||
currentPassword?: string;
|
||||
},
|
||||
) => {
|
||||
if (!client) {
|
||||
model.finishSubmitError({ message: t("workspace.terminal.hostDisconnected") });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const result = await client.setDaemonPassword(payload);
|
||||
await syncProfilePasswordIfNeeded(payload.password);
|
||||
model.finishSubmitSuccess();
|
||||
toast.show(formatSuccessToast(action, result.disconnectedSessionCount, t), {
|
||||
variant: "success",
|
||||
});
|
||||
onCompleted();
|
||||
} catch (error) {
|
||||
model.finishSubmitError(extractRpcError(error, t("errors.unableToSave")));
|
||||
}
|
||||
},
|
||||
[client, model, onCompleted, syncProfilePasswordIfNeeded, t, toast],
|
||||
);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
const attempt = model.beginSubmit();
|
||||
if (!attempt.valid) return;
|
||||
void executeMutation(state.step, attempt.payload);
|
||||
}, [executeMutation, model, state.step]);
|
||||
|
||||
const handleRequestRemove = useCallback(() => {
|
||||
if (state.submitting) return;
|
||||
if (!state.isLocalCredential) {
|
||||
model.enterRemoveStep();
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
const confirmed = await confirmDialog({
|
||||
title: t("devices.password.removeTitle"),
|
||||
message: t("devices.password.removeWarning"),
|
||||
confirmLabel: t("devices.password.removeAction"),
|
||||
cancelLabel: t("common.actions.cancel"),
|
||||
destructive: true,
|
||||
});
|
||||
if (!confirmed) return;
|
||||
model.enterRemoveStep();
|
||||
const attempt = model.beginSubmit();
|
||||
if (!attempt.valid) return;
|
||||
await executeMutation("remove", attempt.payload);
|
||||
})();
|
||||
}, [executeMutation, model, state.isLocalCredential, state.submitting, t]);
|
||||
|
||||
const showCurrentPassword =
|
||||
(state.step === "change" || state.step === "remove") && !state.isLocalCredential;
|
||||
const primaryLabel = resolvePrimaryButtonLabel(state.step, state.submitting, t);
|
||||
|
||||
return (
|
||||
<View style={styles.form} testID={`daemon-password-form-${state.step}`}>
|
||||
<DaemonPasswordStepBanner step={state.step} t={t} />
|
||||
|
||||
{showCurrentPassword ? (
|
||||
<PasswordInputField
|
||||
key={`current-${state.step}`}
|
||||
label={t("devices.password.fields.current")}
|
||||
initialValue={state.currentPassword}
|
||||
showPassword={state.showCurrentPassword}
|
||||
onChangeText={model.setCurrentPassword}
|
||||
onToggleShow={model.toggleShowCurrentPassword}
|
||||
onSubmitEditing={state.step === "remove" ? handleSubmit : undefined}
|
||||
error={translateFieldError(state.fieldErrors.currentPassword, t)}
|
||||
disabled={state.submitting}
|
||||
autoFocus
|
||||
size={fieldSize}
|
||||
returnKeyType={state.step === "remove" ? "done" : "next"}
|
||||
testID="daemon-password-current-input"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{state.step !== "remove" ? (
|
||||
<>
|
||||
<PasswordInputField
|
||||
key={`new-${state.step}`}
|
||||
label={t("devices.password.fields.new")}
|
||||
initialValue={state.newPassword}
|
||||
showPassword={state.showNewPassword}
|
||||
onChangeText={model.setNewPassword}
|
||||
onToggleShow={model.toggleShowNewPassword}
|
||||
error={translateFieldError(state.fieldErrors.newPassword, t)}
|
||||
disabled={state.submitting}
|
||||
autoFocus={!showCurrentPassword}
|
||||
size={fieldSize}
|
||||
testID="daemon-password-new-input"
|
||||
/>
|
||||
<PasswordInputField
|
||||
key={`confirm-${state.step}`}
|
||||
label={
|
||||
state.step === "set"
|
||||
? t("devices.password.fields.confirm")
|
||||
: t("devices.password.fields.confirmNew")
|
||||
}
|
||||
initialValue={state.confirmPassword}
|
||||
showPassword={state.showConfirmPassword}
|
||||
onChangeText={model.setConfirmPassword}
|
||||
onToggleShow={model.toggleShowConfirmPassword}
|
||||
onSubmitEditing={handleSubmit}
|
||||
error={translateFieldError(state.fieldErrors.confirmPassword, t)}
|
||||
disabled={state.submitting}
|
||||
size={fieldSize}
|
||||
returnKeyType="done"
|
||||
testID="daemon-password-confirm-input"
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{state.submitError ? (
|
||||
<Alert
|
||||
size="sm"
|
||||
variant="error"
|
||||
description={state.submitError}
|
||||
testID="daemon-password-submit-error"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<View style={styles.actions}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
style={FLEX_ONE_STYLE}
|
||||
onPress={state.step === "remove" ? model.backToChangeStep : onCancel}
|
||||
disabled={state.submitting}
|
||||
testID="daemon-password-cancel-button"
|
||||
>
|
||||
{t("common.actions.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
variant={state.step === "remove" ? "destructive" : "default"}
|
||||
style={FLEX_ONE_STYLE}
|
||||
loading={state.submitting}
|
||||
disabled={state.submitting}
|
||||
onPress={handleSubmit}
|
||||
testID="daemon-password-submit-button"
|
||||
>
|
||||
{primaryLabel}
|
||||
</Button>
|
||||
</View>
|
||||
|
||||
{state.step === "change" ? (
|
||||
<View style={styles.removeSection}>
|
||||
<View style={styles.divider} />
|
||||
<Button
|
||||
variant="ghost"
|
||||
onPress={handleRequestRemove}
|
||||
disabled={state.submitting}
|
||||
textStyle={styles.removeButtonText}
|
||||
testID="daemon-password-remove-trigger"
|
||||
>
|
||||
{t("devices.password.removeAction")}
|
||||
</Button>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export interface DaemonPasswordSheetProps {
|
||||
serverId: string;
|
||||
visible: boolean;
|
||||
initialMode: "set" | "change";
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function DaemonPasswordSheet({
|
||||
serverId,
|
||||
visible,
|
||||
initialMode,
|
||||
onClose,
|
||||
}: DaemonPasswordSheetProps) {
|
||||
if (!visible) return null;
|
||||
return (
|
||||
<DaemonPasswordSheetOpen
|
||||
key={`${serverId}:${initialMode}`}
|
||||
serverId={serverId}
|
||||
initialMode={initialMode}
|
||||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function DaemonPasswordSheetOpen({
|
||||
serverId,
|
||||
initialMode,
|
||||
onClose,
|
||||
}: Omit<DaemonPasswordSheetProps, "visible">) {
|
||||
const { t } = useTranslation();
|
||||
const isLocalCredential = useSessionStore(
|
||||
(state) => state.sessions[serverId]?.serverInfo?.localCredentialAuth === true,
|
||||
);
|
||||
const [model] = useState(() =>
|
||||
openDaemonPasswordForm({
|
||||
mode: initialMode,
|
||||
isLocalCredential,
|
||||
}),
|
||||
);
|
||||
const state = useSyncExternalStore(model.subscribe, model.getState, model.getState);
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
if (state.submitting) return;
|
||||
onClose();
|
||||
}, [onClose, state.submitting]);
|
||||
|
||||
const header = useMemo<SheetHeader>(() => {
|
||||
if (state.step === "remove") {
|
||||
return {
|
||||
title: t("devices.password.removeTitle"),
|
||||
back: {
|
||||
onPress: model.backToChangeStep,
|
||||
label: t("common.actions.back"),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
title:
|
||||
state.step === "set" ? t("devices.password.setTitle") : t("devices.password.changeTitle"),
|
||||
};
|
||||
}, [model.backToChangeStep, state.step, t]);
|
||||
|
||||
return (
|
||||
<AdaptiveModalSheet
|
||||
header={header}
|
||||
visible
|
||||
onClose={handleClose}
|
||||
snapPoints={SNAP_POINTS}
|
||||
desktopMaxWidth={440}
|
||||
testID="daemon-password-sheet"
|
||||
>
|
||||
<DaemonPasswordFormContent
|
||||
serverId={serverId}
|
||||
initialMode={initialMode}
|
||||
model={model}
|
||||
onCancel={handleClose}
|
||||
onCompleted={onClose}
|
||||
/>
|
||||
</AdaptiveModalSheet>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
form: {
|
||||
gap: theme.spacing[4],
|
||||
},
|
||||
passwordRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
passwordInputWrap: {
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
},
|
||||
actions: {
|
||||
flexDirection: "row",
|
||||
gap: theme.spacing[3],
|
||||
marginTop: theme.spacing[1],
|
||||
},
|
||||
removeSection: {
|
||||
gap: theme.spacing[3],
|
||||
marginTop: theme.spacing[1],
|
||||
},
|
||||
divider: {
|
||||
height: theme.borderWidth[1],
|
||||
backgroundColor: theme.colors.border,
|
||||
},
|
||||
removeButtonText: {
|
||||
color: theme.colors.destructive,
|
||||
},
|
||||
}));
|
||||
@@ -0,0 +1,168 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { TFunction } from "i18next";
|
||||
import type { DaemonSessionSummary } from "@getpaseo/protocol/daemon-clients";
|
||||
import {
|
||||
formatAppDetail,
|
||||
formatAuthMethodLabel,
|
||||
formatDeviceDetail,
|
||||
formatSessionHint,
|
||||
formatSessionTitle,
|
||||
} from "./device-display";
|
||||
|
||||
const translations: Record<string, string> = {
|
||||
"devices.connected.thisDevice": "This device",
|
||||
"devices.transport.local": "Local",
|
||||
"devices.transport.tailscale": "Tailscale",
|
||||
"devices.transport.relay": "Relay",
|
||||
"devices.transport.hub": "Hub",
|
||||
"devices.transport.direct": "Direct",
|
||||
"devices.transport.viaHost": "Via host",
|
||||
"devices.kind.desktop": "Desktop",
|
||||
"devices.kind.mobile": "Mobile",
|
||||
"devices.kind.web": "Web",
|
||||
"devices.kind.hub": "Hub",
|
||||
"devices.kind.plugin": "Plugin",
|
||||
"devices.kind.host": "Host",
|
||||
"devices.auth.localMachine": "Local machine",
|
||||
"devices.auth.password": "Password",
|
||||
"devices.auth.openAccess": "Open access",
|
||||
"devices.auth.hub": "Hub",
|
||||
};
|
||||
|
||||
const t = ((key: string, options?: { host?: string }) => {
|
||||
if (key === "devices.transport.via" && options?.host) {
|
||||
return `Via ${options.host}`;
|
||||
}
|
||||
return translations[key] ?? key;
|
||||
}) as unknown as TFunction;
|
||||
|
||||
function makeSession(overrides: Partial<DaemonSessionSummary> = {}): DaemonSessionSummary {
|
||||
return {
|
||||
sessionId: "sess_1",
|
||||
principalId: "owner",
|
||||
isCurrentSession: false,
|
||||
name: null,
|
||||
platform: null,
|
||||
clientType: "browser",
|
||||
appVersion: "0.19.0",
|
||||
transport: "local",
|
||||
permissions: ["daemon.read", "workspace.read"],
|
||||
connectedAt: "2026-12-01T10:00:00.000Z",
|
||||
socketCount: 1,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("device-display formatting", () => {
|
||||
it("shows real machine name, This device hint, macOS version, and omits 127.0.0.1 on Local Electron", () => {
|
||||
const session = makeSession({
|
||||
isCurrentSession: true,
|
||||
name: "MacBook Pro",
|
||||
appKind: "desktop",
|
||||
platform: "macos",
|
||||
osName: "macOS",
|
||||
osVersion: "15.3.1",
|
||||
transport: "local",
|
||||
remoteIp: "127.0.0.1",
|
||||
ipSource: "direct",
|
||||
authMethod: "local_credential",
|
||||
});
|
||||
|
||||
expect(formatSessionTitle(session, t)).toBe("MacBook Pro");
|
||||
expect(formatSessionHint(session, null, t)).toBe("This device · Local · macOS 15.3");
|
||||
expect(formatDeviceDetail(session)).toBe("MacBook Pro · macOS 15.3.1");
|
||||
expect(formatAppDetail(session, t)).toBe("Desktop 0.19.0");
|
||||
expect(formatAuthMethodLabel(session.authMethod, t)).toBe("Local machine");
|
||||
});
|
||||
|
||||
it("shows observed IP and OS on Tailscale Android and omits OS repetition on Web", () => {
|
||||
const android = makeSession({
|
||||
name: "Pixel 9 Pro",
|
||||
clientType: "mobile",
|
||||
appKind: "mobile",
|
||||
platform: "android",
|
||||
osName: "Android",
|
||||
osVersion: "15",
|
||||
deviceModel: "Pixel 9 Pro",
|
||||
transport: "tailscale",
|
||||
remoteIp: "100.84.12.9",
|
||||
ipSource: "direct",
|
||||
authMethod: "password",
|
||||
});
|
||||
expect(formatSessionTitle(android, t)).toBe("Pixel 9 Pro");
|
||||
expect(formatSessionHint(android, null, t)).toBe("Tailscale · 100.84.12.9 · Android 15");
|
||||
expect(formatDeviceDetail(android)).toBe("Pixel 9 Pro · Android 15");
|
||||
expect(formatAppDetail(android, t)).toBe("Mobile 0.19.0");
|
||||
|
||||
const web = makeSession({
|
||||
isCurrentSession: true,
|
||||
name: "Chrome on macOS",
|
||||
clientType: "browser",
|
||||
appKind: "web",
|
||||
platform: "web",
|
||||
browserName: "Chrome",
|
||||
osName: "macOS",
|
||||
transport: "relay",
|
||||
remoteIp: null,
|
||||
ipSource: null,
|
||||
});
|
||||
expect(formatSessionTitle(web, t)).toBe("Chrome on macOS");
|
||||
expect(formatSessionHint(web, null, t)).toBe("This device · Relay");
|
||||
expect(formatDeviceDetail(web)).toBe("Chrome · macOS");
|
||||
expect(formatAppDetail(web, t)).toBe("Web 0.19.0");
|
||||
});
|
||||
|
||||
it("shows Linux in collapsed hint and distro name in expanded Device detail", () => {
|
||||
const linux = makeSession({
|
||||
name: "workstation",
|
||||
appKind: "desktop",
|
||||
platform: "linux",
|
||||
osName: "Linux",
|
||||
osVersion: "Ubuntu 24.04.1 LTS",
|
||||
transport: "direct",
|
||||
remoteIp: "192.168.1.42",
|
||||
ipSource: "direct",
|
||||
});
|
||||
|
||||
expect(formatSessionHint(linux, null, t)).toBe("Direct · 192.168.1.42 · Linux");
|
||||
expect(formatDeviceDetail(linux)).toBe("workstation · Ubuntu 24.04.1 LTS");
|
||||
});
|
||||
|
||||
it("falls back cleanly for unnamed legacy 0.18.2 clients and Hub", () => {
|
||||
const legacy = makeSession({
|
||||
isCurrentSession: true,
|
||||
name: null,
|
||||
clientType: "mobile",
|
||||
platform: null,
|
||||
appVersion: "0.18.2",
|
||||
transport: "relay",
|
||||
});
|
||||
expect(formatSessionTitle(legacy, t)).toBe("This device");
|
||||
expect(formatSessionHint(legacy, null, t)).toBe("Relay · Mobile 0.18.2");
|
||||
expect(formatDeviceDetail(legacy)).toBeNull();
|
||||
|
||||
const hub = makeSession({
|
||||
name: "Paseo Hub",
|
||||
clientType: "hub",
|
||||
appKind: "hub",
|
||||
appVersion: null,
|
||||
transport: "hub",
|
||||
authMethod: "hub",
|
||||
});
|
||||
expect(formatSessionTitle(hub, t)).toBe("Paseo Hub");
|
||||
expect(formatSessionHint(hub, null, t)).toBe("Hub");
|
||||
expect(formatDeviceDetail(hub)).toBeNull();
|
||||
expect(formatAppDetail(hub, t)).toBe("Hub");
|
||||
expect(formatAuthMethodLabel(hub.authMethod, t)).toBe("Hub");
|
||||
});
|
||||
|
||||
it("maps every daemon SessionAuthMethod value cleanly", () => {
|
||||
expect(formatAuthMethodLabel("local_credential", t)).toBe("Local machine");
|
||||
expect(formatAuthMethodLabel("password", t)).toBe("Password");
|
||||
expect(formatAuthMethodLabel("header_bearer", t)).toBe("Password");
|
||||
expect(formatAuthMethodLabel("unprotected", t)).toBe("Open access");
|
||||
expect(formatAuthMethodLabel("hub", t)).toBe("Hub");
|
||||
expect(formatAuthMethodLabel("plugin", t)).toBe("Plugin");
|
||||
expect(formatAuthMethodLabel(null, t)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,209 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type {
|
||||
DaemonSessionSummary,
|
||||
DaemonSessionTransport,
|
||||
} from "@getpaseo/protocol/daemon-clients";
|
||||
|
||||
function osNameFromPlatform(platform: string | null | undefined): string | null {
|
||||
switch (platform) {
|
||||
case "macos":
|
||||
return "macOS";
|
||||
case "linux":
|
||||
return "Linux";
|
||||
case "windows":
|
||||
return "Windows";
|
||||
case "ios":
|
||||
return "iOS";
|
||||
case "android":
|
||||
return "Android";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function shortenNumericVersion(version: string): string {
|
||||
const match = version.match(/^(\d+(?:\.\d+)?)/);
|
||||
return match?.[1] ?? version;
|
||||
}
|
||||
|
||||
export function formatTransportLabel(
|
||||
transport: DaemonSessionTransport,
|
||||
viaHostName: string | null,
|
||||
t: TFunction,
|
||||
): string {
|
||||
switch (transport) {
|
||||
case "local_ipc":
|
||||
case "local":
|
||||
return t("devices.transport.local");
|
||||
case "tailscale":
|
||||
return t("devices.transport.tailscale");
|
||||
case "relay":
|
||||
return t("devices.transport.relay");
|
||||
case "hub":
|
||||
return t("devices.transport.hub");
|
||||
case "via":
|
||||
return viaHostName
|
||||
? t("devices.transport.via", { host: viaHostName })
|
||||
: t("devices.transport.viaHost");
|
||||
case "direct":
|
||||
return t("devices.transport.direct");
|
||||
}
|
||||
}
|
||||
|
||||
export function formatAppKindLabel(
|
||||
session: Pick<DaemonSessionSummary, "appKind" | "clientType" | "platform">,
|
||||
t: TFunction,
|
||||
): string {
|
||||
switch (session.appKind) {
|
||||
case "desktop":
|
||||
return t("devices.kind.desktop");
|
||||
case "mobile":
|
||||
return t("devices.kind.mobile");
|
||||
case "web":
|
||||
return t("devices.kind.web");
|
||||
case "hub":
|
||||
return t("devices.kind.hub");
|
||||
case "cli":
|
||||
return "CLI";
|
||||
case "mcp":
|
||||
return "MCP";
|
||||
case "plugin":
|
||||
return t("devices.kind.plugin");
|
||||
case "daemon":
|
||||
return t("devices.kind.host");
|
||||
}
|
||||
|
||||
if (
|
||||
session.platform === "macos" ||
|
||||
session.platform === "linux" ||
|
||||
session.platform === "windows"
|
||||
) {
|
||||
return t("devices.kind.desktop");
|
||||
}
|
||||
if (session.platform === "ios" || session.platform === "android") {
|
||||
return t("devices.kind.mobile");
|
||||
}
|
||||
if (session.clientType === "browser" || session.platform === "web") {
|
||||
return t("devices.kind.web");
|
||||
}
|
||||
if (session.clientType === "mobile") return t("devices.kind.mobile");
|
||||
if (session.clientType === "hub") return t("devices.kind.hub");
|
||||
if (session.clientType === "cli") return "CLI";
|
||||
return "MCP";
|
||||
}
|
||||
|
||||
export function formatOsLabel(
|
||||
session: Pick<DaemonSessionSummary, "osName" | "osVersion" | "platform">,
|
||||
options: { compact: boolean },
|
||||
): string | null {
|
||||
const osName = session.osName ?? osNameFromPlatform(session.platform);
|
||||
const osVersion = session.osVersion ?? null;
|
||||
if (!osName) return osVersion;
|
||||
|
||||
if (options.compact) {
|
||||
if (
|
||||
osVersion &&
|
||||
(osName === "macOS" || osName === "iOS" || osName === "iPadOS" || osName === "Android") &&
|
||||
/^\d/.test(osVersion)
|
||||
) {
|
||||
return `${osName} ${shortenNumericVersion(osVersion)}`;
|
||||
}
|
||||
return osName;
|
||||
}
|
||||
|
||||
if (!osVersion) return osName;
|
||||
if (osName === "Linux" && !/^\d/.test(osVersion)) {
|
||||
return osVersion;
|
||||
}
|
||||
return `${osName} ${osVersion}`;
|
||||
}
|
||||
|
||||
export function formatSessionTitle(session: DaemonSessionSummary, t: TFunction): string {
|
||||
if (session.name) return session.name;
|
||||
if (session.isCurrentSession) return t("devices.connected.thisDevice");
|
||||
return formatAppKindLabel(session, t);
|
||||
}
|
||||
|
||||
export function formatSessionHint(
|
||||
session: DaemonSessionSummary,
|
||||
viaHostName: string | null,
|
||||
t: TFunction,
|
||||
): string {
|
||||
const title = formatSessionTitle(session, t);
|
||||
const thisDeviceLabel = t("devices.connected.thisDevice");
|
||||
const transport = formatTransportLabel(session.transport, viaHostName, t);
|
||||
const parts: string[] = [];
|
||||
|
||||
if (session.isCurrentSession && title !== thisDeviceLabel) {
|
||||
parts.push(thisDeviceLabel);
|
||||
}
|
||||
parts.push(transport);
|
||||
|
||||
if (
|
||||
session.remoteIp &&
|
||||
(session.transport === "tailscale" ||
|
||||
session.transport === "direct" ||
|
||||
session.transport === "relay")
|
||||
) {
|
||||
parts.push(session.remoteIp);
|
||||
}
|
||||
|
||||
const shortOs = formatOsLabel(session, { compact: true });
|
||||
if (shortOs && !title.toLowerCase().includes(shortOs.toLowerCase())) {
|
||||
parts.push(shortOs);
|
||||
} else if (
|
||||
!shortOs &&
|
||||
!session.name &&
|
||||
session.appVersion &&
|
||||
session.transport !== "hub" &&
|
||||
session.clientType !== "hub"
|
||||
) {
|
||||
const kind = formatAppKindLabel(session, t);
|
||||
const fallbackDetail = `${kind} ${session.appVersion}`;
|
||||
if (fallbackDetail !== title) {
|
||||
parts.push(fallbackDetail);
|
||||
}
|
||||
}
|
||||
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
export function formatDeviceDetail(session: DaemonSessionSummary): string | null {
|
||||
const osDetail = formatOsLabel(session, { compact: false });
|
||||
const primary =
|
||||
session.deviceModel ??
|
||||
session.browserName ??
|
||||
(session.appKind === "desktop" ? session.name : null);
|
||||
|
||||
if (primary && osDetail) {
|
||||
if (primary.toLowerCase() === osDetail.toLowerCase()) return primary;
|
||||
return `${primary} · ${osDetail}`;
|
||||
}
|
||||
return primary ?? osDetail;
|
||||
}
|
||||
|
||||
export function formatAppDetail(session: DaemonSessionSummary, t: TFunction): string {
|
||||
const kind = formatAppKindLabel(session, t);
|
||||
return session.appVersion ? `${kind} ${session.appVersion}` : kind;
|
||||
}
|
||||
|
||||
export function formatAuthMethodLabel(
|
||||
authMethod: string | null | undefined,
|
||||
t: TFunction,
|
||||
): string | null {
|
||||
switch (authMethod) {
|
||||
case "local_credential":
|
||||
return t("devices.auth.localMachine");
|
||||
case "password":
|
||||
case "header_bearer":
|
||||
return t("devices.auth.password");
|
||||
case "unprotected":
|
||||
return t("devices.auth.openAccess");
|
||||
case "hub":
|
||||
return t("devices.auth.hub");
|
||||
case "plugin":
|
||||
return t("devices.kind.plugin");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-moda
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { PairDeviceSection } from "./pair-device-section";
|
||||
import { DaemonPasswordFormContent } from "./daemon-password-sheet";
|
||||
import { WaysToConnect } from "./ways-to-connect";
|
||||
|
||||
const SNAP_POINTS: string[] = ["72%", "92%"];
|
||||
const SNAP_POINTS: string[] = ["80%", "92%"];
|
||||
const ThemedPlus = withUnistyles(Plus);
|
||||
const iconProps = (theme: Theme) => ({
|
||||
size: theme.iconSize.sm,
|
||||
@@ -16,7 +17,7 @@ const iconProps = (theme: Theme) => ({
|
||||
});
|
||||
const plusIcon = <ThemedPlus uniProps={iconProps} />;
|
||||
|
||||
type PairStep = "ways" | "relay";
|
||||
type PairStep = "ways" | "relay" | "password";
|
||||
|
||||
export function PairDeviceHeaderAction({ serverId }: { serverId: string }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -35,22 +36,59 @@ export function PairDeviceHeaderAction({ serverId }: { serverId: string }) {
|
||||
}, []);
|
||||
const handleOpenRelay = useCallback(() => setStep("relay"), []);
|
||||
const handleBackToWays = useCallback(() => setStep("ways"), []);
|
||||
const handleOpenPassword = useCallback(() => setStep("password"), []);
|
||||
const handleBackToRelay = useCallback(() => setStep("relay"), []);
|
||||
|
||||
const header = useMemo<SheetHeader>(
|
||||
() =>
|
||||
step === "relay"
|
||||
? {
|
||||
title: t("devices.relay.title"),
|
||||
back: {
|
||||
onPress: handleBackToWays,
|
||||
label: t("common.actions.back"),
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: t("settings.host.pairDevices.rowTitle"),
|
||||
},
|
||||
[handleBackToWays, step, t],
|
||||
);
|
||||
const header = useMemo<SheetHeader>(() => {
|
||||
if (step === "password") {
|
||||
return {
|
||||
title: t("devices.password.setTitle"),
|
||||
back: {
|
||||
onPress: handleBackToRelay,
|
||||
label: t("common.actions.back"),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (step === "relay") {
|
||||
return {
|
||||
title: t("devices.relay.title"),
|
||||
back: {
|
||||
onPress: handleBackToWays,
|
||||
label: t("common.actions.back"),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
title: t("settings.host.pairDevices.rowTitle"),
|
||||
};
|
||||
}, [handleBackToRelay, handleBackToWays, step, t]);
|
||||
|
||||
let sheetTestID = "devices-pair-sheet";
|
||||
if (step === "relay") sheetTestID = "devices-relay-pairing";
|
||||
else if (step === "password") sheetTestID = "devices-pair-password-step";
|
||||
|
||||
let sheetContent: React.ReactNode;
|
||||
if (step === "password") {
|
||||
sheetContent = (
|
||||
<DaemonPasswordFormContent
|
||||
key={`${serverId}:pair-password`}
|
||||
serverId={serverId}
|
||||
initialMode="set"
|
||||
onCancel={handleBackToRelay}
|
||||
onCompleted={handleBackToRelay}
|
||||
/>
|
||||
);
|
||||
} else if (step === "relay") {
|
||||
sheetContent = (
|
||||
<PairDeviceSection
|
||||
serverId={serverId}
|
||||
onClose={handleClose}
|
||||
onOpenPassword={handleOpenPassword}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
sheetContent = <WaysToConnect serverId={serverId} onOpenRelay={handleOpenRelay} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -69,14 +107,10 @@ export function PairDeviceHeaderAction({ serverId }: { serverId: string }) {
|
||||
onDismiss={handleDismiss}
|
||||
snapPoints={SNAP_POINTS}
|
||||
desktopMaxWidth={480}
|
||||
desktopHeight={520}
|
||||
testID={step === "relay" ? "devices-relay-pairing" : "devices-pair-sheet"}
|
||||
desktopHeight={560}
|
||||
testID={sheetTestID}
|
||||
>
|
||||
{step === "relay" ? (
|
||||
<PairDeviceSection serverId={serverId} onClose={handleClose} />
|
||||
) : (
|
||||
<WaysToConnect serverId={serverId} onOpenRelay={handleOpenRelay} />
|
||||
)}
|
||||
{sheetContent}
|
||||
</AdaptiveModalSheet>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useMemo } from "react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-modal-sheet";
|
||||
import { PairDeviceSection } from "@/devices/pair-device-section";
|
||||
import { DaemonPasswordFormContent } from "@/devices/daemon-password-sheet";
|
||||
|
||||
export interface PairDeviceModalProps {
|
||||
serverId: string;
|
||||
@@ -10,13 +11,28 @@ export interface PairDeviceModalProps {
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
const SNAP_POINTS: string[] = ["72%", "92%"];
|
||||
const SNAP_POINTS: string[] = ["80%", "92%"];
|
||||
|
||||
export function PairDeviceModal({ serverId, visible, onClose, testID }: PairDeviceModalProps) {
|
||||
const { t } = useTranslation();
|
||||
const [step, setStep] = useState<"relay" | "password">("relay");
|
||||
|
||||
const handleOpenPassword = useCallback(() => setStep("password"), []);
|
||||
const handleBackToRelay = useCallback(() => setStep("relay"), []);
|
||||
const handleDismiss = useCallback(() => setStep("relay"), []);
|
||||
|
||||
const header = useMemo<SheetHeader>(
|
||||
() => ({ title: t("settings.host.pairDevices.rowTitle") }),
|
||||
[t],
|
||||
() =>
|
||||
step === "password"
|
||||
? {
|
||||
title: t("devices.password.setTitle"),
|
||||
back: {
|
||||
onPress: handleBackToRelay,
|
||||
label: t("common.actions.back"),
|
||||
},
|
||||
}
|
||||
: { title: t("settings.host.pairDevices.rowTitle") },
|
||||
[handleBackToRelay, step, t],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -24,11 +40,26 @@ export function PairDeviceModal({ serverId, visible, onClose, testID }: PairDevi
|
||||
header={header}
|
||||
visible={visible}
|
||||
onClose={onClose}
|
||||
onDismiss={handleDismiss}
|
||||
snapPoints={SNAP_POINTS}
|
||||
desktopMaxWidth={480}
|
||||
testID={testID}
|
||||
>
|
||||
<PairDeviceSection serverId={serverId} onClose={onClose} />
|
||||
{step === "password" ? (
|
||||
<DaemonPasswordFormContent
|
||||
key={`${serverId}:modal-password`}
|
||||
serverId={serverId}
|
||||
initialMode="set"
|
||||
onCancel={handleBackToRelay}
|
||||
onCompleted={handleBackToRelay}
|
||||
/>
|
||||
) : (
|
||||
<PairDeviceSection
|
||||
serverId={serverId}
|
||||
onClose={onClose}
|
||||
onOpenPassword={handleOpenPassword}
|
||||
/>
|
||||
)}
|
||||
</AdaptiveModalSheet>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useFetchQuery } from "@/data/query";
|
||||
import { daemonPairingOfferQueryKey } from "@/data/daemon-pairing";
|
||||
import { useDaemonConfig } from "@/hooks/use-daemon-config";
|
||||
import { useHostRuntimeClient, useHostRuntimeSnapshot } from "@/runtime/host-runtime";
|
||||
import { useSessionStore, type DaemonServerInfo } from "@/stores/session-store";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import {
|
||||
EditingTextInput as TextInput,
|
||||
@@ -33,24 +34,42 @@ const foregroundMutedColorMapping = (theme: Theme) => ({
|
||||
});
|
||||
const accentBrightColorMapping = (theme: Theme) => ({ color: theme.colors.accentBright });
|
||||
|
||||
function canOfferSetPassword(
|
||||
serverInfo: DaemonServerInfo | null,
|
||||
serverFeatures: DaemonServerInfo["features"] | undefined,
|
||||
onOpenPassword: (() => void) | undefined,
|
||||
): boolean {
|
||||
if (!onOpenPassword) return false;
|
||||
// COMPAT(daemonPasswordManagement): added in v0.19.x, remove gate after 2027-06-15.
|
||||
if (serverFeatures?.daemonPasswordManagement !== true) return false;
|
||||
if (serverInfo?.passwordManagedByEnv === true) return false;
|
||||
const permissions = serverInfo?.permissions;
|
||||
if (!permissions) return true;
|
||||
return permissions.includes("daemon.manage") && permissions.includes("access.manage");
|
||||
}
|
||||
|
||||
export interface PairDeviceSectionProps {
|
||||
serverId: string;
|
||||
onClose: () => void;
|
||||
onOpenPassword?: () => void;
|
||||
}
|
||||
|
||||
export function PairDeviceSection({ serverId, onClose }: PairDeviceSectionProps) {
|
||||
export function PairDeviceSection({ serverId, onClose, onOpenPassword }: PairDeviceSectionProps) {
|
||||
const { t } = useTranslation();
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const runtimeSnapshot = useHostRuntimeSnapshot(serverId);
|
||||
const serverInfo = useSessionStore((state) => state.sessions[serverId]?.serverInfo ?? null);
|
||||
const isConnected = runtimeSnapshot?.connectionStatus === "online";
|
||||
const isDisconnected =
|
||||
runtimeSnapshot?.connectionStatus === "offline" ||
|
||||
runtimeSnapshot?.connectionStatus === "error";
|
||||
const { patchConfig } = useDaemonConfig(serverId);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const serverFeatures = client?.getLastServerInfoMessage()?.features;
|
||||
const serverFeatures = serverInfo?.features ?? client?.getLastServerInfoMessage()?.features;
|
||||
const supportsPairingRpc = serverFeatures?.daemonStatusRpc === true;
|
||||
const canConfigureRelay = supportsPairingRpc && serverFeatures?.relayConfig === true;
|
||||
const passwordConfigured = serverInfo?.passwordConfigured === true;
|
||||
const canSetPassword = canOfferSetPassword(serverInfo, serverFeatures, onOpenPassword);
|
||||
|
||||
const pairingQuery = useFetchQuery({
|
||||
queryKey: daemonPairingOfferQueryKey(serverId),
|
||||
@@ -123,6 +142,9 @@ export function PairDeviceSection({ serverId, onClose }: PairDeviceSectionProps)
|
||||
onEnableRelay={handleEnableRelay}
|
||||
onClose={onClose}
|
||||
onCopy={handleCopyPress}
|
||||
passwordConfigured={passwordConfigured}
|
||||
canSetPassword={canSetPassword}
|
||||
onOpenPassword={onOpenPassword}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -143,6 +165,9 @@ interface PairDeviceBodyProps {
|
||||
onEnableRelay: () => void;
|
||||
onClose: () => void;
|
||||
onCopy: () => void;
|
||||
passwordConfigured: boolean;
|
||||
canSetPassword: boolean;
|
||||
onOpenPassword?: () => void;
|
||||
}
|
||||
|
||||
function PairDeviceBody(props: PairDeviceBodyProps) {
|
||||
@@ -267,7 +292,32 @@ function PairingOffer(props: PairDeviceBodyProps & { offer: { url: string } }) {
|
||||
{props.copied ? t("pairing.device.copied") : t("pairing.device.copy")}
|
||||
</Button>
|
||||
</View>
|
||||
<Alert size="sm" variant="warning" description={t("pairing.device.securityWarning")} />
|
||||
{props.passwordConfigured ? (
|
||||
<Alert
|
||||
size="sm"
|
||||
variant="info"
|
||||
description={t("pairing.device.passwordProtected")}
|
||||
testID="pairing-password-protected-alert"
|
||||
/>
|
||||
) : (
|
||||
<Alert
|
||||
size="sm"
|
||||
variant="warning"
|
||||
description={t("pairing.device.securityWarning")}
|
||||
testID="pairing-no-password-alert"
|
||||
>
|
||||
{props.canSetPassword && props.onOpenPassword ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onPress={props.onOpenPassword}
|
||||
testID="pairing-set-password-button"
|
||||
>
|
||||
{t("devices.password.setAction")}
|
||||
</Button>
|
||||
) : null}
|
||||
</Alert>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -353,7 +403,7 @@ const styles = StyleSheet.create((theme) => ({
|
||||
lineHeight: theme.fontSize.sm * 1.5,
|
||||
},
|
||||
offer: {
|
||||
gap: theme.spacing[4],
|
||||
gap: theme.spacing[3],
|
||||
},
|
||||
offerHint: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
@@ -364,7 +414,7 @@ const styles = StyleSheet.create((theme) => ({
|
||||
alignSelf: "center",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
width: 304,
|
||||
width: 224,
|
||||
maxWidth: "100%",
|
||||
aspectRatio: 1,
|
||||
padding: theme.spacing[3],
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { usePaneContext } from "@/panels/pane-context";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import type { PluginFile, PluginTab } from "@getpaseo/plugin/client";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { Download } from "lucide-react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
@@ -9,11 +7,11 @@ import { Button } from "@/components/ui/button";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { useFileHandle, useFileHandleSnapshot } from "@/file-panels/file";
|
||||
import { FilePanelLoading } from "@/file-panels/loading";
|
||||
import { FilePanelPicker, FilePanelView, useFilePanelChoice, type FilePanel } from "@/file-panels";
|
||||
import { FilePanelPicker, FilePanelView, useFilePanelChoice } from "@/file-panels";
|
||||
import { resolveFilePreviewReadTarget } from "@/file-explorer/preview-target";
|
||||
import { useFileDownload } from "@/hooks/use-file-download";
|
||||
import { useAppActivelyVisible } from "@/hooks/use-app-visible";
|
||||
import { usePublishPanelInstanceAttributes } from "@/panels/panel-instance-attributes";
|
||||
import { getComponentMountKey } from "@/panels/panel-instance-attributes";
|
||||
import { useHostRuntimeConnectionStatus } from "@/runtime/host-runtime";
|
||||
import { buildAbsoluteExplorerPath } from "@/utils/explorer-paths";
|
||||
import { formatFileSize } from "@/utils/format-file-size";
|
||||
@@ -79,8 +77,6 @@ export function FilePane({
|
||||
presentable: isActive,
|
||||
lineNavigation: location.lineStart ? navigationRevision : null,
|
||||
});
|
||||
const [modified, setModified] = useState(false);
|
||||
usePublishPanelInstanceAttributes({ modified, suspendPendingSave: handle?.holdWrites });
|
||||
const panelLocation = useMemo(
|
||||
() => ({
|
||||
lineStart: location.lineStart,
|
||||
@@ -121,16 +117,19 @@ export function FilePane({
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
const panelMountKey = panel.builtin
|
||||
? `${panel.id}:${targetKey}`
|
||||
: `${panel.id}:${targetKey}:${getComponentMountKey(panel.contribution.Component)}`;
|
||||
return (
|
||||
<View style={styles.container} testID="workspace-file-pane">
|
||||
<FilePanelPicker choice={choice} />
|
||||
<MountedFilePanel
|
||||
key={`${panel.id}:${targetKey}`}
|
||||
<FilePanelView
|
||||
key={panelMountKey}
|
||||
panel={panel}
|
||||
file={handle.file}
|
||||
params={panelLocation}
|
||||
revision={navigationRevision}
|
||||
onModifiedChange={setModified}
|
||||
suspendPendingSave={handle.holdWrites}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -142,34 +141,6 @@ export function FilePane({
|
||||
);
|
||||
}
|
||||
|
||||
/** One panel mount. Its tab reports unsaved changes until the panel unmounts. */
|
||||
function MountedFilePanel({
|
||||
panel,
|
||||
file,
|
||||
params,
|
||||
revision,
|
||||
onModifiedChange,
|
||||
}: {
|
||||
panel: FilePanel;
|
||||
file: PluginFile;
|
||||
params: { path: string; lineStart?: number; lineEnd?: number };
|
||||
revision: number;
|
||||
onModifiedChange: (modified: boolean) => void;
|
||||
}) {
|
||||
const { tabId, state, setCurrentTabState } = usePaneContext();
|
||||
const tab = useMemo<PluginTab>(
|
||||
() => ({
|
||||
id: tabId,
|
||||
setModified: onModifiedChange,
|
||||
state,
|
||||
setState: setCurrentTabState,
|
||||
}),
|
||||
[tabId, onModifiedChange, state, setCurrentTabState],
|
||||
);
|
||||
useEffect(() => () => onModifiedChange(false), [onModifiedChange]);
|
||||
return <FilePanelView panel={panel} file={file} tab={tab} params={params} revision={revision} />;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
container: {
|
||||
flex: 1,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useWorkspace, useFileUrl, type PluginFilePanelProps } from "@getpaseo/plugin/client";
|
||||
import { useWorkspace, useFileUrl } from "@getpaseo/plugin/client";
|
||||
import type { BuiltinFilePanelProps } from "./panels";
|
||||
import { useCallback, useState } from "react";
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
@@ -11,17 +12,17 @@ import { TextFilePanel, type TextFilePreviewProps } from "./source/panel";
|
||||
import type { RenderingFilePanel, SourceFilePanel } from "./catalog";
|
||||
|
||||
/** Source: the text file panel with no Preview, for text files no other built-in panel claims. */
|
||||
function SourcePanel(props: PluginFilePanelProps) {
|
||||
function SourcePanel(props: BuiltinFilePanelProps) {
|
||||
return <TextFilePanel {...props} />;
|
||||
}
|
||||
|
||||
/** Markdown: the text file panel with the rendered document as its Preview. */
|
||||
function MarkdownPanel(props: PluginFilePanelProps) {
|
||||
function MarkdownPanel(props: BuiltinFilePanelProps) {
|
||||
return <TextFilePanel {...props} preview={MarkdownPreview} />;
|
||||
}
|
||||
|
||||
/** HTML: the text file panel with the sandboxed page as its Preview. */
|
||||
function HtmlPanel(props: PluginFilePanelProps) {
|
||||
function HtmlPanel(props: BuiltinFilePanelProps) {
|
||||
return <TextFilePanel {...props} preview={HtmlPreview} />;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ function HtmlPreview({ text }: TextFilePreviewProps) {
|
||||
);
|
||||
}
|
||||
|
||||
function ImagePanel({ file }: PluginFilePanelProps) {
|
||||
function ImagePanel({ file }: BuiltinFilePanelProps) {
|
||||
const url = useFileUrl(file);
|
||||
if (url.status === "loading") return <FilePanelLoading />;
|
||||
if (url.status === "error") return <FilePanelError message={url.error.message} />;
|
||||
@@ -83,7 +84,7 @@ const components = {
|
||||
export function BuiltinFilePanelView({
|
||||
panel,
|
||||
...props
|
||||
}: PluginFilePanelProps & { panel: RenderingFilePanel | SourceFilePanel }) {
|
||||
}: BuiltinFilePanelProps & { panel: RenderingFilePanel | SourceFilePanel }) {
|
||||
const Component = components[panel.id];
|
||||
return <Component {...props} />;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { useMemo } from "react";
|
||||
import type { PluginFilePanelProps } from "@getpaseo/plugin/client";
|
||||
import { useInstalledPlugins } from "@/plugins/registry";
|
||||
import type { PluginFilePanelContribution, InstalledPlugin } from "@/plugins/types";
|
||||
import { filePanelCatalog, type RenderingFilePanel, type SourceFilePanel } from "./catalog";
|
||||
|
||||
/** Props shared by built-in file panels; excludes plugin-owned capabilities such as `openScreen`. */
|
||||
export type BuiltinFilePanelProps = Omit<PluginFilePanelProps, "openScreen">;
|
||||
|
||||
export interface PluginFilePanel {
|
||||
id: string;
|
||||
builtin: false;
|
||||
|
||||
@@ -1,18 +1,45 @@
|
||||
import type { PluginFilePanelProps } from "@getpaseo/plugin/client";
|
||||
import { usePanelTab } from "@/panels/panel-instance-attributes";
|
||||
import { PluginInstallationProvider } from "@/plugins/installation-provider";
|
||||
import { usePluginOpenScreen } from "@/plugins/navigation";
|
||||
import { SurfaceErrorBoundary } from "@/plugins/surface-error-boundary";
|
||||
import type { PluginFilePanel } from "./panels";
|
||||
import type { BuiltinFilePanelProps, PluginFilePanel } from "./panels";
|
||||
|
||||
type PluginFilePanelHostProps = Omit<BuiltinFilePanelProps, "tab"> & {
|
||||
panel: PluginFilePanel;
|
||||
suspendPendingSave?: () => () => void;
|
||||
};
|
||||
|
||||
function MountedPluginFilePanel({
|
||||
panel,
|
||||
suspendPendingSave,
|
||||
...props
|
||||
}: Omit<PluginFilePanelProps, "tab"> & {
|
||||
panel: PluginFilePanel;
|
||||
suspendPendingSave?: () => () => void;
|
||||
}) {
|
||||
const tab = usePanelTab({ suspendPendingSave });
|
||||
const Component = panel.contribution.Component;
|
||||
return <Component {...props} tab={tab} />;
|
||||
}
|
||||
|
||||
export function PluginFilePanelHost({
|
||||
panel,
|
||||
suspendPendingSave,
|
||||
...props
|
||||
}: PluginFilePanelProps & { panel: PluginFilePanel }) {
|
||||
}: PluginFilePanelHostProps) {
|
||||
const { plugin, contribution } = panel;
|
||||
const openScreen = usePluginOpenScreen(plugin);
|
||||
const Component = contribution.Component;
|
||||
return (
|
||||
<SurfaceErrorBoundary installation={plugin} Surface={Component} key={panel.id}>
|
||||
<PluginInstallationProvider plugin={plugin}>
|
||||
<Component {...props} />
|
||||
<MountedPluginFilePanel
|
||||
{...props}
|
||||
openScreen={openScreen}
|
||||
panel={panel}
|
||||
suspendPendingSave={suspendPendingSave}
|
||||
/>
|
||||
</PluginInstallationProvider>
|
||||
</SurfaceErrorBoundary>
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user