mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-27 02:35:31 +00:00
Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afb8634dc3 | ||
|
|
0baecb2e0a | ||
|
|
3fcb4524bb | ||
|
|
edd526561f | ||
|
|
2f54a1d750 | ||
|
|
12ae5f537b | ||
|
|
b6cab288fc | ||
|
|
5bbc180cfe | ||
|
|
557d2e596d | ||
|
|
f2102d0c2a | ||
|
|
186899e66f | ||
|
|
7d14347282 | ||
|
|
89b0f85c8c | ||
|
|
3fc2ef4469 | ||
|
|
bf41c28a5e | ||
|
|
2428a8c232 | ||
|
|
64b8861a9f | ||
|
|
ccd9f0a436 | ||
|
|
713b6dbbfe | ||
|
|
32c3805aad | ||
|
|
d46038ee4b | ||
|
|
be6b5eb169 | ||
|
|
c0903be174 | ||
|
|
5238bfb641 | ||
|
|
90c8446fb8 | ||
|
|
717e75d032 | ||
|
|
62cdc2f2cf | ||
|
|
eaef730f1e | ||
|
|
f0bf09efee | ||
|
|
ad068bd21d | ||
|
|
25666d9172 | ||
|
|
6c237aabf1 | ||
|
|
22baf9e344 |
@@ -342,6 +342,8 @@ jobs:
|
||||
run: |
|
||||
npm run test:unit --workspace=@getpaseo/server -- \
|
||||
src/server/file-observer \
|
||||
src/server/workspace-reconciliation-observation.test.ts \
|
||||
src/utils/checkout-git-identity.test.ts \
|
||||
src/server/workspace-git-service.observation.test.ts \
|
||||
src/server/workspace-git-service.observation.integration.test.ts \
|
||||
--bail=1
|
||||
|
||||
@@ -38,9 +38,9 @@ on:
|
||||
- "true"
|
||||
- "false"
|
||||
rollout_hours:
|
||||
description: "Linear rollout duration in hours. Use 0 for instant rollout."
|
||||
description: "Rollout duration in hours: a 5% canary hold, then a ramp to 100%. Use 0 to admit everyone at once."
|
||||
required: false
|
||||
default: "36"
|
||||
default: "18"
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
@@ -51,7 +51,7 @@ env:
|
||||
SOURCE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
|
||||
CHECKOUT_REF: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.checkout_ref || github.ref_name) || github.ref_name }}
|
||||
SHOULD_PUBLISH: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish != 'false' }}
|
||||
ROLLOUT_HOURS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.rollout_hours || '36' }}
|
||||
ROLLOUT_HOURS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.rollout_hours || '18' }}
|
||||
DESKTOP_PACKAGE_PATH: "packages/desktop"
|
||||
|
||||
jobs:
|
||||
@@ -96,6 +96,7 @@ jobs:
|
||||
publish-macos:
|
||||
needs: [create-release]
|
||||
if: ${{ always() && (needs.create-release.result == 'success' || needs.create-release.result == 'skipped') && ((github.event_name == 'workflow_dispatch' && (github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos')) || (github.event_name == 'push' && (startsWith(github.ref_name, 'v') || startsWith(github.ref_name, 'desktop-v') || startsWith(github.ref_name, 'desktop-macos-v')))) }}
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -181,7 +182,7 @@ jobs:
|
||||
npm run build:desktop "${build_args[@]}"
|
||||
|
||||
- name: Upload packaged smoke diagnostics
|
||||
if: failure()
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: desktop-smoke-macos-${{ matrix.electron_arch }}
|
||||
|
||||
@@ -1,5 +1,95 @@
|
||||
# Changelog
|
||||
|
||||
## 0.17.6 - 2026-11-27
|
||||
|
||||
### Improved
|
||||
|
||||
- Reorganized Settings into Device and Host sections and consolidated sparse pages ([#10933](https://github.com/getpaseo/paseo/pull/10933))
|
||||
- Added arrow-key navigation for models, providers, and profiles in the model picker ([#10929](https://github.com/getpaseo/paseo/pull/10929), [#10962](https://github.com/getpaseo/paseo/pull/10962))
|
||||
- Added an in-place Refresh control for Tailscale availability in host settings and setup ([#10903](https://github.com/getpaseo/paseo/pull/10903))
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed the Antigravity usage source that ran `agy -p /usage` in the background ([#10953](https://github.com/getpaseo/paseo/pull/10953) by [@luoph](https://github.com/luoph))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Paseo Android crashing on Samsung devices when a chat shows a code block or quote ([#10964](https://github.com/getpaseo/paseo/pull/10964))
|
||||
- Fixed mouse clicks not selecting model picker rows on Android ([#10972](https://github.com/getpaseo/paseo/pull/10972))
|
||||
- Fixed macOS Desktop freezing during startup because of Dock progress bar updates ([#10939](https://github.com/getpaseo/paseo/pull/10939))
|
||||
- Fixed Linux AppImage leaking its runtime environment into shells and child processes ([#10920](https://github.com/getpaseo/paseo/pull/10920))
|
||||
- Fixed background Git fetches on Linux spawning orphan D-Bus daemons and retrying failing auth in a loop ([#10921](https://github.com/getpaseo/paseo/pull/10921))
|
||||
- Fixed flashes when restoring archived workspaces and agents, and added an unarchiving state ([#10928](https://github.com/getpaseo/paseo/pull/10928))
|
||||
- Fixed worktree ownership drifting outside the configured worktrees root ([#10878](https://github.com/getpaseo/paseo/pull/10878))
|
||||
- Fixed new web tabs losing projects after another tab evicts the directory cache ([#10942](https://github.com/getpaseo/paseo/pull/10942))
|
||||
- Fixed timelines dropping rows when a rewind epoch changes ([#8794](https://github.com/getpaseo/paseo/pull/8794) by [@LiebeLee](https://github.com/LiebeLee))
|
||||
|
||||
## 0.17.5 - 2026-11-26
|
||||
|
||||
- **Archive workspaces together:** Cmd/Ctrl+click a workspace in the sidebar to select multiple workspaces and archive them in one step. ([#10798](https://github.com/getpaseo/paseo/pull/10798), [#10821](https://github.com/getpaseo/paseo/pull/10821))
|
||||
- **Copy quoted drafts:** Copy a quote from a reply with one tap, without the `>` markers. ([#10608](https://github.com/getpaseo/paseo/pull/10608) by [@pedrovieira](https://github.com/pedrovieira), [@dinhphieu](https://github.com/dinhphieu))
|
||||
- **Redesigned agent profiles page:** Agent profiles have their own dedicated settings page, and the model picker saves a new profile in one tap. ([#10789](https://github.com/getpaseo/paseo/pull/10789), [#10824](https://github.com/getpaseo/paseo/pull/10824))
|
||||
- **Redesigned Add project:** Add project opens on folder search, with Clone and New folder one tab away. ([#10767](https://github.com/getpaseo/paseo/pull/10767))
|
||||
- **Choose how Desktop updates:** Desktop can download updates automatically, only notify you, or never check. ([#10785](https://github.com/getpaseo/paseo/pull/10785))
|
||||
- **First-class Tailscale support:** Turn on Tailscale for a host from its settings or from setup, without editing its configuration. ([#10801](https://github.com/getpaseo/paseo/pull/10801))
|
||||
|
||||
### Added
|
||||
|
||||
- Added host icons, connection types, and latency to the host picker ([#10702](https://github.com/getpaseo/paseo/pull/10702) by [@artile](https://github.com/artile))
|
||||
- Added agent profiles to model picker search and the Command Center ([#10774](https://github.com/getpaseo/paseo/pull/10774))
|
||||
- Added Archive on finish to `paseo schedule create`, `paseo schedule update`, and the schedule MCP tools ([#8479](https://github.com/getpaseo/paseo/pull/8479) by [@ArnoldHueteG](https://github.com/ArnoldHueteG))
|
||||
- Added newer Factory Droid models by updating its catalog entry to Droid 1.20.0 ([#10779](https://github.com/getpaseo/paseo/pull/10779) by [@dsingal0](https://github.com/dsingal0))
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed automatic stable Desktop updates to check at most every 6 hours and to wait 24 hours after each update ([#10882](https://github.com/getpaseo/paseo/pull/10882), [#10901](https://github.com/getpaseo/paseo/pull/10901))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed agents hiding the subagents they create from tabs and the subagent track ([#10887](https://github.com/getpaseo/paseo/pull/10887))
|
||||
- Fixed parent agents getting a Claude subagent's interim reply instead of its final reply when the subagent waits on background work ([#10864](https://github.com/getpaseo/paseo/pull/10864))
|
||||
- Fixed agents that watch a pull request staying in Running after their turn ends ([#10740](https://github.com/getpaseo/paseo/pull/10740) by [@drgould](https://github.com/drgould))
|
||||
- Fixed the Changes pane offering no Push or Pull when the remote is not named `origin` ([#10679](https://github.com/getpaseo/paseo/pull/10679))
|
||||
- Fixed a pane switching to the wrong tab after you split or move its active tab out ([#10716](https://github.com/getpaseo/paseo/pull/10716))
|
||||
- Fixed New workspace leaving focus on the project button after you choose a project ([#10632](https://github.com/getpaseo/paseo/pull/10632))
|
||||
- Fixed archived chats staying in memory until the window reloads ([#10866](https://github.com/getpaseo/paseo/pull/10866))
|
||||
- Fixed hover cards and other overlays slowing down in long app sessions ([#10778](https://github.com/getpaseo/paseo/pull/10778) by [@maci0](https://github.com/maci0))
|
||||
- Fixed Desktop freezing when you open a chat whose last turn has hundreds of tool calls ([#8661](https://github.com/getpaseo/paseo/pull/8661) by [@luoph](https://github.com/luoph))
|
||||
- Fixed direct connections dropping on slow links while a large timeline loads ([#10651](https://github.com/getpaseo/paseo/pull/10651) by [@apple-ouyang](https://github.com/apple-ouyang))
|
||||
- Fixed large Git workspaces stalling the daemon while their file watchers scan ([#10788](https://github.com/getpaseo/paseo/pull/10788), [#10602](https://github.com/getpaseo/paseo/pull/10602))
|
||||
- Fixed a Git change in one repository rescanning every checkout ([#10863](https://github.com/getpaseo/paseo/pull/10863) by [@viiqswim](https://github.com/viiqswim))
|
||||
- Fixed iOS chats staying blank when a pending question is taller than the screen ([#10759](https://github.com/getpaseo/paseo/pull/10759))
|
||||
- Fixed Android long-press text selection in chat leaving the magnifier stuck on screen ([#10844](https://github.com/getpaseo/paseo/pull/10844))
|
||||
- Fixed mobile sheet footers dropping behind the system bar when the keyboard closes ([#10827](https://github.com/getpaseo/paseo/pull/10827))
|
||||
- Fixed the sidebar toggle covering plugin screen titles on macOS ([#10773](https://github.com/getpaseo/paseo/pull/10773))
|
||||
- Fixed Windows file links with a slash before the drive letter failing to open ([#7711](https://github.com/getpaseo/paseo/pull/7711))
|
||||
- Fixed Import Session giving up on slow providers and hiding provider errors ([#10516](https://github.com/getpaseo/paseo/pull/10516) by [@chirag127](https://github.com/chirag127), [@derek-geekdive](https://github.com/derek-geekdive))
|
||||
- Fixed OMP 19.1 `ask` questions not showing a question card ([#10862](https://github.com/getpaseo/paseo/pull/10862) by [@gtoxlili](https://github.com/gtoxlili))
|
||||
- Fixed OpenCode 2 agents with their own MCP servers failing when a shared OpenCode server is running. Requires OpenCode 2.0.29 or later ([#10752](https://github.com/getpaseo/paseo/pull/10752))
|
||||
- Fixed deleted OpenCode subagents staying in the subagent track ([#8332](https://github.com/getpaseo/paseo/pull/8332))
|
||||
- Fixed stopped Claude background subagents showing as running after you reopen the parent ([#9013](https://github.com/getpaseo/paseo/pull/9013))
|
||||
- Fixed plugin and Paseo instructions replacing a Codex agent's own `developer_instructions` ([#10792](https://github.com/getpaseo/paseo/pull/10792))
|
||||
- Fixed the OpenCode Go usage card missing when the Go key is in OpenCode's `auth.json` ([#10678](https://github.com/getpaseo/paseo/pull/10678))
|
||||
- Fixed GitHub, GitLab, and Gitea commands on Windows breaking multiline arguments and expanding `%VAR%` text ([#10685](https://github.com/getpaseo/paseo/pull/10685))
|
||||
- Fixed `paseo hub login` printing a link without the code ([#10751](https://github.com/getpaseo/paseo/pull/10751))
|
||||
- Fixed Hub trigger runs failing on Antigravity and other plugin providers without tool policy support ([#10889](https://github.com/getpaseo/paseo/pull/10889))
|
||||
- Fixed Hub sessions being refused when they read a daemon's provider controls ([#10794](https://github.com/getpaseo/paseo/pull/10794))
|
||||
- Fixed Hermes and other plugin ACP providers leaving processes running after a model list refresh times out ([#10867](https://github.com/getpaseo/paseo/pull/10867))
|
||||
- Fixed a plugin's agent tools returning `Tool not found` after the plugin reloads during a turn ([#10106](https://github.com/getpaseo/paseo/pull/10106) by [@tomgrin10](https://github.com/tomgrin10))
|
||||
- Fixed replies changed by a timeline plugin losing Copy, Fork, and turn duration ([#10795](https://github.com/getpaseo/paseo/pull/10795) by [@Brandon168](https://github.com/Brandon168))
|
||||
- Fixed idle plugin sessions waking the daemon every 10 seconds ([#9363](https://github.com/getpaseo/paseo/pull/9363) by [@Brandon168](https://github.com/Brandon168))
|
||||
|
||||
### Security
|
||||
|
||||
- Changed Claude Code 2.1.326 or later to receive MCP server tokens over stdin instead of in process arguments that other local users can read ([#10698](https://github.com/getpaseo/paseo/pull/10698) by [@mdbraber](https://github.com/mdbraber))
|
||||
- Fixed repository teardown commands running on archive for pull request worktrees whose setup you have not approved ([#10694](https://github.com/getpaseo/paseo/pull/10694))
|
||||
|
||||
### Plugins
|
||||
|
||||
- Added launch wraps so plugins can run agents, terminals, and worktree commands inside a sandbox ([#10786](https://github.com/getpaseo/paseo/pull/10786) by [@clkao](https://github.com/clkao), [@bendavid](https://github.com/bendavid))
|
||||
- Added the parent workspace to plugin workspace snapshots ([#10781](https://github.com/getpaseo/paseo/pull/10781) by [@spatenotte](https://github.com/spatenotte))
|
||||
- Updated the bundled `paseo-plugin` skill to the current plugin API ([#10793](https://github.com/getpaseo/paseo/pull/10793))
|
||||
|
||||
## 0.17.4 - 2026-11-23
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,5 +1,95 @@
|
||||
# Changelog
|
||||
|
||||
## 0.17.6 - 2026-11-27
|
||||
|
||||
### 改进
|
||||
|
||||
- 将设置重组为设备和主机两个范围,并合并了内容较少的页面 ([#10933](https://github.com/getpaseo/paseo/pull/10933))
|
||||
- 为模型选择器中的模型、Provider 和配置文件新增方向键导航 ([#10929](https://github.com/getpaseo/paseo/pull/10929), [#10962](https://github.com/getpaseo/paseo/pull/10962))
|
||||
- 在主机设置和初始设置中新增就地刷新 Tailscale 可用性的按钮 ([#10903](https://github.com/getpaseo/paseo/pull/10903))
|
||||
|
||||
### 变更
|
||||
|
||||
- 移除了在后台运行 `agy -p /usage` 的 Antigravity 用量数据源 ([#10953](https://github.com/getpaseo/paseo/pull/10953),贡献者:[@luoph](https://github.com/luoph))
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复对话中出现代码块或引用时 Paseo Android 在三星设备上崩溃的问题 ([#10964](https://github.com/getpaseo/paseo/pull/10964))
|
||||
- 修复在 Android 上使用鼠标点击无法选择模型选择器行的问题 ([#10972](https://github.com/getpaseo/paseo/pull/10972))
|
||||
- 修复 macOS 桌面端因 Dock 进度条更新在启动时卡死的问题 ([#10939](https://github.com/getpaseo/paseo/pull/10939))
|
||||
- 修复 Linux AppImage 将其运行时环境变量泄漏到 Shell 和子进程的问题 ([#10920](https://github.com/getpaseo/paseo/pull/10920))
|
||||
- 修复 Linux 上后台 Git fetch 启动孤立 D-Bus 进程并在认证失败后循环重试的问题 ([#10921](https://github.com/getpaseo/paseo/pull/10921))
|
||||
- 修复恢复已归档工作区和 Agent 时的界面闪烁问题,并新增恢复中状态提示 ([#10928](https://github.com/getpaseo/paseo/pull/10928))
|
||||
- 修复 worktree 所有权超出已配置 worktrees 根目录的问题 ([#10878](https://github.com/getpaseo/paseo/pull/10878))
|
||||
- 修复另一个标签页淘汰目录缓存后,新打开的网页标签页丢失 project 的问题 ([#10942](https://github.com/getpaseo/paseo/pull/10942))
|
||||
- 修复 rewind epoch 变更时时间线丢失行的问题 ([#8794](https://github.com/getpaseo/paseo/pull/8794),贡献者:[@LiebeLee](https://github.com/LiebeLee))
|
||||
|
||||
## 0.17.5 - 2026-11-26
|
||||
|
||||
- **批量归档工作区**:在侧边栏按住 Cmd/Ctrl 点击工作区即可多选,一步归档。([#10798](https://github.com/getpaseo/paseo/pull/10798), [#10821](https://github.com/getpaseo/paseo/pull/10821))
|
||||
- **复制引用草稿**:一键复制回复中的引用内容,不带 `>` 标记。([#10608](https://github.com/getpaseo/paseo/pull/10608),贡献者:[@pedrovieira](https://github.com/pedrovieira), [@dinhphieu](https://github.com/dinhphieu))
|
||||
- **重新设计的智能体配置文件页面**:智能体配置文件现在有专属的设置页面,模型选择器一键即可保存新的配置文件。([#10789](https://github.com/getpaseo/paseo/pull/10789), [#10824](https://github.com/getpaseo/paseo/pull/10824))
|
||||
- **重新设计的添加 project**:“添加 project”直接打开文件夹搜索,克隆和新建文件夹只需切换一个标签页。([#10767](https://github.com/getpaseo/paseo/pull/10767))
|
||||
- **选择桌面端的更新方式**:桌面端可以自动下载更新、仅通知你,或完全不检查。([#10785](https://github.com/getpaseo/paseo/pull/10785))
|
||||
- **全面支持 Tailscale**:在主机设置或初始设置中为主机开启 Tailscale,无需编辑配置。([#10801](https://github.com/getpaseo/paseo/pull/10801))
|
||||
|
||||
### 新增
|
||||
|
||||
- 在主机选择器中新增主机图标、连接类型和延迟 ([#10702](https://github.com/getpaseo/paseo/pull/10702),贡献者:[@artile](https://github.com/artile))
|
||||
- 在模型选择器搜索和命令中心中新增智能体配置文件 ([#10774](https://github.com/getpaseo/paseo/pull/10774))
|
||||
- 为 `paseo schedule create`、`paseo schedule update` 和定时任务 MCP 工具新增“完成后归档”选项 ([#8479](https://github.com/getpaseo/paseo/pull/8479),贡献者:[@ArnoldHueteG](https://github.com/ArnoldHueteG))
|
||||
- 将 Factory Droid 的目录条目更新到 Droid 1.20.0,新增其较新的模型 ([#10779](https://github.com/getpaseo/paseo/pull/10779),贡献者:[@dsingal0](https://github.com/dsingal0))
|
||||
|
||||
### 变更
|
||||
|
||||
- 桌面端稳定版的自动更新改为最多每 6 小时检查一次,每次更新后等待 24 小时 ([#10882](https://github.com/getpaseo/paseo/pull/10882), [#10901](https://github.com/getpaseo/paseo/pull/10901))
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复 Agent 将自己创建的子 Agent 从标签页和子 Agent 列表中隐藏的问题 ([#10887](https://github.com/getpaseo/paseo/pull/10887))
|
||||
- 修复 Claude 子 Agent 等待后台任务时,父 Agent 收到的是中间回复而不是最终回复的问题 ([#10864](https://github.com/getpaseo/paseo/pull/10864))
|
||||
- 修复监视 PR 的 Agent 在轮次结束后仍显示为运行中的问题 ([#10740](https://github.com/getpaseo/paseo/pull/10740),贡献者:[@drgould](https://github.com/drgould))
|
||||
- 修复远程名称不是 `origin` 时“变更”面板不显示推送或拉取的问题 ([#10679](https://github.com/getpaseo/paseo/pull/10679))
|
||||
- 修复拆分窗格或移出当前标签后,原窗格切换到错误标签的问题 ([#10716](https://github.com/getpaseo/paseo/pull/10716))
|
||||
- 修复在“新建工作区”中选择 project 后,焦点停留在 project 按钮上的问题 ([#10632](https://github.com/getpaseo/paseo/pull/10632))
|
||||
- 修复已归档的对话在窗口重新加载前一直占用内存的问题 ([#10866](https://github.com/getpaseo/paseo/pull/10866))
|
||||
- 修复应用长时间运行后悬停卡片等浮层变慢的问题 ([#10778](https://github.com/getpaseo/paseo/pull/10778),贡献者:[@maci0](https://github.com/maci0))
|
||||
- 修复打开最后一轮包含数百次工具调用的对话时桌面端卡顿的问题 ([#8661](https://github.com/getpaseo/paseo/pull/8661),贡献者:[@luoph](https://github.com/luoph))
|
||||
- 修复在慢速网络上加载大型时间线时直接连接断开的问题 ([#10651](https://github.com/getpaseo/paseo/pull/10651),贡献者:[@apple-ouyang](https://github.com/apple-ouyang))
|
||||
- 修复大型 Git 工作区在文件监视器扫描时阻塞 daemon 的问题 ([#10788](https://github.com/getpaseo/paseo/pull/10788), [#10602](https://github.com/getpaseo/paseo/pull/10602))
|
||||
- 修复一个仓库中的 Git 变更导致所有检出重新扫描的问题 ([#10863](https://github.com/getpaseo/paseo/pull/10863),贡献者:[@viiqswim](https://github.com/viiqswim))
|
||||
- 修复待回答问题高于屏幕时 iOS 对话一直空白的问题 ([#10759](https://github.com/getpaseo/paseo/pull/10759))
|
||||
- 修复 Android 上在对话中长按选择文本后放大镜卡在屏幕上的问题 ([#10844](https://github.com/getpaseo/paseo/pull/10844))
|
||||
- 修复移动端弹窗底部栏在键盘收起时落到系统栏后面的问题 ([#10827](https://github.com/getpaseo/paseo/pull/10827))
|
||||
- 修复 macOS 上侧边栏切换按钮遮挡插件页面标题的问题 ([#10773](https://github.com/getpaseo/paseo/pull/10773))
|
||||
- 修复 Windows 上盘符前带斜杠的文件链接无法打开的问题 ([#7711](https://github.com/getpaseo/paseo/pull/7711))
|
||||
- 修复导入会话在 Provider 响应慢时提前放弃并隐藏 Provider 错误的问题 ([#10516](https://github.com/getpaseo/paseo/pull/10516),贡献者:[@chirag127](https://github.com/chirag127), [@derek-geekdive](https://github.com/derek-geekdive))
|
||||
- 修复 OMP 19.1 的 `ask` 问题不显示问题卡片的问题 ([#10862](https://github.com/getpaseo/paseo/pull/10862),贡献者:[@gtoxlili](https://github.com/gtoxlili))
|
||||
- 修复共享 OpenCode 服务器运行时,带有自己 MCP 服务器的 OpenCode 2 Agent 启动失败的问题。需要 OpenCode 2.0.29 或更高版本 ([#10752](https://github.com/getpaseo/paseo/pull/10752))
|
||||
- 修复已删除的 OpenCode 子 Agent 一直留在子 Agent 列表中的问题 ([#8332](https://github.com/getpaseo/paseo/pull/8332))
|
||||
- 修复重新打开父 Agent 后,已停止的 Claude 后台子 Agent 显示为运行中的问题 ([#9013](https://github.com/getpaseo/paseo/pull/9013))
|
||||
- 修复插件和 Paseo 的指令替换 Codex Agent 自身 `developer_instructions` 的问题 ([#10792](https://github.com/getpaseo/paseo/pull/10792))
|
||||
- 修复 Go 密钥保存在 OpenCode 的 `auth.json` 中时 OpenCode Go 用量卡片消失的问题 ([#10678](https://github.com/getpaseo/paseo/pull/10678))
|
||||
- 修复 Windows 上 GitHub、GitLab 和 Gitea 命令破坏多行参数并展开 `%VAR%` 文本的问题 ([#10685](https://github.com/getpaseo/paseo/pull/10685))
|
||||
- 修复 `paseo hub login` 输出的链接不包含验证码的问题 ([#10751](https://github.com/getpaseo/paseo/pull/10751))
|
||||
- 修复 Hub 触发器在 Antigravity 等不支持工具策略的插件 Provider 上运行失败的问题 ([#10889](https://github.com/getpaseo/paseo/pull/10889))
|
||||
- 修复 Hub 会话读取 daemon 的 Provider 控件时被拒绝的问题 ([#10794](https://github.com/getpaseo/paseo/pull/10794))
|
||||
- 修复模型列表刷新超时后,Hermes 等插件 ACP Provider 留下进程继续运行的问题 ([#10867](https://github.com/getpaseo/paseo/pull/10867))
|
||||
- 修复插件在轮次进行中重新加载后,其 Agent 工具返回 `Tool not found` 的问题 ([#10106](https://github.com/getpaseo/paseo/pull/10106),贡献者:[@tomgrin10](https://github.com/tomgrin10))
|
||||
- 修复被时间线插件改写的回复缺少复制、分叉和轮次耗时的问题 ([#10795](https://github.com/getpaseo/paseo/pull/10795),贡献者:[@Brandon168](https://github.com/Brandon168))
|
||||
- 修复空闲的插件会话每 10 秒唤醒一次 daemon 的问题 ([#9363](https://github.com/getpaseo/paseo/pull/9363),贡献者:[@Brandon168](https://github.com/Brandon168))
|
||||
|
||||
### 安全
|
||||
|
||||
- Claude Code 2.1.326 或更高版本现在通过 stdin 接收 MCP 服务器令牌,不再放在其他本地用户可读取的进程参数中 ([#10698](https://github.com/getpaseo/paseo/pull/10698),贡献者:[@mdbraber](https://github.com/mdbraber))
|
||||
- 修复归档未批准设置的 PR worktree 时仍运行仓库 teardown 命令的问题 ([#10694](https://github.com/getpaseo/paseo/pull/10694))
|
||||
|
||||
### 插件
|
||||
|
||||
- 新增启动包装,插件可以在沙箱中运行 Agent、终端和 worktree 命令 ([#10786](https://github.com/getpaseo/paseo/pull/10786),贡献者:[@clkao](https://github.com/clkao), [@bendavid](https://github.com/bendavid))
|
||||
- 在插件的工作区快照中新增父工作区 ([#10781](https://github.com/getpaseo/paseo/pull/10781),贡献者:[@spatenotte](https://github.com/spatenotte))
|
||||
- 将内置的 `paseo-plugin` 技能更新到当前的插件 API ([#10793](https://github.com/getpaseo/paseo/pull/10793))
|
||||
|
||||
## 0.17.4 - 2026-11-23
|
||||
|
||||
### 修复
|
||||
|
||||
+14
-2
@@ -15,7 +15,7 @@ Each live agent in `AgentManager` carries a `lastStatus` of `initializing`, `idl
|
||||
## Daemon restart recovery
|
||||
|
||||
Restart recovery is off by default. Enable `agents.resumeOnStartup` in host config or
|
||||
Host settings → Agents to resume interrupted agents after graceful shutdown or a crash. The daemon
|
||||
Settings → Host → Daemon to resume interrupted agents after graceful shutdown or a crash. The daemon
|
||||
reopens the saved provider conversation and settings, then sends `Resume working.`. Customize
|
||||
the prompt with `agents.resumePrompt` or the same settings page.
|
||||
Disabling recovery consumes pending intent; enabling it later does not revive old work.
|
||||
@@ -183,7 +183,7 @@ caller, child, and host into one watch.
|
||||
|
||||
Bootstrap restores these watches after repairing stale running records to `closed` and before opening
|
||||
ingress. Reading a closed child's result does not load its provider. A finish notification reports that
|
||||
the child's run has settled; the parent decides whether its task is complete. A child chosen for restart
|
||||
the child has settled (see below); the parent decides whether its task is complete. A child chosen for restart
|
||||
recovery is observed only after its resume was sent, so the parent never hears that it was closed
|
||||
in between. Archived or deleted parents suppress delivery;
|
||||
parent-owned creation watches also stop
|
||||
@@ -196,6 +196,18 @@ outstanding intent. A crash after successful dispatch but before removal commits
|
||||
notification. Clean shutdown can also flush an already queued callback while retaining its intent,
|
||||
so that callback can repeat after restart. This is an at-least-once wakeup, without turn attribution or exactly-once delivery.
|
||||
|
||||
A turn end is not always a settled child. When the child ends its turn with work that will start its
|
||||
next turn by itself, the caller gets one `message` notice ("ended its turn but is still working") and
|
||||
the subscription keeps following the child. That work is 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. While following, turn ends and work changes stay
|
||||
silent until nothing is pending, which sends `finished` and removes the subscription. `followingSince`
|
||||
is stored before the notice is sent, so restarts resume following without repeating it, and following
|
||||
ends after 24 hours with an "is still working" notice. Remote children and providers without the probe
|
||||
report their first turn end as `finished`.
|
||||
|
||||
Permission requests are notification checkpoints, not the end of that subscription. The caller is notified again after a permission response when the child finishes, errors, or requests another permission.
|
||||
The permission notification includes the normalized request plus the child and request IDs, so the caller can inspect it and respond without fetching agent status.
|
||||
A watched child that closes before its finish event also notifies the caller so delegated work cannot disappear silently during archive or workspace teardown.
|
||||
|
||||
@@ -591,6 +591,11 @@ then retry only when a requested row changes during the read. Unrelated agent st
|
||||
invalidate the read. Directory baseline replacements and host removal or renaming still invalidate
|
||||
the affected reads.
|
||||
|
||||
On web and Electron, tabs share IndexedDB but hold independent directory snapshots in memory. A
|
||||
tab can commit directory deltas only while the persisted checkpoint revision matches the one it
|
||||
read or wrote. If a different tab evicts or rewrites that baseline, the next full directory refresh
|
||||
can replace it. Timeline writes do not depend on the directory checkpoint.
|
||||
|
||||
The cache is capped at 32 MiB and evicts whole hosts in least-recently-written order. After an
|
||||
eviction, only a baseline replacement stores that host's directory again. Mutations queued around
|
||||
the eviction are dropped when they are written, so a checkpoint never outlives its rows. Budget
|
||||
|
||||
@@ -10,6 +10,7 @@ Authoritative terminology. UI label wins. Don't invent synonyms; use what's here
|
||||
- **Agent** — See **Agent session**. UI still says "Agent" / "New Agent" in places, but moving toward **Agent session** as the canonical term. Code: `AgentSnapshotPayload` (`packages/protocol/src/messages.ts:608`). Forbidden: "Task", "Job", "Run".
|
||||
- **Daemon** — Local Paseo server process; identified by `serverId`. UI: "Daemon" (system contexts only). Code: `serverId` in `ServerInfoStatusPayloadSchema` (`packages/protocol/src/messages.ts:1936`), `DaemonClient` (`packages/client/src/daemon-client.ts`).
|
||||
- **Host** — Client-side connection profile pointing at a daemon; bundles one or more `HostConnection`s. UI: "Host" / "Add host" / "Switch host". Code: `HostProfile` (`packages/app/src/types/host-connection.ts:37`). Forbidden: "Connection" (means `HostConnection`, not host).
|
||||
- **Device** — A computer or phone running a Paseo client. Open **Devices** in a host’s settings to connect another device.
|
||||
- **Host badge** — The item on a sidebar workspace row's meta row naming which host that workspace lives on. Three things gate it, and they compose as a lattice rather than competing: the sidebar must span more than one host (automatic), **Show → Host** in the sidebar's display preferences must be on (global, all hosts at once), and then that host's own display mode decides _how_ it draws — **Name** / **Icon only** / **Hidden**. Name, color, and display mode are per-host, per-device, and live client-side on `HostProfile.appearance`; nothing about it reaches the daemon. Never add a fourth way to hide it. UI: the "Appearance" group on a host's settings page, and the "Show" submenu in the sidebar's display preferences. Code: `selectHostBadges` (`packages/app/src/hosts/appearance.ts`) takes the first two as its `enabled` input; `WorkspaceMetaRow` (`packages/app/src/components/sidebar/workspace-meta-row/index.tsx`) draws it. Don't confuse with **Status pill**, which reports state rather than identity.
|
||||
- **Project host entry** — One row in a project for a single (project, daemon) pair, aggregating that daemon's workspaces in the project. Internal. Code: `ProjectHostEntry` (`packages/app/src/utils/projects.ts:11`). Don't introduce "Checkout" as a synonym.
|
||||
- **Placement** — One workspace's stable foreign-key relationship to its project plus its git checkout snapshot. Internal. An explicit creation `projectId` is authoritative when active.
|
||||
|
||||
+4
-1
@@ -225,7 +225,10 @@ aborts the shared refresh signal at the deadline, and when it stops. Shutdown wa
|
||||
probes to settle before it shuts down provider clients, so a probe cannot start provider work,
|
||||
such as an OpenCode server, after its client has cleaned up. Providers name active catalog operations and
|
||||
finish subprocess, server, or session cleanup before rejecting. Timeout errors list the operations
|
||||
that were still active when the deadline expired.
|
||||
that were still active when the deadline expired. A plugin provider's connection is shared with its
|
||||
running sessions, so the bridge cannot close it at the deadline; it sends `request.cancel` for the
|
||||
abandoned request instead, and the provider stops that request's work
|
||||
([provider guide](../public-docs/plugins/providers.md#stop-a-request-paseo-cancels)).
|
||||
|
||||
Catalogue results stay cached by identity until a refresh or a change to that provider's configuration.
|
||||
Providers change their model lists on the server without a CLI update, so the daemon refreshes
|
||||
|
||||
+93
-31
@@ -48,7 +48,7 @@ the shipped source.
|
||||
The user decides when the changes on `main` warrant a release and how much risk it takes:
|
||||
|
||||
1. **Direct stable release** for a low-risk batch of polish and bug fixes. Stable desktop updates
|
||||
already ramp over 36 hours (see [Staged rollout](#staged-rollout-stable-channel)), and store
|
||||
start with a 5% canary and ramp over 18 hours (see [Staged rollout](#staged-rollout-stable-channel)), and store
|
||||
review often takes about a day, with no guaranteed timing.
|
||||
2. **Beta flow**, the default for changes that need testing. Release candidates on the `beta`
|
||||
channel. Each beta folds into the series' single changelog entry, publishes npm only on the
|
||||
@@ -324,11 +324,33 @@ Use the beta path when you need to:
|
||||
|
||||
## Staged rollout (stable channel)
|
||||
|
||||
Stable desktop releases go out via a linear time-based rollout for automatic update checks: 0% admitted when the updater manifests appear, 100% admitted 36 hours later, linear ramp in between. Manual checks bypass the rollout so a user can install immediately when they click **Check**. Beta releases bypass the rollout entirely — beta users always receive updates immediately.
|
||||
A stable desktop release reaches automatic updates in stages, so a bad release reaches few installs before you stop it. Each install decides locally from two fields in the release manifests, `releaseDate` and `rolloutHours`. No server tracks installs.
|
||||
|
||||
The rollout is driven by a `rolloutHours` field stamped into the GitHub Release manifests (`latest-mac.yml`, `latest-linux.yml`, `latest.yml`) by the `finalize-rollout` job in `desktop-release.yml`.
|
||||
| Stage | Rule |
|
||||
| -------------- | -------------------------------------------------------------------------------------------------------- |
|
||||
| Canary | For the first 8 hours, 5% of installs are admitted. |
|
||||
| Ramp | From 8 hours to `rolloutHours` (18 by default), admission rises in a straight line from 5% to 100%. |
|
||||
| Check interval | An install asks GitHub for the latest release at most once every 6 hours. |
|
||||
| Cooldown | After an install updates, it skips paced releases for 24 hours. |
|
||||
| Staged update | An install that holds a downloaded update keeps it and does not download the paced release that follows. |
|
||||
|
||||
Desktop release builds now publish in two phases:
|
||||
A paced release is a stable release with `rolloutHours` above 0. When `rolloutHours` is under 16, the canary hold is half of `rolloutHours`.
|
||||
|
||||
Every release places each install at a new position in the rollout, so the canary group changes with each release. With one or two releases per day, an install updates at most once every 24 hours and skips the releases in between.
|
||||
|
||||
These paths skip the stages:
|
||||
|
||||
- A manual check (**Check**) always asks GitHub and always offers the latest release.
|
||||
- A release with `rolloutHours: 0` is an emergency release. Every install takes it at its next check, during a cooldown too, and it replaces a staged update.
|
||||
- The beta channel has no stages. A beta install takes each release at its next check.
|
||||
|
||||
The **Notify** update mode follows the same stages and prompts instead of downloading. **Off** makes no automatic requests.
|
||||
|
||||
`packages/desktop/src/features/app-update-rollout.ts` owns the curve. `app-update-pacing.ts` owns the check interval and the cooldown, and `app-update-service.ts` owns the staged update.
|
||||
|
||||
### How a release is published
|
||||
|
||||
The `finalize-rollout` job in `desktop-release.yml` stamps `releaseDate` and `rolloutHours` into the GitHub Release manifests (`latest-mac.yml`, `latest-linux.yml`, `latest.yml`). Desktop release builds publish in two phases:
|
||||
|
||||
- The GitHub Release stays a draft while platform build jobs upload the installers/packages (`.dmg`, `.zip`, `.exe`, `.AppImage`, etc.).
|
||||
- The final job merges and stamps every channel manifest, uploads them with the final `releaseDate` and `rolloutHours`, then publishes the GitHub Release.
|
||||
@@ -338,20 +360,20 @@ Drafts do not appear in GitHub's releases feed. Updater clients continue to see
|
||||
### Default behavior
|
||||
|
||||
Follow the [standard stable release procedure](#standard-release-stable). The tag push starts
|
||||
the desktop release workflow, which sets a 36-hour rollout when it publishes the release.
|
||||
the desktop release workflow, which sets an 18-hour rollout when it publishes the release.
|
||||
|
||||
The `rollout_hours` input on `desktop-release.yml` is **only read on `workflow_dispatch`** — tag-push runs always default to 36. To get any other rollout duration on a fresh release, use the post-publish flip below.
|
||||
The `rollout_hours` input on `desktop-release.yml` is read only on `workflow_dispatch`. Tag-push runs always use 18. To get any other rollout duration on a fresh release, use the post-publish flip below.
|
||||
|
||||
### Instant-admit release (rollout_hours=0)
|
||||
### Emergency release (rollout_hours=0)
|
||||
|
||||
Follow the [standard stable release procedure](#standard-release-stable). Wait for Desktop
|
||||
Release to publish, then update the manifests to admit everyone immediately.
|
||||
Release to publish, then update the manifests to admit everyone at once.
|
||||
|
||||
```bash
|
||||
# 1. Wait for Desktop Release to publish the GitHub Release.
|
||||
gh run watch <desktop-release-run-id> --exit-status
|
||||
|
||||
# 2. Flip the published manifests to instant admit.
|
||||
# 2. Flip the published manifests to an emergency release.
|
||||
gh workflow run desktop-rollout.yml \
|
||||
-f tag=v0.1.64 \
|
||||
-f rollout_hours=0
|
||||
@@ -359,23 +381,13 @@ gh workflow run desktop-rollout.yml \
|
||||
|
||||
Dispatch only after `finalize-rollout` has published the release. Until then the release is a draft, and a draft has no tag: `desktop-rollout.yml` looks the release up by tag and fails with `release not found`. The concurrency group `desktop-rollout-<tag>` that the two workflows share orders them only once both are queued; it does not hold an early dispatch until the draft is published.
|
||||
|
||||
The first public manifests carry `rolloutHours=36` for the minutes between publish and the flip. The renderer polls every 30 minutes, so active stable users pick up the new manifest on their next check.
|
||||
The first public manifests carry `rolloutHours=18` for the minutes between publish and the flip. An install sees the flip at its next check, which is up to 6 hours after its previous one. In automatic mode it then downloads the release and installs it when the app quits.
|
||||
|
||||
### Adjusting an already-published release
|
||||
|
||||
To change the rollout duration on a release that's already shipped — e.g. flip a hotfix to instant admit, or slow a release down — use the dedicated `desktop-rollout.yml` workflow. It edits the manifests in place on the GitHub release without rebuilding anything. It only rewrites `rolloutHours`; `releaseDate` is preserved, so the rollout clock keeps ticking from the original publish time.
|
||||
To change the rollout duration on a release that already shipped, use the `desktop-rollout.yml` workflow. It edits the manifests in place on the GitHub release without rebuilding anything. It rewrites only `rolloutHours`. `releaseDate` is preserved, so the rollout clock keeps running from the original publish time.
|
||||
|
||||
**Hotfix (instant admit) on an already-shipped release:**
|
||||
|
||||
```bash
|
||||
gh workflow run desktop-rollout.yml \
|
||||
-f tag=v0.1.42 \
|
||||
-f rollout_hours=0
|
||||
```
|
||||
|
||||
`rollout_hours=0` admits 100% of stable users on their next update check (within ~30 min for active clients).
|
||||
|
||||
**Slow a rollout down** (e.g. extend total duration to 72h since the original release):
|
||||
To slow a rollout down, for example to 72 hours since the original release:
|
||||
|
||||
```bash
|
||||
gh workflow run desktop-rollout.yml \
|
||||
@@ -383,13 +395,59 @@ gh workflow run desktop-rollout.yml \
|
||||
-f rollout_hours=72
|
||||
```
|
||||
|
||||
`rollout_hours` is **total duration since the original release date**, not "extend by N more hours from now." If `v0.1.42` was published 2h ago and you set `rollout_hours=72`, the ramp finishes 70h from now.
|
||||
`rollout_hours` is the total duration since the original release date. If `v0.1.42` was published 2 hours ago and you set `rollout_hours=72`, the ramp finishes 70 hours from now.
|
||||
|
||||
A longer rollout does not stop a release. The canary group still updates. To stop a release, [halt it](#halt-a-release).
|
||||
|
||||
The dispatch is idempotent and shares the `desktop-rollout-<tag>` concurrency group with `desktop-release.yml`'s `finalize-rollout` job, so it serializes safely against an in-flight tag-push pipeline targeting the same release.
|
||||
|
||||
### Halt a release
|
||||
|
||||
Stable installs and the download page follow the release that GitHub marks as latest. To stop a release, mark the last good release as latest:
|
||||
|
||||
```bash
|
||||
# v0.1.41 is the last good release.
|
||||
gh release edit v0.1.41 --latest
|
||||
|
||||
# Prints v0.1.41 when the halt is in effect.
|
||||
gh api repos/getpaseo/paseo/releases/latest --jq .tag_name
|
||||
```
|
||||
|
||||
The halt applies to every stable install from its next check, including installs older than the staged rollout:
|
||||
|
||||
- An install that has not downloaded the halted release no longer sees it.
|
||||
- An install that downloaded it asks GitHub again before it installs at quit, and drops the download.
|
||||
- An install that already runs the halted release stays on it, because the app never downgrades. [Ship a fix](#fix-a-bad-release).
|
||||
|
||||
A halt does not reach the beta channel. Beta installs read the release list by date and still take the halted release.
|
||||
|
||||
To resume a halted release, run `gh release edit v0.1.42 --latest` with its tag.
|
||||
|
||||
### Fix a bad release
|
||||
|
||||
1. [Halt](#halt-a-release) the bad release.
|
||||
2. Ship the fix as the next patch with the [standard stable release procedure](#standard-release-stable).
|
||||
3. After Desktop Release publishes the fix, make sure that GitHub marks it as latest:
|
||||
|
||||
```bash
|
||||
gh api repos/getpaseo/paseo/releases/latest --jq .tag_name
|
||||
```
|
||||
|
||||
If the command prints another tag, run `gh release edit <fix-tag> --latest`.
|
||||
|
||||
4. Flip the fix to an [emergency release](#emergency-release-rollout_hours0):
|
||||
|
||||
```bash
|
||||
gh workflow run desktop-rollout.yml \
|
||||
-f tag=<fix-tag> \
|
||||
-f rollout_hours=0
|
||||
```
|
||||
|
||||
Do not leave the fix as a paced release. The installs that took the bad release are in their 24-hour cooldown and skip a paced release. An install that holds the bad release as a staged update, and did not check during the halt, keeps it when a paced release follows. An emergency release reaches both.
|
||||
|
||||
### Custom ramp on a manually-dispatched build
|
||||
|
||||
`desktop-release.yml` accepts `rollout_hours` only on `workflow_dispatch`, which is the path used to **rebuild an existing tag** (retry a failed release, force a rebuild on a different ref). When you go that route, you can stamp a non-default ramp directly:
|
||||
`desktop-release.yml` accepts `rollout_hours` only on `workflow_dispatch`, which is the path used to rebuild an existing tag (retry a failed release, force a rebuild on a different ref). On that path, you can stamp a different ramp directly:
|
||||
|
||||
```bash
|
||||
gh workflow run desktop-release.yml \
|
||||
@@ -397,14 +455,18 @@ gh workflow run desktop-release.yml \
|
||||
-f rollout_hours=6
|
||||
```
|
||||
|
||||
For a fresh release with a custom ramp, follow the [instant-admit procedure](#instant-admit-release-rollout_hours0)
|
||||
For a fresh release with a custom ramp, follow the [emergency release procedure](#emergency-release-rollout_hours0)
|
||||
and set `rollout_hours` to your chosen duration.
|
||||
|
||||
### Releasing during an active rollout
|
||||
|
||||
If you ship N+1 while N is still ramping, N+1 starts a fresh rollout from its own publish timestamp. N's rollout effectively ends — the newer manifest supersedes it. Rollout-aware clients revalidate the manifest for up to five seconds before installing a downloaded update on quit. If N+1 has replaced N but the client is not admitted to N+1 yet, it skips the downloaded N and waits rather than installing two updates in succession. If revalidation times out, the app exits without installing the cached update.
|
||||
If you ship N+1 while N is still ramping, N+1 starts a new rollout from its own publish time, and the rollout of N ends because installs no longer see its manifests.
|
||||
|
||||
If N+1 is a hotfix for a bug in N, dispatch `desktop-rollout.yml -f tag=v0.1.<N+1> -f rollout_hours=0` after N+1 publishes so the users who already got N reach the fix fast.
|
||||
An install that holds N as a staged update keeps N when N+1 is a paced release, and installs N when the app quits. It then waits out its cooldown before it takes a later paced release. The hold covers only paced patch releases that the install saw one after the other. If the install missed a release, it evaluates the newest release instead: it replaces N when it is admitted, and drops N when it is not.
|
||||
|
||||
A minor or major release always ends the hold. The version numbers do not show whether a fix shipped between `0.17.4` and `0.18.0`, so the install treats `0.18.0` as if it missed a release.
|
||||
|
||||
Before an install at quit, the app asks GitHub for the latest release for up to five seconds. If that check does not finish in time, the app exits without installing the staged update.
|
||||
|
||||
### macOS system floor
|
||||
|
||||
@@ -417,10 +479,10 @@ macOS 13 maps to Darwin 22. The two values use different version domains; do not
|
||||
|
||||
### Limitations
|
||||
|
||||
- **No pause / kill switch.** To stop new admissions, ship a superseding release. Clients revalidate on quit and will not install the superseded download, but a client that already completed installation cannot be recalled; ship a hotfix `+1` patch.
|
||||
- **No rollback.** `allowDowngrade = false`. Bad release = ship a hotfix.
|
||||
- **Bootstrap caveat.** Clients running a build older than the rollout feature ignore `rolloutHours` and admit immediately. Rollout protection only applies to clients running the rollout-aware version or later.
|
||||
- **Up to ~30 min automatic admission latency.** Renderer polls every 30 minutes, so a stable user may take up to that long to be evaluated against the rollout window. Clicking **Check** is manual and bypasses rollout admission.
|
||||
- A release cannot be recalled from an install that runs it. `allowDowngrade` is `false`. [Halt](#halt-a-release) the release to protect the other installs, then [ship a fix](#fix-a-bad-release).
|
||||
- An emergency release reaches a running install at its next check, up to 6 hours after its previous one. A manual check sees it at once.
|
||||
- Installs older than the canary and cooldown build have neither. They ramp in a straight line over `rolloutHours` and check every 30 minutes. Installs older than the staged rollout ignore `rolloutHours` and update at once.
|
||||
- The app window starts every automatic check. A release whose window does not load cannot update itself, and its users must download a new build from the website. Smoke the packaged app before you publish.
|
||||
|
||||
## Mobile builds (EAS)
|
||||
|
||||
|
||||
+22
-4
@@ -61,6 +61,11 @@ the chat and its replica cache would keep only the end of the reply. A recovery
|
||||
running catch-up starts after whatever that catch-up applied, because the app applies a forward page
|
||||
row by row and an older cursor repeats rows.
|
||||
|
||||
A live row whose epoch differs from the local cursor is a rewind or replacement this client never
|
||||
saw as an invalidation, not a stale row. The app recovers like a gap: it asks `after` its own
|
||||
cursor, and the daemon answers that stale epoch with a reset tail. Dropping the rows instead would
|
||||
leave the chat on pre-rewind history while the new epoch streams.
|
||||
|
||||
Initialization timeouts guard lack of catch-up progress, not the full multi-page sync. A successful page that queues the next `after` page refreshes the watchdog.
|
||||
|
||||
Opening or resuming an agent fetches the latest available turns with a soft target of 40
|
||||
@@ -202,10 +207,23 @@ owner wraps cached preparation, network catch-up, accepted timeline application,
|
||||
behind one interface. React supplies transport and projection operations without selecting a cache
|
||||
path or issuing a separate persistence notification.
|
||||
|
||||
Active-agent list reconciliation does not own transcript lifetime. An archived agent's fresh
|
||||
history response can arrive before the active-list response that omits it. Clearing history there
|
||||
would discard accepted rows while the viewed owner still considers them synchronized. Entity
|
||||
deletion clears the transcript; list membership changes do not.
|
||||
The viewed-timeline owner also owns how long a transcript stays in memory. An active agent's
|
||||
transcript stays resident while its chat is hidden, so switching back to it needs no fetch. An
|
||||
archived agent's transcript stays resident only while its chat is shown, for example when it is
|
||||
opened from History. When an agent is archived, or the active list drops it because its workspace
|
||||
was archived, the owner releases the transcript unless the chat is shown. It also releases the
|
||||
transcript when the chat stops being shown. A released chat leaves the opened chats. When it is
|
||||
shown again, it reads the replica cache and catches up again. A history page, live event, or cache
|
||||
read that arrives after the release is dropped.
|
||||
|
||||
The active-list reconciliation does not release transcripts itself. An archived agent's fresh
|
||||
history response can arrive before the active-list response that omits it, while the chat is
|
||||
open in History. Clearing history there would discard rows the user is reading.
|
||||
|
||||
An agent counts as archived when the active list omits it, when its row has an archive timestamp,
|
||||
or when the workspace list omits its workspace. The workspace check matters because a workspace
|
||||
archive can complete while one of its agents keeps a row with no archive timestamp. Until a list
|
||||
first hydrates, it marks no agent as archived. Deleting the agent clears the transcript.
|
||||
|
||||
Removing the host from the registry is the destructive boundary: it stops the runtime and clears the
|
||||
session and host-scoped setup state together.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- Archive workspaces together: Cmd/Ctrl+click a workspace in the sidebar to select multiple workspaces and archive them in one step.
|
||||
- Copy quoted drafts: Copy a quote from a reply with one tap, without the > markers.
|
||||
- Redesigned agent profiles page: Agent profiles have their own dedicated settings page, and the model picker saves a new profile in one tap.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Archive workspaces together: Cmd/Ctrl+click a workspace in the sidebar to select multiple workspaces and archive them in one step.
|
||||
- Copy quoted drafts: Copy a quote from a reply with one tap, without the > markers.
|
||||
- Redesigned agent profiles page: Agent profiles have their own dedicated settings page, and the model picker saves a new profile in one tap.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Archive workspaces together: Cmd/Ctrl+click a workspace in the sidebar to select multiple workspaces and archive them in one step.
|
||||
- Copy quoted drafts: Copy a quote from a reply with one tap, without the > markers.
|
||||
- Redesigned agent profiles page: Agent profiles have their own dedicated settings page, and the model picker saves a new profile in one tap.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,5 @@
|
||||
- Archive workspaces together: Cmd/Ctrl+click a workspace in the sidebar to select multiple workspaces and archive them in one step.
|
||||
- Copy quoted drafts: Copy a quote from a reply with one tap, without the > markers.
|
||||
- Redesigned agent profiles page: Agent profiles have their own dedicated settings page, and the model picker saves a new profile in one tap.
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,12 @@
|
||||
Improved
|
||||
- Reorganized Settings into Device and Host sections and consolidated sparse pages
|
||||
- Added arrow-key navigation for models, providers, and profiles in the model picker
|
||||
- Added an in-place Refresh control for Tailscale availability in host settings and setup
|
||||
|
||||
Changed
|
||||
- Removed the Antigravity usage source that ran agy -p /usage in the background
|
||||
|
||||
Fixed
|
||||
- Fixed Paseo Android crashing on Samsung devices when a chat shows a code block or quote
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,12 @@
|
||||
Improved
|
||||
- Reorganized Settings into Device and Host sections and consolidated sparse pages
|
||||
- Added arrow-key navigation for models, providers, and profiles in the model picker
|
||||
- Added an in-place Refresh control for Tailscale availability in host settings and setup
|
||||
|
||||
Changed
|
||||
- Removed the Antigravity usage source that ran agy -p /usage in the background
|
||||
|
||||
Fixed
|
||||
- Fixed Paseo Android crashing on Samsung devices when a chat shows a code block or quote
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,12 @@
|
||||
Improved
|
||||
- Reorganized Settings into Device and Host sections and consolidated sparse pages
|
||||
- Added arrow-key navigation for models, providers, and profiles in the model picker
|
||||
- Added an in-place Refresh control for Tailscale availability in host settings and setup
|
||||
|
||||
Changed
|
||||
- Removed the Antigravity usage source that ran agy -p /usage in the background
|
||||
|
||||
Fixed
|
||||
- Fixed Paseo Android crashing on Samsung devices when a chat shows a code block or quote
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -0,0 +1,12 @@
|
||||
Improved
|
||||
- Reorganized Settings into Device and Host sections and consolidated sparse pages
|
||||
- Added arrow-key navigation for models, providers, and profiles in the model picker
|
||||
- Added an in-place Refresh control for Tailscale availability in host settings and setup
|
||||
|
||||
Changed
|
||||
- Removed the Antigravity usage source that ran agy -p /usage in the background
|
||||
|
||||
Fixed
|
||||
- Fixed Paseo Android crashing on Samsung devices when a chat shows a code block or quote
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
+1
-1
@@ -1 +1 @@
|
||||
sha256-TAVzJzziWDAapQkG4TLkLzOlodkdFNKSl3y/Tm9HB28=
|
||||
sha256-6XXAVBTH6rIdg5eQ9cUeUwV22ikVqTtdWo7i9DYO+/M=
|
||||
|
||||
Generated
+30
-29
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -37541,7 +37541,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -39694,13 +39694,13 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.17.4",
|
||||
"@getpaseo/protocol": "0.17.4",
|
||||
"@getpaseo/server": "0.17.4",
|
||||
"@getpaseo/client": "0.17.6",
|
||||
"@getpaseo/protocol": "0.17.6",
|
||||
"@getpaseo/server": "0.17.6",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -39947,11 +39947,11 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.17.4",
|
||||
"@getpaseo/relay": "0.17.4",
|
||||
"@getpaseo/protocol": "0.17.6",
|
||||
"@getpaseo/relay": "0.17.6",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
@@ -39963,7 +39963,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/cli": "*",
|
||||
@@ -40206,7 +40206,7 @@
|
||||
},
|
||||
"packages/expo-two-way-audio": {
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -40252,7 +40252,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -40282,7 +40282,7 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^1.4.0",
|
||||
@@ -40290,8 +40290,8 @@
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.17.4",
|
||||
"@getpaseo/protocol": "0.17.4",
|
||||
"@getpaseo/client": "0.17.6",
|
||||
"@getpaseo/protocol": "0.17.6",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.2.3",
|
||||
@@ -40301,8 +40301,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.17.4",
|
||||
"@getpaseo/protocol": "0.17.4",
|
||||
"@getpaseo/client": "0.17.6",
|
||||
"@getpaseo/protocol": "0.17.6",
|
||||
"react": ">=19.1.0 <20",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -40324,7 +40324,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
@@ -40351,7 +40351,7 @@
|
||||
}
|
||||
},
|
||||
"packages/react-native-enriched-markdown": {
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
@@ -40367,7 +40367,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^2.4.0",
|
||||
@@ -40589,17 +40589,17 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"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.17.4",
|
||||
"@getpaseo/highlight": "0.17.4",
|
||||
"@getpaseo/plugin": "0.17.4",
|
||||
"@getpaseo/protocol": "0.17.4",
|
||||
"@getpaseo/relay": "0.17.4",
|
||||
"@getpaseo/client": "0.17.6",
|
||||
"@getpaseo/highlight": "0.17.6",
|
||||
"@getpaseo/plugin": "0.17.6",
|
||||
"@getpaseo/protocol": "0.17.6",
|
||||
"@getpaseo/relay": "0.17.6",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/node": "2.1.2",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
@@ -40625,6 +40625,7 @@
|
||||
"p-limit": "^7.3.0",
|
||||
"p-memoize": "^8.0.0",
|
||||
"p-throttle": "^8.1.0",
|
||||
"parse5": "^7.3.0",
|
||||
"pino": "^10.2.0",
|
||||
"pino-pretty": "^13.1.3",
|
||||
"qrcode": "^1.5.4",
|
||||
@@ -41549,7 +41550,7 @@
|
||||
},
|
||||
"packages/website": {
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.29.1",
|
||||
"@cloudflare/workers-types": "^4.20260317.1",
|
||||
@@ -43160,7 +43161,7 @@
|
||||
},
|
||||
"plugins": {
|
||||
"name": "@getpaseo/builtin-plugins",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"dependencies": {
|
||||
"@getpaseo/plugin": "*",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
waitForWorkspaceTabsVisible,
|
||||
} from "../support/helpers/workspace-tabs";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { openSettingsSection } from "../support/helpers/settings";
|
||||
import { buildHostWorkspaceRoute } from "@/utils/host-routes";
|
||||
import { WORKSPACE_DECK_MAX_MOUNTED_WORKSPACES } from "@/screens/workspace/workspace-deck-retention";
|
||||
import { delayBrowserAgentCreatedStatus } from "../support/helpers/new-workspace";
|
||||
@@ -350,6 +351,7 @@ async function selectSendBehaviorInSettings(
|
||||
behaviorLabel: string,
|
||||
stored: string,
|
||||
): Promise<void> {
|
||||
await openSettingsSection(page, "chat");
|
||||
await page.getByRole("button", { name: /^Default send: / }).click();
|
||||
await page.getByRole("menuitem", { name: behaviorLabel, exact: true }).click();
|
||||
await expect
|
||||
|
||||
@@ -272,13 +272,15 @@ test.describe("Agent profiles settings", () => {
|
||||
await test.step("switching Settings sections asks before discarding an edited draft", async () => {
|
||||
await fillAgentProfileName(page, "Unsaved sidebar edit");
|
||||
|
||||
await switchSettingsSectionWithConfirm(page, "Agents", "dismiss");
|
||||
await switchSettingsSectionWithConfirm(page, "Tools & prompts", "dismiss");
|
||||
await expect(page.getByTestId("agent-profile-drawer")).toBeVisible();
|
||||
await expectAgentProfileNameDraft(page, "Unsaved sidebar edit");
|
||||
|
||||
await switchSettingsSectionWithConfirm(page, "Agents", "accept");
|
||||
await switchSettingsSectionWithConfirm(page, "Tools & prompts", "accept");
|
||||
await expect(page.getByTestId("agent-profile-drawer")).toHaveCount(0, { timeout: 30_000 });
|
||||
await expect(page.getByTestId("settings-detail-header-title")).toHaveText("Agents");
|
||||
await expect(page.getByTestId("settings-detail-header-title")).toHaveText(
|
||||
"Tools & prompts",
|
||||
);
|
||||
});
|
||||
|
||||
await test.step("confirming browser Back leaves Agent profiles and discards the draft", async () => {
|
||||
|
||||
@@ -47,7 +47,7 @@ async function openHostOverview(page: Page, daemon: IsolatedHostDaemon): Promise
|
||||
endpoint: `127.0.0.1:${daemon.port}`,
|
||||
},
|
||||
]);
|
||||
await page.goto(`/settings/hosts/${daemon.serverId}/host`);
|
||||
await page.goto(`/settings/hosts/${daemon.serverId}/daemon`);
|
||||
await expect(page.getByText("Online", { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ async function expectHelpHostVersion(page: Page, serverId: string, version: stri
|
||||
async function openHostPage(page: Page, host: RestartableHostDaemon): Promise<void> {
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, host.serverId);
|
||||
await openHostSection(page, host.serverId, "host");
|
||||
await openHostSection(page, host.serverId, "daemon");
|
||||
}
|
||||
|
||||
function hostIdentity(page: Page) {
|
||||
|
||||
@@ -13,8 +13,8 @@ async function openMetadataGenerationSettings(page: Page) {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, serverId);
|
||||
await openHostSection(page, serverId, "metadata");
|
||||
await expectSettingsHeader(page, "Metadata");
|
||||
await openHostSection(page, serverId, "workspaces");
|
||||
await expectSettingsHeader(page, "Workspaces");
|
||||
}
|
||||
|
||||
async function openManualMetadataModelPicker(page: Page) {
|
||||
|
||||
@@ -3,7 +3,9 @@ import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import { test, expect, type Page } from "../support/fixtures";
|
||||
import { connectDaemonClient } from "../support/helpers/daemon-client-loader";
|
||||
import {
|
||||
clickModelRowWhileProviderOpens,
|
||||
closeModelPicker,
|
||||
expectModelListScrollKeepsSearchFocused,
|
||||
expectModelSearchEmptyState,
|
||||
expectModelPickerHeight,
|
||||
expectModelPickerWidth,
|
||||
@@ -154,6 +156,137 @@ test.describe("Cross-provider model search", () => {
|
||||
await expectModelPickerHeight(page, restingHeight);
|
||||
await expectModelPickerWidth(page, restingWidth);
|
||||
});
|
||||
|
||||
await test.step("ArrowUp wraps to the end of a virtualized catalog and Enter selects it", async () => {
|
||||
await searchAllModels(page, "bulk model");
|
||||
await page.keyboard.press("ArrowUp");
|
||||
// Tie-broken lexicographically by modelLabel, so "Bulk model 99" sits at the bottom.
|
||||
const lastRow = page
|
||||
.getByTestId("combobox-desktop-container")
|
||||
.getByTestId(`model-row-${LARGE_CATALOG.id}-bulk-99`);
|
||||
await expect(lastRow).toBeVisible();
|
||||
await expect(lastRow).toHaveAttribute("data-active", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(page.getByTestId("combobox-desktop-container")).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByTestId("combined-model-selector").filter({ visible: true }).first(),
|
||||
).toContainText("Bulk model 99");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
await profile.restore();
|
||||
await provider.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("arrow keys navigate profiles, providers, models, and search results in the composer", async ({
|
||||
page,
|
||||
}) => {
|
||||
const provider = await seedModelProvider(STUDIO);
|
||||
const profile = await seedAgentProfiles([
|
||||
{
|
||||
id: "agent_profile_e2e_arrows",
|
||||
name: "Arrow Profile",
|
||||
provider: STUDIO.id,
|
||||
modelId: "studio-fast",
|
||||
},
|
||||
]);
|
||||
const workspace = await seedWorkspace({ repoPrefix: "model-picker-arrows-" });
|
||||
|
||||
try {
|
||||
await test.step("open the composer model picker on the root view", async () => {
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await clickNewChat(page);
|
||||
await expectComposerVisible(page);
|
||||
await openModelPicker(page);
|
||||
});
|
||||
|
||||
const viewport = page.getByTestId("combobox-desktop-container");
|
||||
const trigger = page.getByTestId("combined-model-selector").filter({ visible: true }).first();
|
||||
const profileRow = viewport.getByTestId("model-profile-row-agent_profile_e2e_arrows");
|
||||
const studioProviderRow = viewport.getByTestId(`model-provider-${STUDIO.id}`);
|
||||
|
||||
await test.step("move from profiles to providers, drill in with ArrowRight, and go back with ArrowLeft", async () => {
|
||||
await expect(profileRow).toHaveAttribute("data-active", "true");
|
||||
// Root view keeps aria-selected absent while keyboard-active uses data-active.
|
||||
await expect(viewport.locator("[aria-selected]")).toHaveCount(0);
|
||||
|
||||
// Step down until Mock Studio is active (provider order can vary across environments).
|
||||
for (let step = 0; step < 10; step += 1) {
|
||||
if ((await studioProviderRow.getAttribute("data-active")) === "true") break;
|
||||
await page.keyboard.press("ArrowDown");
|
||||
}
|
||||
await expect(studioProviderRow).toHaveAttribute("data-active", "true");
|
||||
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await expect(viewport.getByTestId(`model-row-${STUDIO.id}-studio-fast`)).toBeVisible();
|
||||
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await expect(studioProviderRow).toHaveAttribute("data-active", "true");
|
||||
});
|
||||
|
||||
await test.step("Enter drills into the active provider and ArrowDown + Enter selects a model", async () => {
|
||||
await page.keyboard.press("Enter");
|
||||
const deepRow = viewport.getByTestId(`model-row-${STUDIO.id}-studio-deep`);
|
||||
await expect(deepRow).toBeVisible();
|
||||
await expectModelListScrollKeepsSearchFocused(page);
|
||||
|
||||
for (let step = 0; step < 5; step += 1) {
|
||||
if ((await deepRow.getAttribute("data-active")) === "true") break;
|
||||
await page.keyboard.press("ArrowDown");
|
||||
}
|
||||
await expect(deepRow).toHaveAttribute("data-active", "true");
|
||||
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(viewport).toHaveCount(0);
|
||||
await expect(trigger).toContainText("Studio deep think");
|
||||
});
|
||||
|
||||
await test.step("typing filters results while arrow keys select across search matches", async () => {
|
||||
await openModelPicker(page);
|
||||
await searchAllModels(page, "ten second stream");
|
||||
const studioFast = viewport.getByTestId(`model-row-${STUDIO.id}-studio-fast`);
|
||||
const mockFast = viewport.getByTestId("model-row-mock-ten-second-stream");
|
||||
await expect(studioFast).toBeVisible();
|
||||
await expect(mockFast).toBeVisible();
|
||||
|
||||
// Advance to the second match and confirm with Enter.
|
||||
const initialMockActive = (await mockFast.getAttribute("data-active")) === "true";
|
||||
await page.keyboard.press("ArrowDown");
|
||||
const targetRow = initialMockActive ? studioFast : mockFast;
|
||||
await expect(targetRow).toHaveAttribute("data-active", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(viewport).toHaveCount(0);
|
||||
await expect(trigger).toContainText("Ten second stream");
|
||||
});
|
||||
|
||||
await test.step("a press on a model row selects it while the provider list is still opening", async () => {
|
||||
await openModelPicker(page);
|
||||
await clickModelRowWhileProviderOpens(page, {
|
||||
provider: "mock",
|
||||
modelLabel: "One minute stream",
|
||||
});
|
||||
await expect(viewport).toHaveCount(0);
|
||||
await expect(trigger).toContainText("One minute stream");
|
||||
});
|
||||
|
||||
await test.step("Enter on the active profile row applies it", async () => {
|
||||
await openModelPicker(page);
|
||||
await expect(profileRow).toHaveAttribute("data-active", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(viewport).toHaveCount(0);
|
||||
await expect(trigger).toContainText("Ten second stream");
|
||||
});
|
||||
|
||||
await test.step("folded compact sheet also supports Enter on the active profile row", async () => {
|
||||
await page.setViewportSize({ width: 390, height: 800 });
|
||||
await page.getByTestId("combined-model-selector").filter({ visible: true }).first().click();
|
||||
const sheetProfileRow = page.getByTestId("model-profile-row-agent_profile_e2e_arrows");
|
||||
await expect(sheetProfileRow).toBeVisible();
|
||||
await expect(sheetProfileRow).toHaveAttribute("data-active", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(sheetProfileRow).toHaveCount(0);
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
await profile.restore();
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
closeRelayPairing,
|
||||
emptyHome,
|
||||
loadingScreen,
|
||||
openTailscaleDocsFromSetup,
|
||||
expectTailscaleSwitchDisabled,
|
||||
paseoToolsSwitch,
|
||||
pickTheme,
|
||||
projectSuggestion,
|
||||
@@ -105,7 +105,7 @@ test("a new user is walked through setup once", async ({ page }, testInfo) => {
|
||||
await expectSetupStep(page, "Let agents use Paseo");
|
||||
await expect(paseoToolsSwitch(setupModal(page))).toBeChecked();
|
||||
await expect(
|
||||
setupModal(page).getByRole("switch", { name: "Orchestration skills", exact: true }),
|
||||
setupModal(page).getByRole("switch", { name: "Paseo skills", exact: true }),
|
||||
).toBeChecked();
|
||||
await page.screenshot({ path: testInfo.outputPath("4-orchestration.png") });
|
||||
});
|
||||
@@ -403,12 +403,10 @@ test("setup choices carry over to Settings and the phone step pairs over relay",
|
||||
await continueSetup(page);
|
||||
});
|
||||
|
||||
await test.step("Phone offers Tailscale docs and pairs over relay in its own modal", async () => {
|
||||
await test.step("Phone shows a disabled Tailscale switch and pairs over relay", async () => {
|
||||
await expectSetupStep(page, "Take your agents with you");
|
||||
await page.screenshot({ path: testInfo.outputPath("5-phone.png") });
|
||||
expect(await openTailscaleDocsFromSetup(page)).toBe(
|
||||
"https://paseo.sh/docs/connectivity#tailscale",
|
||||
);
|
||||
await expectTailscaleSwitchDisabled(page);
|
||||
const pairing = await openRelayPairingFromSetup(page);
|
||||
await expect(pairing.getByText("Enable relay?", { exact: true })).toBeVisible();
|
||||
await enableRelayAndExpectOffer(page);
|
||||
@@ -419,7 +417,7 @@ test("setup choices carry over to Settings and the phone step pairs over relay",
|
||||
await test.step("Finish closes setup and Settings shows the same Paseo tools value", async () => {
|
||||
await finishSetup(page);
|
||||
await page.locator('[data-testid="sidebar-settings"]:visible').first().click();
|
||||
await openSettingsHostSection(page, host.serverId, "agents");
|
||||
await openSettingsHostSection(page, host.serverId, "tools");
|
||||
await expect(paseoToolsSwitch(page)).toBeChecked();
|
||||
await page.screenshot({ path: testInfo.outputPath("7-settings-agents.png") });
|
||||
});
|
||||
@@ -441,7 +439,7 @@ test("with no skills picked, skills read as off and Continue moves on", async ({
|
||||
await chooseCustomSkills(page, []);
|
||||
await saveSkillSelection(page);
|
||||
const skillsSwitch = setupModal(page).getByRole("switch", {
|
||||
name: "Orchestration skills",
|
||||
name: "Paseo skills",
|
||||
exact: true,
|
||||
});
|
||||
await expect(skillsSwitch).not.toBeChecked();
|
||||
@@ -478,7 +476,7 @@ test("in the compact layout, Finish on Orchestration applies its switches", asyn
|
||||
await step("Let agents use Paseo");
|
||||
await expect(paseoToolsSwitch(page)).toBeChecked();
|
||||
// Skills are not installed, so leaving them off has nothing to apply.
|
||||
const skillsSwitch = page.getByRole("switch", { name: "Orchestration skills", exact: true });
|
||||
const skillsSwitch = page.getByRole("switch", { name: "Paseo skills", exact: true });
|
||||
await skillsSwitch.click();
|
||||
await expect(skillsSwitch).not.toBeChecked();
|
||||
gate.holdNextClientRequest("set_daemon_config_request");
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import {
|
||||
addDirectHostFromSettings,
|
||||
openSettingsHostSection,
|
||||
selectSettingsHost,
|
||||
} from "../support/helpers/settings";
|
||||
import { test } from "../support/fixtures";
|
||||
import { startTailscaleTestDaemon } from "../support/helpers/tailscale-daemon";
|
||||
import { startIsolatedHostDaemon } from "../support/helpers/isolated-host-daemon";
|
||||
import {
|
||||
expectPairingOffer,
|
||||
cancelTailscaleTurnOff,
|
||||
confirmTailscaleTurnOff,
|
||||
connectThroughTailscale,
|
||||
disableTailscale,
|
||||
enableTailscale,
|
||||
expectTailscaleAddress,
|
||||
expectTailscaleAvailable,
|
||||
expectTailscaleRowLoadsOn,
|
||||
expectTailscaleUnavailable,
|
||||
observeDaemonStatusPolling,
|
||||
openSetupMobileStep,
|
||||
refreshTailscaleAvailability,
|
||||
slowConnectionToHost,
|
||||
expectTailscaleUpdateRequired,
|
||||
expectCompletePairingQr,
|
||||
expectRelayConsent,
|
||||
openPairDeviceModal,
|
||||
@@ -37,3 +58,115 @@ test("keeps the pairing QR code inside its compact tile", async ({ page }, testI
|
||||
await daemon.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("asks for a host update when Tailscale controls are unavailable", async ({ page }) => {
|
||||
const daemon = await startIsolatedHostDaemon("pair-device-browser-old-host", {
|
||||
publishedVersion: "0.13.0-beta.2",
|
||||
});
|
||||
try {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await addDirectHostFromSettings(page, { host: "127.0.0.1", port: daemon.port });
|
||||
await selectSettingsHost(page, daemon.serverId);
|
||||
await openSettingsHostSection(page, daemon.serverId, "devices");
|
||||
await expectTailscaleUpdateRequired(page);
|
||||
} finally {
|
||||
await daemon.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("turns Tailscale on and off from Devices, asking first over Tailscale", async ({
|
||||
page,
|
||||
baseURL,
|
||||
}, testInfo) => {
|
||||
test.skip(process.platform !== "linux", "Uses a second IPv4 loopback address");
|
||||
// The journey opens Devices or the setup six times, two of them over a slowed connection.
|
||||
test.setTimeout(120_000);
|
||||
if (!baseURL) throw new Error("Expected the app base URL");
|
||||
const daemon = await startTailscaleTestDaemon(baseURL);
|
||||
try {
|
||||
await preparePairingHost(page, daemon);
|
||||
await enableTailscale(page);
|
||||
await expectTailscaleAddress(page, daemon.tailscaleAddress);
|
||||
await page.screenshot({ path: testInfo.outputPath("devices.png") });
|
||||
|
||||
await test.step("While its status loads, the row never shows Tailscale off", async () => {
|
||||
const address = daemon.tailscaleAddress;
|
||||
await expectTailscaleRowLoadsOn(page, address, () => preparePairingHost(page, daemon));
|
||||
await expectTailscaleRowLoadsOn(page, address, () => openSetupMobileStep(page, daemon));
|
||||
const restoreSpeed = await slowConnectionToHost(page, daemon.port, 300);
|
||||
await expectTailscaleRowLoadsOn(page, address, () => openSetupMobileStep(page, daemon));
|
||||
await expectTailscaleRowLoadsOn(page, address, () => preparePairingHost(page, daemon));
|
||||
await test.step("Turning Tailscale off and back on settles over a slow connection", async () => {
|
||||
await disableTailscale(page, address);
|
||||
await enableTailscale(page);
|
||||
await expectTailscaleAddress(page, address);
|
||||
});
|
||||
restoreSpeed();
|
||||
});
|
||||
|
||||
await disableTailscale(page, daemon.tailscaleAddress);
|
||||
|
||||
await test.step("Over Tailscale, turning it off asks first and Cancel changes nothing", async () => {
|
||||
await enableTailscale(page);
|
||||
await connectThroughTailscale(page, daemon);
|
||||
await cancelTailscaleTurnOff(page, daemon.tailscaleAddress);
|
||||
});
|
||||
await test.step("Confirming turns it off and cuts this connection", async () => {
|
||||
await confirmTailscaleTurnOff(page, daemon.tailscaleAddress);
|
||||
});
|
||||
} finally {
|
||||
await daemon.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("refreshes Tailscale availability in place after Tailscale starts", async ({
|
||||
page,
|
||||
baseURL,
|
||||
}) => {
|
||||
test.skip(process.platform !== "linux", "Uses a second IPv4 loopback address");
|
||||
test.setTimeout(120_000);
|
||||
if (!baseURL) throw new Error("Expected the app base URL");
|
||||
const daemon = await startTailscaleTestDaemon(baseURL, { initialAvailable: false });
|
||||
const statusPolling = observeDaemonStatusPolling(page, daemon.port);
|
||||
try {
|
||||
await preparePairingHost(page, daemon);
|
||||
await expectTailscaleUnavailable(page);
|
||||
|
||||
await test.step("Refreshing while still unavailable shows progress and stays unavailable", async () => {
|
||||
const restoreSpeed = await slowConnectionToHost(page, daemon.port, 250);
|
||||
await preparePairingHost(page, daemon);
|
||||
await expectTailscaleUnavailable(page);
|
||||
await refreshTailscaleAvailability(page);
|
||||
await page.getByRole("button", { name: "Refreshing...", exact: true }).waitFor();
|
||||
await expectTailscaleUnavailable(page);
|
||||
restoreSpeed();
|
||||
});
|
||||
|
||||
await test.step("Refreshing after Tailscale starts enables the switch in place", async () => {
|
||||
await statusPolling.waitForFreshPollWindow();
|
||||
await daemon.setTailscaleAvailable(true);
|
||||
const refreshRequest = statusPolling.waitForStatusRequest(1_000);
|
||||
await refreshTailscaleAvailability(page);
|
||||
await refreshRequest;
|
||||
await expectTailscaleAvailable(page, { timeout: 1_000 });
|
||||
await enableTailscale(page);
|
||||
await expectTailscaleAddress(page, daemon.tailscaleAddress);
|
||||
await disableTailscale(page, daemon.tailscaleAddress);
|
||||
});
|
||||
|
||||
await test.step("Setup mobile step also refreshes Tailscale availability in place", async () => {
|
||||
await daemon.setTailscaleAvailable(false);
|
||||
await openSetupMobileStep(page, daemon);
|
||||
await expectTailscaleUnavailable(page);
|
||||
await statusPolling.waitForFreshPollWindow();
|
||||
await daemon.setTailscaleAvailable(true);
|
||||
const refreshRequest = statusPolling.waitForStatusRequest(1_000);
|
||||
await refreshTailscaleAvailability(page);
|
||||
await refreshRequest;
|
||||
await expectTailscaleAvailable(page, { timeout: 1_000 });
|
||||
});
|
||||
} finally {
|
||||
await daemon.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ function askAgain(page: Page) {
|
||||
|
||||
async function openFilesSettings(page: Page) {
|
||||
await openSettings(page);
|
||||
await openSettingsSection(page, "files");
|
||||
await openSettingsSection(page, "chat");
|
||||
await expect(page.getByTestId("file-panel-settings")).toBeVisible();
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ test("Settings > Files chooses which panel opens .md and asks again on request",
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto("/settings/files");
|
||||
await expect(markdownDropdown(page, PLUGIN_MARKDOWN_OPTION)).toBeVisible({ timeout: 30_000 });
|
||||
await askAgain(page).scrollIntoViewIfNeeded();
|
||||
await expect(askAgain(page)).toBeInViewport({ ratio: 1 });
|
||||
await capture(page, testInfo, "file-panel-settings-compact");
|
||||
await markdownDropdown(page, PLUGIN_MARKDOWN_OPTION).click();
|
||||
@@ -113,22 +114,20 @@ test("Settings > Files chooses which panel opens .md and asks again on request",
|
||||
}
|
||||
});
|
||||
|
||||
test("Settings > Files explains where file panels come from when no plugin adds one", async ({
|
||||
test("Settings > Chat & panes hides file panels when no plugin adds one", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await page.goto("/settings/files");
|
||||
const empty = page.getByTestId("file-panel-settings-empty");
|
||||
await expect(empty).toHaveText("File panels appear here when a plugin adds one", {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(page).toHaveURL(/\/settings\/chat$/);
|
||||
await expect(page.getByTestId("file-panel-settings")).toHaveCount(0);
|
||||
await capture(page, testInfo, "file-panel-settings-empty-wide");
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await expect(empty).toBeVisible();
|
||||
await expect(page.getByTestId("file-panel-settings")).toHaveCount(0);
|
||||
await capture(page, testInfo, "file-panel-settings-empty-compact");
|
||||
});
|
||||
|
||||
test("Settings > Files offers Source in place of a panel no host has, and forgets it", async ({
|
||||
test("Settings > Chat & panes offers Source in place of a panel no host has, and forgets it", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.addInitScript(() => {
|
||||
@@ -146,5 +145,5 @@ test("Settings > Files offers Source in place of a panel no host has, and forget
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByRole("menuitem", { name: SOURCE_OPTION })).toBeHidden();
|
||||
await row.getByRole("button", { name: "Ask again for .pdf", exact: true }).click();
|
||||
await expect(page.getByTestId("file-panel-settings-empty")).toBeVisible();
|
||||
await expect(page.getByTestId("file-panel-settings")).toHaveCount(0);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { test } from "../support/fixtures";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import { renameHostFromSettings } from "../support/helpers/hosts";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { openHostSection, selectSettingsHost } from "../support/helpers/settings";
|
||||
import { openClientHostSettings } from "../support/helpers/settings";
|
||||
|
||||
const REGISTRY_KEY = "@paseo:daemon-registry";
|
||||
const SEED_NONCE_KEY = "@paseo:e2e-seed-nonce";
|
||||
@@ -87,8 +87,7 @@ test("saved hosts survive a registry entry this build can't read, and saving kee
|
||||
|
||||
await test.step("renaming a host keeps its password and the entries it can't read", async () => {
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, OFFLINE_HOST.serverId);
|
||||
await openHostSection(page, OFFLINE_HOST.serverId, "host");
|
||||
await openClientHostSettings(page, OFFLINE_HOST.serverId);
|
||||
await renameHostFromSettings(page, "Renamed offline host");
|
||||
|
||||
await expect
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
expectProviderNotOnHost,
|
||||
expectProviderPageLoaded,
|
||||
gotoProviderPage,
|
||||
openClientHostSettings,
|
||||
openSettingsHost,
|
||||
openHostSection,
|
||||
expectHostLabelDisplayed,
|
||||
@@ -53,36 +54,30 @@ test.describe("Settings host page", () => {
|
||||
const port = getE2EDaemonPort();
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, serverId);
|
||||
await test.step("connections section shows the seeded connection endpoint", async () => {
|
||||
await expectSettingsHeader(page, "Connections");
|
||||
await test.step("client host detail shows the seeded connection endpoint and label editor", async () => {
|
||||
await openClientHostSettings(page, serverId);
|
||||
await expectHostConnectionsCard(page, port);
|
||||
await expectHostLabelDisplayed(page);
|
||||
await clickEditHostLabel(page);
|
||||
await expectHostLabelEditMode(page, TEST_HOST_LABEL);
|
||||
await page.keyboard.press("Escape");
|
||||
});
|
||||
await test.step("agents section shows the inject MCP toggle", async () => {
|
||||
await openHostSection(page, serverId, "agents");
|
||||
await expectSettingsHeader(page, "Agents");
|
||||
await test.step("tools section shows the inject MCP toggle", async () => {
|
||||
await openHostSection(page, serverId, "tools");
|
||||
await expectSettingsHeader(page, "Tools & prompts");
|
||||
await expectHostInjectMcpCard(page);
|
||||
});
|
||||
await test.step("providers section shows the providers card", async () => {
|
||||
await expectHostProvidersCard(page, serverId);
|
||||
await expectSettingsHeader(page, "Providers");
|
||||
});
|
||||
await test.step("host section shows the host label and restart/remove action cards", async () => {
|
||||
await openHostSection(page, serverId, "host");
|
||||
await expectSettingsHeader(page, "Overview");
|
||||
await expectHostLabelDisplayed(page);
|
||||
await test.step("daemon section shows restart and client host shows remove", async () => {
|
||||
await openHostSection(page, serverId, "daemon");
|
||||
await expectSettingsHeader(page, "Daemon");
|
||||
await expectHostActionCards(page, serverId);
|
||||
});
|
||||
await test.step("clicking the label pencil reveals the inline editor", async () => {
|
||||
await openHostSection(page, serverId, "host");
|
||||
|
||||
await expectHostLabelDisplayed(page);
|
||||
await clickEditHostLabel(page);
|
||||
await expectHostLabelEditMode(page, TEST_HOST_LABEL);
|
||||
await page.keyboard.press("Escape");
|
||||
});
|
||||
await test.step("host section does not render daemon lifecycle controls for a remote daemon", async () => {
|
||||
await openHostSection(page, serverId, "host");
|
||||
await test.step("daemon section does not render daemon lifecycle controls for a remote daemon", async () => {
|
||||
await openHostSection(page, serverId, "daemon");
|
||||
|
||||
await expectHostNoDaemonLifecycleRow(page);
|
||||
});
|
||||
@@ -99,7 +94,7 @@ test.describe("Settings host page", () => {
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, outdatedDaemon.serverId);
|
||||
await openHostSection(page, outdatedDaemon.serverId, "host");
|
||||
await openHostSection(page, outdatedDaemon.serverId, "daemon");
|
||||
|
||||
page.once("dialog", (dialog) => dialog.accept());
|
||||
const updateButton = page.getByTestId("host-page-update-button");
|
||||
@@ -138,8 +133,7 @@ test.describe("Settings host page", () => {
|
||||
]);
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, daemon.serverId);
|
||||
await openHostSection(page, daemon.serverId, "host");
|
||||
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");
|
||||
@@ -149,7 +143,7 @@ test.describe("Settings host page", () => {
|
||||
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 openHostSection(page, daemon.serverId, "host");
|
||||
await openHostSection(page, daemon.serverId, "daemon");
|
||||
await expectHostOnlineWithoutError(page);
|
||||
});
|
||||
} finally {
|
||||
@@ -192,7 +186,7 @@ test.describe("Settings host page", () => {
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, serverId);
|
||||
await openHostSection(page, serverId, "agents");
|
||||
await openHostSection(page, serverId, "daemon");
|
||||
};
|
||||
try {
|
||||
await test.step("idle agent release starts on and turns off", async () => {
|
||||
@@ -213,7 +207,7 @@ test.describe("Settings host page", () => {
|
||||
|
||||
await test.step("other hosts keep their own setting", async () => {
|
||||
await selectSettingsHost(page, primaryServerId);
|
||||
await openHostSection(page, primaryServerId, "agents");
|
||||
await openHostSection(page, primaryServerId, "daemon");
|
||||
await expectIdleAgentRelease(page, true);
|
||||
await expectLiveSavedSetting(false);
|
||||
});
|
||||
@@ -232,7 +226,7 @@ test.describe("Settings host page", () => {
|
||||
]);
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await openHostSection(page, daemon.serverId, "agents");
|
||||
await openHostSection(page, daemon.serverId, "daemon");
|
||||
await expectIdleAgentRelease(page, true);
|
||||
// A real filesystem failure, with the daemon and RPC path intact.
|
||||
await rename(configPath, `${configPath}.saved`);
|
||||
@@ -251,7 +245,7 @@ test.describe("Settings host page", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("navigating to /settings/hosts/[serverId] redirects to the connections section", async ({
|
||||
test("navigating to /settings/hosts/[serverId] redirects to the daemon section", async ({
|
||||
page,
|
||||
}) => {
|
||||
const serverId = getServerId();
|
||||
@@ -260,10 +254,9 @@ test.describe("Settings host page", () => {
|
||||
await page.goto(`/settings/hosts/${encodeURIComponent(serverId)}`);
|
||||
|
||||
await expectHostPageVisible(page, serverId);
|
||||
await expectSettingsHeader(page, "Connections");
|
||||
await openHostSection(page, serverId, "host");
|
||||
await expectHostLabelDisplayed(page);
|
||||
await expectSettingsHeader(page, "Daemon");
|
||||
await expectHostActionCards(page, serverId);
|
||||
await expectHostLabelDisplayed(page);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -286,7 +279,7 @@ test("restart recovery defaults off and persists opt-in and custom prompt", asyn
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, serverId);
|
||||
await openHostSection(page, serverId, "agents");
|
||||
await openHostSection(page, serverId, "daemon");
|
||||
await expectRestartRecoveryEnabled(page, false);
|
||||
await setRestartRecoveryEnabled(page, true);
|
||||
await page.reload();
|
||||
@@ -354,12 +347,12 @@ test("sidebar Add host completes without navigating", async ({ page }) => {
|
||||
await expect(page.getByRole("button", { name: "Hosts", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Settings Add host opens the saved host Overview", async ({ page }) => {
|
||||
test("Settings Add host opens the saved host detail", async ({ page }) => {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await addDirectHostFromSettings(page, { host: "127.0.0.1", port: Number(getE2EDaemonPort()) });
|
||||
await expectSettingsHeader(page, "Overview");
|
||||
await expect(page).toHaveURL(new RegExp(`/settings/hosts/${getServerId()}/host$`));
|
||||
await expect(page.getByTestId("host-page-connections-card")).toBeVisible();
|
||||
await expect(page).toHaveURL(new RegExp(`/settings/device-hosts/${getServerId()}$`));
|
||||
});
|
||||
|
||||
test("New workspace Add host preserves the prompt after connecting", async ({ page }) => {
|
||||
|
||||
@@ -46,15 +46,15 @@ test.describe("Settings host selection", () => {
|
||||
|
||||
await openSettings(page);
|
||||
|
||||
await openSettingsHostSection(page, remoteDaemon.serverId, "connections");
|
||||
await openSettingsHostSection(page, remoteDaemon.serverId, "daemon");
|
||||
|
||||
await selectSettingsHost(page, getServerId());
|
||||
await openSettingsSection(page, "appearance");
|
||||
await openSettingsHostSection(page, getServerId(), "connections");
|
||||
await openSettingsHostSection(page, getServerId(), "daemon");
|
||||
|
||||
await clickSettingsBackToWorkspace(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHostSection(page, remoteDaemon.serverId, "connections");
|
||||
await openSettingsHostSection(page, remoteDaemon.serverId, "daemon");
|
||||
} finally {
|
||||
await remoteWorkspace.cleanup().catch(() => undefined);
|
||||
await remoteDaemon.close().catch(() => undefined);
|
||||
|
||||
@@ -9,17 +9,17 @@ test("Settings language selector switches General labels", async ({ page }) => {
|
||||
await openSettings(page);
|
||||
await openSettingsSection(page, "general");
|
||||
|
||||
await expect(page.getByText("Default send", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("Language", { exact: true }).first()).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "System", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "简体中文 - Simplified Chinese", exact: true }).click();
|
||||
|
||||
await expect(page.getByText("默认发送", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("语言", { exact: true }).first()).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "简体中文", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "English - 英语", exact: true }).click();
|
||||
|
||||
await expect(page.getByText("Default send", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("Language", { exact: true }).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("Settings language selector switches to Korean", async ({ page }) => {
|
||||
@@ -32,10 +32,10 @@ test("Settings language selector switches to Korean", async ({ page }) => {
|
||||
await page.getByRole("button", { name: "System", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "한국어 - Korean", exact: true }).click();
|
||||
|
||||
await expect(page.getByText("기본 전송", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("언어", { exact: true }).first()).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "한국어", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "English - 영어", exact: true }).click();
|
||||
|
||||
await expect(page.getByText("Default send", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("Language", { exact: true }).first()).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -62,6 +62,7 @@ import {
|
||||
seedSavedSettingsHosts,
|
||||
selectSettingsHost,
|
||||
expectSettingsHostPickerLabel,
|
||||
openClientHostSettings,
|
||||
openSettingsHostSection,
|
||||
removeCurrentHostFromSettings,
|
||||
openSidebarHostPicker,
|
||||
@@ -176,28 +177,28 @@ test.describe("Settings sidebar scroll position", () => {
|
||||
}
|
||||
|
||||
const sidebar = page.getByTestId("settings-sidebar");
|
||||
const appScrollTop = await revealSettingsSidebarSection(page, "diagnostics");
|
||||
const appScrollTop = await revealSettingsSidebarSection(page, "about");
|
||||
await expect(sidebar.getByRole("button", { name: "About", exact: true })).toBeInViewport();
|
||||
|
||||
await openSettingsSection(page, "about");
|
||||
await expectAboutContent(page);
|
||||
await expectDiagnosticsContent(page);
|
||||
await expectSettingsSidebarScrollOffset(page, appScrollTop);
|
||||
|
||||
await openSettingsSection(page, "diagnostics");
|
||||
await expectDiagnosticsContent(page);
|
||||
await openSettingsSection(page, "shortcuts");
|
||||
await expectSettingsSidebarScrollOffset(page, appScrollTop);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Settings sidebar navigation", () => {
|
||||
test("the sidebar host row opens Overview in one click", async ({ page, withWorkspace }) => {
|
||||
test("the sidebar host row opens Daemon in one click", async ({ page, withWorkspace }) => {
|
||||
const workspace = await withWorkspace({ prefix: "sidebar-host-settings-" });
|
||||
await openWorkspace(page, workspace);
|
||||
await openSidebarHostPicker(page);
|
||||
await sidebarHostRowButton(page).click();
|
||||
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "host"));
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "daemon"));
|
||||
});
|
||||
|
||||
test("Enter opens the active sidebar host row", async ({ page, withWorkspace }) => {
|
||||
@@ -207,7 +208,7 @@ test.describe("Settings sidebar navigation", () => {
|
||||
await openSidebarHostPicker(page);
|
||||
await activateSidebarHostSettingsWithKeyboard(page);
|
||||
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "host"));
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "daemon"));
|
||||
});
|
||||
|
||||
test("opening Settings closes the composer model selector until it is opened again", async ({
|
||||
@@ -282,13 +283,10 @@ test.describe("Settings sidebar navigation", () => {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
|
||||
await openSettingsSection(page, "diagnostics");
|
||||
await expectSettingsHeader(page, "Diagnostics");
|
||||
await expectDiagnosticsContent(page);
|
||||
|
||||
await openSettingsSection(page, "about");
|
||||
await expectSettingsHeader(page, "About");
|
||||
await expectAboutContent(page);
|
||||
await expectDiagnosticsContent(page);
|
||||
|
||||
await openSettingsSection(page, "general");
|
||||
await expectSettingsHeader(page, "General");
|
||||
@@ -313,18 +311,18 @@ test.describe("Settings sidebar navigation", () => {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, secondaryServerId);
|
||||
await openSettingsHostSection(page, secondaryServerId, "connections");
|
||||
await openSettingsHostSection(page, secondaryServerId, "daemon");
|
||||
await openSettingsSection(page, "appearance");
|
||||
await expectSettingsHostPickerLabel(page, "Stable horse");
|
||||
await openSettingsSection(page, "general");
|
||||
await expectSettingsHostPickerLabel(page, "Stable horse");
|
||||
await openSettingsHostSection(page, secondaryServerId, "connections");
|
||||
await openSettingsHostSection(page, secondaryServerId, "daemon");
|
||||
await selectSettingsHost(page, primaryServerId);
|
||||
await openSettingsSection(page, "about");
|
||||
await expectSettingsHostPickerLabel(page, "First horse");
|
||||
});
|
||||
|
||||
test("/h/[serverId]/settings redirects to the host connections section", async ({ page }) => {
|
||||
test("/h/[serverId]/settings redirects to the host daemon section", async ({ page }) => {
|
||||
await gotoAppShell(page);
|
||||
await verifyLegacyHostSettingsRedirect(page);
|
||||
});
|
||||
@@ -528,12 +526,12 @@ test.describe("Settings — compact master-detail", () => {
|
||||
await gotoAppShell(page);
|
||||
await openCompactSettings(page, buildOpenProjectRoute());
|
||||
|
||||
await expectSettingsSidebarSections(page, ["general", "diagnostics", "about"]);
|
||||
await expectSettingsSidebarSections(page, ["general", "hosts", "about"]);
|
||||
await expectCompactSettingsList(page);
|
||||
|
||||
await test.step("open app details and return to the list", async () => {
|
||||
await openSettingsSection(page, "diagnostics");
|
||||
await expectAppRoute(page, buildSettingsSectionRoute("diagnostics"));
|
||||
await openSettingsSection(page, "about");
|
||||
await expectAppRoute(page, buildSettingsSectionRoute("about"));
|
||||
await expectDiagnosticsContent(page);
|
||||
await expectSettingsSidebarHidden(page);
|
||||
await expectSettingsBackButton(page);
|
||||
@@ -554,7 +552,7 @@ test.describe("Settings — compact master-detail", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("host picker settings opens Overview and backs through the settings list", async ({
|
||||
test("host picker settings opens Daemon and backs through the settings list", async ({
|
||||
page,
|
||||
withWorkspace,
|
||||
}) => {
|
||||
@@ -566,8 +564,8 @@ test.describe("Settings — compact master-detail", () => {
|
||||
await page.getByTestId("sidebar-hosts-trigger").click();
|
||||
await sidebarHostRowButton(page).click();
|
||||
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "host"));
|
||||
await expect(page.getByText("Overview", { exact: true })).toBeVisible();
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(getServerId(), "daemon"));
|
||||
await expect(page.getByText("Daemon", { exact: true }).first()).toBeVisible();
|
||||
|
||||
await goBackInSettings(page);
|
||||
await expectCompactSettingsList(page);
|
||||
@@ -597,14 +595,14 @@ test.describe("Settings — compact master-detail", () => {
|
||||
await expectSettingsSidebarVisible(page);
|
||||
await expectSettingsHostPickerLabel(page, secondaryHostLabel);
|
||||
|
||||
await openSettingsHostSection(page, secondaryServerId, "connections");
|
||||
await openSettingsHostSection(page, secondaryServerId, "daemon");
|
||||
await goBackInSettings(page);
|
||||
await expectSettingsHostPickerLabel(page, secondaryHostLabel);
|
||||
|
||||
await openSettingsSection(page, "appearance");
|
||||
await goBackInSettings(page);
|
||||
await expectSettingsHostPickerLabel(page, secondaryHostLabel);
|
||||
await openSettingsHostSection(page, secondaryServerId, "connections");
|
||||
await openSettingsHostSection(page, secondaryServerId, "daemon");
|
||||
await goBackInSettings(page);
|
||||
await expectSettingsHostPickerLabel(page, secondaryHostLabel);
|
||||
});
|
||||
@@ -617,8 +615,9 @@ test.describe("Settings — compact master-detail", () => {
|
||||
|
||||
await openWorkspace(page, workspace);
|
||||
await openCompactSettings(page, buildHostWorkspaceRoute(getServerId(), workspace.workspaceId));
|
||||
await openSettingsHostSection(page, getServerId(), "host");
|
||||
await openClientHostSettings(page, getServerId());
|
||||
await removeCurrentHostFromSettings(page);
|
||||
await goBackInSettings(page);
|
||||
await closeCompactSettings(page);
|
||||
|
||||
await expect(page).toHaveURL(/\/welcome$/);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createMockIdleAgent, openWorkspaceWithAgents } from "../support/helpers
|
||||
import { waitForTabBar, expectAgentTabActive } from "../support/helpers/launcher";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { openSettingsSection } from "../support/helpers/settings";
|
||||
|
||||
async function pressSettingsToggleShortcut(page: import("@playwright/test").Page) {
|
||||
const modifier = process.platform === "darwin" ? "Meta" : "Control";
|
||||
@@ -134,6 +135,7 @@ test.describe("Settings toggle tab regression", () => {
|
||||
|
||||
await pressSettingsToggleShortcut(page);
|
||||
await expect(page).toHaveURL(/\/settings\/general$/);
|
||||
await openSettingsSection(page, "chat");
|
||||
|
||||
const defaultSendTrigger = page.getByRole("button", {
|
||||
name: "Default send: Steer",
|
||||
@@ -324,6 +326,7 @@ test("send shortcut selection persists and controls the composer", async ({ page
|
||||
});
|
||||
await test.step("choose the explicit modifier shortcut and retain it after reload", async () => {
|
||||
await pressSettingsToggleShortcut(page);
|
||||
await openSettingsSection(page, "chat");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Send shortcut: Enter", exact: true }),
|
||||
).toBeVisible();
|
||||
@@ -351,6 +354,7 @@ test("send shortcut selection persists and controls the composer", async ({ page
|
||||
});
|
||||
await test.step("switch back to Enter without changing the default send behavior", async () => {
|
||||
await pressSettingsToggleShortcut(page);
|
||||
await openSettingsSection(page, "chat");
|
||||
await selectSendingOption(page, "Send shortcut", "Enter");
|
||||
await pressSettingsToggleShortcut(page);
|
||||
await composer.fill("Shift still edits");
|
||||
@@ -375,6 +379,7 @@ for (const behavior of ["Steer", "Interrupt", "Queue"] as const) {
|
||||
await openAgentRoute(page, agent);
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeVisible();
|
||||
await pressSettingsToggleShortcut(page);
|
||||
await openSettingsSection(page, "chat");
|
||||
await selectSendingOption(page, "Send shortcut", `${modifierLabel}+Enter`);
|
||||
await selectSendingOption(page, "Default send", behavior);
|
||||
await pressSettingsToggleShortcut(page);
|
||||
|
||||
@@ -175,7 +175,7 @@ test("searches keyboard shortcuts from the sidebar help menu", async ({ page })
|
||||
test("keeps diagnostics available from Settings after globalizing the sheet", async ({ page }) => {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsSection(page, "diagnostics");
|
||||
await openSettingsSection(page, "about");
|
||||
|
||||
await page.getByRole("button", { name: "Run", exact: true }).click();
|
||||
await expectDiagnosticReport(page);
|
||||
|
||||
@@ -210,14 +210,14 @@ async function simulateDamagedLegacyDirectoryCache(
|
||||
return;
|
||||
}
|
||||
const stored = JSON.parse(checkpoint.payload);
|
||||
// Read the cursors from whichever version wrote them, then store them as version 1:
|
||||
// the format whose writer could keep a checkpoint after evicting the rows it describes.
|
||||
// Read the cursors from whichever version wrote them, then store them as version 2:
|
||||
// the format whose writer could keep a checkpoint after another tab evicted its rows.
|
||||
const cursors = typeof stored.version === "number" ? stored.cursors : stored;
|
||||
if (!cursors?.workspaces?.generation) {
|
||||
transaction.abort();
|
||||
return;
|
||||
}
|
||||
store.put({ ...checkpoint, payload: JSON.stringify({ version: 1, cursors }) });
|
||||
store.put({ ...checkpoint, payload: JSON.stringify({ version: 2, cursors }) });
|
||||
for (const row of rows) {
|
||||
if (
|
||||
row.serverId === serverId &&
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import {
|
||||
archiveLocalWorkspaceFromDaemon,
|
||||
archiveWorkspaceFromDaemon,
|
||||
connectNewWorkspaceDaemonClient,
|
||||
createWorktreeViaDaemon,
|
||||
@@ -9,7 +10,12 @@ import {
|
||||
} from "../support/helpers/new-workspace";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { expectWorkspaceAbsentFromSidebar } from "../support/helpers/sidebar";
|
||||
import { createMockIdleAgent, openWorkspaceWithAgents } from "../support/helpers/archive-tab";
|
||||
import {
|
||||
createMockIdleAgent,
|
||||
fetchAgentArchivedAt,
|
||||
openSessions,
|
||||
openWorkspaceWithAgents,
|
||||
} from "../support/helpers/archive-tab";
|
||||
import { connectSeedClient } from "../support/helpers/seed-client";
|
||||
import { createTempGitRepo } from "../support/helpers/workspace";
|
||||
import { getWorkspaceTabTestIds } from "../support/helpers/workspace-tabs";
|
||||
@@ -38,6 +44,61 @@ import {
|
||||
waitForWorkspaceInSidebar,
|
||||
} from "../support/helpers/workspace-ui";
|
||||
|
||||
async function clearIndexedDbDatabases(page: Page): Promise<void> {
|
||||
await page.evaluate(async () => {
|
||||
const dbs = (await indexedDB.databases?.()) ?? [];
|
||||
for (const db of dbs) {
|
||||
if (!db.name) continue;
|
||||
await new Promise<void>((resolve) => {
|
||||
const req = indexedDB.deleteDatabase(db.name!);
|
||||
const done = () => resolve();
|
||||
req.addEventListener("success", done, { once: true });
|
||||
req.addEventListener("error", done, { once: true });
|
||||
req.addEventListener("blocked", done, { once: true });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function delayRefreshAgentRequests(page: Page, delayMs: number): Promise<void> {
|
||||
await page.routeWebSocket(/\/ws/, (ws) => {
|
||||
const server = ws.connectToServer();
|
||||
ws.onMessage((message) => {
|
||||
if (typeof message === "string" && isRefreshAgentRequestMessage(message)) {
|
||||
setTimeout(() => {
|
||||
server.send(message);
|
||||
}, delayMs);
|
||||
return;
|
||||
}
|
||||
server.send(message);
|
||||
});
|
||||
server.onMessage((message) => {
|
||||
ws.send(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function isRefreshAgentRequestMessage(message: string): boolean {
|
||||
try {
|
||||
const parsed = JSON.parse(message) as { type?: string; message?: { type?: string } };
|
||||
return (
|
||||
parsed.type === "refresh_agent_request" || parsed.message?.type === "refresh_agent_request"
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function isSidebarFooterHitTestable(page: Page): Promise<boolean> {
|
||||
return page.evaluate(() => {
|
||||
const footer = document.querySelector('[data-testid="sidebar-footer"]');
|
||||
if (!(footer instanceof HTMLElement)) return false;
|
||||
const rect = footer.getBoundingClientRect();
|
||||
const topEl = document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
||||
return Boolean(topEl && footer.contains(topEl));
|
||||
});
|
||||
}
|
||||
|
||||
test.describe("Workspace archive undo", () => {
|
||||
let client: Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
|
||||
let tempRepo: { path: string; cleanup: () => Promise<void> };
|
||||
@@ -296,6 +357,12 @@ test.describe("Workspace archive undo", () => {
|
||||
await createMockIdleAgent(seedClient, { ...target, title: "first" }),
|
||||
await createMockIdleAgent(seedClient, { ...target, title: "second" }),
|
||||
] as const;
|
||||
const preArchivedAgent = await createMockIdleAgent(seedClient, {
|
||||
...target,
|
||||
title: "pre-archived",
|
||||
});
|
||||
await seedClient.archiveAgent(preArchivedAgent.id);
|
||||
await expect.poll(() => fetchAgentArchivedAt(seedClient, preArchivedAgent.id)).not.toBeNull();
|
||||
await openWorkspaceWithAgents(page, [agents[0], agents[1]]);
|
||||
const tabsBefore = await getWorkspaceTabTestIds(page);
|
||||
|
||||
@@ -308,9 +375,66 @@ test.describe("Workspace archive undo", () => {
|
||||
for (const agent of agents) {
|
||||
await expect(page.getByTestId(`workspace-tab-agent_${agent.id}`).first()).toBeVisible();
|
||||
}
|
||||
await expect(
|
||||
page.getByTestId("agent-unarchiving-callout").filter({ visible: true }),
|
||||
).toHaveCount(1);
|
||||
await expect(page.getByRole("button", { name: "Unarchive", exact: true })).toHaveCount(0);
|
||||
|
||||
// Opening an agent that was already archived before the workspace archive still shows
|
||||
// the manual Unarchive callout rather than claiming it is unarchiving with the workspace.
|
||||
await openSessions(page);
|
||||
await page.getByTestId(`agent-row-${getServerId()}-${preArchivedAgent.id}`).click();
|
||||
await expect(page.getByTestId("agent-archived-callout")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Unarchive", exact: true })).toBeVisible();
|
||||
await expect(
|
||||
page.getByTestId("agent-unarchiving-callout").filter({ visible: true }),
|
||||
).toHaveCount(0);
|
||||
|
||||
await page.getByTestId(`workspace-tab-agent_${agents[0].id}`).first().click();
|
||||
await expect(
|
||||
page.getByTestId("agent-unarchiving-callout").filter({ visible: true }),
|
||||
).toHaveCount(1);
|
||||
|
||||
await page.evaluate(() => {
|
||||
const win = window as unknown as Record<string, unknown>;
|
||||
let sawAgentLoading = false;
|
||||
let running = true;
|
||||
const isVisible = (el: Element | null) => {
|
||||
if (!el || !(el instanceof HTMLElement)) return false;
|
||||
const rect = el.getBoundingClientRect();
|
||||
if (rect.width === 0 || rect.height === 0) return false;
|
||||
const style = getComputedStyle(el);
|
||||
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
||||
};
|
||||
const tick = () => {
|
||||
if (!running) return;
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-loading"]')).some(isVisible)
|
||||
) {
|
||||
sawAgentLoading = true;
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
win.__stopMidUndoLoadingCheck = () => {
|
||||
running = false;
|
||||
return sawAgentLoading;
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
|
||||
teardown.release();
|
||||
await expectHostWorkspaceSettledActive(client, worktree.workspaceId);
|
||||
await expect.poll(() => getWorkspaceTabTestIds(page)).toEqual(tabsBefore);
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeEditable({
|
||||
timeout: 30_000,
|
||||
});
|
||||
const sawMidUndoLoading = await page.evaluate(() => {
|
||||
const win = window as unknown as { __stopMidUndoLoadingCheck?: () => boolean };
|
||||
return win.__stopMidUndoLoadingCheck?.();
|
||||
});
|
||||
expect(sawMidUndoLoading).toBe(false);
|
||||
await expect
|
||||
.poll(() => getWorkspaceTabTestIds(page))
|
||||
.toEqual([...tabsBefore, `workspace-tab-agent_${preArchivedAgent.id}`]);
|
||||
} finally {
|
||||
teardown.release();
|
||||
await seedClient.close().catch(() => undefined);
|
||||
@@ -357,4 +481,318 @@ test.describe("Workspace archive undo", () => {
|
||||
await expect(undoButton(page)).toHaveCount(0);
|
||||
await expect(workspaceRow(page, worktree.workspaceId)).toBeVisible();
|
||||
});
|
||||
|
||||
test("unarchiving a workspace with archived agents skips archived-callout and loading flashes", async ({
|
||||
page,
|
||||
}) => {
|
||||
const seedClient = await connectSeedClient();
|
||||
const project = await openProjectViaDaemon(client, tempRepo.path);
|
||||
try {
|
||||
const agent1 = await createMockIdleAgent(seedClient, {
|
||||
cwd: project.workspaceDirectory,
|
||||
workspaceId: project.workspaceId,
|
||||
title: "Atomic restore agent 1",
|
||||
});
|
||||
const agent2 = await createMockIdleAgent(seedClient, {
|
||||
cwd: project.workspaceDirectory,
|
||||
workspaceId: project.workspaceId,
|
||||
title: "Atomic restore agent 2",
|
||||
});
|
||||
// Seed 25 turns so the archived conversation spans multiple timeline pages (hasOlder=true).
|
||||
for (let i = 0; i < 25; i += 1) {
|
||||
await seedClient.sendAgentMessage(
|
||||
agent1.id,
|
||||
`atomic-restore-turn-${i}: emit 1 coalesced agent stream updates`,
|
||||
);
|
||||
await seedClient.waitForFinish(agent1.id, 15_000);
|
||||
}
|
||||
|
||||
await archiveLocalWorkspaceFromDaemon(client, project.workspaceId);
|
||||
await expect.poll(() => fetchAgentArchivedAt(seedClient, agent1.id)).not.toBeNull();
|
||||
await expect.poll(() => fetchAgentArchivedAt(seedClient, agent2.id)).not.toBeNull();
|
||||
|
||||
await gotoAppShell(page);
|
||||
// Clear persisted replica IndexedDB so this tests a true cold restore.
|
||||
await clearIndexedDbDatabases(page);
|
||||
await page.reload();
|
||||
await waitForSidebarHydration(page);
|
||||
await openSessions(page);
|
||||
await page.getByTestId(`agent-row-${getServerId()}-${agent1.id}`).click();
|
||||
await expect(page.getByTestId("workspace-recovery-action")).toHaveText("Unarchive", {
|
||||
timeout: 30_000,
|
||||
});
|
||||
|
||||
// Verify the compact left sidebar overlays the recovery gate rather than painting behind it.
|
||||
const desktopViewport = page.viewportSize() ?? { width: 1280, height: 720 };
|
||||
await page.setViewportSize({ width: 390, height: 720 });
|
||||
await page.getByRole("button", { name: "Open menu", exact: true }).first().click();
|
||||
const sidebarFooter = page.getByTestId("sidebar-footer").first();
|
||||
await expect(sidebarFooter).toBeVisible();
|
||||
await expect.poll(() => isSidebarFooterHitTestable(page)).toBe(true);
|
||||
await page.setViewportSize(desktopViewport);
|
||||
await expect(page.getByTestId("workspace-recovery-action")).toBeVisible();
|
||||
|
||||
await page.evaluate(() => {
|
||||
const win = window as unknown as Record<string, unknown>;
|
||||
const recoveryButton = document.querySelector('[data-testid="workspace-recovery-action"]');
|
||||
const seen = {
|
||||
archivedCallout: false,
|
||||
agentLoading: false,
|
||||
agentInitialFill: false,
|
||||
updatingToast: false,
|
||||
recoveryButtonRemounted: false,
|
||||
firstRevealedTabsCount: -1,
|
||||
firstRevealedRowCount: -1,
|
||||
firstRevealedStreamOpacity: -1,
|
||||
firstRevealedDistanceFromBottom: -1,
|
||||
};
|
||||
let running = true;
|
||||
const isVisible = (el: Element | null) => {
|
||||
if (!el || !(el instanceof HTMLElement)) return false;
|
||||
const rect = el.getBoundingClientRect();
|
||||
if (rect.width === 0 || rect.height === 0) return false;
|
||||
const style = getComputedStyle(el);
|
||||
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
||||
};
|
||||
const tick = () => {
|
||||
if (!running) return;
|
||||
const currentRecoveryButton = document.querySelector(
|
||||
'[data-testid="workspace-recovery-action"]',
|
||||
);
|
||||
if (currentRecoveryButton && recoveryButton && currentRecoveryButton !== recoveryButton) {
|
||||
seen.recoveryButtonRemounted = true;
|
||||
}
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-archived-callout"]')).some(
|
||||
isVisible,
|
||||
)
|
||||
) {
|
||||
seen.archivedCallout = true;
|
||||
}
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-loading"]')).some(isVisible)
|
||||
) {
|
||||
seen.agentLoading = true;
|
||||
}
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-initial-fill"]')).some(
|
||||
isVisible,
|
||||
)
|
||||
) {
|
||||
seen.agentInitialFill = true;
|
||||
}
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-updating-toast"]')).some(
|
||||
isVisible,
|
||||
)
|
||||
) {
|
||||
seen.updatingToast = true;
|
||||
}
|
||||
const composerVisible = Array.from(
|
||||
document.querySelectorAll(
|
||||
'textarea[aria-label="Message agent..."], [role="textbox"][aria-label="Message agent..."]',
|
||||
),
|
||||
).some(isVisible);
|
||||
if (seen.firstRevealedTabsCount === -1 && composerVisible) {
|
||||
seen.firstRevealedTabsCount = Array.from(
|
||||
document.querySelectorAll('[data-testid^="workspace-tab-"]'),
|
||||
).filter(isVisible).length;
|
||||
const stream =
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-chat-scroll"]')).find(
|
||||
isVisible,
|
||||
) ?? null;
|
||||
if (stream instanceof HTMLElement) {
|
||||
seen.firstRevealedRowCount = stream.querySelectorAll("[data-history-row-id]").length;
|
||||
seen.firstRevealedStreamOpacity = Number.parseFloat(
|
||||
getComputedStyle(stream).opacity || "1",
|
||||
);
|
||||
seen.firstRevealedDistanceFromBottom = Math.max(
|
||||
0,
|
||||
Math.round(stream.scrollHeight - stream.scrollTop - stream.clientHeight),
|
||||
);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
win.__stopUnarchiveFlashCheck = () => {
|
||||
running = false;
|
||||
return seen;
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
|
||||
await page.getByTestId("workspace-recovery-action").click();
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeEditable({
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(
|
||||
page.getByText("atomic-restore-turn-24", { exact: false }).first(),
|
||||
).toBeVisible();
|
||||
const seen = await page.evaluate(() => {
|
||||
const win = window as unknown as {
|
||||
__stopUnarchiveFlashCheck?: () => {
|
||||
archivedCallout: boolean;
|
||||
agentLoading: boolean;
|
||||
agentInitialFill: boolean;
|
||||
updatingToast: boolean;
|
||||
recoveryButtonRemounted: boolean;
|
||||
firstRevealedTabsCount: number;
|
||||
firstRevealedRowCount: number;
|
||||
firstRevealedStreamOpacity: number;
|
||||
firstRevealedDistanceFromBottom: number;
|
||||
};
|
||||
};
|
||||
return win.__stopUnarchiveFlashCheck?.();
|
||||
});
|
||||
expect(seen).toBeDefined();
|
||||
expect({
|
||||
archivedCallout: seen?.archivedCallout,
|
||||
agentLoading: seen?.agentLoading,
|
||||
agentInitialFill: seen?.agentInitialFill,
|
||||
updatingToast: seen?.updatingToast,
|
||||
recoveryButtonRemounted: seen?.recoveryButtonRemounted,
|
||||
firstRevealedTabsCount: seen?.firstRevealedTabsCount,
|
||||
firstRevealedStreamOpacity: seen?.firstRevealedStreamOpacity,
|
||||
}).toEqual({
|
||||
archivedCallout: false,
|
||||
agentLoading: false,
|
||||
agentInitialFill: false,
|
||||
updatingToast: false,
|
||||
recoveryButtonRemounted: false,
|
||||
firstRevealedTabsCount: 2,
|
||||
firstRevealedStreamOpacity: 1,
|
||||
});
|
||||
expect(seen!.firstRevealedRowCount).toBeGreaterThan(0);
|
||||
expect(seen!.firstRevealedDistanceFromBottom).toBeLessThanOrEqual(16);
|
||||
} finally {
|
||||
await client.removeProject(project.projectKey).catch(() => undefined);
|
||||
await seedClient.close().catch(() => undefined);
|
||||
}
|
||||
});
|
||||
|
||||
test("unarchiving a single archived agent keeps the chat mounted without a loading flash", async ({
|
||||
page,
|
||||
}) => {
|
||||
const seedClient = await connectSeedClient();
|
||||
const project = await openProjectViaDaemon(client, tempRepo.path);
|
||||
try {
|
||||
const agent1 = await createMockIdleAgent(seedClient, {
|
||||
cwd: project.workspaceDirectory,
|
||||
workspaceId: project.workspaceId,
|
||||
title: "Single unarchive agent",
|
||||
});
|
||||
await createMockIdleAgent(seedClient, {
|
||||
cwd: project.workspaceDirectory,
|
||||
workspaceId: project.workspaceId,
|
||||
title: "Sibling active agent",
|
||||
});
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
await seedClient.sendAgentMessage(
|
||||
agent1.id,
|
||||
`single-unarchive-turn-${i}: emit 1 coalesced agent stream updates`,
|
||||
);
|
||||
await seedClient.waitForFinish(agent1.id, 15_000);
|
||||
}
|
||||
await seedClient.archiveAgent(agent1.id);
|
||||
await expect.poll(() => fetchAgentArchivedAt(seedClient, agent1.id)).not.toBeNull();
|
||||
|
||||
// Delay `refresh_agent_request` briefly so the UI renders its busy state on the Unarchive button.
|
||||
await delayRefreshAgentRequests(page, 250);
|
||||
|
||||
await gotoAppShell(page);
|
||||
await waitForSidebarHydration(page);
|
||||
await openSessions(page);
|
||||
await page.getByTestId(`agent-row-${getServerId()}-${agent1.id}`).click();
|
||||
const unarchiveBtn = page.getByRole("button", { name: "Unarchive", exact: true });
|
||||
await expect(unarchiveBtn).toBeVisible({ timeout: 30_000 });
|
||||
await expect(
|
||||
page.getByText("single-unarchive-turn-5", { exact: false }).first(),
|
||||
).toBeVisible();
|
||||
|
||||
const idleCalloutBox = await page.getByTestId("agent-archived-callout").boundingBox();
|
||||
if (!idleCalloutBox) throw new Error("Archived callout is not laid out");
|
||||
|
||||
await page.evaluate(() => {
|
||||
const win = window as unknown as Record<string, unknown>;
|
||||
const state = {
|
||||
sawAgentLoading: false,
|
||||
sawUnarchivingCallout: false,
|
||||
unarchivingCalloutHeights: [] as number[],
|
||||
minRowCount: Number.POSITIVE_INFINITY,
|
||||
minStreamOpacity: Number.POSITIVE_INFINITY,
|
||||
};
|
||||
let running = true;
|
||||
const isVisible = (el: Element | null) => {
|
||||
if (!el || !(el instanceof HTMLElement)) return false;
|
||||
const rect = el.getBoundingClientRect();
|
||||
if (rect.width === 0 || rect.height === 0) return false;
|
||||
const style = getComputedStyle(el);
|
||||
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
||||
};
|
||||
const tick = () => {
|
||||
if (!running) return;
|
||||
if (
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-loading"]')).some(isVisible)
|
||||
) {
|
||||
state.sawAgentLoading = true;
|
||||
}
|
||||
const stream =
|
||||
Array.from(document.querySelectorAll('[data-testid="agent-chat-scroll"]')).find(
|
||||
isVisible,
|
||||
) ?? null;
|
||||
if (stream instanceof HTMLElement) {
|
||||
const rowCount = stream.querySelectorAll("[data-history-row-id]").length;
|
||||
const opacity = Number.parseFloat(getComputedStyle(stream).opacity || "1");
|
||||
state.minRowCount = Math.min(state.minRowCount, rowCount);
|
||||
state.minStreamOpacity = Math.min(state.minStreamOpacity, opacity);
|
||||
} else {
|
||||
state.minRowCount = 0;
|
||||
state.minStreamOpacity = 0;
|
||||
}
|
||||
const unarchivingCallout = Array.from(
|
||||
document.querySelectorAll('[data-testid="agent-unarchiving-callout"]'),
|
||||
).find(isVisible);
|
||||
if (unarchivingCallout instanceof HTMLElement) {
|
||||
state.sawUnarchivingCallout = true;
|
||||
state.unarchivingCalloutHeights.push(
|
||||
Math.round(unarchivingCallout.getBoundingClientRect().height),
|
||||
);
|
||||
}
|
||||
requestAnimationFrame(tick);
|
||||
};
|
||||
win.__stopSingleUnarchiveCheck = () => {
|
||||
running = false;
|
||||
return state;
|
||||
};
|
||||
requestAnimationFrame(tick);
|
||||
});
|
||||
|
||||
await unarchiveBtn.click();
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeEditable({
|
||||
timeout: 30_000,
|
||||
});
|
||||
const result = await page.evaluate(() => {
|
||||
const win = window as unknown as {
|
||||
__stopSingleUnarchiveCheck?: () => {
|
||||
sawAgentLoading: boolean;
|
||||
sawUnarchivingCallout: boolean;
|
||||
unarchivingCalloutHeights: number[];
|
||||
minRowCount: number;
|
||||
minStreamOpacity: number;
|
||||
};
|
||||
};
|
||||
return win.__stopSingleUnarchiveCheck?.();
|
||||
});
|
||||
expect(result?.sawAgentLoading).toBe(false);
|
||||
expect(result?.sawUnarchivingCallout).toBe(true);
|
||||
expect(result?.minRowCount).toBeGreaterThan(0);
|
||||
expect(result?.minStreamOpacity).toBe(1);
|
||||
for (const height of result?.unarchivingCalloutHeights ?? []) {
|
||||
expect(Math.abs(height - Math.round(idleCalloutBox.height))).toBeLessThanOrEqual(1);
|
||||
}
|
||||
} finally {
|
||||
await client.removeProject(project.projectKey).catch(() => undefined);
|
||||
await seedClient.close().catch(() => undefined);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,9 +38,6 @@ fill "id=\"direct-password-input\"" "${PASSWORD}"
|
||||
wait stable
|
||||
press "id=\"direct-host-submit\""
|
||||
wait stable
|
||||
open "${APP_ID}" "paseo://settings"
|
||||
wait "label=\"Connections\"" 10000
|
||||
press "label=\"Connections\""
|
||||
wait stable
|
||||
wait "id=\"host-page-connections-card\"" 30000
|
||||
open "${APP_ID}" "paseo://settings/hosts"
|
||||
wait "id=\"client-hosts-card\"" 15000
|
||||
screenshot "${OUT}/16-settings-connected.png"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Start on Settings > Host > Pair device with relay enabled in the Android app.
|
||||
// Start on Settings > Host > Devices with relay enabled in the Android app.
|
||||
// node packages/app/e2e/mobile/pair-device/android.mjs <agent-device-session>
|
||||
import assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
@@ -13,11 +13,7 @@ function ad(...args) {
|
||||
});
|
||||
}
|
||||
|
||||
ad(
|
||||
"press",
|
||||
'label="Pair a device, Scan a QR code or copy a link to connect your phone to this host"',
|
||||
"--settle",
|
||||
);
|
||||
ad("press", 'label="Relay"', "--settle");
|
||||
ad("wait", "text", "Pairing QR code", "10000");
|
||||
const { data } = JSON.parse(ad("snapshot", "-i", "--json"));
|
||||
const sheet = data.nodes.find((node) => node.label === "Bottom Sheet");
|
||||
|
||||
@@ -768,6 +768,44 @@ export async function selectModelRow(
|
||||
await modelRow(page, input).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a provider on a slow machine and clicks a model row before the list has
|
||||
* finished laying out, holding the button as long as a person does.
|
||||
*/
|
||||
export async function clickModelRowWhileProviderOpens(
|
||||
page: Page,
|
||||
input: { provider: string; modelLabel: string },
|
||||
): Promise<void> {
|
||||
const viewport = pickerViewport(page);
|
||||
await drillIntoProvider(page, input.provider);
|
||||
const rowBox = await viewport.getByText(input.modelLabel, { exact: true }).boundingBox();
|
||||
if (!rowBox) throw new Error(`Model row ${input.modelLabel} has no box`);
|
||||
await viewport.getByRole("button", { name: "Back", exact: true }).click();
|
||||
|
||||
const cdp = await page.context().newCDPSession(page);
|
||||
await cdp.send("Emulation.setCPUThrottlingRate", { rate: 10 });
|
||||
try {
|
||||
await drillIntoProvider(page, input.provider);
|
||||
await page.mouse.click(rowBox.x + rowBox.width / 2, rowBox.y + rowBox.height / 2, {
|
||||
delay: 150,
|
||||
});
|
||||
} finally {
|
||||
await cdp.send("Emulation.setCPUThrottlingRate", { rate: 1 });
|
||||
await cdp.detach();
|
||||
}
|
||||
}
|
||||
|
||||
/** Scrolling a provider's model list with the wheel leaves typing and Enter in the search field. */
|
||||
export async function expectModelListScrollKeepsSearchFocused(page: Page): Promise<void> {
|
||||
const search = pickerViewport(page).getByTestId("model-search-input");
|
||||
const list = pickerViewport(page).getByTestId("compact-model-list");
|
||||
await expect(search).toBeFocused();
|
||||
await list.hover();
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => list.evaluate((element) => element.scrollTop)).toBeGreaterThan(0);
|
||||
await expect(search).toBeFocused();
|
||||
}
|
||||
|
||||
// ─── Cross-provider model search ───────────────────────────────────────────
|
||||
|
||||
export async function searchAllModels(page: Page, query: string): Promise<void> {
|
||||
|
||||
@@ -134,9 +134,13 @@ export async function openAgentSkillsSettings(
|
||||
host: "127.0.0.1",
|
||||
port: sandbox.daemon.port,
|
||||
});
|
||||
if (options.compact) await goBackInSettings(page);
|
||||
if (options.compact) {
|
||||
// Adding a host opens its client host detail page; back once goes to Hosts, back again returns to the Settings root.
|
||||
await goBackInSettings(page);
|
||||
await goBackInSettings(page);
|
||||
}
|
||||
await selectSettingsHost(page, sandbox.daemon.serverId);
|
||||
await openHostSection(page, sandbox.daemon.serverId, "agents");
|
||||
await openHostSection(page, sandbox.daemon.serverId, "tools");
|
||||
await expect(page.getByTestId("host-agent-skills-card")).toBeVisible();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function openDaemonOverview(page: Page, daemon: IsolatedHostDaemon)
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, daemon.serverId);
|
||||
await openHostSection(page, daemon.serverId, "host");
|
||||
await openHostSection(page, daemon.serverId, "daemon");
|
||||
}
|
||||
|
||||
export async function restartDaemonInSettings(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, type Page } from "@playwright/test";
|
||||
import { identityForeground, type IdentityColorName } from "@/styles/identity-colors";
|
||||
import { openSettings } from "./app";
|
||||
import { buildSeededHost } from "./daemon-registry";
|
||||
import { clickSettingsBackToWorkspace, openHostSection, selectSettingsHost } from "./settings";
|
||||
import { clickSettingsBackToWorkspace, openClientHostSettings } from "./settings";
|
||||
|
||||
const REGISTRY_KEY = "@paseo:daemon-registry";
|
||||
const SEED_NONCE_KEY = "@paseo:e2e-seed-nonce";
|
||||
@@ -170,8 +170,7 @@ export async function selectAllHostsFilter(page: Page): Promise<void> {
|
||||
|
||||
export async function openHostAppearanceSettings(page: Page, serverId: string): Promise<void> {
|
||||
await openSettings(page);
|
||||
await selectSettingsHost(page, serverId);
|
||||
await openHostSection(page, serverId, "host");
|
||||
await openClientHostSettings(page, serverId);
|
||||
await expect(page.getByTestId("host-appearance-preview")).toBeVisible({ timeout: 15_000 });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { promisify } from "node:util";
|
||||
import { once } from "node:events";
|
||||
import {
|
||||
spawn,
|
||||
execFile,
|
||||
@@ -11,6 +12,7 @@ import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import net from "node:net";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { WebSocket } from "ws";
|
||||
import { withDisabledE2ESpeechEnv } from "./speech-env";
|
||||
import { killProcessTree, spawnTsx } from "./spawn-node";
|
||||
|
||||
@@ -64,12 +66,14 @@ export async function getAvailableHostDaemonPort(): Promise<number> {
|
||||
* Resolves once this daemon answers on its port. An open TCP port is not
|
||||
* enough: the port is released before the daemon binds it, and whatever takes
|
||||
* it in between also accepts connections while the daemon exits with
|
||||
* EADDRINUSE. Only the daemon's own status reports its server id.
|
||||
* EADDRINUSE. Only the daemon's own status reports its server id. Published
|
||||
* daemons can serve status before they accept WebSocket upgrades.
|
||||
*/
|
||||
async function waitForServer(
|
||||
port: number,
|
||||
child: ChildProcess,
|
||||
identity: { serverId: string; paseoHome: string },
|
||||
published: boolean,
|
||||
): Promise<void> {
|
||||
const deadline = Date.now() + 90_000;
|
||||
let lastError: unknown = null;
|
||||
@@ -82,7 +86,10 @@ async function waitForServer(
|
||||
}
|
||||
try {
|
||||
const serverId = await readServerId(port, identity.paseoHome);
|
||||
if (serverId === identity.serverId) return;
|
||||
if (serverId === identity.serverId) {
|
||||
if (published) await checkWebSocketUpgrade(port);
|
||||
return;
|
||||
}
|
||||
lastError = new Error(`Port ${port} is served by ${serverId}, not ${identity.serverId}`);
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
@@ -97,6 +104,12 @@ async function waitForServer(
|
||||
);
|
||||
}
|
||||
|
||||
async function checkWebSocketUpgrade(port: number): Promise<void> {
|
||||
const socket = new WebSocket(`ws://127.0.0.1:${port}/ws`, { handshakeTimeout: 1_000 });
|
||||
await once(socket, "open");
|
||||
socket.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the server id from the daemon's status route. The route needs a bearer
|
||||
* on a password-protected daemon; the daemon accepts the local credential it
|
||||
@@ -246,7 +259,7 @@ export async function startIsolatedHostDaemon(
|
||||
});
|
||||
|
||||
try {
|
||||
await waitForServer(port, spawned, { serverId, paseoHome });
|
||||
await waitForServer(port, spawned, { serverId, paseoHome }, Boolean(publishedPackageRoot));
|
||||
return spawned;
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
|
||||
@@ -161,7 +161,7 @@ export async function finishSetup(page: Page): Promise<void> {
|
||||
/** Opens the Phone step's Relay row: the pair device modal, over setup. */
|
||||
export async function openRelayPairingFromSetup(page: Page): Promise<Locator> {
|
||||
await setupModal(page).getByRole("button", { name: "Relay", exact: true }).click();
|
||||
const pairing = page.getByTestId("onboarding-pair-device-card");
|
||||
const pairing = page.getByTestId("devices-relay-pairing");
|
||||
await expect(pairing).toBeVisible();
|
||||
return pairing;
|
||||
}
|
||||
@@ -171,20 +171,9 @@ export async function closeRelayPairing(pairing: Locator): Promise<void> {
|
||||
await expect(pairing).toHaveCount(0);
|
||||
}
|
||||
|
||||
/** Clicks the Phone step's Tailscale row and returns the docs page it opened. */
|
||||
export async function openTailscaleDocsFromSetup(page: Page): Promise<string> {
|
||||
await page
|
||||
.context()
|
||||
.route("https://paseo.sh/**", (route) =>
|
||||
route.fulfill({ contentType: "text/html", body: "<title>Paseo docs</title>" }),
|
||||
);
|
||||
const popup = page.waitForEvent("popup");
|
||||
await setupModal(page).getByRole("link", { name: "Tailscale, Docs", exact: true }).click();
|
||||
const docs = await popup;
|
||||
await docs.waitForLoadState("domcontentloaded");
|
||||
const url = docs.url();
|
||||
await docs.close();
|
||||
return url;
|
||||
export async function expectTailscaleSwitchDisabled(page: Page): Promise<void> {
|
||||
const setup = setupModal(page);
|
||||
await expect(setup.getByRole("switch", { name: "Tailscale", exact: true })).toBeDisabled();
|
||||
}
|
||||
|
||||
export interface SetupHost {
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
selectSettingsHost,
|
||||
} from "./settings";
|
||||
import { expectAppRoute } from "./route-assertions";
|
||||
import { wsRoutePatternForPort } from "./daemon-port";
|
||||
import { goToSetupStep, showSetupAgainFromSettings } from "./onboarding";
|
||||
import { buildSettingsHostSectionRoute } from "@/utils/host-routes";
|
||||
|
||||
interface PairingHostInput {
|
||||
@@ -60,9 +62,33 @@ export async function prepareLocalPairingHost(
|
||||
await preparePairingHost(page, daemon, additionalHosts);
|
||||
}
|
||||
|
||||
type PairingHost =
|
||||
| Pick<IsolatedHostDaemon, "serverId" | "port">
|
||||
| Pick<OutdatedDaemon, "serverId" | "endpoint">;
|
||||
|
||||
export async function preparePairingHost(
|
||||
page: Page,
|
||||
daemon: IsolatedHostDaemon | OutdatedDaemon,
|
||||
daemon: PairingHost,
|
||||
additionalHosts: PairingHostInput[] = [],
|
||||
): Promise<void> {
|
||||
await openAppOnPairingHost(page, daemon, additionalHosts);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, daemon.serverId);
|
||||
await expect(page.getByTestId("devices-relay")).toHaveCount(0);
|
||||
await openSettingsHostSection(page, daemon.serverId, "devices");
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
}
|
||||
|
||||
/** Loads the app afresh with `daemon` as its first host, then opens the setup's Mobile step. */
|
||||
export async function openSetupMobileStep(page: Page, daemon: PairingHost): Promise<void> {
|
||||
await openAppOnPairingHost(page, daemon);
|
||||
await showSetupAgainFromSettings(page);
|
||||
await goToSetupStep(page, "Mobile");
|
||||
}
|
||||
|
||||
async function openAppOnPairingHost(
|
||||
page: Page,
|
||||
daemon: PairingHost,
|
||||
additionalHosts: PairingHostInput[] = [],
|
||||
): Promise<void> {
|
||||
await seedSavedSettingsHosts(page, [
|
||||
@@ -74,20 +100,372 @@ export async function preparePairingHost(
|
||||
...additionalHosts,
|
||||
]);
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, daemon.serverId);
|
||||
await expect(page.getByTestId("host-page-pair-device-row")).toHaveCount(0);
|
||||
await openSettingsHostSection(page, daemon.serverId, "pair-device");
|
||||
await expect(page.getByTestId("host-page-pair-device-row")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function enableTailscale(page: Page): Promise<void> {
|
||||
const toggle = page.getByRole("switch", { name: "Tailscale", exact: true });
|
||||
await expect(toggle).toBeEnabled();
|
||||
await expect(toggle).not.toBeChecked();
|
||||
await toggle.click();
|
||||
await expect(toggle).toBeChecked();
|
||||
await expect(toggle).toBeEnabled();
|
||||
}
|
||||
|
||||
export async function expectTailscaleAddress(page: Page, address: string): Promise<void> {
|
||||
const row = tailscaleAddressRow(page, address);
|
||||
await expect(row).toBeVisible();
|
||||
await expect(
|
||||
row.getByText("On a phone with Tailscale, add a host at this address"),
|
||||
).toBeVisible();
|
||||
await expect(row.getByRole("button", { name: "Copy", exact: true })).toBeVisible();
|
||||
const response = await fetch(`http://${address}/api/health`);
|
||||
expect(response.ok).toBe(true);
|
||||
}
|
||||
|
||||
/** The switch shows off as soon as it is tapped; the host stops listening when its answer lands. */
|
||||
async function expectHostUnreachableAt(address: string): Promise<void> {
|
||||
await expect
|
||||
.poll(() =>
|
||||
fetch(`http://${address}/api/health`).then(
|
||||
() => "reachable",
|
||||
() => "unreachable",
|
||||
),
|
||||
)
|
||||
.toBe("unreachable");
|
||||
}
|
||||
|
||||
function tailscaleAddressRow(page: Page, address: string) {
|
||||
return page.getByTestId("devices-tailscale-address").filter({ hasText: address });
|
||||
}
|
||||
|
||||
export async function disableTailscale(page: Page, address: string): Promise<void> {
|
||||
const toggle = page.getByRole("switch", { name: "Tailscale", exact: true });
|
||||
await expect(toggle).toBeEnabled();
|
||||
await toggle.click();
|
||||
await expect(toggle).not.toBeChecked();
|
||||
await expect(toggle).toBeEnabled();
|
||||
await expect(tailscaleAddressRow(page, address)).toHaveCount(0);
|
||||
await expectHostUnreachableAt(address);
|
||||
}
|
||||
|
||||
/** Reopens the host over its Tailscale address, as a phone on the tailnet would reach it. */
|
||||
export async function connectThroughTailscale(
|
||||
page: Page,
|
||||
daemon: { serverId: string; tailscaleAddress: string },
|
||||
): Promise<void> {
|
||||
await preparePairingHost(page, { serverId: daemon.serverId, endpoint: daemon.tailscaleAddress });
|
||||
await expectTailscaleAddress(page, daemon.tailscaleAddress);
|
||||
}
|
||||
|
||||
const TURN_OFF_QUESTION =
|
||||
"Turn off Tailscale?\n\nThis device is connected through Tailscale and will lose its connection to the host.";
|
||||
|
||||
/**
|
||||
* Taps the switch off over the Tailscale connection and cancels the question. Every state the row
|
||||
* commits from the tap to after Cancel must still show Tailscale on with its address: nothing
|
||||
* changes until the user confirms.
|
||||
*/
|
||||
export async function cancelTailscaleTurnOff(page: Page, address: string): Promise<void> {
|
||||
const row = await recordTailscaleRow(page);
|
||||
const question = answerNextDialog(page, "dismiss");
|
||||
await page.getByRole("switch", { name: "Tailscale", exact: true }).click();
|
||||
expect(await question).toBe(TURN_OFF_QUESTION);
|
||||
await page.waitForTimeout(500);
|
||||
expect(new Set((await row()).map((state) => `${state.value} ${state.address}`))).toEqual(
|
||||
new Set(["on true"]),
|
||||
);
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeChecked();
|
||||
await expect(tailscaleAddressRow(page, address)).toBeVisible();
|
||||
expect((await fetch(`http://${address}/api/health`)).ok).toBe(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms turning Tailscale off over the Tailscale connection, which cuts this app off the host.
|
||||
* Without the host the row shows no value at all, on or off.
|
||||
*/
|
||||
export async function confirmTailscaleTurnOff(page: Page, address: string): Promise<void> {
|
||||
const question = answerNextDialog(page, "accept");
|
||||
await page.getByRole("switch", { name: "Tailscale", exact: true }).click();
|
||||
expect(await question).toBe(TURN_OFF_QUESTION);
|
||||
await expect(page.getByText("Host is not connected", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toHaveCount(0);
|
||||
await expectHostUnreachableAt(address);
|
||||
}
|
||||
|
||||
function answerNextDialog(page: Page, answer: "accept" | "dismiss"): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
page.once("dialog", async (dialog) => {
|
||||
resolve(dialog.message());
|
||||
await (answer === "accept" ? dialog.accept() : dialog.dismiss());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interface TailscaleRowState {
|
||||
/** `none` while the row shows no value yet. */
|
||||
value: "on" | "off" | "none";
|
||||
address: boolean;
|
||||
hint: string;
|
||||
labelTop: number;
|
||||
hintTop: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records every state the Tailscale row commits, painted or not: from now on in this page, and
|
||||
* from the first paint of every page load after it. Recording again starts a new record.
|
||||
*/
|
||||
async function recordTailscaleRow(page: Page): Promise<() => Promise<TailscaleRowState[]>> {
|
||||
const record = () => {
|
||||
const host = window as unknown as {
|
||||
tailscaleRow?: { states: unknown[]; last: string; sample(): void };
|
||||
};
|
||||
if (host.tailscaleRow) {
|
||||
host.tailscaleRow.states = [];
|
||||
host.tailscaleRow.last = "";
|
||||
host.tailscaleRow.sample();
|
||||
return;
|
||||
}
|
||||
const isVisibleText = (element: Element, text?: string) =>
|
||||
element.childElementCount === 0 &&
|
||||
(text === undefined
|
||||
? (element.textContent ?? "").trim() !== ""
|
||||
: element.textContent === text) &&
|
||||
element.getBoundingClientRect().height > 0;
|
||||
const readValue = (toggle: Element | null) => {
|
||||
if (!toggle) return "none";
|
||||
return toggle.getAttribute("aria-checked") === "true" ? "on" : "off";
|
||||
};
|
||||
const read = () => {
|
||||
const label = [...document.querySelectorAll("div, span")].find((element) =>
|
||||
isVisibleText(element, "Tailscale"),
|
||||
);
|
||||
if (!label) return null;
|
||||
let row: Element = label;
|
||||
while (row.parentElement && !(row as HTMLElement).innerText.includes("\n")) {
|
||||
row = row.parentElement;
|
||||
}
|
||||
const hint = [...row.querySelectorAll("div, span")].find(
|
||||
(element) => element !== label && isVisibleText(element),
|
||||
);
|
||||
const toggle = document.querySelector('[role="switch"][aria-label="Tailscale"]');
|
||||
return {
|
||||
value: readValue(toggle),
|
||||
address: document.querySelector('[data-testid="devices-tailscale-address"]') !== null,
|
||||
hint: hint?.textContent ?? "",
|
||||
labelTop: Math.round(label.getBoundingClientRect().top),
|
||||
hintTop: Math.round(hint?.getBoundingClientRect().top ?? -1),
|
||||
};
|
||||
};
|
||||
const recorder = {
|
||||
states: [] as unknown[],
|
||||
last: "",
|
||||
sample() {
|
||||
const state = read();
|
||||
const key = JSON.stringify(state);
|
||||
if (state && key !== recorder.last) recorder.states.push(state);
|
||||
recorder.last = key;
|
||||
},
|
||||
};
|
||||
host.tailscaleRow = recorder;
|
||||
new MutationObserver(() => recorder.sample()).observe(document, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
attributes: true,
|
||||
});
|
||||
};
|
||||
await page.addInitScript(record);
|
||||
await page.evaluate(record);
|
||||
return () =>
|
||||
page.evaluate(
|
||||
() =>
|
||||
(window as unknown as { tailscaleRow: { states: TailscaleRowState[] } }).tailscaleRow
|
||||
.states,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs `open`, which first shows the Tailscale row of a host with Tailscale on, and checks the row
|
||||
* from its first state to its last: it starts with no value, never shows Tailscale off, and its
|
||||
* label and hint keep their text and place until it settles on, with the address below.
|
||||
*/
|
||||
export async function expectTailscaleRowLoadsOn(
|
||||
page: Page,
|
||||
address: string,
|
||||
open: () => Promise<void>,
|
||||
): Promise<void> {
|
||||
const row = await recordTailscaleRow(page);
|
||||
await open();
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeChecked();
|
||||
await expect(tailscaleAddressRow(page, address)).toBeVisible();
|
||||
const states = await row();
|
||||
expect(states[0]?.value).toBe("none");
|
||||
expect(states.filter((state) => state.value === "off")).toEqual([]);
|
||||
expect(
|
||||
new Set(states.map(({ hint, labelTop, hintTop }) => `${hint} ${labelTop} ${hintTop}`)).size,
|
||||
).toBe(1);
|
||||
expect(states.at(-1)).toMatchObject({ value: "on", address: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds every message between the app and the host on `port` for `ms` in each direction, as on a
|
||||
* slow network. The returned function brings the connection back to full speed and flushes any
|
||||
* queued messages.
|
||||
*/
|
||||
export async function slowConnectionToHost(
|
||||
page: Page,
|
||||
port: number,
|
||||
ms: number,
|
||||
): Promise<() => void> {
|
||||
let delay = ms;
|
||||
const flushers = new Set<() => void>();
|
||||
await page.routeWebSocket(wsRoutePatternForPort(String(port)), (app) => {
|
||||
const host = app.connectToServer();
|
||||
const appToHost = deliverInOrderAfter(
|
||||
() => delay,
|
||||
(message) => host.send(message),
|
||||
);
|
||||
const hostToApp = deliverInOrderAfter(
|
||||
() => delay,
|
||||
(message) => app.send(message),
|
||||
);
|
||||
flushers.add(appToHost.flushNow);
|
||||
flushers.add(hostToApp.flushNow);
|
||||
app.onMessage(appToHost.enqueue);
|
||||
host.onMessage(hostToApp.enqueue);
|
||||
});
|
||||
return () => {
|
||||
delay = 0;
|
||||
for (const flushNow of flushers) flushNow();
|
||||
};
|
||||
}
|
||||
|
||||
function deliverInOrderAfter(delay: () => number, deliver: (message: string | Buffer) => void) {
|
||||
const queue: { at: number; message: string | Buffer }[] = [];
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
const flush = () => {
|
||||
timer = null;
|
||||
while (queue[0] && queue[0].at <= Date.now()) deliver(queue.shift()!.message);
|
||||
if (queue[0]) timer = setTimeout(flush, queue[0].at - Date.now());
|
||||
};
|
||||
return {
|
||||
enqueue: (message: string | Buffer) => {
|
||||
queue.push({ at: Math.max(Date.now() + delay(), queue.at(-1)?.at ?? 0), message });
|
||||
if (!timer) flush();
|
||||
},
|
||||
flushNow: () => {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
while (queue[0]) {
|
||||
const next = queue.shift()!;
|
||||
try {
|
||||
deliver(next.message);
|
||||
} catch {
|
||||
queue.length = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function expectTailscaleUpdateRequired(page: Page): Promise<void> {
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeDisabled();
|
||||
await expect(page.getByText("Update this host to use Tailscale", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "How to update", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectTailscaleUnavailable(page: Page): Promise<void> {
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeDisabled();
|
||||
await expect(
|
||||
page.getByText("Tailscale is not running on this host", { exact: true }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "Get Tailscale", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Refresh", exact: true })).toBeEnabled();
|
||||
}
|
||||
|
||||
export async function refreshTailscaleAvailability(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: "Refresh", exact: true }).click();
|
||||
}
|
||||
|
||||
export async function expectTailscaleAvailable(
|
||||
page: Page,
|
||||
options?: { timeout?: number },
|
||||
): Promise<void> {
|
||||
await expect(page.getByRole("button", { name: "Refresh", exact: true })).toHaveCount(0, options);
|
||||
const toggle = page.getByRole("switch", { name: "Tailscale", exact: true });
|
||||
await expect(toggle).toBeEnabled(options);
|
||||
await expect(toggle).not.toBeChecked(options);
|
||||
await expect(
|
||||
page.getByText("Direct over your tailnet, enter an address", { exact: true }),
|
||||
).toBeVisible(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tracks `daemon.get_status` frames on the host socket so Refresh tests can align right after a
|
||||
* 2-second poll and verify the button click itself sent a fresh status request.
|
||||
*/
|
||||
export function observeDaemonStatusPolling(page: Page, port: number) {
|
||||
let lastResponseAt = 0;
|
||||
let waitingForResponse: (() => void) | null = null;
|
||||
let waitingForRequest: (() => void) | null = null;
|
||||
page.on("websocket", (socket) => {
|
||||
if (!socket.url().includes(`:${port}`)) return;
|
||||
socket.on("framesent", ({ payload }) => {
|
||||
const message = typeof payload === "string" ? payload : payload.toString();
|
||||
if (message.includes('"type":"daemon.get_status.request"')) {
|
||||
waitingForRequest?.();
|
||||
waitingForRequest = null;
|
||||
}
|
||||
});
|
||||
socket.on("framereceived", ({ payload }) => {
|
||||
const message = typeof payload === "string" ? payload : payload.toString();
|
||||
if (message.includes('"type":"daemon.get_status.response"')) {
|
||||
lastResponseAt = Date.now();
|
||||
waitingForResponse?.();
|
||||
waitingForResponse = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
async waitForFreshPollWindow(): Promise<void> {
|
||||
if (Date.now() - lastResponseAt < 250) return;
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
waitingForResponse = null;
|
||||
reject(new Error("Timed out waiting for daemon status poll"));
|
||||
}, 5_000);
|
||||
waitingForResponse = () => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
waitForStatusRequest(timeoutMs = 1_000): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
waitingForRequest = null;
|
||||
reject(new Error("Refresh did not send daemon.get_status.request"));
|
||||
}, timeoutMs);
|
||||
waitingForRequest = () => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function openPairDeviceModal(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: /Pair a device/ }).click();
|
||||
await expect(page.getByTestId("host-page-pair-device-card")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Relay", exact: true }).click();
|
||||
await expect(page.getByTestId("devices-relay-pairing")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectRelayConsent(page: Page): Promise<void> {
|
||||
const modal = page.getByTestId("host-page-pair-device-card");
|
||||
const modal = page.getByTestId("devices-relay-pairing");
|
||||
await expect(modal.getByText("Enable relay?", { exact: true })).toBeVisible();
|
||||
await expect(modal.getByText(/end-to-end encrypted/)).toBeVisible();
|
||||
await expect(modal.getByRole("link", { name: "Read how Paseo relay works" })).toBeVisible();
|
||||
@@ -99,7 +477,7 @@ export async function expectRelayConsent(page: Page): Promise<void> {
|
||||
|
||||
export async function declineRelay(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: "Not now", exact: true }).click();
|
||||
await expect(page.getByTestId("host-page-pair-device-card")).toHaveCount(0);
|
||||
await expect(page.getByTestId("devices-relay-pairing")).toHaveCount(0);
|
||||
}
|
||||
|
||||
export async function enableRelayAndExpectOffer(page: Page): Promise<void> {
|
||||
@@ -124,10 +502,10 @@ export async function expectPairingOffer(page: Page): Promise<void> {
|
||||
|
||||
export async function closePairDeviceModal(page: Page): Promise<void> {
|
||||
await page
|
||||
.getByTestId("host-page-pair-device-card")
|
||||
.getByTestId("devices-relay-pairing")
|
||||
.getByRole("button", { name: "Close", exact: true })
|
||||
.click();
|
||||
await expect(page.getByTestId("host-page-pair-device-card")).toHaveCount(0);
|
||||
await expect(page.getByTestId("devices-relay-pairing")).toHaveCount(0);
|
||||
}
|
||||
|
||||
export async function reloadAndOpenPairDevice(page: Page): Promise<void> {
|
||||
@@ -145,7 +523,7 @@ export async function enableRelayAndExpectFailure(
|
||||
expectedError = "Relay is controlled by a daemon launch override",
|
||||
): Promise<void> {
|
||||
await page.getByRole("button", { name: "Enable relay", exact: true }).click();
|
||||
const modal = page.getByTestId("host-page-pair-device-card");
|
||||
const modal = page.getByTestId("devices-relay-pairing");
|
||||
await expect(modal.getByRole("alert")).toContainText(expectedError);
|
||||
await expect(modal.getByRole("button", { name: "Retry", exact: true })).toBeEnabled();
|
||||
await expect(modal.getByRole("textbox", { name: "Pairing link" })).toHaveCount(0);
|
||||
@@ -155,7 +533,7 @@ export async function retryRelayAndExpectFailure(
|
||||
page: Page,
|
||||
expectedError = "Relay is controlled by a daemon launch override",
|
||||
): Promise<void> {
|
||||
const modal = page.getByTestId("host-page-pair-device-card");
|
||||
const modal = page.getByTestId("devices-relay-pairing");
|
||||
await modal.getByRole("button", { name: "Retry", exact: true }).click();
|
||||
await expect(modal.getByRole("alert")).toContainText(expectedError);
|
||||
await expect(modal.getByRole("button", { name: "Retry", exact: true })).toBeEnabled();
|
||||
@@ -173,7 +551,7 @@ export async function openPairDeviceFromHome(page: Page): Promise<void> {
|
||||
}
|
||||
|
||||
export async function expectRelayUpdateRequired(page: Page): Promise<void> {
|
||||
const modal = page.getByTestId("host-page-pair-device-card");
|
||||
const modal = page.getByTestId("devices-relay-pairing");
|
||||
await expect(
|
||||
modal.getByText("Update the host to enable relay from Paseo Desktop."),
|
||||
).toBeVisible();
|
||||
@@ -195,15 +573,15 @@ export function observePairingOfferRequests(page: Page, daemon: OutdatedDaemon):
|
||||
}
|
||||
|
||||
export async function expectPairingDisconnected(page: Page): Promise<void> {
|
||||
const modal = page.getByTestId("host-page-pair-device-card");
|
||||
const modal = page.getByTestId("devices-relay-pairing");
|
||||
await expect(modal.getByRole("alert")).toContainText("Host is not connected");
|
||||
await expect(modal.getByRole("button", { name: "Retry", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function switchPairDeviceToHost(page: Page, serverId: string): Promise<void> {
|
||||
await selectSettingsHost(page, serverId);
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(serverId, "pair-device"));
|
||||
await expect(page.getByTestId("host-page-pair-device-row")).toBeVisible();
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(serverId, "devices"));
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function openRelaySecurityDocs(page: Page): Promise<void> {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { buildCreateAgentPreferences, buildSeededHost, TEST_HOST_LABEL } from ".
|
||||
import { getServerId } from "./server-id";
|
||||
import { expectAppRoute } from "./route-assertions";
|
||||
import {
|
||||
buildClientHostSettingsRoute,
|
||||
buildSettingsHostSectionRoute,
|
||||
buildSettingsRoute,
|
||||
buildSettingsSectionRoute,
|
||||
@@ -47,35 +48,29 @@ interface SavedSettingsHostInput {
|
||||
|
||||
const SECTION_LABELS = {
|
||||
general: "General",
|
||||
chat: "Chat",
|
||||
hosts: "Hosts",
|
||||
appearance: "Appearance",
|
||||
sidebar: "Sidebar",
|
||||
editor: "Editor",
|
||||
files: "Files",
|
||||
terminal: "Terminal",
|
||||
browser: "Browser",
|
||||
chat: "Chat & panes",
|
||||
shortcuts: "Shortcuts",
|
||||
integrations: "Integrations",
|
||||
permissions: "Permissions",
|
||||
diagnostics: "Diagnostics",
|
||||
notifications: "Notifications",
|
||||
about: "About",
|
||||
} as const;
|
||||
|
||||
export type SettingsSection = keyof typeof SECTION_LABELS;
|
||||
|
||||
type HostSection =
|
||||
| "projects"
|
||||
| "connections"
|
||||
| "pair-device"
|
||||
| "agents"
|
||||
| "metadata"
|
||||
| "voice"
|
||||
| "workspaces"
|
||||
| "providers"
|
||||
| "agent-profiles"
|
||||
| "tools"
|
||||
| "projects"
|
||||
| "workspaces"
|
||||
| "voice"
|
||||
| "usage"
|
||||
| "terminals"
|
||||
| "plugins"
|
||||
| "host";
|
||||
| "devices"
|
||||
| "daemon";
|
||||
|
||||
export async function openSettingsSection(page: Page, section: SettingsSection): Promise<void> {
|
||||
const sidebar = page.getByTestId("settings-sidebar");
|
||||
@@ -198,14 +193,19 @@ export async function expectSettingsDetailScrollOffset(page: Page, offset: numbe
|
||||
await expect.poll(() => scrollBody.evaluate((node) => node.scrollTop)).toBe(offset);
|
||||
}
|
||||
|
||||
export async function openSettingsHost(page: Page, serverId: string): Promise<void> {
|
||||
// Host sections are now flat top-level rows under the Host group. Navigate by
|
||||
// clicking the Connections section row; the picker only matters when >1 host.
|
||||
await page.getByTestId("settings-host-section-connections").click();
|
||||
await expectHostSettingsUrl(page, serverId);
|
||||
export async function openClientHostSettings(page: Page, serverId: string): Promise<void> {
|
||||
await openSettingsSection(page, "hosts");
|
||||
await page.getByTestId(`client-host-row-${serverId}`).click();
|
||||
await expectAppRoute(page, buildClientHostSettingsRoute(serverId));
|
||||
await expect(page.getByTestId("host-page-connections-card")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function openSettingsHost(page: Page, serverId: string): Promise<void> {
|
||||
await page.getByTestId("settings-host-section-daemon").click();
|
||||
await expectHostSettingsUrl(page, serverId);
|
||||
await expect(page.getByTestId("host-page-identity")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function openSettingsHostSection(
|
||||
page: Page,
|
||||
serverId: string,
|
||||
@@ -367,7 +367,7 @@ export async function removeCurrentHostFromSettings(page: Page): Promise<void> {
|
||||
await page.getByTestId("host-page-remove-host-button").click();
|
||||
await expect(page.getByTestId("remove-host-confirm-modal")).toBeVisible();
|
||||
await page.getByTestId("remove-host-confirm").click();
|
||||
await expectAppRoute(page, buildSettingsRoute());
|
||||
await expectAppRoute(page, buildSettingsSectionRoute("hosts"));
|
||||
}
|
||||
|
||||
export async function expectSettingsBackButton(page: Page): Promise<void> {
|
||||
@@ -379,7 +379,7 @@ export async function clickSettingsBackToWorkspace(page: Page): Promise<void> {
|
||||
}
|
||||
|
||||
export async function expectHostSettingsUrl(page: Page, serverId: string): Promise<void> {
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(serverId, "connections"));
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(serverId, "daemon"));
|
||||
}
|
||||
|
||||
export async function verifyLegacyHostSettingsRedirect(page: Page): Promise<void> {
|
||||
@@ -449,7 +449,7 @@ export async function expectAboutContent(page: Page): Promise<void> {
|
||||
}
|
||||
|
||||
export async function expectGeneralContent(page: Page): Promise<void> {
|
||||
await expect(page.getByText("Default send", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("Language", { exact: true }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectAppearanceContent(page: Page): Promise<void> {
|
||||
@@ -474,14 +474,7 @@ export async function expectHostLabelEditMode(page: Page, expectedLabel: string)
|
||||
export async function expectHostConnectionsCard(page: Page, port: string): Promise<void> {
|
||||
const card = page.getByTestId("host-page-connections-card");
|
||||
await expect(card).toBeVisible();
|
||||
// "Connections" appears three times on this page: the sidebar section row, the
|
||||
// detail header title, and the SettingsSection heading above the card. Match
|
||||
// the first to keep the heading assertion without tripping Playwright strict
|
||||
// mode.
|
||||
await expect(page.getByText("Connections", { exact: true }).first()).toBeVisible();
|
||||
await expect(
|
||||
card.getByText(new RegExp(`TCP \\((localhost|127\\.0\\.0\\.1):${port}\\)`)),
|
||||
).toBeVisible();
|
||||
await expect(card.getByText(new RegExp(`(localhost|127\\.0\\.0\\.1):${port}`))).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectHostInjectMcpCard(page: Page): Promise<void> {
|
||||
@@ -518,11 +511,11 @@ export async function openHostSection(
|
||||
}
|
||||
|
||||
export async function expectHostActionCards(page: Page, serverId: string): Promise<void> {
|
||||
// Restart + remove cards live on the Host section; providers moved to its
|
||||
// own Providers section (asserted via expectHostProvidersCard).
|
||||
await openSettingsHostSection(page, serverId, "host");
|
||||
// Restart lives on Daemon; removing the saved host lives on This device -> Hosts.
|
||||
await openSettingsHostSection(page, serverId, "daemon");
|
||||
await expect(page.getByTestId("host-page-restart-card")).toBeVisible();
|
||||
await expect(page.getByTestId("host-page-restart-button")).toBeVisible();
|
||||
await openClientHostSettings(page, serverId);
|
||||
await expect(page.getByTestId("host-page-remove-host-card")).toBeVisible();
|
||||
await expect(page.getByTestId("host-page-remove-host-button")).toBeVisible();
|
||||
}
|
||||
@@ -641,27 +634,30 @@ export async function expectRetiredSidebarSectionsAbsent(page: Page): Promise<vo
|
||||
const sidebar = page.getByTestId("settings-sidebar");
|
||||
await expect(sidebar).toBeVisible();
|
||||
|
||||
// App group rows remain top-level.
|
||||
// App group ("This device") rows remain top-level.
|
||||
await expect(sidebar.getByRole("button", { name: "General", exact: true })).toBeVisible();
|
||||
await expect(sidebar.getByRole("button", { name: "Diagnostics", exact: true })).toBeVisible();
|
||||
await expect(sidebar.getByRole("button", { name: "Hosts", exact: true })).toBeVisible();
|
||||
await expect(sidebar.getByRole("button", { name: "About", exact: true })).toBeVisible();
|
||||
await expect(sidebar.getByRole("button", { name: "Daemon", exact: true })).toHaveCount(0);
|
||||
await expect(sidebar.getByRole("button", { name: "Diagnostics", exact: true })).toHaveCount(0);
|
||||
|
||||
// Host group rows are now flat top-level sections (no drill-in).
|
||||
await expect(sidebar.getByTestId("settings-host-section-connections")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-projects")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-agents")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-workspaces")).toBeVisible();
|
||||
// Host group rows are daemon-scoped flat top-level sections.
|
||||
await expect(sidebar.getByTestId("settings-host-section-providers")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-agent-profiles")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-tools")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-projects")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-workspaces")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-usage")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-host")).toBeVisible();
|
||||
await expect(sidebar.getByTestId("settings-host-section-daemon")).toBeVisible();
|
||||
|
||||
// The old per-host entry rows are replaced by the host picker.
|
||||
// Retired host rows and old per-host entry rows are absent.
|
||||
await expect(sidebar.getByTestId("settings-host-section-connections")).toHaveCount(0);
|
||||
await expect(sidebar.getByTestId("settings-host-section-agents")).toHaveCount(0);
|
||||
await expect(sidebar.getByTestId("settings-host-section-metadata")).toHaveCount(0);
|
||||
await expect(sidebar.locator('[data-testid^="settings-host-entry-"]')).toHaveCount(0);
|
||||
}
|
||||
|
||||
export async function expectHostPageVisible(page: Page, _serverId: string): Promise<void> {
|
||||
await expect(page.getByTestId("host-page-connections-card")).toBeVisible();
|
||||
await expect(page.getByTestId("host-page-identity")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectLocalHostEntryFirst(page: Page, _serverId: string): Promise<void> {
|
||||
@@ -697,7 +693,7 @@ export async function expectNoHostPasswordControls(page: Page): Promise<void> {
|
||||
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/${serverId}`));
|
||||
await expect(page).not.toHaveURL(new RegExp(`/settings/(hosts|device-hosts)/${serverId}`));
|
||||
}
|
||||
|
||||
export async function expectHostOnlineWithoutError(page: Page): Promise<void> {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { once } from "node:events";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
import { killProcessTree, spawnTsx } from "./spawn-node";
|
||||
|
||||
const readySchema = z.object({ port: z.number(), serverId: z.string() });
|
||||
const ackSchema = z.object({ type: z.literal("tailscale-available-set"), available: z.boolean() });
|
||||
|
||||
export async function startTailscaleTestDaemon(
|
||||
origin: string,
|
||||
options?: { initialAvailable?: boolean },
|
||||
) {
|
||||
const entrypoint = path.resolve(
|
||||
__dirname,
|
||||
"../../../../server/src/server/test-utils/tailscale-daemon.ts",
|
||||
);
|
||||
const initialMode = options?.initialAvailable === false ? "unavailable" : "available";
|
||||
const child = spawnTsx(entrypoint, [origin, initialMode], {
|
||||
stdio: ["ignore", "inherit", "inherit", "ipc"],
|
||||
});
|
||||
const signal = AbortSignal.timeout(30_000);
|
||||
try {
|
||||
const ready = await Promise.race([
|
||||
once(child, "message", { signal }).then(([message]) => readySchema.parse(message)),
|
||||
once(child, "exit", { signal }).then(([code]) => {
|
||||
throw new Error(`Tailscale test daemon exited before startup with code ${code}`);
|
||||
}),
|
||||
]);
|
||||
return {
|
||||
...ready,
|
||||
tailscaleAddress: `127.0.0.2:${ready.port}`,
|
||||
async setTailscaleAvailable(available: boolean): Promise<void> {
|
||||
const ack = once(child, "message", { signal: AbortSignal.timeout(10_000) }).then(
|
||||
([message]) => ackSchema.parse(message),
|
||||
);
|
||||
child.send({ type: "set-tailscale-available", available });
|
||||
const result = await ack;
|
||||
if (result.available !== available) {
|
||||
throw new Error(`Expected tailscaleAvailable=${String(available)}`);
|
||||
}
|
||||
},
|
||||
close: () => killProcessTree(child),
|
||||
};
|
||||
} catch (error) {
|
||||
await killProcessTree(child);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.6",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
@@ -40,7 +40,7 @@
|
||||
"dev:ios": "npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo run:ios",
|
||||
"build:apk": "npm --prefix ../.. run build:apk",
|
||||
"build:apk:arm64": "npm --prefix ../.. run build:apk:arm64",
|
||||
"test:android": "expo prebuild --platform android --no-install && cd android && ./gradlew :paseo-native-trace:testReleaseUnitTest :paseo-hardware-keyboard:testReleaseUnitTest :react-native-enriched-markdown:testReleaseUnitTest --tests '*InlineCodeFormattingTest' --tests '*ListRenderingTest' --tests '*TaskListInteractionTest' --tests '*ListBlockquoteMeasurementTest' --tests '*BlockquoteCopyTest' --tests '*LongPressSelectionInterceptTest' --no-daemon --max-workers=2 -Dorg.gradle.parallel=false"
|
||||
"test:android": "expo prebuild --platform android --no-install && cd android && ./gradlew :paseo-native-trace:testReleaseUnitTest :paseo-hardware-keyboard:testReleaseUnitTest :react-native-enriched-markdown:testReleaseUnitTest --tests '*InlineCodeFormattingTest' --tests '*ListRenderingTest' --tests '*TaskListInteractionTest' --tests '*ListBlockquoteMeasurementTest' --tests '*BlockquoteCopyTest' --tests '*CodeBlockCopyButtonConstructionTest' --tests '*LongPressSelectionInterceptTest' --no-daemon --max-workers=2 -Dorg.gradle.parallel=false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
|
||||
@@ -230,19 +230,22 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
|
||||
const hasMeasuredViewport =
|
||||
metrics.viewportMeasuredForKey === metrics.containerKey &&
|
||||
metrics.contentMeasuredForKey === metrics.containerKey;
|
||||
const geometry = nativeHistoryStartGeometry({
|
||||
contentHeight: metrics.contentHeight,
|
||||
viewportHeight: metrics.viewportHeight,
|
||||
offsetY: metrics.offsetY,
|
||||
topOverlayInset,
|
||||
});
|
||||
return {
|
||||
...nativeHistoryStartGeometry({
|
||||
contentHeight: metrics.contentHeight,
|
||||
viewportHeight: metrics.viewportHeight,
|
||||
offsetY: metrics.offsetY,
|
||||
topOverlayInset,
|
||||
}),
|
||||
...geometry,
|
||||
hasOlderHistory,
|
||||
isLoadingOlderHistory,
|
||||
// Reveal an already-filled measured viewport immediately; keep waiting on
|
||||
// rAF before auto-fetching older pages on underfilled views.
|
||||
isReady:
|
||||
isActive &&
|
||||
isAuthoritativeHistoryReady &&
|
||||
historyStartReadyRef.current &&
|
||||
(historyStartReadyRef.current || !geometry.isUnderfilled) &&
|
||||
hasMeasuredViewport,
|
||||
progressKey: olderHistoryProgressKey,
|
||||
};
|
||||
|
||||
@@ -503,18 +503,21 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool
|
||||
}
|
||||
const bottomAnchorSettled =
|
||||
!followOutputRef.current || isScrollContainerNearBottom(scrollContainer);
|
||||
const isUnderfilled =
|
||||
(rowsHostRef.current?.getBoundingClientRect().height ?? 0) +
|
||||
(auxiliaryRef.current?.getBoundingClientRect().height ?? 0) <
|
||||
scrollContainer.clientHeight;
|
||||
return {
|
||||
distanceFromHistoryStart: scrollContainer.scrollTop,
|
||||
isUnderfilled:
|
||||
(rowsHostRef.current?.getBoundingClientRect().height ?? 0) +
|
||||
(auxiliaryRef.current?.getBoundingClientRect().height ?? 0) <
|
||||
scrollContainer.clientHeight,
|
||||
isUnderfilled,
|
||||
hasOlderHistory,
|
||||
isLoadingOlderHistory,
|
||||
// An explicit jump owns the landing position. Revealing another local
|
||||
// page here changes the virtual index before the target has mounted.
|
||||
// Reveal an already-filled viewport during initial layout before paint;
|
||||
// still wait for rAF before auto-fetching older pages on underfilled views.
|
||||
isReady:
|
||||
historyStartReadyRef.current &&
|
||||
(historyStartReadyRef.current || !isUnderfilled) &&
|
||||
isAuthoritativeHistoryReady &&
|
||||
bottomAnchorSettled &&
|
||||
!isJumpSettling(),
|
||||
|
||||
@@ -925,12 +925,14 @@ function RootStack() {
|
||||
<Stack.Screen name="welcome" />
|
||||
<Stack.Screen name="settings/index" />
|
||||
<Stack.Screen name="settings/[section]" />
|
||||
<Stack.Screen name="settings/hosts/index" />
|
||||
<Stack.Screen name="new" />
|
||||
<Stack.Screen name="open-project" />
|
||||
<Stack.Screen name="sessions" />
|
||||
<Stack.Screen name="schedules" />
|
||||
</Stack.Protected>
|
||||
<Stack.Screen name="h/[serverId]" />
|
||||
<Stack.Screen name="settings/device-hosts/[serverId]" />
|
||||
<Stack.Screen name="settings/hosts/[serverId]/index" />
|
||||
<Stack.Screen name="settings/hosts/[serverId]/[hostSection]" />
|
||||
<Stack.Screen name="settings/hosts/[serverId]/plugins/[pluginId]/index" />
|
||||
|
||||
@@ -9,7 +9,9 @@ import { StartupSplashScreen } from "@/screens/startup-splash-screen";
|
||||
import {
|
||||
buildSettingsHostSectionRoute,
|
||||
buildSettingsRoute,
|
||||
buildSettingsSectionRoute,
|
||||
isSettingsSectionSlug,
|
||||
normalizeSettingsSectionSlug,
|
||||
type SettingsSectionSlug,
|
||||
} from "@/utils/host-routes";
|
||||
|
||||
@@ -28,7 +30,7 @@ function SettingsDaemonRedirect() {
|
||||
localDaemon.serverId !== null &&
|
||||
hosts.some((host) => host.serverId === localDaemon.serverId)
|
||||
) {
|
||||
return <Redirect href={buildSettingsHostSectionRoute(localDaemon.serverId, "host")} />;
|
||||
return <Redirect href={buildSettingsHostSectionRoute(localDaemon.serverId, "daemon")} />;
|
||||
}
|
||||
|
||||
return <Redirect href={buildSettingsRoute()} />;
|
||||
@@ -37,7 +39,8 @@ function SettingsDaemonRedirect() {
|
||||
export default function SettingsSectionRoute() {
|
||||
const params = useLocalSearchParams<{ section?: string }>();
|
||||
const rawSection = typeof params.section === "string" ? params.section : "";
|
||||
const section: SettingsSectionSlug = isSettingsSectionSlug(rawSection) ? rawSection : "general";
|
||||
const normalized = normalizeSettingsSectionSlug(rawSection);
|
||||
const section: SettingsSectionSlug = normalized ?? "general";
|
||||
const view = useMemo(() => ({ kind: "section" as const, section }), [section]);
|
||||
|
||||
// COMPAT(settingsDaemonRedirect): added 2026-07-08, remove after 2027-01-08.
|
||||
@@ -49,5 +52,9 @@ export default function SettingsSectionRoute() {
|
||||
);
|
||||
}
|
||||
|
||||
if (normalized && !isSettingsSectionSlug(rawSection)) {
|
||||
return <Redirect href={buildSettingsSectionRoute(normalized)} />;
|
||||
}
|
||||
|
||||
return <SettingsScreen view={view} />;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Redirect, useLocalSearchParams } from "expo-router";
|
||||
import { useMemo } from "react";
|
||||
import { HostRouteBootstrapBoundary } from "@/components/host-route-bootstrap-boundary";
|
||||
import SettingsScreen from "@/screens/settings-screen";
|
||||
import { buildSettingsSectionRoute } from "@/utils/host-routes";
|
||||
|
||||
export default function SettingsDeviceHostDetailRoute() {
|
||||
const params = useLocalSearchParams<{ serverId?: string }>();
|
||||
const serverId = typeof params.serverId === "string" ? params.serverId.trim() : "";
|
||||
const view = useMemo(() => ({ kind: "clientHost" as const, serverId }), [serverId]);
|
||||
|
||||
if (!serverId) {
|
||||
return <Redirect href={buildSettingsSectionRoute("hosts")} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<HostRouteBootstrapBoundary>
|
||||
<SettingsScreen view={view} />
|
||||
</HostRouteBootstrapBoundary>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,30 @@
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { Redirect, useLocalSearchParams } from "expo-router";
|
||||
import { useMemo } from "react";
|
||||
import { HostRouteBootstrapBoundary } from "@/components/host-route-bootstrap-boundary";
|
||||
import SettingsScreen from "@/screens/settings-screen";
|
||||
import { normalizeHostSectionSlug } from "@/utils/host-routes";
|
||||
import {
|
||||
buildClientHostSettingsRoute,
|
||||
buildSettingsHostSectionRoute,
|
||||
isHostSectionSlug,
|
||||
normalizeHostSectionSlug,
|
||||
} from "@/utils/host-routes";
|
||||
|
||||
export default function SettingsHostSectionRoute() {
|
||||
const params = useLocalSearchParams<{ serverId?: string; hostSection?: string }>();
|
||||
const serverId = typeof params.serverId === "string" ? params.serverId.trim() : "";
|
||||
const rawSection = typeof params.hostSection === "string" ? params.hostSection : "";
|
||||
const section = normalizeHostSectionSlug(rawSection) ?? "connections";
|
||||
const normalized = normalizeHostSectionSlug(rawSection);
|
||||
const section = normalized ?? "daemon";
|
||||
const view = useMemo(() => ({ kind: "host" as const, serverId, section }), [serverId, section]);
|
||||
|
||||
if (rawSection === "connections" && serverId) {
|
||||
return <Redirect href={buildClientHostSettingsRoute(serverId)} />;
|
||||
}
|
||||
|
||||
if (normalized && !isHostSectionSlug(rawSection) && serverId) {
|
||||
return <Redirect href={buildSettingsHostSectionRoute(serverId, normalized)} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<HostRouteBootstrapBoundary>
|
||||
<SettingsScreen view={view} />
|
||||
|
||||
@@ -9,5 +9,5 @@ export default function SettingsHostIndexRoute() {
|
||||
return <Redirect href={buildSettingsRoute()} />;
|
||||
}
|
||||
|
||||
return <Redirect href={buildSettingsHostSectionRoute(serverId, "connections")} />;
|
||||
return <Redirect href={buildSettingsHostSectionRoute(serverId, "daemon")} />;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import SettingsScreen from "@/screens/settings-screen";
|
||||
|
||||
const HOSTS_VIEW = { kind: "section" as const, section: "hosts" as const };
|
||||
|
||||
export default function SettingsHostsSectionRoute() {
|
||||
return <SettingsScreen view={HOSTS_VIEW} />;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { ScrollView } from "@/components/ui/scroll-view";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import type { EditingTextInputHandle } from "@/components/ui/text-input";
|
||||
import { AdaptiveTextInput } from "@/components/adaptive-text-input";
|
||||
import { useDismissibleOverlay } from "@/components/ui/overlay-dismissal";
|
||||
import { DismissBackdrop } from "@/components/ui/dismiss-backdrop";
|
||||
@@ -55,6 +56,7 @@ export interface SheetHeaderSearch {
|
||||
resetKey?: string | number;
|
||||
placeholder?: string;
|
||||
autoFocus?: boolean;
|
||||
inputRef?: React.RefObject<EditingTextInputHandle | null>;
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
@@ -489,6 +491,7 @@ export function SheetHeaderView({
|
||||
<View style={styles.searchRow}>
|
||||
<Search size={theme.iconSize.md} color={theme.colors.foregroundMuted} />
|
||||
<AdaptiveTextInput
|
||||
ref={search.inputRef}
|
||||
// @ts-expect-error - outlineStyle is web-only
|
||||
style={[styles.searchInput, isWeb && { outlineStyle: "none" }]}
|
||||
placeholder={search.placeholder ?? t("common.actions.search")}
|
||||
@@ -530,6 +533,7 @@ export function InlineHeaderView({ header }: { header: SheetHeader }) {
|
||||
<View style={styles.inlineSearchRow}>
|
||||
<Search size={theme.iconSize.sm} color={theme.colors.foregroundMuted} />
|
||||
<AdaptiveTextInput
|
||||
ref={header.search.inputRef}
|
||||
// @ts-expect-error - outlineStyle is web-only
|
||||
style={[styles.searchInput, isWeb && { outlineStyle: "none" }]}
|
||||
placeholder={header.search.placeholder ?? t("common.actions.search")}
|
||||
|
||||
@@ -1,55 +1,144 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
import { View, Text } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { ArchiveRestore } from "lucide-react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail";
|
||||
import { FOOTER_HEIGHT } from "@/constants/layout";
|
||||
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import { useUnarchiveAgent } from "@/hooks/use-unarchive-agent";
|
||||
import { KeyboardTranslateView } from "@/keyboard/shift";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CONTROL_HEIGHTS } from "@/components/ui/control-geometry";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { toErrorMessage } from "@/utils/error-messages";
|
||||
|
||||
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
||||
const foregroundMutedColorMapping = (theme: Theme) => ({
|
||||
color: theme.colors.foregroundMuted,
|
||||
});
|
||||
|
||||
interface ArchivedAgentCalloutProps {
|
||||
serverId: string;
|
||||
agentId: string;
|
||||
/** True while the owning workspace's archive undo is restoring this agent. */
|
||||
isWorkspaceRestoring?: boolean;
|
||||
}
|
||||
|
||||
export function ArchivedAgentCallout({ serverId, agentId }: ArchivedAgentCalloutProps) {
|
||||
export function deliverUnarchiveError(input: {
|
||||
error: unknown;
|
||||
attemptKey: string;
|
||||
isMounted: boolean;
|
||||
currentTargetKey: string;
|
||||
onInlineError: (state: { targetKey: string; message: string }) => void;
|
||||
onToastError: (message: string) => void;
|
||||
}): void {
|
||||
const message = toErrorMessage(input.error);
|
||||
if (input.isMounted && input.currentTargetKey === input.attemptKey) {
|
||||
input.onInlineError({ targetKey: input.attemptKey, message });
|
||||
} else {
|
||||
input.onToastError(message);
|
||||
}
|
||||
}
|
||||
|
||||
function ArchivedCalloutRow({
|
||||
isShowingUnarchiving,
|
||||
canUnarchive,
|
||||
onUnarchive,
|
||||
}: {
|
||||
isShowingUnarchiving: boolean;
|
||||
canUnarchive: boolean;
|
||||
onUnarchive: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const isConnected = useHostRuntimeIsConnected(serverId);
|
||||
const [isUnarchiving, setIsUnarchiving] = useState(false);
|
||||
const [unarchiveError, setUnarchiveError] = useState<string | null>(null);
|
||||
return (
|
||||
<View style={styles.calloutRow}>
|
||||
{isShowingUnarchiving ? (
|
||||
<>
|
||||
<ThemedLoadingSpinner size={14} uniProps={foregroundMutedColorMapping} />
|
||||
<Text style={styles.calloutText}>{t("agentPanel.archived.unarchiving")}</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Text style={styles.calloutText}>{t("agentPanel.archived.callout")}</Text>
|
||||
<Button
|
||||
variant="secondary"
|
||||
leftIcon={ArchiveRestore}
|
||||
onPress={onUnarchive}
|
||||
disabled={!canUnarchive}
|
||||
>
|
||||
{t("agentPanel.archived.unarchive")}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function ArchivedAgentCallout({
|
||||
serverId,
|
||||
agentId,
|
||||
isWorkspaceRestoring = false,
|
||||
}: ArchivedAgentCalloutProps) {
|
||||
const targetKey = `${serverId}:${agentId}`;
|
||||
const toast = useToast();
|
||||
const { unarchive, isUnarchiving, canUnarchive } = useUnarchiveAgent({ serverId, agentId });
|
||||
const isShowingUnarchiving = isWorkspaceRestoring || isUnarchiving;
|
||||
const [unarchiveErrorState, setUnarchiveErrorState] = useState<{
|
||||
targetKey: string;
|
||||
message: string;
|
||||
} | null>(null);
|
||||
const unarchiveError =
|
||||
unarchiveErrorState?.targetKey === targetKey ? unarchiveErrorState.message : null;
|
||||
const isMountedRef = useRef(true);
|
||||
const targetKeyRef = useRef(targetKey);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
targetKeyRef.current = targetKey;
|
||||
}, [targetKey]);
|
||||
|
||||
useEffect(() => {
|
||||
isMountedRef.current = true;
|
||||
return () => {
|
||||
isMountedRef.current = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleUnarchive = useCallback(async () => {
|
||||
if (!client || !isConnected || isUnarchiving) return;
|
||||
setIsUnarchiving(true);
|
||||
setUnarchiveError(null);
|
||||
if (!canUnarchive) return;
|
||||
const attemptKey = targetKey;
|
||||
setUnarchiveErrorState(null);
|
||||
try {
|
||||
await client.refreshAgent(agentId);
|
||||
await unarchive();
|
||||
} catch (error) {
|
||||
setUnarchiveError(toErrorMessage(error));
|
||||
setIsUnarchiving(false);
|
||||
deliverUnarchiveError({
|
||||
error,
|
||||
attemptKey,
|
||||
isMounted: isMountedRef.current,
|
||||
currentTargetKey: targetKeyRef.current,
|
||||
onInlineError: setUnarchiveErrorState,
|
||||
onToastError: toast.error,
|
||||
});
|
||||
}
|
||||
}, [client, isConnected, isUnarchiving, agentId]);
|
||||
}, [canUnarchive, targetKey, toast, unarchive]);
|
||||
|
||||
return (
|
||||
<KeyboardTranslateView style={styles.container}>
|
||||
<View style={styles.inputAreaContainer} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.inputAreaContent}>
|
||||
<View style={styles.calloutStack}>
|
||||
<View style={styles.callout}>
|
||||
<Text style={styles.calloutText}>{t("agentPanel.archived.callout")}</Text>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onPress={handleUnarchive}
|
||||
disabled={!isConnected || isUnarchiving}
|
||||
>
|
||||
{t("agentPanel.archived.unarchive")}
|
||||
</Button>
|
||||
<View
|
||||
style={styles.callout}
|
||||
testID={isShowingUnarchiving ? "agent-unarchiving-callout" : "agent-archived-callout"}
|
||||
>
|
||||
<ArchivedCalloutRow
|
||||
isShowingUnarchiving={isShowingUnarchiving}
|
||||
canUnarchive={canUnarchive}
|
||||
onUnarchive={handleUnarchive}
|
||||
/>
|
||||
</View>
|
||||
{unarchiveError ? (
|
||||
{!isShowingUnarchiving && unarchiveError ? (
|
||||
<Text style={styles.errorText} testID="agent-unarchive-error">
|
||||
{unarchiveError}
|
||||
</Text>
|
||||
@@ -80,10 +169,6 @@ const styles = StyleSheet.create((theme: Theme) => ({
|
||||
maxWidth: theme.contentMaxWidth,
|
||||
},
|
||||
callout: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: theme.spacing[3],
|
||||
backgroundColor: theme.colors.surface1,
|
||||
borderWidth: theme.borderWidth[1],
|
||||
borderColor: theme.colors.borderAccent,
|
||||
@@ -97,10 +182,18 @@ const styles = StyleSheet.create((theme: Theme) => ({
|
||||
md: theme.spacing[6],
|
||||
},
|
||||
},
|
||||
calloutRow: {
|
||||
minHeight: CONTROL_HEIGHTS.md,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: theme.spacing[3],
|
||||
},
|
||||
calloutStack: {
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
calloutText: {
|
||||
flexShrink: 1,
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
|
||||
@@ -307,6 +307,7 @@ export function CombinedModelSelector({
|
||||
desktopFixedHeight={browser.desktopFixedHeight}
|
||||
desktopChildrenScrollEnabled={false}
|
||||
header={browser.header}
|
||||
keyboard={browser.keyboard}
|
||||
mobileChildrenScrollEnabled={!browser.isProviderView || !isNative}
|
||||
mobileChildrenContentContainerStyle={styles.mobileBrowserContent}
|
||||
>
|
||||
|
||||
@@ -227,7 +227,7 @@ export const LeftSidebar = memo(function LeftSidebar({
|
||||
openSettingsFromSidebar({
|
||||
workspace: activeWorkspace,
|
||||
isCompact: isCompactLayout,
|
||||
route: buildSettingsHostSectionRoute(serverId, "host"),
|
||||
route: buildSettingsHostSectionRoute(serverId, "daemon"),
|
||||
});
|
||||
},
|
||||
[activeWorkspace, isCompactLayout],
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/** Native moves no focus to buttons from a hardware keyboard, so Enter always reaches the picker. */
|
||||
export function focusedModelBrowserControlOwnsEnter(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Native fires focus on rows only for a hardware keyboard or a TV remote. */
|
||||
export function focusCameFromKeyboard(_target: unknown): boolean {
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
const ACTIVATES_ON_ENTER =
|
||||
'button, a[href], [role="button"], [role="link"], [role="tab"], [role="combobox"], [role="menuitem"]';
|
||||
|
||||
/**
|
||||
* Whether the focused element handles Enter itself (Back, Provider settings, Edit profiles,
|
||||
* Close, Retry, or a model row's sibling profile action button). Navigable rows carry
|
||||
* `data-model-browser-row="true"` and sync `activeKey` on focus, so Enter runs the active row
|
||||
* action even after arrowing away from a Tab-focused row.
|
||||
*/
|
||||
export function focusedModelBrowserControlOwnsEnter(): boolean {
|
||||
const active = document.activeElement;
|
||||
if (!(active instanceof HTMLElement)) return false;
|
||||
if (active.closest('[data-model-browser-row="true"]')) return false;
|
||||
return active.matches(ACTIVATES_ON_ENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointer press also focuses the row it lands on. Only keyboard focus marks a row
|
||||
* active, so the press does not scroll the list to that row before the button is released.
|
||||
*/
|
||||
export function focusCameFromKeyboard(target: unknown): boolean {
|
||||
return target instanceof Element && target.matches(":focus-visible");
|
||||
}
|
||||
@@ -4,10 +4,19 @@ import type {
|
||||
ProviderSelectorProvider,
|
||||
} from "@/provider-selection/provider-selection";
|
||||
import {
|
||||
resolveInitialModelBrowserView,
|
||||
resolveModelBrowserAllView,
|
||||
MODEL_BROWSER_CREATE_PROFILE_KEY,
|
||||
filterAndRankProfileRows,
|
||||
groupProfilesByProviderModel,
|
||||
modelBrowserModelKey,
|
||||
modelBrowserProfileKey,
|
||||
modelBrowserProviderKey,
|
||||
moveModelBrowserActiveKey,
|
||||
resolveActiveModelBrowserKey,
|
||||
resolveInitialModelBrowserView,
|
||||
resolveModelBrowserAllView,
|
||||
resolveModelBrowserKeyCommand,
|
||||
resolveModelBrowserNavItems,
|
||||
resolveModelBrowserProjection,
|
||||
resolveModelBrowserScrolling,
|
||||
} from "./model-browser-view";
|
||||
|
||||
@@ -283,3 +292,486 @@ describe("model browser profile search", () => {
|
||||
expect(filterAndRankProfileRows(profiles, "")).toEqual(profiles);
|
||||
});
|
||||
});
|
||||
|
||||
describe("model browser keyboard navigation", () => {
|
||||
const claude = provider("claude", "Claude Code", [
|
||||
modelRow("claude", "Claude Code", "opus-5", "Opus 5"),
|
||||
modelRow("claude", "Claude Code", "sonnet-4.6", "Sonnet 4.6"),
|
||||
]);
|
||||
const codex = provider("codex", "Codex", [modelRow("codex", "Codex", "gpt-5.4", "GPT-5.4")]);
|
||||
const providers = [claude, codex];
|
||||
const reviewer = {
|
||||
id: "reviewer",
|
||||
provider: "claude",
|
||||
name: "Reviewer",
|
||||
summary: "Claude Code · Opus 5 · Plan",
|
||||
};
|
||||
const quick = {
|
||||
id: "quick",
|
||||
provider: "codex",
|
||||
name: "Quick fix",
|
||||
summary: "Codex · GPT-5.4",
|
||||
};
|
||||
const profiles = [reviewer, quick];
|
||||
|
||||
it("orders profiles before providers on the root browse view", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(items.map((item) => item.key)).toEqual([
|
||||
modelBrowserProfileKey("reviewer"),
|
||||
modelBrowserProfileKey("quick"),
|
||||
modelBrowserProviderKey("claude"),
|
||||
modelBrowserProviderKey("codex"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("includes Create profile before providers when profiles are empty and editable", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles: [],
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(items.map((item) => item.key)).toEqual([
|
||||
MODEL_BROWSER_CREATE_PROFILE_KEY,
|
||||
modelBrowserProviderKey("claude"),
|
||||
modelBrowserProviderKey("codex"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("omits providers when custom root browse content replaces them", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: true,
|
||||
});
|
||||
|
||||
expect(items.map((item) => item.key)).toEqual([
|
||||
modelBrowserProfileKey("reviewer"),
|
||||
modelBrowserProfileKey("quick"),
|
||||
]);
|
||||
});
|
||||
|
||||
it("orders matching profiles before matching models with model indexes in search results", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "opus",
|
||||
isSearchFocused: true,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(items).toEqual([
|
||||
{ key: modelBrowserProfileKey("reviewer"), kind: "profile", profileId: "reviewer" },
|
||||
{
|
||||
key: modelBrowserModelKey("claude:opus-5"),
|
||||
kind: "model",
|
||||
provider: "claude",
|
||||
modelId: "opus-5",
|
||||
modelIndex: 0,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("orders provider profiles before models inside a provider view and skips loading providers", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "provider", providerId: "claude", providerLabel: "Claude Code" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(items.map((item) => item.key)).toEqual([
|
||||
modelBrowserProfileKey("reviewer"),
|
||||
modelBrowserModelKey("claude:opus-5"),
|
||||
modelBrowserModelKey("claude:sonnet-4.6"),
|
||||
]);
|
||||
|
||||
const loadingItems = resolveModelBrowserNavItems({
|
||||
view: { kind: "provider", providerId: "pi", providerLabel: "Pi" },
|
||||
providers: [{ id: "pi", label: "Pi", modelSelection: { kind: "loading" } }],
|
||||
profiles: null,
|
||||
showProfilesSection: false,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
expect(loadingItems).toEqual([]);
|
||||
});
|
||||
|
||||
it("highlights the selected model in an unfiltered provider view and resets to first match on search", () => {
|
||||
const view = { kind: "provider", providerId: "claude", providerLabel: "Claude Code" } as const;
|
||||
const unfilteredItems = resolveModelBrowserNavItems({
|
||||
view,
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveActiveModelBrowserKey({
|
||||
explicitActiveKey: null,
|
||||
items: unfilteredItems,
|
||||
view,
|
||||
normalizedQuery: "",
|
||||
selectedProvider: "claude",
|
||||
selectedModel: "sonnet-4.6",
|
||||
}),
|
||||
).toBe(modelBrowserModelKey("claude:sonnet-4.6"));
|
||||
|
||||
expect(
|
||||
resolveActiveModelBrowserKey({
|
||||
explicitActiveKey: null,
|
||||
items: unfilteredItems,
|
||||
view,
|
||||
normalizedQuery: "opus",
|
||||
selectedProvider: "claude",
|
||||
selectedModel: "sonnet-4.6",
|
||||
}),
|
||||
).toBe(modelBrowserProfileKey("reviewer"));
|
||||
});
|
||||
|
||||
it("restores preferred provider highlight when returning to the root view", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveActiveModelBrowserKey({
|
||||
explicitActiveKey: null,
|
||||
items,
|
||||
view: { kind: "all" },
|
||||
normalizedQuery: "",
|
||||
selectedProvider: "codex",
|
||||
selectedModel: "gpt-5.4",
|
||||
preferredKey: modelBrowserProviderKey("codex"),
|
||||
}),
|
||||
).toBe(modelBrowserProviderKey("codex"));
|
||||
});
|
||||
|
||||
it("omits initial highlight when suppressed on native touch until an arrow key moves selection", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveActiveModelBrowserKey({
|
||||
explicitActiveKey: null,
|
||||
items,
|
||||
view: { kind: "all" },
|
||||
normalizedQuery: "",
|
||||
selectedProvider: "claude",
|
||||
selectedModel: "opus-5",
|
||||
suppressInitialActive: true,
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
const firstMove = moveModelBrowserActiveKey({ items, activeKey: null, key: "ArrowDown" });
|
||||
expect(firstMove).toBe(modelBrowserProfileKey("reviewer"));
|
||||
expect(
|
||||
resolveActiveModelBrowserKey({
|
||||
explicitActiveKey: firstMove,
|
||||
items,
|
||||
view: { kind: "all" },
|
||||
normalizedQuery: "",
|
||||
selectedProvider: "claude",
|
||||
selectedModel: "opus-5",
|
||||
suppressInitialActive: true,
|
||||
}),
|
||||
).toBe(modelBrowserProfileKey("reviewer"));
|
||||
|
||||
expect(moveModelBrowserActiveKey({ items, activeKey: null, key: "ArrowUp" })).toBe(
|
||||
modelBrowserProviderKey("codex"),
|
||||
);
|
||||
});
|
||||
|
||||
it("projects rendered sections and keyboard nav items from a single model", () => {
|
||||
const browse = resolveModelBrowserProjection({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
expect(browse.kind).toBe("browse");
|
||||
if (browse.kind === "browse") {
|
||||
expect(browse.profileSection).toEqual({ kind: "profiles", rows: profiles });
|
||||
expect(browse.providers.map((entry) => entry.id)).toEqual(["claude", "codex"]);
|
||||
expect(browse.showProvidersHeading).toBe(true);
|
||||
expect(browse.isEmpty).toBe(false);
|
||||
expect(browse.navItems.map((item) => item.key)).toEqual([
|
||||
modelBrowserProfileKey("reviewer"),
|
||||
modelBrowserProfileKey("quick"),
|
||||
modelBrowserProviderKey("claude"),
|
||||
modelBrowserProviderKey("codex"),
|
||||
]);
|
||||
}
|
||||
|
||||
const providerSearch = resolveModelBrowserProjection({
|
||||
view: { kind: "provider", providerId: "claude", providerLabel: "Claude Code" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "opus",
|
||||
isSearchFocused: true,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
expect(providerSearch.kind).toBe("modelList");
|
||||
if (providerSearch.kind === "modelList") {
|
||||
expect(providerSearch.showProviderLabel).toBe(false);
|
||||
expect(providerSearch.profileSection).toEqual({
|
||||
kind: "searchProfiles",
|
||||
rows: [reviewer],
|
||||
showModelsHeading: true,
|
||||
});
|
||||
expect(providerSearch.modelRows.map((row) => row.modelId)).toEqual(["opus-5"]);
|
||||
expect(providerSearch.navItems.map((item) => item.key)).toEqual([
|
||||
modelBrowserProfileKey("reviewer"),
|
||||
modelBrowserModelKey("claude:opus-5"),
|
||||
]);
|
||||
}
|
||||
|
||||
expect(
|
||||
resolveModelBrowserProjection({
|
||||
view: { kind: "provider", providerId: "pi", providerLabel: "Pi" },
|
||||
providers: [{ id: "pi", label: "Pi", modelSelection: { kind: "error", message: "boom" } }],
|
||||
profiles: null,
|
||||
showProfilesSection: false,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "providerError",
|
||||
providerId: "pi",
|
||||
message: "boom",
|
||||
navItems: [],
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveModelBrowserProjection({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: true,
|
||||
normalizedQuery: "zzzz",
|
||||
isSearchFocused: true,
|
||||
hasCustomRootBrowseContent: false,
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "noSearchMatches",
|
||||
navItems: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("wraps active key movement across all items", () => {
|
||||
const items = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles: [reviewer],
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
moveModelBrowserActiveKey({
|
||||
items,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
key: "ArrowUp",
|
||||
}),
|
||||
).toBe(modelBrowserProviderKey("codex"));
|
||||
|
||||
expect(
|
||||
moveModelBrowserActiveKey({
|
||||
items,
|
||||
activeKey: modelBrowserProviderKey("codex"),
|
||||
key: "ArrowDown",
|
||||
}),
|
||||
).toBe(modelBrowserProfileKey("reviewer"));
|
||||
});
|
||||
|
||||
it("resolves arrow, enter, drill-down, and back commands while respecting text editing and focused controls", () => {
|
||||
const rootItems = resolveModelBrowserNavItems({
|
||||
view: { kind: "all" },
|
||||
providers,
|
||||
profiles: [reviewer],
|
||||
showProfilesSection: true,
|
||||
canCreateProfileRow: false,
|
||||
normalizedQuery: "",
|
||||
isSearchFocused: false,
|
||||
hasCustomRootBrowseContent: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "ArrowDown" },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toEqual({ kind: "move", nextKey: modelBrowserProviderKey("claude") });
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "ArrowDown", metaKey: true },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "ArrowRight" },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProviderKey("claude"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toEqual({ kind: "drillDown", providerId: "claude", providerLabel: "Claude Code" });
|
||||
|
||||
// ArrowRight stays with the search input when query text exists.
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "ArrowRight" },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProviderKey("claude"),
|
||||
searchQuery: "cl",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
// Enter yields when a secondary button (such as Back or Edit profiles) has DOM focus.
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "Enter" },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: true,
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "Enter" },
|
||||
view: { kind: "all" },
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "activate",
|
||||
item: { key: modelBrowserProfileKey("reviewer"), kind: "profile", profileId: "reviewer" },
|
||||
});
|
||||
|
||||
const providerView = {
|
||||
kind: "provider",
|
||||
providerId: "claude",
|
||||
providerLabel: "Claude Code",
|
||||
} as const;
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "ArrowLeft" },
|
||||
view: providerView,
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toEqual({ kind: "back", providerId: "claude" });
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "Backspace" },
|
||||
view: providerView,
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "o",
|
||||
canGoBack: true,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
expect(
|
||||
resolveModelBrowserKeyCommand({
|
||||
event: { key: "Backspace" },
|
||||
view: providerView,
|
||||
items: rootItems,
|
||||
activeKey: modelBrowserProfileKey("reviewer"),
|
||||
searchQuery: "",
|
||||
canGoBack: false,
|
||||
focusedControlOwnsEnter: false,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { compareMatchScores, scoreTextFields } from "@getpaseo/protocol/search/text-match";
|
||||
import { getNextActiveIndex } from "@/components/ui/combobox-keyboard";
|
||||
import {
|
||||
filterAndRankModelRows,
|
||||
getAllProviderModelRows,
|
||||
getProviderModelRows,
|
||||
type ProviderSelectionModelRow,
|
||||
type ProviderSelectorProvider,
|
||||
} from "@/provider-selection/provider-selection";
|
||||
@@ -135,3 +137,455 @@ export function resolveInitialModelBrowserView({
|
||||
|
||||
return { kind: "all" };
|
||||
}
|
||||
|
||||
export const MODEL_BROWSER_KEYBOARD_KEYS = [
|
||||
"ArrowDown",
|
||||
"ArrowUp",
|
||||
"ArrowRight",
|
||||
"ArrowLeft",
|
||||
"Backspace",
|
||||
"Enter",
|
||||
] as const;
|
||||
|
||||
export const MODEL_BROWSER_CREATE_PROFILE_KEY = "create-profile";
|
||||
|
||||
export function modelBrowserProfileKey(profileId: string): string {
|
||||
return `profile:${profileId}`;
|
||||
}
|
||||
|
||||
export function modelBrowserProviderKey(providerId: string): string {
|
||||
return `provider:${providerId}`;
|
||||
}
|
||||
|
||||
export function modelBrowserModelKey(favoriteKey: string): string {
|
||||
return `model:${favoriteKey}`;
|
||||
}
|
||||
|
||||
/** A profile row shape needed to build the ordered keyboard navigation list. */
|
||||
export interface NavigableProfileRow extends SearchableProfileRow {
|
||||
id: string;
|
||||
provider: string;
|
||||
}
|
||||
|
||||
export type ModelBrowserNavItem =
|
||||
| { key: string; kind: "profile"; profileId: string }
|
||||
| { key: typeof MODEL_BROWSER_CREATE_PROFILE_KEY; kind: "createProfile" }
|
||||
| { key: string; kind: "provider"; providerId: string; providerLabel: string }
|
||||
| { key: string; kind: "model"; provider: string; modelId: string; modelIndex: number };
|
||||
|
||||
export type ModelBrowserProfileSection<TProfile extends NavigableProfileRow = NavigableProfileRow> =
|
||||
| { kind: "none" }
|
||||
| { kind: "createProfile" }
|
||||
| { kind: "profiles"; rows: TProfile[] }
|
||||
| { kind: "searchProfiles"; rows: TProfile[]; showModelsHeading: boolean };
|
||||
|
||||
export type ModelBrowserProjection<TProfile extends NavigableProfileRow = NavigableProfileRow> =
|
||||
| { kind: "providerLoading"; navItems: ModelBrowserNavItem[] }
|
||||
| { kind: "providerError"; providerId: string; message: string; navItems: ModelBrowserNavItem[] }
|
||||
| { kind: "empty"; navItems: ModelBrowserNavItem[] }
|
||||
| { kind: "noSearchMatches"; navItems: ModelBrowserNavItem[] }
|
||||
| {
|
||||
kind: "modelList";
|
||||
profileSection: ModelBrowserProfileSection<TProfile>;
|
||||
modelRows: ProviderSelectionModelRow[];
|
||||
showProviderLabel: boolean;
|
||||
navItems: ModelBrowserNavItem[];
|
||||
}
|
||||
| {
|
||||
kind: "browse";
|
||||
profileSection: ModelBrowserProfileSection<TProfile>;
|
||||
providers: ProviderSelectorProvider[];
|
||||
showProvidersHeading: boolean;
|
||||
isEmpty: boolean;
|
||||
navItems: ModelBrowserNavItem[];
|
||||
};
|
||||
|
||||
export interface ModelBrowserProjectionInput<
|
||||
TProfile extends NavigableProfileRow = NavigableProfileRow,
|
||||
> {
|
||||
view: ModelBrowserView;
|
||||
providers: ProviderSelectorProvider[];
|
||||
profiles: readonly TProfile[] | null;
|
||||
showProfilesSection: boolean;
|
||||
canCreateProfileRow: boolean;
|
||||
normalizedQuery: string;
|
||||
isSearchFocused: boolean;
|
||||
hasCustomRootBrowseContent: boolean;
|
||||
}
|
||||
|
||||
function toProfileNavItems(rows: readonly NavigableProfileRow[]): ModelBrowserNavItem[] {
|
||||
return rows.map((row) => ({
|
||||
key: modelBrowserProfileKey(row.id),
|
||||
kind: "profile",
|
||||
profileId: row.id,
|
||||
}));
|
||||
}
|
||||
|
||||
function profileSectionToNavItems<TProfile extends NavigableProfileRow>(
|
||||
section: ModelBrowserProfileSection<TProfile>,
|
||||
): ModelBrowserNavItem[] {
|
||||
if (section.kind === "none") return [];
|
||||
if (section.kind === "createProfile") {
|
||||
return [{ key: MODEL_BROWSER_CREATE_PROFILE_KEY, kind: "createProfile" }];
|
||||
}
|
||||
return toProfileNavItems(section.rows);
|
||||
}
|
||||
|
||||
function resolveBrowseProfileSection<TProfile extends NavigableProfileRow>(
|
||||
rows: readonly TProfile[] | null,
|
||||
showProfilesSection: boolean,
|
||||
canCreateProfileRow: boolean,
|
||||
): ModelBrowserProfileSection<TProfile> {
|
||||
if (!showProfilesSection || rows === null) return { kind: "none" };
|
||||
if (rows.length > 0) return { kind: "profiles", rows: [...rows] };
|
||||
return canCreateProfileRow ? { kind: "createProfile" } : { kind: "none" };
|
||||
}
|
||||
|
||||
function resolveProviderProfileSection<TProfile extends NavigableProfileRow>({
|
||||
providerProfiles,
|
||||
showProfilesSection,
|
||||
canCreateProfileRow,
|
||||
normalizedQuery,
|
||||
hasModelRows,
|
||||
}: {
|
||||
providerProfiles: readonly TProfile[] | null;
|
||||
showProfilesSection: boolean;
|
||||
canCreateProfileRow: boolean;
|
||||
normalizedQuery: string;
|
||||
hasModelRows: boolean;
|
||||
}): ModelBrowserProfileSection<TProfile> {
|
||||
if (!showProfilesSection || providerProfiles === null) return { kind: "none" };
|
||||
if (normalizedQuery.length === 0) {
|
||||
return resolveBrowseProfileSection(providerProfiles, true, canCreateProfileRow);
|
||||
}
|
||||
const matched = filterAndRankProfileRows(providerProfiles, normalizedQuery);
|
||||
return matched.length > 0
|
||||
? { kind: "searchProfiles", rows: matched, showModelsHeading: hasModelRows }
|
||||
: { kind: "none" };
|
||||
}
|
||||
|
||||
function toProviderNavItems(providers: readonly ProviderSelectorProvider[]): ModelBrowserNavItem[] {
|
||||
return providers.map((provider) => ({
|
||||
key: modelBrowserProviderKey(provider.id),
|
||||
kind: "provider",
|
||||
providerId: provider.id,
|
||||
providerLabel: provider.label,
|
||||
}));
|
||||
}
|
||||
|
||||
function toModelNavItems(rows: readonly ProviderSelectionModelRow[]): ModelBrowserNavItem[] {
|
||||
return rows.map((row, modelIndex) => ({
|
||||
key: modelBrowserModelKey(row.favoriteKey),
|
||||
kind: "model",
|
||||
provider: row.provider,
|
||||
modelId: row.modelId,
|
||||
modelIndex,
|
||||
}));
|
||||
}
|
||||
|
||||
function resolveProviderProjection<TProfile extends NavigableProfileRow>({
|
||||
providerId,
|
||||
providers,
|
||||
profiles,
|
||||
showProfilesSection,
|
||||
canCreateProfileRow,
|
||||
normalizedQuery,
|
||||
}: {
|
||||
providerId: string;
|
||||
providers: ProviderSelectorProvider[];
|
||||
profiles: readonly TProfile[] | null;
|
||||
showProfilesSection: boolean;
|
||||
canCreateProfileRow: boolean;
|
||||
normalizedQuery: string;
|
||||
}): ModelBrowserProjection<TProfile> {
|
||||
const provider = providers.find((entry) => entry.id === providerId) ?? null;
|
||||
if (!provider) return { kind: "empty", navItems: [] };
|
||||
if (provider.modelSelection.kind === "loading") return { kind: "providerLoading", navItems: [] };
|
||||
if (provider.modelSelection.kind === "error") {
|
||||
return {
|
||||
kind: "providerError",
|
||||
providerId,
|
||||
message: provider.modelSelection.message,
|
||||
navItems: [],
|
||||
};
|
||||
}
|
||||
|
||||
const modelRows = filterAndRankModelRows(getProviderModelRows(provider), normalizedQuery);
|
||||
const providerProfiles =
|
||||
profiles !== null ? profiles.filter((row) => row.provider === providerId) : null;
|
||||
const profileSection = resolveProviderProfileSection({
|
||||
providerProfiles,
|
||||
showProfilesSection,
|
||||
canCreateProfileRow,
|
||||
normalizedQuery,
|
||||
hasModelRows: modelRows.length > 0,
|
||||
});
|
||||
|
||||
if (modelRows.length === 0 && profileSection.kind === "none") {
|
||||
return { kind: "empty", navItems: [] };
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "modelList",
|
||||
profileSection,
|
||||
modelRows,
|
||||
showProviderLabel: false,
|
||||
navItems: [...profileSectionToNavItems(profileSection), ...toModelNavItems(modelRows)],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Single source of truth for what ModelBrowser renders and the flat keyboard navigation order.
|
||||
* Deriving navItems directly from the projected sections keeps rendering and arrow keys in lockstep.
|
||||
*/
|
||||
export function resolveModelBrowserProjection<TProfile extends NavigableProfileRow>(
|
||||
input: ModelBrowserProjectionInput<TProfile>,
|
||||
): ModelBrowserProjection<TProfile> {
|
||||
if (input.view.kind === "provider") {
|
||||
return resolveProviderProjection({
|
||||
providerId: input.view.providerId,
|
||||
providers: input.providers,
|
||||
profiles: input.profiles,
|
||||
showProfilesSection: input.showProfilesSection,
|
||||
canCreateProfileRow: input.canCreateProfileRow,
|
||||
normalizedQuery: input.normalizedQuery,
|
||||
});
|
||||
}
|
||||
|
||||
const allView = resolveModelBrowserAllView({
|
||||
providers: input.providers,
|
||||
profiles: input.showProfilesSection && input.profiles ? input.profiles : [],
|
||||
normalizedQuery: input.normalizedQuery,
|
||||
isSearchFocused: input.isSearchFocused,
|
||||
});
|
||||
|
||||
if (allView.kind === "noSearchMatches") {
|
||||
return { kind: "noSearchMatches", navItems: [] };
|
||||
}
|
||||
|
||||
if (allView.kind === "searchResults") {
|
||||
const profileSection: ModelBrowserProfileSection<TProfile> =
|
||||
allView.profiles.length > 0
|
||||
? {
|
||||
kind: "searchProfiles",
|
||||
rows: allView.profiles,
|
||||
showModelsHeading: allView.rows.length > 0,
|
||||
}
|
||||
: { kind: "none" };
|
||||
return {
|
||||
kind: "modelList",
|
||||
profileSection,
|
||||
modelRows: allView.rows,
|
||||
showProviderLabel: true,
|
||||
navItems: [...profileSectionToNavItems(profileSection), ...toModelNavItems(allView.rows)],
|
||||
};
|
||||
}
|
||||
|
||||
const profileSection = resolveBrowseProfileSection(
|
||||
input.profiles,
|
||||
input.showProfilesSection,
|
||||
input.canCreateProfileRow,
|
||||
);
|
||||
const visibleProviders = input.hasCustomRootBrowseContent ? [] : input.providers;
|
||||
const hasResults =
|
||||
input.profiles !== null || input.providers.length > 0 || input.hasCustomRootBrowseContent;
|
||||
|
||||
return {
|
||||
kind: "browse",
|
||||
profileSection,
|
||||
providers: visibleProviders,
|
||||
showProvidersHeading: input.showProfilesSection && input.profiles !== null,
|
||||
isEmpty: !hasResults,
|
||||
navItems: [
|
||||
...profileSectionToNavItems(profileSection),
|
||||
...toProviderNavItems(visibleProviders),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flat visual order of keyboard-navigable rows for the current ModelBrowser state.
|
||||
*/
|
||||
export function resolveModelBrowserNavItems<TProfile extends NavigableProfileRow>(
|
||||
input: ModelBrowserProjectionInput<TProfile>,
|
||||
): ModelBrowserNavItem[] {
|
||||
return resolveModelBrowserProjection(input).navItems;
|
||||
}
|
||||
|
||||
export function resolveInitialModelBrowserActiveKey({
|
||||
items,
|
||||
view,
|
||||
normalizedQuery,
|
||||
selectedProvider,
|
||||
selectedModel,
|
||||
preferredKey,
|
||||
}: {
|
||||
items: readonly ModelBrowserNavItem[];
|
||||
view: ModelBrowserView;
|
||||
normalizedQuery: string;
|
||||
selectedProvider: string;
|
||||
selectedModel: string;
|
||||
preferredKey?: string | null;
|
||||
}): string | null {
|
||||
if (items.length === 0) return null;
|
||||
if (preferredKey && items.some((item) => item.key === preferredKey)) {
|
||||
return preferredKey;
|
||||
}
|
||||
if (normalizedQuery.length > 0) {
|
||||
return items[0].key;
|
||||
}
|
||||
if (view.kind === "provider" && selectedProvider.length > 0 && selectedModel.length > 0) {
|
||||
const selectedItem = items.find(
|
||||
(item) =>
|
||||
item.kind === "model" &&
|
||||
item.provider === selectedProvider &&
|
||||
item.modelId === selectedModel,
|
||||
);
|
||||
if (selectedItem) return selectedItem.key;
|
||||
}
|
||||
return items[0].key;
|
||||
}
|
||||
|
||||
export function resolveActiveModelBrowserKey({
|
||||
explicitActiveKey,
|
||||
items,
|
||||
view,
|
||||
normalizedQuery,
|
||||
selectedProvider,
|
||||
selectedModel,
|
||||
preferredKey,
|
||||
suppressInitialActive = false,
|
||||
}: {
|
||||
explicitActiveKey: string | null;
|
||||
items: readonly ModelBrowserNavItem[];
|
||||
view: ModelBrowserView;
|
||||
normalizedQuery: string;
|
||||
selectedProvider: string;
|
||||
selectedModel: string;
|
||||
preferredKey?: string | null;
|
||||
/** Skip initial highlight on native touch surfaces until the user navigates with a keyboard. */
|
||||
suppressInitialActive?: boolean;
|
||||
}): string | null {
|
||||
if (explicitActiveKey && items.some((item) => item.key === explicitActiveKey)) {
|
||||
return explicitActiveKey;
|
||||
}
|
||||
if (suppressInitialActive) {
|
||||
return null;
|
||||
}
|
||||
return resolveInitialModelBrowserActiveKey({
|
||||
items,
|
||||
view,
|
||||
normalizedQuery,
|
||||
selectedProvider,
|
||||
selectedModel,
|
||||
preferredKey,
|
||||
});
|
||||
}
|
||||
|
||||
export function moveModelBrowserActiveKey({
|
||||
items,
|
||||
activeKey,
|
||||
key,
|
||||
}: {
|
||||
items: readonly ModelBrowserNavItem[];
|
||||
activeKey: string | null;
|
||||
key: "ArrowDown" | "ArrowUp";
|
||||
}): string | null {
|
||||
if (items.length === 0) return null;
|
||||
const currentIndex = activeKey ? items.findIndex((item) => item.key === activeKey) : -1;
|
||||
const nextIndex = getNextActiveIndex({ currentIndex, itemCount: items.length, key });
|
||||
return nextIndex >= 0 ? (items[nextIndex]?.key ?? null) : null;
|
||||
}
|
||||
|
||||
export type ModelBrowserKeyCommand =
|
||||
| { kind: "move"; nextKey: string }
|
||||
| { kind: "activate"; item: ModelBrowserNavItem }
|
||||
| { kind: "drillDown"; providerId: string; providerLabel: string }
|
||||
| { kind: "back"; providerId: string };
|
||||
|
||||
export interface ModelBrowserKeyEvent {
|
||||
key: string;
|
||||
metaKey?: boolean;
|
||||
ctrlKey?: boolean;
|
||||
altKey?: boolean;
|
||||
shiftKey?: boolean;
|
||||
}
|
||||
|
||||
function hasModifierKey(event: ModelBrowserKeyEvent): boolean {
|
||||
return Boolean(event.metaKey || event.ctrlKey || event.altKey);
|
||||
}
|
||||
|
||||
function resolveHierarchyKeyCommand({
|
||||
key,
|
||||
view,
|
||||
activeItem,
|
||||
searchQuery,
|
||||
canGoBack,
|
||||
}: {
|
||||
key: string;
|
||||
view: ModelBrowserView;
|
||||
activeItem: ModelBrowserNavItem | null;
|
||||
searchQuery: string;
|
||||
canGoBack: boolean;
|
||||
}): ModelBrowserKeyCommand | null {
|
||||
if (searchQuery.length > 0) return null;
|
||||
|
||||
if (key === "ArrowRight" && activeItem?.kind === "provider") {
|
||||
return {
|
||||
kind: "drillDown",
|
||||
providerId: activeItem.providerId,
|
||||
providerLabel: activeItem.providerLabel,
|
||||
};
|
||||
}
|
||||
|
||||
if ((key === "ArrowLeft" || key === "Backspace") && view.kind === "provider" && canGoBack) {
|
||||
return { kind: "back", providerId: view.providerId };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a keydown inside ModelBrowser into a navigation command, or null when the key
|
||||
* belongs to text editing or a focused secondary control.
|
||||
*/
|
||||
export function resolveModelBrowserKeyCommand({
|
||||
event,
|
||||
view,
|
||||
items,
|
||||
activeKey,
|
||||
searchQuery,
|
||||
canGoBack,
|
||||
focusedControlOwnsEnter,
|
||||
}: {
|
||||
event: ModelBrowserKeyEvent;
|
||||
view: ModelBrowserView;
|
||||
items: readonly ModelBrowserNavItem[];
|
||||
activeKey: string | null;
|
||||
searchQuery: string;
|
||||
canGoBack: boolean;
|
||||
focusedControlOwnsEnter: boolean;
|
||||
}): ModelBrowserKeyCommand | null {
|
||||
if (hasModifierKey(event)) return null;
|
||||
|
||||
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||
const nextKey = moveModelBrowserActiveKey({ items, activeKey, key: event.key });
|
||||
return nextKey ? { kind: "move", nextKey } : null;
|
||||
}
|
||||
|
||||
if (event.shiftKey) return null;
|
||||
|
||||
const activeItem = activeKey ? (items.find((item) => item.key === activeKey) ?? null) : null;
|
||||
|
||||
if (event.key === "Enter") {
|
||||
return focusedControlOwnsEnter || !activeItem ? null : { kind: "activate", item: activeItem };
|
||||
}
|
||||
|
||||
return resolveHierarchyKeyCommand({
|
||||
key: event.key,
|
||||
view,
|
||||
activeItem,
|
||||
searchQuery,
|
||||
canGoBack,
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,7 @@
|
||||
import { Children, isValidElement, useCallback, useMemo, useState, type ReactNode } from "react";
|
||||
import { useCallback, useMemo, useState, type ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { NestedSettingsRows } from "./row-density";
|
||||
import { SettingsRowChildren } from "./row-children";
|
||||
import { SettingsRowHeader } from "./row-header";
|
||||
|
||||
interface SettingsCollapsibleRowProps {
|
||||
@@ -48,27 +46,7 @@ export function SettingsCollapsibleRow({
|
||||
webAccessibilityProps={webExpandedProps}
|
||||
testID={testID ? `${testID}-toggle` : undefined}
|
||||
/>
|
||||
{expanded ? (
|
||||
<View style={styles.children}>
|
||||
<NestedSettingsRows>
|
||||
{Children.toArray(children).map((child, index) => (
|
||||
<View
|
||||
key={isValidElement(child) ? child.key : index}
|
||||
style={settingsStyles.rowBorder}
|
||||
>
|
||||
{child}
|
||||
</View>
|
||||
))}
|
||||
</NestedSettingsRows>
|
||||
</View>
|
||||
) : null}
|
||||
{expanded ? <SettingsRowChildren>{children}</SettingsRowChildren> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
// The revealed rows keep the card's rails; the tint is what groups them under their header.
|
||||
children: {
|
||||
backgroundColor: theme.colors.surface0,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -25,7 +25,10 @@ import { DropdownTrigger } from "@/components/ui/dropdown-trigger";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { ControlSizeProvider } from "@/components/ui/control-size";
|
||||
import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link";
|
||||
import { useSettingsRowLayout } from "./row-density";
|
||||
import { SettingsRowTitle } from "./row-label";
|
||||
export { SettingsRowChildren } from "./row-children";
|
||||
export { SettingsGroup } from "./headings/settings-group";
|
||||
export { SettingsSection } from "./headings/settings-section";
|
||||
export { SettingsCollapsibleRow } from "./collapsible-row";
|
||||
@@ -36,11 +39,17 @@ export { SettingsBackLink, SettingsDetailHeader } from "./detail-header";
|
||||
export { SettingsInfoTip } from "./headings/settings-info-tip";
|
||||
export { MenuSettingsRows } from "./row-density";
|
||||
|
||||
/** What app screens can add to a plugin-facing row: an accessory beside the label, such as an info tip. */
|
||||
/**
|
||||
* What app screens can add to a plugin-facing row: an accessory beside the label, such as an info
|
||||
* tip, an icon before the label, and a link to a page outside the app under the hint.
|
||||
*/
|
||||
interface AppRowExtras {
|
||||
labelAccessory?: ReactNode;
|
||||
/** An icon before the label, such as the thing the row is about. */
|
||||
leading?: ReactNode;
|
||||
/** A page outside the app that helps with this row, drawn under the hint as "Label ↗". */
|
||||
link?: Pick<ExternalLinkProps, "href" | "label" | "accessibilityLabel">;
|
||||
errorTestID?: string;
|
||||
}
|
||||
|
||||
interface AppSettingsRowProps extends Omit<SettingsRowProps, "hint">, AppRowExtras {
|
||||
@@ -67,29 +76,28 @@ export function SettingsRow({
|
||||
leading,
|
||||
labelAccessory,
|
||||
hint,
|
||||
link,
|
||||
error,
|
||||
errorTestID,
|
||||
children,
|
||||
testID,
|
||||
}: AppSettingsRowProps) {
|
||||
const compact = useIsCompactFormFactor();
|
||||
const layout = useSettingsRowLayout();
|
||||
const rowStyle = useMemo(() => [layout.row, compact && styles.compactRow], [compact, layout]);
|
||||
const accessoryTitleStyle = useMemo(() => [layout.title, styles.accessoryLabel], [layout]);
|
||||
return (
|
||||
<View style={rowStyle} testID={testID}>
|
||||
{leading ? <View style={styles.leading}>{leading}</View> : null}
|
||||
<View style={styles.label}>
|
||||
{labelAccessory ? (
|
||||
<View style={styles.labelRow}>
|
||||
<Text style={accessoryTitleStyle}>{label}</Text>
|
||||
{labelAccessory}
|
||||
</View>
|
||||
) : (
|
||||
<Text style={layout.title}>{label}</Text>
|
||||
)}
|
||||
<SettingsRowTitle label={label} accessory={labelAccessory} />
|
||||
{typeof hint === "string" ? <Text style={layout.hint}>{hint}</Text> : hint}
|
||||
{link ? (
|
||||
<View style={styles.link}>
|
||||
<ExternalLink {...link} />
|
||||
</View>
|
||||
) : null}
|
||||
{error ? (
|
||||
<Text accessibilityRole="alert" style={settingsStyles.rowError}>
|
||||
<Text accessibilityRole="alert" style={settingsStyles.rowError} testID={errorTestID}>
|
||||
{error}
|
||||
</Text>
|
||||
) : null}
|
||||
@@ -103,7 +111,15 @@ export function SettingsRow({
|
||||
);
|
||||
}
|
||||
|
||||
export function SettingsSwitch({ value, onValueChange, disabled, ...row }: SettingsSwitchProps) {
|
||||
/** A switch row. App screens may pass `null` while the value is not known yet; see `Switch`. */
|
||||
export function SettingsSwitch({
|
||||
value,
|
||||
onValueChange,
|
||||
disabled,
|
||||
...row
|
||||
}: Omit<SettingsSwitchProps, "onValueChange" | "value"> &
|
||||
Partial<Pick<SettingsSwitchProps, "onValueChange">> &
|
||||
AppRowExtras & { value: boolean | null }) {
|
||||
return (
|
||||
<SettingsRow {...row}>
|
||||
<Switch
|
||||
@@ -204,7 +220,12 @@ export function SettingsInput({
|
||||
);
|
||||
}
|
||||
|
||||
export function SettingsAction({ actionLabel, onPress, disabled, ...row }: SettingsActionProps) {
|
||||
export function SettingsAction({
|
||||
actionLabel,
|
||||
onPress,
|
||||
disabled,
|
||||
...row
|
||||
}: SettingsActionProps & AppRowExtras) {
|
||||
return (
|
||||
<SettingsRow {...row}>
|
||||
<Button variant="outline" onPress={onPress} disabled={disabled}>
|
||||
@@ -221,13 +242,7 @@ const styles = StyleSheet.create((theme) => ({
|
||||
// The same leading slot as `SettingsRowHeader`, so icons and labels share rails across row kinds.
|
||||
leading: { marginRight: theme.spacing[3], alignItems: "center", justifyContent: "center" },
|
||||
label: { flexGrow: 1, flexShrink: 1, flexBasis: 160, marginRight: theme.spacing[3] },
|
||||
labelRow: {
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
accessoryLabel: { flexShrink: 1, minWidth: 0 },
|
||||
link: { alignItems: "flex-start", marginTop: theme.spacing[1] },
|
||||
control: { flexShrink: 1, maxWidth: "100%" },
|
||||
input: { minWidth: 180 },
|
||||
}));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Children, isValidElement, type ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { NestedSettingsRows } from "./row-density";
|
||||
|
||||
/**
|
||||
* Rows that belong to the row above them, such as the rows an expanded row reveals or the details
|
||||
* a switch turns on. They sit in the same card on a tinted band, laid out as nested rows.
|
||||
*/
|
||||
export function SettingsRowChildren({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<View style={styles.band}>
|
||||
<NestedSettingsRows>
|
||||
{Children.toArray(children).map((child, index) => (
|
||||
<View key={isValidElement(child) ? child.key : index} style={settingsStyles.rowBorder}>
|
||||
{child}
|
||||
</View>
|
||||
))}
|
||||
</NestedSettingsRows>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
// The rows keep the card's rails; the tint is what groups them under the row above.
|
||||
band: {
|
||||
backgroundColor: theme.colors.surface0,
|
||||
},
|
||||
}));
|
||||
@@ -11,6 +11,7 @@ import { SkeletonPulse, useSkeletonPulse } from "@/components/ui/skeleton";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { useSettingsRowLayout, type SettingsRowLayout } from "./row-density";
|
||||
import { SettingsRowTitle } from "./row-label";
|
||||
|
||||
const ThemedChevron = withUnistyles(ChevronRight);
|
||||
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
||||
@@ -118,9 +119,8 @@ export function SettingsRowHeader({
|
||||
</View>
|
||||
) : null}
|
||||
<View style={[contentStyle, styles.passThrough]}>
|
||||
<View style={labelAccessory ? styles.labelRow : undefined} {...HIDDEN_FROM_ASSISTIVE_TECH}>
|
||||
<Text style={layout.title}>{label}</Text>
|
||||
{labelAccessory}
|
||||
<View {...HIDDEN_FROM_ASSISTIVE_TECH}>
|
||||
<SettingsRowTitle label={label} accessory={labelAccessory} />
|
||||
</View>
|
||||
{hintStatus ? (
|
||||
<RowHintLine hint={hint} status={hintStatus} hintStyle={layout.hint} />
|
||||
@@ -293,7 +293,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
borderRadius: theme.borderRadius.sm,
|
||||
backgroundColor: theme.colors.surface2,
|
||||
},
|
||||
labelRow: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2] },
|
||||
summary: {
|
||||
flexShrink: 1,
|
||||
color: theme.colors.foregroundMuted,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { useSettingsRowLayout } from "./row-density";
|
||||
|
||||
/**
|
||||
* A row's label line: the label, and beside it an accessory such as a badge or an info tip. Rows
|
||||
* with inline controls and rows that lead somewhere both draw it, so their labels and hints keep
|
||||
* the same distances whether or not a row carries an accessory.
|
||||
*/
|
||||
export function SettingsRowTitle({ label, accessory }: { label: string; accessory?: ReactNode }) {
|
||||
const layout = useSettingsRowLayout();
|
||||
const titleStyle = useMemo(() => [layout.title, styles.title], [layout]);
|
||||
if (!accessory) return <Text style={layout.title}>{label}</Text>;
|
||||
return (
|
||||
<View style={styles.line}>
|
||||
<Text style={titleStyle}>{label}</Text>
|
||||
<View style={styles.accessory}>{accessory}</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
line: {
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
title: { flexShrink: 1, minWidth: 0 },
|
||||
// An accessory is taller than the label's line. It hangs into the row's padding instead, so the
|
||||
// label and hint keep the distances of a row without one.
|
||||
accessory: { marginVertical: -theme.spacing[1] },
|
||||
}));
|
||||
@@ -1,4 +1,4 @@
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
FlatList,
|
||||
Text,
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Pressable,
|
||||
type ListRenderItemInfo,
|
||||
type PressableStateCallbackType,
|
||||
type ViewToken,
|
||||
} from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -28,6 +27,7 @@ import { Button } from "./button";
|
||||
import { HighlightedText } from "./highlighted-text";
|
||||
import { mutedIconColorMapping } from "./icon-color";
|
||||
import { LoadingSpinner } from "./loading-spinner";
|
||||
import { useRevealActiveFlatListRow } from "./scroll-reveal";
|
||||
import { StatusBadge } from "./status-badge";
|
||||
|
||||
export type AutocompleteOptionIcon =
|
||||
@@ -247,8 +247,6 @@ function endSelected(
|
||||
return null;
|
||||
}
|
||||
|
||||
const FULLY_VISIBLE = { itemVisiblePercentThreshold: 100 };
|
||||
|
||||
function ListPadding() {
|
||||
return <View style={styles.listPadding} />;
|
||||
}
|
||||
@@ -280,71 +278,12 @@ function AutocompleteRows({
|
||||
}: AutocompleteRowsProps) {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const listRef = useRef<FlatList<AutocompleteOption>>(null);
|
||||
const fullyVisibleRows = useRef<{ first: number; last: number } | null>(null);
|
||||
|
||||
// The row the keyboard selected, until it has been brought into the viewport. The row at the
|
||||
// other end is never revealed here: selecting it gives the list a scroller that rests there.
|
||||
const pendingReveal = useRef<number | null>(null);
|
||||
const isPendingRowMeasured = useRef(true);
|
||||
const revealPendingRow = useCallback(() => {
|
||||
const list = listRef.current;
|
||||
const row = pendingReveal.current;
|
||||
const visible = fullyVisibleRows.current;
|
||||
if (!list || row === null || !visible) return;
|
||||
const span = visible.last - visible.first;
|
||||
if (row >= visible.first && row <= visible.last) {
|
||||
pendingReveal.current = null;
|
||||
} else if (row === 0) {
|
||||
list.scrollToOffset({ offset: 0, animated: false });
|
||||
pendingReveal.current = null;
|
||||
fullyVisibleRows.current = { first: 0, last: span };
|
||||
} else {
|
||||
// The row comes in at the edge it was beyond.
|
||||
const isNearer = row < visible.first;
|
||||
isPendingRowMeasured.current = true;
|
||||
list.scrollToIndex({ index: row, viewPosition: isNearer ? 0 : 1, animated: false });
|
||||
// A row that has not mounted has no position yet: the list was sent towards it instead, and
|
||||
// is asked again as rows mount.
|
||||
if (!isPendingRowMeasured.current) return;
|
||||
pendingReveal.current = null;
|
||||
// The list reports what it shows after it has scrolled; the next key press may come first.
|
||||
fullyVisibleRows.current = isNearer
|
||||
? { first: row, last: row + span }
|
||||
: { first: row - span, last: row };
|
||||
}
|
||||
}, []);
|
||||
const handleScrollToIndexFailed = useCallback(
|
||||
(info: { index: number; averageItemLength: number }) => {
|
||||
isPendingRowMeasured.current = false;
|
||||
listRef.current?.scrollToOffset({
|
||||
offset: info.index * info.averageItemLength,
|
||||
animated: false,
|
||||
});
|
||||
},
|
||||
[],
|
||||
);
|
||||
useEffect(() => {
|
||||
pendingReveal.current = selectedRow < 0 ? null : selectedRow;
|
||||
revealPendingRow();
|
||||
}, [revealPendingRow, selectedRow]);
|
||||
|
||||
const handleViewableItemsChanged = useCallback(
|
||||
({ viewableItems }: { viewableItems: ViewToken<AutocompleteOption>[] }) => {
|
||||
const indexes = viewableItems.flatMap((token) => (token.index === null ? [] : [token.index]));
|
||||
if (indexes.length === 0) return;
|
||||
fullyVisibleRows.current = { first: Math.min(...indexes), last: Math.max(...indexes) };
|
||||
revealPendingRow();
|
||||
},
|
||||
[revealPendingRow],
|
||||
);
|
||||
|
||||
// A viewport that got shorter can leave the selected row outside it.
|
||||
const handleLayout = useCallback(() => {
|
||||
// The list reports the rows its new height shows before the row is checked against them.
|
||||
listRef.current?.recordInteraction();
|
||||
pendingReveal.current = selectedRow < 0 ? null : selectedRow;
|
||||
revealPendingRow();
|
||||
}, [revealPendingRow, selectedRow]);
|
||||
const reveal = useRevealActiveFlatListRow({
|
||||
listRef,
|
||||
itemCount: rows.length,
|
||||
activeIndex: selectedRow < 0 ? null : selectedRow,
|
||||
waitForViewable: true,
|
||||
});
|
||||
|
||||
const renderRow = useCallback(
|
||||
({ item, index }: ListRenderItemInfo<AutocompleteOption>) => (
|
||||
@@ -368,11 +307,11 @@ function AutocompleteRows({
|
||||
// The first commit fills the tallest popover, so the popover never opens short and grows.
|
||||
initialNumToRender={Math.ceil(maxHeight / ROW_MIN_HEIGHT) + 1}
|
||||
removeClippedSubviews={false}
|
||||
viewabilityConfig={FULLY_VISIBLE}
|
||||
onViewableItemsChanged={handleViewableItemsChanged}
|
||||
onLayout={handleLayout}
|
||||
onContentSizeChange={revealPendingRow}
|
||||
onScrollToIndexFailed={handleScrollToIndexFailed}
|
||||
viewabilityConfig={reveal.viewabilityConfig}
|
||||
onViewableItemsChanged={reveal.onViewableItemsChanged}
|
||||
onLayout={reveal.onLayout}
|
||||
onContentSizeChange={reveal.onContentSizeChange}
|
||||
onScrollToIndexFailed={reveal.onScrollToIndexFailed}
|
||||
// The list's padding. As a header and footer it counts in the list's own scroll positions.
|
||||
ListHeaderComponent={ListPadding}
|
||||
ListFooterComponent={ListPadding}
|
||||
|
||||
@@ -59,6 +59,7 @@ import {
|
||||
InlineHeaderView,
|
||||
SheetHeaderView,
|
||||
type SheetHeader,
|
||||
type SheetKeyboard,
|
||||
} from "@/components/adaptive-modal-sheet";
|
||||
import { FloatingSurface } from "@/components/ui/floating";
|
||||
import { useDismissKeyboardOnOpen } from "@/components/ui/keyboard-dismiss";
|
||||
@@ -147,6 +148,11 @@ export interface ComboboxProps {
|
||||
anchorRef: React.RefObject<View | null>;
|
||||
/** Where focus goes when the picker closes. Defaults to whatever had focus when it opened. */
|
||||
restoreFocusRef?: React.RefObject<unknown>;
|
||||
/**
|
||||
* Keys custom `children` handle while the combobox is the top overlay. Escape always
|
||||
* closes the combobox. Return true from `onKeyDown` to claim the key.
|
||||
*/
|
||||
keyboard?: SheetKeyboard;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
@@ -1295,12 +1301,16 @@ function DesktopComboboxOptionsBody(props: {
|
||||
function DesktopComboboxBody(props: DesktopBodyProps): ReactElement | null {
|
||||
const active = useRetainedPanelActive();
|
||||
const setOverlayScope = props.setOverlayScope;
|
||||
// Floating UI allocates a fresh `refs` object per render; keep the callback ref stable so
|
||||
// React does not detach and re-register the overlay focus scope on every state update.
|
||||
const setFloatingFnRef = useRef(props.refs.setFloating);
|
||||
setFloatingFnRef.current = props.refs.setFloating;
|
||||
const setFloatingRef = useCallback(
|
||||
(node: View | null) => {
|
||||
props.refs.setFloating(node);
|
||||
setFloatingFnRef.current(node);
|
||||
setOverlayScope(node);
|
||||
},
|
||||
[props.refs, setOverlayScope],
|
||||
[setOverlayScope],
|
||||
);
|
||||
|
||||
// Remove the portal before a retained chat can freeze its closing update.
|
||||
@@ -1430,6 +1440,7 @@ export function Combobox({
|
||||
keepOpenOnSelect = false,
|
||||
anchorRef,
|
||||
restoreFocusRef,
|
||||
keyboard,
|
||||
children,
|
||||
}: ComboboxProps): ReactElement | null {
|
||||
const { t } = useTranslation();
|
||||
@@ -1716,16 +1727,42 @@ export function Combobox({
|
||||
[],
|
||||
);
|
||||
|
||||
const hasChildren = Boolean(children);
|
||||
const overlayKeys = useMemo<readonly string[]>(() => {
|
||||
if (keyboard) return ["Escape", ...keyboard.keys];
|
||||
return hasChildren ? ["Escape"] : ["Escape", "Enter", "ArrowUp", "ArrowDown"];
|
||||
}, [hasChildren, keyboard]);
|
||||
const handleOverlayKeyDown = useCallback(
|
||||
(event: KeyboardInputEvent) => {
|
||||
if (keyboard) {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
handleClose();
|
||||
return true;
|
||||
}
|
||||
if (!keyboard.onKeyDown(event)) return false;
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
if (hasChildren) {
|
||||
if (event.key !== "Escape") return false;
|
||||
event.preventDefault();
|
||||
handleClose();
|
||||
return true;
|
||||
}
|
||||
return isDesktopKey(event.key) ? handleDesktopKey(event.key, event) : false;
|
||||
},
|
||||
[handleClose, handleDesktopKey, hasChildren, keyboard],
|
||||
);
|
||||
const setOverlayScope = useOverlayRegistration({
|
||||
active: isOpen,
|
||||
layer: floatingLayer,
|
||||
keys: ["Escape", "Enter", "ArrowUp", "ArrowDown"],
|
||||
onKeyDown: (event) => (isDesktopKey(event.key) ? handleDesktopKey(event.key, event) : false),
|
||||
keys: overlayKeys,
|
||||
onKeyDown: handleOverlayKeyDown,
|
||||
restoreFocusRef,
|
||||
});
|
||||
|
||||
const effectiveSearchPlaceholder = searchPlaceholder ?? resolvedPlaceholder;
|
||||
const hasChildren = Boolean(children);
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useCallback, useLayoutEffect, useRef, type RefObject } from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, type RefObject } from "react";
|
||||
import type {
|
||||
FlatList,
|
||||
LayoutChangeEvent,
|
||||
NativeScrollEvent,
|
||||
NativeSyntheticEvent,
|
||||
ScrollView,
|
||||
View,
|
||||
ViewToken,
|
||||
} from "react-native";
|
||||
|
||||
export function getScrollOffsetToRevealItem(args: {
|
||||
@@ -107,3 +109,142 @@ export function useRevealActiveItem(options: {
|
||||
|
||||
return { activeItemRef, contentRef, onItemLayout: reveal, onViewportLayout, onScroll };
|
||||
}
|
||||
|
||||
export const FULLY_VISIBLE_VIEWABILITY = { itemVisiblePercentThreshold: 100 };
|
||||
|
||||
export interface RevealActiveFlatListHandlers<T> {
|
||||
viewabilityConfig: typeof FULLY_VISIBLE_VIEWABILITY;
|
||||
onViewableItemsChanged: (info: { viewableItems: ViewToken<T>[] }) => void;
|
||||
onScrollToIndexFailed: (info: { index: number; averageItemLength: number }) => void;
|
||||
onContentSizeChange: () => void;
|
||||
onLayout: () => void;
|
||||
}
|
||||
|
||||
interface VisibleRange {
|
||||
first: number;
|
||||
last: number;
|
||||
}
|
||||
|
||||
function nextVisibleRangeAfterReveal(
|
||||
visible: VisibleRange | null,
|
||||
row: number,
|
||||
isNearer: boolean,
|
||||
): VisibleRange | null {
|
||||
if (!visible) return null;
|
||||
const span = visible.last - visible.first;
|
||||
return isNearer ? { first: row, last: row + span } : { first: row - span, last: row };
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps the keyboard-active row visible inside a virtualized FlatList. Tracks
|
||||
* fully visible rows via viewability callbacks, retries unmeasured rows as they
|
||||
* mount after scrollToIndexFailed, and supports scrolling to offset 0 when a
|
||||
* header item above row 0 is active.
|
||||
*/
|
||||
export function useRevealActiveFlatListRow<T>({
|
||||
listRef,
|
||||
itemCount,
|
||||
activeIndex,
|
||||
hasHeader = false,
|
||||
waitForViewable = false,
|
||||
listKey,
|
||||
}: {
|
||||
listRef: RefObject<FlatList<T> | null>;
|
||||
itemCount: number;
|
||||
activeIndex: number | "top" | null;
|
||||
hasHeader?: boolean;
|
||||
waitForViewable?: boolean;
|
||||
listKey?: unknown;
|
||||
}): RevealActiveFlatListHandlers<T> {
|
||||
const fullyVisibleRows = useRef<VisibleRange | null>(null);
|
||||
const pendingReveal = useRef<number | null>(null);
|
||||
const isPendingRowMeasured = useRef(true);
|
||||
const itemCountRef = useRef(itemCount);
|
||||
itemCountRef.current = itemCount;
|
||||
const hasHeaderRef = useRef(hasHeader);
|
||||
hasHeaderRef.current = hasHeader;
|
||||
const waitForViewableRef = useRef(waitForViewable);
|
||||
waitForViewableRef.current = waitForViewable;
|
||||
|
||||
const revealPendingRow = useCallback(() => {
|
||||
const list = listRef.current;
|
||||
const row = pendingReveal.current;
|
||||
if (!list || row === null || row < 0 || row >= itemCountRef.current) return;
|
||||
|
||||
const visible = fullyVisibleRows.current;
|
||||
if (waitForViewableRef.current && !visible) return;
|
||||
if (visible && row >= visible.first && row <= visible.last) {
|
||||
pendingReveal.current = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (row === 0 && !hasHeaderRef.current) {
|
||||
list.scrollToOffset({ offset: 0, animated: false });
|
||||
pendingReveal.current = null;
|
||||
fullyVisibleRows.current = nextVisibleRangeAfterReveal(visible, 0, true);
|
||||
return;
|
||||
}
|
||||
|
||||
const isNearer = visible !== null && row < visible.first;
|
||||
let viewPosition = 0.5;
|
||||
if (visible !== null) {
|
||||
viewPosition = isNearer ? 0 : 1;
|
||||
}
|
||||
isPendingRowMeasured.current = true;
|
||||
list.scrollToIndex({ index: row, viewPosition, animated: false });
|
||||
if (!isPendingRowMeasured.current) return;
|
||||
pendingReveal.current = null;
|
||||
fullyVisibleRows.current = nextVisibleRangeAfterReveal(visible, row, isNearer);
|
||||
}, [listRef]);
|
||||
|
||||
const handleScrollToIndexFailed = useCallback(
|
||||
(info: { index: number; averageItemLength: number }) => {
|
||||
isPendingRowMeasured.current = false;
|
||||
if (info.index >= itemCountRef.current - 1) {
|
||||
listRef.current?.scrollToEnd({ animated: false });
|
||||
return;
|
||||
}
|
||||
listRef.current?.scrollToOffset({
|
||||
offset: info.index * info.averageItemLength,
|
||||
animated: false,
|
||||
});
|
||||
},
|
||||
[listRef],
|
||||
);
|
||||
|
||||
const handleViewableItemsChanged = useCallback(
|
||||
({ viewableItems }: { viewableItems: ViewToken<T>[] }) => {
|
||||
const indexes = viewableItems.flatMap((token) => (token.index === null ? [] : [token.index]));
|
||||
if (indexes.length === 0) return;
|
||||
fullyVisibleRows.current = { first: Math.min(...indexes), last: Math.max(...indexes) };
|
||||
revealPendingRow();
|
||||
},
|
||||
[revealPendingRow],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (activeIndex === "top") {
|
||||
pendingReveal.current = null;
|
||||
listRef.current?.scrollToOffset({ offset: 0, animated: false });
|
||||
return;
|
||||
}
|
||||
pendingReveal.current = activeIndex !== null && activeIndex >= 0 ? activeIndex : null;
|
||||
revealPendingRow();
|
||||
}, [activeIndex, listKey, listRef, revealPendingRow]);
|
||||
|
||||
// A viewport that got shorter can leave the selected row outside it.
|
||||
const handleLayout = useCallback(() => {
|
||||
listRef.current?.recordInteraction();
|
||||
pendingReveal.current =
|
||||
typeof activeIndex === "number" && activeIndex >= 0 ? activeIndex : null;
|
||||
revealPendingRow();
|
||||
}, [activeIndex, listRef, revealPendingRow]);
|
||||
|
||||
return {
|
||||
viewabilityConfig: FULLY_VISIBLE_VIEWABILITY,
|
||||
onViewableItemsChanged: handleViewableItemsChanged,
|
||||
onScrollToIndexFailed: handleScrollToIndexFailed,
|
||||
onContentSizeChange: revealPendingRow,
|
||||
onLayout: handleLayout,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import {
|
||||
Pressable,
|
||||
View,
|
||||
type GestureResponderEvent,
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
@@ -19,7 +20,11 @@ import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
|
||||
interface SwitchProps {
|
||||
value: boolean;
|
||||
/**
|
||||
* `null` while the value is not known yet, such as while it loads from a host. The switch's space
|
||||
* stays reserved and empty, so the switch takes it when the value arrives and nothing moves.
|
||||
*/
|
||||
value: boolean | null;
|
||||
onValueChange?: (value: boolean) => void;
|
||||
disabled?: boolean;
|
||||
accessibilityLabel?: string;
|
||||
@@ -109,7 +114,7 @@ export function Switch({
|
||||
const handlePress = useCallback(
|
||||
(event: GestureResponderEvent) => {
|
||||
event.stopPropagation();
|
||||
if (disabled) return;
|
||||
if (disabled || value === null) return;
|
||||
onValueChange?.(!value);
|
||||
},
|
||||
[disabled, onValueChange, value],
|
||||
@@ -119,7 +124,10 @@ export function Switch({
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const geometry = useMemo(() => switchGeometryForLayout(size, isCompact), [size, isCompact]);
|
||||
|
||||
const accessibilityState = useMemo(() => ({ checked: value, disabled }), [value, disabled]);
|
||||
const accessibilityState = useMemo(
|
||||
() => ({ checked: value === true, disabled }),
|
||||
[value, disabled],
|
||||
);
|
||||
const pressableStyle = useMemo(
|
||||
() => [
|
||||
styles.switchControl,
|
||||
@@ -134,6 +142,12 @@ export function Switch({
|
||||
],
|
||||
[disabled, geometry.hitHeight, geometry.trackHeight, style],
|
||||
);
|
||||
const unknownStyle = useMemo(
|
||||
() => [{ width: geometry.trackWidth, minHeight: geometry.trackHeight }, style],
|
||||
[geometry.trackWidth, geometry.trackHeight, style],
|
||||
);
|
||||
|
||||
if (value === null) return <View style={unknownStyle} testID={testID} />;
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
|
||||
@@ -347,6 +347,7 @@ export function CompactModelSheet({
|
||||
onClose={close}
|
||||
snapPoints={SNAP_POINTS}
|
||||
scrollable={false}
|
||||
keyboard={rootBrowser.keyboard}
|
||||
contentStyle={styles.sheetBody}
|
||||
contextBridge={contextBridge}
|
||||
testID="agent-controls-model-sheet"
|
||||
@@ -396,6 +397,7 @@ export function CompactModelSheet({
|
||||
snapPoints={SNAP_POINTS}
|
||||
scrollable={false}
|
||||
presentation="push"
|
||||
keyboard={modelBrowser.keyboard}
|
||||
contentStyle={styles.sheetBody}
|
||||
contextBridge={contextBridge}
|
||||
testID="agent-controls-model-browser-sheet"
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { WorkspaceDescriptor } from "@/stores/session-store";
|
||||
import {
|
||||
clearWorkspaceArchivePending,
|
||||
isWorkspaceArchivePending,
|
||||
isWorkspaceArchiveUndoRestoringAgent,
|
||||
markWorkspaceArchivePending,
|
||||
markWorkspaceArchiveUndoPending,
|
||||
shouldSuppressWorkspaceForLocalArchive,
|
||||
@@ -156,4 +157,24 @@ describe("workspace archive undo intent", () => {
|
||||
|
||||
settleWorkspaceArchiveIntent(secondUndo);
|
||||
});
|
||||
|
||||
it("marks only agents that were active at archive time as restoring during undo", () => {
|
||||
const activeTarget = { serverId: "server-1", workspaceId: "/repo/worktree-agents" };
|
||||
const undo = markWorkspaceArchiveUndoPending({
|
||||
...activeTarget,
|
||||
archivedAgentIds: new Set(["agent-active"]),
|
||||
});
|
||||
|
||||
expect(isWorkspaceArchiveUndoRestoringAgent({ ...activeTarget, agentId: "agent-active" })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
isWorkspaceArchiveUndoRestoringAgent({ ...activeTarget, agentId: "agent-pre-archived" }),
|
||||
).toBe(false);
|
||||
|
||||
settleWorkspaceArchiveIntent(undo);
|
||||
expect(isWorkspaceArchiveUndoRestoringAgent({ ...activeTarget, agentId: "agent-active" })).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,8 @@ import { normalizeWorkspaceOpaqueId } from "@/utils/workspace-identity";
|
||||
*/
|
||||
export interface WorkspaceArchiveIntent {
|
||||
readonly kind: "archive" | "undo";
|
||||
/** Active agent IDs in the workspace when this client archived it, so undo only marks those agents as restoring. */
|
||||
readonly archivedAgentIds?: ReadonlySet<string>;
|
||||
}
|
||||
|
||||
const intentsByServer = new Map<string, Map<string, WorkspaceArchiveIntent>>();
|
||||
@@ -44,9 +46,10 @@ function readIntent(input: WorkspaceIntentTarget): WorkspaceArchiveIntent | null
|
||||
function setIntent(
|
||||
input: WorkspaceIntentTarget,
|
||||
kind: WorkspaceArchiveIntent["kind"],
|
||||
archivedAgentIds?: ReadonlySet<string>,
|
||||
): WorkspaceArchiveIntent {
|
||||
const intent: WorkspaceArchiveIntent = { kind };
|
||||
const target = resolveTarget(input);
|
||||
const intent: WorkspaceArchiveIntent = archivedAgentIds ? { kind, archivedAgentIds } : { kind };
|
||||
if (!target) return intent;
|
||||
targetByIntent.set(intent, target);
|
||||
const intents = intentsByServer.get(target.serverId) ?? new Map();
|
||||
@@ -119,14 +122,42 @@ export function isWorkspaceArchivePending(input: WorkspaceIntentTarget): boolean
|
||||
export function markWorkspaceArchiveUndoPending(input: {
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
archivedAgentIds?: ReadonlySet<string>;
|
||||
}): WorkspaceArchiveIntent {
|
||||
return setIntent(input, "undo");
|
||||
return setIntent(input, "undo", input.archivedAgentIds);
|
||||
}
|
||||
|
||||
export function isWorkspaceArchiveUndoPending(input: WorkspaceIntentTarget): boolean {
|
||||
return readIntent(input)?.kind === "undo";
|
||||
}
|
||||
|
||||
/** Returns the active agent IDs captured by a pending workspace undo, if any. */
|
||||
export function getWorkspaceArchiveUndoArchivedAgentIds(
|
||||
input: WorkspaceIntentTarget,
|
||||
): ReadonlySet<string> | null {
|
||||
const intent = readIntent(input);
|
||||
if (intent?.kind !== "undo") return null;
|
||||
return intent.archivedAgentIds ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* True while this client's workspace undo is pending and `agentId` was active in that
|
||||
* workspace when archived. Agents that were already archived before the workspace archive
|
||||
* return false so they are not mislabeled as unarchiving.
|
||||
*/
|
||||
export function isWorkspaceArchiveUndoRestoringAgent(input: {
|
||||
serverId: string;
|
||||
workspaceId?: string | null;
|
||||
agentId?: string | null;
|
||||
}): boolean {
|
||||
const intent = readIntent(input);
|
||||
if (intent?.kind !== "undo") return false;
|
||||
const agentId = input.agentId?.trim();
|
||||
if (!agentId) return false;
|
||||
if (!intent.archivedAgentIds) return false;
|
||||
return intent.archivedAgentIds.has(agentId);
|
||||
}
|
||||
|
||||
export function shouldSuppressWorkspaceForLocalArchive(input: {
|
||||
serverId: string;
|
||||
workspace: WorkspaceDescriptor;
|
||||
|
||||
@@ -37,7 +37,7 @@ export function useEnableBuiltInDaemonOption(): EnableBuiltInDaemonOption {
|
||||
void (async () => {
|
||||
const result = await enable();
|
||||
if (result?.kind === "enabled") {
|
||||
router.push(buildSettingsHostSectionRoute(result.newStatus.serverId, "host"));
|
||||
router.push(buildSettingsHostSectionRoute(result.newStatus.serverId, "daemon"));
|
||||
}
|
||||
})();
|
||||
}, [enable]);
|
||||
|
||||
@@ -11,8 +11,13 @@ import { i18n } from "@/i18n/i18next";
|
||||
|
||||
const DESKTOP_SETTINGS_QUERY_KEY = ["desktop-settings"] as const;
|
||||
|
||||
export type DesktopUpdateMode = "automatic" | "notify" | "off";
|
||||
|
||||
export interface DesktopSettings {
|
||||
releaseChannel: ReleaseChannel;
|
||||
updates: {
|
||||
mode: DesktopUpdateMode;
|
||||
};
|
||||
notifications: {
|
||||
playSound: boolean;
|
||||
};
|
||||
@@ -24,12 +29,16 @@ export interface DesktopSettings {
|
||||
|
||||
export interface DesktopSettingsPatch {
|
||||
releaseChannel?: ReleaseChannel;
|
||||
updates?: Partial<DesktopSettings["updates"]>;
|
||||
notifications?: Partial<DesktopSettings["notifications"]>;
|
||||
daemon?: Partial<DesktopSettings["daemon"]>;
|
||||
}
|
||||
|
||||
export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
||||
releaseChannel: "stable",
|
||||
updates: {
|
||||
mode: "automatic",
|
||||
},
|
||||
notifications: {
|
||||
playSound: true,
|
||||
},
|
||||
@@ -149,13 +158,24 @@ export async function migrateLegacyDesktopSettings(input: {
|
||||
await invokeDesktopCommand("migrate_legacy_desktop_settings", input);
|
||||
}
|
||||
|
||||
function parseUpdateMode(value: unknown): DesktopUpdateMode {
|
||||
if (value === "automatic" || value === "notify" || value === "off") {
|
||||
return value;
|
||||
}
|
||||
return DEFAULT_DESKTOP_SETTINGS.updates.mode;
|
||||
}
|
||||
|
||||
function parseDesktopSettings(raw: unknown): DesktopSettings {
|
||||
const record = isRecord(raw) ? raw : {};
|
||||
const updates = isRecord(record.updates) ? record.updates : {};
|
||||
const notifications = isRecord(record.notifications) ? record.notifications : {};
|
||||
const daemon = isRecord(record.daemon) ? record.daemon : {};
|
||||
|
||||
return {
|
||||
releaseChannel: record.releaseChannel === "beta" ? "beta" : "stable",
|
||||
updates: {
|
||||
mode: parseUpdateMode(updates.mode),
|
||||
},
|
||||
notifications: {
|
||||
playSound:
|
||||
typeof notifications.playSound === "boolean"
|
||||
@@ -181,6 +201,10 @@ function mergeDesktopSettings(
|
||||
): DesktopSettings {
|
||||
return {
|
||||
releaseChannel: updates.releaseChannel ?? current.releaseChannel,
|
||||
updates: {
|
||||
...current.updates,
|
||||
...updates.updates,
|
||||
},
|
||||
notifications: {
|
||||
...current.notifications,
|
||||
...updates.notifications,
|
||||
@@ -195,6 +219,7 @@ function mergeDesktopSettings(
|
||||
function normalizePatch(updates: DesktopSettingsPatch): Record<string, unknown> {
|
||||
return {
|
||||
...(updates.releaseChannel ? { releaseChannel: updates.releaseChannel } : {}),
|
||||
...(updates.updates ? { updates: updates.updates } : {}),
|
||||
...(updates.notifications ? { notifications: updates.notifications } : {}),
|
||||
...(updates.daemon ? { daemon: updates.daemon } : {}),
|
||||
};
|
||||
|
||||
@@ -128,6 +128,43 @@ describe("desktop app updater — check", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("reports 'available' when an update is available to download without auto-downloading", async () => {
|
||||
const { updater, port } = createUpdater({ now: () => 42 });
|
||||
port.nextCheckResult(
|
||||
buildFakeCheckResult({
|
||||
hasUpdate: true,
|
||||
readyToInstall: false,
|
||||
downloading: false,
|
||||
latestVersion: "1.2.3",
|
||||
}),
|
||||
);
|
||||
|
||||
await updater.checkForUpdates({ releaseChannel: "stable" });
|
||||
|
||||
expect(updater.getSnapshot()).toMatchObject({
|
||||
status: "available",
|
||||
availableUpdate: { latestVersion: "1.2.3", readyToInstall: false, downloading: false },
|
||||
lastCheckedAt: 42,
|
||||
});
|
||||
});
|
||||
|
||||
it("tracks download progress updates and clears them once install completes", async () => {
|
||||
const { updater, port } = createUpdater();
|
||||
port.nextInstallResult(buildFakeInstallResult({ installed: true }));
|
||||
|
||||
updater.setDownloadProgress({
|
||||
version: "1.2.3",
|
||||
percent: 42.4,
|
||||
transferred: 42,
|
||||
total: 100,
|
||||
bytesPerSecond: 10,
|
||||
});
|
||||
expect(updater.getSnapshot().downloadProgress?.percent).toBe(42.4);
|
||||
|
||||
await updater.installUpdate({ releaseChannel: "stable" });
|
||||
expect(updater.getSnapshot().downloadProgress).toBeNull();
|
||||
});
|
||||
|
||||
it("reports 'up-to-date' when the check resolves with no update", async () => {
|
||||
const { updater, port } = createUpdater();
|
||||
port.nextCheckResult(buildFakeCheckResult({ hasUpdate: false, readyToInstall: false }));
|
||||
@@ -340,6 +377,55 @@ describe("desktop app updater — install", () => {
|
||||
expect(updater.getSnapshot().status).toBe("up-to-date");
|
||||
});
|
||||
|
||||
it("moves to 'error' instead of 'up-to-date' when the install returns an errorMessage", async () => {
|
||||
const { updater, port } = createUpdater();
|
||||
port.nextInstallResult(
|
||||
buildFakeInstallResult({
|
||||
installed: false,
|
||||
message: "Update failed: ECONNRESET",
|
||||
errorMessage: "ECONNRESET",
|
||||
}),
|
||||
);
|
||||
|
||||
await updater.installUpdate({ releaseChannel: "stable" });
|
||||
|
||||
expect(updater.getSnapshot()).toMatchObject({
|
||||
status: "error",
|
||||
errorMessage: "ECONNRESET",
|
||||
downloadProgress: null,
|
||||
isInstalling: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores duplicate install requests and silent checks while an install is in progress", async () => {
|
||||
const { updater, port } = createUpdater();
|
||||
let resolveInstall!: (result: ReturnType<typeof buildFakeInstallResult>) => void;
|
||||
port.installDesktopAppUpdate = async (input) => {
|
||||
port.recordedInstalls.push(input);
|
||||
return new Promise((resolve) => {
|
||||
resolveInstall = resolve;
|
||||
});
|
||||
};
|
||||
|
||||
const firstInstall = updater.installUpdate({ releaseChannel: "stable" });
|
||||
const secondInstall = await updater.installUpdate({ releaseChannel: "stable" });
|
||||
const silentCheck = await updater.checkForUpdates({
|
||||
releaseChannel: "stable",
|
||||
intent: "automatic",
|
||||
silent: true,
|
||||
});
|
||||
|
||||
expect(secondInstall).toBeNull();
|
||||
expect(silentCheck).toBeNull();
|
||||
expect(port.recordedInstalls).toHaveLength(1);
|
||||
expect(port.recordedChecks).toHaveLength(0);
|
||||
expect(updater.getSnapshot().status).toBe("installing");
|
||||
|
||||
resolveInstall(buildFakeInstallResult({ installed: true }));
|
||||
await firstInstall;
|
||||
expect(updater.getSnapshot().status).toBe("installed");
|
||||
});
|
||||
|
||||
it("reports the install error and moves to 'error' when the install throws", async () => {
|
||||
const { updater, port, reportedInstallErrors } = createUpdater();
|
||||
const error = new Error("install failed");
|
||||
@@ -462,6 +548,47 @@ describe("formatStatusText", () => {
|
||||
).toBe("Restart now");
|
||||
});
|
||||
|
||||
it("formats download-available and live download progress status text", () => {
|
||||
expect(
|
||||
formatStatusText({
|
||||
status: "available",
|
||||
availableUpdate: buildFakeCheckResult({
|
||||
hasUpdate: true,
|
||||
readyToInstall: false,
|
||||
downloading: false,
|
||||
latestVersion: "1.2.3",
|
||||
}),
|
||||
installMessage: null,
|
||||
lastCheckedAt: 42,
|
||||
formatVersion,
|
||||
formatLastCheckedAt,
|
||||
}),
|
||||
).toBe("Update available: v1.2.3. Last checked at time-42.");
|
||||
|
||||
expect(
|
||||
formatStatusText({
|
||||
status: "installing",
|
||||
availableUpdate: buildFakeCheckResult({
|
||||
hasUpdate: true,
|
||||
readyToInstall: false,
|
||||
downloading: false,
|
||||
latestVersion: "1.2.3",
|
||||
}),
|
||||
downloadProgress: {
|
||||
version: "1.2.3",
|
||||
percent: 64.6,
|
||||
transferred: 65,
|
||||
total: 100,
|
||||
bytesPerSecond: 10,
|
||||
},
|
||||
installMessage: null,
|
||||
lastCheckedAt: null,
|
||||
formatVersion,
|
||||
formatLastCheckedAt,
|
||||
}),
|
||||
).toBe("Downloading v1.2.3... 65%");
|
||||
});
|
||||
|
||||
it("uses the active app language for local status wrappers", async () => {
|
||||
await i18n.changeLanguage("zh-CN");
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
DesktopAppUpdateCheckResult,
|
||||
DesktopAppUpdateCheckIntent,
|
||||
DesktopAppUpdateDownloadProgress,
|
||||
DesktopAppUpdateInstallResult,
|
||||
DesktopReleaseChannel,
|
||||
} from "@/desktop/updates/desktop-updates";
|
||||
@@ -21,6 +22,7 @@ export const PENDING_RECHECK_MS = 10_000;
|
||||
export interface DesktopAppUpdaterSnapshot {
|
||||
status: DesktopAppUpdateStatus;
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null;
|
||||
errorMessage: string | null;
|
||||
installMessage: string | null;
|
||||
lastCheckedAt: number | null;
|
||||
@@ -53,6 +55,7 @@ export interface DesktopAppUpdaterDeps {
|
||||
export interface DesktopAppUpdater {
|
||||
getSnapshot(): DesktopAppUpdaterSnapshot;
|
||||
subscribe(listener: () => void): () => void;
|
||||
setDownloadProgress(progress: DesktopAppUpdateDownloadProgress | null): void;
|
||||
checkForUpdates(options?: {
|
||||
releaseChannel: DesktopReleaseChannel;
|
||||
intent?: DesktopAppUpdateCheckIntent;
|
||||
@@ -66,6 +69,7 @@ export interface DesktopAppUpdater {
|
||||
interface InternalState {
|
||||
status: DesktopAppUpdateStatus;
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null;
|
||||
errorMessage: string | null;
|
||||
installMessage: string | null;
|
||||
lastCheckedAt: number | null;
|
||||
@@ -76,6 +80,7 @@ interface InternalState {
|
||||
const INITIAL_STATE: InternalState = {
|
||||
status: "idle",
|
||||
availableUpdate: null,
|
||||
downloadProgress: null,
|
||||
errorMessage: null,
|
||||
installMessage: null,
|
||||
lastCheckedAt: null,
|
||||
@@ -87,6 +92,7 @@ function buildSnapshot(state: InternalState): DesktopAppUpdaterSnapshot {
|
||||
return {
|
||||
status: state.status,
|
||||
availableUpdate: state.availableUpdate,
|
||||
downloadProgress: state.downloadProgress,
|
||||
errorMessage: state.errorMessage,
|
||||
installMessage: state.installMessage,
|
||||
lastCheckedAt: state.lastCheckedAt,
|
||||
@@ -102,9 +108,113 @@ function getErrorMessage(error: unknown): string {
|
||||
return String(error);
|
||||
}
|
||||
|
||||
function formatInstallingStatusText(input: {
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null;
|
||||
formatVersion: (version: string | null | undefined) => string;
|
||||
}): string {
|
||||
const { availableUpdate, downloadProgress, formatVersion } = input;
|
||||
if (downloadProgress == null) {
|
||||
return i18n.t("desktop.updates.status.installing");
|
||||
}
|
||||
const percent = Math.round(downloadProgress.percent);
|
||||
const version = downloadProgress.version ?? availableUpdate?.latestVersion;
|
||||
if (version) {
|
||||
return i18n.t("desktop.updates.status.downloadingVersionProgress", {
|
||||
version: formatVersion(version),
|
||||
percent,
|
||||
});
|
||||
}
|
||||
return i18n.t("desktop.updates.status.downloadingProgress", { percent });
|
||||
}
|
||||
|
||||
function formatPendingStatusText(input: {
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null;
|
||||
lastCheckedAt: number | null;
|
||||
formatVersion: (version: string | null | undefined) => string;
|
||||
formatLastCheckedAt: (timestamp: number) => string;
|
||||
}): string {
|
||||
const { availableUpdate, downloadProgress, lastCheckedAt, formatVersion, formatLastCheckedAt } =
|
||||
input;
|
||||
const time = lastCheckedAt != null ? formatLastCheckedAt(lastCheckedAt) : undefined;
|
||||
if (availableUpdate?.latestVersion) {
|
||||
const version = formatVersion(availableUpdate.latestVersion);
|
||||
if (downloadProgress != null) {
|
||||
return i18n.t(
|
||||
time !== undefined
|
||||
? "desktop.updates.status.pendingWithVersionProgressAndLastChecked"
|
||||
: "desktop.updates.status.pendingWithVersionProgress",
|
||||
{ version, percent: Math.round(downloadProgress.percent), time },
|
||||
);
|
||||
}
|
||||
return i18n.t(
|
||||
time !== undefined
|
||||
? "desktop.updates.status.pendingWithVersionAndLastChecked"
|
||||
: "desktop.updates.status.pendingWithVersion",
|
||||
{ version, time },
|
||||
);
|
||||
}
|
||||
if (time !== undefined) {
|
||||
return i18n.t("desktop.updates.status.pendingWithLastChecked", { time });
|
||||
}
|
||||
return i18n.t("desktop.updates.status.pending");
|
||||
}
|
||||
|
||||
function formatAvailableStatusText(input: {
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
lastCheckedAt: number | null;
|
||||
formatVersion: (version: string | null | undefined) => string;
|
||||
formatLastCheckedAt: (timestamp: number) => string;
|
||||
}): string {
|
||||
const { availableUpdate, lastCheckedAt, formatVersion, formatLastCheckedAt } = input;
|
||||
const time = lastCheckedAt != null ? formatLastCheckedAt(lastCheckedAt) : undefined;
|
||||
const isDownloadRequired =
|
||||
availableUpdate?.hasUpdate === true && availableUpdate.readyToInstall === false;
|
||||
if (availableUpdate?.latestVersion) {
|
||||
const version = formatVersion(availableUpdate.latestVersion);
|
||||
if (isDownloadRequired) {
|
||||
return i18n.t(
|
||||
time !== undefined
|
||||
? "desktop.updates.status.downloadAvailableWithVersionAndLastChecked"
|
||||
: "desktop.updates.status.downloadAvailableWithVersion",
|
||||
{ version, time },
|
||||
);
|
||||
}
|
||||
return i18n.t(
|
||||
time !== undefined
|
||||
? "desktop.updates.status.availableWithVersionAndLastChecked"
|
||||
: "desktop.updates.status.availableWithVersion",
|
||||
{ version, time },
|
||||
);
|
||||
}
|
||||
if (isDownloadRequired) {
|
||||
return time !== undefined
|
||||
? i18n.t("desktop.updates.status.downloadAvailableWithLastChecked", { time })
|
||||
: i18n.t("desktop.updates.status.downloadAvailable");
|
||||
}
|
||||
return time !== undefined
|
||||
? i18n.t("desktop.updates.status.availableWithLastChecked", { time })
|
||||
: i18n.t("desktop.updates.status.available");
|
||||
}
|
||||
|
||||
function resolveCheckOutcome(result: DesktopAppUpdateCheckResult): {
|
||||
status: DesktopAppUpdateStatus;
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
} {
|
||||
if (result.readyToInstall || (result.hasUpdate && !result.downloading)) {
|
||||
return { status: "available", availableUpdate: result };
|
||||
}
|
||||
if (result.hasUpdate) {
|
||||
return { status: "pending", availableUpdate: result };
|
||||
}
|
||||
return { status: "up-to-date", availableUpdate: null };
|
||||
}
|
||||
|
||||
export function formatStatusText(input: {
|
||||
status: DesktopAppUpdateStatus;
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress?: DesktopAppUpdateDownloadProgress | null;
|
||||
installMessage: string | null;
|
||||
lastCheckedAt: number | null;
|
||||
formatVersion: (version: string | null | undefined) => string;
|
||||
@@ -113,79 +223,45 @@ export function formatStatusText(input: {
|
||||
const {
|
||||
status,
|
||||
availableUpdate,
|
||||
downloadProgress = null,
|
||||
installMessage,
|
||||
lastCheckedAt,
|
||||
formatVersion,
|
||||
formatLastCheckedAt,
|
||||
} = input;
|
||||
|
||||
if (status === "checking") {
|
||||
return i18n.t("desktop.updates.status.checking");
|
||||
}
|
||||
|
||||
if (status === "checking") return i18n.t("desktop.updates.status.checking");
|
||||
if (status === "installing") {
|
||||
return i18n.t("desktop.updates.status.installing");
|
||||
return formatInstallingStatusText({ availableUpdate, downloadProgress, formatVersion });
|
||||
}
|
||||
|
||||
if (status === "up-to-date") {
|
||||
if (lastCheckedAt != null) {
|
||||
return i18n.t("desktop.updates.status.upToDateWithLastChecked", {
|
||||
time: formatLastCheckedAt(lastCheckedAt),
|
||||
});
|
||||
}
|
||||
return i18n.t("desktop.updates.status.upToDate");
|
||||
return lastCheckedAt != null
|
||||
? i18n.t("desktop.updates.status.upToDateWithLastChecked", {
|
||||
time: formatLastCheckedAt(lastCheckedAt),
|
||||
})
|
||||
: i18n.t("desktop.updates.status.upToDate");
|
||||
}
|
||||
|
||||
if (status === "pending") {
|
||||
if (availableUpdate?.latestVersion) {
|
||||
return i18n.t(
|
||||
lastCheckedAt != null
|
||||
? "desktop.updates.status.pendingWithVersionAndLastChecked"
|
||||
: "desktop.updates.status.pendingWithVersion",
|
||||
{
|
||||
version: formatVersion(availableUpdate.latestVersion),
|
||||
time: lastCheckedAt != null ? formatLastCheckedAt(lastCheckedAt) : undefined,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (lastCheckedAt != null) {
|
||||
return i18n.t("desktop.updates.status.pendingWithLastChecked", {
|
||||
time: formatLastCheckedAt(lastCheckedAt),
|
||||
});
|
||||
}
|
||||
return i18n.t("desktop.updates.status.pending");
|
||||
return formatPendingStatusText({
|
||||
availableUpdate,
|
||||
downloadProgress,
|
||||
lastCheckedAt,
|
||||
formatVersion,
|
||||
formatLastCheckedAt,
|
||||
});
|
||||
}
|
||||
|
||||
if (status === "available") {
|
||||
if (availableUpdate?.latestVersion) {
|
||||
return i18n.t(
|
||||
lastCheckedAt != null
|
||||
? "desktop.updates.status.availableWithVersionAndLastChecked"
|
||||
: "desktop.updates.status.availableWithVersion",
|
||||
{
|
||||
version: formatVersion(availableUpdate.latestVersion),
|
||||
time: lastCheckedAt != null ? formatLastCheckedAt(lastCheckedAt) : undefined,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (lastCheckedAt != null) {
|
||||
return i18n.t("desktop.updates.status.availableWithLastChecked", {
|
||||
time: formatLastCheckedAt(lastCheckedAt),
|
||||
});
|
||||
}
|
||||
return i18n.t("desktop.updates.status.available");
|
||||
return formatAvailableStatusText({
|
||||
availableUpdate,
|
||||
lastCheckedAt,
|
||||
formatVersion,
|
||||
formatLastCheckedAt,
|
||||
});
|
||||
}
|
||||
|
||||
if (status === "installed") {
|
||||
return installMessage ?? i18n.t("desktop.updates.status.installed");
|
||||
}
|
||||
|
||||
if (status === "error") {
|
||||
return i18n.t("desktop.updates.status.failed");
|
||||
}
|
||||
|
||||
if (status === "error") return i18n.t("desktop.updates.status.failed");
|
||||
return i18n.t("desktop.updates.status.idle");
|
||||
}
|
||||
|
||||
@@ -202,6 +278,16 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
}
|
||||
}
|
||||
|
||||
function setDownloadProgress(progress: DesktopAppUpdateDownloadProgress | null): void {
|
||||
if (progress === null && state.downloadProgress === null) {
|
||||
return;
|
||||
}
|
||||
commit({
|
||||
...state,
|
||||
downloadProgress: progress,
|
||||
});
|
||||
}
|
||||
|
||||
async function checkForUpdates(options?: {
|
||||
releaseChannel: DesktopReleaseChannel;
|
||||
intent?: DesktopAppUpdateCheckIntent;
|
||||
@@ -211,7 +297,7 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
return null;
|
||||
}
|
||||
const { releaseChannel, intent = "manual", silent = false } = options;
|
||||
if (silent && state.status === "checking") {
|
||||
if (silent && (state.status === "checking" || state.isInstalling)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -241,6 +327,7 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
...state,
|
||||
status: "error",
|
||||
availableUpdate: null,
|
||||
downloadProgress: null,
|
||||
errorMessage: result.errorMessage,
|
||||
installMessage: null,
|
||||
lastCheckedAt: nextLastCheckedAt,
|
||||
@@ -248,24 +335,13 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
return result;
|
||||
}
|
||||
|
||||
let nextStatus: DesktopAppUpdateStatus;
|
||||
let nextAvailable: DesktopAppUpdateCheckResult | null;
|
||||
|
||||
if (result.readyToInstall) {
|
||||
nextStatus = "available";
|
||||
nextAvailable = result;
|
||||
} else if (result.hasUpdate) {
|
||||
nextStatus = "pending";
|
||||
nextAvailable = result;
|
||||
} else {
|
||||
nextStatus = "up-to-date";
|
||||
nextAvailable = null;
|
||||
}
|
||||
const outcome = resolveCheckOutcome(result);
|
||||
|
||||
commit({
|
||||
...state,
|
||||
status: nextStatus,
|
||||
availableUpdate: nextAvailable,
|
||||
status: outcome.status,
|
||||
availableUpdate: outcome.availableUpdate,
|
||||
downloadProgress: outcome.status === "pending" ? state.downloadProgress : null,
|
||||
errorMessage: null,
|
||||
installMessage: null,
|
||||
lastCheckedAt: nextLastCheckedAt,
|
||||
@@ -284,6 +360,7 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
commit({
|
||||
...state,
|
||||
status: "error",
|
||||
downloadProgress: null,
|
||||
errorMessage: message,
|
||||
lastCheckedAt: intent === "manual" ? deps.now() : state.lastCheckedAt,
|
||||
});
|
||||
@@ -295,6 +372,10 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
async function installUpdate(options: {
|
||||
releaseChannel: DesktopReleaseChannel;
|
||||
}): Promise<DesktopAppUpdateInstallResult | null> {
|
||||
if (state.isInstalling) {
|
||||
return null;
|
||||
}
|
||||
|
||||
commit({
|
||||
...state,
|
||||
status: "installing",
|
||||
@@ -307,10 +388,23 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
releaseChannel: options.releaseChannel,
|
||||
});
|
||||
const nextLastCheckedAt = deps.now();
|
||||
if (!result.installed && result.errorMessage) {
|
||||
commit({
|
||||
...state,
|
||||
status: "error",
|
||||
downloadProgress: null,
|
||||
errorMessage: result.errorMessage,
|
||||
installMessage: null,
|
||||
lastCheckedAt: nextLastCheckedAt,
|
||||
isInstalling: false,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
commit({
|
||||
...state,
|
||||
status: result.installed ? "installed" : "up-to-date",
|
||||
availableUpdate: null,
|
||||
downloadProgress: null,
|
||||
installMessage: result.message,
|
||||
lastCheckedAt: nextLastCheckedAt,
|
||||
isInstalling: false,
|
||||
@@ -326,6 +420,7 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
commit({
|
||||
...state,
|
||||
status: "error",
|
||||
downloadProgress: null,
|
||||
errorMessage: message,
|
||||
isInstalling: false,
|
||||
});
|
||||
@@ -341,6 +436,7 @@ export function createDesktopAppUpdater(deps: DesktopAppUpdaterDeps): DesktopApp
|
||||
listeners.delete(listener);
|
||||
};
|
||||
},
|
||||
setDownloadProgress,
|
||||
checkForUpdates,
|
||||
installUpdate,
|
||||
};
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { isElectronRuntime } from "@/desktop/host";
|
||||
import { listenToDesktopEvent, type DesktopEventUnlisten } from "@/desktop/electron/events";
|
||||
import { invokeDesktopCommand } from "@/desktop/electron/invoke";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { i18n } from "@/i18n/i18next";
|
||||
|
||||
export interface DesktopAppUpdateDownloadProgress {
|
||||
version: string | null;
|
||||
percent: number;
|
||||
transferred: number;
|
||||
total: number;
|
||||
bytesPerSecond: number;
|
||||
}
|
||||
|
||||
export interface DesktopAppUpdateCheckResult {
|
||||
hasUpdate: boolean;
|
||||
readyToInstall: boolean;
|
||||
downloading: boolean;
|
||||
currentVersion: string | null;
|
||||
latestVersion: string | null;
|
||||
body: string | null;
|
||||
@@ -17,6 +27,7 @@ export interface DesktopAppUpdateInstallResult {
|
||||
installed: boolean;
|
||||
version: string | null;
|
||||
message: string;
|
||||
errorMessage?: string | null;
|
||||
}
|
||||
|
||||
export interface DesktopRuntimeInfo {
|
||||
@@ -115,9 +126,13 @@ export async function checkDesktopAppUpdate({
|
||||
throw new Error("Unexpected response while checking desktop updates.");
|
||||
}
|
||||
|
||||
const hasUpdate = result.hasUpdate === true;
|
||||
const readyToInstall = result.readyToInstall === true;
|
||||
return {
|
||||
hasUpdate: result.hasUpdate === true,
|
||||
readyToInstall: result.readyToInstall === true,
|
||||
hasUpdate,
|
||||
readyToInstall,
|
||||
downloading:
|
||||
typeof result.downloading === "boolean" ? result.downloading : hasUpdate && !readyToInstall,
|
||||
currentVersion: toStringOrNull(result.currentVersion),
|
||||
latestVersion: toStringOrNull(result.latestVersion),
|
||||
body: toStringOrNull(result.body),
|
||||
@@ -126,6 +141,36 @@ export async function checkDesktopAppUpdate({
|
||||
};
|
||||
}
|
||||
|
||||
export function parseDesktopAppUpdateDownloadProgress(
|
||||
raw: unknown,
|
||||
): DesktopAppUpdateDownloadProgress | null {
|
||||
if (!isRecord(raw)) {
|
||||
return null;
|
||||
}
|
||||
const percent = toNumberOr(Number.NaN, raw.percent);
|
||||
if (!Number.isFinite(percent)) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
version: toStringOrNull(raw.version),
|
||||
percent: Math.max(0, Math.min(100, percent)),
|
||||
transferred: toNumberOr(0, raw.transferred),
|
||||
total: toNumberOr(0, raw.total),
|
||||
bytesPerSecond: toNumberOr(0, raw.bytesPerSecond),
|
||||
};
|
||||
}
|
||||
|
||||
export async function subscribeDesktopAppUpdateDownloadProgress(
|
||||
handler: (progress: DesktopAppUpdateDownloadProgress | null) => void,
|
||||
): Promise<DesktopEventUnlisten> {
|
||||
if (!shouldShowDesktopUpdateSection()) {
|
||||
return () => {};
|
||||
}
|
||||
return listenToDesktopEvent<unknown>("app-update-download-progress", (payload) => {
|
||||
handler(payload === null ? null : parseDesktopAppUpdateDownloadProgress(payload));
|
||||
});
|
||||
}
|
||||
|
||||
export async function installDesktopAppUpdate({
|
||||
releaseChannel,
|
||||
}: {
|
||||
@@ -136,10 +181,12 @@ export async function installDesktopAppUpdate({
|
||||
throw new Error("Unexpected response while installing desktop update.");
|
||||
}
|
||||
|
||||
const errorMessage = toStringOrNull(result.errorMessage);
|
||||
return {
|
||||
installed: result.installed === true,
|
||||
version: toStringOrNull(result.version),
|
||||
message: toStringOrNull(result.message) ?? i18n.t("desktop.updates.status.installed"),
|
||||
...(errorMessage ? { errorMessage } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,50 @@ describe("resolveUpdateCalloutDescriptor", () => {
|
||||
expect(descriptor?.dismissalKey).toBe("desktop-update:installing:1.2.3");
|
||||
});
|
||||
|
||||
it("labels the callout as Download when the update has not been downloaded yet", () => {
|
||||
const descriptor = resolveUpdateCalloutDescriptor(
|
||||
input({ availableUpdate: { latestVersion: "1.2.3", readyToInstall: false } }),
|
||||
);
|
||||
|
||||
expect(descriptor?.title).toBe("Update available");
|
||||
expect(descriptor?.body).toEqual({
|
||||
kind: "available",
|
||||
versionLabel: "v1.2.3",
|
||||
readyToInstall: false,
|
||||
});
|
||||
expect(descriptor?.actions).toEqual([
|
||||
{ role: "changelog", label: "What's new" },
|
||||
{ role: "install", label: "Download", variant: "primary", disabled: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it("shows download progress while downloading an update", () => {
|
||||
const descriptor = resolveUpdateCalloutDescriptor(
|
||||
input({
|
||||
status: "installing",
|
||||
isInstalling: true,
|
||||
downloadProgress: {
|
||||
version: "1.2.3",
|
||||
percent: 42.2,
|
||||
transferred: 42,
|
||||
total: 100,
|
||||
bytesPerSecond: 10,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(descriptor?.title).toBe("Downloading update");
|
||||
expect(descriptor?.body).toEqual({
|
||||
kind: "downloading",
|
||||
versionLabel: "v1.2.3",
|
||||
percent: 42,
|
||||
});
|
||||
expect(descriptor?.actions).toEqual([
|
||||
{ role: "changelog", label: "What's new" },
|
||||
{ role: "install", label: "Downloading...", variant: "primary", disabled: true },
|
||||
]);
|
||||
});
|
||||
|
||||
it("shows a retry action and surfaces the error message on error", () => {
|
||||
const descriptor = resolveUpdateCalloutDescriptor(
|
||||
input({ status: "error", errorMessage: "Download failed", availableUpdate: null }),
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { DesktopAppUpdateStatus } from "@/desktop/updates/use-desktop-app-updater";
|
||||
import type { DesktopAppUpdateDownloadProgress } from "@/desktop/updates/desktop-updates";
|
||||
import { i18n } from "@/i18n/i18next";
|
||||
|
||||
export type UpdateCalloutBody =
|
||||
| { kind: "available"; versionLabel: string | null }
|
||||
| { kind: "available"; versionLabel: string | null; readyToInstall?: boolean }
|
||||
| { kind: "downloading"; versionLabel: string | null; percent: number }
|
||||
| { kind: "installing" }
|
||||
| { kind: "error"; message: string };
|
||||
|
||||
@@ -31,7 +33,8 @@ export interface ResolveUpdateCalloutInput {
|
||||
isDesktopApp: boolean;
|
||||
status: DesktopAppUpdateStatus;
|
||||
isInstalling: boolean;
|
||||
availableUpdate: { latestVersion?: string | null } | null;
|
||||
availableUpdate: { latestVersion?: string | null; readyToInstall?: boolean } | null;
|
||||
downloadProgress?: DesktopAppUpdateDownloadProgress | null;
|
||||
errorMessage: string | null;
|
||||
}
|
||||
|
||||
@@ -40,6 +43,59 @@ function formatVersionLabel(latestVersion: string | null | undefined): string |
|
||||
return `v${latestVersion.replace(/^v/i, "")}`;
|
||||
}
|
||||
|
||||
function resolveCalloutPresentation(input: {
|
||||
isError: boolean;
|
||||
isInstalling: boolean;
|
||||
readyToInstall: boolean;
|
||||
latestVersion: string | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null | undefined;
|
||||
errorMessage: string | null;
|
||||
}): { title: string; body: UpdateCalloutBody } {
|
||||
if (input.isInstalling && input.downloadProgress != null) {
|
||||
return {
|
||||
title: i18n.t("desktop.updates.callout.downloadingTitle"),
|
||||
body: {
|
||||
kind: "downloading",
|
||||
versionLabel: formatVersionLabel(input.latestVersion),
|
||||
percent: Math.round(input.downloadProgress.percent),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (input.isInstalling) {
|
||||
return {
|
||||
title: i18n.t("desktop.updates.callout.installingTitle"),
|
||||
body: { kind: "installing" },
|
||||
};
|
||||
}
|
||||
if (input.isError) {
|
||||
return {
|
||||
title: i18n.t("desktop.updates.callout.failedTitle"),
|
||||
body: {
|
||||
kind: "error",
|
||||
message: input.errorMessage ?? i18n.t("desktop.updates.callout.genericError"),
|
||||
},
|
||||
};
|
||||
}
|
||||
const versionLabel = formatVersionLabel(input.latestVersion);
|
||||
return {
|
||||
title: i18n.t("desktop.updates.callout.availableTitle"),
|
||||
body: input.readyToInstall
|
||||
? { kind: "available", versionLabel }
|
||||
: { kind: "available", versionLabel, readyToInstall: false },
|
||||
};
|
||||
}
|
||||
|
||||
function resolveInstallActionLabel(input: {
|
||||
isDownloading: boolean;
|
||||
isInstalling: boolean;
|
||||
readyToInstall: boolean;
|
||||
}): string {
|
||||
if (input.isDownloading) return i18n.t("desktop.updates.callout.downloadingAction");
|
||||
if (input.isInstalling) return i18n.t("desktop.updates.callout.installingAction");
|
||||
if (input.readyToInstall) return i18n.t("desktop.updates.callout.installAndRestart");
|
||||
return i18n.t("desktop.updates.callout.downloadAndRestart");
|
||||
}
|
||||
|
||||
export function resolveUpdateCalloutDescriptor(
|
||||
input: ResolveUpdateCalloutInput,
|
||||
): UpdateCalloutDescriptor | null {
|
||||
@@ -50,26 +106,22 @@ export function resolveUpdateCalloutDescriptor(
|
||||
|
||||
const isError = input.status === "error";
|
||||
const isInstalling = input.isInstalling;
|
||||
const isDownloading = isInstalling && input.downloadProgress != null;
|
||||
const isAvailable = !isInstalling && !isError;
|
||||
const readyToInstall = input.availableUpdate?.readyToInstall !== false;
|
||||
|
||||
const latestVersion = input.availableUpdate?.latestVersion ?? null;
|
||||
const latestVersion =
|
||||
input.availableUpdate?.latestVersion ?? input.downloadProgress?.version ?? null;
|
||||
const dismissalKey = `desktop-update:${input.status}:${latestVersion ?? "unknown"}`;
|
||||
|
||||
let title: string;
|
||||
let body: UpdateCalloutBody;
|
||||
if (isInstalling) {
|
||||
title = i18n.t("desktop.updates.callout.installingTitle");
|
||||
body = { kind: "installing" };
|
||||
} else if (isError) {
|
||||
title = i18n.t("desktop.updates.callout.failedTitle");
|
||||
body = {
|
||||
kind: "error",
|
||||
message: input.errorMessage ?? i18n.t("desktop.updates.callout.genericError"),
|
||||
};
|
||||
} else {
|
||||
title = i18n.t("desktop.updates.callout.availableTitle");
|
||||
body = { kind: "available", versionLabel: formatVersionLabel(latestVersion) };
|
||||
}
|
||||
const { title, body } = resolveCalloutPresentation({
|
||||
isError,
|
||||
isInstalling,
|
||||
readyToInstall,
|
||||
latestVersion,
|
||||
downloadProgress: input.downloadProgress,
|
||||
errorMessage: input.errorMessage,
|
||||
});
|
||||
|
||||
const actions: UpdateCalloutActionDescriptor[] = [
|
||||
{ role: "changelog", label: i18n.t("desktop.updates.callout.whatsNew") },
|
||||
@@ -79,9 +131,7 @@ export function resolveUpdateCalloutDescriptor(
|
||||
} else {
|
||||
actions.push({
|
||||
role: "install",
|
||||
label: isInstalling
|
||||
? i18n.t("desktop.updates.callout.installingAction")
|
||||
: i18n.t("desktop.updates.callout.installAndRestart"),
|
||||
label: resolveInstallActionLabel({ isDownloading, isInstalling, readyToInstall }),
|
||||
variant: "primary",
|
||||
disabled: isInstalling,
|
||||
});
|
||||
|
||||
@@ -34,9 +34,12 @@ type InstallOutcome =
|
||||
function buildCheckResult(
|
||||
overrides: Partial<DesktopAppUpdateCheckResult> = {},
|
||||
): DesktopAppUpdateCheckResult {
|
||||
const hasUpdate = overrides.hasUpdate ?? false;
|
||||
const readyToInstall = overrides.readyToInstall ?? false;
|
||||
return {
|
||||
hasUpdate: false,
|
||||
readyToInstall: false,
|
||||
hasUpdate,
|
||||
readyToInstall,
|
||||
downloading: overrides.downloading ?? (hasUpdate && !readyToInstall),
|
||||
currentVersion: null,
|
||||
latestVersion: null,
|
||||
body: null,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Gift } from "lucide-react-native";
|
||||
import { type ReactNode, useEffect, useRef } from "react";
|
||||
import { type ReactNode, useEffect, useMemo, useRef } from "react";
|
||||
import { View } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useUnistyles } from "react-native-unistyles";
|
||||
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
||||
import {
|
||||
type SidebarCalloutAction,
|
||||
SidebarCalloutDescriptionText,
|
||||
@@ -19,9 +20,24 @@ import { openChangelog } from "@/changelog";
|
||||
const CHECK_INTERVAL_MS = 30 * 60 * 1000;
|
||||
|
||||
function renderBody(body: UpdateCalloutBody, t: ReturnType<typeof useTranslation>["t"]): ReactNode {
|
||||
if (body.kind === "downloading") {
|
||||
return (
|
||||
<UpdateDownloadingDescription
|
||||
versionLabel={body.versionLabel ?? undefined}
|
||||
percent={body.percent}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (body.kind === "installing") return t("desktop.updates.callout.installingDescription");
|
||||
if (body.kind === "error") return body.message;
|
||||
return <UpdateAvailableDescription versionLabel={body.versionLabel ?? undefined} t={t} />;
|
||||
return (
|
||||
<UpdateAvailableDescription
|
||||
versionLabel={body.versionLabel ?? undefined}
|
||||
readyToInstall={body.readyToInstall !== false}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function materializeActions(
|
||||
@@ -42,8 +58,11 @@ export function UpdateCalloutSource() {
|
||||
const { theme } = useUnistyles();
|
||||
const {
|
||||
isDesktopApp,
|
||||
updateMode,
|
||||
isLoadingSettings,
|
||||
status,
|
||||
availableUpdate,
|
||||
downloadProgress,
|
||||
errorMessage,
|
||||
checkForUpdates,
|
||||
installUpdate,
|
||||
@@ -58,7 +77,7 @@ export function UpdateCalloutSource() {
|
||||
void checkForUpdates();
|
||||
});
|
||||
useEffect(() => {
|
||||
if (!isDesktopApp) return;
|
||||
if (!isDesktopApp || isLoadingSettings || updateMode === "off") return;
|
||||
|
||||
void checkForUpdates({ intent: "automatic", silent: true });
|
||||
|
||||
@@ -71,7 +90,7 @@ export function UpdateCalloutSource() {
|
||||
clearInterval(intervalRef.current);
|
||||
}
|
||||
};
|
||||
}, [isDesktopApp, checkForUpdates]);
|
||||
}, [isDesktopApp, isLoadingSettings, updateMode, checkForUpdates]);
|
||||
|
||||
useEffect(() => {
|
||||
const descriptor = resolveUpdateCalloutDescriptor({
|
||||
@@ -79,6 +98,7 @@ export function UpdateCalloutSource() {
|
||||
status,
|
||||
isInstalling,
|
||||
availableUpdate,
|
||||
downloadProgress,
|
||||
errorMessage,
|
||||
});
|
||||
if (!descriptor) return;
|
||||
@@ -103,6 +123,7 @@ export function UpdateCalloutSource() {
|
||||
}, [
|
||||
availableUpdate,
|
||||
callouts,
|
||||
downloadProgress,
|
||||
errorMessage,
|
||||
install,
|
||||
isDesktopApp,
|
||||
@@ -117,23 +138,94 @@ export function UpdateCalloutSource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatAvailableSummary(
|
||||
t: ReturnType<typeof useTranslation>["t"],
|
||||
versionLabel: string | undefined,
|
||||
readyToInstall: boolean,
|
||||
): string {
|
||||
if (readyToInstall) {
|
||||
return versionLabel
|
||||
? t("desktop.updates.callout.versionReady", { version: versionLabel })
|
||||
: t("desktop.updates.callout.newVersionReady");
|
||||
}
|
||||
return versionLabel
|
||||
? t("desktop.updates.callout.versionAvailable", { version: versionLabel })
|
||||
: t("desktop.updates.callout.newVersionAvailable");
|
||||
}
|
||||
|
||||
function UpdateAvailableDescription({
|
||||
versionLabel,
|
||||
readyToInstall,
|
||||
t,
|
||||
}: {
|
||||
versionLabel?: string;
|
||||
readyToInstall: boolean;
|
||||
t: ReturnType<typeof useTranslation>["t"];
|
||||
}) {
|
||||
const summary = formatAvailableSummary(t, versionLabel, readyToInstall);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SidebarCalloutDescriptionText>
|
||||
{versionLabel
|
||||
? t("desktop.updates.callout.versionReady", { version: versionLabel })
|
||||
: t("desktop.updates.callout.newVersionReady")}
|
||||
</SidebarCalloutDescriptionText>
|
||||
<SidebarCalloutDescriptionText>{summary}</SidebarCalloutDescriptionText>
|
||||
<SidebarCalloutDescriptionText>
|
||||
{t("desktop.updates.callout.restartWarning")}
|
||||
</SidebarCalloutDescriptionText>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function UpdateDownloadingDescription({
|
||||
versionLabel,
|
||||
percent,
|
||||
t,
|
||||
}: {
|
||||
versionLabel?: string;
|
||||
percent: number;
|
||||
t: ReturnType<typeof useTranslation>["t"];
|
||||
}) {
|
||||
const clampedPercent = Math.max(0, Math.min(100, percent));
|
||||
const accessibilityValue = useMemo(
|
||||
() => ({ min: 0, max: 100, now: clampedPercent }),
|
||||
[clampedPercent],
|
||||
);
|
||||
const progressFillStyle = useMemo(
|
||||
() => [styles.progressFill, { width: `${clampedPercent}%` as const }],
|
||||
[clampedPercent],
|
||||
);
|
||||
return (
|
||||
<View style={styles.progressContainer}>
|
||||
<SidebarCalloutDescriptionText>
|
||||
{versionLabel
|
||||
? t("desktop.updates.callout.downloadingVersionDescription", {
|
||||
version: versionLabel,
|
||||
percent: clampedPercent,
|
||||
})
|
||||
: t("desktop.updates.callout.downloadingDescription", { percent: clampedPercent })}
|
||||
</SidebarCalloutDescriptionText>
|
||||
<View
|
||||
style={styles.progressTrack}
|
||||
accessibilityRole="progressbar"
|
||||
accessibilityValue={accessibilityValue}
|
||||
>
|
||||
<View style={progressFillStyle} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
progressContainer: {
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
progressTrack: {
|
||||
height: 4,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
backgroundColor: theme.colors.surface3,
|
||||
overflow: "hidden",
|
||||
},
|
||||
progressFill: {
|
||||
height: "100%",
|
||||
borderRadius: theme.borderRadius.full,
|
||||
backgroundColor: theme.colors.accent,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,30 +1,94 @@
|
||||
import { useCallback, useEffect, useMemo, useSyncExternalStore } from "react";
|
||||
import { useCallback, useEffect, useSyncExternalStore } from "react";
|
||||
import {
|
||||
checkDesktopAppUpdate,
|
||||
formatVersionWithPrefix,
|
||||
installDesktopAppUpdate,
|
||||
shouldShowDesktopUpdateSection,
|
||||
subscribeDesktopAppUpdateDownloadProgress,
|
||||
type DesktopAppUpdateCheckResult,
|
||||
type DesktopAppUpdateCheckIntent,
|
||||
type DesktopAppUpdateDownloadProgress,
|
||||
type DesktopAppUpdateInstallResult,
|
||||
} from "@/desktop/updates/desktop-updates";
|
||||
import { useDesktopSettings } from "@/desktop/settings/desktop-settings";
|
||||
import { useDesktopSettings, type DesktopUpdateMode } from "@/desktop/settings/desktop-settings";
|
||||
import { useDesktopIpcErrorReporter } from "@/desktop/hooks/desktop-ipc-error";
|
||||
import {
|
||||
PENDING_RECHECK_MS,
|
||||
createDesktopAppUpdater,
|
||||
formatStatusText,
|
||||
type DesktopAppUpdater,
|
||||
type DesktopAppUpdaterErrorReport,
|
||||
type DesktopAppUpdateStatus,
|
||||
} from "@/desktop/updates/desktop-app-updater";
|
||||
import { formatMessageTimestamp } from "@/utils/time";
|
||||
|
||||
export type { DesktopAppUpdateStatus };
|
||||
|
||||
let activeInstallErrorReporter: ((report: DesktopAppUpdaterErrorReport) => void) | null = null;
|
||||
let sharedDesktopAppUpdater: DesktopAppUpdater | null = null;
|
||||
let progressSubscriptionCount = 0;
|
||||
let progressUnsubscribe: (() => void) | null = null;
|
||||
|
||||
function getSharedDesktopAppUpdater(): DesktopAppUpdater {
|
||||
if (!sharedDesktopAppUpdater) {
|
||||
sharedDesktopAppUpdater = createDesktopAppUpdater({
|
||||
port: {
|
||||
checkDesktopAppUpdate,
|
||||
installDesktopAppUpdate,
|
||||
},
|
||||
now: () => Date.now(),
|
||||
reportInstallError: (report) => {
|
||||
activeInstallErrorReporter?.(report);
|
||||
},
|
||||
});
|
||||
}
|
||||
return sharedDesktopAppUpdater;
|
||||
}
|
||||
|
||||
function retainDownloadProgressSubscription(updater: DesktopAppUpdater): () => void {
|
||||
progressSubscriptionCount += 1;
|
||||
if (progressSubscriptionCount === 1) {
|
||||
let active = true;
|
||||
const teardown = () => {
|
||||
active = false;
|
||||
};
|
||||
progressUnsubscribe = teardown;
|
||||
void subscribeDesktopAppUpdateDownloadProgress((progress) => {
|
||||
if (active) {
|
||||
updater.setDownloadProgress(progress);
|
||||
}
|
||||
})
|
||||
.then((cleanup) => {
|
||||
if (active) {
|
||||
progressUnsubscribe = () => {
|
||||
active = false;
|
||||
cleanup();
|
||||
};
|
||||
} else {
|
||||
cleanup();
|
||||
}
|
||||
return undefined;
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
|
||||
return () => {
|
||||
progressSubscriptionCount = Math.max(0, progressSubscriptionCount - 1);
|
||||
if (progressSubscriptionCount === 0) {
|
||||
progressUnsubscribe?.();
|
||||
progressUnsubscribe = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface UseDesktopAppUpdaterReturn {
|
||||
isDesktopApp: boolean;
|
||||
updateMode: DesktopUpdateMode;
|
||||
isLoadingSettings: boolean;
|
||||
status: DesktopAppUpdateStatus;
|
||||
statusText: string;
|
||||
availableUpdate: DesktopAppUpdateCheckResult | null;
|
||||
downloadProgress: DesktopAppUpdateDownloadProgress | null;
|
||||
errorMessage: string | null;
|
||||
lastCheckedAt: number | null;
|
||||
isChecking: boolean;
|
||||
@@ -38,22 +102,15 @@ export interface UseDesktopAppUpdaterReturn {
|
||||
|
||||
export function useDesktopAppUpdater(): UseDesktopAppUpdaterReturn {
|
||||
const isDesktopApp = shouldShowDesktopUpdateSection();
|
||||
const { settings: desktopSettings } = useDesktopSettings();
|
||||
const { settings: desktopSettings, isLoading: isLoadingSettings } = useDesktopSettings();
|
||||
const releaseChannel = desktopSettings.releaseChannel;
|
||||
const updateMode = desktopSettings.updates.mode;
|
||||
const reportError = useDesktopIpcErrorReporter();
|
||||
const updater = getSharedDesktopAppUpdater();
|
||||
|
||||
const updater = useMemo(
|
||||
() =>
|
||||
createDesktopAppUpdater({
|
||||
port: {
|
||||
checkDesktopAppUpdate,
|
||||
installDesktopAppUpdate,
|
||||
},
|
||||
now: () => Date.now(),
|
||||
reportInstallError: reportError,
|
||||
}),
|
||||
[reportError],
|
||||
);
|
||||
useEffect(() => {
|
||||
activeInstallErrorReporter = reportError;
|
||||
}, [reportError]);
|
||||
|
||||
const snapshot = useSyncExternalStore(
|
||||
updater.subscribe,
|
||||
@@ -84,13 +141,20 @@ export function useDesktopAppUpdater(): UseDesktopAppUpdaterReturn {
|
||||
|
||||
useEffect(() => {
|
||||
if (!isDesktopApp) {
|
||||
return undefined;
|
||||
}
|
||||
return retainDownloadProgressSubscription(updater);
|
||||
}, [isDesktopApp, updater]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isDesktopApp || isLoadingSettings || updateMode === "off") {
|
||||
return;
|
||||
}
|
||||
void checkForUpdates({ intent: "automatic", silent: true });
|
||||
}, [checkForUpdates, isDesktopApp]);
|
||||
}, [checkForUpdates, isDesktopApp, isLoadingSettings, updateMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isDesktopApp || snapshot.status !== "pending") {
|
||||
if (!isDesktopApp || snapshot.status !== "pending" || updateMode === "off") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -101,20 +165,24 @@ export function useDesktopAppUpdater(): UseDesktopAppUpdaterReturn {
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, [checkForUpdates, isDesktopApp, snapshot.status]);
|
||||
}, [checkForUpdates, isDesktopApp, snapshot.status, updateMode]);
|
||||
|
||||
return {
|
||||
isDesktopApp,
|
||||
updateMode,
|
||||
isLoadingSettings,
|
||||
status: snapshot.status,
|
||||
statusText: formatStatusText({
|
||||
status: snapshot.status,
|
||||
availableUpdate: snapshot.availableUpdate,
|
||||
downloadProgress: snapshot.downloadProgress,
|
||||
installMessage: snapshot.installMessage,
|
||||
lastCheckedAt: snapshot.lastCheckedAt,
|
||||
formatVersion: formatVersionWithPrefix,
|
||||
formatLastCheckedAt: (timestamp) => formatMessageTimestamp(new Date(timestamp)),
|
||||
}),
|
||||
availableUpdate: snapshot.availableUpdate,
|
||||
downloadProgress: snapshot.downloadProgress,
|
||||
errorMessage: snapshot.errorMessage,
|
||||
lastCheckedAt: snapshot.lastCheckedAt,
|
||||
isChecking: snapshot.isChecking,
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export { PairDeviceModal } from "./pair-device-modal";
|
||||
export { WaysToConnect } from "./ways-to-connect";
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-modal-sheet";
|
||||
import { PairDeviceSection } from "@/desktop/components/pair-device-section";
|
||||
import { PairDeviceSection } from "@/devices/pair-device-section";
|
||||
|
||||
export interface PairDeviceModalProps {
|
||||
serverId: string;
|
||||
+1
-1
@@ -23,7 +23,7 @@ import {
|
||||
|
||||
const RELAY_DOCS_URL = "https://paseo.sh/docs/security";
|
||||
export const CONNECTIVITY_DOCS_URL = "https://paseo.sh/docs/connectivity";
|
||||
export const TAILSCALE_DOCS_URL = `${CONNECTIVITY_DOCS_URL}#tailscale`;
|
||||
const TAILSCALE_DOCS_URL = `${CONNECTIVITY_DOCS_URL}#tailscale`;
|
||||
const FLEX_ONE_STYLE = { flex: 1 } as const;
|
||||
const ThemedLoadingSpinner = withUnistyles(LoadingSpinner);
|
||||
const ThemedShieldCheck = withUnistyles(ShieldCheck);
|
||||
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { TailscaleStatus } from "@getpaseo/protocol/messages";
|
||||
import { i18n } from "@/i18n/i18next";
|
||||
import { describeTailscale } from "./tailscale-hint";
|
||||
|
||||
// Statuses as the host reports them; see `createDaemonListeners` in the server's listeners.ts.
|
||||
const off: TailscaleStatus = { ip: "100.101.102.103", address: null, state: "off" };
|
||||
|
||||
describe("the Tailscale row's hint", () => {
|
||||
it("says why Tailscale stays off when the host listens on a socket", () => {
|
||||
const socketHint = "Off, because this host listens on a local socket";
|
||||
expect(describeTailscale({ ...off, lockedBy: "main", mainIsSocket: true }, i18n.t)).toBe(
|
||||
socketHint,
|
||||
);
|
||||
expect(describeTailscale({ ...off, lockedBy: "launch", mainIsSocket: true }, i18n.t)).toBe(
|
||||
socketHint,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the hint of every other state", () => {
|
||||
const hint = (status: TailscaleStatus) => describeTailscale(status, i18n.t);
|
||||
expect(hint(off)).toBe("Direct over your tailnet, enter an address");
|
||||
expect(hint({ ip: null, address: null, state: "unavailable", lockedBy: "launch" })).toBe(
|
||||
"Tailscale is not running on this host",
|
||||
);
|
||||
expect(hint({ ...off, state: "waiting", address: "100.101.102.103:6767" })).toBe(
|
||||
"Waiting for Tailscale to start on this host",
|
||||
);
|
||||
expect(hint({ ...off, state: "on", address: "100.101.102.103:6767", lockedBy: "main" })).toBe(
|
||||
"Always on, because this host already accepts Tailscale connections",
|
||||
);
|
||||
expect(hint({ ...off, lockedBy: "launch" })).toBe(
|
||||
"Controlled by the command that starts this host",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { TailscaleStatus } from "@getpaseo/protocol/messages";
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
/** The line under the Tailscale label for each state the host reports, most specific first. */
|
||||
export function describeTailscale(status: TailscaleStatus, t: TFunction): string {
|
||||
if (status.state === "unavailable") return t("devices.tailscale.unavailable");
|
||||
if (status.state === "waiting") return t("devices.tailscale.waiting");
|
||||
// A socket is why Tailscale cannot be on, even when the launch command also fixes the address.
|
||||
if (status.mainIsSocket) return t("devices.tailscale.socket");
|
||||
if (status.lockedBy === "launch") return t("devices.tailscale.launch");
|
||||
if (status.lockedBy === "main") return t("devices.tailscale.alwaysOn");
|
||||
return t("devices.tailscale.hint");
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { RotateCw } from "lucide-react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import {
|
||||
SettingsAction,
|
||||
SettingsRow,
|
||||
SettingsRowChildren,
|
||||
SettingsSwitch,
|
||||
} from "@/components/settings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import { useFetchQuery } from "@/data/query";
|
||||
import { useHostRuntimeClient, useHostRuntimeSnapshot } from "@/runtime/host-runtime";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { confirmDialog } from "@/utils/confirm-dialog";
|
||||
import { copyToClipboard } from "@/utils/copy-to-clipboard";
|
||||
import { describeTailscale } from "./tailscale-hint";
|
||||
import { resolveTailscaleControlState } from "./tailscale-state";
|
||||
|
||||
const UPDATES_DOCS_URL = "https://paseo.sh/docs/updates";
|
||||
const TAILSCALE_DOWNLOAD_URL = "https://tailscale.com/download";
|
||||
// A product name, the same in every language.
|
||||
const LABEL = "Tailscale";
|
||||
|
||||
type HostClient = NonNullable<ReturnType<typeof useHostRuntimeClient>>;
|
||||
|
||||
/**
|
||||
* Turns Tailscale on or off for a host and shows the address a phone on the tailnet adds. Renders
|
||||
* as a row inside a `SettingsCard`; when Tailscale is on, the address is a nested row under it.
|
||||
*/
|
||||
export function TailscaleRow({ serverId }: { serverId: string }) {
|
||||
const { t } = useTranslation();
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const connection = useHostRuntimeSnapshot(serverId)?.connectionStatus;
|
||||
const serverInfo = useSessionStore((state) => state.sessions[serverId]?.serverInfo);
|
||||
const updateLink = useMemo(
|
||||
() => ({ href: UPDATES_DOCS_URL, label: t("devices.tailscale.updateDocs") }),
|
||||
[t],
|
||||
);
|
||||
// COMPAT(tailscale): added in v0.16.0, remove after 2027-05-25 once daemon floor >= v0.16.0.
|
||||
if (serverInfo && serverInfo.features?.tailscale !== true) {
|
||||
return (
|
||||
<SettingsSwitch
|
||||
label={LABEL}
|
||||
hint={t("devices.tailscale.update")}
|
||||
link={updateLink}
|
||||
value={false}
|
||||
disabled
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (client && connection === "online" && serverInfo) {
|
||||
return <TailscaleControl serverId={serverId} client={client} />;
|
||||
}
|
||||
// Without the host the row shows no value: the switch's space stays empty. A host the app has
|
||||
// reached before keeps its server info, so while the app retries it still reads as disconnected.
|
||||
const lost = connection === "offline" || connection === "error" || Boolean(serverInfo);
|
||||
return (
|
||||
<SettingsSwitch
|
||||
label={LABEL}
|
||||
hint={t(lost ? "workspace.terminal.hostDisconnected" : "devices.tailscale.hint")}
|
||||
value={null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function TailscaleControl({ serverId, client }: { serverId: string; client: HostClient }) {
|
||||
const { t } = useTranslation();
|
||||
const tailscale = useTailscale(serverId, client);
|
||||
const { status } = tailscale;
|
||||
const installLink = useMemo(
|
||||
() => ({ href: TAILSCALE_DOWNLOAD_URL, label: t("devices.tailscale.install") }),
|
||||
[t],
|
||||
);
|
||||
const refreshLabel = t(
|
||||
tailscale.refreshing ? "devices.tailscale.refreshing" : "devices.tailscale.refresh",
|
||||
);
|
||||
const refreshButton = tailscale.showRefresh ? (
|
||||
<Tooltip delayDuration={0} enabledOnDesktop enabledOnMobile={false}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
leftIcon={RotateCw}
|
||||
onPress={tailscale.refresh}
|
||||
loading={tailscale.refreshing}
|
||||
disabled={tailscale.refreshDisabled}
|
||||
accessibilityLabel={refreshLabel}
|
||||
testID="devices-tailscale-refresh"
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" align="center" offset={6}>
|
||||
<Text style={styles.tooltipText}>{refreshLabel}</Text>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
) : null;
|
||||
const switchControl = tailscale.showSwitch ? (
|
||||
<Switch
|
||||
value={tailscale.value}
|
||||
onValueChange={tailscale.setEnabled}
|
||||
disabled={tailscale.switchDisabled}
|
||||
accessibilityLabel={LABEL}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsRow
|
||||
label={LABEL}
|
||||
hint={status ? describeTailscale(status, t) : t("devices.tailscale.hint")}
|
||||
link={tailscale.showInstallLink ? installLink : undefined}
|
||||
error={tailscale.error}
|
||||
>
|
||||
{refreshButton && switchControl ? (
|
||||
<View style={styles.controls}>
|
||||
{refreshButton}
|
||||
{switchControl}
|
||||
</View>
|
||||
) : (
|
||||
(refreshButton ?? switchControl)
|
||||
)}
|
||||
</SettingsRow>
|
||||
{tailscale.address ? <TailscaleAddress address={tailscale.address} /> : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TailscaleAddress({ address }: { address: string }) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const copy = useCallback(() => {
|
||||
void copyToClipboard(address)
|
||||
.then(() => toast.copied())
|
||||
.catch(() => toast.error(t("common.errors.error")));
|
||||
}, [address, t, toast]);
|
||||
return (
|
||||
<SettingsRowChildren>
|
||||
<SettingsAction
|
||||
label={address}
|
||||
hint={t("devices.tailscale.address")}
|
||||
actionLabel={t("common.actions.copy")}
|
||||
onPress={copy}
|
||||
testID="devices-tailscale-address"
|
||||
/>
|
||||
</SettingsRowChildren>
|
||||
);
|
||||
}
|
||||
|
||||
interface TailscaleChange {
|
||||
enabled: boolean;
|
||||
confirmed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host's Tailscale state and the one way to change it. While a change is in flight the switch
|
||||
* already shows where it is going, so a tap answers at once; the host's answer then settles it.
|
||||
* Turning Tailscale off over the connection it would cut asks first, and nothing changes on screen
|
||||
* until the user confirms.
|
||||
*/
|
||||
function useTailscale(serverId: string, client: HostClient) {
|
||||
const { t } = useTranslation();
|
||||
const queryClient = useQueryClient();
|
||||
const queryKey = useMemo(() => ["tailscale-status", serverId], [serverId]);
|
||||
const fetchStatus = useCallback(async () => {
|
||||
const { tailscale } = await client.getDaemonStatus({ includeProviders: false });
|
||||
if (!tailscale) throw new Error("Host did not report Tailscale status");
|
||||
return tailscale;
|
||||
}, [client]);
|
||||
|
||||
const query = useFetchQuery({
|
||||
queryKey,
|
||||
queryFn: fetchStatus,
|
||||
// Tailscale can come up after the host does; polling and returning to the window pick it up.
|
||||
refetchInterval: 2_000,
|
||||
refetchOnWindowFocus: true,
|
||||
staleTimeMs: 0,
|
||||
dataShape: "value",
|
||||
});
|
||||
|
||||
const change = useMutation({
|
||||
mutationFn: async ({ enabled, confirmed }: TailscaleChange) => {
|
||||
await queryClient.cancelQueries({ queryKey });
|
||||
return client.setTailscaleEnabled(enabled, confirmed);
|
||||
},
|
||||
onSuccess: (result) => queryClient.setQueryData(queryKey, result.tailscale),
|
||||
});
|
||||
|
||||
const refreshMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
await queryClient.cancelQueries({ queryKey });
|
||||
return fetchStatus();
|
||||
},
|
||||
onSuccess: (tailscale) => queryClient.setQueryData(queryKey, tailscale),
|
||||
});
|
||||
|
||||
const status = query.data;
|
||||
const control = resolveTailscaleControlState({
|
||||
status,
|
||||
statusUpdatedAt: query.dataUpdatedAt,
|
||||
statusError: query.isError,
|
||||
changePending: change.isPending,
|
||||
changePendingEnabled: change.variables?.enabled,
|
||||
changeError: change.isError,
|
||||
changeErrorEnabled: change.variables?.enabled,
|
||||
refreshPending: refreshMutation.isPending,
|
||||
refreshError: refreshMutation.isError,
|
||||
refreshSubmittedAt: refreshMutation.submittedAt,
|
||||
});
|
||||
|
||||
const { mutate, reset: resetChange } = change;
|
||||
const { mutate: runRefresh, reset: resetRefresh } = refreshMutation;
|
||||
const confirmTurnOff = useCallback(
|
||||
() =>
|
||||
confirmDialog({
|
||||
title: t("devices.tailscale.confirmTitle"),
|
||||
message: t("devices.tailscale.confirmMessage"),
|
||||
confirmLabel: t("devices.tailscale.confirmAction"),
|
||||
cancelLabel: t("common.actions.cancel"),
|
||||
destructive: true,
|
||||
}),
|
||||
[t],
|
||||
);
|
||||
const turnOffConfirmed = useCallback(async () => {
|
||||
if (await confirmTurnOff()) {
|
||||
resetRefresh();
|
||||
mutate({ enabled: false, confirmed: true });
|
||||
}
|
||||
}, [confirmTurnOff, mutate, resetRefresh]);
|
||||
const disconnects = status?.disconnectsCurrentConnection === true;
|
||||
const setEnabled = useCallback(
|
||||
(enabled: boolean) => {
|
||||
if (!enabled && disconnects) {
|
||||
void turnOffConfirmed();
|
||||
return;
|
||||
}
|
||||
resetRefresh();
|
||||
mutate(
|
||||
{ enabled, confirmed: false },
|
||||
{
|
||||
// The status was stale: the host would cut this connection after all. Its answer has
|
||||
// already put the row back to on, so the question is asked over what is true.
|
||||
onSuccess: (result) => {
|
||||
if (result.confirmationRequired) void turnOffConfirmed();
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
[disconnects, mutate, resetRefresh, turnOffConfirmed],
|
||||
);
|
||||
const refresh = useCallback(() => {
|
||||
resetChange();
|
||||
runRefresh();
|
||||
}, [resetChange, runRefresh]);
|
||||
|
||||
return {
|
||||
status,
|
||||
value: control.value,
|
||||
showSwitch: control.showSwitch,
|
||||
switchDisabled: control.switchDisabled,
|
||||
showRefresh: control.showRefresh,
|
||||
refreshing: control.refreshing,
|
||||
refreshDisabled: control.refreshDisabled,
|
||||
showInstallLink: control.showInstallLink,
|
||||
error: control.errorKey ? t(control.errorKey) : undefined,
|
||||
// A tap is ignored until the host answers the one before it.
|
||||
setEnabled: control.switchDisabled ? undefined : setEnabled,
|
||||
refresh: control.refreshDisabled ? undefined : refresh,
|
||||
address: control.address,
|
||||
};
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
controls: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
tooltipText: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.sm,
|
||||
},
|
||||
}));
|
||||
@@ -0,0 +1,203 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { TailscaleStatus } from "@getpaseo/protocol/messages";
|
||||
import { resolveTailscaleControlState, type TailscaleControlStateInput } from "./tailscale-state";
|
||||
|
||||
const baseInput: TailscaleControlStateInput = {
|
||||
status: undefined,
|
||||
statusUpdatedAt: 0,
|
||||
statusError: false,
|
||||
changePending: false,
|
||||
changeError: false,
|
||||
refreshPending: false,
|
||||
refreshError: false,
|
||||
refreshSubmittedAt: 0,
|
||||
};
|
||||
|
||||
const unavailable: TailscaleStatus = { ip: null, address: null, state: "unavailable" };
|
||||
const waiting: TailscaleStatus = { ip: null, address: "100.101.102.103:6767", state: "waiting" };
|
||||
const off: TailscaleStatus = { ip: "100.101.102.103", address: null, state: "off" };
|
||||
const on: TailscaleStatus = { ip: "100.101.102.103", address: "100.101.102.103:6767", state: "on" };
|
||||
|
||||
describe("resolveTailscaleControlState", () => {
|
||||
it("reserves the switch space without Refresh during initial load", () => {
|
||||
expect(resolveTailscaleControlState(baseInput)).toEqual({
|
||||
value: null,
|
||||
showSwitch: true,
|
||||
switchDisabled: true,
|
||||
showRefresh: false,
|
||||
refreshing: false,
|
||||
refreshDisabled: false,
|
||||
showInstallLink: false,
|
||||
address: null,
|
||||
errorKey: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("shows Refresh, install link, and a disabled switch when Tailscale is unavailable", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: unavailable,
|
||||
statusUpdatedAt: 1000,
|
||||
}),
|
||||
).toEqual({
|
||||
value: false,
|
||||
showSwitch: true,
|
||||
switchDisabled: true,
|
||||
showRefresh: true,
|
||||
refreshing: false,
|
||||
refreshDisabled: false,
|
||||
showInstallLink: true,
|
||||
address: null,
|
||||
errorKey: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("shows Refresh alongside the enabled switch when Tailscale is waiting", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: waiting,
|
||||
statusUpdatedAt: 1000,
|
||||
}),
|
||||
).toEqual({
|
||||
value: true,
|
||||
showSwitch: true,
|
||||
switchDisabled: false,
|
||||
showRefresh: true,
|
||||
refreshing: false,
|
||||
refreshDisabled: false,
|
||||
showInstallLink: false,
|
||||
address: null,
|
||||
errorKey: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("hides Refresh once Tailscale becomes available or active", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: off,
|
||||
statusUpdatedAt: 2000,
|
||||
}),
|
||||
).toMatchObject({
|
||||
value: false,
|
||||
showSwitch: true,
|
||||
switchDisabled: false,
|
||||
showRefresh: false,
|
||||
showInstallLink: false,
|
||||
address: null,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: on,
|
||||
statusUpdatedAt: 3000,
|
||||
}),
|
||||
).toMatchObject({
|
||||
value: true,
|
||||
showSwitch: true,
|
||||
switchDisabled: false,
|
||||
showRefresh: false,
|
||||
showInstallLink: false,
|
||||
address: "100.101.102.103:6767",
|
||||
});
|
||||
});
|
||||
|
||||
it("shows Refresh without an empty switch spacer when initial status check fails, and keeps it visible while retrying", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
statusError: true,
|
||||
}),
|
||||
).toEqual({
|
||||
value: null,
|
||||
showSwitch: false,
|
||||
switchDisabled: true,
|
||||
showRefresh: true,
|
||||
refreshing: false,
|
||||
refreshDisabled: false,
|
||||
showInstallLink: false,
|
||||
address: null,
|
||||
errorKey: "devices.tailscale.statusError",
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
statusError: true,
|
||||
refreshPending: true,
|
||||
refreshSubmittedAt: 1500,
|
||||
}),
|
||||
).toEqual({
|
||||
value: null,
|
||||
showSwitch: false,
|
||||
switchDisabled: true,
|
||||
showRefresh: true,
|
||||
refreshing: true,
|
||||
refreshDisabled: true,
|
||||
showInstallLink: false,
|
||||
address: null,
|
||||
errorKey: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("surfaces a failed manual refresh even when a prior status is loaded, and clears it once a newer status arrives", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: unavailable,
|
||||
statusUpdatedAt: 1000,
|
||||
refreshError: true,
|
||||
refreshSubmittedAt: 2000,
|
||||
}),
|
||||
).toMatchObject({
|
||||
showRefresh: true,
|
||||
errorKey: "devices.tailscale.statusError",
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: unavailable,
|
||||
statusUpdatedAt: 3000,
|
||||
refreshError: true,
|
||||
refreshSubmittedAt: 2000,
|
||||
}),
|
||||
).toMatchObject({
|
||||
showRefresh: true,
|
||||
errorKey: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("prevents concurrent refresh and toggle actions", () => {
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: waiting,
|
||||
statusUpdatedAt: 1000,
|
||||
refreshPending: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
switchDisabled: true,
|
||||
refreshing: true,
|
||||
refreshDisabled: true,
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveTailscaleControlState({
|
||||
...baseInput,
|
||||
status: waiting,
|
||||
statusUpdatedAt: 1000,
|
||||
changePending: true,
|
||||
changePendingEnabled: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
value: false,
|
||||
switchDisabled: true,
|
||||
refreshing: false,
|
||||
refreshDisabled: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
import type { TailscaleStatus } from "@getpaseo/protocol/messages";
|
||||
|
||||
export type TailscaleErrorKey =
|
||||
| "devices.tailscale.turnOnError"
|
||||
| "devices.tailscale.turnOffError"
|
||||
| "devices.tailscale.statusError";
|
||||
|
||||
export interface TailscaleControlStateInput {
|
||||
status: TailscaleStatus | undefined;
|
||||
statusUpdatedAt: number;
|
||||
statusError: boolean;
|
||||
changePending: boolean;
|
||||
changePendingEnabled?: boolean;
|
||||
changeError: boolean;
|
||||
changeErrorEnabled?: boolean;
|
||||
refreshPending: boolean;
|
||||
refreshError: boolean;
|
||||
refreshSubmittedAt: number;
|
||||
}
|
||||
|
||||
export interface TailscaleControlState {
|
||||
value: boolean | null;
|
||||
showSwitch: boolean;
|
||||
switchDisabled: boolean;
|
||||
showRefresh: boolean;
|
||||
refreshing: boolean;
|
||||
refreshDisabled: boolean;
|
||||
showInstallLink: boolean;
|
||||
address: string | null;
|
||||
errorKey: TailscaleErrorKey | null;
|
||||
}
|
||||
|
||||
function resolveSwitchValue(input: TailscaleControlStateInput): boolean | null {
|
||||
if (input.changePending) return input.changePendingEnabled ?? null;
|
||||
if (!input.status) return null;
|
||||
return input.status.state === "on" || input.status.state === "waiting";
|
||||
}
|
||||
|
||||
function shouldShowRefresh(input: TailscaleControlStateInput): boolean {
|
||||
if (!input.status) {
|
||||
return input.statusError || input.refreshError || input.refreshPending;
|
||||
}
|
||||
return input.status.state === "unavailable" || input.status.state === "waiting";
|
||||
}
|
||||
|
||||
function resolveErrorKey(input: TailscaleControlStateInput): TailscaleErrorKey | null {
|
||||
if (input.changeError) {
|
||||
return input.changeErrorEnabled
|
||||
? "devices.tailscale.turnOnError"
|
||||
: "devices.tailscale.turnOffError";
|
||||
}
|
||||
if (input.refreshError && input.refreshSubmittedAt >= input.statusUpdatedAt) {
|
||||
return "devices.tailscale.statusError";
|
||||
}
|
||||
if (!input.refreshPending && input.statusError && !input.status) {
|
||||
return "devices.tailscale.statusError";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the Tailscale row's controls and error state from the host status query and the latest
|
||||
* toggle or manual refresh attempt.
|
||||
*/
|
||||
export function resolveTailscaleControlState(
|
||||
input: TailscaleControlStateInput,
|
||||
): TailscaleControlState {
|
||||
const { status } = input;
|
||||
const value = resolveSwitchValue(input);
|
||||
const busy = input.changePending || input.refreshPending;
|
||||
const showRefresh = shouldShowRefresh(input);
|
||||
const showSwitch = Boolean(status) || !showRefresh;
|
||||
const switchDisabled =
|
||||
!status || status.state === "unavailable" || Boolean(status.lockedBy) || busy;
|
||||
|
||||
return {
|
||||
value,
|
||||
showSwitch,
|
||||
switchDisabled,
|
||||
showRefresh,
|
||||
refreshing: input.refreshPending,
|
||||
refreshDisabled: busy,
|
||||
showInstallLink: status?.state === "unavailable",
|
||||
address: status?.state === "on" && value ? status.address : null,
|
||||
errorKey: resolveErrorKey(input),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { SettingsCard, SettingsDetailRow, SettingsSection } from "@/components/settings";
|
||||
import { PairDeviceModal } from "./pair-device-modal";
|
||||
import { CONNECTIVITY_DOCS_URL } from "./pair-device-section";
|
||||
import { TailscaleRow } from "./tailscale-row";
|
||||
|
||||
/**
|
||||
* The ways another device can connect to a host: Relay, which pairs through a QR code in a sheet,
|
||||
* and Tailscale, a switch and an address. Settings and the setup's phone step show this same block.
|
||||
*/
|
||||
export function WaysToConnect({ serverId }: { serverId: string }) {
|
||||
const { t } = useTranslation();
|
||||
const [pairing, setPairing] = useState(false);
|
||||
const openPairing = useCallback(() => setPairing(true), []);
|
||||
const closePairing = useCallback(() => setPairing(false), []);
|
||||
const docsLink = useMemo(
|
||||
() => ({
|
||||
href: CONNECTIVITY_DOCS_URL,
|
||||
label: t("devices.docs"),
|
||||
accessibilityLabel: t("devices.docsAccessibility"),
|
||||
}),
|
||||
[t],
|
||||
);
|
||||
|
||||
return (
|
||||
<SettingsSection title={t("devices.waysToConnect")} link={docsLink}>
|
||||
<SettingsCard>
|
||||
<SettingsDetailRow
|
||||
label={t("devices.relay.title")}
|
||||
hint={t("devices.relay.hint")}
|
||||
onPress={openPairing}
|
||||
testID="devices-relay"
|
||||
/>
|
||||
<TailscaleRow serverId={serverId} />
|
||||
</SettingsCard>
|
||||
<PairDeviceModal
|
||||
serverId={serverId}
|
||||
visible={pairing}
|
||||
onClose={closePairing}
|
||||
testID="devices-relay-pairing"
|
||||
/>
|
||||
</SettingsSection>
|
||||
);
|
||||
}
|
||||
@@ -681,4 +681,56 @@ describe("deriveAgentScreenViewState", () => {
|
||||
expect(sync.ui).toBe("status");
|
||||
expect(result.memory.hadInitialSyncFailure).toBe(false);
|
||||
});
|
||||
|
||||
it("stays ready without reverting to boot when an archived agent unarchives", () => {
|
||||
const archivedAgent = {
|
||||
...createAgent("agent-1"),
|
||||
archivedAt: new Date("2026-02-19T00:01:00.000Z"),
|
||||
};
|
||||
const archivedResult = deriveAgentScreenViewState({
|
||||
input: {
|
||||
...createBaseInput(),
|
||||
agent: archivedAgent,
|
||||
isArchived: true,
|
||||
hasHydratedHistoryBefore: false,
|
||||
needsAuthoritativeSync: true,
|
||||
isHistorySyncing: true,
|
||||
visibilityCatchUpStatus: "pending",
|
||||
},
|
||||
memory: createBaseMemory(),
|
||||
});
|
||||
expectReadyState(archivedResult.state);
|
||||
expect(archivedResult.memory.hasRenderedReady).toBe(true);
|
||||
|
||||
const unarchivedAgent = {
|
||||
...createAgent("agent-1"),
|
||||
archivedAt: null,
|
||||
};
|
||||
const unarchivedInput = {
|
||||
...createBaseInput(),
|
||||
agent: unarchivedAgent,
|
||||
isArchived: false,
|
||||
hasHydratedHistoryBefore: false,
|
||||
needsAuthoritativeSync: true,
|
||||
isHistorySyncing: true,
|
||||
visibilityCatchUpStatus: "pending" as const,
|
||||
};
|
||||
|
||||
// Without prior ready render, the same unarchived input stays in boot.
|
||||
const freshBoot = deriveAgentScreenViewState({
|
||||
input: unarchivedInput,
|
||||
memory: createBaseMemory(),
|
||||
});
|
||||
expect(freshBoot.state.tag).toBe("boot");
|
||||
|
||||
// Because this screen already rendered ready while archived, unarchiving stays ready.
|
||||
const unarchivedResult = deriveAgentScreenViewState({
|
||||
input: unarchivedInput,
|
||||
memory: archivedResult.memory,
|
||||
});
|
||||
const ready = expectReadyState(unarchivedResult.state);
|
||||
expect(ready.agent.id).toBe("agent-1");
|
||||
expect(ready.source).toBe("authoritative");
|
||||
expect(ready.sync).toEqual({ status: "catching_up", ui: "overlay" });
|
||||
});
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user