mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-21 08:42:39 +00:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f9982b488 | ||
|
|
b63a325be3 | ||
|
|
6ec6633425 | ||
|
|
b26b9234c0 | ||
|
|
aec01ea605 | ||
|
|
a1da1b8f23 | ||
|
|
73390346ca | ||
|
|
718ed932b7 | ||
|
|
0009a7e717 | ||
|
|
29db2b7980 | ||
|
|
8c096b5e33 | ||
|
|
d0bc188a5b | ||
|
|
06fe97c901 | ||
|
|
f943e790b6 | ||
|
|
23d7a089e2 | ||
|
|
99fc204c55 | ||
|
|
33eb36c021 | ||
|
|
0fc6bf0c94 | ||
|
|
2d55870490 |
@@ -93,6 +93,3 @@ app.json
|
||||
|
||||
# Heap snapshots dumped by --heapsnapshot-near-heap-limit; keep them for debugging.
|
||||
*.heapsnapshot
|
||||
|
||||
# Project-local Serena configuration and memories.
|
||||
.serena/
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## 0.11.4 - 2026-10-15
|
||||
|
||||
[Hoplite](https://hoplite.sh) joins Paseo as our first sponsor through the company sponsorship program. Hoplite builds cloud coding agents that turn tasks from GitHub, Linear, Slack and more into pull requests. Thank you to the Hoplite team for supporting Paseo.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Hoplite showing an error in Settings → Providers instead of discovering models in workspaces linked to a Hoplite project
|
||||
|
||||
## 0.11.3 - 2026-10-15
|
||||
|
||||
### Added
|
||||
|
||||
- Added Hoplite as an opt-in provider in the ACP provider catalog ([#6953](https://github.com/getpaseo/paseo/pull/6953) by [@odinglyn0](https://github.com/odinglyn0))
|
||||
- Added search to the Add provider catalog ([#6953](https://github.com/getpaseo/paseo/pull/6953), [#7030](https://github.com/getpaseo/paseo/pull/7030))
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed Add provider failures to show as a toast ([#7030](https://github.com/getpaseo/paseo/pull/7030))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Remove being offered for plugin providers such as Antigravity and Muse Code ([#6568](https://github.com/getpaseo/paseo/pull/6568) by [@Ctrl-Creeper](https://github.com/Ctrl-Creeper))
|
||||
|
||||
## 0.11.2 - 2026-10-09
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
<img src="https://paseo.sh/mobile-mockup.png" alt="Paseo mobile app" width="100%">
|
||||
</p>
|
||||
|
||||
Paseo is a desktop, mobile, web, and CLI app for coding agents. Open the desktop app and work: agents, editor, terminals, diffs, pull requests, and a browser in one window. Run many agents at once, each in its own worktree, on one machine or several. The mobile app is the full app, native on iOS and Android.
|
||||
Paseo is an open source agentic development environment for desktop, mobile, web, and CLI. Open the desktop app and work: agents, editor, terminals, diffs, pull requests, and a browser in one window. Run many agents at once, each in its own worktree, on one machine or several. The mobile app is the full app, native on iOS and Android.
|
||||
|
||||
- **Parallel agents:** Run many agents at once, each in its own worktree.
|
||||
- **Built-in orchestration:** Agents in Paseo can create worktrees, launch other agents, and talk to them, across providers.
|
||||
- **Full IDE:** Edit files, review diffs, open pull requests, and run terminals, in split panes you arrange how you want.
|
||||
- **Complete development workflow:** Edit files, review diffs, open pull requests, and run terminals, in split panes you arrange how you want.
|
||||
- **Self-hosted:** Agents run on your machine with your full dev environment. Use your tools, your configs, and your skills.
|
||||
- **Multi-provider:** Claude Code, Codex, Copilot, OpenCode, Pi, Antigravity, and Muse Code through the same interface. Pick the right model for each job.
|
||||
- **Voice control:** Dictate tasks or talk through problems in voice mode. Hands-free when you need it.
|
||||
|
||||
+28
-2
@@ -69,11 +69,11 @@ the marker. Closing a tab sets that client's label to `false`. Any `true` client
|
||||
open. Detach clears the parent and every open-tab label. The surviving child therefore becomes a
|
||||
normal root agent immediately, and closing its still-open tab archives it.
|
||||
|
||||
Runtime ownership is resolved from explicit workspace ID and caller context, never from `cwd`. Workspace creation is a separate operation with `local | worktree` isolation; agent creation only selects an existing workspace.
|
||||
Runtime ownership is resolved from explicit workspace ID and caller context, never from `cwd`. Workspace creation is a separate operation with `local | worktree` isolation; agent creation reuses that workspace unless a new workspace is explicitly requested.
|
||||
|
||||
Users can also detach an existing subagent from the subagents track. Detach is deliberately a manual lifecycle gesture, not an agent-facing MCP tool. It removes the parent and open-tab lifecycle labels: it does not stop, archive, move, or restart the agent. The agent keeps its current `cwd` and `workspaceId`, leaves the former parent's track, and behaves like a root agent for tab close, workspace activity, and future parent archive.
|
||||
|
||||
`notifyOnFinish` defaults to `true` for agent-scoped creation and background prompt follow-ups because most delegated work needs to report back to the creating agent. Set it to `false` only for truly fire-and-forget agents or prompts.
|
||||
`notifyOnFinish` defaults to `true` for agent-scoped creation and prompt follow-ups because most delegated work needs to report back to the creating agent. Set it to `false` only for truly fire-and-forget agents or prompts.
|
||||
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.
|
||||
@@ -84,6 +84,32 @@ Some providers can create their own child sessions inside one provider runtime.
|
||||
|
||||
The provider still owns the underlying runtime. Paseo keeps an agent record so the child can be opened, tracked, archived, and cascaded with the parent, but prompts and history hydration route through the provider adapter for that native child handle.
|
||||
|
||||
## Background workspaces
|
||||
|
||||
`workspace.background` controls discovery only. Background workspaces contain ordinary durable
|
||||
agents and terminals: provider history, plugin hooks, parentage, archive, and restart recovery
|
||||
keep their normal behavior. Visibility is creation-only; selecting an existing workspace cannot
|
||||
change it. New workspaces default to false, inherit the caller workspace's value when an agent
|
||||
creates one without an override, and accept explicit true or false.
|
||||
|
||||
The daemon derives agent discovery from workspace ownership. Default workspace and agent lists,
|
||||
including History requests, exclude background work; `filter.includeBackground` includes it.
|
||||
Exact-ID operations bypass discovery filtering. The app replicates both kinds and filters only
|
||||
its sidebar with **Show background**, so direct navigation and restored tabs remain available.
|
||||
|
||||
Sequenced directories keep complete canonical collections. A filtered read must never replace
|
||||
those collections with its subset. Inclusive and default observations have distinct cursor
|
||||
scopes, so changing scope requires a fresh snapshot rather than reusing an incomplete cache.
|
||||
Clients gate creation and inclusive discovery on `features.backgroundWorkspaces`.
|
||||
|
||||
### Private daemon helpers
|
||||
|
||||
Branch-name and commit-message generators still use private disposable internal runtimes.
|
||||
`AgentManager` does not persist them or their provider sessions, excludes them from public
|
||||
discovery and plugin hooks, and drops their timelines on archive. An archived helper retains
|
||||
its exact-ID result briefly to cover completion before a waiter attaches. This internal
|
||||
lifecycle is separate from public workspace visibility and is not a public creation option.
|
||||
|
||||
## Archive
|
||||
|
||||
Archive is a **soft delete**: the agent record stays on disk with `archivedAt` set, the runtime is closed, and the agent disappears from active lists. Archive is **global** — it lives on the server and propagates to every connected client.
|
||||
|
||||
@@ -345,6 +345,10 @@ join active work or reuse committed stages. A persisted resource alone cannot pr
|
||||
that a provider accepted its initial prompt. Interrupted side effects with no conclusive
|
||||
receipt return an unknown outcome instead of being repeated.
|
||||
|
||||
Agent registration commits creation. Rejecting the first prompt is a turn error on that
|
||||
agent; reporting creation failure leaves an orphaned agent and invites another Create.
|
||||
Receipt replay must not resend the prompt.
|
||||
|
||||
`packages/client/src/creation/` owns capability selection and legacy orchestration.
|
||||
Callers always pass the initial prompt to agent creation. On an older host, the client
|
||||
adapts keyed creation to the legacy create/send sequence; it cannot continue that
|
||||
|
||||
@@ -484,7 +484,7 @@ The [Agent Client Protocol (ACP)](https://agentclientprotocol.com) is an open st
|
||||
|
||||
ACP agents communicate over JSON-RPC 2.0 on stdio. Paseo spawns the agent process and talks to it through stdin/stdout.
|
||||
|
||||
Paseo also ships an in-app ACP provider catalog for common agents, including CodeWhale, Cursor, DeepAgents, DimCode, Gemini CLI, Hermes, Qwen Code, and Kimi Code. Most catalog entries create the same `extends: "acp"` provider config shown below. Hoplite activates its [bundled provider](plugins.md#built-in-plugins) instead.
|
||||
Paseo also ships an in-app ACP provider catalog for common agents, including CodeWhale, Cursor, DeepAgents, DimCode, Gemini CLI, Hermes, Qwen Code, and Kimi Code. Catalog entries create the same `extends: "acp"` provider config shown below.
|
||||
|
||||
### Adding a generic ACP provider
|
||||
|
||||
|
||||
@@ -107,12 +107,6 @@ absent from the installed plugin list and source configuration; their client bun
|
||||
appear in the plugin catalog. Editing one in development requires a daemon restart.
|
||||
Directory, Git, and npm installs cannot use a built-in ID.
|
||||
|
||||
A provider registration with `requiresConfiguration: true` participates only while its ID exists
|
||||
under `agents.providers`. Hoplite uses this for catalog opt-in. Add writes `{ "enabled": true }`
|
||||
without `extends`, so it selects the bundled adapter. Remove deletes the config entry; setting
|
||||
`enabled: false` keeps the entry. The bundled JavaScript still loads at startup, but an absent
|
||||
provider does not enter executable resolution or catalog discovery.
|
||||
|
||||
Provider plugins use separate installation and provider IDs. `muse-provider` registers the
|
||||
selectable `muse` provider (Muse Code) and a usage source. Its `status({ launch })` reports
|
||||
availability and a diagnostic after the daemon resolves the executable. Configure command,
|
||||
|
||||
@@ -61,6 +61,8 @@ Core direct providers: `claude` (in `providers/claude/agent.ts`), `codex` (`code
|
||||
|
||||
Claude first-party model metadata lives in `packages/server/src/server/agent/providers/claude/model-manifest.ts`. When adding or updating a Claude model, update that manifest only; the model picker thinking options and Claude-specific feature gates are derived from the manifest. Do not add model-specific Claude capability lists in feature code.
|
||||
|
||||
Keep the curated Claude catalog: `supportedModels()` has historically omitted older versions and carries less metadata. Discovery is only an opt-in visibility gate, not a replacement catalog or an entitlement guarantee. Claude Code v2.1.197 added `resolvedModel` to disambiguate alias rows; a bare family alias does not establish access to a particular version. Explicit user-configured models must remain selectable when discovery fails or omits them.
|
||||
|
||||
Paseo tools are not implemented as MCP tools internally. They live in a shared tool catalog under `packages/server/src/server/agent/tools/`; MCP is only the fallback adapter. The daemon resolves `agents.providers.<provider>.paseoTools` by the exact provider ID. The catalog policy belongs to the caller: it filters the tools exposed to the current agent. When that agent calls `create_agent`, the child receives the policy for the child provider ID; the caller's policy is not inherited.
|
||||
|
||||
A provider that can register runtime tools directly should set `supportsNativePaseoTools: true` and consume the already-filtered `launchContext.paseoTools` in `createSession`/`resumeSession`. When native tools are present, `AgentManager` strips the internal Paseo MCP server from the provider launch config so the provider does not receive the same tools twice. Providers that only know MCP should keep `supportsMcpServers: true` and let the daemon inject `/mcp/agents`; the MCP server builds the same policy-filtered catalog for that caller. Filtering is enforced at catalog registration in both paths. Browser tools remain subject to the daemon browser-tools setting and browser-host availability.
|
||||
|
||||
+19
-5
@@ -223,7 +223,7 @@ submission. Overlapping sends settle independently rather than collapsing to one
|
||||
message.
|
||||
|
||||
Daemons advertising `server_info.features.canonicalSubmittedPrompts` guarantee that every accepted
|
||||
prompt carrying a client message id is recorded and streamed as a canonical `user_message` with that
|
||||
human prompt carrying a client message id is recorded and streamed as a canonical `user_message` with that
|
||||
same id. This includes daemon-handled commands that do not allocate a foreground turn; their submitted
|
||||
row is recorded before handler output. The app tracks submission transactions only for hosts with this
|
||||
capability. Older hosts keep the shipped untracked optimistic-row behavior and roll that row back on RPC
|
||||
@@ -238,11 +238,25 @@ foreground control ownership remains a separate daemon concern. Cancellation req
|
||||
with that record rather than in a React component, so an old request cannot clear a newer one. Submissions
|
||||
remain a separate pre-turn registry and retire on canonical acknowledgement.
|
||||
|
||||
Canonical turns and visible responses are different boundaries. System-injected prompts are absent from
|
||||
the Paseo timeline, so one visible response can span several canonical turns without a user message
|
||||
between them. Layout and copy group that response together; lifecycle, timing, tool sequences, and exact
|
||||
Canonical turns and visible responses are different boundaries. Agent-originated prompts and lifecycle
|
||||
notifications project into tool rows, so they do not create a human-message boundary. Legacy system
|
||||
prompts, including schedule injections, remain hidden. One visible response can span several canonical
|
||||
turns; layout and copy group that response together while lifecycle, timing, tool sequences, and exact
|
||||
fork positions retain the canonical `turnId` boundaries.
|
||||
|
||||
Agent-message XML belongs to the daemon's `agent/agent-messages` boundary. Prompt delivery encodes
|
||||
provenance; acceptance, provider echoes, import, and replay share its projection. The delivery ID is
|
||||
also the projected call ID, so a provider echo cannot create a second row. Sender IDs are opaque and
|
||||
do not imply local ownership or authorization. Capture the sender title at delivery: archived or
|
||||
removed senders must remain understandable without a live directory lookup.
|
||||
|
||||
The optional `agentMessage` payload carries event, sender, and delivered text. Shared client
|
||||
presentation (`protocol/agent-message-display`) owns its heading and expanded details. The daemon
|
||||
must not construct UI labels or prepend sender labels to the semantic message body. The existing
|
||||
`tool_call` / `plain_text` envelope is a compatibility adapter: older clients still parse the row and
|
||||
expand its body. New clients use the typed payload, never infer the event from a tool name or parse
|
||||
XML. Stream reduction and disk-cache serialization preserve the payload without rendering it.
|
||||
|
||||
The compatibility boundary for older daemons is snapshot normalization: running/idle status becomes an
|
||||
anonymous active turn or idle state once, and downstream code consumes the same activity shape. The app
|
||||
does not combine anonymous lifecycle events, timestamps, timeline rows, and resume coverage to infer a
|
||||
@@ -250,7 +264,7 @@ second running state. Disconnect preserves the last replicated turn until cache
|
||||
advances it; replica removal remains the destructive close boundary. Elapsed time comes only from turn
|
||||
liveness, never from submission records or whichever timeline rows happen to be mounted.
|
||||
|
||||
The daemon records one canonical submitted user row at acceptance. Its wire `messageId` is the
|
||||
For human prompts, the daemon records one canonical submitted user row at acceptance. Its wire `messageId` is the
|
||||
submission's `clientMessageId`, so the row is born with its final identity and remains immutable on
|
||||
the wire. A correlated provider echo records the provider's native identity internally without
|
||||
dispatching another timeline event. Rewind resolves the wire identity to that provider identity at
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
Added
|
||||
- Added Hoplite as an opt-in provider in the ACP provider catalog
|
||||
- Added search to the Add provider catalog
|
||||
|
||||
Changed
|
||||
- Changed Add provider failures to show as a toast
|
||||
|
||||
Fixed
|
||||
- Fixed Remove being offered for plugin providers such as Antigravity and Muse Code
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,11 +0,0 @@
|
||||
Added
|
||||
- Added Hoplite as an opt-in provider in the ACP provider catalog
|
||||
- Added search to the Add provider catalog
|
||||
|
||||
Changed
|
||||
- Changed Add provider failures to show as a toast
|
||||
|
||||
Fixed
|
||||
- Fixed Remove being offered for plugin providers such as Antigravity and Muse Code
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,11 +0,0 @@
|
||||
Added
|
||||
- Added Hoplite as an opt-in provider in the ACP provider catalog
|
||||
- Added search to the Add provider catalog
|
||||
|
||||
Changed
|
||||
- Changed Add provider failures to show as a toast
|
||||
|
||||
Fixed
|
||||
- Fixed Remove being offered for plugin providers such as Antigravity and Muse Code
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,11 +0,0 @@
|
||||
Added
|
||||
- Added Hoplite as an opt-in provider in the ACP provider catalog
|
||||
- Added search to the Add provider catalog
|
||||
|
||||
Changed
|
||||
- Changed Add provider failures to show as a toast
|
||||
|
||||
Fixed
|
||||
- Fixed Remove being offered for plugin providers such as Antigravity and Muse Code
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,6 +0,0 @@
|
||||
Hoplite joins Paseo as our first sponsor through the company sponsorship program. Hoplite builds cloud coding agents that turn tasks from GitHub, Linear, Slack and more into pull requests. Thank you to the Hoplite team for supporting Paseo.
|
||||
|
||||
Fixed
|
||||
- Fixed Hoplite showing an error in Settings → Providers instead of discovering models in workspaces linked to a Hoplite project
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,6 +0,0 @@
|
||||
Hoplite joins Paseo as our first sponsor through the company sponsorship program. Hoplite builds cloud coding agents that turn tasks from GitHub, Linear, Slack and more into pull requests. Thank you to the Hoplite team for supporting Paseo.
|
||||
|
||||
Fixed
|
||||
- Fixed Hoplite showing an error in Settings → Providers instead of discovering models in workspaces linked to a Hoplite project
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,6 +0,0 @@
|
||||
Hoplite joins Paseo as our first sponsor through the company sponsorship program. Hoplite builds cloud coding agents that turn tasks from GitHub, Linear, Slack and more into pull requests. Thank you to the Hoplite team for supporting Paseo.
|
||||
|
||||
Fixed
|
||||
- Fixed Hoplite showing an error in Settings → Providers instead of discovering models in workspaces linked to a Hoplite project
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
@@ -1,6 +0,0 @@
|
||||
Hoplite joins Paseo as our first sponsor through the company sponsorship program. Hoplite builds cloud coding agents that turn tasks from GitHub, Linear, Slack and more into pull requests. Thank you to the Hoplite team for supporting Paseo.
|
||||
|
||||
Fixed
|
||||
- Fixed Hoplite showing an error in Settings → Providers instead of discovering models in workspaces linked to a Hoplite project
|
||||
|
||||
Full notes: https://paseo.sh/changelog
|
||||
+1
-1
@@ -1 +1 @@
|
||||
sha256-AKY6OMZgHeyn/To/2zsmtfb5C4fKniUp8gvpEYaR7/o=
|
||||
sha256-CK96G7MWsmd/VDvkuaFJ23U04EGNmeiXdTYbmR8RDDQ=
|
||||
|
||||
Generated
+28
-28
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "paseo",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
@@ -36413,7 +36413,7 @@
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
"@codemirror/language": "6.12.4",
|
||||
@@ -37496,12 +37496,12 @@
|
||||
},
|
||||
"packages/cli": {
|
||||
"name": "@getpaseo/cli",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.0.0",
|
||||
"@getpaseo/client": "0.11.4",
|
||||
"@getpaseo/protocol": "0.11.4",
|
||||
"@getpaseo/server": "0.11.4",
|
||||
"@getpaseo/client": "0.11.2",
|
||||
"@getpaseo/protocol": "0.11.2",
|
||||
"@getpaseo/server": "0.11.2",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^12.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -37748,10 +37748,10 @@
|
||||
},
|
||||
"packages/client": {
|
||||
"name": "@getpaseo/client",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@getpaseo/protocol": "0.11.4",
|
||||
"@getpaseo/relay": "0.11.4",
|
||||
"@getpaseo/protocol": "0.11.2",
|
||||
"@getpaseo/relay": "0.11.2",
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -37762,7 +37762,7 @@
|
||||
},
|
||||
"packages/desktop": {
|
||||
"name": "@getpaseo/desktop",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@getpaseo/cli": "*",
|
||||
@@ -38006,7 +38006,7 @@
|
||||
},
|
||||
"packages/expo-two-way-audio": {
|
||||
"name": "@getpaseo/expo-two-way-audio",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
@@ -38902,7 +38902,7 @@
|
||||
},
|
||||
"packages/highlight": {
|
||||
"name": "@getpaseo/highlight",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.12.4",
|
||||
"@codemirror/legacy-modes": "^6.5.3",
|
||||
@@ -38931,14 +38931,14 @@
|
||||
},
|
||||
"packages/plugin": {
|
||||
"name": "@getpaseo/plugin",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^1.4.0",
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@getpaseo/client": "0.11.4",
|
||||
"@getpaseo/protocol": "0.11.4",
|
||||
"@getpaseo/client": "0.11.2",
|
||||
"@getpaseo/protocol": "0.11.2",
|
||||
"@types/node": "^20.9.0",
|
||||
"@types/react": "~19.2.0",
|
||||
"react": "19.1.0",
|
||||
@@ -38948,8 +38948,8 @@
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@getpaseo/client": "0.11.4",
|
||||
"@getpaseo/protocol": "0.11.4",
|
||||
"@getpaseo/client": "0.11.2",
|
||||
"@getpaseo/protocol": "0.11.2",
|
||||
"react": "~19.1.0",
|
||||
"react-native": ">=0.81.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -38971,7 +38971,7 @@
|
||||
},
|
||||
"packages/protocol": {
|
||||
"name": "@getpaseo/protocol",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"semver": "^7.8.5",
|
||||
"zod": "^4.4.3"
|
||||
@@ -38998,7 +38998,7 @@
|
||||
},
|
||||
"packages/relay": {
|
||||
"name": "@getpaseo/relay",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.5.1",
|
||||
"tweetnacl": "^1.0.3",
|
||||
@@ -39216,16 +39216,16 @@
|
||||
},
|
||||
"packages/server": {
|
||||
"name": "@getpaseo/server",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "^0.17.1",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.246",
|
||||
"@anthropic-ai/sdk": "^0.104.2",
|
||||
"@getpaseo/client": "0.11.4",
|
||||
"@getpaseo/highlight": "0.11.4",
|
||||
"@getpaseo/plugin": "0.11.4",
|
||||
"@getpaseo/protocol": "0.11.4",
|
||||
"@getpaseo/relay": "0.11.4",
|
||||
"@getpaseo/client": "0.11.2",
|
||||
"@getpaseo/highlight": "0.11.2",
|
||||
"@getpaseo/plugin": "0.11.2",
|
||||
"@getpaseo/protocol": "0.11.2",
|
||||
"@getpaseo/relay": "0.11.2",
|
||||
"@isaacs/ttlcache": "^2.1.4",
|
||||
"@modelcontextprotocol/sdk": "1.29.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
@@ -40146,7 +40146,7 @@
|
||||
},
|
||||
"packages/website": {
|
||||
"name": "@getpaseo/website",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.29.1",
|
||||
"@cloudflare/workers-types": "^4.20260317.1",
|
||||
@@ -41754,7 +41754,7 @@
|
||||
},
|
||||
"plugins": {
|
||||
"name": "@getpaseo/builtin-plugins",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"dependencies": {
|
||||
"@getpaseo/plugin": "*",
|
||||
"zod": "^4.4.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paseo",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"private": true,
|
||||
"description": "Paseo: voice-controlled development environment for local AI coding agents",
|
||||
"keywords": [
|
||||
|
||||
@@ -2,6 +2,7 @@ const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const pkg = require("./package.json");
|
||||
const withAndroidAsyncStorageSize = require("./plugins/with-android-async-storage-size");
|
||||
const withAndroidOptionalCamera = require("./plugins/with-android-optional-camera");
|
||||
const withAndroidProfileable = require("./plugins/with-android-profileable");
|
||||
const withFdroidAutolinking = require("./plugins/with-fdroid-autolinking");
|
||||
const withPasteInput = require("./plugins/with-paste-input");
|
||||
@@ -145,6 +146,7 @@ export default {
|
||||
withAndroidScroll,
|
||||
[withAndroidAsyncStorageSize, 64],
|
||||
...buildProfile.cameraPlugins,
|
||||
withAndroidOptionalCamera,
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createRequire } from "node:module";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
// Load the copies the Expo CLI uses for prebuild, not older hoisted ones.
|
||||
const requireFromExpo = createRequire(require.resolve("expo/package.json"));
|
||||
const requireFromExpoCli = createRequire(requireFromExpo.resolve("@expo/cli/package.json"));
|
||||
const { getPrebuildConfigAsync } = requireFromExpoCli("@expo/prebuild-config");
|
||||
const { compileModsAsync } = requireFromExpoCli(
|
||||
"@expo/config-plugins/build/plugins/mod-compiler.js",
|
||||
);
|
||||
|
||||
interface ManifestEntry {
|
||||
$: Record<string, string>;
|
||||
}
|
||||
|
||||
const originalFdroidFlag = process.env.PASEO_FDROID_BUILD;
|
||||
|
||||
async function resolveAndroidManifest() {
|
||||
const { exp } = await getPrebuildConfigAsync(__dirname, { platforms: ["android"] });
|
||||
await compileModsAsync(exp, {
|
||||
projectRoot: __dirname,
|
||||
introspect: true,
|
||||
platforms: ["android"],
|
||||
assertMissingModProviders: false,
|
||||
});
|
||||
return exp._internal.modResults.android.manifest.manifest;
|
||||
}
|
||||
|
||||
describe("Android app config", () => {
|
||||
afterEach(() => {
|
||||
if (originalFdroidFlag === undefined) {
|
||||
delete process.env.PASEO_FDROID_BUILD;
|
||||
} else {
|
||||
process.env.PASEO_FDROID_BUILD = originalFdroidFlag;
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Google Play", "0"],
|
||||
["F-Droid", "1"],
|
||||
])(
|
||||
"%s build installs on devices without a camera",
|
||||
async (_build, fdroidFlag) => {
|
||||
process.env.PASEO_FDROID_BUILD = fdroidFlag;
|
||||
const manifest = await resolveAndroidManifest();
|
||||
const permissions = (manifest["uses-permission"] ?? []).map(
|
||||
(entry: ManifestEntry) => entry.$["android:name"],
|
||||
);
|
||||
const features = (manifest["uses-feature"] ?? []).map((entry: ManifestEntry) => entry.$);
|
||||
|
||||
expect(permissions).toContain("android.permission.CAMERA");
|
||||
expect(features).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ "android:name": "android.hardware.camera", "android:required": "false" },
|
||||
{ "android:name": "android.hardware.camera.autofocus", "android:required": "false" },
|
||||
]),
|
||||
);
|
||||
},
|
||||
30_000,
|
||||
);
|
||||
});
|
||||
@@ -1,24 +1,13 @@
|
||||
import {
|
||||
closeModelPicker,
|
||||
openModelPicker,
|
||||
seedAgentProfiles,
|
||||
} from "../support/helpers/agent-profiles";
|
||||
import { expectComposerVisible } from "../support/helpers/composer";
|
||||
import { clickNewChat, gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { test } from "../support/fixtures";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import { connectDaemonClient } from "../support/helpers/daemon-client-loader";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import {
|
||||
expectProviderInstalledInSettings,
|
||||
findAcpCatalogProvider,
|
||||
installAcpCatalogProvider,
|
||||
openAddProviderArea,
|
||||
openSettingsHost,
|
||||
openSettingsHostSection,
|
||||
seedSavedSettingsHosts,
|
||||
} from "../support/helpers/settings";
|
||||
|
||||
const ACP_PROVIDER = {
|
||||
@@ -27,13 +16,8 @@ const ACP_PROVIDER = {
|
||||
};
|
||||
|
||||
interface ProviderCatalogDaemonClient {
|
||||
getLastServerInfoMessage(): {
|
||||
features?: { hopliteProvider?: boolean; plugins?: boolean };
|
||||
} | null;
|
||||
connect(): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
getDaemonConfig(): Promise<{ config: { providers?: Record<string, unknown> } }>;
|
||||
getProvidersSnapshot(): Promise<{ entries: Array<{ provider: string }> }>;
|
||||
patchDaemonConfig(config: { removeProviders?: string[] }): Promise<unknown>;
|
||||
}
|
||||
|
||||
@@ -57,124 +41,3 @@ test.describe("ACP provider catalog", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
for (const theme of ["light", "dark"] as const) {
|
||||
test(`adds Hoplite from the catalog in ${theme} theme`, async ({ page }, testInfo) => {
|
||||
const client = await connectDaemonClient<ProviderCatalogDaemonClient>({
|
||||
clientIdPrefix: "hoplite-catalog-e2e",
|
||||
});
|
||||
try {
|
||||
expect(client.getLastServerInfoMessage()?.features?.hopliteProvider).toBe(true);
|
||||
await client.patchDaemonConfig({ removeProviders: ["hoplite"] });
|
||||
expect(
|
||||
(await client.getProvidersSnapshot()).entries.some((entry) => entry.provider === "hoplite"),
|
||||
).toBe(false);
|
||||
await page.addInitScript((value) => {
|
||||
localStorage.setItem("@paseo:app-settings", JSON.stringify({ theme: value }));
|
||||
}, theme);
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, getServerId());
|
||||
await openSettingsHostSection(page, getServerId(), "providers");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Hoplite provider details", exact: true }),
|
||||
).toHaveCount(0);
|
||||
await openAddProviderArea(page);
|
||||
await findAcpCatalogProvider(page, "Hoplite");
|
||||
await page.screenshot({ path: testInfo.outputPath(`hoplite-catalog-${theme}.png`) });
|
||||
await installAcpCatalogProvider(page, "Hoplite");
|
||||
await expectProviderInstalledInSettings(page, "Hoplite");
|
||||
await page.screenshot({ path: testInfo.outputPath(`hoplite-installed-${theme}.png`) });
|
||||
expect((await client.getDaemonConfig()).config.providers?.hoplite).toEqual({ enabled: true });
|
||||
await writeFile(
|
||||
testInfo.outputPath(`hoplite-added-${theme}.json`),
|
||||
JSON.stringify(await client.getProvidersSnapshot(), null, 2),
|
||||
);
|
||||
await removeHoplite(page);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Hoplite provider details", exact: true }),
|
||||
).toHaveCount(0);
|
||||
expect((await client.getDaemonConfig()).config.providers?.hoplite).toBeUndefined();
|
||||
expect(
|
||||
(await client.getProvidersSnapshot()).entries.some((entry) => entry.provider === "hoplite"),
|
||||
).toBe(false);
|
||||
await writeFile(
|
||||
testInfo.outputPath(`hoplite-removed-${theme}.json`),
|
||||
JSON.stringify(await client.getProvidersSnapshot(), null, 2),
|
||||
);
|
||||
await openAddProviderArea(page);
|
||||
await findAcpCatalogProvider(page, "Hoplite");
|
||||
await page.screenshot({ path: testInfo.outputPath(`hoplite-removed-${theme}.png`) });
|
||||
await installAcpCatalogProvider(page, "Hoplite");
|
||||
await expectProviderInstalledInSettings(page, "Hoplite");
|
||||
} finally {
|
||||
await client.patchDaemonConfig({ removeProviders: ["hoplite"] }).catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function removeHoplite(page: import("@playwright/test").Page): Promise<void> {
|
||||
await page.getByTestId("provider-actions-hoplite").click();
|
||||
page.once("dialog", (dialog) => {
|
||||
void dialog.accept();
|
||||
});
|
||||
await page.getByTestId("provider-remove-hoplite").click();
|
||||
}
|
||||
|
||||
test("unsupported host asks for an update without writing Hoplite config", async ({
|
||||
page,
|
||||
outdatedDaemon,
|
||||
}, testInfo) => {
|
||||
const client = await connectDaemonClient<ProviderCatalogDaemonClient>({
|
||||
clientIdPrefix: "hoplite-unsupported",
|
||||
port: Number(new URL(`http://${outdatedDaemon.endpoint}`).port),
|
||||
});
|
||||
try {
|
||||
expect(client.getLastServerInfoMessage()?.features?.plugins).toBe(true);
|
||||
expect(client.getLastServerInfoMessage()?.features?.hopliteProvider).toBe(false);
|
||||
const before = await client.getDaemonConfig();
|
||||
await seedSavedSettingsHosts(page, [outdatedDaemon]);
|
||||
await page.reload();
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, outdatedDaemon.serverId);
|
||||
await openSettingsHostSection(page, outdatedDaemon.serverId, "providers");
|
||||
await openAddProviderArea(page);
|
||||
await page.getByRole("button", { name: "Add Hoplite", exact: true }).click();
|
||||
const errorToast = page.getByTestId("app-toast-message");
|
||||
await expect(errorToast).toHaveText("Update the host to add Hoplite.");
|
||||
await expect(errorToast).toBeInViewport();
|
||||
expect((await client.getDaemonConfig()).config).toEqual(before.config);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Hoplite provider details", exact: true }),
|
||||
).toHaveCount(0);
|
||||
await page.screenshot({ path: testInfo.outputPath("hoplite-update-host.png") });
|
||||
} finally {
|
||||
await client.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("model selector excludes Hoplite before opt-in", async ({ page }, testInfo) => {
|
||||
const client = await connectDaemonClient<ProviderCatalogDaemonClient>({
|
||||
clientIdPrefix: "hoplite-picker",
|
||||
});
|
||||
const profiles = await seedAgentProfiles([
|
||||
{ id: "hoplite-picker-anchor", name: "Picker anchor", provider: "mock" },
|
||||
]);
|
||||
const workspace = await seedWorkspace({ repoPrefix: "hoplite-picker-" });
|
||||
try {
|
||||
await client.patchDaemonConfig({ removeProviders: ["hoplite"] });
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await clickNewChat(page);
|
||||
await expectComposerVisible(page);
|
||||
await openModelPicker(page);
|
||||
await expect(page.getByTestId("model-provider-mock")).toBeVisible();
|
||||
await expect(page.getByTestId("model-provider-hoplite")).toHaveCount(0);
|
||||
await page.screenshot({ path: testInfo.outputPath("hoplite-model-selector-absent.png") });
|
||||
await closeModelPicker(page);
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
await profiles.restore();
|
||||
await client.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -284,7 +284,6 @@ async function expectRejectedSubmissionRestored(
|
||||
await expectComposerDraft(page, input.prompt);
|
||||
await expectComposerEditable(page);
|
||||
await expectAttachmentPill(page, "composer-image-attachment-pill");
|
||||
await expect(page.getByTestId("user-message").filter({ hasText: input.prompt })).toHaveCount(0);
|
||||
if (input.preservesActiveTurn) {
|
||||
await expect(page.getByTestId("turn-working-indicator")).toBeVisible();
|
||||
return;
|
||||
@@ -295,13 +294,21 @@ async function expectRejectedSubmissionRestored(
|
||||
|
||||
async function retryRestoredSubmission(page: Page, prompt: string): Promise<void> {
|
||||
await page.getByRole("textbox", { name: "Message agent..." }).first().press("Enter");
|
||||
const userMessage = page.getByTestId("user-message").filter({ hasText: prompt });
|
||||
await expect(userMessage).toHaveCount(1);
|
||||
const attempts = page.getByTestId("user-message").filter({ hasText: prompt });
|
||||
await expect(attempts).toHaveCount(2);
|
||||
const userMessage = attempts.last();
|
||||
await expect(userMessage).toHaveAttribute("aria-busy", "false", { timeout: 30_000 });
|
||||
await expect(userMessage.getByRole("button", { name: "Open image attachment" })).toBeVisible();
|
||||
await expect(page.getByTestId("composer-image-attachment-pill")).toHaveCount(0);
|
||||
}
|
||||
|
||||
async function expectRejectedPromptBeforeError(page: Page, prompt: string, errorMessage: string) {
|
||||
const messages = page.getByTestId("user-message").or(page.getByTestId("assistant-message"));
|
||||
await expect(messages).toHaveCount(2);
|
||||
await expect(messages.nth(0)).toContainText(prompt);
|
||||
await expect(messages.nth(1)).toContainText(`[System Error] ${errorMessage}`);
|
||||
}
|
||||
|
||||
async function configureSteerInSettings(page: Page): Promise<void> {
|
||||
const modifier = process.platform === "darwin" ? "Meta" : "Control";
|
||||
await page.keyboard.press(`${modifier}+Comma`);
|
||||
@@ -1173,13 +1180,14 @@ test.describe("Agent message submission", () => {
|
||||
await toasts.expectNeverShown("agent-updating-toast");
|
||||
});
|
||||
|
||||
test("restores a rejected submission and accepts its retry", async ({
|
||||
test("retains a rejected submission before its error and accepts its retry", async ({
|
||||
page,
|
||||
rejectionScenario,
|
||||
}) => {
|
||||
const prompt = "Restore this rejected submission.";
|
||||
await submitMessageThatWillBeRejected(page, prompt);
|
||||
await expectRejectedSubmissionRestored(page, { prompt, ...rejectionScenario });
|
||||
await expectRejectedPromptBeforeError(page, prompt, rejectionScenario.errorMessage);
|
||||
await retryRestoredSubmission(page, prompt);
|
||||
});
|
||||
|
||||
@@ -1209,6 +1217,7 @@ test.describe("Agent message submission", () => {
|
||||
errorMessage: "Requested mock steer transport failure",
|
||||
preservesActiveTurn: true,
|
||||
});
|
||||
await expect(page.getByTestId("user-message").filter({ hasText: prompt })).toHaveCount(0);
|
||||
|
||||
expect(gate.getClientRequestCount("send_agent_message_request")).toBe(sendsBefore + 1);
|
||||
expect(gate.getClientRequestCount("cancel_agent_request")).toBe(cancelsBefore);
|
||||
|
||||
@@ -133,58 +133,6 @@ test("scroll detector accounts for delayed wheel input and growth below the new
|
||||
).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("scroll detector follows the entered image through resize and virtual offset correction", () => {
|
||||
for (const height of [225, 1632]) {
|
||||
const before: ScrollFrame = {
|
||||
at: 1000,
|
||||
scrollTop: 2208,
|
||||
scrollHeight: 5000,
|
||||
viewportHeight: 516,
|
||||
virtualized: true,
|
||||
loading: false,
|
||||
rows: [
|
||||
{ id: "image", top: -704, height: 560 },
|
||||
{ id: "caption", top: -144, height: 100 },
|
||||
{ id: "old-reader", top: -44, height: 127 },
|
||||
],
|
||||
anchor: "old-reader",
|
||||
wheelTotal: 0,
|
||||
lastWheelAt: 0,
|
||||
inputFinishedAt: null,
|
||||
imageLoads: 0,
|
||||
mounted: 3,
|
||||
unmounted: 0,
|
||||
};
|
||||
const resize = height - 560;
|
||||
const after: ScrollFrame = {
|
||||
...before,
|
||||
at: 1060,
|
||||
// The virtualizer corrects 110px of estimates while the wheel moves 160px.
|
||||
scrollTop: 1938,
|
||||
scrollHeight: 5000 + resize - 110,
|
||||
wheelTotal: 160,
|
||||
lastWheelAt: 1020,
|
||||
imageLoads: 1,
|
||||
rows: [
|
||||
{ id: "image", top: -544, height },
|
||||
{ id: "caption", top: 16 + resize, height: 100 },
|
||||
{ id: "old-reader", top: 116 + resize, height: 127 },
|
||||
],
|
||||
};
|
||||
expect(findScrollJumps([before, after])).toEqual([]);
|
||||
// Resizing must not excuse additional viewport movement.
|
||||
expect(
|
||||
findScrollJumps([
|
||||
before,
|
||||
{
|
||||
...after,
|
||||
rows: after.rows.map((row) => ({ id: row.id, height: row.height, top: row.top + 100 })),
|
||||
},
|
||||
]),
|
||||
).toHaveLength(1);
|
||||
}
|
||||
});
|
||||
|
||||
for (const cadence of scrollCadences) {
|
||||
test(`varied timeline preserves reading position during ${cadence.name} upward scrolling`, async ({
|
||||
page,
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { gateNextAgentMessage } from "../support/helpers/agent-message-gate";
|
||||
import {
|
||||
fillComposerDraft,
|
||||
expectComposerDraft,
|
||||
attachFileFromMenu,
|
||||
} from "../support/helpers/composer";
|
||||
import { ensureExplorerSidebar, openFilesPanel } from "../support/helpers/workspace-tabs";
|
||||
|
||||
const APP_SETTINGS_KEY = "@paseo:app-settings";
|
||||
@@ -26,14 +33,19 @@ async function openComposerDiff(page: Page) {
|
||||
await composerChangesPill(page).click();
|
||||
}
|
||||
|
||||
async function seedChangedAgent(repoPrefix: string) {
|
||||
async function seedChangedAgent(
|
||||
repoPrefix: string,
|
||||
featureValues?: Record<string, unknown>,
|
||||
files: Array<{ path: string; content: string }> = [],
|
||||
) {
|
||||
const workspace = await seedMockAgentWorkspace({
|
||||
repoPrefix,
|
||||
featureValues,
|
||||
title: "Composer diff stat",
|
||||
repo: {
|
||||
withRemote: true,
|
||||
// Exclude the local remote before the daemon starts observing this checkout.
|
||||
files: [{ path: ".gitignore", content: "/remote.git/\n" }],
|
||||
files: [{ path: ".gitignore", content: "/remote.git/\n" }, ...files],
|
||||
},
|
||||
});
|
||||
try {
|
||||
@@ -156,3 +168,691 @@ test("composer diff stat reveals Changes, then opens the diff in the focused pan
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
async function tapFirstAddedDiffLine(
|
||||
page: Page,
|
||||
surface: Locator = page.getByTestId("working-diff-panel"),
|
||||
) {
|
||||
const body = surface.getByTestId("diff-file-0-body");
|
||||
await expect(body).toBeVisible({ timeout: 30000 });
|
||||
const bounds = await body.boundingBox();
|
||||
if (!bounds) throw new Error("Expanded diff body has no bounds");
|
||||
const fontSize = await surface
|
||||
.getByTestId("git-diff-canvas")
|
||||
.evaluate((element) => Number.parseFloat(getComputedStyle(element).fontSize));
|
||||
await page.touchscreen.tap(bounds.x + 120, bounds.y + Math.round(fontSize * 1.5) * 2.5);
|
||||
}
|
||||
|
||||
async function openReviewDiff(page: Page, workspace: Awaited<ReturnType<typeof seedChangedAgent>>) {
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: workspace.agentId });
|
||||
await expect(composerChangesPill(page)).toBeVisible({ timeout: 30000 });
|
||||
if (await page.getByTestId("workspace-tab-working_diff").count()) {
|
||||
await selectDiffTab(page);
|
||||
} else {
|
||||
await revealComposerChangesInExplorer(page);
|
||||
await openComposerDiff(page);
|
||||
}
|
||||
await expect(page.getByTestId("diff-file-0-body")).toBeVisible();
|
||||
}
|
||||
|
||||
async function saveReviewComment(page: Page, body: string) {
|
||||
await page.getByRole("textbox", { name: "Review comment" }).fill(body);
|
||||
await page.getByRole("button", { name: "Save review comment", exact: true }).click();
|
||||
await expect(page.getByRole("button", { name: "Bottom sheet backdrop" })).toHaveCount(0);
|
||||
}
|
||||
|
||||
async function cancelReviewComment(page: Page) {
|
||||
await page.getByRole("button", { name: "Cancel review comment", exact: true }).click();
|
||||
await expect(page.getByRole("button", { name: "Bottom sheet backdrop" })).toHaveCount(0);
|
||||
}
|
||||
|
||||
test.describe("review comments", () => {
|
||||
test.use({ hasTouch: true });
|
||||
|
||||
test("compact review comments open a sheet and preserve saved comments through save, edit, cancel and reload", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("compact-review-comment-");
|
||||
try {
|
||||
await test.step("Open a compact sheet with reachable input and actions", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await showCompactLayout(page);
|
||||
await tapFirstAddedDiffLine(page);
|
||||
await expectCompactCommentSheet(page);
|
||||
});
|
||||
await test.step("Save, discard an edit, then save an updated comment", async () => {
|
||||
await saveReviewComment(page, " Please simplify this. ");
|
||||
await expectSavedReview(page, "Please simplify this.");
|
||||
await editSavedReview(page, "Please simplify this.");
|
||||
await fillReviewComment(page, "Discard this edit");
|
||||
await cancelReviewComment(page);
|
||||
await expectSavedReview(page, "Please simplify this.");
|
||||
await editSavedReview(page, "Please simplify this.");
|
||||
await saveReviewComment(page, "Updated comment");
|
||||
await expectSavedReview(page, "Updated comment");
|
||||
});
|
||||
await test.step("Discard a new comment and retain the saved one after reload", async () => {
|
||||
await tapFirstAddedDiffLine(page);
|
||||
await fillReviewComment(page, "Discard new comment");
|
||||
await cancelReviewComment(page);
|
||||
await expectReviewAbsent(page, "Discard new comment");
|
||||
await reloadReview(page);
|
||||
await expectSavedReview(page, "Updated comment");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("wide review comments retain inline editing", async ({ page }) => {
|
||||
const workspace = await seedChangedAgent("wide-review-comment-");
|
||||
try {
|
||||
await test.step("Save and cancel an inline edit on a wide screen", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await tapFirstAddedDiffLine(page);
|
||||
await expectInlineCommentEditor(page);
|
||||
await saveReviewComment(page, "Wide comment");
|
||||
await expectSavedReview(page, "Wide comment");
|
||||
await editSavedReview(page, "Wide comment");
|
||||
await expectInlineCommentEditor(page);
|
||||
await cancelReviewComment(page);
|
||||
await expectSavedReview(page, "Wide comment");
|
||||
});
|
||||
await test.step("The existing composer still sends the review", async () => {
|
||||
await sendReviewThroughComposer(page, workspace.agentId);
|
||||
await selectDiffTab(page);
|
||||
await expectReviewAbsent(page, "Wide comment");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function sendReviewThroughComposer(page: Page, agentId: string) {
|
||||
await page.getByTestId(`workspace-tab-agent_${agentId}`).click();
|
||||
await expect(page.getByTestId("composer-review-attachment-pill")).toBeVisible();
|
||||
await page.getByRole("textbox", { name: "Message agent..." }).fill("Address this review");
|
||||
await page.getByRole("button", { name: "Send message", exact: true }).click();
|
||||
await expect(page.getByText("Address this review", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByTestId("composer-review-attachment-pill")).toHaveCount(0);
|
||||
}
|
||||
|
||||
async function addSavedReview(
|
||||
page: Page,
|
||||
body: string,
|
||||
surface: Locator = page.getByTestId("working-diff-panel"),
|
||||
) {
|
||||
await tapFirstAddedDiffLine(page, surface);
|
||||
await saveReviewComment(page, body);
|
||||
await expectSavedReview(page, body, surface);
|
||||
}
|
||||
|
||||
async function expectSavedReview(
|
||||
page: Page,
|
||||
body: string,
|
||||
surface: Locator = page.getByTestId("working-diff-panel"),
|
||||
) {
|
||||
await expect(surface.getByText(body, { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
async function editSavedReview(page: Page, expectedBody: string) {
|
||||
await page
|
||||
.getByTestId("working-diff-panel")
|
||||
.getByRole("button", { name: "Edit review comment", exact: true })
|
||||
.click();
|
||||
await expect(page.getByRole("textbox", { name: "Review comment" })).toHaveValue(expectedBody);
|
||||
}
|
||||
|
||||
async function sendFeedback(page: Page, count: number) {
|
||||
await page.getByRole("button", { name: `Send feedback (${count})`, exact: true }).click();
|
||||
}
|
||||
|
||||
async function expectFeedbackSent(page: Page, recipient: string) {
|
||||
await expect(page.getByText(`Feedback sent to ${recipient}`, { exact: true })).toBeVisible();
|
||||
await expect(page.getByTestId("working-diff-panel")).toBeVisible();
|
||||
}
|
||||
|
||||
test.describe("send review feedback", () => {
|
||||
test.use({ hasTouch: true });
|
||||
|
||||
test("compact feedback sends directly to the only workspace agent and preserves its composer draft", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-feedback-single-");
|
||||
try {
|
||||
await test.step("Save a review without changing the chat draft", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await selectAgentTab(page, workspace.agentId);
|
||||
await fillComposerDraft(page, "Keep this thought");
|
||||
await attachFileFromMenu(page, {
|
||||
name: "unrelated.txt",
|
||||
mimeType: "text/plain",
|
||||
buffer: Buffer.from("Unrelated draft attachment"),
|
||||
});
|
||||
await selectDiffTab(page);
|
||||
await showCompactLayout(page);
|
||||
await addSavedReview(page, "Please simplify this.");
|
||||
});
|
||||
await test.step("Send directly and stay on the diff", async () => {
|
||||
await sendFeedback(page, 1);
|
||||
await expectFeedbackSent(page, "Composer diff stat");
|
||||
await expectReviewAbsent(page, "Please simplify this.");
|
||||
await captureFeedback(page, "single");
|
||||
});
|
||||
await test.step("Return to the untouched composer draft", async () => {
|
||||
await showWideLayout(page);
|
||||
await selectAgentTab(page, workspace.agentId);
|
||||
await expectComposerDraft(page, "Keep this thought");
|
||||
await expect(page.getByText("unrelated.txt", { exact: true })).toBeVisible();
|
||||
await expect(page.getByTestId("composer-review-attachment-pill")).toHaveCount(0);
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
test("feedback pending ownership follows the draft across Diff and compact Changes", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-shared-pending-");
|
||||
const gate = await gateNextAgentMessage(page);
|
||||
try {
|
||||
await test.step("Send feedback from the Diff tab and hold its real request", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await showCompactLayout(page);
|
||||
await addSavedReview(page, "One draft across surfaces");
|
||||
await sendFeedback(page, 1);
|
||||
await gate.waitForRequest();
|
||||
});
|
||||
await test.step("The compact Changes surface observes the same pending operation", async () => {
|
||||
await revealCompactChanges(page);
|
||||
await expect(
|
||||
compactReviewSurface(page).getByRole("button", {
|
||||
name: "Sending feedback (1)",
|
||||
exact: true,
|
||||
}),
|
||||
).toBeDisabled();
|
||||
expect(gate.requestCount()).toBe(1);
|
||||
gate.accept();
|
||||
await expect(
|
||||
compactReviewSurface(page).getByText("Feedback sent to Composer diff stat", {
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("an unsaved review survives presentation changes and acknowledgement before Save", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-editor-ownership-");
|
||||
const gate = await gateNextAgentMessage(page);
|
||||
try {
|
||||
await test.step("Carry unsaved inline text into the compact sheet and back", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await tapFirstAddedDiffLine(page);
|
||||
await fillReviewComment(page, "Body across presentations");
|
||||
await showCompactLayout(page);
|
||||
await expectReviewEditorBody(page, "Body across presentations");
|
||||
await showWideLayout(page);
|
||||
await expectReviewEditorBody(page, "Body across presentations");
|
||||
await saveReviewComment(page, "Body across presentations");
|
||||
});
|
||||
await test.step("Keep an open edit saveable after acknowledgement removes its original", async () => {
|
||||
await sendFeedback(page, 1);
|
||||
await gate.waitForRequest();
|
||||
await editSavedReview(page, "Body across presentations");
|
||||
await fillReviewComment(page, "Keep this unsaved edit");
|
||||
gate.accept();
|
||||
await expectFeedbackSent(page, "Composer diff stat");
|
||||
await expectReviewEditorBody(page, "Keep this unsaved edit");
|
||||
await showCompactLayout(page);
|
||||
await expectReviewEditorBody(page, "Keep this unsaved edit");
|
||||
await saveReviewComment(page, "Keep this unsaved edit");
|
||||
await expectSavedReview(page, "Keep this unsaved edit");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("saved feedback preserves navigation across multiple diff files", async ({ page }) => {
|
||||
const workspace = await seedMultiFileReview();
|
||||
try {
|
||||
await test.step("Save compact feedback and retain both floating actions", async () => {
|
||||
await openCompactReviewExplorer(page, workspace);
|
||||
await addSavedReview(page, "Keep file navigation available", compactReviewSurface(page));
|
||||
await expectReviewNavigationReachable(page);
|
||||
});
|
||||
await test.step("Jump to another file without covering the feedback action", async () => {
|
||||
await jumpToReviewFile(page, "z-last.ts");
|
||||
await scrollReviewToLastLine(page);
|
||||
await expectReviewNavigationReachable(page);
|
||||
await captureFeedback(page, "navigation-compact");
|
||||
});
|
||||
await test.step("Wide file navigation and feedback remain reachable", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await navigateWideReviewFile(page, "README.md");
|
||||
await expectFeedbackReachable(page);
|
||||
await expectSavedReview(page, "Keep file navigation available");
|
||||
await captureFeedback(page, "navigation-wide");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("feedback sends only matching comments and preserves orphaned comments", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedMultiFileReview();
|
||||
try {
|
||||
await test.step("A saved comment whose diff disappears has no sendable context", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await showCompactLayout(page);
|
||||
await addSavedReview(page, "Retain this orphan");
|
||||
await setReadmeDiff(workspace, false);
|
||||
await expectUnmatchedFeedback(page);
|
||||
});
|
||||
await test.step("Send the matching subset with an accurate count", async () => {
|
||||
await addSavedReview(page, "Send this matching comment");
|
||||
await sendFeedback(page, 1);
|
||||
await expectFeedbackSent(page, "Composer diff stat");
|
||||
await expectReviewAbsent(page, "Send this matching comment");
|
||||
await expectUnmatchedFeedback(page);
|
||||
});
|
||||
await test.step("Restoring the missing diff reveals the unsent comment", async () => {
|
||||
await setReadmeDiff(workspace, true);
|
||||
await expectSavedReview(page, "Retain this orphan");
|
||||
await expectFeedbackReachable(page);
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("zero open agent tabs retain feedback with a disabled reason", async ({ page }) => {
|
||||
const workspace = await seedChangedAgent("review-feedback-zero-");
|
||||
try {
|
||||
await test.step("Close the agent tab while keeping the review", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await addSavedReview(page, "Keep until an agent is opened");
|
||||
await closeAgentTab(page, workspace.agentId);
|
||||
});
|
||||
await test.step("The disabled action explains why in wide and compact layouts", async () => {
|
||||
await expectFeedbackUnavailable(page);
|
||||
await captureFeedback(page, "zero-wide");
|
||||
await showCompactLayout(page);
|
||||
await expectFeedbackUnavailable(page);
|
||||
await expectSavedReview(page, "Keep until an agent is opened");
|
||||
await captureFeedback(page, "zero-compact");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("only open tabs in this workspace appear in compact and wide recipient menus", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-feedback-multiple-");
|
||||
const other = await seedChangedAgent("review-feedback-other-");
|
||||
try {
|
||||
const second = await createReviewRecipient(workspace, "Second reviewer");
|
||||
const historical = await createReviewRecipient(workspace, "Closed historical agent");
|
||||
await test.step("Open two local tabs and a tab in another workspace", async () => {
|
||||
await openReviewDiff(page, other);
|
||||
await addSavedReview(page, "Other workspace review");
|
||||
await openReviewDiff(page, workspace);
|
||||
await closeAgentTab(page, historical.id);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: second.id });
|
||||
await selectDiffTab(page);
|
||||
await addSavedReview(page, "Review for second agent");
|
||||
});
|
||||
await test.step("The wide menu includes only local open agents", async () => {
|
||||
await captureWideFeedbackAppearance(page);
|
||||
});
|
||||
await test.step("Escape returns keyboard focus to feedback so the chooser can reopen", async () => {
|
||||
await openFeedbackWithKeyboard(page);
|
||||
await dismissRecipientMenu(page);
|
||||
await expectFeedbackFocused(page);
|
||||
await reopenFeedbackWithKeyboard(page);
|
||||
await dismissRecipientMenu(page);
|
||||
await expectFeedbackFocused(page);
|
||||
});
|
||||
await test.step("Choose the second agent in the compact menu and stay on the diff", async () => {
|
||||
await showCompactLayout(page);
|
||||
await captureFeedback(page, "cta-compact");
|
||||
await sendFeedback(page, 1);
|
||||
await expectRecipientMenu(page);
|
||||
await captureFeedback(page, "menu-compact");
|
||||
await chooseFeedbackRecipient(page, "Second reviewer");
|
||||
await expectFeedbackSent(page, "Second reviewer");
|
||||
await expectReviewAbsent(page, "Review for second agent");
|
||||
});
|
||||
await test.step("The other workspace's saved review remains", async () => {
|
||||
await openReviewDiff(page, other);
|
||||
await expectSavedReview(page, "Other workspace review");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
await other.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("failed feedback remains editable and retries through the real provider", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-feedback-retry-", { mockPromptRejections: 1 });
|
||||
try {
|
||||
await test.step("A provider rejection retains the saved review", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await showCompactLayout(page);
|
||||
await addSavedReview(page, "Initial feedback");
|
||||
await sendFeedback(page, 1);
|
||||
await expectFeedbackFailure(page);
|
||||
await expectSavedReview(page, "Initial feedback");
|
||||
await captureFeedback(page, "failure");
|
||||
});
|
||||
await test.step("Edit the retained feedback and retry successfully", async () => {
|
||||
await editSavedReview(page, "Initial feedback");
|
||||
await saveReviewComment(page, "Corrected feedback");
|
||||
await sendFeedback(page, 1);
|
||||
await expectFeedbackSent(page, "Composer diff stat");
|
||||
await expectReviewAbsent(page, "Corrected feedback");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("pending feedback blocks repeat submission and preserves edits and additions", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedChangedAgent("review-feedback-pending-");
|
||||
const gate = await gateNextAgentMessage(page);
|
||||
try {
|
||||
await test.step("Hold the real request while feedback is pending", async () => {
|
||||
await openReviewDiff(page, workspace);
|
||||
await showCompactLayout(page);
|
||||
await addSavedReview(page, "Sent version");
|
||||
await sendFeedback(page, 1);
|
||||
const request = await gate.waitForRequest();
|
||||
expect(request.agentId).toBe(workspace.agentId);
|
||||
expect(request.text).toBe("Please address this code review.");
|
||||
expect(request.attachments).toMatchObject([
|
||||
{
|
||||
type: "review",
|
||||
cwd: workspace.cwd,
|
||||
comments: [
|
||||
{
|
||||
filePath: "README.md",
|
||||
lineNumber: 2,
|
||||
body: "Sent version",
|
||||
context: { targetLine: { content: "export const one = 1;", newLineNumber: 2 } },
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
await expectFeedbackPending(page);
|
||||
});
|
||||
await test.step("Save an edit and another comment before acknowledgement", async () => {
|
||||
await editSavedReview(page, "Sent version");
|
||||
await saveReviewComment(page, "Edited during send");
|
||||
await addSavedReview(page, "Added during send");
|
||||
await expectFeedbackPending(page);
|
||||
expect(gate.requestCount()).toBe(1);
|
||||
await captureFeedback(page, "pending");
|
||||
});
|
||||
await test.step("A real acknowledgement preserves both new versions", async () => {
|
||||
gate.accept();
|
||||
await expectFeedbackSent(page, "Composer diff stat");
|
||||
await expectSavedReview(page, "Edited during send");
|
||||
await expectSavedReview(page, "Added during send");
|
||||
await expectReviewAbsent(page, "Sent version");
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function showCompactLayout(page: Page) {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
}
|
||||
async function showWideLayout(page: Page) {
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
}
|
||||
async function selectAgentTab(page: Page, agentId: string) {
|
||||
await page.getByTestId(`workspace-tab-agent_${agentId}`).click({ position: { x: 12, y: 13 } });
|
||||
}
|
||||
async function selectDiffTab(page: Page) {
|
||||
await page.getByTestId("workspace-tab-working_diff").click({ position: { x: 12, y: 13 } });
|
||||
}
|
||||
async function fillReviewComment(page: Page, body: string) {
|
||||
await page.getByRole("textbox", { name: "Review comment" }).fill(body);
|
||||
}
|
||||
async function expectReviewAbsent(page: Page, body: string) {
|
||||
await expect(page.getByTestId("working-diff-panel").getByText(body, { exact: true })).toHaveCount(
|
||||
0,
|
||||
);
|
||||
}
|
||||
async function reloadReview(page: Page) {
|
||||
await page.reload();
|
||||
await expect(page.getByTestId("working-diff-panel")).toBeVisible({ timeout: 30000 });
|
||||
}
|
||||
async function expectInlineCommentEditor(page: Page) {
|
||||
await expect(page.getByTestId("inline-review-editor")).toBeVisible();
|
||||
await expect(page.getByTestId("review-comment-sheet")).toHaveCount(0);
|
||||
}
|
||||
async function expectCompactCommentSheet(page: Page) {
|
||||
await expect(page.getByTestId("review-comment-sheet")).toBeVisible();
|
||||
await expect(page.getByText("README.md · +2", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("textbox", { name: "Review comment" })).toBeInViewport({ ratio: 1 });
|
||||
for (const action of ["Save", "Cancel"])
|
||||
await expect(
|
||||
page.getByRole("button", { name: `${action} review comment`, exact: true }),
|
||||
).toBeInViewport({ ratio: 1 });
|
||||
await expect(page.getByTestId("inline-review-editor")).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Save review comment", exact: true }),
|
||||
).toBeDisabled();
|
||||
}
|
||||
function feedbackButton(page: Page) {
|
||||
return page.getByRole("button", { name: "Send feedback (1)", exact: true });
|
||||
}
|
||||
async function openFeedbackWithKeyboard(page: Page) {
|
||||
await feedbackButton(page).focus();
|
||||
await expectFeedbackFocused(page);
|
||||
await reopenFeedbackWithKeyboard(page);
|
||||
}
|
||||
async function reopenFeedbackWithKeyboard(page: Page) {
|
||||
await page.keyboard.press("Enter");
|
||||
await expectRecipientMenu(page);
|
||||
const recipient = page.getByRole("menuitem", { name: "Composer diff stat", exact: true });
|
||||
await recipient.focus();
|
||||
await expect(recipient).toBeFocused();
|
||||
}
|
||||
async function expectFeedbackFocused(page: Page) {
|
||||
await expect(feedbackButton(page)).toBeFocused();
|
||||
}
|
||||
|
||||
async function captureWideFeedbackAppearance(page: Page) {
|
||||
for (const colorScheme of ["light", "dark"] as const) {
|
||||
await page.emulateMedia({ colorScheme });
|
||||
await expectSavedReview(page, "Review for second agent");
|
||||
await captureFeedback(page, `cta-wide-${colorScheme}-closed`);
|
||||
await sendFeedback(page, 1);
|
||||
await expectRecipientMenu(page);
|
||||
await captureFeedback(page, `cta-wide-${colorScheme}-open`);
|
||||
await dismissRecipientMenu(page);
|
||||
}
|
||||
await page.emulateMedia({ colorScheme: "light" });
|
||||
}
|
||||
|
||||
async function captureFeedback(page: Page, name: string) {
|
||||
await page.screenshot({ path: `/tmp/phase2-feedback-${name}.png` });
|
||||
}
|
||||
|
||||
async function closeAgentTab(page: Page, agentId: string) {
|
||||
await page.getByTestId(`workspace-tab-agent_${agentId}`).click({ button: "right" });
|
||||
await page.getByTestId(`workspace-tab-context-agent_${agentId}-close`).click();
|
||||
await expect(page.getByTestId(`workspace-tab-agent_${agentId}`)).toHaveCount(0);
|
||||
}
|
||||
async function expectFeedbackUnavailable(page: Page) {
|
||||
await expect(page.getByRole("button", { name: "Send feedback (1)", exact: true })).toBeDisabled();
|
||||
await expect(
|
||||
page.getByText("Open an agent tab in this workspace to send feedback.", { exact: true }),
|
||||
).toBeVisible();
|
||||
}
|
||||
async function createReviewRecipient(
|
||||
workspace: Awaited<ReturnType<typeof seedChangedAgent>>,
|
||||
title: string,
|
||||
) {
|
||||
return workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.cwd,
|
||||
workspaceId: workspace.workspaceId,
|
||||
title,
|
||||
modeId: "load-test",
|
||||
model: "e2e-fast-stream",
|
||||
});
|
||||
}
|
||||
async function expectRecipientMenu(page: Page) {
|
||||
for (const name of ["Composer diff stat", "Second reviewer"]) {
|
||||
await expect(page.getByRole("menuitem", { name, exact: true })).toBeInViewport({ ratio: 1 });
|
||||
}
|
||||
await expect(page.getByRole("menuitem")).toHaveCount(2);
|
||||
}
|
||||
async function dismissRecipientMenu(page: Page) {
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByRole("menuitem")).toHaveCount(0);
|
||||
}
|
||||
async function chooseFeedbackRecipient(page: Page, name: string) {
|
||||
await page.getByRole("menuitem", { name, exact: true }).click();
|
||||
}
|
||||
async function expectFeedbackFailure(page: Page) {
|
||||
await expect(
|
||||
page.getByText("Requested mock prompt rejection", { exact: true }).first(),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Send feedback (1)", exact: true })).toBeEnabled();
|
||||
}
|
||||
async function expectFeedbackPending(page: Page, count = 1) {
|
||||
await expect(
|
||||
page.getByRole("button", { name: `Sending feedback (${count})`, exact: true }),
|
||||
).toBeDisabled();
|
||||
}
|
||||
|
||||
async function seedMultiFileReview() {
|
||||
const workspace = await seedChangedAgent("review-feedback-navigation-", undefined, [
|
||||
{ path: "z-last.ts", content: "export const final = 0;\n" },
|
||||
]);
|
||||
await writeFile(
|
||||
path.join(workspace.cwd, "z-last.ts"),
|
||||
Array.from({ length: 120 }, (_, index) => `export const value${index} = ${index};`).join("\n") +
|
||||
"\n",
|
||||
);
|
||||
await workspace.client.checkoutRefresh(workspace.cwd);
|
||||
return workspace;
|
||||
}
|
||||
async function expectFeedbackReachable(page: Page) {
|
||||
await expect(page.getByRole("button", { name: "Send feedback (1)", exact: true })).toBeInViewport(
|
||||
{ ratio: 1 },
|
||||
);
|
||||
}
|
||||
async function expectReviewNavigationReachable(page: Page) {
|
||||
await expectFeedbackReachable(page);
|
||||
const jump = page.getByRole("button", { name: "Jump to file", exact: true });
|
||||
await expect(jump).toBeInViewport({ ratio: 1 });
|
||||
const navigationBounds = await jump.boundingBox();
|
||||
const feedbackBounds = await page
|
||||
.getByRole("button", { name: "Send feedback (1)", exact: true })
|
||||
.boundingBox();
|
||||
if (!navigationBounds || !feedbackBounds) throw new Error("Review actions have no bounds");
|
||||
expect(feedbackBounds.y + feedbackBounds.height).toBeLessThanOrEqual(navigationBounds.y);
|
||||
}
|
||||
async function jumpToReviewFile(page: Page, name: string) {
|
||||
await page.getByRole("button", { name: "Jump to file", exact: true }).click();
|
||||
const sheet = page.getByTestId("changes-jump-to-file-sheet");
|
||||
await page
|
||||
.getByTestId("changes-file-tree")
|
||||
.filter({ visible: true })
|
||||
.getByText(name, { exact: true })
|
||||
.click();
|
||||
await expect(sheet).toHaveCount(0);
|
||||
await expect(reviewFileHeader(compactReviewSurface(page), name)).toBeInViewport();
|
||||
}
|
||||
async function navigateWideReviewFile(page: Page, name: string) {
|
||||
const explorer = await ensureExplorerSidebar(page);
|
||||
await explorer.getByTestId("changes-tree-panel").getByText(name, { exact: true }).click();
|
||||
await expect(reviewFileHeader(page.getByTestId("working-diff-panel"), name)).toBeInViewport();
|
||||
}
|
||||
|
||||
async function setReadmeDiff(
|
||||
workspace: Awaited<ReturnType<typeof seedChangedAgent>>,
|
||||
changed: boolean,
|
||||
) {
|
||||
await writeFile(
|
||||
path.join(workspace.cwd, "README.md"),
|
||||
changed ? "# Temp Repo\nexport const one = 1;\nexport const two = 2;\n" : "# Temp Repo\n",
|
||||
);
|
||||
await workspace.client.checkoutRefresh(workspace.cwd);
|
||||
}
|
||||
async function expectUnmatchedFeedback(page: Page) {
|
||||
await expect(page.getByRole("button", { name: "Send feedback (0)", exact: true })).toBeDisabled();
|
||||
await expect(
|
||||
page.getByText("Saved comments no longer match this diff.", { exact: true }),
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
function compactReviewSurface(page: Page) {
|
||||
return page.getByTestId("explorer-content-area").filter({ visible: true });
|
||||
}
|
||||
async function openCompactReviewExplorer(
|
||||
page: Page,
|
||||
workspace: Awaited<ReturnType<typeof seedChangedAgent>>,
|
||||
) {
|
||||
await showWideLayout(page);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: workspace.agentId });
|
||||
await selectAgentTab(page, workspace.agentId);
|
||||
await showCompactLayout(page);
|
||||
await composerChangesPill(page).click();
|
||||
await expect(compactReviewSurface(page).getByTestId("diff-file-0-body")).toBeVisible();
|
||||
}
|
||||
|
||||
function reviewFileHeader(surface: Locator, name: string) {
|
||||
return surface.locator(`[data-diff-header-path="${name}"]`).getByTestId(/^diff-file-\d+$/);
|
||||
}
|
||||
|
||||
async function scrollReviewToLastLine(page: Page) {
|
||||
const surface = compactReviewSurface(page);
|
||||
const bounds = await surface.boundingBox();
|
||||
if (!bounds) throw new Error("Compact review has no bounds");
|
||||
await page.mouse.move(bounds.x + 120, bounds.y + 200);
|
||||
await page.mouse.wheel(0, 10000);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const body = await surface.getByTestId("diff-file-1-body").boundingBox();
|
||||
const feedback = await page
|
||||
.getByRole("button", { name: "Send feedback (1)", exact: true })
|
||||
.boundingBox();
|
||||
if (!body || !feedback) return false;
|
||||
return body.y + body.height <= feedback.y;
|
||||
})
|
||||
.toBe(true);
|
||||
}
|
||||
|
||||
async function revealCompactChanges(page: Page) {
|
||||
await page.getByTestId("workspace-explorer-toggle").first().click();
|
||||
await page.getByTestId("explorer-header").getByText("Changes", { exact: true }).click();
|
||||
await expect(compactReviewSurface(page).getByTestId("diff-file-0-body")).toBeVisible();
|
||||
}
|
||||
async function expectReviewEditorBody(page: Page, body: string) {
|
||||
await expect(page.getByRole("textbox", { name: "Review comment", exact: true })).toHaveValue(
|
||||
body,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,3 +128,46 @@ for (const scenario of [
|
||||
await creation.expectAgentCount(1);
|
||||
});
|
||||
}
|
||||
|
||||
for (const entry of [
|
||||
{
|
||||
name: "agent draft",
|
||||
open: (creation: Awaited<ReturnType<typeof createCreationScenario>>) =>
|
||||
creation.openAgentDraft(),
|
||||
button: "Send message",
|
||||
settled: async (_creation: Awaited<ReturnType<typeof createCreationScenario>>) => {},
|
||||
},
|
||||
{
|
||||
name: "new workspace",
|
||||
open: (creation: Awaited<ReturnType<typeof createCreationScenario>>) =>
|
||||
creation.openWorkspaceForm("local"),
|
||||
button: "Create",
|
||||
settled: (creation: Awaited<ReturnType<typeof createCreationScenario>>) =>
|
||||
creation.expectOneCreatedWorkspace(),
|
||||
},
|
||||
]) {
|
||||
test(`${entry.name} becomes an agent tab when the first prompt is rejected`, async ({
|
||||
creation,
|
||||
promptRejection,
|
||||
page,
|
||||
}, testInfo) => {
|
||||
void promptRejection;
|
||||
const prompt =
|
||||
"Continue the attached conversation.\n" + "Earlier conversation context.\n".repeat(100);
|
||||
await entry.open(creation);
|
||||
await creation.submitPrompt(prompt, entry.button);
|
||||
await entry.settled(creation);
|
||||
await creation.expectCreatedAgentError();
|
||||
await creation.expectPromptBeforeError(prompt);
|
||||
await page.screenshot({ path: testInfo.outputPath("created-agent-prompt-error.png") });
|
||||
await creation.reloadAgent();
|
||||
await creation.expectPromptBeforeError(prompt);
|
||||
await creation.submitPrompt("emit 1 coalesced agent stream updates for a corrected prompt.");
|
||||
await creation.expectPromptVisible(
|
||||
"emit 1 coalesced agent stream updates for a corrected prompt.",
|
||||
);
|
||||
await creation.expectAssistantReply();
|
||||
await creation.expectAgentCount(1);
|
||||
await expect(page.getByText("agent_request_key_conflict", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
import path from "node:path";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import {
|
||||
closeModelPicker,
|
||||
drillIntoProvider,
|
||||
openModelPicker,
|
||||
} from "../support/helpers/agent-profiles";
|
||||
import { expectComposerVisible, expectComposerFocused } from "../support/helpers/composer";
|
||||
import { connectDaemonClient } from "../support/helpers/daemon-client-loader";
|
||||
import { clickNewChat, gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { openSettingsHost, openSettingsHostSection } from "../support/helpers/settings";
|
||||
|
||||
// Use an existing repository linked to the signed-in user's Hoplite project.
|
||||
const cwd = process.env.E2E_HOPLITE_CWD ?? path.resolve(__dirname, "../../../..");
|
||||
|
||||
test.use({
|
||||
viewport: { width: 1440, height: 1000 },
|
||||
e2eDaemonConfig: { version: 1, agents: { providers: { hoplite: { enabled: true } } } },
|
||||
});
|
||||
|
||||
async function openHopliteSettings(page: Page): Promise<void> {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, getServerId());
|
||||
await openSettingsHostSection(page, getServerId(), "providers");
|
||||
await page.getByRole("button", { name: "Hoplite provider details", exact: true }).click();
|
||||
}
|
||||
|
||||
async function expectEmptyGlobalCatalog(page: Page, client: DaemonClient): Promise<void> {
|
||||
const models = await client.listProviderModels("hoplite");
|
||||
expect(models.error).toBeNull();
|
||||
expect(models.models).toEqual([]);
|
||||
const snapshot = await client.getProvidersSnapshot();
|
||||
expect(snapshot.entries.find((entry) => entry.provider === "hoplite")).toMatchObject({
|
||||
status: "ready",
|
||||
models: [],
|
||||
});
|
||||
await expect(page.getByText("No models detected", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Retry", exact: true })).toHaveCount(0);
|
||||
}
|
||||
|
||||
async function refreshGlobalCatalog(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: "Refresh", exact: true }).click();
|
||||
await expect(page.getByRole("button", { name: "Refresh", exact: true })).toBeEnabled({
|
||||
timeout: 120_000,
|
||||
});
|
||||
}
|
||||
|
||||
async function openWorkspaceModels(page: Page, workspaceId: string): Promise<void> {
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await clickNewChat(page);
|
||||
await expectComposerVisible(page);
|
||||
await expectComposerFocused(page);
|
||||
await openModelPicker(page);
|
||||
await page.getByTestId("sheet-header-back").click();
|
||||
await drillIntoProvider(page, "hoplite");
|
||||
}
|
||||
|
||||
test("real Hoplite has an empty global catalog and discovers models in its linked workspace", async ({
|
||||
page,
|
||||
e2eWorkerClient,
|
||||
}, testInfo) => {
|
||||
test.setTimeout(180_000);
|
||||
const client = await connectDaemonClient<DaemonClient>({ clientIdPrefix: "hoplite-discovery" });
|
||||
const created = await e2eWorkerClient.createWorkspace({
|
||||
source: { kind: "directory", path: cwd },
|
||||
title: "Hoplite discovery QA",
|
||||
});
|
||||
expect(created.error).toBeNull();
|
||||
const workspace = created.workspace!;
|
||||
try {
|
||||
await test.step("global settings succeed with no models, including refresh", async () => {
|
||||
await openHopliteSettings(page);
|
||||
await expectEmptyGlobalCatalog(page, client);
|
||||
await refreshGlobalCatalog(page);
|
||||
await expectEmptyGlobalCatalog(page, client);
|
||||
await page.screenshot({ path: testInfo.outputPath("hoplite-global-empty.png") });
|
||||
});
|
||||
|
||||
await test.step("the linked workspace discovers real models", async () => {
|
||||
const models = await client.listProviderModels("hoplite", { cwd });
|
||||
expect(models.error).toBeNull();
|
||||
expect(models.models!.length).toBeGreaterThan(0);
|
||||
await testInfo.attach("workspace-models", {
|
||||
body: JSON.stringify(models, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
await openWorkspaceModels(page, workspace.id);
|
||||
await expect(page.getByText(models.models![0]!.label, { exact: true }).last()).toBeVisible();
|
||||
await page.screenshot({ path: testInfo.outputPath("hoplite-workspace-models.png") });
|
||||
await closeModelPicker(page);
|
||||
});
|
||||
|
||||
await test.step("workspace discovery does not populate the global catalog", async () => {
|
||||
await openHopliteSettings(page);
|
||||
await expectEmptyGlobalCatalog(page, client);
|
||||
await refreshGlobalCatalog(page);
|
||||
await expectEmptyGlobalCatalog(page, client);
|
||||
const models = await client.listProviderModels("hoplite", { cwd });
|
||||
expect(models.error).toBeNull();
|
||||
expect(models.models!.length).toBeGreaterThan(0);
|
||||
});
|
||||
} finally {
|
||||
await client.close();
|
||||
await e2eWorkerClient.removeProject(workspace.projectId);
|
||||
}
|
||||
});
|
||||
@@ -10,29 +10,16 @@ import {
|
||||
openSettingsHost,
|
||||
openSettingsHostSection,
|
||||
} from "../support/helpers/settings";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
|
||||
const CUSTOM_PROVIDER = {
|
||||
id: "junie",
|
||||
name: "Junie",
|
||||
} as const;
|
||||
|
||||
const PLUGIN_PROVIDER = {
|
||||
id: "direct-example",
|
||||
name: "Direct provider example",
|
||||
pluginId: "provider-direct-example",
|
||||
} as const;
|
||||
|
||||
interface ProviderRemovalDaemonClient {
|
||||
connect(): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
getDaemonConfig(): Promise<{ config: { pluginsEnabled?: boolean } }>;
|
||||
patchDaemonConfig(config: {
|
||||
removeProviders?: string[];
|
||||
pluginsEnabled?: boolean;
|
||||
}): Promise<unknown>;
|
||||
installDirectoryPlugin(path: string): Promise<unknown>;
|
||||
removePlugin(pluginId: string): Promise<void>;
|
||||
patchDaemonConfig(config: { removeProviders?: string[] }): Promise<unknown>;
|
||||
getProvidersSnapshot(): Promise<{
|
||||
entries: Array<{ provider: string; source?: "builtin" | "custom" }>;
|
||||
}>;
|
||||
@@ -106,45 +93,4 @@ test.describe("provider removal", () => {
|
||||
await client.close().catch(() => undefined);
|
||||
}
|
||||
});
|
||||
|
||||
test("does not offer Remove for a plugin-registered provider", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
const client = await connectDaemonClient<ProviderRemovalDaemonClient>({
|
||||
clientIdPrefix: "provider-removal-e2e",
|
||||
});
|
||||
|
||||
const plugin = await copyPluginExample("provider-direct");
|
||||
try {
|
||||
const previous = await client.getDaemonConfig();
|
||||
try {
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(plugin.directory);
|
||||
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, getServerId());
|
||||
await openSettingsHostSection(page, getServerId(), "providers");
|
||||
|
||||
const pluginProviderRow = page.getByRole("button", {
|
||||
name: `${PLUGIN_PROVIDER.name} provider details`,
|
||||
exact: true,
|
||||
});
|
||||
await expect(pluginProviderRow).toBeVisible();
|
||||
await expect(page.getByTestId(`provider-actions-${PLUGIN_PROVIDER.id}`)).toHaveCount(0);
|
||||
|
||||
// The provider survives a removeProviders patch pointed at it: the
|
||||
// plugin, not config.json, owns the definition.
|
||||
await client.patchDaemonConfig({ removeProviders: [PLUGIN_PROVIDER.id] });
|
||||
await expect(pluginProviderRow).toBeVisible();
|
||||
} finally {
|
||||
await client.removePlugin(PLUGIN_PROVIDER.pluginId).catch(() => undefined);
|
||||
await client
|
||||
.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled })
|
||||
.catch(() => undefined);
|
||||
}
|
||||
} finally {
|
||||
await client.close().catch(() => undefined);
|
||||
await plugin.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { test, expect, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { openAgentRoute } from "../support/helpers/mock-agent";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
|
||||
function workspaceRowTestId(workspaceId: string): string {
|
||||
@@ -73,3 +74,75 @@ test.describe("Sidebar workspace rename", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function toggleBackgroundWorkspaces(page: Page): Promise<void> {
|
||||
await page.getByLabel("Display preferences", { exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Show background", exact: true }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
}
|
||||
|
||||
async function expectWorkspaceInSidebar(page: Page, workspaceId: string): Promise<void> {
|
||||
// Rows have no single accessible role: their nested title and actions share this container.
|
||||
await expect(page.getByTestId(workspaceRowTestId(workspaceId))).toBeVisible({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
async function expectWorkspaceHidden(page: Page, workspaceId: string): Promise<void> {
|
||||
await expect(page.getByTestId(workspaceRowTestId(workspaceId))).toHaveCount(0);
|
||||
}
|
||||
|
||||
async function reconnectApp(page: Page): Promise<void> {
|
||||
await page.reload();
|
||||
await expect(page.getByLabel("Display preferences", { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
async function expectWorkerOpen(page: Page): Promise<void> {
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeEditable({
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(page.getByText("Background reviewer", { exact: true }).first()).toBeVisible();
|
||||
await expect(page.getByText("Background review prompt", { exact: true }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
test("background workspace stays directly accessible across sidebar toggles and reconnect", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
const workspace = await seedWorkspace({
|
||||
repoPrefix: "sidebar-background-",
|
||||
title: "Background review",
|
||||
background: true,
|
||||
});
|
||||
try {
|
||||
const worker = await workspace.client.createAgent({
|
||||
provider: "mock",
|
||||
cwd: workspace.repoPath,
|
||||
workspaceId: workspace.workspaceId,
|
||||
title: "Background reviewer",
|
||||
initialPrompt: "Background review prompt",
|
||||
model: "e2e-fast-stream",
|
||||
modeId: "load-test",
|
||||
});
|
||||
await test.step("Default sidebar hides background work", async () => {
|
||||
await gotoAppShell(page);
|
||||
await expectWorkspaceHidden(page, workspace.workspaceId);
|
||||
});
|
||||
await test.step("Show background exposes the fully replicated workspace", async () => {
|
||||
await toggleBackgroundWorkspaces(page);
|
||||
await expectWorkspaceInSidebar(page, workspace.workspaceId);
|
||||
await reconnectApp(page);
|
||||
await expectWorkspaceInSidebar(page, workspace.workspaceId);
|
||||
});
|
||||
await test.step("Direct agent navigation survives hiding and reconnect", async () => {
|
||||
await toggleBackgroundWorkspaces(page);
|
||||
await expectWorkspaceHidden(page, workspace.workspaceId);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: worker.id });
|
||||
await expectWorkerOpen(page);
|
||||
await expectWorkspaceHidden(page, workspace.workspaceId);
|
||||
await reconnectApp(page);
|
||||
await expectWorkerOpen(page);
|
||||
await expectWorkspaceHidden(page, workspace.workspaceId);
|
||||
await page.screenshot({ path: testInfo.outputPath("background-direct-open.png") });
|
||||
});
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import { delayBrowserAgentCreatedStatus } from "./helpers/new-workspace";
|
||||
|
||||
export const test = base.extend<{
|
||||
startup: { release(): Promise<void>; fail(): Promise<void> };
|
||||
promptRejection: void;
|
||||
creation: Awaited<ReturnType<typeof createCreationScenario>>;
|
||||
promptRetry: ReturnType<typeof createPromptRetryScenario>;
|
||||
agentRetries: Awaited<ReturnType<typeof retryNextAgentCreation>>;
|
||||
@@ -65,6 +66,37 @@ export default function contribute(server) {
|
||||
await client.close();
|
||||
}
|
||||
},
|
||||
promptRejection: async ({ page }, provide) => {
|
||||
void page;
|
||||
const client = await connectNewWorkspaceDaemonClient();
|
||||
const plugin = await copyPluginExample("lifecycle-logger");
|
||||
const previous = await client.getDaemonConfig();
|
||||
try {
|
||||
await writeFile(
|
||||
path.join(plugin.directory, "index.server.ts"),
|
||||
`
|
||||
export default function contribute(server) {
|
||||
return server.before("agent.create", ({ request }) => ({
|
||||
...request,
|
||||
config: {
|
||||
...request.config,
|
||||
model: "e2e-fast-stream",
|
||||
featureValues: { ...request.config.featureValues, mockPromptRejections: 1 },
|
||||
},
|
||||
}));
|
||||
}
|
||||
`,
|
||||
);
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(plugin.directory);
|
||||
await provide();
|
||||
} finally {
|
||||
await client.removePlugin("lifecycle-logger");
|
||||
await client.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled });
|
||||
await plugin.cleanup();
|
||||
await client.close();
|
||||
}
|
||||
},
|
||||
creation: async ({ page }, provide) => {
|
||||
const creation = await createCreationScenario(page);
|
||||
try {
|
||||
|
||||
@@ -6,6 +6,8 @@ type WebSocketMessage = string | Buffer;
|
||||
interface SendAgentMessageRequest {
|
||||
type: "send_agent_message_request";
|
||||
requestId: string;
|
||||
text: unknown;
|
||||
attachments: unknown;
|
||||
agentId: string;
|
||||
/** Absent when the client sends into an idle agent. */
|
||||
activeTurnBehavior?: string;
|
||||
@@ -29,6 +31,8 @@ function readSendRequest(message: WebSocketMessage): SendAgentMessageRequest | n
|
||||
return {
|
||||
type: "send_agent_message_request",
|
||||
requestId: request.requestId,
|
||||
text: request.text,
|
||||
attachments: request.attachments,
|
||||
agentId: request.agentId,
|
||||
activeTurnBehavior:
|
||||
typeof request.activeTurnBehavior === "string" ? request.activeTurnBehavior : undefined,
|
||||
@@ -74,6 +78,7 @@ export async function gateNextAgentMessage(page: Page) {
|
||||
|
||||
return {
|
||||
waitForRequest,
|
||||
requestCount: () => requests.length,
|
||||
accept(index = 0) {
|
||||
const heldMessage = heldMessages[index];
|
||||
if (!serverSocket || !heldMessage) {
|
||||
|
||||
@@ -98,7 +98,6 @@ async function createCodexRestoreJourney(page: Page, client: SeedDaemonClient, i
|
||||
settings: { modeId: "full-access", thinkingOptionId: "low" },
|
||||
title: "Codex worktree restore reproduction",
|
||||
initialPrompt: `Reply with exactly ${REPLY} and nothing else. Do not use tools.`,
|
||||
background: true,
|
||||
}),
|
||||
);
|
||||
agentId = agent.agentId;
|
||||
|
||||
@@ -182,6 +182,47 @@ export async function createCreationScenario(page: Page) {
|
||||
await this.expectWorkspaceReadyBeforeAgentCompletion();
|
||||
expect((await project.client.fetchAgents()).entries).toHaveLength(0);
|
||||
},
|
||||
async expectCreatedAgentError() {
|
||||
await requests.settled();
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("assistant-message")
|
||||
.filter({ hasText: "[System Error] Requested mock prompt rejection", visible: true }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page
|
||||
.locator('[data-testid^="workspace-tab-agent_"][aria-selected="true"]')
|
||||
.filter({ visible: true }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator('[data-testid^="workspace-tab-draft_"]').filter({ visible: true }),
|
||||
).toHaveCount(0);
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." }).first()).toBeEditable();
|
||||
await expect(page.getByTestId("turn-working-indicator")).toHaveCount(0);
|
||||
},
|
||||
async expectPromptBeforeError(prompt: string) {
|
||||
const messages = page
|
||||
.getByTestId("user-message")
|
||||
.or(page.getByTestId("assistant-message"))
|
||||
.filter({ visible: true });
|
||||
await expect(messages).toHaveCount(2);
|
||||
await expect(messages.nth(0)).toContainText(prompt);
|
||||
await expect(messages.nth(1)).toContainText("[System Error]");
|
||||
await expect(messages.nth(1)).toBeInViewport();
|
||||
},
|
||||
async reloadAgent() {
|
||||
await page.reload();
|
||||
await expect(page.getByText("Updating messages", { exact: true })).toHaveCount(0);
|
||||
await this.expectCreatedAgentError();
|
||||
},
|
||||
async expectAssistantReply() {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("assistant-message")
|
||||
.filter({ visible: true, hasNotText: "[System Error]" })
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
},
|
||||
async expectStartupFailure() {
|
||||
await expect(page.getByText(/Creation startup failed for test/).first()).toBeVisible();
|
||||
},
|
||||
|
||||
@@ -66,6 +66,7 @@ export interface SeedDaemonClient {
|
||||
worktreeSlug?: string;
|
||||
};
|
||||
title?: string;
|
||||
background?: boolean;
|
||||
}): Promise<{
|
||||
workspace: SeedWorkspaceDescriptor | null;
|
||||
error: string | null;
|
||||
@@ -223,6 +224,7 @@ export interface SeededWorkspace {
|
||||
export async function seedWorkspace(options: {
|
||||
repoPrefix: string;
|
||||
title?: string;
|
||||
background?: boolean;
|
||||
port?: number;
|
||||
/** Repo fixture options; only applies to git projects (the default). */
|
||||
repo?: Parameters<typeof createTempGitRepo>[1];
|
||||
@@ -238,6 +240,7 @@ export async function seedWorkspace(options: {
|
||||
const created = await client.createWorkspace({
|
||||
source: { kind: "directory", path: project.path },
|
||||
title: options.title,
|
||||
background: options.background,
|
||||
});
|
||||
if (!created.workspace) {
|
||||
throw new Error(created.error ?? `Failed to create workspace ${project.path}`);
|
||||
|
||||
@@ -370,7 +370,7 @@ export async function findAcpCatalogProvider(page: Page, providerName: string):
|
||||
|
||||
export async function installAcpCatalogProvider(page: Page, providerName: string): Promise<void> {
|
||||
await findAcpCatalogProvider(page, providerName);
|
||||
await page.getByRole("button", { name: `Add ${providerName}`, exact: true }).click();
|
||||
await page.getByRole("button", { name: "Add", exact: true }).click();
|
||||
}
|
||||
|
||||
export async function expectProviderInstalledInSettings(
|
||||
|
||||
@@ -297,7 +297,11 @@ export function findScrollJumps(frames: ScrollFrame[]) {
|
||||
// Follow that intended row, not text now below the image.
|
||||
const recent = frames.findLast((frame) => frame.at <= previous.at - 100);
|
||||
const wheelBudget = current.wheelTotal - (recent?.wheelTotal ?? 0);
|
||||
const frameScroll = Math.max(0, previous.scrollTop - current.scrollTop);
|
||||
const availableScroll = Math.min(frameScroll, wheelBudget, previous.scrollTop);
|
||||
const readingLine = 8 - availableScroll;
|
||||
const currentRows = new Map(current.rows.map((row) => [row.id, row]));
|
||||
const intendedRow = previous.rows.find((row) => row.top + row.height > readingLine);
|
||||
const anchor = previous.anchor;
|
||||
const before = currentRows.has(anchor)
|
||||
? previous.rows.find((row) => row.id === anchor)!
|
||||
@@ -312,33 +316,25 @@ export function findScrollJumps(frames: ScrollFrame[]) {
|
||||
// A busy main thread can deliver wheel movement hundreds of milliseconds
|
||||
// after its event. Only assert idle stability after the driver stops input.
|
||||
const idle = current.inputFinishedAt !== null && previous.at - current.inputFinishedAt > 250;
|
||||
// scrollTop also includes virtualizer estimate corrections. Locate the row
|
||||
// entered by wheel input from its viewport movement instead. Its old height
|
||||
// identifies the reader before a simultaneous image resize takes effect.
|
||||
const intendedRow = previous.rows.find((row) => {
|
||||
const next = currentRows.get(row.id);
|
||||
if (!next || idle || wheelBudget <= 0) return false;
|
||||
const travel = next.top - row.top;
|
||||
return (
|
||||
travel >= -8 &&
|
||||
travel <= Math.min(wheelBudget, previous.scrollTop) + 32 &&
|
||||
(next.top <= 8 || current.scrollTop === 0) &&
|
||||
next.top + row.height > 8
|
||||
);
|
||||
});
|
||||
const enteredRowResize = intendedRow
|
||||
// Wheel events can precede their scroll update, or include input already
|
||||
// applied in earlier frames. Locate the reader with this frame's scroll,
|
||||
// bounded by recent input. Growth below it can move the old anchor without
|
||||
// moving the reading line.
|
||||
const readerFollowsInput =
|
||||
intendedRow &&
|
||||
currentRows.has(intendedRow.id) &&
|
||||
Math.abs(currentRows.get(intendedRow.id)!.top - intendedRow.top - availableScroll) <= 32;
|
||||
const enteredRowGrowth = readerFollowsInput
|
||||
? previous.rows.reduce((growth, row) => {
|
||||
if (row.top < intendedRow.top || row.top >= before.top) return growth;
|
||||
const height = currentRows.get(row.id)?.height ?? row.height;
|
||||
return growth + height - row.height;
|
||||
return growth + Math.max(0, height - row.height);
|
||||
}, 0)
|
||||
: 0;
|
||||
const readingMovement = movement - enteredRowResize;
|
||||
const excessForward = readingMovement > wheelBudget + 32;
|
||||
const excessForward = movement > wheelBudget + enteredRowGrowth + 32;
|
||||
// Upward wheel input moves the same text DOWN the viewport. A negative move
|
||||
// is a reversal, independent of legitimate scrollTop compensation on prepend.
|
||||
if (readingMovement >= -8 && (!idle || Math.abs(readingMovement) <= 8) && !excessForward)
|
||||
return [];
|
||||
if (movement >= -8 && (!idle || Math.abs(movement) <= 8) && !excessForward) return [];
|
||||
return [
|
||||
{
|
||||
frame: index,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@getpaseo/app",
|
||||
"version": "0.11.4",
|
||||
"version": "0.11.2",
|
||||
"private": true,
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
const { withAndroidManifest } = require("expo/config-plugins");
|
||||
|
||||
// Requesting CAMERA implies these features are required, which hides the app
|
||||
// on Google Play for devices without a camera. Pairing works without QR scanning.
|
||||
const OPTIONAL_CAMERA_FEATURES = ["android.hardware.camera", "android.hardware.camera.autofocus"];
|
||||
|
||||
function withAndroidOptionalCamera(config) {
|
||||
return withAndroidManifest(config, (modConfig) => {
|
||||
const manifest = modConfig.modResults.manifest;
|
||||
const features = manifest["uses-feature"] ?? [];
|
||||
for (const name of OPTIONAL_CAMERA_FEATURES) {
|
||||
const existing = features.find((feature) => feature.$["android:name"] === name);
|
||||
if (existing) {
|
||||
existing.$["android:required"] = "false";
|
||||
} else {
|
||||
features.push({ $: { "android:name": name, "android:required": "false" } });
|
||||
}
|
||||
}
|
||||
manifest["uses-feature"] = features;
|
||||
return modConfig;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = withAndroidOptionalCamera;
|
||||
@@ -792,6 +792,7 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
detail={data.detail}
|
||||
cwd={context.cwd}
|
||||
metadata={data.metadata}
|
||||
agentMessage={data.agentMessage}
|
||||
isLastInSequence={isLastInSequence}
|
||||
onOpenFilePath={handleToolCallOpenFile}
|
||||
maxDetailHeight={maxDetailHeight}
|
||||
|
||||
@@ -48,8 +48,6 @@ export const ACP_PROVIDER_ICON_SVGS = {
|
||||
goose:
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">\n <path fill="currentColor" d="M20.9093 19.3861L19.5185 18.2413C18.7624 17.619 18.1189 16.8713 17.6157 16.0313C16.9205 14.8706 15.9599 13.8912 14.8133 13.1735L14.2533 12.8475C14.0614 12.7141 13.9276 12.5062 13.9086 12.2716C13.8963 12.1204 13.9326 11.9852 14.0171 11.8662C14.3087 11.4553 15.896 9.74698 16.1722 9.51845C16.528 9.22442 16.9243 8.97987 17.2921 8.69986C17.3443 8.66 17.3968 8.62035 17.4485 8.57989C17.4503 8.57808 17.4529 8.57668 17.4545 8.57508C17.5725 8.48195 17.6838 8.383 17.7724 8.26563C18.2036 7.76631 18.195 7.3443 18.195 7.3443C18.195 7.3443 18.1954 7.3439 18.1956 7.3437C18.1497 7.23133 17.9847 6.88163 17.6492 6.71759C17.9458 6.71178 18.2805 6.82294 18.4323 6.97156C18.6148 6.68534 18.7328 6.49967 18.9162 6.18762C18.9599 6.11352 18.9831 5.97652 18.8996 5.89981C18.8996 5.89981 18.8992 5.89981 18.8988 5.89981C18.8988 5.89981 18.8988 5.8994 18.8988 5.899C18.8972 5.8974 18.8952 5.8962 18.8936 5.8946C18.892 5.893 18.891 5.89119 18.8892 5.88939C18.8892 5.88939 18.8888 5.88939 18.8884 5.88939C18.8884 5.88939 18.8884 5.88899 18.8884 5.88859C18.885 5.88518 18.8812 5.88258 18.8776 5.87938C18.8754 5.87717 18.8736 5.87457 18.8716 5.87217C18.8692 5.87016 18.8665 5.86836 18.8643 5.86616C18.8609 5.86275 18.8587 5.85855 18.8551 5.85534C18.8551 5.85534 18.8545 5.85514 18.8543 5.85534C18.8543 5.85534 18.8543 5.85494 18.8543 5.85454C18.8527 5.85294 18.8507 5.85174 18.8491 5.85013C18.8475 5.84853 18.8463 5.84653 18.8447 5.84493C18.8447 5.84493 18.8441 5.84473 18.8439 5.84493C18.8439 5.84493 18.8439 5.84453 18.8439 5.84413C18.7672 5.7606 18.6302 5.78384 18.5561 5.8275C18.1503 6.06625 17.7555 6.32322 17.3996 6.54855C17.3996 6.54855 16.9778 6.53973 16.4783 6.97116C16.3607 7.05989 16.2618 7.17125 16.1688 7.28902C16.167 7.29082 16.1654 7.29322 16.164 7.29503C16.1234 7.3465 16.0837 7.39898 16.0441 7.45145C15.7639 7.81939 15.5195 8.21556 15.2255 8.57128C14.9971 8.84768 13.2887 10.4348 12.8777 10.7264C12.7587 10.8109 12.6237 10.8474 12.4723 10.835C12.2379 10.8161 12.0298 10.6821 11.8965 10.4903L11.5704 9.93024C10.8527 8.78318 9.87332 7.82299 8.71264 7.12778C7.87262 6.62466 7.12514 5.98092 6.50264 5.22503L5.35778 3.83421C5.3013 3.76571 5.19314 3.77693 5.15268 3.85585C5.02249 4.10941 4.77393 4.64479 4.58346 5.36483C4.57885 5.38186 4.58286 5.39988 4.59407 5.4135C4.83082 5.69952 5.37901 6.32983 6.03196 6.863C6.07742 6.90005 6.04017 6.97336 5.98369 6.95774C5.42047 6.80432 4.87288 6.55796 4.46308 6.34805C4.42964 6.33103 4.38918 6.35226 4.38437 6.38951C4.32068 6.89985 4.30425 7.46027 4.37155 8.05112C4.37355 8.07035 4.38577 8.08697 4.4036 8.09479C4.87088 8.29808 5.61816 8.59311 6.40269 8.78078C6.45958 8.7944 6.45777 8.87632 6.40029 8.88733C5.78941 9.0023 5.14968 9.02794 4.62973 9.02113C4.59327 9.02073 4.56643 9.05518 4.57625 9.09023C4.6806 9.45896 4.822 9.8339 5.00847 10.2115C5.08559 10.3811 5.16951 10.5475 5.25944 10.7104C5.27486 10.7382 5.3047 10.7548 5.33655 10.7534C5.76577 10.7324 6.28452 10.6871 6.80608 10.595C6.89501 10.5794 6.94268 10.6964 6.86757 10.7466C6.51345 10.9834 6.13571 11.1873 5.7844 11.3551C5.73733 11.3777 5.72211 11.4378 5.75315 11.4797C5.96186 11.7625 6.19139 12.0301 6.44075 12.2794C6.44075 12.2794 7.66853 13.5441 7.70198 13.6432C8.41841 12.9096 9.59612 12.0964 10.8966 11.3864C9.15488 12.8036 8.18387 13.8499 7.69517 14.4444L7.35447 14.9225C7.17742 15.1708 7.02379 15.4346 6.89541 15.7112C6.46579 16.6356 5.75756 18.5051 5.75756 18.5051C5.70328 18.6515 5.74754 18.7959 5.84168 18.89C5.84388 18.8922 5.84609 18.8944 5.84849 18.8964C5.85069 18.8986 5.8527 18.901 5.8549 18.9032C5.94924 18.9976 6.09345 19.0416 6.23986 18.9874C6.23986 18.9874 8.10897 18.2791 9.03371 17.8495C9.31031 17.7211 9.57429 17.5673 9.82245 17.3905L10.349 17.0153C10.6278 16.8166 11.0096 16.8483 11.2517 17.0904L12.4655 18.3042C12.7148 18.5535 12.9824 18.7831 13.2652 18.9918C13.3073 19.0226 13.3672 19.0076 13.3898 18.9605C13.5579 18.6094 13.7618 18.2313 13.9983 17.8774C14.0486 17.8022 14.1657 17.8501 14.1499 17.9388C14.0576 18.4606 14.0127 18.9794 13.9915 19.4084C13.9899 19.44 14.0067 19.4701 14.0345 19.4855C14.1972 19.5756 14.3636 19.6595 14.5335 19.7364C14.911 19.9229 15.2862 20.0645 15.6547 20.1687C15.6897 20.1785 15.7242 20.1516 15.7238 20.1152C15.7168 19.595 15.7424 18.9553 15.8576 18.3446C15.8684 18.2869 15.9503 18.2851 15.9641 18.3422C16.1516 19.127 16.4466 19.8742 16.6501 20.3413C16.6579 20.3591 16.6744 20.3712 16.6938 20.3734C17.2847 20.4407 17.8451 20.4242 18.3554 20.3606C18.3929 20.3559 18.4141 20.3155 18.3969 20.2818C18.187 19.872 17.9406 19.3241 17.7872 18.7612C17.7718 18.7046 17.8449 18.6675 17.8819 18.713C18.4151 19.3659 19.0454 19.9141 19.3314 20.1508C19.345 20.1621 19.3633 20.1659 19.3801 20.1615C20.1003 19.9712 20.6357 19.7226 20.8891 19.5922C20.968 19.5518 20.9792 19.4436 20.9107 19.3871L20.9093 19.3861Z"/>\n</svg>\n',
|
||||
grok: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 1024 1024" fill="none">\n <path fill="currentColor" d="M395.479 633.828L735.91 381.105C752.599 368.715 776.454 373.548 784.406 392.792C826.26 494.285 807.561 616.253 724.288 699.996C641.016 783.739 525.151 802.104 419.247 760.277L303.556 814.143C469.49 928.202 670.987 899.995 796.901 773.282C896.776 672.843 927.708 535.937 898.785 412.476L899.047 412.739C857.105 231.37 909.358 158.874 1016.4 10.6326C1018.93 7.11771 1021.47 3.60279 1024 0L883.144 141.651V141.212L395.392 633.916"/>\n <path fill="currentColor" d="M325.226 695.251C206.128 580.84 226.662 403.776 328.285 301.668C403.431 226.097 526.549 195.254 634.026 240.596L749.454 186.994C728.657 171.88 702.007 155.623 671.424 144.2C533.19 86.9942 367.693 115.465 255.323 228.382C147.234 337.081 113.244 504.215 171.613 646.833C215.216 753.423 143.739 828.818 71.7385 904.916C46.2237 931.893 20.6216 958.87 0 987.429L325.139 695.339"/>\n</svg>\n',
|
||||
hoplite:
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="1.394 1.679 8.494 7.828" fill="currentColor"><path d="M8.237 7.813C8.276 7.789 8.327 7.796 8.358 7.83L9.741 9.346C9.797 9.407 9.754 9.506 9.671 9.507H8.977C8.924 9.507 8.881 9.463 8.881 9.41V9.125C8.881 9.089 8.861 9.057 8.83 9.04L7.589 8.379C7.524 8.344 7.521 8.251 7.584 8.212L8.237 7.813ZM3.944 1.679C4.502 1.679 5.052 1.82 5.54 2.09L5.962 2.323C6.024 2.358 6.029 2.446 5.97 2.486L5.091 3.09C5.065 3.108 5.05 3.137 5.05 3.169V3.495C5.05 3.529 5.032 3.561 5.003 3.578L4.68 3.769C4.594 3.82 4.498 3.722 4.549 3.637L4.592 3.566C4.63 3.502 4.584 3.421 4.51 3.421H4.028C3.925 3.421 3.894 3.562 3.989 3.604L4.377 3.775C4.448 3.806 4.455 3.904 4.389 3.944L3.77 4.323C3.755 4.332 3.737 4.337 3.72 4.337H3.361C3.309 4.337 3.268 4.379 3.268 4.431C3.268 4.484 3.309 4.526 3.361 4.526H3.779C3.797 4.526 3.814 4.521 3.829 4.513L7.599 2.272C8.135 1.954 8.815 2.008 9.294 2.407C9.307 2.418 9.314 2.434 9.314 2.451V2.729C9.315 2.812 9.413 2.856 9.475 2.8L9.728 2.57C9.789 2.514 9.888 2.558 9.888 2.641V5.812C9.888 5.865 9.845 5.908 9.792 5.908H9.359C9.331 5.908 9.303 5.895 9.285 5.873L8.374 4.773C8.337 4.728 8.268 4.728 8.229 4.771L7.468 5.625C7.429 5.669 7.438 5.737 7.487 5.769L9.038 6.776C9.098 6.815 9.096 6.903 9.035 6.939L6.618 8.363C6.556 8.4 6.478 8.358 6.474 8.286L6.439 7.633C6.437 7.578 6.48 7.532 6.535 7.532H6.925C6.948 7.532 6.971 7.523 6.988 7.508L7.211 7.31C7.276 7.252 7.236 7.144 7.148 7.142L5.991 7.118H1.49C1.437 7.118 1.394 7.075 1.394 7.022V3.308C1.394 3.255 1.437 3.212 1.49 3.212H2.544C2.597 3.212 2.64 3.169 2.64 3.116V2.969C2.64 2.916 2.597 2.873 2.544 2.873H1.461C1.366 2.873 1.329 2.75 1.408 2.697L2.134 2.221C2.672 1.867 3.301 1.679 3.944 1.679Z"/></svg>\n',
|
||||
junie:
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 40 40" fill="none">\n <path d="M25 15H35V16.75C35 29 30.5001 35 16.5001 35H15V25H16.5001C22.6251 25 25 22.875 25 16.75V15Z" fill="currentColor"/>\n <rect x="5" y="15" width="10" height="10" fill="currentColor"/>\n <rect x="15" y="5" width="10" height="10" fill="currentColor"/>\n</svg>\n',
|
||||
kilo: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 40 40">\n <path fill="currentColor" d="M27.9998324,34.6666921h6.6666279v5.3333023h-8.3809037l-3.6190266-3.6190266v-8.3809037h5.3333023v6.6666279ZM39.9997627,26.2857884l-3.6190266-3.6190266h-8.3809037v5.3333023h6.6666279v6.6666279h5.3333023v-8.3809037ZM17.3332326,22.6667578h-5.3333023v5.3333023h5.3333023v-5.3333023ZM0,36.3809638l3.6190266,3.6190266h13.714206v-5.3333023H5.3333023v-11.9999302H0v13.714206ZM33.9600959,11.9999247V3.619021L30.3410693-.0000056h-7.6745392v5.3333023h5.9602634v6.6666279h-5.9602634v5.3333023h17.3332326v-5.3333023h-6.0396668ZM5.3333023,0H0v17.3332326h5.3333023v-5.9999651h6.6666279v5.9999651h5.3333023v-5.9999651l-5.3333023-5.3333023h-6.6666279V0ZM17.3332326,0h-5.3333023v5.9999651h5.3333023V0Z"/>\n</svg>\n',
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="1.394 1.679 8.494 7.828" fill="currentColor"><path d="M8.237 7.813C8.276 7.789 8.327 7.796 8.358 7.83L9.741 9.346C9.797 9.407 9.754 9.506 9.671 9.507H8.977C8.924 9.507 8.881 9.463 8.881 9.41V9.125C8.881 9.089 8.861 9.057 8.83 9.04L7.589 8.379C7.524 8.344 7.521 8.251 7.584 8.212L8.237 7.813ZM3.944 1.679C4.502 1.679 5.052 1.82 5.54 2.09L5.962 2.323C6.024 2.358 6.029 2.446 5.97 2.486L5.091 3.09C5.065 3.108 5.05 3.137 5.05 3.169V3.495C5.05 3.529 5.032 3.561 5.003 3.578L4.68 3.769C4.594 3.82 4.498 3.722 4.549 3.637L4.592 3.566C4.63 3.502 4.584 3.421 4.51 3.421H4.028C3.925 3.421 3.894 3.562 3.989 3.604L4.377 3.775C4.448 3.806 4.455 3.904 4.389 3.944L3.77 4.323C3.755 4.332 3.737 4.337 3.72 4.337H3.361C3.309 4.337 3.268 4.379 3.268 4.431C3.268 4.484 3.309 4.526 3.361 4.526H3.779C3.797 4.526 3.814 4.521 3.829 4.513L7.599 2.272C8.135 1.954 8.815 2.008 9.294 2.407C9.307 2.418 9.314 2.434 9.314 2.451V2.729C9.315 2.812 9.413 2.856 9.475 2.8L9.728 2.57C9.789 2.514 9.888 2.558 9.888 2.641V5.812C9.888 5.865 9.845 5.908 9.792 5.908H9.359C9.331 5.908 9.303 5.895 9.285 5.873L8.374 4.773C8.337 4.728 8.268 4.728 8.229 4.771L7.468 5.625C7.429 5.669 7.438 5.737 7.487 5.769L9.038 6.776C9.098 6.815 9.096 6.903 9.035 6.939L6.618 8.363C6.556 8.4 6.478 8.358 6.474 8.286L6.439 7.633C6.437 7.578 6.48 7.532 6.535 7.532H6.925C6.948 7.532 6.971 7.523 6.988 7.508L7.211 7.31C7.276 7.252 7.236 7.144 7.148 7.142L5.991 7.118H1.49C1.437 7.118 1.394 7.075 1.394 7.022V3.308C1.394 3.255 1.437 3.212 1.49 3.212H2.544C2.597 3.212 2.64 3.169 2.64 3.116V2.969C2.64 2.916 2.597 2.873 2.544 2.873H1.461C1.366 2.873 1.329 2.75 1.408 2.697L2.134 2.221C2.672 1.867 3.301 1.679 3.944 1.679Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,3 +1,4 @@
|
||||
import type { AgentMessage } from "@getpaseo/protocol/agent-message";
|
||||
import { ASSISTANT_IMAGE_DEFAULT_ASPECT_RATIO } from "@/utils/assistant-image-metadata";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { TaskListRow } from "@/components/task-list-row";
|
||||
@@ -3022,6 +3023,7 @@ function areExpandableBadgePropsEqual(previous: ExpandableBadgeProps, next: Expa
|
||||
}
|
||||
|
||||
interface ToolCallProps {
|
||||
agentMessage?: AgentMessage;
|
||||
toolName: string;
|
||||
args?: unknown;
|
||||
result?: unknown;
|
||||
@@ -3041,6 +3043,7 @@ interface ToolCallProps {
|
||||
}
|
||||
|
||||
export const ToolCall = memo(function ToolCall({
|
||||
agentMessage,
|
||||
toolName,
|
||||
args,
|
||||
result,
|
||||
@@ -3081,6 +3084,7 @@ export const ToolCall = memo(function ToolCall({
|
||||
const presentation = useMemo(
|
||||
() =>
|
||||
buildToolCallPresentation({
|
||||
agentMessage,
|
||||
toolName,
|
||||
status,
|
||||
error: error ?? null,
|
||||
@@ -3089,7 +3093,7 @@ export const ToolCall = memo(function ToolCall({
|
||||
cwd,
|
||||
resolveIcon: resolveToolCallIcon,
|
||||
}),
|
||||
[toolName, status, error, effectiveDetail, metadata, cwd],
|
||||
[toolName, status, error, effectiveDetail, metadata, cwd, agentMessage],
|
||||
);
|
||||
const handleOpenFile = useMemo(() => {
|
||||
const openFilePath = presentation.openFilePath;
|
||||
@@ -3105,7 +3109,7 @@ export const ToolCall = memo(function ToolCall({
|
||||
toolName,
|
||||
displayName: presentation.displayName,
|
||||
summary: presentation.summary,
|
||||
detail: effectiveDetail,
|
||||
detail: presentation.detail,
|
||||
errorText: presentation.errorText,
|
||||
icon: presentation.icon,
|
||||
showLoadingSkeleton: presentation.isLoadingDetails,
|
||||
@@ -3117,12 +3121,12 @@ export const ToolCall = memo(function ToolCall({
|
||||
shouldRenderInline,
|
||||
openToolCall,
|
||||
toolName,
|
||||
presentation.detail,
|
||||
presentation.displayName,
|
||||
presentation.summary,
|
||||
presentation.errorText,
|
||||
presentation.icon,
|
||||
presentation.isLoadingDetails,
|
||||
effectiveDetail,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -3158,7 +3162,7 @@ export const ToolCall = memo(function ToolCall({
|
||||
return (
|
||||
<ToolCallDetailsContent
|
||||
toolName={toolName}
|
||||
detail={effectiveDetail}
|
||||
detail={presentation.detail}
|
||||
errorText={presentation.errorText}
|
||||
maxHeight={maxDetailHeight}
|
||||
showLoadingSkeleton={presentation.isLoadingDetails}
|
||||
@@ -3167,7 +3171,7 @@ export const ToolCall = memo(function ToolCall({
|
||||
}, [
|
||||
shouldRenderInline,
|
||||
toolName,
|
||||
effectiveDetail,
|
||||
presentation.detail,
|
||||
presentation.errorText,
|
||||
presentation.isLoadingDetails,
|
||||
maxDetailHeight,
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Text, View, type LayoutChangeEvent } from "react-native";
|
||||
import { Pressable, Text, View } from "react-native";
|
||||
import { SvgXml } from "react-native-svg";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { PackagePlus } from "lucide-react-native";
|
||||
import { ExternalLink, PackagePlus, Search } from "lucide-react-native";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ExternalLink } from "@/components/ui/external-link";
|
||||
import { SearchField } from "@/components/ui/search-field";
|
||||
import { StatusBadge } from "@/components/ui/status-badge";
|
||||
import { rankProviderCatalog } from "@/components/provider-catalog-search";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import {
|
||||
useAcpProviderCatalog,
|
||||
type AcpProviderCatalogItem,
|
||||
} from "@/hooks/use-acp-provider-catalog";
|
||||
import { useProvidersSnapshot } from "@/hooks/use-providers-snapshot";
|
||||
import { SPACING, type Theme } from "@/styles/theme";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { openExternalUrl } from "@/utils/open-external-url";
|
||||
import { EditingTextInput as TextInput } from "@/components/ui/text-input";
|
||||
|
||||
interface ProviderCatalogListProps {
|
||||
serverId: string;
|
||||
@@ -23,43 +21,52 @@ interface ProviderCatalogListProps {
|
||||
onInstall: (entry: AcpProviderCatalogItem) => Promise<void> | void;
|
||||
}
|
||||
|
||||
const SEARCH_ICON_SIZE = 16;
|
||||
const PROVIDER_FALLBACK_ICON_SIZE = 20;
|
||||
const PROVIDER_REMOTE_ICON_SIZE = 24;
|
||||
const TILE_GAP = SPACING[3];
|
||||
/** Narrowest tile that keeps the icon, type badge, install link, and Add on one row. */
|
||||
const MIN_TILE_WIDTH = 300;
|
||||
const MAX_COLUMNS = 4;
|
||||
|
||||
const ThemedPackagePlus = withUnistyles(PackagePlus);
|
||||
const ThemedSvgXml = withUnistyles(SvgXml);
|
||||
const ThemedSearch = withUnistyles(Search);
|
||||
const ThemedExternalLink = withUnistyles(ExternalLink);
|
||||
const ThemedTextInput = withUnistyles(TextInput, (theme) => ({
|
||||
placeholderTextColor: theme.colors.foregroundMuted,
|
||||
}));
|
||||
|
||||
const foregroundColorMapping = (theme: Theme) => ({ color: theme.colors.foreground });
|
||||
const foregroundMutedColorMapping = (theme: Theme) => ({
|
||||
color: theme.colors.foregroundMuted,
|
||||
});
|
||||
|
||||
function columnCountForWidth(width: number): number {
|
||||
const fits = Math.floor((width + TILE_GAP) / (MIN_TILE_WIDTH + TILE_GAP));
|
||||
return Math.min(MAX_COLUMNS, Math.max(1, fits));
|
||||
function matchesSearch(entry: AcpProviderCatalogItem, query: string): boolean {
|
||||
const normalized = query.trim().toLowerCase();
|
||||
if (!normalized) return true;
|
||||
return [entry.title, entry.id, entry.description].some((value) =>
|
||||
value.toLowerCase().includes(normalized),
|
||||
);
|
||||
}
|
||||
|
||||
interface CatalogTileProps {
|
||||
interface CatalogRowProps {
|
||||
entry: AcpProviderCatalogItem;
|
||||
/** `undefined` until the grid is measured, or in a single column; the tile fills the row. */
|
||||
width: number | undefined;
|
||||
installing: boolean;
|
||||
onInstall: (entry: AcpProviderCatalogItem) => void;
|
||||
}
|
||||
|
||||
function CatalogTile({ entry, width, installing, onInstall }: CatalogTileProps) {
|
||||
function CatalogRow({ entry, installing, onInstall }: CatalogRowProps) {
|
||||
const { t } = useTranslation();
|
||||
const actionLabel = installing
|
||||
? t("providerCatalog.actions.adding")
|
||||
: t("providerCatalog.actions.add");
|
||||
const handleInstall = useCallback(() => {
|
||||
onInstall(entry);
|
||||
}, [entry, onInstall]);
|
||||
const tileStyle = useMemo(
|
||||
() => [settingsStyles.card, styles.tile, width === undefined ? styles.tileFull : { width }],
|
||||
[width],
|
||||
);
|
||||
|
||||
const handleOpenInstallLink = useCallback(() => {
|
||||
void openExternalUrl(entry.installLink);
|
||||
}, [entry.installLink]);
|
||||
|
||||
return (
|
||||
<View style={tileStyle} testID={`provider-catalog-tile-${entry.id}`}>
|
||||
<View style={styles.row}>
|
||||
<View style={styles.iconFrame}>
|
||||
{entry.iconSvg ? (
|
||||
<ThemedSvgXml
|
||||
@@ -72,33 +79,42 @@ function CatalogTile({ entry, width, installing, onInstall }: CatalogTileProps)
|
||||
<ThemedPackagePlus size={PROVIDER_FALLBACK_ICON_SIZE} uniProps={foregroundColorMapping} />
|
||||
)}
|
||||
</View>
|
||||
<View style={styles.details}>
|
||||
<Text style={styles.name} numberOfLines={1}>
|
||||
{entry.title}
|
||||
</Text>
|
||||
<View style={styles.metaRow}>
|
||||
{/* The catalog is the ACP registry, so every entry it offers is an ACP provider. */}
|
||||
<StatusBadge label={t("providerCatalog.types.acp")} size="xs" />
|
||||
<ExternalLink
|
||||
href={entry.installLink}
|
||||
label={t("providerCatalog.actions.installInstructions")}
|
||||
accessibilityLabel={t("providerCatalog.actions.installInstructionsFor", {
|
||||
provider: entry.title,
|
||||
})}
|
||||
/>
|
||||
<View style={styles.textColumn}>
|
||||
<View style={styles.titleRow}>
|
||||
<Text style={styles.name} numberOfLines={1}>
|
||||
{entry.title}
|
||||
</Text>
|
||||
<Text style={styles.version} numberOfLines={1}>
|
||||
{entry.version}
|
||||
</Text>
|
||||
</View>
|
||||
<Text style={styles.description} numberOfLines={1}>
|
||||
{entry.description || entry.id}
|
||||
</Text>
|
||||
<Pressable
|
||||
accessibilityRole="link"
|
||||
accessibilityLabel={t("providerCatalog.actions.installInstructionsFor", {
|
||||
provider: entry.title,
|
||||
})}
|
||||
onPress={handleOpenInstallLink}
|
||||
style={styles.installLink}
|
||||
>
|
||||
<Text style={styles.installLinkText} numberOfLines={1}>
|
||||
{t("providerCatalog.actions.installInstructions")}
|
||||
</Text>
|
||||
<ThemedExternalLink size={12} uniProps={foregroundMutedColorMapping} />
|
||||
</Pressable>
|
||||
</View>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
variant="default"
|
||||
disabled={installing}
|
||||
loading={installing}
|
||||
onPress={handleInstall}
|
||||
accessibilityLabel={t("providerCatalog.actions.addProvider", { provider: entry.title })}
|
||||
style={styles.addButton}
|
||||
style={styles.actionButton}
|
||||
testID={`install-provider-${entry.id}`}
|
||||
>
|
||||
{installing ? t("providerCatalog.actions.adding") : t("providerCatalog.actions.add")}
|
||||
{actionLabel}
|
||||
</Button>
|
||||
</View>
|
||||
);
|
||||
@@ -113,7 +129,6 @@ export function ProviderCatalogList({
|
||||
const { entries: catalogEntries } = useAcpProviderCatalog();
|
||||
const { entries: providerEntries } = useProvidersSnapshot(serverId);
|
||||
const [search, setSearch] = useState("");
|
||||
const [gridWidth, setGridWidth] = useState<number | null>(null);
|
||||
|
||||
const installedIds = useMemo(
|
||||
() => new Set(providerEntries?.map((entry) => entry.provider) ?? []),
|
||||
@@ -122,48 +137,41 @@ export function ProviderCatalogList({
|
||||
|
||||
const availableEntries = useMemo(
|
||||
() =>
|
||||
rankProviderCatalog(
|
||||
catalogEntries.filter((entry) => !installedIds.has(entry.id)),
|
||||
search,
|
||||
),
|
||||
catalogEntries
|
||||
.filter((entry) => !installedIds.has(entry.id))
|
||||
.filter((entry) => matchesSearch(entry, search)),
|
||||
[catalogEntries, installedIds, search],
|
||||
);
|
||||
|
||||
const handleGridLayout = useCallback((event: LayoutChangeEvent) => {
|
||||
setGridWidth(event.nativeEvent.layout.width);
|
||||
}, []);
|
||||
|
||||
const tileWidth = useMemo(() => {
|
||||
if (gridWidth === null) return undefined;
|
||||
const columns = columnCountForWidth(gridWidth);
|
||||
if (columns === 1) return undefined;
|
||||
return Math.floor((gridWidth - TILE_GAP * (columns - 1)) / columns);
|
||||
}, [gridWidth]);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.searchRail}>
|
||||
<SearchField
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
placeholder={t("providerCatalog.search")}
|
||||
clearAccessibilityLabel={t("providerCatalog.clearSearch")}
|
||||
<View style={styles.searchField}>
|
||||
<View style={styles.searchIcon}>
|
||||
<ThemedSearch size={SEARCH_ICON_SIZE} uniProps={foregroundMutedColorMapping} />
|
||||
</View>
|
||||
<ThemedTextInput
|
||||
testID="provider-catalog-search"
|
||||
clearTestID="provider-catalog-search-clear"
|
||||
initialValue={search}
|
||||
onChangeText={setSearch}
|
||||
accessibilityLabel={t("providerCatalog.search")}
|
||||
placeholder={t("providerCatalog.search")}
|
||||
// @ts-expect-error - outlineStyle is web-only
|
||||
style={[styles.searchInput, isWeb && { outlineStyle: "none" }]}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{availableEntries.length === 0 ? (
|
||||
<View style={[settingsStyles.card, styles.stateBox]}>
|
||||
<View style={styles.stateBox}>
|
||||
<Text style={styles.stateText}>{t("providerCatalog.noProviders")}</Text>
|
||||
</View>
|
||||
) : (
|
||||
<View style={styles.grid} onLayout={handleGridLayout}>
|
||||
<View style={styles.list}>
|
||||
{availableEntries.map((entry) => (
|
||||
<CatalogTile
|
||||
<CatalogRow
|
||||
key={entry.id}
|
||||
entry={entry}
|
||||
width={tileWidth}
|
||||
installing={installingProviderId === entry.id}
|
||||
onInstall={onInstall}
|
||||
/>
|
||||
@@ -175,56 +183,101 @@ export function ProviderCatalogList({
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
searchRail: {
|
||||
searchField: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
backgroundColor: theme.colors.surface2,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.border,
|
||||
paddingHorizontal: theme.spacing[3],
|
||||
marginBottom: theme.spacing[3],
|
||||
},
|
||||
grid: {
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
gap: TILE_GAP,
|
||||
searchIcon: {
|
||||
width: 18,
|
||||
alignItems: "center",
|
||||
},
|
||||
tile: {
|
||||
searchInput: {
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
paddingVertical: theme.spacing[3],
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
},
|
||||
list: {
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.border,
|
||||
overflow: "hidden",
|
||||
},
|
||||
row: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[3],
|
||||
padding: theme.spacing[3],
|
||||
},
|
||||
tileFull: {
|
||||
width: "100%",
|
||||
},
|
||||
details: {
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
gap: theme.spacing[1],
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: theme.colors.border,
|
||||
},
|
||||
iconFrame: {
|
||||
flexShrink: 0,
|
||||
width: 36,
|
||||
height: 36,
|
||||
borderRadius: theme.borderRadius.md,
|
||||
backgroundColor: theme.colors.surface2,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
addButton: {
|
||||
flexShrink: 0,
|
||||
},
|
||||
textColumn: {
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
gap: theme.spacing[1],
|
||||
},
|
||||
titleRow: {
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
minWidth: 0,
|
||||
},
|
||||
name: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.base,
|
||||
fontWeight: theme.fontWeight.normal,
|
||||
fontWeight: theme.fontWeight.medium,
|
||||
flexShrink: 1,
|
||||
},
|
||||
metaRow: {
|
||||
version: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.sm,
|
||||
flexShrink: 0,
|
||||
},
|
||||
description: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.sm,
|
||||
},
|
||||
installLink: {
|
||||
alignSelf: "flex-start",
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing[2],
|
||||
gap: theme.spacing[1],
|
||||
maxWidth: "100%",
|
||||
},
|
||||
installLinkText: {
|
||||
color: theme.colors.foregroundMuted,
|
||||
fontSize: theme.fontSize.sm,
|
||||
},
|
||||
actionButton: {
|
||||
width: 92,
|
||||
flexShrink: 0,
|
||||
},
|
||||
stateBox: {
|
||||
minHeight: 96,
|
||||
borderRadius: theme.borderRadius.lg,
|
||||
borderWidth: 1,
|
||||
borderColor: theme.colors.border,
|
||||
backgroundColor: theme.colors.surface1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: theme.spacing[3],
|
||||
padding: theme.spacing[4],
|
||||
},
|
||||
stateText: {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { rankProviderCatalog } from "./provider-catalog-search";
|
||||
|
||||
const entries = [
|
||||
{ id: "kiro-cli", title: "Kiro CLI" },
|
||||
{ id: "goose", title: "goose" },
|
||||
{ id: "kimi", title: "Kimi Code CLI" },
|
||||
{ id: "gemini", title: "Gemini CLI" },
|
||||
{ id: "qwen-code", title: "Qwen Code" },
|
||||
{ id: "codex-acp", title: "Codex" },
|
||||
];
|
||||
|
||||
function titles(list: { title: string }[]): string[] {
|
||||
return list.map((entry) => entry.title);
|
||||
}
|
||||
|
||||
describe("rankProviderCatalog", () => {
|
||||
it("lists every provider alphabetically by name without a query", () => {
|
||||
expect(titles(rankProviderCatalog(entries, " "))).toEqual([
|
||||
"Codex",
|
||||
"Gemini CLI",
|
||||
"goose",
|
||||
"Kimi Code CLI",
|
||||
"Kiro CLI",
|
||||
"Qwen Code",
|
||||
]);
|
||||
});
|
||||
|
||||
it("ranks the strongest match first and drops providers that do not match", () => {
|
||||
expect(titles(rankProviderCatalog(entries, "cod"))).toEqual([
|
||||
"Codex",
|
||||
"Kimi Code CLI",
|
||||
"Qwen Code",
|
||||
]);
|
||||
});
|
||||
|
||||
it("matches in-word subsequences and multiple tokens like the other pickers", () => {
|
||||
expect(titles(rankProviderCatalog(entries, "gmni"))).toEqual(["Gemini CLI"]);
|
||||
expect(titles(rankProviderCatalog(entries, "qw cod"))).toEqual(["Qwen Code"]);
|
||||
});
|
||||
|
||||
it("matches the provider id", () => {
|
||||
expect(titles(rankProviderCatalog(entries, "kiro-cli"))).toEqual(["Kiro CLI"]);
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import {
|
||||
compareMatchScores,
|
||||
scoreTextFields,
|
||||
type MatchScore,
|
||||
} from "@getpaseo/protocol/search/text-match";
|
||||
|
||||
export interface SearchableCatalogEntry {
|
||||
id: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
function compareTitles(a: SearchableCatalogEntry, b: SearchableCatalogEntry): number {
|
||||
return a.title.localeCompare(b.title, undefined, { sensitivity: "base" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Orders the Add provider catalog. Without a query the list is alphabetical by
|
||||
* name. With a query it uses the pickers' ranked matcher over the fields the
|
||||
* tile shows (name and id), best match first, ties alphabetical.
|
||||
*/
|
||||
export function rankProviderCatalog<T extends SearchableCatalogEntry>(
|
||||
entries: readonly T[],
|
||||
query: string,
|
||||
): T[] {
|
||||
if (!query.trim()) return [...entries].sort(compareTitles);
|
||||
|
||||
const scored: { entry: T; score: MatchScore }[] = [];
|
||||
for (const entry of entries) {
|
||||
const score = scoreTextFields(query, [entry.title, entry.id]);
|
||||
if (score) scored.push({ entry, score });
|
||||
}
|
||||
scored.sort((a, b) => compareMatchScores(a.score, b.score) || compareTitles(a.entry, b.entry));
|
||||
return scored.map(({ entry }) => entry);
|
||||
}
|
||||
@@ -63,11 +63,7 @@ import {
|
||||
type SidebarWorkspacePlacement,
|
||||
} from "@/hooks/use-sidebar-workspaces-list";
|
||||
import { useSidebarOrderStore } from "@/stores/sidebar-order-store";
|
||||
import {
|
||||
hasActiveSidebarLabelFilter,
|
||||
useSidebarViewStore,
|
||||
type SidebarGroupMode,
|
||||
} from "@/stores/sidebar-view-store";
|
||||
import { useSidebarViewStore, type SidebarGroupMode } from "@/stores/sidebar-view-store";
|
||||
import { useShowShortcutBadges } from "@/hooks/use-show-shortcut-badges";
|
||||
import {
|
||||
ContextMenu,
|
||||
@@ -1919,9 +1915,6 @@ export function SidebarWorkspaceList({
|
||||
const onToggleWorkspacePin = useSidebarWorkspacePinController();
|
||||
const getPinnedWorkspaceOrder = useSidebarOrderStore((state) => state.getPinnedWorkspaceOrder);
|
||||
const setPinnedWorkspaceOrder = useSidebarOrderStore((state) => state.setPinnedWorkspaceOrder);
|
||||
const hasActiveLabelFilter = useSidebarViewStore((state) =>
|
||||
hasActiveSidebarLabelFilter(state.labelFilter),
|
||||
);
|
||||
const handlePinnedWorkspaceReorder = useCallback(
|
||||
(reorderedWorkspaces: SidebarWorkspacePlacement[]) => {
|
||||
const reorderedWorkspaceKeys = reorderedWorkspaces.map((workspace) => workspace.workspaceKey);
|
||||
@@ -1953,11 +1946,10 @@ export function SidebarWorkspaceList({
|
||||
// this whole subtree, which unmounted the header — and the header is where the display menu's
|
||||
// trigger lives, so filtering the last row away closed the menu you were filtering from.
|
||||
//
|
||||
// Only the label filter can get here. The project filter resolves against the projects it can
|
||||
// see and falls back to "all projects" when nothing matches, so it either keeps at least one
|
||||
// project or is not applied at all — it can narrow this list but never empty it.
|
||||
const sidebarFilterEmpty =
|
||||
hasActiveLabelFilter && hasProjectsBeforeFilter && projects.length === 0;
|
||||
// Background visibility can also hide the last project. Keep the header mounted
|
||||
// whenever a local filter empties an otherwise populated directory, so users can
|
||||
// reach the display menu to reveal their work again.
|
||||
const sidebarFilterEmpty = hasProjectsBeforeFilter && projects.length === 0;
|
||||
|
||||
// Project mode is the one that keeps its project headers; every other grouping mode is a flat
|
||||
// list of grouped rows, so a new mode lands in the grouped branch rather than silently in this
|
||||
|
||||
@@ -301,6 +301,13 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
|
||||
sheetTitle={t("sidebar.display.heading")}
|
||||
testID="sidebar-display-preferences-content"
|
||||
>
|
||||
<MenuItem
|
||||
selected={preferences.showBackground}
|
||||
closeOnSelect={false}
|
||||
onSelect={preferences.toggleBackground}
|
||||
>
|
||||
{t("sidebar.display.showBackground")}
|
||||
</MenuItem>
|
||||
<MenuSubTrigger
|
||||
id="grouping"
|
||||
value={t(GROUPING_LABEL_KEYS[preferences.grouping])}
|
||||
|
||||
@@ -16,6 +16,8 @@ import { DEFAULT_SIDEBAR_ROW_ITEMS, type SidebarRowItem, type SidebarRowItems }
|
||||
export type SidebarTrailingChoice = Exclude<SidebarWorkspaceTrailing, "none">;
|
||||
|
||||
export interface SidebarDisplayPreferences {
|
||||
showBackground: boolean;
|
||||
toggleBackground: () => void;
|
||||
grouping: SidebarGroupMode;
|
||||
setGrouping: (mode: SidebarGroupMode) => void;
|
||||
titleSource: WorkspaceTitleSource;
|
||||
@@ -48,6 +50,8 @@ export interface SidebarDisplayPreferences {
|
||||
* this for a value and set it; where it lands is this module's problem.
|
||||
*/
|
||||
export function useSidebarDisplayPreferences(): SidebarDisplayPreferences {
|
||||
const showBackground = useSidebarViewStore((state) => state.showBackground);
|
||||
const toggleBackground = useSidebarViewStore((state) => state.toggleBackground);
|
||||
const grouping = useSidebarViewStore((state) => state.groupMode);
|
||||
const setGrouping = useSidebarViewStore((state) => state.setGroupMode);
|
||||
const hostFilters = useSidebarViewStore((state) => state.hostFilters);
|
||||
@@ -104,6 +108,8 @@ export function useSidebarDisplayPreferences(): SidebarDisplayPreferences {
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
showBackground,
|
||||
toggleBackground,
|
||||
grouping,
|
||||
setGrouping,
|
||||
titleSource: workspaceTitleSource,
|
||||
@@ -125,6 +131,8 @@ export function useSidebarDisplayPreferences(): SidebarDisplayPreferences {
|
||||
clearLabelFilter,
|
||||
}),
|
||||
[
|
||||
showBackground,
|
||||
toggleBackground,
|
||||
grouping,
|
||||
setGrouping,
|
||||
workspaceTitleSource,
|
||||
|
||||
@@ -57,6 +57,7 @@ export function SidebarModelProvider({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const list = useSidebarWorkspacesList({ enabled: active });
|
||||
const showBackground = useSidebarViewStore((state) => state.showBackground);
|
||||
const groupMode = useSidebarViewStore((state) => state.groupMode);
|
||||
const labelFilter = useSidebarViewStore((state) => state.labelFilter);
|
||||
const projectFilters = useSidebarViewStore((state) => state.projectFilters);
|
||||
@@ -107,9 +108,12 @@ export function SidebarModelProvider({
|
||||
workspaces: [...workspaceEntriesByKey.values()],
|
||||
projectFilters: resolvedProjectFilters,
|
||||
});
|
||||
const filtered = filterWorkspacesByLabels({ workspaces: byProject, ...labelFilter });
|
||||
const filtered = filterWorkspacesByLabels({
|
||||
workspaces: byProject.filter((workspace) => showBackground || !workspace.background),
|
||||
...labelFilter,
|
||||
});
|
||||
return new Map(filtered.map((workspace) => [workspace.workspaceKey, workspace]));
|
||||
}, [labelFilter, resolvedProjectFilters, workspaceEntriesByKey]);
|
||||
}, [showBackground, labelFilter, resolvedProjectFilters, workspaceEntriesByKey]);
|
||||
const visibleWorkspaceKeys = useMemo(
|
||||
() => new Set(filteredWorkspaceEntriesByKey.keys()),
|
||||
[filteredWorkspaceEntriesByKey],
|
||||
@@ -124,16 +128,19 @@ export function SidebarModelProvider({
|
||||
const included = new Set(resolvedProjectFilters);
|
||||
projects = projects.filter((project) => included.has(project.viewKey));
|
||||
}
|
||||
if (hasActiveLabelFilter) {
|
||||
if (hasActiveLabelFilter || !showBackground) {
|
||||
projects = projects.flatMap((project) => {
|
||||
const workspaces = project.workspaces.filter((workspace) =>
|
||||
visibleWorkspaceKeys.has(workspace.workspaceKey),
|
||||
);
|
||||
return workspaces.length > 0 ? [{ ...project, workspaces }] : [];
|
||||
return workspaces.length > 0 || (!hasActiveLabelFilter && project.workspaces.length === 0)
|
||||
? [{ ...project, workspaces }]
|
||||
: [];
|
||||
});
|
||||
}
|
||||
return projects;
|
||||
}, [
|
||||
showBackground,
|
||||
hasActiveLabelFilter,
|
||||
hasActiveProjectFilter,
|
||||
resolvedProjectFilters,
|
||||
|
||||
@@ -174,6 +174,7 @@ export function Button({
|
||||
...props
|
||||
}: PropsWithChildren<
|
||||
Omit<PressableProps, "style"> & {
|
||||
ref?: React.Ref<View>;
|
||||
variant?: ButtonVariant;
|
||||
size?: ButtonSize;
|
||||
leftIcon?: LeftIcon;
|
||||
|
||||
@@ -1,47 +1,67 @@
|
||||
import { forwardRef, useMemo } from "react";
|
||||
import { Text, type View } from "react-native";
|
||||
import type { LucideIcon } from "lucide-react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { PressHighlight } from "@/components/ui/press-highlight";
|
||||
import { ICON_SIZE, SPACING } from "@/styles/theme";
|
||||
import { ICON_SIZE } from "@/styles/theme";
|
||||
|
||||
const FLOATING_ACTION_BUTTON_SIZE = 56;
|
||||
const FLOATING_ACTION_BUTTON_INSET = SPACING[4];
|
||||
|
||||
/** Space a scrolling surface keeps below its content so the button traps nothing. */
|
||||
export const FLOATING_ACTION_BUTTON_CLEARANCE =
|
||||
FLOATING_ACTION_BUTTON_SIZE + FLOATING_ACTION_BUTTON_INSET;
|
||||
import {
|
||||
FLOATING_ACTION_BUTTON_SIZE,
|
||||
FLOATING_ACTION_BUTTON_INSET,
|
||||
} from "./floating-action-layout";
|
||||
export {
|
||||
FLOATING_ACTION_BUTTON_CLEARANCE,
|
||||
floatingActionsClearance,
|
||||
} from "./floating-action-layout";
|
||||
|
||||
export interface FloatingActionButtonProps {
|
||||
icon: LucideIcon;
|
||||
/** Names the action; the button carries no label. */
|
||||
/** Names the action for assistive technology. */
|
||||
accessibilityLabel: string;
|
||||
onPress: () => void;
|
||||
label?: string;
|
||||
disabled?: boolean;
|
||||
bottomInset?: number;
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The one floating action a scrolling surface can offer. It pins itself to the
|
||||
* bottom-right of its nearest positioned ancestor, so the ancestor decides what
|
||||
* the button may cover.
|
||||
* Pins an action to the bottom-right of its nearest positioned ancestor.
|
||||
* The surface reserves scroll clearance and uses bottomInset to separate stacked actions.
|
||||
*/
|
||||
export function FloatingActionButton({
|
||||
icon: Icon,
|
||||
accessibilityLabel,
|
||||
onPress,
|
||||
testID,
|
||||
}: FloatingActionButtonProps) {
|
||||
return (
|
||||
<PressHighlight
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
onPress={onPress}
|
||||
style={styles.button}
|
||||
highlightStyle={styles.pressed}
|
||||
testID={testID}
|
||||
>
|
||||
<Icon size={ICON_SIZE.lg} color={styles.glyph.color} />
|
||||
</PressHighlight>
|
||||
);
|
||||
}
|
||||
export const FloatingActionButton = forwardRef<View, FloatingActionButtonProps>(
|
||||
function FloatingActionButton(
|
||||
{ icon: Icon, accessibilityLabel, onPress, label, disabled = false, bottomInset = 0, testID },
|
||||
ref,
|
||||
) {
|
||||
const accessibilityState = useMemo(() => ({ disabled }), [disabled]);
|
||||
const buttonStyle = useMemo(
|
||||
() => [
|
||||
styles.button,
|
||||
label && styles.labeled,
|
||||
disabled && styles.disabled,
|
||||
{ bottom: FLOATING_ACTION_BUTTON_INSET + bottomInset },
|
||||
],
|
||||
[bottomInset, disabled, label],
|
||||
);
|
||||
return (
|
||||
<PressHighlight
|
||||
ref={ref}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
accessibilityState={accessibilityState}
|
||||
disabled={disabled}
|
||||
onPress={onPress}
|
||||
style={buttonStyle}
|
||||
highlightStyle={styles.pressed}
|
||||
testID={testID}
|
||||
>
|
||||
<Icon size={ICON_SIZE.lg} color={styles.glyph.color} />
|
||||
{label ? <Text style={styles.label}>{label}</Text> : null}
|
||||
</PressHighlight>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
button: {
|
||||
@@ -56,6 +76,15 @@ const styles = StyleSheet.create((theme) => ({
|
||||
backgroundColor: theme.colors.surface3,
|
||||
...theme.shadow.md,
|
||||
},
|
||||
labeled: {
|
||||
width: "auto",
|
||||
minWidth: FLOATING_ACTION_BUTTON_SIZE,
|
||||
paddingHorizontal: theme.spacing[4],
|
||||
flexDirection: "row",
|
||||
gap: theme.spacing[2],
|
||||
},
|
||||
label: { color: theme.colors.foreground, fontSize: theme.fontSize.base },
|
||||
disabled: { opacity: theme.opacity[50] },
|
||||
pressed: {
|
||||
backgroundColor: theme.colors.interactionHighlight,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
floatingActionsClearance,
|
||||
FLOATING_ACTION_BUTTON_CLEARANCE,
|
||||
} from "./floating-action-layout";
|
||||
|
||||
describe("floating action scroll clearance", () => {
|
||||
it("keeps the last diff line above Jump to file before and after feedback is added", () => {
|
||||
const jump = FLOATING_ACTION_BUTTON_CLEARANCE;
|
||||
const feedback = FLOATING_ACTION_BUTTON_CLEARANCE + 44;
|
||||
expect(floatingActionsClearance([jump, 0], 34)).toBe(106);
|
||||
expect(floatingActionsClearance([jump, feedback], 34)).toBe(222);
|
||||
expect(floatingActionsClearance([0, feedback], 34)).toBe(150);
|
||||
expect(floatingActionsClearance([jump, feedback], 0)).toBe(188);
|
||||
expect(floatingActionsClearance([0, 0], 34)).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { SPACING } from "@/styles/theme";
|
||||
|
||||
export const FLOATING_ACTION_BUTTON_SIZE = 56;
|
||||
export const FLOATING_ACTION_BUTTON_INSET = SPACING[4];
|
||||
export const FLOATING_ACTION_BUTTON_CLEARANCE =
|
||||
FLOATING_ACTION_BUTTON_SIZE + FLOATING_ACTION_BUTTON_INSET;
|
||||
|
||||
/** Reserve the stacked actions and the safe-area inset once for their scrolling surface. */
|
||||
export function floatingActionsClearance(
|
||||
actionClearances: readonly number[],
|
||||
bottomInset: number,
|
||||
): number {
|
||||
const clearance = actionClearances.reduce((total, action) => total + action, 0);
|
||||
return clearance > 0 ? clearance + bottomInset : 0;
|
||||
}
|
||||
@@ -245,3 +245,12 @@ describe("bottom sheet visibility tracker", () => {
|
||||
expect(context.backPress.press()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not cancel the owner's editor when the compact sheet leaves the tree on resize", () => {
|
||||
const context = setup();
|
||||
openSheet(context);
|
||||
context.tracker.attachController(null);
|
||||
context.tracker.handleSheetDismiss();
|
||||
expect(context.closeCount()).toBe(0);
|
||||
expect(context.backPress.press()).toBe(false);
|
||||
});
|
||||
|
||||
@@ -121,6 +121,9 @@ export function createBottomSheetVisibilityTracker(opts: {
|
||||
}
|
||||
},
|
||||
handleSheetDismiss() {
|
||||
// Portal cleanup reports dismissal after the sheet leaves the tree. It is
|
||||
// presentation teardown, so the owner keeps its desired state.
|
||||
if (!controller) return;
|
||||
if (visible) {
|
||||
setPhase("dismissing");
|
||||
notifyClose();
|
||||
|
||||
@@ -8,7 +8,6 @@ export interface AcpProviderCatalogEntry {
|
||||
iconSvg: string | null;
|
||||
installLink: string;
|
||||
command: readonly [string, ...string[]];
|
||||
bundledProvider?: boolean;
|
||||
env?: Readonly<Record<string, string>>;
|
||||
params?: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
@@ -239,16 +238,6 @@ const CATALOG_DATA = [
|
||||
installLink: "https://hermes-agent.nousresearch.com/docs/user-guide/features/acp",
|
||||
command: ["hermes", "acp"],
|
||||
},
|
||||
{
|
||||
id: "hoplite",
|
||||
bundledProvider: true,
|
||||
title: "Hoplite",
|
||||
description: "Cloud coding agent through the local hoplite acp bridge",
|
||||
version: "manual",
|
||||
iconId: "hoplite",
|
||||
installLink: "https://hoplite.sh/docs/cli#install",
|
||||
command: ["hoplite", "acp"],
|
||||
},
|
||||
{
|
||||
id: "junie",
|
||||
title: "Junie",
|
||||
@@ -400,7 +389,6 @@ export const ACP_PROVIDER_CATALOG: AcpProviderCatalogEntry[] = CATALOG_DATA.map(
|
||||
version: entry.version,
|
||||
installLink: entry.installLink,
|
||||
command: entry.command,
|
||||
bundledProvider: "bundledProvider" in entry ? entry.bundledProvider : undefined,
|
||||
env: "env" in entry ? entry.env : undefined,
|
||||
params: "params" in entry ? entry.params : undefined,
|
||||
iconSvg: entry.iconId ? (ACP_PROVIDER_ICON_SVGS[entry.iconId] ?? null) : null,
|
||||
|
||||
@@ -315,6 +315,7 @@ function reviewActionsForFirstAddition(): NonNullable<
|
||||
commentsByTarget: new Map(),
|
||||
editor: { target, commentId: null, body: "" },
|
||||
onStartComment() {},
|
||||
onChangeEditorBody() {},
|
||||
onCancelEditor() {},
|
||||
onSaveEditor() {},
|
||||
onEditComment() {},
|
||||
|
||||
@@ -389,6 +389,7 @@ describe("diff document model", () => {
|
||||
commentId: null,
|
||||
},
|
||||
onStartComment() {},
|
||||
onChangeEditorBody() {},
|
||||
onCancelEditor() {},
|
||||
onSaveEditor() {},
|
||||
onEditComment() {},
|
||||
@@ -790,6 +791,7 @@ function reviewActionsWithEditor(
|
||||
commentsByTarget: new Map(),
|
||||
editor: target ? { target, body: "", commentId: null } : null,
|
||||
onStartComment() {},
|
||||
onChangeEditorBody() {},
|
||||
onCancelEditor() {},
|
||||
onSaveEditor() {},
|
||||
onEditComment() {},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { floatingActionsClearance } from "@/components/ui/floating-action-button";
|
||||
import { useState, useCallback, useMemo, type ReactElement, type ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
@@ -31,6 +33,7 @@ import {
|
||||
import { type ParsedDiffFile } from "@/git/use-diff-query";
|
||||
import type { ChangesState } from "@/panels/changes/state";
|
||||
import { defaultChangesState } from "@/panels/changes/state";
|
||||
import { ReviewCommentSheet, ReviewFeedbackAction } from "@/review";
|
||||
import { DiffDocument, type WorkingDiffMode } from "@/git/diff-document";
|
||||
import { ChangedFilesTree } from "@/git/changed-files-tree";
|
||||
import { JUMP_TO_FILE_CLEARANCE, JumpToFile } from "@/git/jump-to-file";
|
||||
@@ -1548,7 +1551,9 @@ export function ChangesSurface({
|
||||
isDiffLoading,
|
||||
reviewActions,
|
||||
reviewAttachment,
|
||||
reviewFeedback,
|
||||
} = useWorkingDiff({
|
||||
presentation,
|
||||
serverId,
|
||||
workspaceId: workspaceId ?? undefined,
|
||||
cwd,
|
||||
@@ -1729,6 +1734,7 @@ export function ChangesSurface({
|
||||
],
|
||||
);
|
||||
|
||||
const { bottom: bottomInset } = useSafeAreaInsets();
|
||||
const hasChanges = files.length > 0;
|
||||
const jumpToFileInset = jumpToFileClearance({
|
||||
isCompact: isMobile,
|
||||
@@ -1778,27 +1784,41 @@ export function ChangesSurface({
|
||||
});
|
||||
|
||||
const diffContent: ReactElement = (
|
||||
<DiffBodyContent
|
||||
isStatusLoading={isStatusLoading}
|
||||
statusErrorMessage={statusErrorMessage}
|
||||
notGit={notGit}
|
||||
isDiffLoading={isDiffLoading}
|
||||
diffErrorMessage={diffErrorMessage}
|
||||
diffTooLarge={diffTooLarge}
|
||||
hasChanges={hasChanges}
|
||||
emptyMessage={emptyMessage}
|
||||
emptyAction={emptyAction}
|
||||
checkingRepositoryLabel={t("workspace.git.diff.checkingRepository")}
|
||||
notRepositoryLabel={t("workspace.git.diff.notRepository")}
|
||||
>
|
||||
<DiffDocument
|
||||
files={files}
|
||||
contentInsetBottom={jumpToFileInset}
|
||||
collapseState={collapseState}
|
||||
displayPreferences={sharedDisplayPreferences}
|
||||
mode={workingMode}
|
||||
<View style={styles.diffContainer}>
|
||||
<DiffBodyContent
|
||||
isStatusLoading={isStatusLoading}
|
||||
statusErrorMessage={statusErrorMessage}
|
||||
notGit={notGit}
|
||||
isDiffLoading={isDiffLoading}
|
||||
diffErrorMessage={diffErrorMessage}
|
||||
diffTooLarge={diffTooLarge}
|
||||
hasChanges={hasChanges}
|
||||
emptyMessage={emptyMessage}
|
||||
emptyAction={emptyAction}
|
||||
checkingRepositoryLabel={t("workspace.git.diff.checkingRepository")}
|
||||
notRepositoryLabel={t("workspace.git.diff.notRepository")}
|
||||
>
|
||||
<DiffDocument
|
||||
files={files}
|
||||
contentInsetBottom={floatingActionsClearance(
|
||||
[jumpToFileInset, reviewFeedback.clearance],
|
||||
bottomInset,
|
||||
)}
|
||||
collapseState={collapseState}
|
||||
displayPreferences={sharedDisplayPreferences}
|
||||
mode={workingMode}
|
||||
/>
|
||||
</DiffBodyContent>
|
||||
<ReviewFeedbackAction
|
||||
bottomOffset={jumpToFileInset}
|
||||
enabled={enabled}
|
||||
hasDiff={presentation !== "tree"}
|
||||
model={reviewFeedback.model}
|
||||
state={reviewFeedback.state}
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
/>
|
||||
</DiffBodyContent>
|
||||
</View>
|
||||
);
|
||||
const bodyContent = (
|
||||
<ChangesBody
|
||||
@@ -1934,6 +1954,13 @@ export function ChangesSurface({
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<ReviewCommentSheet
|
||||
enabled={enabled}
|
||||
editor={reviewActions.sheetEditor}
|
||||
reviewActions={reviewActions}
|
||||
onChangeBody={reviewActions.onChangeEditorBody}
|
||||
/>
|
||||
|
||||
<ChangesCommits
|
||||
presentation={presentation}
|
||||
serverId={serverId}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { FolderTree } from "lucide-react-native";
|
||||
import {
|
||||
@@ -53,6 +54,7 @@ export interface JumpToFileProps {
|
||||
/** Compact overview of a loaded diff: a floating action that opens the changed-files tree. */
|
||||
export function JumpToFile({ files, mode, onSelectFile }: JumpToFileProps) {
|
||||
const { t } = useTranslation();
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
// The sheet is a transient overview, so it always opens fully expanded and
|
||||
// never writes to the panel's persisted folder state.
|
||||
@@ -83,6 +85,7 @@ export function JumpToFile({ files, mode, onSelectFile }: JumpToFileProps) {
|
||||
<>
|
||||
<FloatingActionButton
|
||||
icon={FolderTree}
|
||||
bottomInset={bottom}
|
||||
accessibilityLabel={title}
|
||||
onPress={open}
|
||||
testID="changes-jump-to-file"
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
buildReviewDraftKey,
|
||||
useInlineReviewController,
|
||||
useReviewAttachmentSnapshot,
|
||||
useReviewFeedback,
|
||||
} from "@/review";
|
||||
import { useCheckoutDiffQuery } from "@/git/use-diff-query";
|
||||
import { useCheckoutStatusQuery } from "@/git/use-status-query";
|
||||
@@ -19,6 +20,7 @@ interface UseWorkingDiffOptions {
|
||||
ignoreWhitespace: boolean;
|
||||
enabled: boolean;
|
||||
queryScope?: string;
|
||||
presentation?: string;
|
||||
}
|
||||
|
||||
export function useWorkingDiff({
|
||||
@@ -28,6 +30,7 @@ export function useWorkingDiff({
|
||||
ignoreWhitespace,
|
||||
enabled,
|
||||
queryScope,
|
||||
presentation,
|
||||
}: UseWorkingDiffOptions) {
|
||||
const {
|
||||
status,
|
||||
@@ -81,7 +84,7 @@ export function useWorkingDiff({
|
||||
}),
|
||||
[baseRef, cwd, diffMode, ignoreWhitespace, serverId, workspaceId],
|
||||
);
|
||||
const reviewActions = useInlineReviewController({ reviewDraftKey });
|
||||
const reviewActions = useInlineReviewController({ reviewDraftKey, presentation });
|
||||
const reviewAttachment = useReviewAttachmentSnapshot({
|
||||
key: reviewDraftKey,
|
||||
diffFiles: files,
|
||||
@@ -90,6 +93,13 @@ export function useWorkingDiff({
|
||||
baseRef,
|
||||
});
|
||||
|
||||
const reviewFeedback = useReviewFeedback({
|
||||
serverId,
|
||||
workspaceId,
|
||||
reviewDraftKey,
|
||||
attachment: reviewAttachment,
|
||||
});
|
||||
|
||||
return {
|
||||
status,
|
||||
isStatusLoading,
|
||||
@@ -107,6 +117,7 @@ export function useWorkingDiff({
|
||||
isDiffLoading,
|
||||
reviewActions,
|
||||
reviewAttachment,
|
||||
reviewFeedback,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export interface SidebarWorkspacePlacement {
|
||||
workspaceDirectory?: string;
|
||||
projectKind: WorkspaceStructureProject["projectKind"];
|
||||
workspaceKind: WorkspaceDescriptor["workspaceKind"];
|
||||
background?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@@ -164,6 +165,7 @@ export function createSidebarWorkspaceEntry(input: {
|
||||
input.workspace.worktreeSlug ?? shortenPath(input.workspace.workspaceDirectory),
|
||||
projectKind: input.workspace.projectKind,
|
||||
workspaceKind: input.workspace.workspaceKind,
|
||||
background: input.workspace.background,
|
||||
name: input.workspace.name,
|
||||
title: input.workspace.title ?? null,
|
||||
pinnedAt: input.workspace.pinnedAt,
|
||||
|
||||
@@ -44,7 +44,6 @@ describe("ACP provider catalog", () => {
|
||||
expect(findProvider("codewhale").command).toEqual(["codewhale", "serve", "--acp"]);
|
||||
expect(findProvider("devin").command).toEqual(["devin", "acp"]);
|
||||
expect(findProvider("goose").command).toEqual(["goose", "acp"]);
|
||||
expect(findProvider("hoplite").command).toEqual(["hoplite", "acp"]);
|
||||
expect(findProvider("junie").command).toEqual(["junie", "--acp", "true"]);
|
||||
expect(findProvider("kiro").command).toEqual(["kiro-cli", "acp"]);
|
||||
expect(findProvider("poolside").command).toEqual(["pool", "acp"]);
|
||||
@@ -60,32 +59,6 @@ describe("ACP provider catalog", () => {
|
||||
expect(findProvider("minimax-code").iconSvg).toContain("<svg");
|
||||
});
|
||||
|
||||
it("offers Hoplite through its local ACP bridge with the Hoplite mark", () => {
|
||||
expect(findProvider("hoplite")).toMatchObject({
|
||||
title: "Hoplite",
|
||||
command: ["hoplite", "acp"],
|
||||
installLink: "https://hoplite.sh/docs/cli#install",
|
||||
});
|
||||
expect(buildAcpProviderConfigPatch(findProvider("hoplite"), true)).toEqual({
|
||||
providers: {
|
||||
hoplite: { enabled: true },
|
||||
},
|
||||
});
|
||||
const ids = getAcpProviderCatalog().map((entry) => entry.id);
|
||||
expect(ids.indexOf("hermes")).toBeLessThan(ids.indexOf("hoplite"));
|
||||
expect(ids.indexOf("hoplite")).toBeLessThan(ids.indexOf("junie"));
|
||||
expect(findProvider("hoplite").iconSvg).toContain('fill="currentColor"');
|
||||
});
|
||||
|
||||
it.each([undefined, false])(
|
||||
"rejects unsupported bundled Hoplite before producing a patch (%s)",
|
||||
(supported) => {
|
||||
expect(() => buildAcpProviderConfigPatch(findProvider("hoplite"), supported)).toThrow(
|
||||
"Update the host to add Hoplite.",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("maps a catalog entry to the daemon provider config patch", () => {
|
||||
expect(buildAcpProviderConfigPatch(findProvider("amp-acp"))).toEqual({
|
||||
providers: {
|
||||
|
||||
@@ -10,13 +10,7 @@ export function getAcpProviderCatalog(): AcpProviderCatalogItem[] {
|
||||
|
||||
export function buildAcpProviderConfigPatch(
|
||||
entry: AcpProviderCatalogItem,
|
||||
supportsHopliteProvider = false,
|
||||
): MutableDaemonConfigPatch {
|
||||
if (entry.bundledProvider) {
|
||||
// COMPAT(hopliteProvider): added after v0.11.2, remove after 2027-04-15 once host floor includes the bundled adapter.
|
||||
if (!supportsHopliteProvider) throw new Error("Update the host to add Hoplite.");
|
||||
return { providers: { [entry.id]: { enabled: true } } };
|
||||
}
|
||||
return {
|
||||
providers: {
|
||||
[entry.id]: {
|
||||
|
||||
@@ -30,6 +30,7 @@ export const ar: TranslationResources = {
|
||||
back: "خلف",
|
||||
loading: "تحميل...",
|
||||
actions: {
|
||||
save: "حفظ",
|
||||
back: "خلف",
|
||||
cancel: "يلغي",
|
||||
close: "يغلق",
|
||||
@@ -1147,6 +1148,7 @@ export const ar: TranslationResources = {
|
||||
done: "تم",
|
||||
},
|
||||
display: {
|
||||
showBackground: "إظهار مساحات العمل في الخلفية",
|
||||
trigger: "تفضيلات العرض",
|
||||
heading: "العرض",
|
||||
grouping: {
|
||||
@@ -1650,19 +1652,14 @@ export const ar: TranslationResources = {
|
||||
title: "إضافة مزود",
|
||||
search: "مقدمي البحث",
|
||||
noProviders: "لم يتم العثور على مقدمي الخدمات",
|
||||
clearSearch: "مسح البحث",
|
||||
actions: {
|
||||
add: "يضيف",
|
||||
addProvider: "إضافة {{provider}}",
|
||||
adding: "إضافة",
|
||||
installed: "تم التثبيت",
|
||||
cancel: "يلغي",
|
||||
installInstructions: "تعليمات التثبيت",
|
||||
installInstructionsFor: "تعليمات تثبيت{{provider}}",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "غير قادر على تثبيت الموفر",
|
||||
},
|
||||
@@ -2009,6 +2006,17 @@ export const ar: TranslationResources = {
|
||||
accessibility: "تم استخدام نافذة السياق{{percentage}}%",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "إرسال الملاحظات ({{count}})",
|
||||
sending: "جارٍ إرسال الملاحظات ({{count}})",
|
||||
chooseAgent: "اختر وكيلاً",
|
||||
sent: "تم إرسال الملاحظات إلى {{recipient}}",
|
||||
"no-agents": "افتح علامة تبويب وكيل في مساحة العمل هذه لإرسال الملاحظات.",
|
||||
disconnected: "اتصل بالمضيف لإرسال الملاحظات.",
|
||||
"no-context": "لم تعد التعليقات المحفوظة تتطابق مع هذا الفرق.",
|
||||
failed: "تعذر إرسال الملاحظات. حاول مرة أخرى.",
|
||||
prompt: "يرجى معالجة مراجعة الكود هذه.",
|
||||
},
|
||||
comment: {
|
||||
add: "إضافة تعليق المراجعة",
|
||||
edit: "تحرير تعليق المراجعة",
|
||||
|
||||
@@ -26,6 +26,7 @@ export const en = {
|
||||
back: "Back",
|
||||
loading: "Loading...",
|
||||
actions: {
|
||||
save: "Save",
|
||||
back: "Back",
|
||||
cancel: "Cancel",
|
||||
close: "Close",
|
||||
@@ -1155,6 +1156,7 @@ export const en = {
|
||||
done: "Done",
|
||||
},
|
||||
display: {
|
||||
showBackground: "Show background",
|
||||
trigger: "Display preferences",
|
||||
heading: "Display",
|
||||
grouping: {
|
||||
@@ -1675,19 +1677,14 @@ export const en = {
|
||||
title: "Add provider",
|
||||
search: "Search providers",
|
||||
noProviders: "No providers found",
|
||||
clearSearch: "Clear search",
|
||||
actions: {
|
||||
add: "Add",
|
||||
addProvider: "Add {{provider}}",
|
||||
adding: "Adding",
|
||||
installed: "Installed",
|
||||
cancel: "Cancel",
|
||||
installInstructions: "Install instructions",
|
||||
installInstructionsFor: "{{provider}} install instructions",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "Unable to install provider",
|
||||
},
|
||||
@@ -2034,6 +2031,17 @@ export const en = {
|
||||
accessibility: "Context window {{percentage}}% used",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "Send feedback ({{count}})",
|
||||
sending: "Sending feedback ({{count}})",
|
||||
chooseAgent: "Choose an agent",
|
||||
sent: "Feedback sent to {{recipient}}",
|
||||
"no-agents": "Open an agent tab in this workspace to send feedback.",
|
||||
disconnected: "Connect to the host to send feedback.",
|
||||
"no-context": "Saved comments no longer match this diff.",
|
||||
failed: "Failed to send feedback. Try again.",
|
||||
prompt: "Please address this code review.",
|
||||
},
|
||||
comment: {
|
||||
add: "Add review comment",
|
||||
edit: "Edit review comment",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const es: TranslationResources = {
|
||||
back: "Atrás",
|
||||
loading: "Cargando...",
|
||||
actions: {
|
||||
save: "Guardar",
|
||||
back: "Atrás",
|
||||
cancel: "Cancelar",
|
||||
close: "Cerrar",
|
||||
@@ -1183,6 +1184,7 @@ export const es: TranslationResources = {
|
||||
done: "Terminado",
|
||||
},
|
||||
display: {
|
||||
showBackground: "Mostrar espacios en segundo plano",
|
||||
trigger: "Preferencias de visualización",
|
||||
heading: "Visualización",
|
||||
grouping: {
|
||||
@@ -1696,19 +1698,14 @@ export const es: TranslationResources = {
|
||||
title: "Agregar proveedor",
|
||||
search: "Proveedores de búsqueda",
|
||||
noProviders: "No se encontraron proveedores",
|
||||
clearSearch: "Borrar búsqueda",
|
||||
actions: {
|
||||
add: "Agregar",
|
||||
addProvider: "Añadir {{provider}}",
|
||||
adding: "Añadiendo",
|
||||
installed: "Instalado",
|
||||
cancel: "Cancelar",
|
||||
installInstructions: "Instrucciones de instalación",
|
||||
installInstructionsFor: "Instrucciones de instalación de{{provider}}",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "No se puede instalar el proveedor",
|
||||
},
|
||||
@@ -2057,6 +2054,17 @@ export const es: TranslationResources = {
|
||||
accessibility: "Ventana de contexto{{percentage}}% utilizada",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "Enviar comentarios ({{count}})",
|
||||
sending: "Enviando comentarios ({{count}})",
|
||||
chooseAgent: "Elegir un agente",
|
||||
sent: "Comentarios enviados a {{recipient}}",
|
||||
"no-agents": "Abre una pestaña de agente en este espacio de trabajo para enviar comentarios.",
|
||||
disconnected: "Conéctate al host para enviar comentarios.",
|
||||
"no-context": "Los comentarios guardados ya no coinciden con este diff.",
|
||||
failed: "No se pudieron enviar los comentarios. Inténtalo de nuevo.",
|
||||
prompt: "Por favor, atiende esta revisión de código.",
|
||||
},
|
||||
comment: {
|
||||
add: "Agregar comentario de revisión",
|
||||
edit: "Editar comentario de revisión",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const fr: TranslationResources = {
|
||||
back: "Retour",
|
||||
loading: "Chargement…",
|
||||
actions: {
|
||||
save: "Enregistrer",
|
||||
back: "Retour",
|
||||
cancel: "Annuler",
|
||||
close: "Fermer",
|
||||
@@ -1174,6 +1175,7 @@ export const fr: TranslationResources = {
|
||||
done: "Terminé",
|
||||
},
|
||||
display: {
|
||||
showBackground: "Afficher les espaces en arrière-plan",
|
||||
trigger: "Préférences d’affichage",
|
||||
heading: "Affichage",
|
||||
grouping: {
|
||||
@@ -1692,19 +1694,14 @@ export const fr: TranslationResources = {
|
||||
title: "Ajouter un fournisseur",
|
||||
search: "Rechercher des fournisseurs",
|
||||
noProviders: "Aucun fournisseur trouvé",
|
||||
clearSearch: "Effacer la recherche",
|
||||
actions: {
|
||||
add: "Ajouter",
|
||||
addProvider: "Ajouter {{provider}}",
|
||||
adding: "Ajout…",
|
||||
installed: "Installé",
|
||||
cancel: "Annuler",
|
||||
installInstructions: "Instructions d’installation",
|
||||
installInstructionsFor: "Instructions d’installation de {{provider}}",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "Impossible d’installer le fournisseur",
|
||||
},
|
||||
@@ -2054,6 +2051,18 @@ export const fr: TranslationResources = {
|
||||
accessibility: "Fenêtre de contexte : {{percentage}} % utilisés",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "Envoyer les commentaires ({{count}})",
|
||||
sending: "Envoi des commentaires ({{count}})",
|
||||
chooseAgent: "Choisir un agent",
|
||||
sent: "Commentaires envoyés à {{recipient}}",
|
||||
"no-agents":
|
||||
"Ouvrez un onglet d’agent dans cet espace de travail pour envoyer les commentaires.",
|
||||
disconnected: "Connectez-vous à l’hôte pour envoyer les commentaires.",
|
||||
"no-context": "Les commentaires enregistrés ne correspondent plus à ce diff.",
|
||||
failed: "Échec de l’envoi des commentaires. Réessayez.",
|
||||
prompt: "Veuillez traiter cette revue de code.",
|
||||
},
|
||||
comment: {
|
||||
add: "Ajouter un commentaire de revue",
|
||||
edit: "Modifier le commentaire de revue",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ja: TranslationResources = {
|
||||
back: "戻る",
|
||||
loading: "読み込み中...",
|
||||
actions: {
|
||||
save: "保存",
|
||||
back: "戻る",
|
||||
cancel: "キャンセル",
|
||||
close: "閉じる",
|
||||
@@ -1160,6 +1161,7 @@ export const ja: TranslationResources = {
|
||||
done: "完了",
|
||||
},
|
||||
display: {
|
||||
showBackground: "バックグラウンドを表示",
|
||||
trigger: "表示設定",
|
||||
heading: "表示",
|
||||
grouping: {
|
||||
@@ -1667,19 +1669,14 @@ export const ja: TranslationResources = {
|
||||
title: "プロバイダーを追加",
|
||||
search: "プロバイダーを検索",
|
||||
noProviders: "プロバイダーが見つかりません",
|
||||
clearSearch: "検索をクリア",
|
||||
actions: {
|
||||
add: "追加",
|
||||
addProvider: "{{provider}} を追加",
|
||||
adding: "追加中",
|
||||
installed: "インストール済み",
|
||||
cancel: "キャンセル",
|
||||
installInstructions: "インストール手順",
|
||||
installInstructionsFor: "{{provider}}のインストール手順",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "プロバイダーをインストールできません",
|
||||
},
|
||||
@@ -2029,6 +2026,18 @@ export const ja: TranslationResources = {
|
||||
accessibility: "コンテキストウィンドウ{{percentage}}%使用",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "フィードバックを送信 ({{count}})",
|
||||
sending: "フィードバックを送信中 ({{count}})",
|
||||
chooseAgent: "エージェントを選択",
|
||||
sent: "{{recipient}} にフィードバックを送信しました",
|
||||
"no-agents":
|
||||
"フィードバックを送信するには、このワークスペースでエージェントタブを開いてください。",
|
||||
disconnected: "フィードバックを送信するにはホストに接続してください。",
|
||||
"no-context": "保存したコメントはこの差分と一致しなくなりました。",
|
||||
failed: "フィードバックを送信できませんでした。もう一度お試しください。",
|
||||
prompt: "このコードレビューに対応してください。",
|
||||
},
|
||||
comment: {
|
||||
add: "レビューコメントを追加",
|
||||
edit: "レビューコメントを編集",
|
||||
|
||||
@@ -30,6 +30,7 @@ export const ko: TranslationResources = {
|
||||
back: "뒤로",
|
||||
loading: "불러오는 중...",
|
||||
actions: {
|
||||
save: "저장",
|
||||
back: "뒤로",
|
||||
cancel: "취소",
|
||||
close: "닫기",
|
||||
@@ -1154,6 +1155,7 @@ export const ko: TranslationResources = {
|
||||
done: "완료",
|
||||
},
|
||||
display: {
|
||||
showBackground: "백그라운드 표시",
|
||||
trigger: "표시 설정",
|
||||
heading: "표시",
|
||||
grouping: {
|
||||
@@ -1660,19 +1662,14 @@ export const ko: TranslationResources = {
|
||||
title: "프로바이더 추가",
|
||||
search: "프로바이더 검색",
|
||||
noProviders: "프로바이더를 찾을 수 없습니다",
|
||||
clearSearch: "검색 지우기",
|
||||
actions: {
|
||||
add: "추가",
|
||||
addProvider: "{{provider}} 추가",
|
||||
adding: "추가 중",
|
||||
installed: "설치됨",
|
||||
cancel: "취소",
|
||||
installInstructions: "설치 안내",
|
||||
installInstructionsFor: "{{provider}} 설치 안내",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "프로바이더를 설치할 수 없습니다",
|
||||
},
|
||||
@@ -2019,6 +2016,17 @@ export const ko: TranslationResources = {
|
||||
accessibility: "컨텍스트 윈도우 {{percentage}}% 사용됨",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "피드백 보내기 ({{count}})",
|
||||
sending: "피드백 전송 중 ({{count}})",
|
||||
chooseAgent: "에이전트 선택",
|
||||
sent: "{{recipient}}에게 피드백을 보냈습니다",
|
||||
"no-agents": "피드백을 보내려면 이 작업 공간에서 에이전트 탭을 여세요.",
|
||||
disconnected: "피드백을 보내려면 호스트에 연결하세요.",
|
||||
"no-context": "저장된 댓글이 더 이상 이 변경 사항과 일치하지 않습니다.",
|
||||
failed: "피드백 전송에 실패했습니다. 다시 시도하세요.",
|
||||
prompt: "이 코드 리뷰를 반영해 주세요.",
|
||||
},
|
||||
comment: {
|
||||
add: "리뷰 댓글 추가",
|
||||
edit: "리뷰 댓글 편집",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ptBR: TranslationResources = {
|
||||
back: "Voltar",
|
||||
loading: "Carregando...",
|
||||
actions: {
|
||||
save: "Salvar",
|
||||
back: "Voltar",
|
||||
cancel: "Cancelar",
|
||||
close: "Fechar",
|
||||
@@ -1173,6 +1174,7 @@ export const ptBR: TranslationResources = {
|
||||
done: "Concluído",
|
||||
},
|
||||
display: {
|
||||
showBackground: "Mostrar espaços em segundo plano",
|
||||
trigger: "Preferências de exibição",
|
||||
heading: "Exibição",
|
||||
grouping: {
|
||||
@@ -1681,19 +1683,14 @@ export const ptBR: TranslationResources = {
|
||||
title: "Adicionar provedor",
|
||||
search: "Buscar provedores",
|
||||
noProviders: "Nenhum provedor encontrado",
|
||||
clearSearch: "Limpar pesquisa",
|
||||
actions: {
|
||||
add: "Adicionar",
|
||||
addProvider: "Adicionar {{provider}}",
|
||||
adding: "Adicionando",
|
||||
installed: "Instalado",
|
||||
cancel: "Cancelar",
|
||||
installInstructions: "Instruções de instalação",
|
||||
installInstructionsFor: "Instruções de instalação de {{provider}}",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "Não foi possível instalar provedor",
|
||||
},
|
||||
@@ -2042,6 +2039,17 @@ export const ptBR: TranslationResources = {
|
||||
accessibility: "Janela de contexto {{percentage}}% usada",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "Enviar comentários ({{count}})",
|
||||
sending: "Enviando comentários ({{count}})",
|
||||
chooseAgent: "Escolher um agente",
|
||||
sent: "Comentários enviados para {{recipient}}",
|
||||
"no-agents": "Abra uma aba de agente neste espaço de trabalho para enviar comentários.",
|
||||
disconnected: "Conecte-se ao host para enviar comentários.",
|
||||
"no-context": "Os comentários salvos não correspondem mais a este diff.",
|
||||
failed: "Falha ao enviar comentários. Tente novamente.",
|
||||
prompt: "Por favor, atenda a esta revisão de código.",
|
||||
},
|
||||
comment: {
|
||||
add: "Adicionar comentário de revisão",
|
||||
edit: "Editar comentário de revisão",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ru: TranslationResources = {
|
||||
back: "Назад",
|
||||
loading: "Загрузка...",
|
||||
actions: {
|
||||
save: "Сохранить",
|
||||
back: "Назад",
|
||||
cancel: "Отмена",
|
||||
close: "Закрыть",
|
||||
@@ -1164,6 +1165,7 @@ export const ru: TranslationResources = {
|
||||
done: "Готово",
|
||||
},
|
||||
display: {
|
||||
showBackground: "Показать фоновые пространства",
|
||||
trigger: "Настройки отображения",
|
||||
heading: "Отображение",
|
||||
grouping: {
|
||||
@@ -1679,19 +1681,14 @@ export const ru: TranslationResources = {
|
||||
title: "Добавить провайдера",
|
||||
search: "Поиск провайдеров",
|
||||
noProviders: "Провайдеры не найдены",
|
||||
clearSearch: "Очистить поиск",
|
||||
actions: {
|
||||
add: "Добавить",
|
||||
addProvider: "Добавить {{provider}}",
|
||||
adding: "Добавление",
|
||||
installed: "Установлено",
|
||||
cancel: "Отмена",
|
||||
installInstructions: "Инструкции по установке",
|
||||
installInstructionsFor: "Инструкции по установке {{provider}}",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "Не удалось установить провайдера",
|
||||
},
|
||||
@@ -2042,6 +2039,17 @@ export const ru: TranslationResources = {
|
||||
accessibility: "Использовано {{percentage}}% контекстного окна",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "Отправить отзыв ({{count}})",
|
||||
sending: "Отправка отзыва ({{count}})",
|
||||
chooseAgent: "Выберите агента",
|
||||
sent: "Отзыв отправлен: {{recipient}}",
|
||||
"no-agents": "Откройте вкладку агента в этой рабочей области, чтобы отправить отзыв.",
|
||||
disconnected: "Подключитесь к хосту, чтобы отправить отзыв.",
|
||||
"no-context": "Сохранённые комментарии больше не соответствуют этому diff.",
|
||||
failed: "Не удалось отправить отзыв. Повторите попытку.",
|
||||
prompt: "Пожалуйста, учтите эту проверку кода.",
|
||||
},
|
||||
comment: {
|
||||
add: "Добавить комментарий к ревью",
|
||||
edit: "Изменить комментарий к ревью",
|
||||
|
||||
@@ -30,6 +30,7 @@ export const zhCN: TranslationResources = {
|
||||
back: "返回",
|
||||
loading: "加载中...",
|
||||
actions: {
|
||||
save: "保存",
|
||||
back: "返回",
|
||||
cancel: "取消",
|
||||
close: "关闭",
|
||||
@@ -1139,6 +1140,7 @@ export const zhCN: TranslationResources = {
|
||||
done: "已完成",
|
||||
},
|
||||
display: {
|
||||
showBackground: "显示后台工作区",
|
||||
trigger: "显示偏好",
|
||||
heading: "显示",
|
||||
grouping: {
|
||||
@@ -1633,19 +1635,14 @@ export const zhCN: TranslationResources = {
|
||||
title: "添加 provider",
|
||||
search: "搜索 providers",
|
||||
noProviders: "未找到 providers",
|
||||
clearSearch: "清除搜索",
|
||||
actions: {
|
||||
add: "添加",
|
||||
addProvider: "添加 {{provider}}",
|
||||
adding: "正在添加",
|
||||
installed: "已安装",
|
||||
cancel: "取消",
|
||||
installInstructions: "安装说明",
|
||||
installInstructionsFor: "{{provider}} 安装说明",
|
||||
},
|
||||
types: {
|
||||
acp: "ACP",
|
||||
},
|
||||
errors: {
|
||||
unableToInstall: "无法安装 provider",
|
||||
},
|
||||
@@ -1987,6 +1984,17 @@ export const zhCN: TranslationResources = {
|
||||
accessibility: "上下文窗口已使用 {{percentage}}%",
|
||||
},
|
||||
review: {
|
||||
feedback: {
|
||||
send: "发送反馈 ({{count}})",
|
||||
sending: "正在发送反馈 ({{count}})",
|
||||
chooseAgent: "选择智能体",
|
||||
sent: "已向 {{recipient}} 发送反馈",
|
||||
"no-agents": "请在此工作区打开智能体标签页以发送反馈。",
|
||||
disconnected: "请连接到主机以发送反馈。",
|
||||
"no-context": "保存的评论不再匹配此差异。",
|
||||
failed: "发送反馈失败。请重试。",
|
||||
prompt: "请处理此代码审查。",
|
||||
},
|
||||
comment: {
|
||||
add: "添加 review 评论",
|
||||
edit: "编辑 review 评论",
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { AdaptiveModalSheet } from "@/components/adaptive-modal-sheet";
|
||||
import { FormTextInput } from "@/components/ui/form-field";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { InlineReviewActions, InlineReviewEditorState } from "./geometry";
|
||||
|
||||
export function ReviewCommentSheet({
|
||||
editor,
|
||||
reviewActions,
|
||||
onChangeBody,
|
||||
enabled,
|
||||
}: {
|
||||
enabled: boolean | undefined;
|
||||
editor: InlineReviewEditorState | null;
|
||||
reviewActions: InlineReviewActions;
|
||||
onChangeBody: (body: string) => void;
|
||||
}) {
|
||||
if (enabled === false || !editor) return null;
|
||||
return (
|
||||
<OpenReviewCommentSheet
|
||||
editor={editor}
|
||||
reviewActions={reviewActions}
|
||||
onChangeBody={onChangeBody}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function OpenReviewCommentSheet({
|
||||
editor,
|
||||
reviewActions,
|
||||
onChangeBody,
|
||||
}: {
|
||||
editor: InlineReviewEditorState;
|
||||
reviewActions: InlineReviewActions;
|
||||
onChangeBody: (body: string) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const context = `${editor.target.filePath} · ${editor.target.side === "old" ? "−" : "+"}${editor.target.lineNumber}`;
|
||||
const header = useMemo(
|
||||
() => ({
|
||||
title: t("review.comment.label"),
|
||||
subtitle: <Text style={styles.context}>{context}</Text>,
|
||||
}),
|
||||
[context, t],
|
||||
);
|
||||
const { onSaveEditor, onCancelEditor } = reviewActions;
|
||||
const handleSave = useCallback(() => onSaveEditor(editor.body), [onSaveEditor, editor.body]);
|
||||
const canSave = editor.body.trim().length > 0;
|
||||
const footer = useMemo(
|
||||
() => (
|
||||
<View style={styles.actions}>
|
||||
<Button
|
||||
size="md"
|
||||
variant="secondary"
|
||||
accessibilityLabel={t("review.comment.cancelAccessibility")}
|
||||
onPress={onCancelEditor}
|
||||
>
|
||||
{t("review.comment.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
size="md"
|
||||
variant="default"
|
||||
accessibilityLabel={t("review.comment.saveAccessibility")}
|
||||
disabled={!canSave}
|
||||
onPress={handleSave}
|
||||
>
|
||||
{t("common.actions.save")}
|
||||
</Button>
|
||||
</View>
|
||||
),
|
||||
[canSave, handleSave, onCancelEditor, t],
|
||||
);
|
||||
return (
|
||||
<AdaptiveModalSheet
|
||||
visible
|
||||
header={header}
|
||||
onClose={onCancelEditor}
|
||||
snapPoints={COMMENT_SNAP_POINTS}
|
||||
scrollable={false}
|
||||
testID="review-comment-sheet"
|
||||
footer={footer}
|
||||
>
|
||||
<FormTextInput
|
||||
key={editor.target.key + (editor.commentId ?? "new")}
|
||||
size="md"
|
||||
multiline
|
||||
accessibilityLabel={t("review.comment.label")}
|
||||
placeholder={t("review.comment.placeholder")}
|
||||
initialValue={editor.body}
|
||||
onChangeText={onChangeBody}
|
||||
style={styles.input}
|
||||
/>
|
||||
</AdaptiveModalSheet>
|
||||
);
|
||||
}
|
||||
|
||||
const COMMENT_SNAP_POINTS = ["50%", "90%"];
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
context: { color: theme.colors.foregroundMuted, fontSize: theme.fontSize.sm },
|
||||
input: { flex: 1, minHeight: 0, textAlignVertical: "top" },
|
||||
actions: { flex: 1, flexDirection: "row", justifyContent: "flex-end", gap: theme.spacing[2] },
|
||||
}));
|
||||
@@ -0,0 +1,145 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createReviewEditor, createReviewEditorScope, type ReviewCommentWriter } from "./index";
|
||||
import type { ReviewDraftComment } from "../state";
|
||||
import type { ReviewableDiffTarget } from "@/utils/diff-layout";
|
||||
|
||||
const target: ReviewableDiffTarget = {
|
||||
key: "src/example.ts:new:2",
|
||||
filePath: "src/example.ts",
|
||||
side: "new",
|
||||
lineNumber: 2,
|
||||
hunkHeader: "@@ -1,2 +1,2 @@",
|
||||
hunkIndex: 0,
|
||||
lineIndex: 2,
|
||||
oldLineNumber: null,
|
||||
newLineNumber: 2,
|
||||
lineType: "add",
|
||||
content: "const value = next;",
|
||||
};
|
||||
|
||||
function memoryWriter() {
|
||||
const drafts = new Map<string, ReviewDraftComment[]>();
|
||||
let sequence = 0;
|
||||
const writer: ReviewCommentWriter = {
|
||||
saveComment: ({ key, id, comment }) => {
|
||||
const current = drafts.get(key) ?? [];
|
||||
if (id && current.some((saved) => saved.id === id)) {
|
||||
drafts.set(
|
||||
key,
|
||||
current.map((saved) => (saved.id === id ? { ...saved, ...comment } : saved)),
|
||||
);
|
||||
} else {
|
||||
const saved = {
|
||||
...comment,
|
||||
id: String(++sequence),
|
||||
createdAt: "2026-10-09T00:00:00Z",
|
||||
updatedAt: "2026-10-09T00:00:00Z",
|
||||
};
|
||||
drafts.set(key, [...current, saved]);
|
||||
}
|
||||
},
|
||||
deleteComment: ({ key, id }) => {
|
||||
drafts.set(
|
||||
key,
|
||||
(drafts.get(key) ?? []).filter((comment) => comment.id !== id),
|
||||
);
|
||||
},
|
||||
};
|
||||
return { writer, comments: (key: string) => drafts.get(key) ?? [] };
|
||||
}
|
||||
|
||||
describe("review editor", () => {
|
||||
it("saves trimmed comments, edits the same record, and cancels without altering saved comments", () => {
|
||||
const storage = memoryWriter();
|
||||
const editor = createReviewEditor("first", storage.writer);
|
||||
editor.start(target);
|
||||
editor.setBody(" First comment ");
|
||||
editor.save(editor.getState()!.body);
|
||||
expect(editor.getState()).toBeNull();
|
||||
const saved = storage.comments("first")[0]!;
|
||||
expect(saved).toMatchObject({
|
||||
filePath: target.filePath,
|
||||
side: "new",
|
||||
lineNumber: 2,
|
||||
body: "First comment",
|
||||
});
|
||||
editor.edit(target, saved);
|
||||
editor.setBody("Discarded edit");
|
||||
editor.cancel();
|
||||
expect(storage.comments("first")).toEqual([saved]);
|
||||
editor.edit(target, saved);
|
||||
editor.save(" Updated comment ");
|
||||
expect(storage.comments("first")).toEqual([{ ...saved, body: "Updated comment" }]);
|
||||
editor.start(target);
|
||||
editor.setBody("Discarded new comment");
|
||||
editor.cancel();
|
||||
expect(storage.comments("first")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("keeps an open edit saveable after its submitted record is acknowledged", () => {
|
||||
const storage = memoryWriter();
|
||||
const editor = createReviewEditor("first", storage.writer);
|
||||
editor.start(target);
|
||||
editor.save("Submitted body");
|
||||
const saved = storage.comments("first")[0]!;
|
||||
editor.edit(target, saved);
|
||||
editor.setBody("Typed before acknowledgement");
|
||||
storage.writer.deleteComment({ key: "first", id: saved.id });
|
||||
expect(editor.getState()!.body).toBe("Typed before acknowledgement");
|
||||
editor.save(editor.getState()!.body);
|
||||
expect(storage.comments("first")).toMatchObject([
|
||||
{
|
||||
body: "Typed before acknowledgement",
|
||||
filePath: target.filePath,
|
||||
lineNumber: target.lineNumber,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects empty saves and repeated saves after the editor closes", () => {
|
||||
const storage = memoryWriter();
|
||||
const editor = createReviewEditor("first", storage.writer);
|
||||
editor.start(target);
|
||||
editor.save(" \n ");
|
||||
expect(editor.getState()).toEqual({ target, commentId: null, body: "" });
|
||||
expect(storage.comments("first")).toEqual([]);
|
||||
editor.save("Saved once");
|
||||
editor.save("Duplicate");
|
||||
expect(storage.comments("first").map((comment) => comment.body)).toEqual(["Saved once"]);
|
||||
});
|
||||
|
||||
it("isolates draft ownership and closes an editor when its saved comment is deleted", () => {
|
||||
const storage = memoryWriter();
|
||||
const first = createReviewEditor("first", storage.writer);
|
||||
const second = createReviewEditor("second", storage.writer);
|
||||
first.start(target);
|
||||
first.save("First workspace");
|
||||
const saved = storage.comments("first")[0]!;
|
||||
first.edit(target, saved);
|
||||
expect(second.getState()).toBeNull();
|
||||
second.start(target);
|
||||
second.save("Second workspace");
|
||||
first.delete(saved.id);
|
||||
expect(first.getState()).toBeNull();
|
||||
expect(storage.comments("first")).toEqual([]);
|
||||
expect(storage.comments("second").map((comment) => comment.body)).toEqual(["Second workspace"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("retains an open editor through remounts without exposing it on another surface or draft", async () => {
|
||||
const storage = memoryWriter();
|
||||
const scope = createReviewEditorScope(storage.writer);
|
||||
const editor = scope.forDraft("first", "diff");
|
||||
const unsubscribe = editor.subscribe(() => {});
|
||||
editor.start(target);
|
||||
editor.setBody("Unsaved wide body");
|
||||
unsubscribe();
|
||||
await Promise.resolve();
|
||||
const compact = scope.forDraft("first", "diff");
|
||||
expect(compact.getState()!.body).toBe("Unsaved wide body");
|
||||
expect(scope.forDraft("first", "combined").getState()).toBeNull();
|
||||
expect(scope.forDraft("second", "diff").getState()).toBeNull();
|
||||
compact.save(compact.getState()!.body);
|
||||
expect(storage.comments("first")[0]!.body).toBe("Unsaved wide body");
|
||||
expect(scope.forDraft("first", "diff").getState()).toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { ReviewableDiffTarget } from "@/utils/diff-layout";
|
||||
import type { InlineReviewEditorState } from "../geometry";
|
||||
import type { ReviewDraftComment } from "../state";
|
||||
|
||||
export interface ReviewCommentWriter {
|
||||
saveComment: (input: {
|
||||
key: string;
|
||||
id: string | null;
|
||||
comment: Pick<ReviewDraftComment, "filePath" | "side" | "lineNumber" | "body">;
|
||||
}) => void;
|
||||
deleteComment: (input: { key: string; id: string }) => void;
|
||||
}
|
||||
|
||||
/** One editor belongs to one review draft; replacing the draft creates a fresh editor. */
|
||||
export function createReviewEditor(key: string, writer: ReviewCommentWriter) {
|
||||
return buildReviewEditor(key, writer, () => {});
|
||||
}
|
||||
|
||||
function buildReviewEditor(key: string, writer: ReviewCommentWriter, onUnused: () => void) {
|
||||
let editor: InlineReviewEditorState | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
function publish(next: InlineReviewEditorState | null) {
|
||||
editor = next;
|
||||
listeners.forEach((listener) => listener());
|
||||
if (!editor && listeners.size === 0) onUnused();
|
||||
}
|
||||
return {
|
||||
getState: () => editor,
|
||||
subscribe: (listener: () => void) => {
|
||||
listeners.add(listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
queueMicrotask(() => {
|
||||
if (!editor && listeners.size === 0) onUnused();
|
||||
});
|
||||
};
|
||||
},
|
||||
start: (target: ReviewableDiffTarget) => publish({ target, commentId: null, body: "" }),
|
||||
edit: (target: ReviewableDiffTarget, comment: ReviewDraftComment) =>
|
||||
publish({ target, commentId: comment.id, body: comment.body }),
|
||||
setBody: (body: string) => {
|
||||
if (editor) publish({ ...editor, body });
|
||||
},
|
||||
cancel: () => publish(null),
|
||||
save: (body: string) => {
|
||||
const trimmedBody = body.trim();
|
||||
if (!editor || !trimmedBody) return;
|
||||
writer.saveComment({
|
||||
key,
|
||||
id: editor.commentId,
|
||||
comment: {
|
||||
filePath: editor.target.filePath,
|
||||
side: editor.target.side,
|
||||
lineNumber: editor.target.lineNumber,
|
||||
body: trimmedBody,
|
||||
},
|
||||
});
|
||||
publish(null);
|
||||
},
|
||||
delete: (id: string) => {
|
||||
writer.deleteComment({ key, id });
|
||||
if (editor?.commentId === id) publish(null);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** An open draft survives presentation remounts; each presentation owns its editor for that draft. */
|
||||
export function createReviewEditorScope(writer: ReviewCommentWriter) {
|
||||
const editors = new Map<string, ReturnType<typeof createReviewEditor>>();
|
||||
return {
|
||||
forDraft(key: string, presentation: string) {
|
||||
const owner = JSON.stringify([key, presentation]);
|
||||
let model = editors.get(owner);
|
||||
if (!model) {
|
||||
const created = buildReviewEditor(key, writer, () => {
|
||||
if (editors.get(owner) === created) editors.delete(owner);
|
||||
});
|
||||
model = created;
|
||||
editors.set(owner, model);
|
||||
}
|
||||
return model;
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
createReviewFeedback,
|
||||
createReviewFeedbackScope,
|
||||
type ReviewFeedbackPorts,
|
||||
type ReviewFeedbackSnapshot,
|
||||
type FeedbackAttachment,
|
||||
type FeedbackRecipient,
|
||||
} from "./index";
|
||||
import type { ReviewDraftComment } from "../state";
|
||||
|
||||
function makeComment(id: string, body = id): ReviewDraftComment {
|
||||
return {
|
||||
id,
|
||||
body,
|
||||
filePath: "sample.ts",
|
||||
side: "new",
|
||||
lineNumber: 2,
|
||||
createdAt: "2026-10-09T00:00:00Z",
|
||||
updatedAt: "2026-10-09T00:00:00Z",
|
||||
};
|
||||
}
|
||||
function makeRecipient(agentId: string): FeedbackRecipient {
|
||||
return {
|
||||
agentId,
|
||||
tab: {
|
||||
key: `agent_${agentId}`,
|
||||
tabId: `agent_${agentId}`,
|
||||
kind: "agent",
|
||||
target: { kind: "agent", agentId },
|
||||
},
|
||||
};
|
||||
}
|
||||
function makeAttachment(comments: readonly ReviewDraftComment[]): FeedbackAttachment | null {
|
||||
if (!comments.length) return null;
|
||||
const line = {
|
||||
type: "add" as const,
|
||||
content: "const value = 1",
|
||||
oldLineNumber: null,
|
||||
newLineNumber: 2,
|
||||
};
|
||||
return {
|
||||
kind: "review",
|
||||
reviewDraftKey: "draft",
|
||||
commentCount: comments.length,
|
||||
attachment: {
|
||||
type: "review",
|
||||
mimeType: "application/paseo-review",
|
||||
cwd: "/workspace",
|
||||
mode: "uncommitted",
|
||||
baseRef: null,
|
||||
comments: comments.map((comment) => ({
|
||||
filePath: comment.filePath,
|
||||
side: comment.side,
|
||||
lineNumber: comment.lineNumber,
|
||||
body: comment.body,
|
||||
context: { hunkHeader: "@@ -1 +1 @@", targetLine: line, lines: [line] },
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
function setup(agentIds: string[], unavailableIds: string[] = [], create = createReviewFeedback) {
|
||||
let comments = [makeComment("first")];
|
||||
let recipients = agentIds.map(makeRecipient);
|
||||
let connected = true;
|
||||
let rejectSend: ((error: Error) => void) | null = null;
|
||||
let resolveSend: (() => void) | null = null;
|
||||
const sends: Array<{ recipient: FeedbackRecipient; attachment: FeedbackAttachment }> = [];
|
||||
const read = (): ReviewFeedbackSnapshot => ({
|
||||
comments,
|
||||
recipients,
|
||||
connected,
|
||||
attachment: makeAttachment(comments.filter((comment) => !unavailableIds.includes(comment.id))),
|
||||
});
|
||||
const ports: ReviewFeedbackPorts = {
|
||||
read,
|
||||
send: (recipient, attachment) => {
|
||||
sends.push({ recipient, attachment });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
resolveSend = resolve;
|
||||
rejectSend = reject;
|
||||
});
|
||||
},
|
||||
clearSent: (sent) => {
|
||||
comments = comments.filter(
|
||||
(current) =>
|
||||
!sent.some(
|
||||
(prior) =>
|
||||
prior.id === current.id &&
|
||||
prior.updatedAt === current.updatedAt &&
|
||||
prior.body === current.body,
|
||||
),
|
||||
);
|
||||
},
|
||||
failedMessage: () => "Failed to send",
|
||||
};
|
||||
const model = create(ports);
|
||||
return {
|
||||
model,
|
||||
ports,
|
||||
sends,
|
||||
comments: () => comments,
|
||||
setComments: (next: ReviewDraftComment[]) => {
|
||||
comments = next;
|
||||
model.refresh();
|
||||
},
|
||||
setRecipients: (ids: string[]) => {
|
||||
recipients = ids.map(makeRecipient);
|
||||
model.refresh();
|
||||
},
|
||||
disconnect: () => {
|
||||
connected = false;
|
||||
model.refresh();
|
||||
},
|
||||
succeed: () => resolveSend!(),
|
||||
fail: () => rejectSend!(new Error("Host rejected feedback")),
|
||||
};
|
||||
}
|
||||
|
||||
describe("review feedback", () => {
|
||||
it("counts only attached comments, freezes the sending count, and retains orphans", async () => {
|
||||
const feedback = setup(["one"], ["orphan"]);
|
||||
feedback.setComments([makeComment("first"), makeComment("orphan")]);
|
||||
expect(feedback.model.getState()).toMatchObject({ commentCount: 2, sendableCommentCount: 1 });
|
||||
const pending = feedback.model.press();
|
||||
feedback.setComments([makeComment("first"), makeComment("orphan"), makeComment("added")]);
|
||||
expect(feedback.model.getState()).toMatchObject({
|
||||
phase: { kind: "sending", commentCount: 1 },
|
||||
sendableCommentCount: 2,
|
||||
});
|
||||
expect(feedback.sends[0]!.attachment.commentCount).toBe(1);
|
||||
feedback.succeed();
|
||||
await pending;
|
||||
expect(feedback.comments()).toEqual([makeComment("orphan"), makeComment("added")]);
|
||||
});
|
||||
it("retains an entirely orphaned draft without claiming any comments are sendable", async () => {
|
||||
const feedback = setup(["one"], ["first"]);
|
||||
expect(feedback.model.getState()).toMatchObject({
|
||||
commentCount: 1,
|
||||
sendableCommentCount: 0,
|
||||
disabledReason: "no-context",
|
||||
canSend: false,
|
||||
});
|
||||
await feedback.model.press();
|
||||
expect(feedback.sends).toEqual([]);
|
||||
expect(feedback.comments()).toEqual([makeComment("first")]);
|
||||
});
|
||||
it("retains comments and explains why no workspace agent can receive them", async () => {
|
||||
const feedback = setup([]);
|
||||
await feedback.model.press();
|
||||
expect(feedback.model.getState()).toMatchObject({
|
||||
canSend: false,
|
||||
disabledReason: "no-agents",
|
||||
commentCount: 1,
|
||||
});
|
||||
expect(feedback.sends).toEqual([]);
|
||||
expect(feedback.comments()).toEqual([makeComment("first")]);
|
||||
});
|
||||
it("sends once to the only recipient and clears only sent versions", async () => {
|
||||
const feedback = setup(["one"]);
|
||||
const pending = feedback.model.press();
|
||||
await feedback.model.press();
|
||||
await feedback.model.send("one");
|
||||
expect(feedback.sends).toEqual([
|
||||
{ recipient: makeRecipient("one"), attachment: makeAttachment([makeComment("first")]) },
|
||||
]);
|
||||
feedback.setComments([makeComment("first", "Edited during send"), makeComment("added")]);
|
||||
feedback.succeed();
|
||||
await pending;
|
||||
expect(feedback.comments()).toEqual([
|
||||
makeComment("first", "Edited during send"),
|
||||
makeComment("added"),
|
||||
]);
|
||||
expect(feedback.model.getState().phase).toEqual({
|
||||
kind: "sent",
|
||||
recipient: makeRecipient("one"),
|
||||
});
|
||||
});
|
||||
it("clears unchanged sent comments while preserving additions", async () => {
|
||||
const feedback = setup(["one"]);
|
||||
const pending = feedback.model.press();
|
||||
feedback.setComments([makeComment("first"), makeComment("added")]);
|
||||
feedback.succeed();
|
||||
await pending;
|
||||
expect(feedback.comments()).toEqual([makeComment("added")]);
|
||||
});
|
||||
it("asks for a recipient when several tabs exist and validates the selection again", async () => {
|
||||
const feedback = setup(["one", "two"]);
|
||||
await feedback.model.press();
|
||||
expect(feedback.model.getState().phase).toEqual({ kind: "choosing" });
|
||||
expect(feedback.sends).toEqual([]);
|
||||
feedback.setRecipients(["one"]);
|
||||
await feedback.model.send("two");
|
||||
expect(feedback.sends).toEqual([]);
|
||||
const pending = feedback.model.send("one");
|
||||
feedback.succeed();
|
||||
await pending;
|
||||
expect(feedback.comments()).toEqual([]);
|
||||
});
|
||||
it("retains comments on failure and retries using the latest saved version", async () => {
|
||||
const feedback = setup(["one"]);
|
||||
const failed = feedback.model.press();
|
||||
feedback.fail();
|
||||
await failed;
|
||||
expect(feedback.model.getState().phase).toEqual({
|
||||
kind: "failed",
|
||||
message: "Host rejected feedback",
|
||||
});
|
||||
expect(feedback.comments()).toEqual([makeComment("first")]);
|
||||
feedback.setComments([makeComment("first", "Corrected before retry")]);
|
||||
const retried = feedback.model.press();
|
||||
feedback.succeed();
|
||||
await retried;
|
||||
expect(feedback.sends).toHaveLength(2);
|
||||
expect(feedback.sends[1]!.attachment.attachment.comments[0]!.body).toBe(
|
||||
"Corrected before retry",
|
||||
);
|
||||
expect(feedback.comments()).toEqual([]);
|
||||
});
|
||||
it("keeps workspace drafts independent and prevents disconnected sends", async () => {
|
||||
const first = setup(["one"]);
|
||||
const second = setup(["other"]);
|
||||
first.disconnect();
|
||||
await first.model.press();
|
||||
expect(first.model.getState().disabledReason).toBe("disconnected");
|
||||
const pending = second.model.press();
|
||||
second.succeed();
|
||||
await pending;
|
||||
expect(first.comments()).toEqual([makeComment("first")]);
|
||||
expect(first.sends).toEqual([]);
|
||||
expect(second.comments()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shared review submission ownership", () => {
|
||||
it("blocks another surface and reconnects to the pending draft while other drafts remain usable", async () => {
|
||||
const scope = createReviewFeedbackScope();
|
||||
const first = setup(["one"], [], (ports) => scope.connect("workspace-one", ports));
|
||||
const second = scope.connect("workspace-one", first.ports);
|
||||
const other = setup(["other"], [], (ports) => scope.connect("workspace-other", ports));
|
||||
const unsubscribe = first.model.subscribe(() => {});
|
||||
const pending = first.model.press();
|
||||
unsubscribe();
|
||||
await Promise.resolve();
|
||||
const reconnected = scope.connect("workspace-one", first.ports);
|
||||
expect(second.getState()).toMatchObject({ canSend: false, phase: { kind: "sending" } });
|
||||
await second.press();
|
||||
await reconnected.send("one");
|
||||
expect(first.sends).toHaveLength(1);
|
||||
const otherPending = other.model.press();
|
||||
expect(other.sends).toHaveLength(1);
|
||||
first.fail();
|
||||
await pending;
|
||||
expect(second.getState().phase).toEqual({ kind: "failed", message: "Host rejected feedback" });
|
||||
const retry = second.press();
|
||||
first.succeed();
|
||||
await retry;
|
||||
expect(first.sends).toHaveLength(2);
|
||||
other.succeed();
|
||||
await otherPending;
|
||||
});
|
||||
it("opens only the active surface's recipient chooser", async () => {
|
||||
const scope = createReviewFeedbackScope();
|
||||
const first = setup(["one", "two"], [], (ports) => scope.connect("same", ports));
|
||||
const second = scope.connect("same", first.ports);
|
||||
await first.model.press();
|
||||
expect(first.model.getState().phase).toEqual({ kind: "choosing" });
|
||||
expect(second.getState().phase).toEqual({ kind: "idle" });
|
||||
first.model.closeMenu();
|
||||
expect(first.model.getState().phase).toEqual({ kind: "idle" });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,177 @@
|
||||
import type { ComposerAttachment } from "@/attachments/types";
|
||||
import type { ReviewDraftComment } from "../state";
|
||||
import type { WorkspaceTabDescriptor } from "@/screens/workspace/workspace-tabs-types";
|
||||
|
||||
export interface FeedbackRecipient {
|
||||
agentId: string;
|
||||
tab: WorkspaceTabDescriptor;
|
||||
}
|
||||
export type FeedbackAttachment = Extract<ComposerAttachment, { kind: "review" }>;
|
||||
export interface ReviewFeedbackSnapshot {
|
||||
comments: readonly ReviewDraftComment[];
|
||||
attachment: FeedbackAttachment | null;
|
||||
recipients: readonly FeedbackRecipient[];
|
||||
connected: boolean;
|
||||
}
|
||||
export interface ReviewFeedbackPorts {
|
||||
read: () => ReviewFeedbackSnapshot;
|
||||
send: (recipient: FeedbackRecipient, attachment: FeedbackAttachment) => Promise<void>;
|
||||
clearSent: (comments: readonly ReviewDraftComment[]) => void;
|
||||
failedMessage: () => string;
|
||||
}
|
||||
export type FeedbackPhase =
|
||||
| { kind: "idle" }
|
||||
| { kind: "choosing" }
|
||||
| { kind: "sending"; recipient: FeedbackRecipient; commentCount: number }
|
||||
| { kind: "failed"; message: string }
|
||||
| { kind: "sent"; recipient: FeedbackRecipient };
|
||||
export interface ReviewFeedbackState {
|
||||
phase: FeedbackPhase;
|
||||
commentCount: number;
|
||||
sendableCommentCount: number;
|
||||
recipients: readonly FeedbackRecipient[];
|
||||
disabledReason: "no-agents" | "disconnected" | "no-context" | null;
|
||||
canSend: boolean;
|
||||
}
|
||||
|
||||
export function createReviewFeedback(ports: ReviewFeedbackPorts) {
|
||||
return createFeedbackView(ports, createFeedbackWorkflow());
|
||||
}
|
||||
|
||||
/** Surfaces share submission ownership while keeping their chooser and live inputs local. */
|
||||
export function createReviewFeedbackScope() {
|
||||
const workflows = new Map<string, ReturnType<typeof createFeedbackWorkflow>>();
|
||||
return {
|
||||
connect(key: string, ports: ReviewFeedbackPorts) {
|
||||
let workflow = workflows.get(key);
|
||||
if (!workflow) {
|
||||
const created = createFeedbackWorkflow(() => {
|
||||
if (workflows.get(key) === created) workflows.delete(key);
|
||||
});
|
||||
workflow = created;
|
||||
workflows.set(key, workflow);
|
||||
}
|
||||
return createFeedbackView(ports, workflow);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function createFeedbackWorkflow(onUnused: () => void = () => {}) {
|
||||
let phase: FeedbackPhase = { kind: "idle" };
|
||||
const observers = new Set<() => void>();
|
||||
function releaseIfUnused() {
|
||||
queueMicrotask(() => {
|
||||
if (observers.size === 0 && phase.kind !== "sending") onUnused();
|
||||
});
|
||||
}
|
||||
return {
|
||||
getPhase: () => phase,
|
||||
changePhase(next: FeedbackPhase) {
|
||||
phase = next;
|
||||
observers.forEach((observer) => observer());
|
||||
releaseIfUnused();
|
||||
},
|
||||
subscribe(observer: () => void) {
|
||||
observers.add(observer);
|
||||
return () => {
|
||||
observers.delete(observer);
|
||||
releaseIfUnused();
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function createFeedbackView(
|
||||
ports: ReviewFeedbackPorts,
|
||||
workflow: ReturnType<typeof createFeedbackWorkflow>,
|
||||
) {
|
||||
let choosing = false;
|
||||
const choosingPhase: FeedbackPhase = { kind: "choosing" };
|
||||
const getPhase = () => (choosing ? choosingPhase : workflow.getPhase());
|
||||
let state = deriveState(ports.read(), getPhase());
|
||||
const listeners = new Set<() => void>();
|
||||
function publish() {
|
||||
state = deriveState(ports.read(), getPhase());
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
async function send(agentId: string) {
|
||||
const snapshot = ports.read();
|
||||
const current = deriveState(snapshot, workflow.getPhase());
|
||||
const recipient = snapshot.recipients.find((candidate) => candidate.agentId === agentId);
|
||||
if (!current.canSend || !recipient || !snapshot.attachment) return;
|
||||
const attachment = snapshot.attachment;
|
||||
const sentComments = snapshot.comments.filter((comment) =>
|
||||
attachment.attachment.comments.some(
|
||||
(sent) =>
|
||||
sent.filePath === comment.filePath &&
|
||||
sent.side === comment.side &&
|
||||
sent.lineNumber === comment.lineNumber &&
|
||||
sent.body === comment.body,
|
||||
),
|
||||
);
|
||||
choosing = false;
|
||||
workflow.changePhase({ kind: "sending", recipient, commentCount: attachment.commentCount });
|
||||
publish();
|
||||
try {
|
||||
await ports.send(recipient, attachment);
|
||||
ports.clearSent(sentComments);
|
||||
workflow.changePhase({ kind: "sent", recipient });
|
||||
} catch (error) {
|
||||
workflow.changePhase({
|
||||
kind: "failed",
|
||||
message: error instanceof Error ? error.message : ports.failedMessage(),
|
||||
});
|
||||
}
|
||||
publish();
|
||||
}
|
||||
return {
|
||||
getState: () => {
|
||||
if (state.phase !== getPhase()) state = deriveState(ports.read(), getPhase());
|
||||
return state;
|
||||
},
|
||||
subscribe: (listener: () => void) => {
|
||||
listeners.add(listener);
|
||||
const unsubscribe = workflow.subscribe(() => {
|
||||
choosing = false;
|
||||
publish();
|
||||
});
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
unsubscribe();
|
||||
};
|
||||
},
|
||||
refresh: publish,
|
||||
press: async () => {
|
||||
const snapshot = ports.read();
|
||||
if (!deriveState(snapshot, workflow.getPhase()).canSend) return;
|
||||
if (snapshot.recipients.length === 1) {
|
||||
await send(snapshot.recipients[0]!.agentId);
|
||||
} else {
|
||||
choosing = true;
|
||||
publish();
|
||||
}
|
||||
},
|
||||
closeMenu: () => {
|
||||
if (choosing) {
|
||||
choosing = false;
|
||||
publish();
|
||||
}
|
||||
},
|
||||
send,
|
||||
};
|
||||
}
|
||||
|
||||
function deriveState(snapshot: ReviewFeedbackSnapshot, phase: FeedbackPhase): ReviewFeedbackState {
|
||||
let disabledReason: ReviewFeedbackState["disabledReason"] = null;
|
||||
if (snapshot.recipients.length === 0) disabledReason = "no-agents";
|
||||
else if (!snapshot.connected) disabledReason = "disconnected";
|
||||
else if (!snapshot.attachment) disabledReason = "no-context";
|
||||
return {
|
||||
phase,
|
||||
commentCount: snapshot.comments.length,
|
||||
sendableCommentCount: snapshot.attachment?.commentCount ?? 0,
|
||||
recipients: snapshot.recipients,
|
||||
disabledReason,
|
||||
canSend: snapshot.comments.length > 0 && disabledReason === null && phase.kind !== "sending",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
import { useCallback, useMemo, type ReactNode } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { Send } from "lucide-react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { useMenuContext } from "@/components/ui/menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { buttonControlHeight } from "@/components/ui/control-geometry";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { SPACING } from "@/styles/theme";
|
||||
import { FloatingActionButton } from "@/components/ui/floating-action-button";
|
||||
import {
|
||||
WorkspaceTabPresentationResolver,
|
||||
WorkspaceTabIcon,
|
||||
type WorkspaceTabPresentation,
|
||||
} from "@/screens/workspace/workspace-tab-presentation";
|
||||
import type { FeedbackRecipient, ReviewFeedbackState, createReviewFeedback } from "./index";
|
||||
|
||||
type FeedbackModel = ReturnType<typeof createReviewFeedback>;
|
||||
interface ReviewFeedbackActionProps {
|
||||
bottomOffset: number;
|
||||
model: FeedbackModel;
|
||||
state: ReviewFeedbackState;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}
|
||||
|
||||
export function ReviewFeedbackAction({
|
||||
enabled,
|
||||
hasDiff,
|
||||
...props
|
||||
}: Omit<ReviewFeedbackActionProps, "workspaceId"> & {
|
||||
workspaceId?: string | null;
|
||||
enabled: boolean | undefined;
|
||||
hasDiff: boolean;
|
||||
}) {
|
||||
if (enabled === false || !hasDiff) return null;
|
||||
return <OpenReviewFeedbackAction {...props} workspaceId={props.workspaceId ?? ""} />;
|
||||
}
|
||||
|
||||
function OpenReviewFeedbackAction({
|
||||
model,
|
||||
state,
|
||||
serverId,
|
||||
workspaceId,
|
||||
bottomOffset,
|
||||
}: ReviewFeedbackActionProps) {
|
||||
const { t } = useTranslation();
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const onOpenChange = useCallback(
|
||||
(open: boolean) => {
|
||||
if (!open) model.closeMenu();
|
||||
},
|
||||
[model],
|
||||
);
|
||||
const noteStyle = useMemo(
|
||||
() => [
|
||||
styles.note,
|
||||
!isCompact && styles.centered,
|
||||
{
|
||||
bottom:
|
||||
bottom +
|
||||
bottomOffset +
|
||||
(isCompact ? 88 : buttonControlHeight.sm + SPACING[4] + SPACING[2]),
|
||||
},
|
||||
],
|
||||
[bottom, bottomOffset, isCompact],
|
||||
);
|
||||
const sending = state.phase.kind === "sending";
|
||||
const label = t(sending ? "review.feedback.sending" : "review.feedback.send", {
|
||||
count: state.phase.kind === "sending" ? state.phase.commentCount : state.sendableCommentCount,
|
||||
});
|
||||
const unavailableNotice =
|
||||
state.disabledReason && state.commentCount > 0 ? (
|
||||
<Text style={styles.text}>{t(`review.feedback.${state.disabledReason}`)}</Text>
|
||||
) : null;
|
||||
let notice: ReactNode = unavailableNotice;
|
||||
if (state.phase.kind === "failed")
|
||||
notice = <Text style={styles.error}>{state.phase.message}</Text>;
|
||||
else if (state.phase.kind === "sent")
|
||||
notice = (
|
||||
<>
|
||||
<SentNotice
|
||||
recipient={state.phase.recipient}
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
/>
|
||||
{unavailableNotice}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{state.commentCount > 0 ? (
|
||||
<DropdownMenu
|
||||
open={state.phase.kind === "choosing"}
|
||||
onOpenChange={onOpenChange}
|
||||
compactMode="sheet"
|
||||
>
|
||||
<FeedbackTrigger
|
||||
model={model}
|
||||
label={label}
|
||||
disabled={!state.canSend}
|
||||
bottomInset={bottom + bottomOffset}
|
||||
/>
|
||||
<DropdownMenuContent
|
||||
side="top"
|
||||
align="center"
|
||||
sheetTitle={t("review.feedback.chooseAgent")}
|
||||
>
|
||||
{state.recipients.map((recipient) => (
|
||||
<RecipientOption
|
||||
key={recipient.tab.key}
|
||||
recipient={recipient}
|
||||
model={model}
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
/>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : null}
|
||||
{notice ? (
|
||||
<View style={noteStyle} accessibilityRole="alert">
|
||||
{notice}
|
||||
</View>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function FeedbackTrigger({
|
||||
model,
|
||||
label,
|
||||
disabled,
|
||||
bottomInset,
|
||||
}: {
|
||||
model: FeedbackModel;
|
||||
label: string;
|
||||
disabled: boolean;
|
||||
bottomInset: number;
|
||||
}) {
|
||||
const { triggerRef } = useMenuContext("FeedbackTrigger");
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const press = useCallback(() => {
|
||||
void model.press();
|
||||
}, [model]);
|
||||
if (!isCompact) {
|
||||
return (
|
||||
<View
|
||||
pointerEvents="box-none"
|
||||
style={[styles.wideAction, { bottom: bottomInset + SPACING[4] }]}
|
||||
>
|
||||
<Button
|
||||
ref={triggerRef}
|
||||
variant="default"
|
||||
size="sm"
|
||||
leftIcon={Send}
|
||||
accessibilityLabel={label}
|
||||
disabled={disabled}
|
||||
onPress={press}
|
||||
>
|
||||
{label}
|
||||
</Button>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<FloatingActionButton
|
||||
ref={triggerRef}
|
||||
icon={Send}
|
||||
label={label}
|
||||
accessibilityLabel={label}
|
||||
disabled={disabled}
|
||||
bottomInset={bottomInset}
|
||||
onPress={press}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function RecipientOption({
|
||||
recipient,
|
||||
model,
|
||||
serverId,
|
||||
workspaceId,
|
||||
}: {
|
||||
recipient: FeedbackRecipient;
|
||||
model: FeedbackModel;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}) {
|
||||
const choose = useCallback(() => {
|
||||
void model.send(recipient.agentId);
|
||||
}, [model, recipient.agentId]);
|
||||
const render = useCallback(
|
||||
(presentation: WorkspaceTabPresentation) => (
|
||||
<RecipientRow presentation={presentation} onSelect={choose} />
|
||||
),
|
||||
[choose],
|
||||
);
|
||||
return (
|
||||
<WorkspaceTabPresentationResolver
|
||||
tab={recipient.tab}
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
>
|
||||
{render}
|
||||
</WorkspaceTabPresentationResolver>
|
||||
);
|
||||
}
|
||||
|
||||
function RecipientRow({
|
||||
presentation,
|
||||
onSelect,
|
||||
}: {
|
||||
presentation: WorkspaceTabPresentation;
|
||||
onSelect: () => void;
|
||||
}) {
|
||||
const leading = useMemo(
|
||||
() => <WorkspaceTabIcon presentation={presentation} backdrop="surface0" />,
|
||||
[presentation],
|
||||
);
|
||||
return (
|
||||
<DropdownMenuItem leading={leading} onSelect={onSelect}>
|
||||
{presentation.label}
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
}
|
||||
|
||||
function SentNotice({
|
||||
recipient,
|
||||
serverId,
|
||||
workspaceId,
|
||||
}: {
|
||||
recipient: FeedbackRecipient;
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const render = useCallback(
|
||||
(presentation: WorkspaceTabPresentation) => (
|
||||
<Text style={styles.text}>
|
||||
{t("review.feedback.sent", { recipient: presentation.label })}
|
||||
</Text>
|
||||
),
|
||||
[t],
|
||||
);
|
||||
return (
|
||||
<WorkspaceTabPresentationResolver
|
||||
tab={recipient.tab}
|
||||
serverId={serverId}
|
||||
workspaceId={workspaceId}
|
||||
>
|
||||
{render}
|
||||
</WorkspaceTabPresentationResolver>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
wideAction: { position: "absolute", left: 0, right: 0, alignItems: "center" },
|
||||
centered: { alignItems: "center" },
|
||||
note: {
|
||||
position: "absolute",
|
||||
right: theme.spacing[4],
|
||||
left: theme.spacing[4],
|
||||
alignItems: "flex-end",
|
||||
},
|
||||
text: {
|
||||
color: theme.colors.foreground,
|
||||
fontSize: theme.fontSize.sm,
|
||||
backgroundColor: theme.colors.surface1,
|
||||
padding: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
},
|
||||
error: {
|
||||
color: theme.colors.destructive,
|
||||
fontSize: theme.fontSize.sm,
|
||||
backgroundColor: theme.colors.surface1,
|
||||
padding: theme.spacing[2],
|
||||
borderRadius: theme.borderRadius.md,
|
||||
},
|
||||
}));
|
||||
@@ -0,0 +1,120 @@
|
||||
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
||||
import {
|
||||
useReviewDraftComments,
|
||||
getReviewDraftComments,
|
||||
clearSentReviewDraftComments,
|
||||
} from "../store";
|
||||
import { useWorkspaceLayoutStore } from "@/stores/workspace-layout-store";
|
||||
import { buildWorkspaceTabPersistenceKey } from "@/workspace-tabs/model";
|
||||
import { deriveWorkspaceTabModel } from "@/screens/workspace/workspace-tab-model";
|
||||
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import { useAppSettings } from "@/hooks/use-settings";
|
||||
import { dispatchComposerAgentMessage } from "@/composer/actions";
|
||||
import { createMessageSubmissionWriter } from "@/composer/submission/writer";
|
||||
import { useSessionStore, selectAgentTurnPresentation } from "@/stores/session-store";
|
||||
import { FLOATING_ACTION_BUTTON_CLEARANCE } from "@/components/ui/floating-action-button";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { buttonControlHeight } from "@/components/ui/control-geometry";
|
||||
import { SPACING } from "@/styles/theme";
|
||||
import { i18n } from "@/i18n/i18next";
|
||||
import {
|
||||
createReviewFeedbackScope,
|
||||
type FeedbackAttachment,
|
||||
type FeedbackRecipient,
|
||||
} from "./index";
|
||||
|
||||
const feedbackScope = createReviewFeedbackScope();
|
||||
|
||||
export function useReviewFeedback(input: {
|
||||
reviewDraftKey: string;
|
||||
serverId: string;
|
||||
workspaceId?: string;
|
||||
attachment: FeedbackAttachment | null;
|
||||
}) {
|
||||
const { serverId, reviewDraftKey, workspaceId } = input;
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const workspaceKey = workspaceId
|
||||
? buildWorkspaceTabPersistenceKey({ serverId, workspaceId })
|
||||
: null;
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const connected = useHostRuntimeIsConnected(serverId);
|
||||
const { settings } = useAppSettings();
|
||||
const comments = useReviewDraftComments(reviewDraftKey);
|
||||
const layout = useWorkspaceLayoutStore((store) =>
|
||||
workspaceKey ? store.layoutByWorkspace[workspaceKey] : undefined,
|
||||
);
|
||||
// The adapter keeps live host and diff inputs available to commands without reconstructing the workflow.
|
||||
const live = useRef({
|
||||
client,
|
||||
connected,
|
||||
attachment: input.attachment,
|
||||
sendBehavior: settings.sendBehavior,
|
||||
});
|
||||
live.current = {
|
||||
client,
|
||||
connected,
|
||||
attachment: input.attachment,
|
||||
sendBehavior: settings.sendBehavior,
|
||||
};
|
||||
const model = useMemo(
|
||||
() =>
|
||||
feedbackScope.connect(reviewDraftKey, {
|
||||
read: () => ({
|
||||
comments: getReviewDraftComments(reviewDraftKey) ?? [],
|
||||
attachment: live.current.attachment,
|
||||
connected: live.current.connected,
|
||||
recipients: readRecipients(workspaceKey),
|
||||
}),
|
||||
send: async (recipient, attachment) => {
|
||||
const { client: targetClient, sendBehavior } = live.current;
|
||||
if (!targetClient) throw new Error(i18n.t("workspace.terminal.hostDisconnected"));
|
||||
const activeTurnBehavior = sendBehavior === "steer" ? "steer" : "interrupt";
|
||||
await dispatchComposerAgentMessage({
|
||||
client: targetClient,
|
||||
agentId: recipient.agentId,
|
||||
text: i18n.t("review.feedback.prompt"),
|
||||
attachments: [attachment],
|
||||
encodeImages: async () => [],
|
||||
submission: createMessageSubmissionWriter(serverId),
|
||||
activeTurnBehavior,
|
||||
activeTurnId:
|
||||
activeTurnBehavior === "steer"
|
||||
? (selectAgentTurnPresentation(
|
||||
useSessionStore.getState().sessions[serverId],
|
||||
recipient.agentId,
|
||||
).turnId ?? undefined)
|
||||
: undefined,
|
||||
});
|
||||
},
|
||||
clearSent: (sentComments) =>
|
||||
clearSentReviewDraftComments({ key: reviewDraftKey, comments: sentComments }),
|
||||
failedMessage: () => i18n.t("review.feedback.failed"),
|
||||
}),
|
||||
[reviewDraftKey, serverId, workspaceKey],
|
||||
);
|
||||
useEffect(() => {
|
||||
model.refresh();
|
||||
}, [model, comments, layout, connected, input.attachment]);
|
||||
const state = useSyncExternalStore(model.subscribe, model.getState, model.getState);
|
||||
return {
|
||||
model,
|
||||
state,
|
||||
clearance:
|
||||
state.commentCount > 0
|
||||
? (isCompact ? FLOATING_ACTION_BUTTON_CLEARANCE : buttonControlHeight.sm + SPACING[4]) + 44
|
||||
: 0,
|
||||
};
|
||||
}
|
||||
|
||||
function readRecipients(workspaceKey: string | null): FeedbackRecipient[] {
|
||||
const tabs = workspaceKey
|
||||
? useWorkspaceLayoutStore.getState().getWorkspaceTabs(workspaceKey)
|
||||
: [];
|
||||
const descriptors = deriveWorkspaceTabModel({ tabs }).tabs;
|
||||
const recipients: FeedbackRecipient[] = [];
|
||||
for (const { descriptor } of descriptors) {
|
||||
if (descriptor.target.kind === "agent")
|
||||
recipients.push({ agentId: descriptor.target.agentId, tab: descriptor });
|
||||
}
|
||||
return recipients;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ export interface InlineReviewActions {
|
||||
onStartComment: (target: ReviewableDiffTarget) => void;
|
||||
onEditComment: (target: ReviewableDiffTarget, comment: ReviewDraftComment) => void;
|
||||
onCancelEditor: () => void;
|
||||
onChangeEditorBody: (body: string) => void;
|
||||
onSaveEditor: (body: string) => void;
|
||||
onDeleteComment: (id: string) => void;
|
||||
}
|
||||
|
||||
@@ -31,3 +31,8 @@ export {
|
||||
SMALL_ACTION_HIT_SLOP,
|
||||
useInlineReviewController,
|
||||
} from "./surface";
|
||||
|
||||
export { ReviewCommentSheet } from "./comment-sheet";
|
||||
|
||||
export { useReviewFeedback } from "./feedback/use-feedback";
|
||||
export { ReviewFeedbackAction } from "./feedback/surface";
|
||||
|
||||
@@ -2,7 +2,16 @@ import { describe, expect, it } from "vitest";
|
||||
import type { StateStorage } from "zustand/middleware";
|
||||
import type { ParsedDiffFile } from "@/git/use-diff-query";
|
||||
import { createValidatedPersistStorage } from "@/storage/validated-persist-storage";
|
||||
import { buildReviewAttachmentSnapshot, buildReviewDraftKey } from "./store";
|
||||
import {
|
||||
buildReviewAttachmentSnapshot,
|
||||
buildReviewDraftKey,
|
||||
addReviewDraftComment,
|
||||
saveReviewDraftComment,
|
||||
clearSentReviewDraftComments,
|
||||
getReviewDraftComments,
|
||||
resetReviewDraftStore,
|
||||
useReviewDraftStore,
|
||||
} from "./store";
|
||||
import {
|
||||
addCommentToState,
|
||||
clearReviewInState,
|
||||
@@ -304,3 +313,49 @@ describe("buildReviewAttachmentSnapshot", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("successful feedback cleanup", () => {
|
||||
it("clears sent versions only, preserving edits, additions and other workspace drafts", () => {
|
||||
resetReviewDraftStore();
|
||||
const first = addReviewDraftComment({ key: "first", comment: makeComment() });
|
||||
const edited = addReviewDraftComment({
|
||||
key: "first",
|
||||
comment: makeComment({ id: "edited", body: "Before send" }),
|
||||
});
|
||||
const other = addReviewDraftComment({ key: "other", comment: makeComment({ id: "other" }) });
|
||||
useReviewDraftStore.getState().updateComment({
|
||||
key: "first",
|
||||
id: edited.id,
|
||||
updates: { body: "After send" },
|
||||
updatedAt: edited.updatedAt,
|
||||
});
|
||||
const added = addReviewDraftComment({ key: "first", comment: makeComment({ id: "added" }) });
|
||||
clearSentReviewDraftComments({ key: "first", comments: [first, edited] });
|
||||
expect(getReviewDraftComments("first")).toEqual([{ ...edited, body: "After send" }, added]);
|
||||
expect(getReviewDraftComments("other")).toEqual([other]);
|
||||
resetReviewDraftStore();
|
||||
});
|
||||
});
|
||||
|
||||
it("saves an acknowledged open edit as a new version and keeps subsequent edits on that record", () => {
|
||||
resetReviewDraftStore();
|
||||
const submitted = addReviewDraftComment({ key: "first", comment: makeComment() });
|
||||
clearSentReviewDraftComments({ key: "first", comments: [submitted] });
|
||||
saveReviewDraftComment({
|
||||
key: "first",
|
||||
id: submitted.id,
|
||||
comment: { ...submitted, body: "Open edit after acknowledgement" },
|
||||
});
|
||||
const restored = getReviewDraftComments("first")![0]!;
|
||||
expect(restored.body).toBe("Open edit after acknowledgement");
|
||||
expect(restored.id).not.toBe(submitted.id);
|
||||
clearSentReviewDraftComments({ key: "first", comments: [submitted] });
|
||||
expect(getReviewDraftComments("first")).toEqual([restored]);
|
||||
saveReviewDraftComment({
|
||||
key: "first",
|
||||
id: restored.id,
|
||||
comment: { ...restored, body: "Saved again" },
|
||||
});
|
||||
expect(getReviewDraftComments("first")).toMatchObject([{ id: restored.id, body: "Saved again" }]);
|
||||
resetReviewDraftStore();
|
||||
});
|
||||
|
||||
@@ -320,3 +320,43 @@ export function useReviewAttachmentSnapshot(input: {
|
||||
[comments, input.key, input.cwd, input.mode, input.baseRef, input.diffFiles],
|
||||
);
|
||||
}
|
||||
|
||||
/** Acknowledgement removes only the versions included in that submission. */
|
||||
export function clearSentReviewDraftComments(input: {
|
||||
key: string;
|
||||
comments: readonly ReviewDraftComment[];
|
||||
}): void {
|
||||
const sentById = new Map(input.comments.map((comment) => [comment.id, comment]));
|
||||
useReviewDraftStore.setState((state) => {
|
||||
const current = state.drafts[input.key];
|
||||
if (!current) return state;
|
||||
const remaining = current.filter((comment) => {
|
||||
const sent = sentById.get(comment.id);
|
||||
return !sent || sent.updatedAt !== comment.updatedAt || sent.body !== comment.body;
|
||||
});
|
||||
if (remaining.length === current.length) return state;
|
||||
return { drafts: { ...state.drafts, [input.key]: remaining } };
|
||||
});
|
||||
}
|
||||
|
||||
/** Acknowledgement can remove the original while the user still has an edit open. */
|
||||
export function saveReviewDraftComment(input: {
|
||||
key: string;
|
||||
id: string | null;
|
||||
comment: Pick<ReviewDraftComment, "filePath" | "side" | "lineNumber" | "body">;
|
||||
}): void {
|
||||
const store = useReviewDraftStore.getState();
|
||||
if (input.id && store.drafts[input.key]?.some((comment) => comment.id === input.id)) {
|
||||
store.updateComment({ key: input.key, id: input.id, updates: { body: input.comment.body } });
|
||||
} else {
|
||||
store.addComment({
|
||||
key: input.key,
|
||||
comment: {
|
||||
filePath: input.comment.filePath,
|
||||
side: input.comment.side,
|
||||
lineNumber: input.comment.lineNumber,
|
||||
body: input.comment.body,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,45 +9,24 @@ import { useReviewDraftStore, type ReviewDraftComment } from "./store";
|
||||
import { buildReviewableDiffTargetKey, type ReviewableDiffTarget } from "@/utils/diff-layout";
|
||||
import {
|
||||
getInlineReviewThreadState,
|
||||
getInlineReviewThreadViewportStyle,
|
||||
getSplitInlineReviewThreadState,
|
||||
type InlineReviewActions,
|
||||
} from "./geometry";
|
||||
import {
|
||||
getInlineReviewThreadViewportStyle,
|
||||
groupInlineReviewCommentsByTarget,
|
||||
InlineReviewEditor,
|
||||
InlineReviewGutterCell,
|
||||
InlineReviewThread,
|
||||
SMALL_ACTION_HIT_SLOP,
|
||||
useInlineReviewController,
|
||||
type InlineReviewActions,
|
||||
} from "./index";
|
||||
} from "./surface";
|
||||
|
||||
void testI18n;
|
||||
|
||||
const { theme, pressablePropsByLabel } = vi.hoisted(() => {
|
||||
const { pressablePropsByLabel } = vi.hoisted(() => {
|
||||
Object.assign(globalThis, { __DEV__: false });
|
||||
return {
|
||||
theme: {
|
||||
spacing: { 1: 4, 2: 8, 3: 12 },
|
||||
borderWidth: { 1: 1 },
|
||||
borderRadius: { base: 4, md: 6, lg: 8, xl: 12, full: 999 },
|
||||
opacity: { 50: 0.5 },
|
||||
fontSize: { xs: 11, sm: 13 },
|
||||
fontWeight: { normal: "400", medium: "500" },
|
||||
lineHeight: { diff: 18 },
|
||||
colors: {
|
||||
accent: "#0a84ff",
|
||||
accentForeground: "#fff",
|
||||
border: "#555",
|
||||
destructive: "#ff453a",
|
||||
foreground: "#fff",
|
||||
foregroundMuted: "#aaa",
|
||||
surface1: "#111",
|
||||
surface2: "#222",
|
||||
surface3: "#333",
|
||||
palette: { white: "#fff" },
|
||||
},
|
||||
},
|
||||
pressablePropsByLabel: new Map<string, Record<string, unknown>>(),
|
||||
};
|
||||
return { pressablePropsByLabel: new Map<string, Record<string, unknown>>() };
|
||||
});
|
||||
|
||||
vi.mock("react-native", async (importOriginal) => {
|
||||
@@ -88,13 +67,16 @@ vi.mock("react-native", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("react-native-unistyles", () => ({
|
||||
StyleSheet: {
|
||||
create: (factory: unknown) => (typeof factory === "function" ? factory(theme) : factory),
|
||||
},
|
||||
withUnistyles: <T,>(component: T) => component,
|
||||
useUnistyles: () => ({ theme, rt: { breakpoint: "md" } }),
|
||||
}));
|
||||
vi.mock("react-native-unistyles", async () => {
|
||||
const { darkTheme: theme } = await import("@/styles/theme");
|
||||
return {
|
||||
StyleSheet: {
|
||||
create: (factory: unknown) => (typeof factory === "function" ? factory(theme) : factory),
|
||||
},
|
||||
withUnistyles: <T,>(component: T) => component,
|
||||
useUnistyles: () => ({ theme, rt: { breakpoint: "md" } }),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@/constants/platform", () => ({
|
||||
getIsElectron: () => false,
|
||||
@@ -103,19 +85,6 @@ vi.mock("@/constants/platform", () => ({
|
||||
isWeb: true,
|
||||
}));
|
||||
|
||||
vi.mock("lucide-react-native", () => {
|
||||
const createIcon = (name: string) => (props: Record<string, unknown>) =>
|
||||
React.createElement("span", { ...props, "data-icon": name });
|
||||
return {
|
||||
Check: createIcon("Check"),
|
||||
CircleDot: createIcon("CircleDot"),
|
||||
Pencil: createIcon("Pencil"),
|
||||
Plus: createIcon("Plus"),
|
||||
Trash2: createIcon("Trash2"),
|
||||
X: createIcon("X"),
|
||||
};
|
||||
});
|
||||
|
||||
function target(overrides: Partial<ReviewableDiffTarget> = {}): ReviewableDiffTarget {
|
||||
return {
|
||||
filePath: "src/example.ts",
|
||||
@@ -147,6 +116,7 @@ function buildReviewActions(overrides: Partial<InlineReviewActions> = {}): Inlin
|
||||
onStartComment: vi.fn(),
|
||||
onEditComment: vi.fn(),
|
||||
onCancelEditor: vi.fn(),
|
||||
onChangeEditorBody: () => {},
|
||||
onSaveEditor: vi.fn(),
|
||||
onDeleteComment: vi.fn(),
|
||||
...overrides,
|
||||
@@ -312,8 +282,9 @@ describe("git diff inline review helpers", () => {
|
||||
|
||||
it("keeps the line number visible and only floats the plus for line hover", () => {
|
||||
const reviewTarget = target();
|
||||
const { container, queryByText, rerender } = render(
|
||||
const { queryByTestId, queryByText, rerender } = render(
|
||||
<InlineReviewGutterCell
|
||||
actionTestID="add-comment-glyph"
|
||||
reviewTarget={reviewTarget}
|
||||
comments={EMPTY_COMMENTS}
|
||||
isEditorOpen={false}
|
||||
@@ -324,10 +295,11 @@ describe("git diff inline review helpers", () => {
|
||||
);
|
||||
|
||||
expect(queryByText("2")).toBeTruthy();
|
||||
expect(container.querySelector("[data-icon='Plus']")).toBeNull();
|
||||
expect(queryByTestId("add-comment-glyph")).toBeNull();
|
||||
|
||||
rerender(
|
||||
<InlineReviewGutterCell
|
||||
actionTestID="add-comment-glyph"
|
||||
reviewTarget={reviewTarget}
|
||||
comments={COMMENT_LIST}
|
||||
isEditorOpen={false}
|
||||
@@ -338,10 +310,11 @@ describe("git diff inline review helpers", () => {
|
||||
);
|
||||
|
||||
expect(queryByText("2")).toBeTruthy();
|
||||
expect(container.querySelector("[data-icon='Plus']")).toBeNull();
|
||||
expect(queryByTestId("add-comment-glyph")).toBeNull();
|
||||
|
||||
rerender(
|
||||
<InlineReviewGutterCell
|
||||
actionTestID="add-comment-glyph"
|
||||
reviewTarget={reviewTarget}
|
||||
comments={EMPTY_COMMENTS}
|
||||
isEditorOpen
|
||||
@@ -352,10 +325,11 @@ describe("git diff inline review helpers", () => {
|
||||
);
|
||||
|
||||
expect(queryByText("2")).toBeTruthy();
|
||||
expect(container.querySelector("[data-icon='Plus']")).toBeNull();
|
||||
expect(queryByTestId("add-comment-glyph")).toBeNull();
|
||||
|
||||
rerender(
|
||||
<InlineReviewGutterCell
|
||||
actionTestID="add-comment-glyph"
|
||||
reviewTarget={reviewTarget}
|
||||
comments={COMMENT_LIST}
|
||||
isEditorOpen={false}
|
||||
@@ -367,7 +341,7 @@ describe("git diff inline review helpers", () => {
|
||||
);
|
||||
|
||||
expect(queryByText("2")).toBeTruthy();
|
||||
expect(container.querySelector("[data-icon='Plus']")).toBeTruthy();
|
||||
expect(queryByTestId("add-comment-glyph")).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -384,7 +358,7 @@ describe("InlineReviewEditor", () => {
|
||||
const onCancel = vi.fn();
|
||||
const onSave = vi.fn();
|
||||
const { getByTestId } = render(
|
||||
<InlineReviewEditor
|
||||
<ReviewEditorFixture
|
||||
initialBody=" initial "
|
||||
onCancel={onCancel}
|
||||
onSave={onSave}
|
||||
@@ -404,7 +378,7 @@ describe("InlineReviewEditor", () => {
|
||||
const onCancel = vi.fn();
|
||||
const onSave = vi.fn();
|
||||
const { getByTestId } = render(
|
||||
<InlineReviewEditor
|
||||
<ReviewEditorFixture
|
||||
initialBody="ready"
|
||||
onCancel={onCancel}
|
||||
onSave={onSave}
|
||||
@@ -428,7 +402,7 @@ describe("InlineReviewEditor", () => {
|
||||
removeEventListener: vi.fn(),
|
||||
});
|
||||
const { getByTestId, queryByText } = render(
|
||||
<InlineReviewEditor
|
||||
<ReviewEditorFixture
|
||||
initialBody="ready"
|
||||
onCancel={vi.fn()}
|
||||
onSave={vi.fn()}
|
||||
@@ -472,3 +446,13 @@ describe("InlineReviewThread", () => {
|
||||
expect(actions.onDeleteComment).toHaveBeenCalledWith("comment-1");
|
||||
});
|
||||
});
|
||||
|
||||
function ReviewEditorFixture({
|
||||
initialBody,
|
||||
...props
|
||||
}: Omit<React.ComponentProps<typeof InlineReviewEditor>, "body" | "onChangeBody"> & {
|
||||
initialBody: string;
|
||||
}) {
|
||||
const [body, onChangeBody] = React.useState(initialBody);
|
||||
return <InlineReviewEditor {...props} body={body} onChangeBody={onChangeBody} />;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
useSyncExternalStore,
|
||||
} from "react";
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Plus, Trash2 } from "lucide-react-native";
|
||||
@@ -17,10 +24,17 @@ import {
|
||||
EditingTextInput as TextInput,
|
||||
type EditingTextInputHandle,
|
||||
} from "@/components/ui/text-input";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { createReviewEditorScope } from "./editor";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { inlineUnistylesStyle } from "@/styles/unistyles-inline-style";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { useReviewDraftComments, useReviewDraftStore, type ReviewDraftComment } from "./store";
|
||||
import {
|
||||
useReviewDraftComments,
|
||||
useReviewDraftStore,
|
||||
saveReviewDraftComment,
|
||||
type ReviewDraftComment,
|
||||
} from "./store";
|
||||
import { buildReviewableDiffTargetKey, type ReviewableDiffTarget } from "@/utils/diff-layout";
|
||||
import {
|
||||
INLINE_REVIEW_EDITOR_HEIGHT,
|
||||
@@ -98,92 +112,42 @@ export function groupInlineReviewCommentsByTarget(
|
||||
return grouped;
|
||||
}
|
||||
|
||||
export function useInlineReviewController(input: { reviewDraftKey: string }): InlineReviewActions {
|
||||
const reviewEditors = createReviewEditorScope({
|
||||
saveComment: saveReviewDraftComment,
|
||||
deleteComment: (input) => useReviewDraftStore.getState().deleteComment(input),
|
||||
});
|
||||
|
||||
export function useInlineReviewController(input: {
|
||||
reviewDraftKey: string;
|
||||
presentation?: string;
|
||||
}): InlineReviewActions & {
|
||||
sheetEditor: InlineReviewEditorState | null;
|
||||
onChangeEditorBody: (body: string) => void;
|
||||
} {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const reviewComments = useReviewDraftComments(input.reviewDraftKey);
|
||||
const commentsByTarget = useMemo(
|
||||
() => groupInlineReviewCommentsByTarget(reviewComments),
|
||||
[reviewComments],
|
||||
);
|
||||
const [editor, setEditor] = useState<InlineReviewEditorState | null>(null);
|
||||
const addComment = useReviewDraftStore((state) => state.addComment);
|
||||
const updateComment = useReviewDraftStore((state) => state.updateComment);
|
||||
const deleteComment = useReviewDraftStore((state) => state.deleteComment);
|
||||
|
||||
useEffect(() => {
|
||||
setEditor(null);
|
||||
}, [input.reviewDraftKey]);
|
||||
|
||||
const handleStartComment = useCallback((target: ReviewableDiffTarget) => {
|
||||
setEditor({ target, commentId: null, body: "" });
|
||||
}, []);
|
||||
|
||||
const handleEditComment = useCallback(
|
||||
(target: ReviewableDiffTarget, comment: ReviewDraftComment) => {
|
||||
setEditor({ target, commentId: comment.id, body: comment.body });
|
||||
},
|
||||
[],
|
||||
const model = useMemo(
|
||||
() => reviewEditors.forDraft(input.reviewDraftKey, input.presentation ?? "diff"),
|
||||
[input.reviewDraftKey, input.presentation],
|
||||
);
|
||||
|
||||
const handleCancelEditor = useCallback(() => {
|
||||
setEditor(null);
|
||||
}, []);
|
||||
|
||||
const handleSaveEditor = useCallback(
|
||||
(body: string) => {
|
||||
const trimmedBody = body.trim();
|
||||
if (!editor || trimmedBody.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor.commentId) {
|
||||
updateComment({
|
||||
key: input.reviewDraftKey,
|
||||
id: editor.commentId,
|
||||
updates: { body: trimmedBody },
|
||||
});
|
||||
} else {
|
||||
addComment({
|
||||
key: input.reviewDraftKey,
|
||||
comment: {
|
||||
filePath: editor.target.filePath,
|
||||
side: editor.target.side,
|
||||
lineNumber: editor.target.lineNumber,
|
||||
body: trimmedBody,
|
||||
},
|
||||
});
|
||||
}
|
||||
setEditor(null);
|
||||
},
|
||||
[addComment, editor, input.reviewDraftKey, updateComment],
|
||||
);
|
||||
|
||||
const handleDeleteComment = useCallback(
|
||||
(id: string) => {
|
||||
deleteComment({ key: input.reviewDraftKey, id });
|
||||
setEditor((current) => (current?.commentId === id ? null : current));
|
||||
},
|
||||
[deleteComment, input.reviewDraftKey],
|
||||
);
|
||||
|
||||
return useMemo<InlineReviewActions>(
|
||||
const editor = useSyncExternalStore(model.subscribe, model.getState, model.getState);
|
||||
return useMemo(
|
||||
() => ({
|
||||
commentsByTarget,
|
||||
editor,
|
||||
onStartComment: handleStartComment,
|
||||
onEditComment: handleEditComment,
|
||||
onCancelEditor: handleCancelEditor,
|
||||
onSaveEditor: handleSaveEditor,
|
||||
onDeleteComment: handleDeleteComment,
|
||||
editor: isCompact ? null : editor,
|
||||
sheetEditor: isCompact ? editor : null,
|
||||
onChangeEditorBody: model.setBody,
|
||||
onStartComment: model.start,
|
||||
onEditComment: model.edit,
|
||||
onCancelEditor: model.cancel,
|
||||
onSaveEditor: model.save,
|
||||
onDeleteComment: model.delete,
|
||||
}),
|
||||
[
|
||||
commentsByTarget,
|
||||
editor,
|
||||
handleCancelEditor,
|
||||
handleDeleteComment,
|
||||
handleEditComment,
|
||||
handleSaveEditor,
|
||||
handleStartComment,
|
||||
],
|
||||
[commentsByTarget, editor, isCompact, model],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -321,7 +285,8 @@ export function InlineReviewThread({
|
||||
const editorElement = editor ? (
|
||||
<InlineReviewEditor
|
||||
key={editingCommentId ?? "new"}
|
||||
initialBody={editor.body}
|
||||
body={editor.body}
|
||||
onChangeBody={reviewActions.onChangeEditorBody}
|
||||
onCancel={reviewActions.onCancelEditor}
|
||||
onSave={reviewActions.onSaveEditor}
|
||||
testID="inline-review-editor"
|
||||
@@ -428,19 +393,20 @@ export function getInlineReviewThreadViewportStyle({
|
||||
}
|
||||
|
||||
export function InlineReviewEditor({
|
||||
initialBody,
|
||||
body,
|
||||
onChangeBody,
|
||||
onCancel,
|
||||
onSave,
|
||||
testID,
|
||||
}: {
|
||||
initialBody: string;
|
||||
body: string;
|
||||
onChangeBody: (body: string) => void;
|
||||
onCancel: () => void;
|
||||
onSave: (body: string) => void;
|
||||
testID?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const inputRef = useRef<EditingTextInputHandle | null>(null);
|
||||
const [body, setBody] = useState(initialBody);
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
const trimmedBody = body.trim();
|
||||
const canSave = trimmedBody.length > 0;
|
||||
@@ -506,7 +472,7 @@ export function InlineReviewEditor({
|
||||
placeholderTextColor={styles.placeholderColor.color}
|
||||
multiline
|
||||
initialValue={body}
|
||||
onChangeText={setBody}
|
||||
onChangeText={onChangeBody}
|
||||
onFocus={handleFocus}
|
||||
onBlur={handleBlur}
|
||||
style={inputStyle}
|
||||
|
||||
@@ -33,6 +33,10 @@ type ProjectListResult = Awaited<ReturnType<DaemonClient["listProjects"]>>;
|
||||
type AgentFetchResult = Awaited<ReturnType<DaemonClient["fetchAgents"]>>;
|
||||
|
||||
class FakeDirectoryClient {
|
||||
supportsBackgroundWorkspaces(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
supportsWorkspaceLabels = false;
|
||||
listWorkspaceLabelsCalls = 0;
|
||||
fetchAgentsCalls = 0;
|
||||
|
||||
@@ -535,6 +535,7 @@ export class DirectorySync {
|
||||
let subscribe = initialSubscribe;
|
||||
while (true) {
|
||||
const query: Parameters<DaemonClient["observeWorkspaces"]>[0] = {
|
||||
...(client.supportsBackgroundWorkspaces() ? { includeBackground: true } : {}),
|
||||
sort: [{ key: "activity_at", direction: "desc" }],
|
||||
page: cursor ? { limit: PAGE_LIMIT, cursor } : { limit: PAGE_LIMIT },
|
||||
...(supportsDirectorySync
|
||||
@@ -634,6 +635,7 @@ export class DirectorySync {
|
||||
const limit = input.page?.limit ?? PAGE_LIMIT;
|
||||
const query: Omit<FetchAgentsOptions, "subscribe"> = {
|
||||
...(input.filter ? { filter: input.filter } : { scope: "active" as const }),
|
||||
...(client.supportsBackgroundWorkspaces() ? { includeBackground: true } : {}),
|
||||
sort: AGENT_SORT,
|
||||
page: cursor ? { limit, cursor } : { limit },
|
||||
...(!input.filter && cursor === null && this.supportsDirectorySync()
|
||||
|
||||
@@ -52,6 +52,9 @@ it("requests the managed connection credential through desktop main without a we
|
||||
});
|
||||
|
||||
class FakeDaemonClient {
|
||||
supportsBackgroundWorkspaces(): boolean {
|
||||
return false;
|
||||
}
|
||||
private state: ConnectionState = { status: "idle" };
|
||||
private listeners = new Set<(status: ConnectionState) => void>();
|
||||
private error: string | null = null;
|
||||
|
||||
@@ -859,3 +859,36 @@ describe("ReplicaCache", () => {
|
||||
expect(storage.cleanups).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it("retains semantic agent messages across disk-cache reconstruction", async () => {
|
||||
const storage = new MemoryStorage();
|
||||
const writer = createCache(storage);
|
||||
const value = timeline();
|
||||
value.items = [
|
||||
{
|
||||
kind: "tool_call",
|
||||
id: "delivery",
|
||||
timestamp: new Date(1),
|
||||
timelineCursor: { epoch: "epoch-1", seq: 12 },
|
||||
payload: {
|
||||
source: "agent",
|
||||
data: {
|
||||
provider: "codex",
|
||||
callId: "delivery",
|
||||
name: "agent_message",
|
||||
status: "completed",
|
||||
error: null,
|
||||
detail: { type: "plain_text", text: "Done" },
|
||||
agentMessage: {
|
||||
event: "finished",
|
||||
sender: { id: "remote::worker", title: "Reviewer" },
|
||||
text: "Done",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
writer.commitTimeline(SERVER_ID, "agent-1", value);
|
||||
await writer.flush();
|
||||
expect(await createCache(storage).readTimeline(SERVER_ID, "agent-1")).toEqual(value);
|
||||
});
|
||||
|
||||
@@ -421,6 +421,7 @@ function serializeAgentToolCall(data: AgentToolCallData): StoredToolCall {
|
||||
name: data.name,
|
||||
detail: data.detail,
|
||||
...(data.metadata ? { metadata: data.metadata } : {}),
|
||||
...(data.agentMessage ? { agentMessage: data.agentMessage } : {}),
|
||||
};
|
||||
switch (data.status) {
|
||||
case "running":
|
||||
@@ -584,6 +585,7 @@ function deserializeBuiltinTimelineItem(
|
||||
error: tool.error,
|
||||
detail: tool.detail,
|
||||
...(tool.metadata ? { metadata: tool.metadata } : {}),
|
||||
...(tool.agentMessage ? { agentMessage: tool.agentMessage } : {}),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@ import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ProviderSnapshotEntry } from "@getpaseo/protocol/agent-types";
|
||||
import type { MutableDaemonConfig } from "@getpaseo/protocol/messages";
|
||||
import { ToastApiProvider } from "@/contexts/toast-api-context";
|
||||
|
||||
const { theme, snapshotState, configState, patchConfigMock, openProviderSettingsMock } = vi.hoisted(
|
||||
() => ({
|
||||
@@ -282,12 +281,6 @@ vi.mock("@/utils/confirm-dialog", () => ({
|
||||
|
||||
import { ProvidersSection } from "./providers-section";
|
||||
|
||||
function unexpectedToast(): never {
|
||||
throw new Error("Provider row interactions should not display a toast");
|
||||
}
|
||||
|
||||
const toastApi = { show: unexpectedToast, copied: unexpectedToast, error: unexpectedToast };
|
||||
|
||||
const claudeEntry: ProviderSnapshotEntry = {
|
||||
provider: "claude",
|
||||
status: "ready",
|
||||
@@ -373,11 +366,7 @@ describe("ProvidersSection", () => {
|
||||
|
||||
function render(): void {
|
||||
act(() => {
|
||||
root?.render(
|
||||
<ToastApiProvider api={toastApi}>
|
||||
<ProvidersSection serverId="server-1" />
|
||||
</ToastApiProvider>,
|
||||
);
|
||||
root?.render(<ProvidersSection serverId="server-1" />);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "react-native";
|
||||
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useToast } from "@/contexts/toast-api-context";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import { useHostFeature } from "@/runtime/host-features";
|
||||
@@ -20,7 +19,6 @@ import { useDaemonConfig } from "@/hooks/use-daemon-config";
|
||||
import { buildProviderDefinitions } from "@/utils/provider-definitions";
|
||||
import {
|
||||
buildAcpProviderConfigPatch,
|
||||
getAcpProviderCatalog,
|
||||
type AcpProviderCatalogItem,
|
||||
} from "@/hooks/use-acp-provider-catalog";
|
||||
import { ProviderCatalogList } from "@/components/provider-catalog-list";
|
||||
@@ -327,12 +325,10 @@ export interface ProvidersSectionProps {
|
||||
|
||||
export function ProvidersSection({ serverId }: ProvidersSectionProps) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const isConnected = useHostRuntimeIsConnected(serverId);
|
||||
const supportsHopliteProvider = useHostFeature(serverId, "hopliteProvider");
|
||||
const supportsProviderRemoval = useHostFeature(serverId, "providerRemoval");
|
||||
const { entries, isLoading, refresh } = useProvidersSnapshot(serverId);
|
||||
const { config, patchConfig } = useDaemonConfig(serverId);
|
||||
const { patchConfig } = useDaemonConfig(serverId);
|
||||
const openProviderSettings = useProviderSettingsStore((state) => state.open);
|
||||
const [pendingProviderId, setPendingProviderId] = useState<string | null>(null);
|
||||
const [removingProviderId, setRemovingProviderId] = useState<string | null>(null);
|
||||
@@ -342,19 +338,6 @@ export function ProvidersSection({ serverId }: ProvidersSectionProps) {
|
||||
const providerDefinitions = useMemo(() => buildProviderDefinitions(entries), [entries]);
|
||||
const hasServer = serverId.length > 0;
|
||||
|
||||
/** Config owns derived providers and opt-in bundled catalog providers. */
|
||||
const isConfigOwnedProvider = useCallback(
|
||||
(providerId: string) =>
|
||||
Boolean(
|
||||
config?.providers?.[providerId] &&
|
||||
(config.providers[providerId].extends ||
|
||||
getAcpProviderCatalog().some(
|
||||
(entry) => entry.id === providerId && entry.bundledProvider,
|
||||
)),
|
||||
),
|
||||
[config],
|
||||
);
|
||||
|
||||
const handleOpenProviderSettings = useCallback(
|
||||
(providerId: string) => {
|
||||
openProviderSettings({ serverId, provider: providerId });
|
||||
@@ -416,15 +399,18 @@ export function ProvidersSection({ serverId }: ProvidersSectionProps) {
|
||||
if (installingProviderId) return;
|
||||
setInstallingProviderId(entry.id);
|
||||
try {
|
||||
await patchConfig(buildAcpProviderConfigPatch(entry, supportsHopliteProvider));
|
||||
await patchConfig(buildAcpProviderConfigPatch(entry));
|
||||
await refresh([entry.id]);
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : String(error));
|
||||
Alert.alert(
|
||||
t("settings.providers.addErrorTitle"),
|
||||
error instanceof Error ? error.message : String(error),
|
||||
);
|
||||
} finally {
|
||||
setInstallingProviderId((current) => (current === entry.id ? null : current));
|
||||
}
|
||||
},
|
||||
[installingProviderId, patchConfig, refresh, supportsHopliteProvider, toast],
|
||||
[installingProviderId, patchConfig, refresh, t],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -458,11 +444,7 @@ export function ProvidersSection({ serverId }: ProvidersSectionProps) {
|
||||
enabled={entry.enabled ?? true}
|
||||
isToggling={pendingProviderId === def.id}
|
||||
isRemoving={removingProviderId === def.id}
|
||||
canRemove={
|
||||
supportsProviderRemoval &&
|
||||
entry.source === "custom" &&
|
||||
isConfigOwnedProvider(def.id)
|
||||
}
|
||||
canRemove={supportsProviderRemoval && entry.source === "custom"}
|
||||
isFirst={index === 0}
|
||||
onPress={handleOpenProviderSettings}
|
||||
onToggleEnabled={handleToggleEnabled}
|
||||
|
||||
@@ -113,6 +113,7 @@ export interface WorkspaceDescriptor {
|
||||
worktreeSlug?: WorkspaceDescriptorPayload["worktreeSlug"];
|
||||
projectKind: WorkspaceDescriptorPayload["projectKind"];
|
||||
workspaceKind: WorkspaceDescriptorPayload["workspaceKind"];
|
||||
background?: boolean;
|
||||
name: string;
|
||||
title?: string | null;
|
||||
pinnedAt?: string | null;
|
||||
@@ -150,6 +151,7 @@ export function normalizeWorkspaceDescriptor(
|
||||
worktreeSlug: payload.worktreeSlug,
|
||||
projectKind: payload.projectKind,
|
||||
workspaceKind: payload.workspaceKind,
|
||||
background: payload.background ?? false,
|
||||
name: payload.name,
|
||||
title: payload.title ?? null,
|
||||
pinnedAt: payload.pinnedAt ?? null,
|
||||
|
||||
@@ -32,6 +32,7 @@ function createMemoryStorage(entries: Record<string, string | null>): MemoryStor
|
||||
describe("sidebar view store", () => {
|
||||
beforeEach(() => {
|
||||
useSidebarViewStore.setState({
|
||||
showBackground: false,
|
||||
groupMode: "project",
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
@@ -84,6 +85,7 @@ describe("sidebar view store", () => {
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
showBackground: false,
|
||||
groupMode: "status",
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
@@ -98,6 +100,7 @@ describe("sidebar view store", () => {
|
||||
hostFilter: "host-a",
|
||||
}),
|
||||
).toEqual({
|
||||
showBackground: false,
|
||||
groupMode: "status",
|
||||
hostFilters: ["host-a"],
|
||||
projectFilters: [],
|
||||
@@ -112,6 +115,7 @@ describe("sidebar view store", () => {
|
||||
hostFilters: ["host-a", "host-b"],
|
||||
}),
|
||||
).toEqual({
|
||||
showBackground: false,
|
||||
groupMode: "status",
|
||||
hostFilters: ["host-a", "host-b"],
|
||||
projectFilters: [],
|
||||
@@ -222,6 +226,7 @@ describe("sidebar view store", () => {
|
||||
projectFilters: ["project-a", "project-b"],
|
||||
}),
|
||||
).toEqual({
|
||||
showBackground: false,
|
||||
groupMode: "project",
|
||||
hostFilters: ["host-a"],
|
||||
projectFilters: ["project-a", "project-b"],
|
||||
@@ -231,6 +236,7 @@ describe("sidebar view store", () => {
|
||||
|
||||
it("never keeps project filters from state the schema rejects", () => {
|
||||
expect(migrateSidebarViewState({ projectFilters: "project-a" })).toEqual({
|
||||
showBackground: false,
|
||||
groupMode: "project",
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
|
||||
@@ -9,7 +9,7 @@ export type SidebarGroupMode = "project" | "status";
|
||||
|
||||
const SIDEBAR_VIEW_STORAGE_KEY = "sidebar-view";
|
||||
const LEGACY_SIDEBAR_GROUP_MODE_STORAGE_KEY = "sidebar-group-mode";
|
||||
const SIDEBAR_VIEW_STORE_VERSION = 6;
|
||||
const SIDEBAR_VIEW_STORE_VERSION = 7;
|
||||
|
||||
/**
|
||||
* The key standing for "this workspace carries no labels at all".
|
||||
@@ -47,6 +47,7 @@ function toggleFilterEntry(list: readonly string[], key: string): string[] {
|
||||
|
||||
interface SidebarViewStoreState {
|
||||
groupMode: SidebarGroupMode;
|
||||
showBackground: boolean;
|
||||
// Empty means "all hosts". A non-empty list pins the sidebar to those hosts.
|
||||
hostFilters: string[];
|
||||
/**
|
||||
@@ -61,6 +62,7 @@ interface SidebarViewStoreState {
|
||||
*/
|
||||
projectFilters: string[];
|
||||
labelFilter: SidebarLabelFilter;
|
||||
toggleBackground: () => void;
|
||||
setGroupMode: (mode: SidebarGroupMode) => void;
|
||||
toggleHostFilter: (serverId: string) => void;
|
||||
clearHostFilters: () => void;
|
||||
@@ -74,6 +76,7 @@ interface SidebarViewStoreState {
|
||||
|
||||
interface SidebarViewPersistedState {
|
||||
groupMode: SidebarGroupMode;
|
||||
showBackground: boolean;
|
||||
hostFilters: string[];
|
||||
projectFilters: string[];
|
||||
labelFilter: SidebarLabelFilter;
|
||||
@@ -84,6 +87,7 @@ const SidebarLabelFilterSchema = z.object({
|
||||
labels: z.array(z.string()),
|
||||
});
|
||||
const SidebarViewPersistedStateSchema = z.strictObject({
|
||||
showBackground: z.boolean().optional(),
|
||||
groupMode: PersistedSidebarGroupModeSchema.optional(),
|
||||
hostFilters: z.array(z.string()).optional(),
|
||||
hostFilter: z.string().nullable().optional(),
|
||||
@@ -122,6 +126,7 @@ export function migrateSidebarViewState(persistedState: unknown): SidebarViewPer
|
||||
const result = SidebarViewPersistedStateSchema.safeParse(persistedState);
|
||||
if (!result.success) {
|
||||
return {
|
||||
showBackground: false,
|
||||
groupMode: "project",
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
@@ -133,6 +138,7 @@ export function migrateSidebarViewState(persistedState: unknown): SidebarViewPer
|
||||
const legacyGroupMode = readLegacyGroupMode(state);
|
||||
if (legacyGroupMode) {
|
||||
return {
|
||||
showBackground: false,
|
||||
groupMode: legacyGroupMode,
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
@@ -141,6 +147,7 @@ export function migrateSidebarViewState(persistedState: unknown): SidebarViewPer
|
||||
}
|
||||
|
||||
return {
|
||||
showBackground: state.showBackground ?? false,
|
||||
groupMode: state.groupMode === "status" ? "status" : "project",
|
||||
hostFilters: readHostFilters(state),
|
||||
projectFilters: state.projectFilters ?? [],
|
||||
@@ -178,10 +185,12 @@ export function createSidebarViewStorage(
|
||||
export const useSidebarViewStore = create<SidebarViewStoreState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
showBackground: false,
|
||||
groupMode: "project",
|
||||
hostFilters: [],
|
||||
projectFilters: [],
|
||||
labelFilter: emptyLabelFilter(),
|
||||
toggleBackground: () => set((state) => ({ showBackground: !state.showBackground })),
|
||||
setGroupMode: (mode) => set({ groupMode: mode }),
|
||||
toggleHostFilter: (serverId) =>
|
||||
set((state) => ({ hostFilters: toggleFilterEntry(state.hostFilters, serverId) })),
|
||||
@@ -228,6 +237,7 @@ export const useSidebarViewStore = create<SidebarViewStoreState>()(
|
||||
SidebarViewPersistedStateSchema,
|
||||
),
|
||||
partialize: (state) => ({
|
||||
showBackground: state.showBackground ?? false,
|
||||
groupMode: state.groupMode,
|
||||
hostFilters: state.hostFilters,
|
||||
projectFilters: state.projectFilters,
|
||||
|
||||
@@ -92,3 +92,42 @@ describe("tool-call presentation", () => {
|
||||
expect(presentation.icon).toBe(fakeIcons.brain);
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
["message", "Message from QA messenger"],
|
||||
["finished", "QA messenger finished"],
|
||||
["errored", "QA messenger errored"],
|
||||
["permission-required", "QA messenger needs permission"],
|
||||
["closed", "QA messenger closed"],
|
||||
] as const)("presents %s from structured provenance without a second label", (event, heading) => {
|
||||
const presentation = buildToolCallPresentation({
|
||||
toolName: "internal_name_should_not_be_visible",
|
||||
status: "completed",
|
||||
error: null,
|
||||
detail: { type: "plain_text", label: "legacy summary", text: "legacy body" },
|
||||
agentMessage: {
|
||||
event,
|
||||
sender: { id: "server::sender", title: "QA messenger" },
|
||||
text: "The delivered message.",
|
||||
},
|
||||
resolveIcon: fakeResolveIcon,
|
||||
});
|
||||
expect(presentation.displayName).toBe(heading);
|
||||
expect(presentation.summary).toBeUndefined();
|
||||
expect(presentation.detail).toEqual({
|
||||
type: "plain_text",
|
||||
icon: "bot",
|
||||
text: "From agent: server::sender\n\nThe delivered message.",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses an opaque sender ID when no title is available", () => {
|
||||
const presentation = buildToolCallPresentation({
|
||||
toolName: "agent_message",
|
||||
status: "completed",
|
||||
error: null,
|
||||
agentMessage: { event: "message", sender: { id: "remote::worker" }, text: "Hello" },
|
||||
resolveIcon: fakeResolveIcon,
|
||||
});
|
||||
expect(presentation.displayName).toBe("Message from remote::worker");
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { AgentMessage } from "@getpaseo/protocol/agent-message";
|
||||
import { buildAgentMessageDisplay } from "@getpaseo/protocol/agent-message-display";
|
||||
import type { PlanOutcome } from "@/components/plan-card";
|
||||
import type { ComponentType } from "react";
|
||||
import type { ToolCallDetail } from "@getpaseo/protocol/agent-types";
|
||||
@@ -13,6 +15,7 @@ type ToolCallStatus = "executing" | "running" | "completed" | "failed" | "cancel
|
||||
export type ToolCallPresentationIcon = ComponentType<{ size?: number; color?: string }>;
|
||||
|
||||
interface BuildToolCallPresentationInput {
|
||||
agentMessage?: AgentMessage;
|
||||
toolName: string;
|
||||
status: ToolCallStatus;
|
||||
error: unknown;
|
||||
@@ -23,6 +26,7 @@ interface BuildToolCallPresentationInput {
|
||||
}
|
||||
|
||||
export interface ToolCallPresentation {
|
||||
detail: ToolCallDetail | undefined;
|
||||
displayName: string;
|
||||
summary?: string;
|
||||
errorText?: string;
|
||||
@@ -51,9 +55,13 @@ function displayDetail(detail: ToolCallDetail | undefined): ToolCallDetail {
|
||||
export function buildToolCallPresentation(
|
||||
input: BuildToolCallPresentationInput,
|
||||
): ToolCallPresentation {
|
||||
const detailForDisplay = displayDetail(input.detail);
|
||||
const detail = input.agentMessage
|
||||
? buildAgentMessageDisplay(input.agentMessage).detail
|
||||
: input.detail;
|
||||
const detailForDisplay = displayDetail(detail);
|
||||
const displayModel = buildToolCallDisplayModel({
|
||||
name: input.toolName,
|
||||
agentMessage: input.agentMessage,
|
||||
status: displayStatus(input.status),
|
||||
error: input.error ?? null,
|
||||
detail: detailForDisplay,
|
||||
@@ -61,21 +69,22 @@ export function buildToolCallPresentation(
|
||||
cwd: input.cwd,
|
||||
});
|
||||
const isLoadingDetails = isPendingToolCallDetail({
|
||||
detail: input.detail,
|
||||
detail,
|
||||
status: input.status,
|
||||
error: input.error,
|
||||
});
|
||||
const hasDetails = Boolean(input.error) || hasMeaningfulToolCallDetail(input.detail);
|
||||
const hasDetails = Boolean(input.error) || hasMeaningfulToolCallDetail(detail);
|
||||
|
||||
return {
|
||||
detail,
|
||||
displayName: displayModel.displayName,
|
||||
summary: displayModel.summary,
|
||||
errorText: displayModel.errorText,
|
||||
icon: input.resolveIcon(input.toolName, input.detail),
|
||||
icon: input.resolveIcon(input.toolName, detail),
|
||||
isLoadingDetails,
|
||||
hasDetails,
|
||||
canOpenDetails: hasDetails || isLoadingDetails,
|
||||
openFilePath: extractToolCallFilePath(input.detail),
|
||||
openFilePath: extractToolCallFilePath(detail),
|
||||
isPlan: input.detail?.type === "plan",
|
||||
planOutcome: input.detail?.type === "plan" ? resolvePlanOutcome(input) : undefined,
|
||||
};
|
||||
|
||||
@@ -2305,3 +2305,28 @@ describe("notification timeline items", () => {
|
||||
expect(new Set(state.map((item) => item.id)).size).toBe(state.length);
|
||||
});
|
||||
});
|
||||
|
||||
it("retains agent-message provenance through live delivery and repeated history", () => {
|
||||
const agentMessage = {
|
||||
event: "finished" as const,
|
||||
sender: { id: "remote::worker", title: "Reviewer" },
|
||||
text: "Done",
|
||||
};
|
||||
const event = {
|
||||
type: "timeline",
|
||||
provider: "codex",
|
||||
item: {
|
||||
type: "tool_call",
|
||||
callId: "delivery",
|
||||
name: "agent_message",
|
||||
status: "completed",
|
||||
error: null,
|
||||
detail: { type: "plain_text", text: "Done" },
|
||||
agentMessage,
|
||||
},
|
||||
} satisfies AgentStreamEventPayload;
|
||||
const live = reduceStreamUpdate([], event, new Date(1));
|
||||
const replay = reduceStreamUpdate(live, event, new Date(2));
|
||||
expect(replay).toHaveLength(1);
|
||||
expect(replay[0]).toMatchObject({ payload: { data: { agentMessage } } });
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user