mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-02 13:15:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89773d2ec3 | ||
|
|
8fcd4e151d | ||
|
|
3e17a0e125 | ||
|
|
a5fe858831 | ||
|
|
64db9df945 | ||
|
|
51601d45cf | ||
|
|
d7d6523333 | ||
|
|
f4a6d7841c | ||
|
|
4db5d454cd | ||
|
|
b34d4f5c3f | ||
|
|
7bfdbbad2c | ||
|
|
98c98d1017 | ||
|
|
e9ea31ef3b | ||
|
|
5a6e6d1918 | ||
|
|
acd119743b | ||
|
|
a7bc7ac759 | ||
|
|
9b82a65f3d | ||
|
|
d131b54230 | ||
|
|
c75b718b2d | ||
|
|
3e2179cbc9 | ||
|
|
20755f5097 | ||
|
|
1fe9905fa3 | ||
|
|
211416b8eb | ||
|
|
ab5e1d6fcb | ||
|
|
5029998013 | ||
|
|
2719695236 | ||
|
|
dc66f296da | ||
|
|
f7ceb13bd7 | ||
|
|
fdec437e07 | ||
|
|
67b5da3544 | ||
|
|
197e84c337 | ||
|
|
4d9bc25a1d | ||
|
|
910e65d8b2 | ||
|
|
12e7f1fab1 | ||
|
|
bbdc3e326d | ||
|
|
bac45474de | ||
|
|
e928961472 | ||
|
|
83b80351f7 | ||
|
|
6eba86db2f | ||
|
|
f83c3bab70 | ||
|
|
535f3d36d0 | ||
|
|
32fe3074a0 | ||
|
|
5b1ccba548 | ||
|
|
6cffd3994d | ||
|
|
4101519112 | ||
|
|
da58a57998 | ||
|
|
f76fd024fb | ||
|
|
2f7e22e621 | ||
|
|
9592f88fdf | ||
|
|
0d244c192a | ||
|
|
6354565748 | ||
|
|
e06218e9f4 | ||
|
|
fec7454c31 | ||
|
|
5adfd4961c | ||
|
|
d1ee5dee63 | ||
|
|
1adabf70c8 | ||
|
|
87427c2aa1 | ||
|
|
cfa4536358 | ||
|
|
7f75b0e166 | ||
|
|
b0ca089d54 | ||
|
|
91e7713721 | ||
|
|
e20ea2aaf2 | ||
|
|
806214d285 | ||
|
|
e5edb6efd5 | ||
|
|
0a0544fa4f | ||
|
|
914143e8b0 |
+17
-11
@@ -236,17 +236,23 @@ wake-ups), or the child's own outstanding finish subscriptions as a caller. Hear
|
||||
crons, change-request watches, and other daemon background items never count: they are external
|
||||
triggers, not work the caller is waiting for.
|
||||
|
||||
Every turn end reports `finished` at once. When work is still pending, the notice names it and the
|
||||
subscription follows the child: each later turn end reports `finished` again, and the child settling
|
||||
with nothing pending sends a final `finished` and removes the subscription, even when the work
|
||||
drains without another turn. Reporting at once keeps a long-lived task, such as a dev server, from
|
||||
leaving the caller without the child's reply. Following is what lets the caller hear the reply a
|
||||
background task wakes up later ([#6346](https://github.com/getpaseo/paseo/issues/6346)). A work change
|
||||
that leaves work pending sends nothing. Errors, permission requests, and closes report as they
|
||||
happen. `followingSince` is stored when following starts, so a restart keeps following instead of
|
||||
waiting for another turn end. After 24 hours of following, the caller gets a final `finished` with
|
||||
the child's last reply and the subscription ends. Remote children and providers without the probe
|
||||
report their first turn end as a settled `finished`.
|
||||
Every turn end reports `finished` at once, unless the child already sent an agent message to its
|
||||
caller during that turn and started no further tool work afterwards. In that case the child's
|
||||
message already delivered its reply, so the redundant `finished` notice is skipped: a settled watch
|
||||
ends silently, and a watch with pending work keeps following silently until a later turn starts or
|
||||
the work drains. Starting another non-reporting tool call or a new turn clears that mark (plain text output after the
|
||||
message does not), and errors, permission requests, cancellations, and closes are never suppressed. When work is still
|
||||
pending on an unreported turn end, the notice names it and the subscription follows the child: each
|
||||
later turn end reports `finished` again, and the child settling with nothing pending sends a final
|
||||
`finished` and removes the subscription, even when the work drains without another turn. Reporting
|
||||
at once keeps a long-lived task, such as a dev server, from leaving the caller without the child's
|
||||
reply. Following is what lets the caller hear the reply a background task wakes up later
|
||||
([#6346](https://github.com/getpaseo/paseo/issues/6346)). A work change that leaves work pending
|
||||
sends nothing. Errors, permission requests, and closes report as they happen. `followingSince` is
|
||||
stored when following starts, so a restart keeps following instead of waiting for another turn end.
|
||||
After 24 hours of following, the caller gets a final `finished` with the child's last reply and the
|
||||
subscription ends. Remote children and providers without the probe report their first turn end as a
|
||||
settled `finished`.
|
||||
|
||||
Permission requests are notification checkpoints, not the end of that subscription. The caller is notified again after a permission response when the child finishes, errors, or requests another permission.
|
||||
The permission notification includes the normalized request plus the child and request IDs, so the caller can inspect it and respond without fetching agent status.
|
||||
|
||||
@@ -29,7 +29,7 @@ So arrival sets a _target_ and the reveal rate is derived from the backlog inste
|
||||
- **The coalescer is leading + trailing.** The first delta after an idle window flushes synchronously; only the rest of the burst waits for the trailing timer. Reverting to trailing-only adds a full window to the first character of every turn. Same shape and the same reason as `TerminalOutputCoalescer`.
|
||||
- **The leading flush adds a canonical row, and that is fine.** A burst's first chunk lands as its own timeline row. `mergeAssistantChunks` / `mergeReasoningChunks` in `timeline-projection.ts` join contiguous same-turn rows, and clients read the projected timeline, so history is unaffected. Tests that assert on raw rows have to account for the extra row; tests that assert on what a client sees do not.
|
||||
- **The store holds the full text; only the rendered slice is paced.** Copy, selection, the chat outline, and scroll geometry all read the same string the user can see. Pacing the store instead would leave the bottom anchor chasing a content height that is ahead of the reveal.
|
||||
- **One source assistant message is one display row.** Presentation projects plugin output and caches unchanged history. The shared [Markdown renderer](markdown-renderer.md) owns rendering on every platform. Chat paces the visible source and applies a 32,000-character render cap on web; native keeps the complete message. The native renderer keeps closed blocks in a stable head and sends the paced suffix to a separate tail view during streaming; completion reunites them for selection. This stays inside the renderer, without promoting blocks into timeline history.
|
||||
- **One source assistant message is one display row.** Presentation projects plugin output and caches unchanged history. The shared [Markdown renderer](markdown-renderer.md) owns rendering on every platform. Chat paces the visible source and applies a 32,000-character render cap on web; native keeps the complete message. While streaming, the renderer keeps closed blocks in head parts and sends the paced suffix to a separate tail; completion reunites them for selection. This stays inside the renderer, without promoting blocks into timeline history.
|
||||
- **Message identity survives completion.** Assistant row ids are source message ids. Plugin rows can replace a source, so find, scroll-to-message and history reveal still use `getStreamItemMessageId`. Width-specific measurements describe whole rendered messages.
|
||||
- **First sight of a text is revealed whole.** Only growth is paced. This is what makes history hydration, timeline replay, a virtualized row remounting on scroll, and an already-finished message all render complete on first paint without a special case for each.
|
||||
- **Leaving `phase: "streaming"` snaps the reveal.** A completed turn must never be left holding characters. `layoutStream` sets the phase, so anything outside the live head with an active turn is already complete.
|
||||
@@ -49,11 +49,19 @@ So arrival sets a _target_ and the reveal rate is derived from the backlog inste
|
||||
while text arrives, and release obsolete window caches as the reader reveals more history;
|
||||
window caches must stay bounded while their source timeline remains loaded.
|
||||
|
||||
## Native parsing cost
|
||||
## Markdown parsing cost
|
||||
|
||||
The native library reparses and measures its entire `markdown` prop on each update. During streaming, the renderer splits source at an mdast block boundary and memoizes the head, so per-frame updates parse only the tail. Boundary discovery runs when a source line completes, rather than on every reveal frame. The unfinished line and final parsed block stay in the tail, preserving list continuation, setext headings, tables and open fences. Reference-dependent source and HTML retain a larger tail because later source can change their meaning. A single long block therefore still carries its full parsing cost.
|
||||
Both engines reparse their entire `markdown` prop on each update: md4c in C++ on native, md4c in WASM plus a JSON tree on web. Source adaptation adds a full mdast parse for some text, such as any `&`, at about 1 µs per character. Rendering a growing reply whole on each reveal frame therefore makes the reply quadratic to stream.
|
||||
|
||||
Completion restores one native text view per Mermaid-delimited segment, so selection crosses prose paragraphs again. The head retains its trailing block margin while split. JS reveal remains the pacing source; native opacity animation stays disabled.
|
||||
While streaming, `createStreamingMarkdownSplitter` in `components/markdown/streaming.ts` splits the message into head parts and a tail, on every platform. The tail is the last block and the unfinished line, so list continuation, setext headings, tables and open fences render as they will when complete. Rules that keep the cost per frame flat as the reply grows:
|
||||
|
||||
- **Discovery is incremental.** The boundary moves only when a line completes, and each time the splitter parses only the source after the boundary. Blocks before it are closed and need no document context.
|
||||
- **Head parts are sealed at 2,000 characters.** Each completed block re-renders the head part it lands in. Only the last part grows, so that work stays bounded. A single head would re-render all closed blocks each time a block completes.
|
||||
- **The first part keeps its React key from the first frame to the completed message.** Completion re-renders it in place instead of remounting it, and the parts share one image occurrence key, so an image keeps its acquisition when its block moves into the head.
|
||||
|
||||
Two kinds of source fall back to a growing render, because later source can change how earlier source reads. A link definition can turn an earlier `[label]` into a link, so a message with one renders as one document until it completes. HTML needs its enclosing source, so HTML and every block after it stay in the tail. A single long block also carries its full cost.
|
||||
|
||||
Completion renders one view per Mermaid-delimited segment, so native selection crosses prose paragraphs again; while streaming it crosses only within a part. JS reveal remains the pacing source; native opacity animation stays disabled.
|
||||
|
||||
## Measuring
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
Use `MarkdownRenderer` for chat replies, file previews, plans, pull requests and changelog content. It uses `react-native-enriched-markdown` on iOS, Android and web. Keep source adaptation and renderer configuration in `components/markdown`; consumers supply Markdown and, when needed, its file location.
|
||||
|
||||
Native selection belongs to the library's text view. Keep an assistant message in one row so selection can cross paragraphs, headings and lists. Code blocks and tables use the library's native views and their selection behavior. Web uses browser selection over semantic HTML. Once its WASM parser is initialized, the library parses synchronously for the first commit of each mounted row; an empty interim row would corrupt virtualized measurements and move the reader. Chat owns paced reveal, the web render cap, message identity and list measurement. Native renders completed messages together. While streaming, it keeps closed blocks in one head view and updates a separate tail, then reunites the text on completion. See [native parsing cost](agent-stream-performance.md#native-parsing-cost) for the boundary and pacing constraints.
|
||||
Native selection belongs to the library's text view. Keep an assistant message in one row so selection can cross paragraphs, headings and lists. Code blocks and tables use the library's native views and their selection behavior. Web uses browser selection over semantic HTML. Once its WASM parser is initialized, the library parses synchronously for the first commit of each mounted row; an empty interim row would corrupt virtualized measurements and move the reader. Call `preloadMarkdownParser()` ahead of navigation or gate a loading skeleton on `useMarkdownParserReady()` (`packages/app/src/components/markdown/parser-ready.ts`) so cold web mounts do not paint an empty interim container. Chat owns paced reveal, the web render cap, message identity and list measurement. A completed message renders as one document. While streaming, the renderer keeps closed blocks in head parts and updates a separate tail, then reunites the text on completion. See [Markdown parsing cost](agent-stream-performance.md#markdown-parsing-cost) for the boundary and pacing constraints.
|
||||
|
||||
## Block spacing
|
||||
|
||||
Every block is separated by one gap, `density.blockGap`: 12 on compact layouts, 16 wider. Inside the library's text, every element style ends with that gap and the library drops it after the last block. Views stacked outside the library (Mermaid segments, streaming head and tail) use the same gap through `MarkdownBlockStack`. Do not give a block type its own margins; change the gap.
|
||||
Every block is separated by one gap, `density.blockGap`: 12 on compact layouts, 16 wider. Inside the library's text, every element style ends with that gap and the library drops it after the last block. Views stacked outside the library (Mermaid segments, streaming head parts and tail) use the same gap through `MarkdownBlockStack`. Do not give a block type its own margins; change the gap.
|
||||
|
||||
## Links and images
|
||||
|
||||
@@ -14,7 +14,11 @@ Workspace file links use the shared file-link resolver. The workspace supplies i
|
||||
|
||||
Right-click on web and long press on native open one link menu per rendered part (`components/markdown/link-menu`), not one per link: a menu root cannot sit inside a paragraph without producing invalid markup on web. The native long-press event carries only the URL, with no position and no syntax context. The menu takes the position from the touch that started the press, and treats a URL that is no `](destination)` in the source as recognized text.
|
||||
|
||||
Pass `external` for author-controlled Markdown from outside the host, such as a plugin README. It follows the registry's overview contract in `packages/protocol/src/plugin-overview.ts`, which the website also uses: only absolute https links and images work, and any other destination renders as its label or alt text. The parser still autolinks bare `http://`, `www.` and email text, so a link press checks the URL again and opens only https. None of the workspace recognition above applies, so `Node.js` is prose, not a file. The lines of a paragraph join, as they do on the README's forge.
|
||||
Compose the renderer's capabilities per surface instead of bundling them under one flag:
|
||||
|
||||
- `destinations="https"` restricts links and images to absolute `https://` destinations following the registry's overview contract in `packages/protocol/src/plugin-overview.ts` (which the website also uses). Any other destination renders as its label or alt text, no host files are read via `client.readFile`, and workspace path recognition is off so `Node.js` stays prose. The parser still autolinks bare `http://`, `www.` and email text, so a link press checks the URL again and opens only `https://`.
|
||||
- `forgeShorthand` (default `true`) controls whether `#12` / `owner/repo#12` references resolve against the workspace's `ForgeShorthandProvider`. Pull request comments keep `destinations="https"` with `forgeShorthand` enabled; plugin READMEs and the changelog disable `forgeShorthand` so they never link to whichever workspace happens to be open.
|
||||
- `softBreaks` (`"break"` default, `"join"` for READMEs and changelogs) controls whether single newlines inside a paragraph become hard breaks or join into one line as they do on a forge.
|
||||
|
||||
Resolve workspace image paths over the existing session RPC, then give the library a cached native file URL or web blob URL. HTTP(S) images pass through unchanged. This preserves relay, SSH and local socket connections, which do not expose a daemon HTTP endpoint. Each mounted renderer owns its image acquisition identity, so a later reply reads a rewritten path again while the earlier mounted reply retains its snapshot. Image taps open the attachment lightbox. File previews resolve relative images against the Markdown file's directory. An image alone on its line becomes its own paragraph before the library sees it, so it renders as a block on every platform; the library only treats sole-child paragraph images as blocks, and with hard soft breaks every newline is a break node, which left own-line images inline on iOS and web. Images that share a line with text stay inline at line height and keep their aspect ratio. A linked image counts as an image, so review-bot badges such as `[](url) Confidence` stay inline on web; the library's web renderer only checked direct paragraph children, so it rendered them as full-width block images (fixed in the fork).
|
||||
|
||||
|
||||
@@ -146,9 +146,10 @@ definition, no longer eligible to begin.
|
||||
- Panels whose gesture wrapper already owns visibility use `RetainedPanelActivity` to provide the
|
||||
same active signal without adding another layout root. Persistent animations, timers, polling, and
|
||||
shared clocks must subscribe to that signal and stop when their final visible consumer leaves.
|
||||
- Synchronized step animations use one wall-clock-aligned source. Register a local shared value only
|
||||
while its retained panel is active so hidden animated styles remain mounted without receiving clock
|
||||
updates. Do not give every instance its own loop or leave hidden styles subscribed to the source.
|
||||
- Synchronized step animations use one source. Do not give every instance its own loop. A hidden
|
||||
instance stops running the source and keeps its place, because the active signal changes after the
|
||||
panel has slid into view; see
|
||||
[running-indicators.md](running-indicators.md#hidden-panels).
|
||||
- Retention order and render order are separate concerns. LRU metadata may change on every switch;
|
||||
keyed retained roots must keep a stable sibling order. Moving large retained roots triggered Fabric
|
||||
Differ failures (`addViewAt` / `removeViewAt` view reuse) on Android.
|
||||
|
||||
+53
-13
@@ -14,14 +14,37 @@ value.
|
||||
|
||||
`components/indicator-motion` owns the two pieces every indicator shares:
|
||||
|
||||
- `useIndicatorMotion()` decides whether an indicator may move: not under reduced motion, not in a
|
||||
retained panel that is not showing, not while the app is in the background. An indicator that may
|
||||
not move draws its resting frame and runs nothing. Ask this hook; do not read reduced motion or
|
||||
visibility yourself.
|
||||
- `useIndicatorMotion()` says what an indicator does now. Ask this hook; do not read reduced motion
|
||||
or visibility yourself.
|
||||
- `moving`: it runs.
|
||||
- `held`: nobody can see it, in a retained panel that is not showing or in an app in the
|
||||
background. It runs nothing and keeps its place.
|
||||
- `resting`: the system asks for reduced motion. It draws its resting frame and runs nothing.
|
||||
- The driver: `loop.web.ts` on web, `clock.ts` on native.
|
||||
|
||||
Animate only `transform` and `opacity`. Anything else is painted on the main thread every frame.
|
||||
|
||||
## Hidden panels
|
||||
|
||||
A phone's sidebar slides into view before its panel counts as showing: the panel's active signal
|
||||
changes when the slide settles, never during it (see [mobile-panels.md](mobile-panels.md)). An
|
||||
indicator that changes what it draws on that signal changes it in front of the user. A held ring
|
||||
that drew its resting position jumped to the running position at the end of every slide.
|
||||
|
||||
So on native a held indicator stays bound to its clock and stops running it:
|
||||
|
||||
- The clock and the loader's ticker count the time they have run, and hold it while nothing runs
|
||||
them. They are never set back to zero or to the wall clock.
|
||||
- While another panel runs the clock, a held view follows it. Measured on an Android emulator with
|
||||
six held rings behind a running chat, the app drew the same frames a second as with the rings
|
||||
unbound, and CPU on each thread differed by less than it does between two runs.
|
||||
- While nothing runs the clock, a held view costs nothing: behind an idle chat the app draws no
|
||||
frames.
|
||||
- One commit can stop the last moving indicator and start another, as when the sidebar replaces the
|
||||
chat. The clock stops after the commit, so it counts through that without a restart.
|
||||
|
||||
Web does not do this: a held indicator on web cancels its loop and draws its resting frame.
|
||||
|
||||
## Frames
|
||||
|
||||
Keeping the animation off the React thread does not make it free. Every time an indicator moves,
|
||||
@@ -88,11 +111,27 @@ For a transition that is fine. For an indicator that runs for an hour it was 22
|
||||
the UI thread of an Android emulator.
|
||||
|
||||
React Native's own `Animated` with `useNativeDriver: true` updates the view from the native driver
|
||||
and commits nothing. `clock.ts` builds a clock out of it: a decay that never slows, at one unit per
|
||||
millisecond, is the time since it started. Decay is the one native-driven animation that computes
|
||||
its value from the frame timestamp instead of replaying a 60 fps recording, so it is exact at any
|
||||
refresh rate and needs no loop restart. `Animated.modulo` and `interpolate` turn the clock into a
|
||||
rotation or a translation, all inside the native driver.
|
||||
and commits nothing. `clock.ts` builds a clock out of it: a linear timing at one unit per
|
||||
millisecond is the time since the clock started. `Animated.modulo` and `interpolate` turn the clock
|
||||
into a rotation or a translation, all inside the native driver.
|
||||
|
||||
The timing counts in spans of ten minutes. The end of a span is the one event that reaches the JS
|
||||
thread, which starts the next span where that one ended, so a cycle keeps its place from one span to
|
||||
the next.
|
||||
|
||||
The native driver owns the clock's value. The JS thread starts and stops the counting and never
|
||||
sets the value, so a stopped clock keeps the value its views show. When the clock stops, the driver
|
||||
reports the value it stopped at, and the next start counts on from it.
|
||||
|
||||
Do not drive the clock with a decay. A decay that never slows counts time without spans, but the
|
||||
driver ends a decay when its value moves less than 0.1 between two frames, whatever the
|
||||
deceleration. Two frames that carry the same millisecond are enough, and then every indicator on
|
||||
the clock freezes. Starting the decay again from the JS thread shows as a pause and a jump each
|
||||
time.
|
||||
|
||||
Android replays a timing as 60 positions a second at any refresh rate, and iOS interpolates between
|
||||
them. Every cycle on the clock is stepped at 30 positions a second, so this does not show. A cycle
|
||||
without steps would move 60 times a second on a 120 Hz Android display.
|
||||
|
||||
`cycle(periodMs, { steps })` holds the position at each step. The driver still ticks every frame,
|
||||
but a view whose transform did not change is not invalidated, so nothing is drawn between steps.
|
||||
@@ -100,14 +139,15 @@ but a view whose transform did not change is not invalidated, so nothing is draw
|
||||
The native clock starts on the frame where the driver picks it up, so two clocks started at
|
||||
different times turn their steps over on different frames. That is why the shimmer rides
|
||||
`sharedIndicatorClock`, the rings' clock, with `phase: "own"`: its pass starts at the clock's
|
||||
current step. The JS thread works out that step from the time it started the clock. The driver
|
||||
current step. The JS thread works out that step from the time it started the clock and the value
|
||||
the clock started from. The driver
|
||||
starts the clock a frame or two later, so a pass can start one step early or late. The band starts
|
||||
one band width outside the label, so this does not show.
|
||||
|
||||
The loader changes six times per cycle, so it does not ride the frame clock. `step-ticker.ts` wakes
|
||||
the JS thread once per step, aligned to wall-clock step boundaries, and publishes the step into a
|
||||
native `Animated.Value`. A wake-up that arrives late publishes the step that is current by then, so
|
||||
the loader never drifts and every loader shows the same step.
|
||||
the JS thread once per step and publishes the step into a native `Animated.Value`. A wake-up that
|
||||
arrives late publishes the step that is current by then, so the loader never drifts. Every loader
|
||||
reads the one value, so they all show the same step.
|
||||
|
||||
Do not apply Unistyles dynamic styles to these `Animated.View`s; see
|
||||
[unistyles.md](unistyles.md#reanimated-animatedview--dynamic-styles-crashes).
|
||||
|
||||
@@ -172,9 +172,10 @@ is offline and until a reconnected chat's check answers, so an unchanged chat ne
|
||||
toast. Returning from background on a socket that stayed connected shows nothing until the check
|
||||
answers: the chat stayed subscribed, so a slow answer is no reason to doubt it, and a socket that
|
||||
died without closing fails the foreground liveness probe and becomes a reconnect. Updating messages
|
||||
appears for a chat that is behind, until the fetch completes, and for an opened chat whose check is
|
||||
still unanswered `FRESHNESS_CHECK_QUIET_MS` after it was sent. That delay measures the daemon, so it
|
||||
starts at the request: on a cold start the cache read alone can take longer. Socket connectivity
|
||||
appears for a chat that is behind, until the fetch completes, and for an opened chat whose check or
|
||||
cursorless initial tail catch-up (such as a display-only cache) is still unanswered
|
||||
`FRESHNESS_CHECK_QUIET_MS` after the subscribe request was sent. That delay measures the daemon, so
|
||||
it starts at the request: on a cold start the cache read alone can take longer. Socket connectivity
|
||||
alone cannot certify that the displayed conversation is current. The timeline owner publishes freshness; the view renders it without a toast timer or a
|
||||
separate resume workflow.
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
sha256-04BfmBEaEZy3ohSi3Z8S3/a3xBsLKhls+8mcjJ0Y2/A=
|
||||
sha256-x6E6SY98/8pUNLomlPzSNedZ+ZKJPzsQeS9L455i+n0=
|
||||
|
||||
Generated
+7
@@ -12136,6 +12136,12 @@
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@silvia-odwyer/photon-node": {
|
||||
"version": "0.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@silvia-odwyer/photon-node/-/photon-node-0.3.4.tgz",
|
||||
"integrity": "sha512-bnly4BKB3KDTFxrUIcgCLbaeVVS8lrAkri1pEzskpmxu9MdfGQTy8b8EgcD83ywD3RPMsIulY8xJH5Awa+t9fA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@sinclair/typebox": {
|
||||
"version": "0.27.10",
|
||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.10.tgz",
|
||||
@@ -40615,6 +40621,7 @@
|
||||
"@modelcontextprotocol/server": "2.4.0",
|
||||
"@opencode-ai/sdk": "1.14.46",
|
||||
"@opencode/client": "2.0.10",
|
||||
"@silvia-odwyer/photon-node": "^0.3.4",
|
||||
"@xterm/addon-serialize": "0.14.0",
|
||||
"@xterm/addon-unicode-graphemes": "0.5.0-beta.330",
|
||||
"@xterm/headless": "6.1.0-beta.334",
|
||||
|
||||
@@ -125,10 +125,17 @@ for (const theme of ["light", "dark"] as const) {
|
||||
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);
|
||||
// The row leaves the list once Remove is confirmed, before the daemon answers.
|
||||
await expect
|
||||
.poll(async () => (await client.getDaemonConfig()).config.providers?.hoplite)
|
||||
.toBeUndefined();
|
||||
await expect
|
||||
.poll(async () =>
|
||||
(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),
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
answerFreshnessCheck,
|
||||
commitTimelineTurnsWhileDisconnected,
|
||||
disconnectViewedTimeline,
|
||||
expectCleanLoadingSurfaces,
|
||||
expectEmptyChatSynced,
|
||||
expectPromptAndWholeReply,
|
||||
expectResumeAnsweredWithoutFetch,
|
||||
@@ -26,11 +27,14 @@ import {
|
||||
restoreViewedTimelineWithHeldResponse,
|
||||
restoreViewedTimelineWithLiveRowsFirst,
|
||||
reopenWithFreshnessCheckUnanswered,
|
||||
reopenWithTimelineTailUnanswered,
|
||||
seedStreamingReplyAgent,
|
||||
sendPromptWhileDisconnected,
|
||||
stopStreamingReply,
|
||||
waitForDisplayOnlyTimelineCache,
|
||||
waitForResumeAnswer,
|
||||
reopenAppWatchingForUpdatingToast,
|
||||
watchColdAndReloadLoadingSurfaces,
|
||||
watchForUpdatingToast,
|
||||
} from "../support/helpers/timeline-resume";
|
||||
|
||||
@@ -176,4 +180,36 @@ test.describe("Agent timeline resume", () => {
|
||||
await agent.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("cold opens and display-only cache reloads keep loading steady and reserve Updating messages for slow replies", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
const agent = await seedLongMockAgentTimeline({ turns: 30 });
|
||||
try {
|
||||
await watchColdAndReloadLoadingSurfaces(page);
|
||||
|
||||
await test.step("cold open fetches one tail without showing a premature toast", async () => {
|
||||
const requests = rememberTimelineRequestCounts(gate, agent.agentId);
|
||||
await openAgentTimeline(page, agent);
|
||||
await expectTimelinePromptVisible(page, agent.newestPrompt);
|
||||
await expectCleanLoadingSurfaces(page, gate, requests);
|
||||
});
|
||||
|
||||
await test.step("display-only cached reload shows Updating messages until the overdue tail arrives", async () => {
|
||||
await scrollTimelineUntilOlderHistoryIsReachable(page, agent.firstOlderPagePrompt);
|
||||
await waitForDisplayOnlyTimelineCache(page, agent);
|
||||
|
||||
const requests = rememberTimelineRequestCounts(gate, agent.agentId);
|
||||
await reopenWithTimelineTailUnanswered({ page, gate, agentId: agent.agentId });
|
||||
await expectTimelinePromptVisible(page, agent.newestPrompt);
|
||||
gate.releaseHeldTimelineResponses();
|
||||
await expectCleanLoadingSurfaces(page, gate, requests);
|
||||
});
|
||||
} finally {
|
||||
gate.restore();
|
||||
await agent.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,9 @@ import {
|
||||
} from "../support/helpers/composer";
|
||||
|
||||
import { openCommandCenter, closeCommandCenter } from "../support/helpers/command-center";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import {
|
||||
PROMPT_PLUGIN_ID,
|
||||
expectPromptsDrawnByPlugin,
|
||||
withPromptTimelinePlugin,
|
||||
} from "../support/helpers/plugin-timeline";
|
||||
@@ -279,6 +281,7 @@ test("finds text in a prompt a timeline plugin draws", async ({ page }, testInfo
|
||||
await agent.client.waitForFinish(agent.agentId, 15_000);
|
||||
await withPromptTimelinePlugin(async () => {
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, [PROMPT_PLUGIN_ID]);
|
||||
await expectPromptsDrawnByPlugin(page);
|
||||
await openChatFind(page);
|
||||
await query(page).fill("scope-needle");
|
||||
|
||||
@@ -25,7 +25,9 @@ import {
|
||||
expectReadingStreamedMarkdown,
|
||||
} from "../support/helpers/chat-outline";
|
||||
import { createCreationScenario } from "../support/helpers/creation";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import {
|
||||
PROMPT_PLUGIN_ID,
|
||||
attachPromptTimelineEvidence,
|
||||
expectPromptsDrawnByPlugin,
|
||||
expectVirtualizedPluginPromptVisible,
|
||||
@@ -118,6 +120,7 @@ test.describe("desktop chat outline", () => {
|
||||
await withPromptTimelinePlugin(async () => {
|
||||
await page.setViewportSize(WIDE_VIEWPORT);
|
||||
await openAgentTimeline(page, agent);
|
||||
await approveClientPluginsInUi(page, [PROMPT_PLUGIN_ID]);
|
||||
await expectChatOutlinePrompts(page, 80);
|
||||
await expectPromptsDrawnByPlugin(page);
|
||||
await expectTimelinePromptNotMounted(page, agent.prompts[39]);
|
||||
@@ -148,6 +151,7 @@ test.describe("desktop chat outline", () => {
|
||||
const history = await holdOlderHistoryPages(page, agent);
|
||||
await page.setViewportSize(WIDE_VIEWPORT);
|
||||
await openAgentTimeline(page, agent);
|
||||
await approveClientPluginsInUi(page, [PROMPT_PLUGIN_ID]);
|
||||
await expectChatOutlinePrompts(page, 80);
|
||||
await scrollThroughOlderHistoryPages(page, 2, history);
|
||||
await scrollTimelineToNewestLoadedEdge(page);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { withDirectoryPlugin } from "../support/helpers/plugin-timeline";
|
||||
import {
|
||||
attachImageFromMenu,
|
||||
@@ -158,6 +159,7 @@ test.describe("Client slash commands", () => {
|
||||
}`,
|
||||
run: async () => {
|
||||
await withOpenReadyMockAgent(page, { title: "Attached slash command" }, async () => {
|
||||
await approveClientPluginsInUi(page, ["attachment-slash-e2e"]);
|
||||
const input = composerLocator(page);
|
||||
await input.fill("/pict");
|
||||
await expect(
|
||||
|
||||
@@ -172,7 +172,7 @@ test("retrying failed agent initialization keeps the plugin metadata set on New
|
||||
startup,
|
||||
composerMetadata,
|
||||
}) => {
|
||||
await creation.openWorkspaceForm("local");
|
||||
await creation.openWorkspaceForm("local", { approvePlugins: ["composer-metadata"] });
|
||||
await composerMetadata.set({ "composer-metadata.tag": "kept" });
|
||||
await creation.submitPrompt("Start the tagged task.", "Create");
|
||||
await creation.expectAgentStillStarting();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { seedMockAgentWorkspace, openAgentRoute } from "../support/helpers/mock-agent";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { installDaemonWebSocketGate } from "../support/helpers/daemon-websocket-gate";
|
||||
import { openFileFromExplorer } from "../support/helpers/file-explorer";
|
||||
import { waitForWorkspaceInReplicaCache } from "../support/helpers/replica-cache-storage";
|
||||
import { openSettingsSection, clickSettingsBackToWorkspace } from "../support/helpers/settings";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import {
|
||||
@@ -547,3 +550,64 @@ test("keeps the comment shortcut in the editor beside an Explorer agent", async
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
async function restoreHostConnection(gate: Awaited<ReturnType<typeof installDaemonWebSocketGate>>) {
|
||||
gate.holdNextServerMessage("status");
|
||||
gate.restore();
|
||||
await gate.waitForHeldServerMessage("status");
|
||||
gate.releaseHeldServerMessage("status");
|
||||
}
|
||||
|
||||
test("loads Files and file filter automatically once the host connects after launch or disconnect", async ({
|
||||
page,
|
||||
withWorkspace,
|
||||
}) => {
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
const workspace = await withWorkspace();
|
||||
await writeFile(path.join(workspace.repoPath, "startup-repro.txt"), "hello\n", "utf8");
|
||||
|
||||
await test.step("open Files on the workspace before reloading", async () => {
|
||||
await workspace.navigateTo();
|
||||
const explorer = await ensureExplorerSidebar(page);
|
||||
await openFilesPanel(page);
|
||||
await expect(
|
||||
explorer
|
||||
.getByTestId("file-explorer-tree-scroll")
|
||||
.getByText("startup-repro.txt", { exact: true }),
|
||||
).toBeVisible();
|
||||
await waitForWorkspaceInReplicaCache(page, workspace.workspaceId);
|
||||
});
|
||||
|
||||
await test.step("reload while the host is unreachable and recover automatically on connect", async () => {
|
||||
await gate.drop();
|
||||
await page.reload();
|
||||
await gate.waitForBlockedConnection();
|
||||
|
||||
const explorer = explorerSidebar(page);
|
||||
await expect(explorer).toBeVisible();
|
||||
|
||||
await restoreHostConnection(gate);
|
||||
|
||||
await expect(
|
||||
explorer
|
||||
.getByTestId("file-explorer-tree-scroll")
|
||||
.getByText("startup-repro.txt", { exact: true }),
|
||||
).toBeVisible();
|
||||
await expect(explorer.getByText("Host is not connected", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
|
||||
await test.step("filter Files while disconnected and recover automatically on reconnect", async () => {
|
||||
const explorer = explorerSidebar(page);
|
||||
await gate.drop();
|
||||
await gate.waitForBlockedConnection();
|
||||
|
||||
await explorer.getByPlaceholder("Search files").fill("startup-repro");
|
||||
|
||||
await restoreHostConnection(gate);
|
||||
|
||||
await expect(
|
||||
explorer.getByTestId("file-filter-results").getByText("startup-repro.txt", { exact: true }),
|
||||
).toBeVisible();
|
||||
await expect(explorer.getByText("Host is not connected", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -199,6 +199,39 @@ test("shows listing failure details beside healthy sessions and retries the fail
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps a request timeout visible while retrying the provider", async ({ page }) => {
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
const flow = new ImportSessionFlow(page);
|
||||
await flow.openWorkspace(scenario.project.workspaceId, { width: 1280, height: 844 });
|
||||
await page.clock.install();
|
||||
|
||||
await test.step("the first listings time out before any response reaches the sheet", async () => {
|
||||
gate.setServerMessageSuppressed("fetch_recent_provider_sessions_response", true);
|
||||
await flow.openFromWorkspaceHeader();
|
||||
await expect
|
||||
.poll(() => gate.getClientRequestCount("fetch_recent_provider_sessions_request"))
|
||||
.toBeGreaterThanOrEqual(2);
|
||||
await page.clock.fastForward(101_000);
|
||||
await flow.expectProviderError("Claude");
|
||||
await flow.expectProviderRequestTimeout();
|
||||
gate.setServerMessageSuppressed("fetch_recent_provider_sessions_response", false);
|
||||
});
|
||||
|
||||
await test.step("Retry keeps the timeout visible until Claude replies", async () => {
|
||||
gate.holdNextClientRequest("fetch_recent_provider_sessions_request");
|
||||
await flow.startProviderRetry("claude");
|
||||
await gate.waitForHeldClientRequest();
|
||||
await flow.expectProviderRetryPending("claude");
|
||||
await flow.expectProviderError("Claude");
|
||||
await flow.expectProviderRequestTimeout();
|
||||
gate.releaseHeldClientRequest();
|
||||
|
||||
await flow.expectProviderRecovered("Claude");
|
||||
await flow.expectRows({ first: [scenario.importSessionId] });
|
||||
await flow.expectProviderError("Broken ACP");
|
||||
});
|
||||
});
|
||||
|
||||
test("Import Session keeps listings tied to their host during a switch and a pending import", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { expectComposerDraft, fillComposerDraft } from "../support/helpers/composer";
|
||||
import { gotoWorkspace } from "../support/helpers/launcher";
|
||||
import { runWorkspaceActionFromCommandCenter } from "../support/helpers/command-center-workspace-actions";
|
||||
import { waitForDraftComposer } from "../support/helpers/command-center-agent-controls";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
|
||||
const openText = "Keep this open New Agent draft";
|
||||
const orphanText = "Unreachable draft from an earlier version";
|
||||
const existingAgentText = "Keep this archived conversation draft";
|
||||
|
||||
async function openDraftTab(page: Page): Promise<void> {
|
||||
await runWorkspaceActionFromCommandCenter(page, "New agent");
|
||||
await waitForDraftComposer(page);
|
||||
}
|
||||
|
||||
async function persistedDraftTexts(page: Page): Promise<string[]> {
|
||||
return page.evaluate(() => {
|
||||
const drafts = JSON.parse(localStorage.getItem("paseo-drafts") ?? "{}").state?.drafts ?? {};
|
||||
return Object.values(drafts).map(
|
||||
(record) => (record as { input: { text: string } }).input.text,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function seedOrphanBeforeUpgrade(page: Page): Promise<void> {
|
||||
await page.evaluate(
|
||||
({ orphan, archived }) => {
|
||||
const makeDraft = (text: string) => ({
|
||||
input: { text, attachments: [] },
|
||||
lifecycle: "active",
|
||||
updatedAt: Date.now(),
|
||||
version: 1,
|
||||
});
|
||||
const envelope = JSON.parse(localStorage.getItem("paseo-drafts") ?? "{}");
|
||||
envelope.state.drafts["draft:old-server:previously-closed-tab"] = makeDraft(orphan);
|
||||
envelope.state.drafts["agent:old-server:archived-agent"] = makeDraft(archived);
|
||||
localStorage.setItem("paseo-drafts", JSON.stringify(envelope));
|
||||
localStorage.removeItem("paseo:orphaned-workspace-drafts-swept");
|
||||
const nonce = localStorage.getItem("@paseo:e2e-seed-nonce");
|
||||
if (nonce) localStorage.setItem("@paseo:e2e-disable-default-seed-once", nonce);
|
||||
},
|
||||
{ orphan: orphanText, archived: existingAgentText },
|
||||
);
|
||||
}
|
||||
|
||||
async function closeDraftWithShortcut(page: Page, answer: "cancel" | "discard"): Promise<void> {
|
||||
const prompt = page.waitForEvent("dialog");
|
||||
const shortcut = page.keyboard.press("Alt+Shift+w");
|
||||
const dialog = await prompt;
|
||||
expect(dialog.message()).toContain("Unsaved changes");
|
||||
if (answer === "cancel") await dialog.dismiss();
|
||||
else await dialog.accept();
|
||||
await shortcut;
|
||||
}
|
||||
|
||||
test("keeps open New Agent drafts through upgrade and confirms before discarding them", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "discard-new-agent-draft-" });
|
||||
try {
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await openDraftTab(page);
|
||||
await fillComposerDraft(page, openText);
|
||||
await expect.poll(() => persistedDraftTexts(page)).toContain(openText);
|
||||
await seedOrphanBeforeUpgrade(page);
|
||||
|
||||
await page.reload();
|
||||
await expectComposerDraft(page, openText);
|
||||
await expect.poll(() => persistedDraftTexts(page)).not.toContain(orphanText);
|
||||
await expect.poll(() => persistedDraftTexts(page)).toContain(existingAgentText);
|
||||
|
||||
await closeDraftWithShortcut(page, "cancel");
|
||||
await expectComposerDraft(page, openText);
|
||||
|
||||
await closeDraftWithShortcut(page, "discard");
|
||||
await expect.poll(() => persistedDraftTexts(page)).not.toContain(openText);
|
||||
await openDraftTab(page);
|
||||
await expectComposerDraft(page, "");
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
@@ -11,9 +11,11 @@ import {
|
||||
installBrowserNotificationRecorder,
|
||||
openNotificationSettings,
|
||||
readRecordedBrowserNotifications,
|
||||
reloadAndWaitForDevicePresence,
|
||||
setNotificationSwitch,
|
||||
setPluginNotificationSwitch,
|
||||
} from "../support/helpers/notification-settings";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { seedWorkspace, type SeedDaemonClient } from "../support/helpers/seed-client";
|
||||
|
||||
@@ -107,7 +109,7 @@ test.describe("Settings → Notifications and OS notification filtering", () =>
|
||||
|
||||
await test.step("enabling Agent finished persists across page reload and allows finished notifications", async () => {
|
||||
await setNotificationSwitch(page, "Agent finished", true);
|
||||
await page.reload();
|
||||
await reloadAndWaitForDevicePresence(page);
|
||||
await expectNotificationSwitchState(page, "Agent finished", {
|
||||
checked: true,
|
||||
disabled: false,
|
||||
@@ -137,7 +139,7 @@ test.describe("Settings → Notifications and OS notification filtering", () =>
|
||||
).toBeVisible();
|
||||
await expectNotificationSubControlsDisabled(page, true);
|
||||
|
||||
await page.reload();
|
||||
await reloadAndWaitForDevicePresence(page);
|
||||
await expectNotificationSwitchState(page, "Enable notifications", {
|
||||
checked: false,
|
||||
disabled: false,
|
||||
@@ -172,6 +174,7 @@ test.describe("Settings → Notifications and OS notification filtering", () =>
|
||||
await seeded.client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await seeded.client.installDirectoryPlugin(pluginExample.directory);
|
||||
installedPlugin = true;
|
||||
await approveClientPluginsInUi(page, ["notifications-example"]);
|
||||
|
||||
const pluginToggle = page.getByRole("switch", { name: "Build alerts", exact: true });
|
||||
await expect(pluginToggle).toBeVisible();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { createHostClient } from "@getpaseo/client/node";
|
||||
import { expect } from "@playwright/test";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import {
|
||||
addDirectHostFromSettings,
|
||||
@@ -24,11 +26,51 @@ import {
|
||||
slowConnectionToHost,
|
||||
expectTailscaleUpdateRequired,
|
||||
expectCompletePairingQr,
|
||||
expectConnectedClientRow,
|
||||
expectRelayConsent,
|
||||
expandConnectedClientRow,
|
||||
openDevicesPage,
|
||||
openPairDeviceModal,
|
||||
preparePairingHost,
|
||||
returnFromRelayToWaysToConnect,
|
||||
} from "../support/helpers/pair-device";
|
||||
|
||||
test("lists connected clients with scopes and navigates Pair a device → Relay → Back", async ({
|
||||
page,
|
||||
}) => {
|
||||
const daemon = await startIsolatedHostDaemon("pair-device-connected-clients", {
|
||||
mutableRelay: { enabled: true },
|
||||
});
|
||||
const viewer = createHostClient(`127.0.0.1:${daemon.port}`, {
|
||||
clientId: "cid_e2e_phone_viewer",
|
||||
clientType: "mobile",
|
||||
appVersion: "0.18.1",
|
||||
clientInfo: { name: "Test Phone", platform: "ios" },
|
||||
sessionPermissions: ["daemon.read", "workspace.read"],
|
||||
reconnect: { enabled: false },
|
||||
});
|
||||
try {
|
||||
await openDevicesPage(page, daemon);
|
||||
await expectConnectedClientRow(page, "This device", "Full access");
|
||||
await expandConnectedClientRow(page, "This device");
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("devices-connected-clients-card")
|
||||
.getByText("access.manage", { exact: true }),
|
||||
).toBeVisible();
|
||||
|
||||
await viewer.connect();
|
||||
await expectConnectedClientRow(page, "Test Phone", "Read-only");
|
||||
|
||||
await openPairDeviceModal(page);
|
||||
await expectPairingOffer(page);
|
||||
await returnFromRelayToWaysToConnect(page);
|
||||
} finally {
|
||||
await viewer.close();
|
||||
await daemon.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("opens relay consent in browser web", async ({ page }) => {
|
||||
const daemon = await startIsolatedHostDaemon("pair-device-browser-relay-off", {
|
||||
mutableRelay: { enabled: false },
|
||||
@@ -81,7 +123,7 @@ test("turns Tailscale on and off from Devices, asking first over Tailscale", asy
|
||||
}, testInfo) => {
|
||||
test.skip(process.platform !== "linux", "Uses a second IPv4 loopback address");
|
||||
// The journey opens Devices or the setup six times, two of them over a slowed connection.
|
||||
test.setTimeout(120_000);
|
||||
test.setTimeout(180_000);
|
||||
if (!baseURL) throw new Error("Expected the app base URL");
|
||||
const daemon = await startTailscaleTestDaemon(baseURL);
|
||||
try {
|
||||
|
||||
@@ -2,6 +2,10 @@ import path from "node:path";
|
||||
import { expect } from "../support/fixtures";
|
||||
import {
|
||||
test,
|
||||
expectInstantPrefetchedRelatedOpen,
|
||||
expectStableDesktopBackToListing,
|
||||
expectStableUncachedListingOpen,
|
||||
expectStackedFirstFrameOnNarrowDesktop,
|
||||
expectStillBrowsing,
|
||||
installFromPage,
|
||||
installListingFromRow,
|
||||
@@ -80,3 +84,89 @@ test("shows scorecard progressive disclosure, updates, custom links, and related
|
||||
await page.screenshot({ path: path.join(captureDir, "live-app-mobile-scorecard.png") });
|
||||
}
|
||||
});
|
||||
|
||||
test("renders branded sponsor buttons for single and stacked platforms in light and dark themes", async ({
|
||||
page,
|
||||
directoryHost,
|
||||
}) => {
|
||||
const captureDir = process.env.PASEO_CAPTURE_DIR;
|
||||
await page.setViewportSize({ width: 1280, height: 1000 });
|
||||
await page.emulateMedia({ colorScheme: "dark" });
|
||||
await openDirectory(page, directoryHost);
|
||||
await openListingPage(page);
|
||||
|
||||
const singleGithub = page.getByTestId("funding-button-github");
|
||||
await expect(singleGithub).toBeVisible();
|
||||
await expect(singleGithub).toContainText("Sponsor on GitHub");
|
||||
await expect(singleGithub).toHaveCSS("background-color", "rgba(219, 97, 162, 0.1)");
|
||||
await expect(singleGithub).toHaveCSS("border-top-color", "rgba(219, 97, 162, 0.32)");
|
||||
await expect(singleGithub.locator("svg")).toHaveAttribute("fill", "#ea7bb3");
|
||||
|
||||
if (captureDir) {
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({ path: path.join(captureDir, "app-gallery-single-dark.png") });
|
||||
}
|
||||
|
||||
await page.emulateMedia({ colorScheme: "light" });
|
||||
await expect(singleGithub).toBeVisible();
|
||||
await expect(singleGithub).toHaveCSS("background-color", "rgba(191, 57, 137, 0.08)");
|
||||
await expect(singleGithub).toHaveCSS("border-top-color", "rgba(191, 57, 137, 0.3)");
|
||||
await expect(singleGithub.locator("svg")).toHaveAttribute("fill", "#bf3989");
|
||||
if (captureDir) {
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({ path: path.join(captureDir, "app-gallery-single-light.png") });
|
||||
}
|
||||
|
||||
await page.getByTestId("plugin-related-acme/pr-radar").click();
|
||||
const platforms = [
|
||||
["github", "Sponsor on GitHub"],
|
||||
["kofi", "Support on Ko-fi"],
|
||||
["buymeacoffee", "Buy Me a Coffee"],
|
||||
["opencollective", "Sponsor on Open Collective"],
|
||||
["patreon", "Support on Patreon"],
|
||||
["polar", "Sponsor on Polar"],
|
||||
["liberapay", "Donate on Liberapay"],
|
||||
["paypal", "Donate via PayPal"],
|
||||
["custom", "Sponsor"],
|
||||
] as const;
|
||||
|
||||
for (const [platform, label] of platforms) {
|
||||
const btn = page.getByTestId(`funding-button-${platform}`).filter({ visible: true });
|
||||
await expect(btn).toBeVisible();
|
||||
await expect(btn).toContainText(label);
|
||||
}
|
||||
const stackedKofi = page.getByTestId("funding-button-kofi").filter({ visible: true });
|
||||
await expect(stackedKofi).toHaveCSS("background-color", "rgba(217, 67, 64, 0.08)");
|
||||
await expect(stackedKofi.locator("svg")).toHaveAttribute("fill", "#d94340");
|
||||
if (captureDir) {
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({ path: path.join(captureDir, "app-gallery-stacked-light.png") });
|
||||
}
|
||||
|
||||
await page.emulateMedia({ colorScheme: "dark" });
|
||||
for (const [platform] of platforms) {
|
||||
await expect(
|
||||
page.getByTestId(`funding-button-${platform}`).filter({ visible: true }),
|
||||
).toBeVisible();
|
||||
}
|
||||
await expect(stackedKofi).toHaveCSS("background-color", "rgba(255, 94, 91, 0.1)");
|
||||
await expect(stackedKofi.locator("svg")).toHaveAttribute("fill", "#ff7a78");
|
||||
if (captureDir) {
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({ path: path.join(captureDir, "app-gallery-stacked-dark.png") });
|
||||
}
|
||||
});
|
||||
|
||||
test("opens plugin pages without empty markdown collapse, stacked back flash, or layout shift", async ({
|
||||
page,
|
||||
directoryHost,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 960 });
|
||||
directoryHost.setDetailDelayMs(250);
|
||||
await openDirectory(page, directoryHost);
|
||||
|
||||
await expectStableUncachedListingOpen(page);
|
||||
await expectInstantPrefetchedRelatedOpen(page, directoryHost);
|
||||
await expectStableDesktopBackToListing(page);
|
||||
await expectStackedFirstFrameOnNarrowDesktop(page);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import { openHostSection } from "../support/helpers/settings";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { waitForSettledPosition } from "../support/helpers/sheet-layout";
|
||||
import { openPluginPage, openPluginPageActions } from "../support/helpers/plugin-gallery";
|
||||
import {
|
||||
allowPluginExecution,
|
||||
cancelPluginExecutionBypassConfirm,
|
||||
confirmPluginExecutionBypass,
|
||||
declinePluginExecution,
|
||||
ensureArtifactsDir,
|
||||
expectExecutedPluginMarkers,
|
||||
expectExecutedPluginMarkersContain,
|
||||
expectPluginApprovalPrompt,
|
||||
expectPluginExecutionBypass,
|
||||
getExecutedPluginMarkers,
|
||||
openPluginExecutionBypassConfirm,
|
||||
pluginApprovalSheet,
|
||||
pluginExecutionBypassConfirmModal,
|
||||
pluginExecutionBypassSwitch,
|
||||
reloadKeepingPersistedState,
|
||||
setPluginExecutionBypass,
|
||||
withInstalledClientPlugins,
|
||||
type ClientProbePluginSpec,
|
||||
} from "../support/helpers/plugin-execution-approval";
|
||||
|
||||
const REPO_ROOT = path.resolve(__dirname, "../../../..");
|
||||
|
||||
const ALPHA: ClientProbePluginSpec = {
|
||||
id: "alpha-probe",
|
||||
name: "Alpha Probe",
|
||||
sidebarTitle: "Alpha Probe",
|
||||
markerKey: "alpha-probe",
|
||||
};
|
||||
|
||||
const BETA: ClientProbePluginSpec = {
|
||||
id: "beta-probe",
|
||||
name: "Beta Probe",
|
||||
sidebarTitle: "Beta Probe",
|
||||
markerKey: "beta-probe",
|
||||
};
|
||||
|
||||
const GAMMA: ClientProbePluginSpec = {
|
||||
id: "gamma-probe",
|
||||
name: "Gamma Probe",
|
||||
sidebarTitle: "Gamma Probe",
|
||||
markerKey: "gamma-probe",
|
||||
};
|
||||
|
||||
test("prompts sequentially before evaluating stacked client plugins, holds layout steady, persists decisions, and lets settings allow or block them", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
const artifacts = await ensureArtifactsDir(REPO_ROOT);
|
||||
|
||||
await withInstalledClientPlugins([ALPHA, BETA, GAMMA], async () => {
|
||||
await gotoAppShell(page);
|
||||
|
||||
await test.step("no client plugin executes before user approval", async () => {
|
||||
await expectPluginApprovalPrompt(page, { pluginId: ALPHA.id, progress: "1 of 3" });
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([]);
|
||||
await expect(page.getByText(ALPHA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByText(BETA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByText(GAMMA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
await page.screenshot({ path: path.join(artifacts, "02-after-prompt-1-of-3.png") });
|
||||
});
|
||||
|
||||
await test.step("approving the first advances in place with steady button geometry", async () => {
|
||||
const sheet = pluginApprovalSheet(page);
|
||||
const allowButton = sheet.getByRole("button", { name: "Allow", exact: true });
|
||||
const declineButton = sheet.getByRole("button", { name: "Don't allow", exact: true });
|
||||
const beforeAllow = await allowButton.boundingBox();
|
||||
const beforeDecline = await declineButton.boundingBox();
|
||||
expect(beforeAllow).not.toBeNull();
|
||||
expect(beforeDecline).not.toBeNull();
|
||||
|
||||
await allowPluginExecution(page);
|
||||
await expectPluginApprovalPrompt(page, { pluginId: BETA.id, progress: "2 of 3" });
|
||||
await expectExecutedPluginMarkers(page, [ALPHA.markerKey]);
|
||||
await expect(page.getByText(ALPHA.sidebarTitle, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(BETA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
|
||||
const afterAllow = await allowButton.boundingBox();
|
||||
const afterDecline = await declineButton.boundingBox();
|
||||
expect(afterAllow).toEqual(beforeAllow);
|
||||
expect(afterDecline).toEqual(beforeDecline);
|
||||
await page.screenshot({ path: path.join(artifacts, "03-after-prompt-2-of-3.png") });
|
||||
});
|
||||
|
||||
await test.step("declining the second and approving the third settles cleanly", async () => {
|
||||
await declinePluginExecution(page);
|
||||
await expectPluginApprovalPrompt(page, { pluginId: GAMMA.id, progress: "3 of 3" });
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([ALPHA.markerKey]);
|
||||
|
||||
await allowPluginExecution(page);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
await expectExecutedPluginMarkers(page, [ALPHA.markerKey, GAMMA.markerKey]);
|
||||
await expect(page.getByText(ALPHA.sidebarTitle, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(GAMMA.sidebarTitle, { exact: true })).toBeVisible();
|
||||
await expect(page.getByText(BETA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "04-after-settled-approved-and-declined.png"),
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("reloading keeps approved plugins active and declined blocked without re-prompting", async () => {
|
||||
await reloadKeepingPersistedState(page);
|
||||
await expect(page.getByText(ALPHA.sidebarTitle, { exact: true })).toBeVisible({
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expect(page.getByText(GAMMA.sidebarTitle, { exact: true })).toBeVisible();
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([ALPHA.markerKey, GAMMA.markerKey]);
|
||||
await expect(page.getByText(BETA.sidebarTitle, { exact: true })).toHaveCount(0);
|
||||
});
|
||||
|
||||
await test.step("settings surfaces the declined plugin and lets the user allow or block it", async () => {
|
||||
await openSettings(page);
|
||||
await openHostSection(page, getServerId(), "plugins");
|
||||
await expect(page.getByTestId(`plugin-row-${BETA.id}`)).toContainText("blocked");
|
||||
await openPluginPage(page, BETA.name, BETA.id);
|
||||
await expect(page.getByTestId("plugin-client-blocked-alert")).toBeVisible();
|
||||
await page.screenshot({ path: path.join(artifacts, "05-after-settings-blocked-plugin.png") });
|
||||
|
||||
await page.getByTestId("plugin-client-execution-allow").click();
|
||||
await expect(page.getByTestId("plugin-client-blocked-alert")).toHaveCount(0);
|
||||
await expectExecutedPluginMarkersContain(page, BETA.markerKey);
|
||||
|
||||
await openPluginPageActions(page, BETA.name);
|
||||
await page.getByRole("menuitem", { name: "Block on this device", exact: true }).click();
|
||||
await expect(page.getByTestId("plugin-client-blocked-alert")).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("presents the queued approval bottom sheet cleanly on compact viewports and closes cleanly on dismiss", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
const artifacts = await ensureArtifactsDir(REPO_ROOT);
|
||||
|
||||
await withInstalledClientPlugins([ALPHA, BETA], async () => {
|
||||
await gotoAppShell(page);
|
||||
|
||||
await test.step("shows the first prompt in a compact bottom sheet", async () => {
|
||||
await expectPluginApprovalPrompt(page, { pluginId: ALPHA.id, progress: "1 of 2" });
|
||||
await waitForSettledPosition(pluginApprovalSheet(page));
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([]);
|
||||
await page.screenshot({ path: path.join(artifacts, "06-after-compact-sheet-1-of-2.png") });
|
||||
});
|
||||
|
||||
await test.step("approves the first and dismisses the remaining queue cleanly", async () => {
|
||||
await allowPluginExecution(page);
|
||||
await expectPluginApprovalPrompt(page, { pluginId: BETA.id, progress: "2 of 2" });
|
||||
await expectExecutedPluginMarkers(page, [ALPHA.markerKey]);
|
||||
|
||||
await page.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([ALPHA.markerKey]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("lets Settings -> General toggle bypass client plugin approval, persists across reload, and restores prompting when turned off", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
const artifacts = await ensureArtifactsDir(REPO_ROOT);
|
||||
|
||||
await withInstalledClientPlugins([ALPHA, BETA], async ({ install }) => {
|
||||
await gotoAppShell(page);
|
||||
|
||||
await test.step("approve one plugin and decline the other before opening Settings -> General", async () => {
|
||||
await expectPluginApprovalPrompt(page, { pluginId: ALPHA.id, progress: "1 of 2" });
|
||||
await allowPluginExecution(page);
|
||||
await expectPluginApprovalPrompt(page, { pluginId: BETA.id, progress: "2 of 2" });
|
||||
await declinePluginExecution(page);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
await expectExecutedPluginMarkers(page, [ALPHA.markerKey]);
|
||||
});
|
||||
|
||||
await test.step("General settings shows the minimal bypass toggle off by default", async () => {
|
||||
await openSettings(page);
|
||||
const row = page.getByTestId("settings-plugin-execution-bypass-row");
|
||||
await expect(row).toBeVisible();
|
||||
await expect(row).toContainText("Run plugins without asking");
|
||||
await expect(row).not.toContainText("Unsafe");
|
||||
await expect(row).toContainText(
|
||||
"Any connected host can run plugin code inside Paseo and reach your other hosts",
|
||||
);
|
||||
await expectPluginExecutionBypass(page, false);
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "settings-general-plugin-bypass-off-desktop.png"),
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("turning bypass on requires confirmation and canceling keeps it off", async () => {
|
||||
await openPluginExecutionBypassConfirm(page);
|
||||
const modal = pluginExecutionBypassConfirmModal(page);
|
||||
await expect(modal).toContainText("Run plugins without asking?");
|
||||
await expect(modal).toContainText(
|
||||
"Any connected host can run plugin code inside Paseo and reach your other connected hosts.",
|
||||
);
|
||||
await expectPluginExecutionBypass(page, false);
|
||||
await expect(modal.getByRole("dialog")).toHaveCSS("opacity", "1");
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "settings-general-plugin-bypass-confirm-desktop.png"),
|
||||
});
|
||||
|
||||
await cancelPluginExecutionBypassConfirm(page);
|
||||
expect(await getExecutedPluginMarkers(page)).toEqual([ALPHA.markerKey]);
|
||||
});
|
||||
|
||||
await test.step("confirming turns bypass on and runs declined and newly installed plugins without prompting", async () => {
|
||||
await openPluginExecutionBypassConfirm(page);
|
||||
await confirmPluginExecutionBypass(page);
|
||||
await expectExecutedPluginMarkersContain(page, BETA.markerKey);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
|
||||
await install(GAMMA);
|
||||
await expectExecutedPluginMarkersContain(page, GAMMA.markerKey);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
// Let the 180ms switch track animation settle before capturing the ON screenshot.
|
||||
await page.waitForTimeout(300);
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "settings-general-plugin-bypass-on-desktop.png"),
|
||||
});
|
||||
});
|
||||
|
||||
await test.step("reloading preserves bypass on and runs all plugins without prompting", async () => {
|
||||
await reloadKeepingPersistedState(page);
|
||||
await expectPluginExecutionBypass(page, true);
|
||||
await expectExecutedPluginMarkersContain(page, ALPHA.markerKey);
|
||||
await expectExecutedPluginMarkersContain(page, BETA.markerKey);
|
||||
await expectExecutedPluginMarkersContain(page, GAMMA.markerKey);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
});
|
||||
|
||||
await test.step("turning bypass off needs no confirmation, restores prompting for unreviewed plugins, and persists across reload", async () => {
|
||||
await setPluginExecutionBypass(page, false);
|
||||
await expectPluginApprovalPrompt(page, { pluginId: GAMMA.id });
|
||||
await declinePluginExecution(page);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
|
||||
await reloadKeepingPersistedState(page);
|
||||
await expectPluginExecutionBypass(page, false);
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
await expectExecutedPluginMarkers(page, [ALPHA.markerKey]);
|
||||
});
|
||||
|
||||
await test.step("compact mobile viewport renders the General toggle and confirm sheet cleanly", async () => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
const row = page.getByTestId("settings-plugin-execution-bypass-row");
|
||||
const toggle = pluginExecutionBypassSwitch(page);
|
||||
await expect(row).toBeVisible();
|
||||
await expect(toggle).toBeVisible();
|
||||
const rowBox = await row.boundingBox();
|
||||
const toggleBox = await toggle.boundingBox();
|
||||
expect(rowBox).not.toBeNull();
|
||||
expect(toggleBox).not.toBeNull();
|
||||
expect(toggleBox!.x + toggleBox!.width).toBeLessThanOrEqual(390);
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "settings-general-plugin-bypass-compact.png"),
|
||||
});
|
||||
|
||||
await openPluginExecutionBypassConfirm(page);
|
||||
await waitForSettledPosition(pluginExecutionBypassConfirmModal(page));
|
||||
await page.screenshot({
|
||||
path: path.join(artifacts, "settings-general-plugin-bypass-confirm-compact.png"),
|
||||
});
|
||||
await cancelPluginExecutionBypassConfirm(page);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import type { Frame, TestInfo } from "@playwright/test";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
@@ -172,6 +173,7 @@ test("directory examples mount the PDF frame and write Markdown through the file
|
||||
await page.setViewportSize(WIDE);
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, ["pdf-panel", "markdown-panel"]);
|
||||
await openFileExplorer(page);
|
||||
await openFile(page, "report.pdf");
|
||||
await expect(page.getByTitle("Document preview", { exact: true })).toHaveAttribute(
|
||||
|
||||
@@ -6,6 +6,7 @@ import { expectFileTabOpen, openFileExplorer } from "../support/helpers/file-exp
|
||||
import {
|
||||
BUILTIN_MARKDOWN_OPTION,
|
||||
MARKDOWN_PANEL_ID,
|
||||
MARKDOWN_PANEL_PLUGIN_ID,
|
||||
PLUGIN_MARKDOWN_OPTION,
|
||||
expectBuiltinMarkdown,
|
||||
expectPluginMarkdown,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
openMarkdown,
|
||||
storedFilePanelAssociations,
|
||||
} from "../support/helpers/markdown-file-panel-plugin";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
|
||||
async function choosePanel(page: Page, option: string, options: { remember: boolean }) {
|
||||
await page.getByRole("radio", { name: option, exact: true }).click();
|
||||
@@ -110,6 +112,7 @@ test("asks once which panel opens Markdown and remembers it when told to", async
|
||||
try {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, [MARKDOWN_PANEL_PLUGIN_ID]);
|
||||
await openFileExplorer(page);
|
||||
|
||||
// First open: the built-in renders under the picker.
|
||||
|
||||
@@ -6,6 +6,7 @@ import { gotoWorkspace } from "../support/helpers/launcher";
|
||||
import {
|
||||
BUILTIN_MARKDOWN_OPTION,
|
||||
MARKDOWN_PANEL_ID,
|
||||
MARKDOWN_PANEL_PLUGIN_ID,
|
||||
PLUGIN_MARKDOWN_OPTION,
|
||||
expectPluginMarkdown,
|
||||
filePanelPicker,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
openMarkdown,
|
||||
storedFilePanelAssociations,
|
||||
} from "../support/helpers/markdown-file-panel-plugin";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { openSettingsSection } from "../support/helpers/settings";
|
||||
|
||||
@@ -59,6 +61,7 @@ test("Settings > Files chooses which panel opens .md and asks again on request",
|
||||
try {
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, [MARKDOWN_PANEL_PLUGIN_ID]);
|
||||
await openFilesSettings(page);
|
||||
|
||||
// Nothing remembered: the row asks every time and has nothing to forget.
|
||||
|
||||
@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { installDaemonWebSocketGate } from "../support/helpers/daemon-websocket-gate";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
@@ -131,6 +132,7 @@ test("directory plugins render PDF bytes and write Markdown through the file han
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
const gate = await installDaemonWebSocketGate(page);
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await openFileExplorer(page);
|
||||
await openWorkspaceFile(page, "report.pdf");
|
||||
await expect(page.getByText("PDF plugin: report.pdf", { exact: true })).toBeVisible();
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
expectRemovedPlugin,
|
||||
} from "../support/helpers/plugin-reconnect";
|
||||
import { verifyPluginTranslations } from "../support/helpers/plugin-translations";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -98,6 +99,7 @@ export default function contribute(plugin) {
|
||||
|
||||
async function openHostUiPlugin(page: Page): Promise<void> {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.getByRole("button", { name: "Host UI", exact: true }).click();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { expect, test, type Page } from "../support/fixtures";
|
||||
import { openCommandCenter } from "../support/helpers/command-center";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
@@ -87,6 +88,7 @@ test.describe("plugin icons", () => {
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
const target = { serverId: getServerId(), workspaceId: workspace.workspaceId };
|
||||
await waitForWorkspaceInSidebar(page, target);
|
||||
await switchWorkspaceViaSidebar({ page, ...target });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import overviewCorpus from "../../../protocol/tests/fixtures/plugin-overview.json";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
@@ -500,6 +501,7 @@ async function installLocalPluginWithStatusExamples(
|
||||
|
||||
const catalog = observePluginCatalog(page);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["failed-preview-plugin"]);
|
||||
await openPluginSettings(page);
|
||||
await catalog.waitForInitialFetch();
|
||||
await expectPluginFailed(page, "failed-preview-plugin");
|
||||
@@ -514,6 +516,7 @@ async function installLocalPluginWithStatusExamples(
|
||||
await openSourceInstall(page);
|
||||
await expectPluginSourceDocsOpen(page);
|
||||
await submitSourceInstall(page, directory);
|
||||
await approveClientPluginsInUi(page, ["e2e-plugin"]);
|
||||
await expectSourceInstalled(page, "e2e-plugin");
|
||||
await expectPluginOn(page, "e2e-plugin");
|
||||
await expectPluginHealthy(page, "e2e-plugin");
|
||||
@@ -605,6 +608,7 @@ async function toggleRemoveAndReinstallLocalPlugin(page: Page, directory: string
|
||||
await expectPluginRemoved(page, "e2e-plugin");
|
||||
|
||||
await installFromSource(page, directory, "e2e-plugin");
|
||||
await approveClientPluginsInUi(page, ["e2e-plugin"]);
|
||||
await expectPluginOn(page, "e2e-plugin");
|
||||
await gotoAppShell(page);
|
||||
await openContribution(page, "Plugin v3", "Plugin v3 cleanup 7");
|
||||
@@ -659,6 +663,10 @@ async function retryGitInstallAndInspectRows(
|
||||
await capturePluginInstallForm(page, testInfo, "compact-error");
|
||||
|
||||
await submitSourceInstall(page, pathToFileURL(repository).href);
|
||||
await approveClientPluginsInUi(page, [
|
||||
"compact-plugin-with-a-realistically-long-name",
|
||||
"git-e2e-plugin",
|
||||
]);
|
||||
await expectSourceInstalled(page, "git-e2e-plugin");
|
||||
await expectPluginsOn(page);
|
||||
await expectPluginOn(page, "git-e2e-plugin");
|
||||
@@ -724,6 +732,7 @@ async function prepareLegacyPluginHost(
|
||||
pluginGitManagement: true,
|
||||
});
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["legacy-source-plugin"]);
|
||||
await openPluginSettings(page);
|
||||
|
||||
return directory;
|
||||
@@ -906,6 +915,7 @@ test("keeps Reload pending past a minute while the plugin queue is busy", async
|
||||
// Plugins on is a precondition here, not the subject: set it through the daemon.
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installPluginSource({ source: pluginDirectory });
|
||||
await approveClientPluginsInUi(page, ["e2e-plugin"]);
|
||||
// Installed before Plugins opens, so it opens on the Installed tab.
|
||||
await openPluginSettings(page);
|
||||
await expectPluginOn(page, "e2e-plugin");
|
||||
@@ -928,6 +938,7 @@ test("keeps Reload pending past a minute while the plugin queue is busy", async
|
||||
await capturePluginSurface(page, testInfo, "plugin-reload-past-deadline.png");
|
||||
|
||||
await queue.release();
|
||||
await approveClientPluginsInUi(page, ["gated-build-plugin"]);
|
||||
// The daemon's answer only arrives once the plugin really started again.
|
||||
await reload.waitForResponse();
|
||||
expect(reload.requestCount()).toBe(1);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { expect, test as base, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
@@ -119,6 +120,7 @@ const test = base.extend<{ modalExample: Page }>({
|
||||
async function openWideExamples(page: Page) {
|
||||
await page.setViewportSize({ width: 1100, height: 800 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["modal-ui-example"]);
|
||||
await page.getByRole("button", { name: "Modal examples", exact: true }).click();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { expect, test, type Page } from "../support/fixtures";
|
||||
import { composerLocator, submitMessageWithButton } from "../support/helpers/composer";
|
||||
import { seedMockAgentWorkspace, openAgentRoute } from "../support/helpers/mock-agent";
|
||||
import { withPopoverTimelinePlugin } from "../support/helpers/plugin-timeline";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { POPOVER_PLUGIN_ID, withPopoverTimelinePlugin } from "../support/helpers/plugin-timeline";
|
||||
|
||||
async function openPreviewWhileTyping(page: Page): Promise<void> {
|
||||
await composerLocator(page).focus();
|
||||
@@ -25,6 +26,7 @@ test("Escape dismisses a plugin preview before interrupting the agent", async ({
|
||||
try {
|
||||
await withPopoverTimelinePlugin(async () => {
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, [POPOVER_PLUGIN_ID]);
|
||||
await submitMessageWithButton(page, "Show the plugin preview.");
|
||||
await agent.client.waitForFinish(agent.agentId, 30_000);
|
||||
await expect(page.getByRole("button", { name: "Hover plugin preview" })).toBeVisible();
|
||||
|
||||
@@ -12,7 +12,7 @@ test("shows which runtime is incompatible and recovers after the requirement is
|
||||
}) => {
|
||||
await openRequirementHost(page, requirementHost);
|
||||
await expectAppMismatch(page);
|
||||
await correctRequirementAndReload(page, requirementHost.directory);
|
||||
await correctRequirementAndReload(page, requirementHost.directory, { approvePrompt: true });
|
||||
await rejectDaemonMismatch(page, requirementHost.directory);
|
||||
await correctRequirementAndReload(page, requirementHost.directory);
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
LEGACY_PLUGIN_ID,
|
||||
SHOWCASE_PLUGIN_ID,
|
||||
WIDE,
|
||||
approveSidebarPluginsInUi,
|
||||
closeScreen,
|
||||
expectRowActive,
|
||||
footerItem,
|
||||
@@ -182,6 +183,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 390, height: 600 });
|
||||
await gotoAppShell(page);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await page.getByRole("button", { name: "Open menu", exact: true }).first().click();
|
||||
await expect(botRow(page, "status")).toBeAttached();
|
||||
const workspace = visibleTestId(page, `sidebar-workspace-row-${getServerId()}:${workspaceId}`);
|
||||
@@ -213,6 +215,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 480 });
|
||||
await gotoAppShell(page);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await expect(botRow(page, "status")).toBeAttached();
|
||||
const workspace = visibleTestId(page, `sidebar-workspace-row-${getServerId()}:${workspaceId}`);
|
||||
await expect(workspace).toBeInViewport({ ratio: 1 });
|
||||
@@ -240,6 +243,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test("a restored plugin screen waits for its catalog before rendering", async ({ page }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
const row = headerRow(page, SHOWCASE_PLUGIN_ID, "deploys");
|
||||
await expect(row).toBeVisible({ timeout: 30_000 });
|
||||
await row.click();
|
||||
@@ -278,6 +282,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
await seedSidebarFooterPreferences(page, [{ key: "usage", visible: true }]);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
const row = headerRow(page, SHOWCASE_PLUGIN_ID, "deploys");
|
||||
const sync = footerItem(page, SHOWCASE_PLUGIN_ID, "sync");
|
||||
await expect(row).toBeVisible({ timeout: 30_000 });
|
||||
@@ -365,6 +370,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test("a plugin screen reads workspaces through the state hooks", async ({ page }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await expect(headerRow(page, SHOWCASE_PLUGIN_ID, "deploys")).toBeVisible({ timeout: 30_000 });
|
||||
await runCommand(page, "Open plugin workspaces");
|
||||
await expect(screenTitle(page)).toHaveText("Workspaces");
|
||||
@@ -375,6 +381,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test("a plugin screen keeps the sidebar toggle before its title", async ({ page }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await expect(headerRow(page, SHOWCASE_PLUGIN_ID, "deploys")).toBeVisible({ timeout: 30_000 });
|
||||
await runCommand(page, "Open plugin workspaces");
|
||||
await expect(screenTitle(page)).toHaveText("Workspaces");
|
||||
@@ -394,6 +401,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test("a header row's shortcut hint presses the row", async ({ page }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
const newWorkspace = visibleTestId(page, "sidebar-global-new-workspace");
|
||||
await expect(newWorkspace).toBeVisible({ timeout: 30_000 });
|
||||
await newWorkspace.hover();
|
||||
@@ -419,6 +427,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
const entry = headerRow(page, LEGACY_PLUGIN_ID, "entry");
|
||||
await expect(entry).toBeVisible({ timeout: 30_000 });
|
||||
let entryIcon = "";
|
||||
@@ -503,6 +512,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test.setTimeout(180_000);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
const bot1 = botRow(page, "bot-1");
|
||||
const bot2 = botRow(page, "bot-2");
|
||||
const status = botRow(page, "status");
|
||||
@@ -587,6 +597,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
test.setTimeout(120_000);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await expect(botRow(page, "bot-1")).toBeVisible({ timeout: 30_000 });
|
||||
const alerts = footerItem(page, BOTS_PLUGIN_ID, "alerts");
|
||||
await expect(alerts).toHaveCount(0);
|
||||
@@ -606,6 +617,7 @@ test.describe("Plugin sidebar items", () => {
|
||||
const alerts = footerItem(page, BOTS_PLUGIN_ID, "alerts");
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
await expect(botRow(page, "bot-1")).toBeVisible({ timeout: 30_000 });
|
||||
|
||||
await runCommand(page, "Add bot alerts");
|
||||
|
||||
@@ -4,6 +4,7 @@ import { expect, test, type Page } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { openCommandCenter } from "../support/helpers/command-center";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { seedWorkspace, type SeededWorkspace } from "../support/helpers/seed-client";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
@@ -34,6 +35,7 @@ async function withExample(
|
||||
await client.installDirectoryPlugin(copy.directory);
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [example.id]);
|
||||
const target = { serverId: getServerId(), workspaceId: workspace.workspaceId };
|
||||
await waitForWorkspaceInSidebar(page, target);
|
||||
await switchWorkspaceViaSidebar({ page, ...target });
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -63,8 +64,11 @@ const MOCHA_MUTED_FOREGROUND = "rgb(166, 173, 200)";
|
||||
const LATTE_MUTED_FOREGROUND = "rgb(108, 111, 133)";
|
||||
const LATTE_RING = "rgb(156, 160, 176)";
|
||||
|
||||
async function selectTheme(page: Page, name: string) {
|
||||
async function selectTheme(page: Page, name: string, approvePluginId?: string) {
|
||||
await page.goto("/settings");
|
||||
if (approvePluginId) {
|
||||
await approveClientPluginsInUi(page, [approvePluginId]);
|
||||
}
|
||||
await openSettingsSection(page, "appearance");
|
||||
const theme = page.getByRole("radio", { name, exact: true });
|
||||
await expect(theme).toBeVisible({ timeout: 30_000 });
|
||||
@@ -108,7 +112,7 @@ test("keeps plugin workspace timestamps readable on state surfaces and honors ov
|
||||
try {
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await selectTheme(page, "Solarized Dark");
|
||||
await selectTheme(page, "Solarized Dark", PLUGIN_ID);
|
||||
await openAgentRoute(page, selected);
|
||||
const selectedRow = page.getByTestId(
|
||||
`sidebar-workspace-row-${getServerId()}:${selected.workspaceId}`,
|
||||
@@ -160,6 +164,7 @@ test("applies a contributed theme and falls back when its plugin is gone", async
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.goto("/settings");
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await expect(page.getByTestId("settings-sidebar")).toBeVisible();
|
||||
await openSettingsSection(page, "appearance");
|
||||
|
||||
@@ -263,6 +268,7 @@ test("reaches the last theme when a plugin contributes more themes than fit", as
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize({ width: 1280, height: 720 });
|
||||
await page.goto("/settings");
|
||||
await approveClientPluginsInUi(page, [MANY_THEMES_PLUGIN_ID]);
|
||||
await expect(page.getByTestId("settings-sidebar")).toBeVisible();
|
||||
await openSettingsSection(page, "appearance");
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { submitMessageWithButton } from "../support/helpers/composer";
|
||||
import { openFileExplorer, openFileFromExplorer } from "../support/helpers/file-explorer";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { runCommand } from "../support/helpers/plugin-sidebar-items";
|
||||
import {
|
||||
@@ -214,6 +215,7 @@ test("the workspace layout example arranges a wide workspace", async ({ page })
|
||||
await withLayoutExample(undefined, async ({ agentId, workspaceId }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await openAgentRoute(page, { workspaceId, agentId });
|
||||
await approveClientPluginsInUi(page, ["workspace-layout"]);
|
||||
|
||||
await test.step("/aside opens the child agent's chat in the Explorer", async () => {
|
||||
await sendToMainChat(page, "/aside hey");
|
||||
@@ -264,6 +266,7 @@ test("the workspace layout example opens over a phone's chat", async ({ page })
|
||||
await withLayoutExample(promptMentioning(FILE_LINK), async ({ agentId, workspaceId }) => {
|
||||
await page.setViewportSize(COMPACT);
|
||||
await openAgentRoute(page, { workspaceId, agentId });
|
||||
await approveClientPluginsInUi(page, ["workspace-layout"]);
|
||||
|
||||
await test.step("/aside opens the Explorer over the chat", async () => {
|
||||
await submitMessageWithButton(page, "/aside hey");
|
||||
@@ -302,6 +305,7 @@ test("a file a plugin opens in another workspace waits there on a phone", async
|
||||
await page.setViewportSize(COMPACT);
|
||||
// Visiting the first workspace leaves its screen mounted behind the second.
|
||||
await openAgentRoute(page, first);
|
||||
await approveClientPluginsInUi(page, ["workspace-layout"]);
|
||||
await expect(composerIn(page.locator("body"))).toBeEditable({ timeout: 30_000 });
|
||||
await switchToWorkspace(page, second.workspaceId);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -297,6 +298,7 @@ test.describe("plugin workspace panels and Command Center", () => {
|
||||
await primaryClient.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize(WIDE_VIEWPORT);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await addConnectedHostAndReload(page, {
|
||||
serverId: secondaryDaemon.serverId,
|
||||
label: "Secondary plugin host",
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { connectNewWorkspaceDaemonClient } from "../support/helpers/new-workspace";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { pluginRequirements } from "../support/helpers/plugin-fixture";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import {
|
||||
@@ -95,6 +96,7 @@ test("a plugin badge shows on workspace rows, hides quietly, and follows its Sho
|
||||
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
|
||||
await test.step("the badge draws on the row; a null item and a throwing item draw nothing", async () => {
|
||||
await expect(badge(page, "review")).toBeVisible();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
openSettingsHost,
|
||||
openSettingsHostSection,
|
||||
} from "../support/helpers/settings";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
|
||||
const CUSTOM_PROVIDER = {
|
||||
@@ -202,6 +203,7 @@ test.describe("provider removal", () => {
|
||||
await client.installDirectoryPlugin(plugin.directory);
|
||||
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_PROVIDER.pluginId]);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, getServerId());
|
||||
await openSettingsHostSection(page, getServerId(), "providers");
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from "../support/helpers/composer";
|
||||
import { connectDaemonClient } from "../support/helpers/daemon-client-loader";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { copyPluginExample } from "../support/helpers/plugin-fixture";
|
||||
import { userScrollsTimelineToHistoryStart } from "../support/helpers/timeline-pagination";
|
||||
|
||||
@@ -266,6 +267,7 @@ test.describe.serial("Provider switching in chat", () => {
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, workspace);
|
||||
await approveClientPluginsInUi(page, [DIRECT_PROVIDER.pluginId]);
|
||||
await expectComposerVisible(page);
|
||||
await expectComposerMode(page, "Load test");
|
||||
|
||||
@@ -461,6 +463,7 @@ test.describe.serial("Provider switching in chat", () => {
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, workspace);
|
||||
await approveClientPluginsInUi(page, [DIRECT_PROVIDER.pluginId]);
|
||||
await expectComposerVisible(page);
|
||||
|
||||
await submitMessage(page, runningPrompt);
|
||||
@@ -513,6 +516,7 @@ test.describe.serial("Provider switching in chat", () => {
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, workspace);
|
||||
await approveClientPluginsInUi(page, [DIRECT_PROVIDER.pluginId]);
|
||||
await expectComposerVisible(page);
|
||||
await submitMessage(page, "Run a one-minute mock turn first.");
|
||||
await expectAgentReadyToInterrupt(page);
|
||||
@@ -567,6 +571,7 @@ test.describe.serial("Provider switching in chat", () => {
|
||||
|
||||
try {
|
||||
await openAgentRoute(page, workspace);
|
||||
await approveClientPluginsInUi(page, [DIRECT_PROVIDER.pluginId]);
|
||||
await expectComposerVisible(page);
|
||||
|
||||
await submitMessageWithButton(page, preSwitchPrompt);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
test("a refresh clears a failed update from the provider's page and its row", async ({
|
||||
providerUpdateFailure: { page, otherClient },
|
||||
}) => {
|
||||
await openProviderInstallation(page);
|
||||
await openProviderInstallation(page, { approvePlugin: true });
|
||||
|
||||
await test.step("Refresh on the page clears the failure", async () => {
|
||||
await runFailingUpdate(page);
|
||||
|
||||
@@ -9,7 +9,11 @@ import {
|
||||
expectCompactSidebarOpen,
|
||||
} from "../support/helpers/usage-sidebar-item";
|
||||
import { gotoAppShell } from "../support/helpers/app";
|
||||
import { SHOWCASE_PLUGIN_ID, installSidebarPlugins } from "../support/helpers/plugin-sidebar-items";
|
||||
import {
|
||||
SHOWCASE_PLUGIN_ID,
|
||||
approveSidebarPluginsInUi,
|
||||
installSidebarPlugins,
|
||||
} from "../support/helpers/plugin-sidebar-items";
|
||||
import {
|
||||
expectFooterIconRow,
|
||||
expectFooterSeparator,
|
||||
@@ -227,6 +231,7 @@ test.describe("Sidebar footer rows in Appearance settings", () => {
|
||||
{ key: "import", visible: false },
|
||||
]);
|
||||
await gotoAppShell(page);
|
||||
await approveSidebarPluginsInUi(page);
|
||||
|
||||
await test.step("the Footer card lists only the footer rows", async () => {
|
||||
await openSidebarNavSettings(page);
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getActiveTabTestId } from "../support/helpers/launcher";
|
||||
import type { Page, Locator } from "@playwright/test";
|
||||
import { test, expect } from "../support/fixtures";
|
||||
import { expectComposerVisible } from "../support/helpers/composer";
|
||||
import { approveClientPluginsInUi } from "../support/helpers/plugin-execution-approval";
|
||||
import { withDirectoryPlugin } from "../support/helpers/plugin-timeline";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
|
||||
import { getE2EDaemonPort } from "../support/helpers/daemon-port";
|
||||
@@ -188,6 +189,7 @@ export default function contribute(client) {
|
||||
run: async () => {
|
||||
await page.setViewportSize({ width: 1280, height: 1000 });
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, ["reply-fold-e2e"]);
|
||||
await expectComposerVisible(page);
|
||||
for (const width of [1280, 390]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
|
||||
@@ -34,7 +34,9 @@ function report(input: {
|
||||
sourceLabel: input.sourceLabel,
|
||||
icon: ICON,
|
||||
report:
|
||||
input.report.status === "error" || input.report.status === "unavailable"
|
||||
input.report.status === "error" ||
|
||||
input.report.status === "unavailable" ||
|
||||
input.report.status === "not_fetched"
|
||||
? input.report
|
||||
: {
|
||||
status: "available",
|
||||
@@ -138,6 +140,45 @@ test.describe("usage settings", () => {
|
||||
await expect(card.getByText("64% used")).toBeVisible();
|
||||
});
|
||||
|
||||
test("a manual report asks for Refresh and changes only on the user's Refresh", async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(120_000);
|
||||
const serverId = getServerId();
|
||||
const manual = (entry: UsageReportEntry): UsageReportEntry => ({ ...entry, refresh: "manual" });
|
||||
const usage = await installUsageReportsFixture(page, {
|
||||
lists: [
|
||||
(request) => [
|
||||
manual(
|
||||
report({
|
||||
sourceId: "quota",
|
||||
sourceLabel: "Quota",
|
||||
report: request.forceRefresh
|
||||
? { status: "available", windows: [{ id: "w", label: "Weekly", usedPct: 12 }] }
|
||||
: { status: "not_fetched" },
|
||||
}),
|
||||
),
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHostSection(page, serverId, "usage");
|
||||
const card = page.getByTestId("usage-report-quota:account");
|
||||
await expect(
|
||||
card.getByText("Not checked yet. Quota usage updates only when you refresh it."),
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
await expect(card.getByText("Error", { exact: true })).toHaveCount(0);
|
||||
expect(forcedRefreshCount(usage)).toBe(0);
|
||||
|
||||
await card.getByTestId("usage-refresh").click();
|
||||
await expect(card.getByText("12% used")).toBeVisible();
|
||||
expect(usage.listRequests().filter((request) => request.forceRefresh)).toEqual([
|
||||
{ forceRefresh: true, reportIds: ["quota:account"] },
|
||||
]);
|
||||
});
|
||||
|
||||
test("asks to update a host without usage support and never calls it", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
const serverId = getServerId();
|
||||
|
||||
@@ -3,12 +3,17 @@ import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "../support/fixtures";
|
||||
import { createIdleAgent } from "../support/helpers/archive-tab";
|
||||
import { expectComposerVisible } from "../support/helpers/composer";
|
||||
import { clickNewTerminal, terminalSurfaceLocator } from "../support/helpers/launcher";
|
||||
import {
|
||||
clickNewChat,
|
||||
clickNewTerminal,
|
||||
terminalSurfaceLocator,
|
||||
} from "../support/helpers/launcher";
|
||||
import { renameModalInput } from "../support/helpers/rename";
|
||||
import { seedWorkspace } from "../support/helpers/seed-client";
|
||||
import { getServerId } from "../support/helpers/server-id";
|
||||
import { clickSettingsBackToWorkspace, openCompactSettings } from "../support/helpers/settings";
|
||||
import { openSettings } from "../support/helpers/app";
|
||||
import { gotoAppShell, openSettings } from "../support/helpers/app";
|
||||
import { selectWorkspaceInSidebar } from "../support/helpers/sidebar";
|
||||
import { runWorkspaceActionFromCommandCenter } from "../support/helpers/command-center-workspace-actions";
|
||||
import {
|
||||
clickFirstTerminalTab,
|
||||
@@ -35,8 +40,12 @@ async function expectSameRenderedNode(
|
||||
);
|
||||
}
|
||||
|
||||
function isRenderedNodeConnected(node: Awaited<ReturnType<typeof captureRenderedNode>>) {
|
||||
return node.evaluate((candidate) => candidate.isConnected);
|
||||
}
|
||||
|
||||
async function expectNodeConnected(node: Awaited<ReturnType<typeof captureRenderedNode>>) {
|
||||
expect(await node.evaluate((candidate) => candidate.isConnected)).toBe(true);
|
||||
expect(await isRenderedNodeConnected(node)).toBe(true);
|
||||
}
|
||||
|
||||
async function getSettingsShortcut(page: Page) {
|
||||
@@ -50,6 +59,34 @@ async function waitForWorkspaceRoute(page: Page, route: string) {
|
||||
}
|
||||
|
||||
test.describe("Workspace pane mounting", () => {
|
||||
test("inactive composers expire while switching between other workspaces", async ({
|
||||
page,
|
||||
withWorkspace,
|
||||
}) => {
|
||||
const first = await withWorkspace({ prefix: "deck-expiry-first-" });
|
||||
const second = await withWorkspace({ prefix: "deck-expiry-second-" });
|
||||
const third = await withWorkspace({ prefix: "deck-expiry-third-" });
|
||||
const oneMinute = 60_000;
|
||||
|
||||
await page.clock.install();
|
||||
await gotoAppShell(page);
|
||||
await selectWorkspaceInSidebar(page, first.workspaceId);
|
||||
await clickNewChat(page);
|
||||
const composer = await captureRenderedNode(
|
||||
page.getByTestId("message-input-root").filter({ visible: true }),
|
||||
);
|
||||
|
||||
await selectWorkspaceInSidebar(page, second.workspaceId);
|
||||
await expect(page).toHaveURL(buildHostWorkspaceRoute(getServerId(), second.workspaceId));
|
||||
await page.clock.fastForward(9 * oneMinute);
|
||||
await expectNodeConnected(composer);
|
||||
|
||||
await selectWorkspaceInSidebar(page, third.workspaceId);
|
||||
await expect(page).toHaveURL(buildHostWorkspaceRoute(getServerId(), third.workspaceId));
|
||||
await page.clock.fastForward(2 * oneMinute);
|
||||
await expect.poll(() => isRenderedNodeConnected(composer)).toBe(false);
|
||||
});
|
||||
|
||||
test("workspace navigation keeps the existing agent composer mounted", async ({ page }) => {
|
||||
test.setTimeout(90_000);
|
||||
// Keep both split panes wide enough for the tab-rail interactions below.
|
||||
|
||||
@@ -13,6 +13,8 @@ function ad(...args) {
|
||||
});
|
||||
}
|
||||
|
||||
ad("press", 'label="Pair a device"', "--settle");
|
||||
ad("wait", "text", "Relay", "10000");
|
||||
ad("press", 'label="Relay"', "--settle");
|
||||
ad("wait", "text", "Pairing QR code", "10000");
|
||||
const { data } = JSON.parse(ad("snapshot", "-i", "--json"));
|
||||
|
||||
@@ -6,6 +6,7 @@ import appPackage from "../../../package.json";
|
||||
import { expect, test as base, type Page } from "../fixtures";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { addConnectedHostAndReload } from "./hosts";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
const pluginId = "builtin-settings";
|
||||
@@ -69,6 +70,7 @@ export async function openBuiltinPluginSettings(
|
||||
label: "Built-in settings host",
|
||||
destination: `/settings/hosts/${host.serverId}/plugins/${pluginId}/${screenId}`,
|
||||
});
|
||||
await approveClientPluginsInUi(page, [pluginId]);
|
||||
}
|
||||
|
||||
export async function expectBuiltinPluginSettings(page: Page) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { WorkspaceCreateRequest } from "@getpaseo/protocol/messages";
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
import { daemonWsRoutePattern } from "./daemon-port";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { gotoWorkspace } from "./launcher";
|
||||
import { fillComposerDraft } from "./composer";
|
||||
import { createAgentTabFromMenu } from "./workspace-tabs";
|
||||
@@ -146,8 +147,14 @@ export async function createCreationScenario(page: Page) {
|
||||
const evictionWorkspaceIds = new Set<string>();
|
||||
return {
|
||||
cleanup: project.cleanup,
|
||||
async openWorkspaceForm(isolation: "local" | "worktree") {
|
||||
async openWorkspaceForm(
|
||||
isolation: "local" | "worktree",
|
||||
options?: { approvePlugins?: readonly string[] },
|
||||
) {
|
||||
await gotoAppShell(page);
|
||||
if (options?.approvePlugins?.length) {
|
||||
await approveClientPluginsInUi(page, options.approvePlugins);
|
||||
}
|
||||
await waitForSidebarHydration(page);
|
||||
await openNewWorkspaceComposer(page, project);
|
||||
await selectWorkspaceIsolation(page, isolation);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { expect, type Page, type TestInfo } from "@playwright/test";
|
||||
import { gotoWorkspace } from "./launcher";
|
||||
import { buildAgentRoute } from "./mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
import { seedWorkspace } from "./seed-client";
|
||||
import { ensureExplorerSidebar } from "./workspace-tabs";
|
||||
@@ -63,6 +64,7 @@ export async function withExplorerPanelPlugins(
|
||||
await client.installDirectoryPlugin(second);
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, ["explorer-review", "explorer-other"]);
|
||||
|
||||
await run(workspace);
|
||||
} finally {
|
||||
|
||||
@@ -132,11 +132,31 @@ export class ImportSessionFlow {
|
||||
}
|
||||
async retryProvider(provider: string, label: string) {
|
||||
await this.expectProviderError(label);
|
||||
await this.page.getByTestId(`import-session-retry-${provider}`).click();
|
||||
await this.startProviderRetry(provider);
|
||||
await expect(this.page.getByTestId(`import-session-retry-${provider}`)).toBeEnabled();
|
||||
await this.expectProviderError(label);
|
||||
await expect(this.page.getByRole("progressbar")).toHaveCount(0);
|
||||
}
|
||||
async startProviderRetry(provider: string) {
|
||||
await this.page.getByTestId(`import-session-retry-${provider}`).click();
|
||||
}
|
||||
async expectProviderRetryPending(provider: string) {
|
||||
await expect(this.page.getByTestId(`import-session-retry-${provider}`)).toBeDisabled();
|
||||
}
|
||||
async expectProviderRequestTimeout() {
|
||||
await expect(
|
||||
this.page
|
||||
.getByText("No response to fetch_recent_provider_sessions_request after 100000ms", {
|
||||
exact: true,
|
||||
})
|
||||
.first(),
|
||||
).toBeVisible();
|
||||
}
|
||||
async expectProviderRecovered(label: string) {
|
||||
await expect(
|
||||
this.page.getByText(`Could not load ${label} sessions`, { exact: true }),
|
||||
).toHaveCount(0);
|
||||
}
|
||||
async startImport(id: string) {
|
||||
await this.revealSession(id);
|
||||
await this.page.getByTestId(rowTestId(id)).click();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
import { expect, type Page, type WebSocket } from "@playwright/test";
|
||||
import { openSettingsSection } from "./settings";
|
||||
|
||||
export interface RecordedBrowserNotification {
|
||||
@@ -75,6 +75,32 @@ export async function installBrowserNotificationRecorder(page: Page): Promise<vo
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the app and waits until it has told the daemon this device is present.
|
||||
*
|
||||
* The daemon shows an attention notification only on a client that has sent a
|
||||
* heartbeat. Settings render from local storage before the reloaded app connects,
|
||||
* so an agent that finishes right after the reload finds no present client and
|
||||
* no notification is shown.
|
||||
*/
|
||||
export async function reloadAndWaitForDevicePresence(page: Page): Promise<void> {
|
||||
let presenceReported = false;
|
||||
const watchHeartbeats = (socket: WebSocket) => {
|
||||
socket.on("framesent", (frame) => {
|
||||
if (typeof frame.payload === "string" && frame.payload.includes('"client_heartbeat"')) {
|
||||
presenceReported = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
page.on("websocket", watchHeartbeats);
|
||||
try {
|
||||
await page.reload();
|
||||
await expect.poll(() => presenceReported).toBe(true);
|
||||
} finally {
|
||||
page.off("websocket", watchHeartbeats);
|
||||
}
|
||||
}
|
||||
|
||||
export async function readRecordedBrowserNotifications(
|
||||
page: Page,
|
||||
): Promise<RecordedBrowserNotification[]> {
|
||||
|
||||
@@ -134,7 +134,7 @@ export async function addProjectFromSetup(page: Page, projectPath: string): Prom
|
||||
|
||||
export async function showSetupAgainFromSettings(page: Page): Promise<void> {
|
||||
await page.locator('[data-testid="sidebar-settings"]:visible').first().click();
|
||||
await page.getByRole("button", { name: "Show setup again", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Show", exact: true }).click();
|
||||
}
|
||||
|
||||
export async function goToSetupStep(page: Page, label: string): Promise<void> {
|
||||
|
||||
@@ -66,6 +66,56 @@ type PairingHost =
|
||||
| Pick<IsolatedHostDaemon, "serverId" | "port">
|
||||
| Pick<OutdatedDaemon, "serverId" | "endpoint">;
|
||||
|
||||
export async function openDevicesPage(page: Page, daemon: PairingHost): Promise<void> {
|
||||
await openAppOnPairingHost(page, daemon);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, daemon.serverId);
|
||||
await openSettingsHostSection(page, daemon.serverId, "devices");
|
||||
await expect(page.getByTestId("devices-connected-clients-card")).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectConnectedClientRow(
|
||||
page: Page,
|
||||
title: string,
|
||||
scopeLabel: string,
|
||||
): Promise<void> {
|
||||
const card = page.getByTestId("devices-connected-clients-card");
|
||||
const row = card.getByRole("button", { name: title, exact: true });
|
||||
await expect(row).toBeVisible();
|
||||
await expect(card.getByText(scopeLabel, { exact: true }).first()).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expandConnectedClientRow(page: Page, title: string): Promise<void> {
|
||||
const card = page.getByTestId("devices-connected-clients-card");
|
||||
await card.getByRole("button", { name: title, exact: true }).click();
|
||||
await expect(card.getByText("Permissions", { exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function returnFromRelayToWaysToConnect(page: Page): Promise<void> {
|
||||
await page
|
||||
.getByTestId("devices-relay-pairing")
|
||||
.getByRole("button", { name: "Back", exact: true })
|
||||
.click();
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function openPairDeviceWaysSheet(page: Page): Promise<void> {
|
||||
await expect(page.getByTestId("devices-pair-button")).toBeVisible();
|
||||
await page.getByTestId("devices-pair-button").click();
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
}
|
||||
|
||||
async function ensurePairDeviceWaysSheetOpen(page: Page): Promise<void> {
|
||||
const relayRow = page.getByTestId("devices-relay");
|
||||
const pairButton = page.getByTestId("devices-pair-button");
|
||||
await relayRow.or(pairButton).first().waitFor({ state: "visible" });
|
||||
if (!(await relayRow.isVisible())) {
|
||||
await pairButton.click();
|
||||
await expect(relayRow).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
export async function preparePairingHost(
|
||||
page: Page,
|
||||
daemon: PairingHost,
|
||||
@@ -74,9 +124,9 @@ export async function preparePairingHost(
|
||||
await openAppOnPairingHost(page, daemon, additionalHosts);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, daemon.serverId);
|
||||
await expect(page.getByTestId("devices-relay")).toHaveCount(0);
|
||||
await expect(page.getByTestId("devices-pair-button")).toHaveCount(0);
|
||||
await openSettingsHostSection(page, daemon.serverId, "devices");
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
await openPairDeviceWaysSheet(page);
|
||||
}
|
||||
|
||||
/** Loads the app afresh with `daemon` as its first host, then opens the setup's Mobile step. */
|
||||
@@ -185,10 +235,12 @@ export async function cancelTailscaleTurnOff(page: Page, address: string): Promi
|
||||
*/
|
||||
export async function confirmTailscaleTurnOff(page: Page, address: string): Promise<void> {
|
||||
const question = answerNextDialog(page, "accept");
|
||||
await page.getByRole("switch", { name: "Tailscale", exact: true }).click();
|
||||
const sheet = page.getByTestId("devices-pair-sheet");
|
||||
const scope = (await sheet.isVisible()) ? sheet : page;
|
||||
await scope.getByRole("switch", { name: "Tailscale", exact: true }).click();
|
||||
expect(await question).toBe(TURN_OFF_QUESTION);
|
||||
await expect(page.getByText("Host is not connected", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toHaveCount(0);
|
||||
await expect(scope.getByText("Host is not connected", { exact: true })).toBeVisible();
|
||||
await expect(scope.getByRole("switch", { name: "Tailscale", exact: true })).toHaveCount(0);
|
||||
await expectHostUnreachableAt(address);
|
||||
}
|
||||
|
||||
@@ -372,9 +424,12 @@ function deliverInOrderAfter(delay: () => number, deliver: (message: string | Bu
|
||||
}
|
||||
|
||||
export async function expectTailscaleUpdateRequired(page: Page): Promise<void> {
|
||||
await expect(page.getByRole("switch", { name: "Tailscale", exact: true })).toBeDisabled();
|
||||
await expect(page.getByText("Update this host to use Tailscale", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "How to update", exact: true })).toBeVisible();
|
||||
await ensurePairDeviceWaysSheetOpen(page);
|
||||
const sheet = page.getByTestId("devices-pair-sheet");
|
||||
const scope = (await sheet.isVisible()) ? sheet : page;
|
||||
await expect(scope.getByRole("switch", { name: "Tailscale", exact: true })).toBeDisabled();
|
||||
await expect(scope.getByText("Update this host to use Tailscale", { exact: true })).toBeVisible();
|
||||
await expect(scope.getByRole("link", { name: "How to update", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function expectTailscaleUnavailable(page: Page): Promise<void> {
|
||||
@@ -460,6 +515,7 @@ export function observeDaemonStatusPolling(page: Page, port: number) {
|
||||
}
|
||||
|
||||
export async function openPairDeviceModal(page: Page): Promise<void> {
|
||||
await ensurePairDeviceWaysSheetOpen(page);
|
||||
await page.getByRole("button", { name: "Relay", exact: true }).click();
|
||||
await expect(page.getByTestId("devices-relay-pairing")).toBeVisible();
|
||||
}
|
||||
@@ -579,9 +635,14 @@ export async function expectPairingDisconnected(page: Page): Promise<void> {
|
||||
}
|
||||
|
||||
export async function switchPairDeviceToHost(page: Page, serverId: string): Promise<void> {
|
||||
const sheet = page.getByTestId("devices-pair-sheet");
|
||||
if (await sheet.isVisible()) {
|
||||
await sheet.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await expect(sheet).toHaveCount(0);
|
||||
}
|
||||
await selectSettingsHost(page, serverId);
|
||||
await expectAppRoute(page, buildSettingsHostSectionRoute(serverId, "devices"));
|
||||
await expect(page.getByTestId("devices-relay")).toBeVisible();
|
||||
await openPairDeviceWaysSheet(page);
|
||||
}
|
||||
|
||||
export async function openRelaySecurityDocs(page: Page): Promise<void> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Locator, TestInfo } from "@playwright/test";
|
||||
import { test, expect, type Page } from "@playwright/test";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample } from "./plugin-fixture";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { buildAgentRoute } from "./mock-agent";
|
||||
@@ -73,6 +74,7 @@ export async function withButtonAuthorExample(
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["button-examples"]);
|
||||
await page.goto(buildAgentRoute(workspace.workspaceId, agent.id));
|
||||
|
||||
await run({
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from "./compact-workspace-scripts";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { seedWorkspace } from "./seed-client";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
const PLUGIN_ID = "button-showcase";
|
||||
@@ -354,6 +355,7 @@ export async function withButtonShowcase(
|
||||
try {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.goto(buildAgentRoute(workspace.workspaceId, agent.id));
|
||||
await expect(page.getByRole("button", { name: "Run review", exact: true })).toBeVisible();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { expect, test, type Page } from "@playwright/test";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { openAgentRoute } from "./mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
import { seedWorkspace } from "./seed-client";
|
||||
|
||||
@@ -39,6 +40,7 @@ export async function withComposerControlsExample(
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: agent.id });
|
||||
await run({
|
||||
narrowTheWindow: () =>
|
||||
@@ -217,6 +219,7 @@ async function withToolbarPlugin(
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [ONE_TOGGLE_PLUGIN_ID]);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: agent.id });
|
||||
await expect(toolbar(page)).toBeVisible({ timeout: 30_000 });
|
||||
await run({
|
||||
|
||||
@@ -13,6 +13,7 @@ import { gotoWorkspace } from "./launcher";
|
||||
import { openCommandCenter } from "./command-center";
|
||||
import { openAgentRoute, seedMockAgentWorkspace } from "./mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient, openGlobalNewWorkspaceComposer } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
import { seedWorkspace } from "./seed-client";
|
||||
import {
|
||||
@@ -86,6 +87,7 @@ export async function withComposerToolsExample(
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["composer-controls-example"]);
|
||||
await openAgentRoute(page, { workspaceId: workspace.workspaceId, agentId: agent.id });
|
||||
await run({
|
||||
openComposerToolsInExplorer: () =>
|
||||
@@ -213,6 +215,7 @@ export async function withPluginWritingToAnotherWorkspace(
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["composer-ref"]);
|
||||
await run({
|
||||
openTargetAgent: () =>
|
||||
test.step("open the agent the plugin will write to", async () => {
|
||||
@@ -356,6 +359,7 @@ export default function contribute(client) {
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["composer-focus"]);
|
||||
await run({
|
||||
openOtherAgent: () =>
|
||||
test.step("open another agent, so the target's tab is not showing", async () => {
|
||||
@@ -479,6 +483,7 @@ export default function contribute(client) {
|
||||
await client.installDirectoryPlugin(directory);
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["held-composer"]);
|
||||
await run({
|
||||
openNewWorkspace: () =>
|
||||
test.step("open the New workspace composer", async () => {
|
||||
@@ -596,6 +601,7 @@ export async function withPluginFocusingASubagent(
|
||||
try {
|
||||
await page.setViewportSize(COMPACT);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["focus-agent"]);
|
||||
await run({
|
||||
keepParentInExplorerOnCompactScreen: () =>
|
||||
test.step("move the parent into the Explorer, then narrow the window", async () => {
|
||||
@@ -740,6 +746,7 @@ export async function withPluginFocusingAnAgentWithContextUsage(
|
||||
try {
|
||||
await page.setViewportSize(COMPACT);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["focus-agent"]);
|
||||
await run({
|
||||
openContextUsageOnPhone: () =>
|
||||
test.step("open the agent's context usage on a phone", async () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { expect, test as base, type Page } from "../fixtures";
|
||||
import appPackage from "../../../package.json";
|
||||
import { gotoAppShell, openSettings } from "./app";
|
||||
import { addConnectedHostAndReload } from "./hosts";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
import {
|
||||
expectToast,
|
||||
@@ -31,7 +32,14 @@ export const LISTING = {
|
||||
overview: "Directory example keeps a checklist beside your agents.",
|
||||
};
|
||||
|
||||
export const test = base.extend<{ directoryHost: { serverId: string; port: number } }>({
|
||||
export const test = base.extend<{
|
||||
directoryHost: {
|
||||
serverId: string;
|
||||
port: number;
|
||||
setDetailDelayMs: (ms: number) => void;
|
||||
waitForDetailServed: (listingId: string) => Promise<void>;
|
||||
};
|
||||
}>({
|
||||
directoryHost: async ({ e2eWorker }, provide) => {
|
||||
void e2eWorker;
|
||||
const root = await mkdtemp(path.join(tmpdir(), "paseo-plugin-directory-"));
|
||||
@@ -42,7 +50,12 @@ export const test = base.extend<{ directoryHost: { serverId: string; port: numbe
|
||||
pluginRegistryUrl: registry.url,
|
||||
});
|
||||
try {
|
||||
await provide({ serverId: host.serverId, port: host.port });
|
||||
await provide({
|
||||
serverId: host.serverId,
|
||||
port: host.port,
|
||||
setDetailDelayMs: registry.setDetailDelayMs,
|
||||
waitForDetailServed: registry.waitForDetailServed,
|
||||
});
|
||||
} finally {
|
||||
await host.dispose();
|
||||
}
|
||||
@@ -161,26 +174,50 @@ function createRelatedFixtures(date: string) {
|
||||
650,
|
||||
],
|
||||
] as const;
|
||||
return specs.map(([id, name, description, installs]) => ({
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
license: "MIT",
|
||||
categories: ["tools"],
|
||||
author: { github: "acme", name: "Acme" },
|
||||
repository: { url: `https://github.com/${id}` },
|
||||
artifact: { kind: "git", remote: `https://github.com/${id}.git`, commit: "a".repeat(40) },
|
||||
scorecardSummary: {
|
||||
health: { grade: "good" },
|
||||
review: { status: "passed", score: 4, noteCount: 0 },
|
||||
},
|
||||
media: [],
|
||||
submittedAt: date,
|
||||
reviewedAt: date,
|
||||
updatedAt: date,
|
||||
publishedAt: date,
|
||||
installs,
|
||||
}));
|
||||
return specs.map(([id, name, description, installs]) => {
|
||||
const entry: Record<string, unknown> = {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
license: "MIT",
|
||||
categories: ["tools"],
|
||||
author:
|
||||
id === "acme/pr-radar"
|
||||
? {
|
||||
github: "acme",
|
||||
name: "Acme",
|
||||
bio: "Building developer workflow plugins for Paseo.",
|
||||
website: "https://acme.dev",
|
||||
}
|
||||
: { github: "acme", name: "Acme" },
|
||||
repository: { url: `https://github.com/${id}` },
|
||||
artifact: { kind: "git", remote: `https://github.com/${id}.git`, commit: "a".repeat(40) },
|
||||
scorecardSummary: {
|
||||
health: { grade: "good" },
|
||||
review: { status: "passed", score: 4, noteCount: 0 },
|
||||
},
|
||||
media: [],
|
||||
submittedAt: date,
|
||||
reviewedAt: date,
|
||||
updatedAt: date,
|
||||
publishedAt: date,
|
||||
installs,
|
||||
};
|
||||
if (id === "acme/pr-radar") {
|
||||
entry.funding = [
|
||||
{ platform: "github", url: "https://github.com/sponsors/acme" },
|
||||
{ platform: "kofi", url: "https://ko-fi.com/acme" },
|
||||
{ platform: "buymeacoffee", url: "https://buymeacoffee.com/acme" },
|
||||
{ platform: "opencollective", url: "https://opencollective.com/acme" },
|
||||
{ platform: "patreon", url: "https://patreon.com/acme" },
|
||||
{ platform: "polar", url: "https://polar.sh/acme" },
|
||||
{ platform: "liberapay", url: "https://liberapay.com/acme" },
|
||||
{ platform: "paypal", url: "https://paypal.me/acme" },
|
||||
{ url: "https://ifdian.net/a/acme" },
|
||||
];
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
|
||||
async function startRegistry(listing: Record<string, unknown>) {
|
||||
@@ -285,20 +322,52 @@ async function startRegistry(listing: Record<string, unknown>) {
|
||||
readme: `# ${item.name}\n\n${item.description}`,
|
||||
};
|
||||
}
|
||||
let detailDelayMs = 0;
|
||||
const servedDetails = new Set<string>();
|
||||
const detailWaiters = new Map<string, Array<() => void>>();
|
||||
const markDetailServed = (requestUrl: string | undefined) => {
|
||||
const match = requestUrl ? /^\/plugins\/(.+)\.json$/.exec(requestUrl) : null;
|
||||
if (!match) return;
|
||||
const id = match[1]!;
|
||||
servedDetails.add(id);
|
||||
const waiters = detailWaiters.get(id);
|
||||
if (waiters) {
|
||||
detailWaiters.delete(id);
|
||||
for (const resolve of waiters) resolve();
|
||||
}
|
||||
};
|
||||
const server = createServer((request, response) => {
|
||||
const document = request.url ? documents[request.url] : undefined;
|
||||
if (!document) {
|
||||
response.writeHead(404).end();
|
||||
return;
|
||||
}
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.end(JSON.stringify(document));
|
||||
const respond = () => {
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.end(JSON.stringify(document), () => markDetailServed(request.url));
|
||||
};
|
||||
if (detailDelayMs > 0 && request.url?.startsWith("/plugins/")) {
|
||||
setTimeout(respond, detailDelayMs);
|
||||
} else {
|
||||
respond();
|
||||
}
|
||||
});
|
||||
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
||||
const address = server.address();
|
||||
if (!address || typeof address === "string") throw new Error("Missing registry address");
|
||||
return {
|
||||
url: `http://127.0.0.1:${address.port}`,
|
||||
setDetailDelayMs: (ms: number) => {
|
||||
detailDelayMs = ms;
|
||||
},
|
||||
waitForDetailServed: (listingId: string) => {
|
||||
if (servedDetails.has(listingId)) return Promise.resolve();
|
||||
return new Promise<void>((resolve) => {
|
||||
const list = detailWaiters.get(listingId) ?? [];
|
||||
list.push(resolve);
|
||||
detailWaiters.set(listingId, list);
|
||||
});
|
||||
},
|
||||
close: () => new Promise<void>((resolve) => server.close(() => resolve())),
|
||||
};
|
||||
}
|
||||
@@ -328,6 +397,7 @@ export async function installListingFromRow(page: Page) {
|
||||
const sheet = page.getByTestId("plugin-install-sheet");
|
||||
await expect(sheet).toContainText("Acme");
|
||||
await sheet.getByTestId("plugin-install-confirm").click();
|
||||
await approveClientPluginsInUi(page, ["directory-example"]);
|
||||
await expect(listingRow(page).getByTestId(`plugin-uninstall-${LISTING.id}`)).toBeVisible({
|
||||
timeout: 60_000,
|
||||
});
|
||||
@@ -362,6 +432,7 @@ export async function uninstallFromPage(page: Page) {
|
||||
export async function installFromPage(page: Page) {
|
||||
await page.getByTestId(`plugin-install-${LISTING.id}`).filter({ visible: true }).click();
|
||||
await page.getByTestId("plugin-install-confirm").click();
|
||||
await approveClientPluginsInUi(page, ["directory-example"]);
|
||||
await expect(
|
||||
page.getByRole("button", { name: `Actions for ${LISTING.name}`, exact: true }),
|
||||
).toBeVisible({ timeout: 60_000 });
|
||||
@@ -372,3 +443,237 @@ export async function openFromInstalledTab(page: Page) {
|
||||
await selectInstalledTab(page);
|
||||
await openPluginPage(page, LISTING.name, "directory-example");
|
||||
}
|
||||
|
||||
interface PluginFrameSample {
|
||||
url: string;
|
||||
stacked: boolean;
|
||||
hasSkeleton: boolean;
|
||||
updatesLabel: string | null;
|
||||
overviewHeight: number | null;
|
||||
overviewTextLen: number;
|
||||
licenseY: number | null;
|
||||
relatedY: number | null;
|
||||
}
|
||||
|
||||
async function sampleFramesDuring(
|
||||
page: Page,
|
||||
{
|
||||
action,
|
||||
waitUntilSettled,
|
||||
}: { action: () => Promise<void>; waitUntilSettled: () => Promise<void> },
|
||||
): Promise<PluginFrameSample[]> {
|
||||
await page.evaluate(() => {
|
||||
const samples: PluginFrameSample[] = [];
|
||||
const host = window as unknown as {
|
||||
__pluginFrameSamples?: PluginFrameSample[];
|
||||
__stopPluginFrameSampling?: () => void;
|
||||
};
|
||||
host.__pluginFrameSamples = samples;
|
||||
let running = true;
|
||||
host.__stopPluginFrameSampling = () => {
|
||||
running = false;
|
||||
};
|
||||
|
||||
const isVisible = (el: Element): boolean => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.width > 0 && rect.height > 0;
|
||||
};
|
||||
const queryVisible = (selector: string): Element | null => {
|
||||
const nodes = Array.from(document.querySelectorAll(selector));
|
||||
for (let i = nodes.length - 1; i >= 0; i -= 1) {
|
||||
if (isVisible(nodes[i]!)) return nodes[i]!;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const findVisibleText = (text: string): Element | null => {
|
||||
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
||||
let node: Node | null;
|
||||
let match: Element | null = null;
|
||||
while ((node = walker.nextNode())) {
|
||||
if (
|
||||
node.textContent?.trim() === text &&
|
||||
node.parentElement &&
|
||||
isVisible(node.parentElement)
|
||||
) {
|
||||
match = node.parentElement;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
};
|
||||
const findOverviewCard = (tabsEl: Element | null, stacked: boolean): Element | null => {
|
||||
if (!tabsEl) return null;
|
||||
const container = stacked
|
||||
? (tabsEl.closest('[style*="overflow"]')?.parentElement ??
|
||||
tabsEl.parentElement?.parentElement?.parentElement)
|
||||
: tabsEl.parentElement?.parentElement;
|
||||
if (!container) return null;
|
||||
const visibleChildren = Array.from(container.children).filter(isVisible);
|
||||
return visibleChildren[visibleChildren.length - 1] ?? null;
|
||||
};
|
||||
const roundRect = (el: Element | null) => el?.getBoundingClientRect() ?? null;
|
||||
|
||||
const record = () => {
|
||||
const tabsEl = queryVisible('[data-testid="plugin-page-tabs"]');
|
||||
const stacked = Boolean(queryVisible('[data-testid="plugin-page-tab-details"]'));
|
||||
const updatesTabEl = queryVisible('[data-testid="plugin-page-tab-updates"]');
|
||||
const skeletonEl = queryVisible('[data-testid="plugin-overview-skeleton"]');
|
||||
const licenseRect = roundRect(findVisibleText("License"));
|
||||
const relatedRect = roundRect(findVisibleText("Related plugins"));
|
||||
const overviewCard = findOverviewCard(tabsEl, stacked);
|
||||
const overviewRect = roundRect(overviewCard);
|
||||
|
||||
samples.push({
|
||||
url: location.pathname,
|
||||
stacked,
|
||||
hasSkeleton: Boolean(skeletonEl),
|
||||
updatesLabel: updatesTabEl?.textContent?.trim() ?? null,
|
||||
overviewHeight: overviewRect ? Math.round(overviewRect.height) : null,
|
||||
overviewTextLen: overviewCard?.textContent?.trim().length ?? 0,
|
||||
licenseY: licenseRect ? Math.round(licenseRect.y) : null,
|
||||
relatedY: relatedRect ? Math.round(relatedRect.y) : null,
|
||||
});
|
||||
|
||||
if (running) requestAnimationFrame(record);
|
||||
};
|
||||
requestAnimationFrame(record);
|
||||
});
|
||||
|
||||
await action();
|
||||
await waitUntilSettled();
|
||||
await page.evaluate(
|
||||
() =>
|
||||
new Promise<void>((resolve) =>
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve())),
|
||||
),
|
||||
);
|
||||
return page.evaluate(() => {
|
||||
const host = window as unknown as {
|
||||
__pluginFrameSamples?: PluginFrameSample[];
|
||||
__stopPluginFrameSampling?: () => void;
|
||||
};
|
||||
host.__stopPluginFrameSampling?.();
|
||||
return host.__pluginFrameSamples ?? [];
|
||||
});
|
||||
}
|
||||
|
||||
function assertOverviewNeverCollapsed(
|
||||
frames: PluginFrameSample[],
|
||||
{ minHeight }: { minHeight: number },
|
||||
) {
|
||||
const withOverview = frames.filter((frame) => frame.overviewHeight !== null);
|
||||
expect(withOverview.length).toBeGreaterThan(0);
|
||||
for (const frame of withOverview) {
|
||||
expect(frame.hasSkeleton || frame.overviewTextLen > 0).toBe(true);
|
||||
expect(frame.overviewHeight).toBeGreaterThanOrEqual(minHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the example listing without hovering first and verifies zero collapse or layout shift. */
|
||||
export async function expectStableUncachedListingOpen(page: Page) {
|
||||
const frames = await sampleFramesDuring(page, {
|
||||
action: async () => {
|
||||
await listingRow(page).getByText(LISTING.name, { exact: true }).click();
|
||||
},
|
||||
waitUntilSettled: async () => {
|
||||
await expect(page.getByText(LISTING.overview, { exact: true })).toBeVisible();
|
||||
},
|
||||
});
|
||||
const onPage = frames.filter((frame) => frame.url.endsWith(`/${LISTING.id}`));
|
||||
expect(onPage.length).toBeGreaterThan(0);
|
||||
for (const frame of onPage) {
|
||||
expect(frame.stacked).toBe(false);
|
||||
expect(frame.updatesLabel).not.toBe("Updates · 1");
|
||||
}
|
||||
assertOverviewNeverCollapsed(onPage, { minHeight: 200 });
|
||||
const licensePositions = new Set(
|
||||
onPage.map((frame) => frame.licenseY).filter((y): y is number => y !== null),
|
||||
);
|
||||
expect(licensePositions.size).toBe(1);
|
||||
const relatedPositions = new Set(
|
||||
onPage.map((frame) => frame.relatedY).filter((y): y is number => y !== null),
|
||||
);
|
||||
expect(relatedPositions.size).toBe(1);
|
||||
}
|
||||
|
||||
/** Hovers a related plugin to prefetch it, clicks it, and asserts Markdown lands on frame 1. */
|
||||
export async function expectInstantPrefetchedRelatedOpen(
|
||||
page: Page,
|
||||
{ waitForDetailServed }: { waitForDetailServed: (listingId: string) => Promise<void> },
|
||||
) {
|
||||
const relatedCard = page.getByTestId("plugin-related-acme/pr-radar").filter({ visible: true });
|
||||
await relatedCard.hover();
|
||||
await waitForDetailServed("acme/pr-radar");
|
||||
// Allow the local daemon WebSocket response to reach the browser query cache.
|
||||
await page.waitForTimeout(200);
|
||||
const frames = await sampleFramesDuring(page, {
|
||||
action: async () => {
|
||||
await relatedCard.click();
|
||||
},
|
||||
waitUntilSettled: async () => {
|
||||
await expect(pluginPageName(page)).toHaveText("PR Radar");
|
||||
await expect(
|
||||
page
|
||||
.getByText("Monitors pull requests and CI checks across connected hosts.")
|
||||
.filter({ visible: true })
|
||||
.nth(1),
|
||||
).toBeVisible();
|
||||
},
|
||||
});
|
||||
const onPage = frames.filter((frame) => frame.url.endsWith("/acme/pr-radar"));
|
||||
expect(onPage.length).toBeGreaterThan(0);
|
||||
for (const frame of onPage) {
|
||||
expect(frame.hasSkeleton).toBe(false);
|
||||
expect(frame.overviewTextLen).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Goes back to the previous plugin page and asserts it stays two-column on every frame. */
|
||||
export async function expectStableDesktopBackToListing(page: Page) {
|
||||
const frames = await sampleFramesDuring(page, {
|
||||
action: async () => {
|
||||
await page.goBack();
|
||||
},
|
||||
waitUntilSettled: async () => {
|
||||
await expect(pluginPageName(page)).toHaveText(LISTING.name);
|
||||
},
|
||||
});
|
||||
const onPage = frames.filter((frame) => frame.url.endsWith(`/${LISTING.id}`));
|
||||
expect(onPage.length).toBeGreaterThan(0);
|
||||
for (const frame of onPage) {
|
||||
expect(frame.stacked).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens a listing in a narrow desktop split (< 700px detail width) and asserts stacked frame 1. */
|
||||
export async function expectStackedFirstFrameOnNarrowDesktop(page: Page) {
|
||||
await page
|
||||
.getByRole("button", { name: "Back to plugins", exact: true })
|
||||
.filter({ visible: true })
|
||||
.click();
|
||||
await expect(listingRow(page)).toBeVisible();
|
||||
await page.setViewportSize({ width: 920, height: 960 });
|
||||
const frames = await sampleFramesDuring(page, {
|
||||
action: async () => {
|
||||
await page
|
||||
.getByTestId("plugin-listing-acme/commit-diff")
|
||||
.filter({ visible: true })
|
||||
.getByText("Commit Diff", { exact: true })
|
||||
.click();
|
||||
},
|
||||
waitUntilSettled: async () => {
|
||||
await expect(pluginPageName(page)).toHaveText("Commit Diff");
|
||||
await expect(
|
||||
page
|
||||
.getByText("Compact commit history and inline file tree diff viewer.")
|
||||
.filter({ visible: true })
|
||||
.nth(1),
|
||||
).toBeVisible();
|
||||
},
|
||||
});
|
||||
const onPage = frames.filter((frame) => frame.url.endsWith("/acme/commit-diff"));
|
||||
expect(onPage.length).toBeGreaterThan(0);
|
||||
for (const frame of onPage) {
|
||||
expect(frame.stacked).toBe(true);
|
||||
}
|
||||
assertOverviewNeverCollapsed(onPage, { minHeight: 80 });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, type Locator, type Page } from "@playwright/test";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
export interface ClientProbePluginSpec {
|
||||
id: string;
|
||||
name: string;
|
||||
sidebarTitle: string;
|
||||
markerKey: string;
|
||||
}
|
||||
|
||||
export async function createClientProbePlugin(spec: ClientProbePluginSpec): Promise<{
|
||||
directory: string;
|
||||
cleanup: () => Promise<void>;
|
||||
}> {
|
||||
const directory = await mkdtemp(path.join(tmpdir(), `paseo-plugin-approval-${spec.id}-`));
|
||||
await writeFile(
|
||||
path.join(directory, "paseo-plugin.json"),
|
||||
JSON.stringify({
|
||||
id: spec.id,
|
||||
name: spec.name,
|
||||
requirements: pluginRequirements,
|
||||
}),
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.server.ts"),
|
||||
`export default function contribute() { return () => {}; }\n`,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(directory, "index.client.tsx"),
|
||||
`import React from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { SidebarRow } from "@getpaseo/plugin/client/ui";
|
||||
|
||||
const executed = (globalThis.__paseoPluginExecutions = globalThis.__paseoPluginExecutions || []);
|
||||
executed.push(${JSON.stringify(spec.markerKey)});
|
||||
|
||||
function ProbeScreen({ theme }) {
|
||||
return (
|
||||
<View style={{ flex: 1, padding: 24 }}>
|
||||
<Text style={{ color: theme.colors.foreground }}>${spec.name} screen</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function ProbeItem({ currentScreen, openScreen }) {
|
||||
return (
|
||||
<SidebarRow
|
||||
icon="Puzzle"
|
||||
active={currentScreen?.screenId === "main"}
|
||||
onPress={() => openScreen({ screenId: "main" })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default function contribute(client) {
|
||||
client.addScreen({ id: "main", title: ${JSON.stringify(spec.sidebarTitle)}, Component: ProbeScreen });
|
||||
client.addSidebarHeaderItem({
|
||||
id: "main",
|
||||
title: ${JSON.stringify(spec.sidebarTitle)},
|
||||
Component: ProbeItem,
|
||||
});
|
||||
return () => {};
|
||||
}
|
||||
`,
|
||||
);
|
||||
return {
|
||||
directory,
|
||||
cleanup: () => rm(directory, { recursive: true, force: true }),
|
||||
};
|
||||
}
|
||||
|
||||
export interface InstalledClientPluginsContext {
|
||||
install: (spec: ClientProbePluginSpec) => Promise<void>;
|
||||
}
|
||||
|
||||
export async function withInstalledClientPlugins<T>(
|
||||
specs: readonly ClientProbePluginSpec[],
|
||||
run: (ctx: InstalledClientPluginsContext) => Promise<T>,
|
||||
): Promise<T> {
|
||||
const client = await connectNewWorkspaceDaemonClient({ ownProjects: false });
|
||||
const previous = await client.getDaemonConfig();
|
||||
const created: Array<{ id: string; cleanup: () => Promise<void> }> = [];
|
||||
const install = async (spec: ClientProbePluginSpec) => {
|
||||
const fixture = await createClientProbePlugin(spec);
|
||||
created.push({ id: spec.id, cleanup: fixture.cleanup });
|
||||
await client.installDirectoryPlugin(fixture.directory);
|
||||
};
|
||||
try {
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
for (const spec of specs) {
|
||||
await install(spec);
|
||||
}
|
||||
return await run({ install });
|
||||
} finally {
|
||||
for (const item of created.toReversed()) {
|
||||
await client.removePlugin(item.id).catch(() => undefined);
|
||||
}
|
||||
await client
|
||||
.patchDaemonConfig({ pluginsEnabled: previous.config.pluginsEnabled ?? false })
|
||||
.catch(() => undefined);
|
||||
await client.close().catch(() => undefined);
|
||||
for (const item of created) {
|
||||
await item.cleanup().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function pluginExecutionBypassSwitch(page: Page): Locator {
|
||||
return page.getByRole("switch", { name: "Run plugins without asking", exact: true });
|
||||
}
|
||||
|
||||
export function pluginExecutionBypassConfirmModal(page: Page): Locator {
|
||||
return page.getByTestId("plugin-execution-bypass-confirm-modal");
|
||||
}
|
||||
|
||||
export async function expectPluginExecutionBypass(page: Page, enabled: boolean): Promise<void> {
|
||||
const toggle = pluginExecutionBypassSwitch(page);
|
||||
await expect(toggle).toBeVisible({ timeout: 30_000 });
|
||||
await expect(toggle).toHaveAttribute("aria-checked", String(enabled));
|
||||
}
|
||||
|
||||
export async function openPluginExecutionBypassConfirm(page: Page): Promise<void> {
|
||||
const toggle = pluginExecutionBypassSwitch(page);
|
||||
await expect(toggle).toHaveAttribute("aria-checked", "false");
|
||||
await toggle.click();
|
||||
await expect(pluginExecutionBypassConfirmModal(page)).toBeVisible();
|
||||
}
|
||||
|
||||
export async function cancelPluginExecutionBypassConfirm(page: Page): Promise<void> {
|
||||
const modal = pluginExecutionBypassConfirmModal(page);
|
||||
await expect(modal).toBeVisible();
|
||||
await page.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await expect(modal).toHaveCount(0);
|
||||
await expectPluginExecutionBypass(page, false);
|
||||
}
|
||||
|
||||
export async function confirmPluginExecutionBypass(page: Page): Promise<void> {
|
||||
const modal = pluginExecutionBypassConfirmModal(page);
|
||||
await expect(modal).toBeVisible();
|
||||
await page.getByRole("button", { name: "Turn on", exact: true }).click();
|
||||
await expect(modal).toHaveCount(0);
|
||||
await expectPluginExecutionBypass(page, true);
|
||||
}
|
||||
|
||||
export async function setPluginExecutionBypass(page: Page, enabled: boolean): Promise<void> {
|
||||
if (enabled) {
|
||||
await openPluginExecutionBypassConfirm(page);
|
||||
await confirmPluginExecutionBypass(page);
|
||||
return;
|
||||
}
|
||||
const toggle = pluginExecutionBypassSwitch(page);
|
||||
await expect(toggle).toHaveAttribute("aria-checked", "true");
|
||||
await toggle.click();
|
||||
await expect(pluginExecutionBypassConfirmModal(page)).toHaveCount(0);
|
||||
await expectPluginExecutionBypass(page, false);
|
||||
}
|
||||
|
||||
export function pluginApprovalSheet(page: Page): Locator {
|
||||
return page.getByTestId("plugin-execution-approval");
|
||||
}
|
||||
|
||||
export async function expectPluginApprovalPrompt(
|
||||
page: Page,
|
||||
expected: { pluginId: string; progress?: string },
|
||||
): Promise<void> {
|
||||
await expect(pluginApprovalSheet(page)).toBeVisible({ timeout: 30_000 });
|
||||
await expect(page.getByTestId("plugin-execution-approval-plugin")).toContainText(
|
||||
expected.pluginId,
|
||||
);
|
||||
if (expected.progress) {
|
||||
await expect(page.getByTestId("plugin-execution-approval-progress")).toHaveText(
|
||||
expected.progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function allowPluginExecution(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: "Allow", exact: true }).click();
|
||||
}
|
||||
|
||||
export async function declinePluginExecution(page: Page): Promise<void> {
|
||||
await page.getByRole("button", { name: "Don't allow", exact: true }).click();
|
||||
}
|
||||
|
||||
async function readPromptIdentity(
|
||||
page: Page,
|
||||
): Promise<{ pluginText: string; hostText: string; key: string } | null> {
|
||||
const pluginLocator = page.getByTestId("plugin-execution-approval-plugin");
|
||||
const hostLocator = page.getByTestId("plugin-execution-approval-host");
|
||||
if (!(await pluginLocator.isVisible().catch(() => false))) return null;
|
||||
if (!(await hostLocator.isVisible().catch(() => false))) return null;
|
||||
const pluginText = (await pluginLocator.textContent().catch(() => ""))?.trim() ?? "";
|
||||
const hostText = (await hostLocator.textContent().catch(() => ""))?.trim() ?? "";
|
||||
if (!pluginText || !hostText) return null;
|
||||
return { pluginText, hostText, key: `${pluginText}\0${hostText}` };
|
||||
}
|
||||
|
||||
async function waitForNextApprovalTarget(
|
||||
page: Page,
|
||||
previousKey: string | null,
|
||||
): Promise<{ pluginText: string; hostText: string; key: string }> {
|
||||
let matched: { pluginText: string; hostText: string; key: string } | null = null;
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const current = await readPromptIdentity(page);
|
||||
if (!current || current.key === previousKey) return false;
|
||||
matched = current;
|
||||
return true;
|
||||
},
|
||||
{ timeout: 30_000, message: "Expected next plugin execution approval prompt" },
|
||||
)
|
||||
.toBe(true);
|
||||
if (!matched) {
|
||||
throw new Error("Expected next plugin execution approval prompt");
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
/**
|
||||
* Approves every expected client plugin through the real confirmation sheet UI.
|
||||
* Handles stacked plugins and multi-host arrivals in any order, then waits for the sheet to close.
|
||||
*/
|
||||
export async function approveClientPluginsInUi(
|
||||
page: Page,
|
||||
pluginIds: readonly string[],
|
||||
): Promise<void> {
|
||||
const remaining = [...pluginIds];
|
||||
let previousKey: string | null = null;
|
||||
while (remaining.length > 0) {
|
||||
await expect(pluginApprovalSheet(page)).toBeVisible({ timeout: 30_000 });
|
||||
const target = await waitForNextApprovalTarget(page, previousKey);
|
||||
const matchedIndex = remaining.findIndex((id) => target.pluginText.includes(id));
|
||||
if (matchedIndex === -1) {
|
||||
throw new Error(
|
||||
`Unexpected plugin execution prompt "${target.pluginText}" on "${target.hostText}"; expected one of: ${remaining.join(", ")}`,
|
||||
);
|
||||
}
|
||||
remaining.splice(matchedIndex, 1);
|
||||
previousKey = target.key;
|
||||
await allowPluginExecution(page);
|
||||
}
|
||||
await expect(pluginApprovalSheet(page)).toHaveCount(0);
|
||||
}
|
||||
|
||||
export async function getExecutedPluginMarkers(page: Page): Promise<string[]> {
|
||||
return page.evaluate(() => {
|
||||
const raw = (globalThis as { __paseoPluginExecutions?: unknown }).__paseoPluginExecutions;
|
||||
return Array.isArray(raw) ? raw.filter((item): item is string => typeof item === "string") : [];
|
||||
});
|
||||
}
|
||||
|
||||
export async function expectExecutedPluginMarkers(
|
||||
page: Page,
|
||||
expected: readonly string[],
|
||||
): Promise<void> {
|
||||
await expect.poll(() => getExecutedPluginMarkers(page)).toEqual(expected);
|
||||
}
|
||||
|
||||
export async function expectExecutedPluginMarkersContain(
|
||||
page: Page,
|
||||
marker: string,
|
||||
): Promise<void> {
|
||||
await expect.poll(() => getExecutedPluginMarkers(page)).toContain(marker);
|
||||
}
|
||||
|
||||
export async function reloadKeepingPersistedState(page: Page): Promise<void> {
|
||||
await page.evaluate(() => {
|
||||
const nonce = localStorage.getItem("@paseo:e2e-seed-nonce");
|
||||
if (!nonce) throw new Error("Expected e2e seed nonce before reload");
|
||||
localStorage.setItem("@paseo:e2e-disable-default-seed-once", nonce);
|
||||
});
|
||||
await page.reload();
|
||||
}
|
||||
|
||||
export async function ensureArtifactsDir(repoRoot: string): Promise<string> {
|
||||
const dir = path.join(repoRoot, ".artifacts");
|
||||
await mkdir(dir, { recursive: true });
|
||||
return dir;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { gotoAppShell } from "./app";
|
||||
import { addConnectedHostAndReload } from "./hosts";
|
||||
import { startIsolatedHostDaemon } from "./isolated-host-daemon";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
const id = "host-clients";
|
||||
@@ -98,6 +99,7 @@ export async function installHostClientsScenario(page: Page) {
|
||||
await primary.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await primary.installDirectoryPlugin(directory);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [id]);
|
||||
await openHostClients(page);
|
||||
await addConnectedHostAndReload(page, {
|
||||
serverId: secondary.serverId,
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
openProjectViaDaemon,
|
||||
submitNewWorkspacePrompt,
|
||||
} from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample } from "./plugin-fixture";
|
||||
import { getServerId } from "./server-id";
|
||||
import { createTempGitRepo } from "./workspace";
|
||||
@@ -147,6 +148,7 @@ export async function withNewWorkspaceIssuesExample(
|
||||
const other = otherRepo ? await openProjectViaDaemon(client, otherRepo.path) : null;
|
||||
let target = project;
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await waitForSidebarHydration(page);
|
||||
await openNewWorkspaceComposer(page, project);
|
||||
// The sidebar rows used to reach the screen exist only at desktop width.
|
||||
|
||||
@@ -6,6 +6,7 @@ import { gotoAppShell, openSettings } from "./app";
|
||||
import { openModelPicker } from "./agent-profiles";
|
||||
import { openAgentRoute } from "./mock-agent";
|
||||
import { connectNewWorkspaceDaemonClient, openGlobalNewWorkspaceComposer } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample } from "./plugin-fixture";
|
||||
import { seedWorkspace, type SeededWorkspace } from "./seed-client";
|
||||
import { getServerId } from "./server-id";
|
||||
@@ -76,6 +77,7 @@ export const test = base.extend<{ providerIcons: ProviderIconJourney }>({
|
||||
try {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["provider-direct-example"]);
|
||||
const iconPaths = await readIconPaths(page, plugin.directory);
|
||||
await provide({ page, testInfo, iconPaths, workspace });
|
||||
} finally {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { expect, type Page } from "../fixtures";
|
||||
import { gotoAppShell } from "./app";
|
||||
import { installDaemonWebSocketGate } from "./daemon-websocket-gate";
|
||||
import { connectDaemonClient } from "./daemon-client-loader";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
const PLUGIN_ID = "retained-plugin-e2e";
|
||||
@@ -76,6 +77,7 @@ async function createProbe(page: Page) {
|
||||
async open() {
|
||||
await page.setViewportSize({ width: 1100, height: 800 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await page.getByRole("button", { name: "Reconnect probe", exact: true }).click();
|
||||
await expect(page.getByText("Stored title: Agent monitor", { exact: true })).toBeVisible();
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ import { connectDaemonClient } from "./daemon-client-loader";
|
||||
import { addConnectedHostAndReload } from "./hosts";
|
||||
import { gotoAppShell, openSettings } from "./app";
|
||||
import { openHostSection, selectSettingsHost } from "./settings";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
import {
|
||||
backToPlugins,
|
||||
@@ -108,9 +109,16 @@ export async function expectAppMismatch(page: Page) {
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
export async function correctRequirementAndReload(page: Page, directory: string) {
|
||||
export async function correctRequirementAndReload(
|
||||
page: Page,
|
||||
directory: string,
|
||||
options?: { approvePrompt?: boolean },
|
||||
) {
|
||||
await writeRequirements(directory, pluginRequirements.paseo);
|
||||
await reloadRequirementsPlugin(page);
|
||||
if (options?.approvePrompt) {
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
}
|
||||
await backToPlugins(page, PLUGIN_ID);
|
||||
await expectPluginHealthy(page, PLUGIN_ID);
|
||||
await expect(page.getByText(/Your app is/)).toHaveCount(0);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
import { expect, test as base, type Page } from "../fixtures";
|
||||
import { gotoAppShell, openSettings } from "./app";
|
||||
@@ -99,11 +100,13 @@ export const test = base.extend<{ settingsPlugin: SettingsClient }>({
|
||||
|
||||
export async function openDisplaySettings(page: Page) {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["settings-example", TABBED_PLUGIN_ID]);
|
||||
await openSettings(page);
|
||||
await openSettingsExamplePage(page);
|
||||
}
|
||||
export async function openCompactDisplaySettings(page: Page) {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["settings-example", TABBED_PLUGIN_ID]);
|
||||
await openCompactSettings(page, new URL(page.url()).pathname);
|
||||
await openSettingsExamplePage(page);
|
||||
}
|
||||
@@ -120,6 +123,7 @@ async function expectSettingsExampleScreen(page: Page) {
|
||||
}
|
||||
export async function openPluginsPage(page: Page) {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["settings-example", TABBED_PLUGIN_ID]);
|
||||
await openSettings(page);
|
||||
await openHostSection(page, getServerId(), "plugins");
|
||||
}
|
||||
@@ -183,6 +187,7 @@ export async function expectSettingsTab(page: Page, title: "General" | "Advanced
|
||||
}
|
||||
export async function openTabbedSettingsLink(page: Page, title: "General" | "Advanced") {
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["settings-example", TABBED_PLUGIN_ID]);
|
||||
await page.goto(`${pluginPageRoute(TABBED_PLUGIN_ID)}/${title.toLowerCase()}`);
|
||||
await expectSettingsTab(page, title);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,16 @@ import path from "node:path";
|
||||
import { expect, type Locator, type Page } from "@playwright/test";
|
||||
import { openCommandCenter } from "./command-center";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { pluginRequirements } from "./plugin-fixture";
|
||||
|
||||
export const SHOWCASE_PLUGIN_ID = "sidebar-showcase";
|
||||
export const LEGACY_PLUGIN_ID = "legacy-sidebar";
|
||||
export const BOTS_PLUGIN_ID = "sidebar-bots";
|
||||
|
||||
export async function approveSidebarPluginsInUi(page: Page): Promise<void> {
|
||||
await approveClientPluginsInUi(page, [SHOWCASE_PLUGIN_ID, LEGACY_PLUGIN_ID, BOTS_PLUGIN_ID]);
|
||||
}
|
||||
export const WIDE = { width: 1440, height: 900 };
|
||||
export const COMPACT = { width: 390, height: 844 };
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { expect, type Page, type TestInfo } from "@playwright/test";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { openAgentRoute, seedMockAgentWorkspace, type MockAgentWorkspace } from "./mock-agent";
|
||||
@@ -110,7 +111,8 @@ export default function contribute(client) {
|
||||
return () => {};
|
||||
}`;
|
||||
|
||||
const PROMPT_PLUGIN_ID = "timeline-prompt-e2e";
|
||||
export const PROMPT_PLUGIN_ID = "timeline-prompt-e2e";
|
||||
export const POPOVER_PLUGIN_ID = "timeline-popover-e2e";
|
||||
|
||||
function promptClientSource(prompts?: readonly string[]): string {
|
||||
return `import React from "react";
|
||||
@@ -201,6 +203,7 @@ export async function withTimelinePlugin(
|
||||
run: async () => {
|
||||
try {
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
await expect(
|
||||
page.getByRole("textbox", { name: "Message agent..." }).first(),
|
||||
).toBeVisible();
|
||||
@@ -356,6 +359,7 @@ export async function viewInlineThinkingExample(page: Page, info: TestInfo): Pro
|
||||
await client.patchDaemonConfig({ pluginsEnabled: true });
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, ["inline-thinking"]);
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." }).first()).toBeVisible();
|
||||
await requestPluginTimeline(agent);
|
||||
const thought = page.getByText(/^Need to find the scroll container/);
|
||||
@@ -423,6 +427,7 @@ export default function contribute(client) {
|
||||
}`,
|
||||
run: async () => {
|
||||
await openAgentRoute(page, agent);
|
||||
await approveClientPluginsInUi(page, ["timeline-local-ids"]);
|
||||
await expect(page.getByRole("textbox", { name: "Message agent..." }).first()).toBeVisible();
|
||||
await run();
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { TestInfo, BrowserContext } from "@playwright/test";
|
||||
import { expect, type Page } from "../fixtures";
|
||||
import { gotoAppShell, openSettings } from "./app";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample } from "./plugin-fixture";
|
||||
|
||||
async function chooseChinese(page: Page) {
|
||||
@@ -40,6 +41,7 @@ export async function verifyPluginTranslations(page: Page, info: TestInfo) {
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["translation-notes"]);
|
||||
await page.getByRole("button", { name: "Workspace notes", exact: true }).click();
|
||||
await expect(page.getByText("App language: en", { exact: true })).toBeVisible();
|
||||
await page
|
||||
@@ -125,6 +127,7 @@ export async function verifyPluginToolTranslations(page: Page, info: TestInfo) {
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await gotoAppShell(page);
|
||||
await approveClientPluginsInUi(page, ["translation-notes"]);
|
||||
await page.goto(buildAgentRoute(workspace.workspaceId, agent.id));
|
||||
const commandCenter = await openCommandCenter(page);
|
||||
await commandCenter.getByTestId("command-center-input").fill("Show notes tools");
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { DaemonClient as InternalDaemonClient } from "@getpaseo/client/inte
|
||||
import { expect, test as base, type Page } from "../fixtures";
|
||||
import { gotoAppShell, openSettings } from "./app";
|
||||
import { connectDaemonClient } from "./daemon-client-loader";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample, pluginRequirements } from "./plugin-fixture";
|
||||
import { getServerId } from "./server-id";
|
||||
import { leaveProviderDetail, openSettingsHostSection } from "./settings";
|
||||
@@ -84,8 +85,14 @@ export const test = base.extend<{ providerUpdateFailure: ProviderUpdateFailure }
|
||||
},
|
||||
});
|
||||
|
||||
export async function openProviderInstallation(page: Page): Promise<void> {
|
||||
export async function openProviderInstallation(
|
||||
page: Page,
|
||||
options?: { approvePlugin?: boolean },
|
||||
): Promise<void> {
|
||||
await gotoAppShell(page);
|
||||
if (options?.approvePlugin) {
|
||||
await approveClientPluginsInUi(page, [PLUGIN_ID]);
|
||||
}
|
||||
await openSettings(page);
|
||||
await openSettingsHostSection(page, getServerId(), "providers");
|
||||
await page
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { expect, type Page } from "@playwright/test";
|
||||
import { approveClientPluginsInUi } from "./plugin-execution-approval";
|
||||
import { copyPluginExample } from "./plugin-fixture";
|
||||
import { connectNewWorkspaceDaemonClient } from "./new-workspace";
|
||||
import { seedWorkspace } from "./seed-client";
|
||||
@@ -33,6 +34,7 @@ export async function withSidebarViews(
|
||||
await client.installDirectoryPlugin(example.directory);
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await gotoWorkspace(page, workspace.workspaceId);
|
||||
await approveClientPluginsInUi(page, ["sidebar-views"]);
|
||||
await run(sidebarViews(page, workspace.workspaceId, client));
|
||||
} finally {
|
||||
await client.removePlugin("sidebar-views");
|
||||
|
||||
@@ -175,6 +175,22 @@ export async function reopenWithFreshnessCheckUnanswered(
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Updating messages" })).toBeVisible();
|
||||
}
|
||||
|
||||
/** Reopens display-only history with the tail held until the app shows the outstanding update. */
|
||||
export async function reopenWithTimelineTailUnanswered({
|
||||
page,
|
||||
gate,
|
||||
agentId,
|
||||
}: {
|
||||
page: Page;
|
||||
gate: DaemonWebSocketGate;
|
||||
agentId: string;
|
||||
}): Promise<void> {
|
||||
gate.holdTimelineResponses(agentId);
|
||||
await page.reload();
|
||||
await gate.waitForHeldTimelineResponse();
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Updating messages" })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function answerFreshnessCheck(page: Page, gate: DaemonWebSocketGate): Promise<void> {
|
||||
gate.releaseHeldClientRequest();
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Updating messages" })).toHaveCount(0);
|
||||
@@ -324,6 +340,121 @@ export async function stopStreamingReply(agent: StreamingReplyAgent): Promise<st
|
||||
return reply;
|
||||
}
|
||||
|
||||
interface LoadingSurfaceRecord {
|
||||
loaderText: string[];
|
||||
spinnerYsByTestId: Record<string, number[]>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__loadingSurfaceRecord?: LoadingSurfaceRecord;
|
||||
}
|
||||
}
|
||||
|
||||
function recordLoadingSurfaces(): void {
|
||||
const record: LoadingSurfaceRecord = {
|
||||
loaderText: [],
|
||||
spinnerYsByTestId: {},
|
||||
};
|
||||
window.__loadingSurfaceRecord = record;
|
||||
|
||||
const isVisible = (el: Element | null): el is HTMLElement => {
|
||||
if (!(el instanceof HTMLElement)) return false;
|
||||
const style = window.getComputedStyle(el);
|
||||
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") {
|
||||
return false;
|
||||
}
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.width > 0 && rect.height > 0;
|
||||
};
|
||||
|
||||
const sample = () => {
|
||||
if (!document.body) return;
|
||||
for (const testId of [
|
||||
"workspace-loading",
|
||||
"agent-loading",
|
||||
"agent-history-overlay",
|
||||
"agent-initial-fill",
|
||||
]) {
|
||||
const el = document.querySelector(`[data-testid="${testId}"]`);
|
||||
if (!isVisible(el)) continue;
|
||||
const text = (el.textContent ?? "").trim();
|
||||
if (text.length > 0 && !record.loaderText.includes(text)) {
|
||||
record.loaderText.push(text);
|
||||
}
|
||||
const spinner = el.querySelector('[role="progressbar"]');
|
||||
if (spinner) {
|
||||
const y = Math.round(spinner.getBoundingClientRect().y);
|
||||
const list = record.spinnerYsByTestId[testId] ?? [];
|
||||
if (!list.includes(y)) list.push(y);
|
||||
record.spinnerYsByTestId[testId] = list;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const start = () => {
|
||||
const observer = new MutationObserver(sample);
|
||||
observer.observe(document.documentElement ?? document, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
characterData: true,
|
||||
});
|
||||
sample();
|
||||
};
|
||||
|
||||
if (document.documentElement) start();
|
||||
else document.addEventListener("DOMContentLoaded", start, { once: true });
|
||||
}
|
||||
|
||||
/** Records loading text, spinner Y positions, and any Updating messages toast from first paint. */
|
||||
export async function watchColdAndReloadLoadingSurfaces(page: Page): Promise<void> {
|
||||
await page.addInitScript(recordLoadingSurfaces);
|
||||
await page.addInitScript(recordUpdatingToastTiming);
|
||||
}
|
||||
|
||||
/** Checks loading geometry and verifies the toast waits for a slow daemon reply. */
|
||||
export async function expectCleanLoadingSurfaces(
|
||||
page: Page,
|
||||
gate: DaemonWebSocketGate,
|
||||
before: TimelineRequestCounts,
|
||||
): Promise<void> {
|
||||
await gate.waitForServerMessage(TIMELINE_RESPONSE, before.fetches + 1);
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Updating messages" })).toHaveCount(0);
|
||||
await expectToastWaitedForTheDaemon(page);
|
||||
const record = await page.evaluate(() => window.__loadingSurfaceRecord as LoadingSurfaceRecord);
|
||||
expect(record.loaderText, "loading states must not render visible text").toEqual([]);
|
||||
for (const [testId, ys] of Object.entries(record.spinnerYsByTestId)) {
|
||||
expect(
|
||||
ys.length,
|
||||
`${testId} spinner shifted vertically (${ys.join(", ")})`,
|
||||
).toBeLessThanOrEqual(1);
|
||||
}
|
||||
expect(
|
||||
gate.getTimelineRequestCount("after", before.agentId) - before.after,
|
||||
"initial tail load must not trigger a redundant after catch-up",
|
||||
).toBe(0);
|
||||
}
|
||||
|
||||
/** Waits until the persisted replica cache drops coverage to a display-only snapshot. */
|
||||
export async function waitForDisplayOnlyTimelineCache(
|
||||
page: Page,
|
||||
agent: LongTimelineAgent,
|
||||
): Promise<void> {
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const cache = await readReplicaCache(page);
|
||||
const timeline = cache?.hosts
|
||||
?.flatMap((host) => host.timelines)
|
||||
.find((entry) => entry.agentId === agent.agentId);
|
||||
return timeline?.items ? { items: timeline.items.length, range: timeline.range } : null;
|
||||
},
|
||||
{ timeout: 15_000 },
|
||||
)
|
||||
.toMatchObject({ range: null });
|
||||
}
|
||||
|
||||
export async function expectPromptAndWholeReply(
|
||||
page: Page,
|
||||
agent: StreamingReplyAgent,
|
||||
|
||||
@@ -14,5 +14,8 @@ import { renderRootComponent } from "expo-router/build/renderRootComponent";
|
||||
import { startWatchdog } from "./src/watchdog";
|
||||
import { RootApp } from "./src/root-app";
|
||||
|
||||
import { sweepOrphanedWorkspaceDrafts } from "./src/workspace-tabs/sweep-orphaned-drafts";
|
||||
|
||||
startWatchdog();
|
||||
void sweepOrphanedWorkspaceDrafts();
|
||||
renderRootComponent(RootApp);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"dev:ios": "npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo run:ios",
|
||||
"build:apk": "npm --prefix ../.. run build:apk",
|
||||
"build:apk:arm64": "npm --prefix ../.. run build:apk:arm64",
|
||||
"test:android": "expo prebuild --platform android --no-install && cd android && ./gradlew :paseo-native-trace:testReleaseUnitTest :paseo-hardware-keyboard:testReleaseUnitTest :react-native-enriched-markdown:testReleaseUnitTest --tests '*InlineCodeFormattingTest' --tests '*ListRenderingTest' --tests '*TaskListInteractionTest' --tests '*ListBlockquoteMeasurementTest' --tests '*BlockquoteCopyTest' --tests '*CodeBlockCopyButtonConstructionTest' --tests '*LongPressSelectionInterceptTest' --no-daemon --max-workers=2 -Dorg.gradle.parallel=false"
|
||||
"test:android": "expo prebuild --platform android --no-install && cd android && ./gradlew :paseo-native-trace:testReleaseUnitTest :paseo-hardware-keyboard:testReleaseUnitTest :expo-modules-core:testReleaseUnitTest --tests expo.modules.kotlin.activityresult.AppContextActivityResultRegistryRecreationTest :react-native-enriched-markdown:testReleaseUnitTest --tests '*InlineCodeFormattingTest' --tests '*ListRenderingTest' --tests '*TaskListInteractionTest' --tests '*ListBlockquoteMeasurementTest' --tests '*BlockquoteCopyTest' --tests '*CodeBlockCopyButtonConstructionTest' --tests '*LongPressSelectionInterceptTest' --no-daemon --max-workers=2 -Dorg.gradle.parallel=false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/commands": "6.10.4",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { useFetchQuery } from "@/data/query";
|
||||
import { useDebouncedValue } from "@/hooks/use-debounced-value";
|
||||
import { useHostRuntimeClient } from "@/runtime/host-runtime";
|
||||
import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime";
|
||||
import type { GithubRepositoryChoice } from "./model";
|
||||
import { resolveSearch, type SearchResult } from "./search-result";
|
||||
|
||||
@@ -19,8 +19,9 @@ export function useDirectorySearch(input: {
|
||||
}): SearchResult<string> {
|
||||
const { hostId } = input;
|
||||
const client = useHostRuntimeClient(hostId ?? "");
|
||||
const isConnected = useHostRuntimeIsConnected(hostId ?? "");
|
||||
const debouncedQuery = useDebouncedValue(input.query, SEARCH_DEBOUNCE_MS);
|
||||
const enabled = Boolean(client && input.enabled);
|
||||
const enabled = Boolean(client && isConnected && input.enabled);
|
||||
const search = useFetchQuery({
|
||||
queryKey: ["add-project-flow-directories", hostId, debouncedQuery],
|
||||
queryFn: async () => {
|
||||
@@ -64,8 +65,9 @@ export function useGithubRepositorySearch(input: {
|
||||
}): SearchResult<GithubRepositoryChoice> {
|
||||
const { hostId } = input;
|
||||
const client = useHostRuntimeClient(hostId ?? "");
|
||||
const isConnected = useHostRuntimeIsConnected(hostId ?? "");
|
||||
const debouncedQuery = useDebouncedValue(input.query, SEARCH_DEBOUNCE_MS);
|
||||
const enabled = Boolean(client && input.enabled);
|
||||
const enabled = Boolean(client && isConnected && input.enabled);
|
||||
const search = useFetchQuery({
|
||||
queryKey: ["add-project-flow-github", hostId, debouncedQuery],
|
||||
queryFn: async () => {
|
||||
|
||||
@@ -69,4 +69,27 @@ describe("host agent skills", () => {
|
||||
expect(result.current.supported).toBe(false);
|
||||
expect(client.getAgentSkillsStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("waits until the host is connected before fetching and fetches once online", async () => {
|
||||
runtime.connected = false;
|
||||
const client = {
|
||||
getAgentSkillsStatus: vi.fn(async () => ({
|
||||
state: "not-installed",
|
||||
ops: [],
|
||||
available: ["paseo"],
|
||||
installed: [],
|
||||
selection: { mode: "all" },
|
||||
})),
|
||||
};
|
||||
runtime.clients.set("reconnecting-host", client);
|
||||
|
||||
const { result, rerender } = renderHook(() => useAgentSkills("reconnecting-host"), { wrapper });
|
||||
expect(client.getAgentSkillsStatus).not.toHaveBeenCalled();
|
||||
|
||||
runtime.connected = true;
|
||||
rerender();
|
||||
|
||||
await waitFor(() => expect(result.current.status?.available).toEqual(["paseo"]));
|
||||
expect(client.getAgentSkillsStatus).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ export function useAgentSkills(serverId: string) {
|
||||
if (!client) throw new Error(t("settings.host.skills.unavailable"));
|
||||
return client.getAgentSkillsStatus();
|
||||
},
|
||||
enabled: supported && client !== null,
|
||||
enabled: supported && client !== null && connected,
|
||||
retry: false,
|
||||
dataShape: "value",
|
||||
staleTimeMs: 0,
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
* Pure state machine for the chat history's flick-to-dismiss gesture.
|
||||
*
|
||||
* Native keyboardDismissMode cannot express this interaction: "on-drag"
|
||||
* dismisses on the first pixel, while "interactive" is iOS-only. We therefore classify the list's existing scroll gesture at
|
||||
* release instead of introducing a competing pan recognizer.
|
||||
* dismisses on the first pixel, and iOS "interactive" only follows a finger
|
||||
* that reaches the keyboard. We therefore classify the list's existing scroll
|
||||
* gesture at release instead of introducing a competing pan recognizer.
|
||||
*/
|
||||
|
||||
const DISMISS_VELOCITY_POINTS_PER_MS = 1.5;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { ScrollViewProps } from "react-native";
|
||||
|
||||
/**
|
||||
* iOS lets the keyboard follow a drag that reaches it, as in Messages. The
|
||||
* keyboard controller reports each frame of that drag, so the composer stays on
|
||||
* the keyboard edge.
|
||||
*/
|
||||
export const NATIVE_KEYBOARD_DISMISS_MODE: ScrollViewProps["keyboardDismissMode"] = "interactive";
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { ScrollViewProps } from "react-native";
|
||||
|
||||
/**
|
||||
* Android has no interactive keyboard dismissal. The flick classifier in
|
||||
* `model.ts` is the only drag that closes the keyboard there.
|
||||
*/
|
||||
export const NATIVE_KEYBOARD_DISMISS_MODE: ScrollViewProps["keyboardDismissMode"] = "none";
|
||||
+14
-4
@@ -13,13 +13,15 @@ import {
|
||||
recordScroll,
|
||||
releaseDrag,
|
||||
} from "./model";
|
||||
import { NATIVE_KEYBOARD_DISMISS_MODE } from "./native-dismiss-mode";
|
||||
|
||||
type ScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
|
||||
|
||||
/**
|
||||
* Owns the chat history's flick-to-dismiss behavior. The native stream only
|
||||
* forwards the LegendList scroll lifecycle; removing this hook and those three
|
||||
* calls removes the feature completely.
|
||||
* Owns how the chat history closes the keyboard: a flick toward older messages,
|
||||
* a drag into the keyboard on iOS, and a tap on content that no control claims.
|
||||
* The native stream spreads the two keyboard props and forwards the LegendList
|
||||
* scroll lifecycle; removing this hook and those calls removes the feature.
|
||||
*/
|
||||
export function useScrollKeyboardDismiss() {
|
||||
const { shift } = useKeyboardShift();
|
||||
@@ -53,5 +55,13 @@ export function useScrollKeyboardDismiss() {
|
||||
Keyboard.dismiss();
|
||||
});
|
||||
|
||||
return { onScroll, onScrollBeginDrag, onScrollEndDrag };
|
||||
return {
|
||||
keyboardDismissMode: NATIVE_KEYBOARD_DISMISS_MODE,
|
||||
// "handled" lets links, tool calls, and copy buttons act on the first tap
|
||||
// while the keyboard is open. A tap that no child claims still closes it.
|
||||
keyboardShouldPersistTaps: "handled" as const,
|
||||
onScroll,
|
||||
onScrollBeginDrag,
|
||||
onScrollEndDrag,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
} from "@legendapp/list/react-native";
|
||||
import { withUnistyles } from "react-native-unistyles";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { LoadingState } from "@/components/ui/loading-state";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { useNativeSplashHold } from "@/native-splash";
|
||||
@@ -123,15 +122,6 @@ function distanceFromEnd(input: {
|
||||
return Math.max(0, input.contentHeight - input.viewportHeight - input.offsetY);
|
||||
}
|
||||
const viewportStyle: ViewStyle = { flex: 1 };
|
||||
const initialFillStyle: ViewStyle = {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
};
|
||||
|
||||
function keyExtractor(item: { id: string }): string {
|
||||
return item.id;
|
||||
@@ -159,6 +149,7 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
|
||||
isAuthoritativeHistoryReady,
|
||||
isInitialHistoryLoading,
|
||||
revealInitialHistory,
|
||||
onInitialHistoryVisibilityChange,
|
||||
onNearBottomChange,
|
||||
onNearHistoryStart,
|
||||
isLoadingOlderHistory,
|
||||
@@ -265,6 +256,12 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
|
||||
() => historyStartPagination.state.status === "settling",
|
||||
);
|
||||
const finishInitialFill = useStableEvent(() => historyStartPagination.reveal());
|
||||
const reportInitialHistoryVisibility = useStableEvent((visible: boolean) => {
|
||||
onInitialHistoryVisibilityChange?.(visible);
|
||||
});
|
||||
useLayoutEffect(() => {
|
||||
reportInitialHistoryVisibility(historyStartPaginationState.visible);
|
||||
}, [historyStartPaginationState.visible, reportInitialHistoryVisibility]);
|
||||
const retryHistoryStart = useStableEvent(() => historyStartPagination.rearm());
|
||||
const scheduleHistoryStartSettle = useStableEvent(() => {
|
||||
let scheduler = historyStartSettleSchedulerRef.current;
|
||||
@@ -795,6 +792,8 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
|
||||
onMomentumScrollBegin={handleMomentumScrollBegin}
|
||||
onMomentumScrollEnd={handleMomentumScrollEnd}
|
||||
scrollEventThrottle={16}
|
||||
keyboardDismissMode={scrollKeyboardDismiss.keyboardDismissMode}
|
||||
keyboardShouldPersistTaps={scrollKeyboardDismiss.keyboardShouldPersistTaps}
|
||||
onContentSizeChange={handleContentSizeChange}
|
||||
onItemSizeChanged={handleItemSizeChanged}
|
||||
onReady={handleListPlaced}
|
||||
@@ -811,11 +810,6 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
|
||||
{canExpandDrawDistance ? (
|
||||
<InitialDrawDistanceExpansion schedule={drawDistanceExpansion.schedule} />
|
||||
) : null}
|
||||
{!historyStartPaginationState.visible ? (
|
||||
<View pointerEvents="none" style={initialFillStyle}>
|
||||
<LoadingState testID="agent-initial-fill" title={t("agentPanel.states.loadingHistory")} />
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import { flushSync } from "react-dom";
|
||||
import { withUnistyles } from "react-native-unistyles";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { LoadingState } from "@/components/ui/loading-state";
|
||||
import { useStableEvent } from "@/hooks/use-stable-event";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getStreamItemMessageId, type StreamItem } from "@/types/stream";
|
||||
@@ -77,14 +76,6 @@ const historyStartSlotStyle: CSSProperties = {
|
||||
};
|
||||
|
||||
const streamRowsHostStyle: CSSProperties = { position: "relative", width: "100%" };
|
||||
const initialFillStyle: CSSProperties = {
|
||||
position: "absolute",
|
||||
inset: 0,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
pointerEvents: "none",
|
||||
};
|
||||
|
||||
// Rows and the live auxiliary (turn footer, pending permissions) center their content with
|
||||
// `alignSelf`, which only applies inside a flex container.
|
||||
@@ -439,6 +430,7 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool
|
||||
isAuthoritativeHistoryReady,
|
||||
isInitialHistoryLoading,
|
||||
revealInitialHistory,
|
||||
onInitialHistoryVisibilityChange,
|
||||
onNearBottomChange,
|
||||
onReadingPositionChange,
|
||||
onNearHistoryStart,
|
||||
@@ -707,6 +699,12 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool
|
||||
() => historyStartPagination.state.status === "settling",
|
||||
);
|
||||
const finishInitialFill = useStableEvent(() => historyStartPagination.reveal());
|
||||
const reportInitialHistoryVisibility = useStableEvent((visible: boolean) => {
|
||||
onInitialHistoryVisibilityChange?.(visible);
|
||||
});
|
||||
useLayoutEffect(() => {
|
||||
reportInitialHistoryVisibility(historyStartPaginationState.visible);
|
||||
}, [historyStartPaginationState.visible, reportInitialHistoryVisibility]);
|
||||
const rearmHistoryStartFromUserIntent = useStableEvent(() => historyStartPagination.rearm());
|
||||
const scheduleHistoryStartPrependSettle = useStableEvent(() => {
|
||||
let scheduler = historyStartSettleSchedulerRef.current;
|
||||
@@ -1750,11 +1748,6 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool
|
||||
{shouldRenderEmpty ? listEmptyComponent : null}
|
||||
</div>
|
||||
</div>
|
||||
{!historyStartPaginationState.visible ? (
|
||||
<div style={initialFillStyle}>
|
||||
<LoadingState testID="agent-initial-fill" title={t("agentPanel.states.loadingHistory")} />
|
||||
</div>
|
||||
) : null}
|
||||
{scrollEnabled && !isMobileBreakpoint ? (
|
||||
<DomOverlayScrollbar
|
||||
scrollContainerRef={scrollContainerRef}
|
||||
|
||||
@@ -94,6 +94,8 @@ export interface StreamRenderInput {
|
||||
isAuthoritativeHistoryReady: boolean;
|
||||
isInitialHistoryLoading?: boolean;
|
||||
revealInitialHistory?: boolean;
|
||||
/** When supplied, the host pane owns the full-pane initial-fill loading overlay. */
|
||||
onInitialHistoryVisibilityChange?: (visible: boolean) => void;
|
||||
onNearBottomChange: (value: boolean) => void;
|
||||
// The history row under the top of the viewport, for surfaces that mark where the reader
|
||||
// is in the transcript. Only the web viewport measures it today.
|
||||
|
||||
@@ -258,6 +258,8 @@ export interface AgentStreamViewProps {
|
||||
isAuthoritativeHistoryReady?: boolean;
|
||||
isInitialHistoryLoading?: boolean;
|
||||
revealInitialHistory?: boolean;
|
||||
/** When supplied, the host pane owns the full-pane initial-fill loading overlay. */
|
||||
onInitialHistoryVisibilityChange?: (visible: boolean) => void;
|
||||
/** Tail space required by a transparent overlay rendered at the bottom edge. */
|
||||
bottomOverlayTailClearance?: number;
|
||||
/** Bottom offset required for controls floating above that overlay. */
|
||||
@@ -357,6 +359,7 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
isAuthoritativeHistoryReady = true,
|
||||
isInitialHistoryLoading,
|
||||
revealInitialHistory,
|
||||
onInitialHistoryVisibilityChange,
|
||||
bottomOverlayTailClearance = 0,
|
||||
bottomOverlayControlClearance,
|
||||
toast,
|
||||
@@ -1231,6 +1234,7 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
isAuthoritativeHistoryReady,
|
||||
isInitialHistoryLoading,
|
||||
revealInitialHistory,
|
||||
onInitialHistoryVisibilityChange,
|
||||
onNearBottomChange: nearBottom.set,
|
||||
onReadingPositionChange: handleReadingPositionChange,
|
||||
onNearHistoryStart: loadOlder,
|
||||
@@ -1384,6 +1388,9 @@ function agentStreamViewPropsEqual(
|
||||
if (left.revealInitialHistory !== right.revealInitialHistory) {
|
||||
reasons.push("revealInitialHistory");
|
||||
}
|
||||
if (left.onInitialHistoryVisibilityChange !== right.onInitialHistoryVisibilityChange) {
|
||||
reasons.push("onInitialHistoryVisibilityChange");
|
||||
}
|
||||
if (left.bottomOverlayTailClearance !== right.bottomOverlayTailClearance) {
|
||||
reasons.push("bottomOverlayTailClearance");
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ import { WorkspaceShortcutTargetsSubscriber } from "@/components/workspace-short
|
||||
import { FloatingPanelPortalHost } from "@/components/ui/floating-panel-portal";
|
||||
import { HostChooserModal, useHostChooser } from "@/hosts/host-chooser";
|
||||
import { HostConfirmationSheet } from "@/hosts/host-confirmation-sheet";
|
||||
import { PluginExecutionApprovalSheet } from "@/plugins/execution-approval/sheet";
|
||||
import { HEADER_INNER_HEIGHT, useIsCompactFormFactor } from "@/constants/layout";
|
||||
import {
|
||||
canDesktopAppSidebarShare,
|
||||
@@ -568,6 +569,7 @@ function AppContainer({ children, chromeEnabled: chromeEnabledOverride }: AppCon
|
||||
<AddProjectFlowHost />
|
||||
<HostChooserModal />
|
||||
<HostConfirmationSheet />
|
||||
<PluginExecutionApprovalSheet />
|
||||
<ProviderSettingsHost />
|
||||
<WorkspaceSetupDialog />
|
||||
<KeyboardShortcutsDialog />
|
||||
|
||||
@@ -147,6 +147,9 @@ function HostWorkspaceRouteContent() {
|
||||
}
|
||||
|
||||
function WorkspaceDeck() {
|
||||
// The compiler caches render-time Date.now() without this directive.
|
||||
"use no memo";
|
||||
|
||||
const activeSelection = useActiveWorkspaceSelection();
|
||||
const [retainedSelections, setRetainedSelections] = useState<RetainedWorkspaceSelection[]>(() =>
|
||||
activeSelection ? [{ selection: activeSelection, inactiveSince: null }] : [],
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
import React, { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import type { DaemonClient, FileReadResult } from "@getpaseo/client/internal/daemon-client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { AssistantFileLinkResolverProvider } from "@/assistant-file-links";
|
||||
import { ForgeShorthandProvider } from "@/git/forge-shorthand";
|
||||
import { ChangelogBody } from "./changelog-sheet";
|
||||
import type { ChangelogState } from "./changelog-source";
|
||||
|
||||
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
||||
beforeEach(() => vi.stubGlobal("React", React));
|
||||
|
||||
let root: Root | null = null;
|
||||
let container: HTMLDivElement | null = null;
|
||||
|
||||
afterEach(() => {
|
||||
act(() => root?.unmount());
|
||||
container?.remove();
|
||||
root = null;
|
||||
container = null;
|
||||
});
|
||||
|
||||
function noop() {}
|
||||
|
||||
const CHANGELOG_FIXTURE_STATE: ChangelogState = {
|
||||
status: "ready",
|
||||
releases: [
|
||||
{
|
||||
version: "0.19.0",
|
||||
date: "2026-12-01",
|
||||
highlights:
|
||||
"Highlights see #123, [Release](https://paseo.sh/changelog), [Local](/etc/passwd), ",
|
||||
sections: [
|
||||
{
|
||||
title: "Fixed",
|
||||
body: "Section   see #456",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
version: "0.18.0",
|
||||
date: "2026-11-20",
|
||||
highlights: "",
|
||||
sections: [
|
||||
{
|
||||
title: "Added",
|
||||
body: "Only sections  [Docs](https://paseo.sh/docs) see #789",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function createFakeFileReader() {
|
||||
const reads: { cwd: string; path: string }[] = [];
|
||||
const client = {
|
||||
async readFile(cwd: string, path: string): Promise<FileReadResult> {
|
||||
reads.push({ cwd, path });
|
||||
return {
|
||||
kind: "image",
|
||||
path,
|
||||
mime: "image/png",
|
||||
size: 4,
|
||||
modifiedAt: "2026-12-01T00:00:00.000Z",
|
||||
bytes: new Uint8Array([1, 2, 3, 4]),
|
||||
};
|
||||
},
|
||||
} as unknown as DaemonClient;
|
||||
return { reads, client };
|
||||
}
|
||||
|
||||
async function settleLayout() {
|
||||
for (let frame = 0; frame < 2; frame++) {
|
||||
await act(() => new Promise<void>((resolve) => requestAnimationFrame(() => resolve())));
|
||||
}
|
||||
}
|
||||
|
||||
describe("changelog Markdown safety", () => {
|
||||
it("never calls client.readFile and does not link workspace forge shorthand in highlights or sections", async () => {
|
||||
const { reads, client: fakeClient } = createFakeFileReader();
|
||||
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
|
||||
act(() =>
|
||||
root?.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AssistantFileLinkResolverProvider
|
||||
serverId="server-1"
|
||||
workspaceRoot="/repo"
|
||||
client={fakeClient}
|
||||
>
|
||||
<ForgeShorthandProvider
|
||||
forge="github"
|
||||
remoteUrl="https://github.com/acme/widgets.git"
|
||||
forgeWeb={null}
|
||||
>
|
||||
<ChangelogBody
|
||||
state={CHANGELOG_FIXTURE_STATE}
|
||||
shownReleases={2}
|
||||
onShowMore={noop}
|
||||
onRetry={noop}
|
||||
/>
|
||||
</ForgeShorthandProvider>
|
||||
</AssistantFileLinkResolverProvider>
|
||||
</QueryClientProvider>,
|
||||
),
|
||||
);
|
||||
|
||||
await expect.poll(() => container?.textContent).toContain("HighlightLocal");
|
||||
await expect.poll(() => container?.textContent).toContain("DirectSectionLocal");
|
||||
await settleLayout();
|
||||
|
||||
expect(reads).toEqual([]);
|
||||
|
||||
const links = Array.from(container.querySelectorAll("a")).map((a) => ({
|
||||
text: a.textContent,
|
||||
href: a.getAttribute("href"),
|
||||
}));
|
||||
expect(links).toContainEqual(
|
||||
expect.objectContaining({ text: "Release", href: "https://paseo.sh/changelog" }),
|
||||
);
|
||||
expect(links).toContainEqual(
|
||||
expect.objectContaining({ text: "Docs", href: "https://paseo.sh/docs" }),
|
||||
);
|
||||
expect(links.some((l) => l.text === "#123" || l.text === "#789" || l.text === "Local")).toBe(
|
||||
false,
|
||||
);
|
||||
|
||||
const imgs = Array.from(container.querySelectorAll("img"));
|
||||
expect(imgs.map((img) => img.getAttribute("alt"))).not.toContain("HighlightLocal");
|
||||
expect(imgs.map((img) => img.getAttribute("alt"))).not.toContain("DirectSectionLocal");
|
||||
});
|
||||
});
|
||||
@@ -86,7 +86,7 @@ interface ChangelogBodyProps {
|
||||
onRetry: () => void;
|
||||
}
|
||||
|
||||
function ChangelogBody({ state, shownReleases, onShowMore, onRetry }: ChangelogBodyProps) {
|
||||
export function ChangelogBody({ state, shownReleases, onShowMore, onRetry }: ChangelogBodyProps) {
|
||||
const { t } = useTranslation();
|
||||
const appVersion = useMemo(() => resolveAppVersion()?.replace(/^v/i, "") ?? null, []);
|
||||
|
||||
@@ -168,7 +168,15 @@ const ReleaseView = memo(function ReleaseView({ release, isCurrent }: ReleaseVie
|
||||
<View style={styles.headingSpacer} />
|
||||
{date ? <Text style={styles.date}>{date}</Text> : null}
|
||||
</View>
|
||||
{hasHighlights ? <MarkdownRenderer text={release.highlights} compact /> : null}
|
||||
{hasHighlights ? (
|
||||
<MarkdownRenderer
|
||||
text={release.highlights}
|
||||
compact
|
||||
destinations="https"
|
||||
forgeShorthand={false}
|
||||
softBreaks="join"
|
||||
/>
|
||||
) : null}
|
||||
{hasHighlights && release.sections.length > 0 ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -188,7 +196,15 @@ function ReleaseSections({ sections }: { sections: readonly ChangelogSection[] }
|
||||
return keyChangelogSections(sections).map(({ key, section }) => (
|
||||
<View key={key} style={styles.section}>
|
||||
{section.title ? <Text style={styles.sectionTitle}>{section.title}</Text> : null}
|
||||
{section.body ? <MarkdownRenderer text={section.body} compact /> : null}
|
||||
{section.body ? (
|
||||
<MarkdownRenderer
|
||||
text={section.body}
|
||||
compact
|
||||
destinations="https"
|
||||
forgeShorthand={false}
|
||||
softBreaks="join"
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
));
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import type {
|
||||
ExplorerEntry,
|
||||
} from "@/stores/session-store";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { useHostRuntimeClient, useHostRuntimeConnectionStatus } from "@/runtime/host-runtime";
|
||||
import { FileActionsContextMenuContent } from "@/components/file-actions-menu";
|
||||
import { ContextMenu, ContextMenuTrigger, useContextMenu } from "@/components/ui/context-menu";
|
||||
import { useFileExplorerActions } from "@/hooks/use-file-explorer-actions";
|
||||
@@ -570,13 +571,33 @@ export function FileExplorerPane({
|
||||
const treeListRef = useRef<FlatList<ExplorerListRow>>(null);
|
||||
const scrollbar = useOverlayFlatListScrollbar(treeListRef, { enabled: !isCompact });
|
||||
|
||||
const client = useHostRuntimeClient(serverId);
|
||||
const connectionStatus = useHostRuntimeConnectionStatus(serverId);
|
||||
const canFetch = Boolean(client && connectionStatus === "online");
|
||||
const isHostConnecting = connectionStatus === "connecting" || connectionStatus === "idle";
|
||||
const isHostUnavailable = connectionStatus === "offline" || connectionStatus === "error";
|
||||
|
||||
const hasInitializedRef = useRef(false);
|
||||
const wasCanFetchRef = useRef(canFetch);
|
||||
|
||||
useEffect(() => {
|
||||
hasInitializedRef.current = false;
|
||||
wasCanFetchRef.current = false;
|
||||
}, [workspaceStateKey]);
|
||||
|
||||
useEffect(() => {
|
||||
const reconnected = !wasCanFetchRef.current && canFetch;
|
||||
wasCanFetchRef.current = canFetch;
|
||||
if (!canFetch) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
reconnected &&
|
||||
workspaceStateKey &&
|
||||
useSessionStore.getState().sessions[serverId]?.fileExplorer.get(workspaceStateKey)?.lastError
|
||||
) {
|
||||
hasInitializedRef.current = false;
|
||||
}
|
||||
void initializeExplorer({
|
||||
hasWorkspaceScope,
|
||||
hasInitializedRef,
|
||||
@@ -587,9 +608,12 @@ export function FileExplorerPane({
|
||||
setExpandedPathsForWorkspace,
|
||||
});
|
||||
}, [
|
||||
canFetch,
|
||||
client,
|
||||
expandedPaths,
|
||||
hasWorkspaceScope,
|
||||
requestDirectoryListing,
|
||||
serverId,
|
||||
setExpandedPathsForWorkspace,
|
||||
showHiddenFiles,
|
||||
workspaceStateKey,
|
||||
@@ -1007,12 +1031,16 @@ export function FileExplorerPane({
|
||||
onLayout: scrollbar.onLayout,
|
||||
});
|
||||
|
||||
const displayedError =
|
||||
error ??
|
||||
(!directories.has(".") && isHostUnavailable ? t("workspace.terminal.hostDisconnected") : null);
|
||||
const showInitialLoading = resolveShowInitialLoading({
|
||||
directories,
|
||||
isExplorerLoading,
|
||||
pendingRequest,
|
||||
isHostConnecting,
|
||||
});
|
||||
const showBackFromError = Boolean(error && selectedEntryPath);
|
||||
const showBackFromError = Boolean(displayedError && selectedEntryPath);
|
||||
const errorRecoveryPath = useMemo(() => getErrorRecoveryPath(explorerState), [explorerState]);
|
||||
|
||||
const rowActions = useMemo<EntryRowActions>(
|
||||
@@ -1184,7 +1212,7 @@ export function FileExplorerPane({
|
||||
style={styles.container}
|
||||
>
|
||||
<FileExplorerPaneContent
|
||||
error={error}
|
||||
error={displayedError}
|
||||
isCompact={isCompact}
|
||||
serverId={serverId}
|
||||
workspaceRoot={normalizedWorkspaceRoot}
|
||||
@@ -1551,14 +1579,19 @@ function resolveShowInitialLoading({
|
||||
directories,
|
||||
isExplorerLoading,
|
||||
pendingRequest,
|
||||
isHostConnecting,
|
||||
}: {
|
||||
directories: Map<string, unknown>;
|
||||
isExplorerLoading: boolean;
|
||||
pendingRequest: AgentFileExplorerState["pendingRequest"] | null;
|
||||
isHostConnecting: boolean;
|
||||
}): boolean {
|
||||
if (directories.has(".")) {
|
||||
return false;
|
||||
}
|
||||
if (isHostConnecting) {
|
||||
return true;
|
||||
}
|
||||
return Boolean(
|
||||
isExplorerLoading && pendingRequest?.mode === "list" && pendingRequest?.path === ".",
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
resolveProvidersToFetch,
|
||||
requiresImportSessionsHostUpgrade,
|
||||
type SessionsQueryResult,
|
||||
type SessionsListing,
|
||||
sumFilteredAlreadyImportedCount,
|
||||
} from "@/components/import-session-sheet-view-model";
|
||||
|
||||
@@ -37,15 +38,13 @@ function entry(
|
||||
}
|
||||
|
||||
function settled(
|
||||
data: SessionsQueryResult["data"],
|
||||
flags?: Partial<Omit<SessionsQueryResult, "data">>,
|
||||
response: SessionsListing["response"],
|
||||
requestError: string | null = null,
|
||||
): SessionsQueryResult {
|
||||
return {
|
||||
data,
|
||||
isError: false,
|
||||
data: response || requestError !== null ? { response, requestError } : undefined,
|
||||
isLoading: false,
|
||||
isPending: false,
|
||||
...flags,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ describe("collectProviderErrorRows", () => {
|
||||
it("returns a row for each provider whose request failed", () => {
|
||||
const rows = collectProviderErrorRows(
|
||||
["claude", "codex"],
|
||||
[settled(undefined, { isError: true }), settled({ entries: [] })],
|
||||
[settled(undefined, ""), settled({ entries: [] })],
|
||||
new Map([["claude", "Claude Code"]]),
|
||||
);
|
||||
expect(rows).toEqual([
|
||||
@@ -206,22 +205,15 @@ describe("collectProviderErrorRows", () => {
|
||||
});
|
||||
|
||||
it("uses provider id when the label map has no entry", () => {
|
||||
const rows = collectProviderErrorRows(
|
||||
["codex"],
|
||||
[settled(undefined, { isError: true })],
|
||||
new Map(),
|
||||
);
|
||||
const rows = collectProviderErrorRows(["codex"], [settled(undefined, "")], new Map());
|
||||
expect(rows).toEqual([{ provider: "codex", label: "codex", message: null, retrying: false }]);
|
||||
});
|
||||
|
||||
it("shows the current request failure instead of an older provider error", () => {
|
||||
const query = {
|
||||
...settled(
|
||||
{ entries: [], providerErrors: [{ provider: "codex", message: "old provider failure" }] },
|
||||
{ isError: true },
|
||||
),
|
||||
error: new Error(" Connection closed. Reconnect the host and retry. "),
|
||||
};
|
||||
const query = settled(
|
||||
{ entries: [], providerErrors: [{ provider: "codex", message: "old provider failure" }] },
|
||||
" Connection closed. Reconnect the host and retry. ",
|
||||
);
|
||||
expect(collectProviderErrorRows(["codex"], [query], new Map())).toEqual([
|
||||
{
|
||||
provider: "codex",
|
||||
@@ -278,7 +270,7 @@ describe("hasMoreSessions", () => {
|
||||
|
||||
it("keeps reporting more while the next page replaces placeholder rows", () => {
|
||||
expect(
|
||||
hasMoreSessions([settled({ entries: [entry()] }, { isPlaceholderData: true })], 45),
|
||||
hasMoreSessions([{ ...settled({ entries: [entry()] }), isPlaceholderData: true }], 45),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,16 +30,19 @@ export function requiresImportSessionsHostUpgrade(input: {
|
||||
return !input.supportsSnapshot || (Boolean(input.workspaceId) && !input.supportsWorkspaceTarget);
|
||||
}
|
||||
|
||||
interface SessionsResponse {
|
||||
entries: FetchRecentProviderSessionEntry[];
|
||||
filteredAlreadyImportedCount?: number;
|
||||
providerErrors?: Array<{ provider: string; message: string }>;
|
||||
}
|
||||
|
||||
export interface SessionsListing {
|
||||
response: SessionsResponse | undefined;
|
||||
requestError: string | null;
|
||||
}
|
||||
|
||||
export interface SessionsQueryResult {
|
||||
data:
|
||||
| {
|
||||
entries: FetchRecentProviderSessionEntry[];
|
||||
filteredAlreadyImportedCount?: number;
|
||||
providerErrors?: Array<{ provider: string; message: string }>;
|
||||
}
|
||||
| undefined;
|
||||
isError: boolean;
|
||||
error?: Error | null;
|
||||
data: SessionsListing | undefined;
|
||||
isFetching?: boolean;
|
||||
isLoading: boolean;
|
||||
isPending: boolean;
|
||||
@@ -78,8 +81,8 @@ export function aggregateSessionEntries(
|
||||
const seen = new Set<string>();
|
||||
const collected: FetchRecentProviderSessionEntry[] = [];
|
||||
for (const query of queries) {
|
||||
if (!query.data) continue;
|
||||
for (const entry of query.data.entries) {
|
||||
if (!query.data?.response) continue;
|
||||
for (const entry of query.data.response.entries) {
|
||||
const key = `${entry.providerId}:${entry.providerHandleId}`;
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
@@ -97,7 +100,7 @@ export function sumFilteredAlreadyImportedCount(
|
||||
): number {
|
||||
let total = 0;
|
||||
for (const query of queries) {
|
||||
total += query.data?.filteredAlreadyImportedCount ?? 0;
|
||||
total += query.data?.response?.filteredAlreadyImportedCount ?? 0;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@@ -114,7 +117,7 @@ export function hasMoreSessions(
|
||||
): boolean {
|
||||
if (nextPageLimit(limit) === limit) return false;
|
||||
return queries.some((entryQuery) => {
|
||||
const count = entryQuery.data?.entries.length ?? 0;
|
||||
const count = entryQuery.data?.response?.entries.length ?? 0;
|
||||
return entryQuery.isPlaceholderData ? count > 0 : count >= limit;
|
||||
});
|
||||
}
|
||||
@@ -142,11 +145,12 @@ export function collectProviderErrorRows(
|
||||
const query = queries[index];
|
||||
const provider = providersToFetch[index];
|
||||
if (!query || provider === undefined) continue;
|
||||
const failed = query.isError || (query.data?.providerErrors?.length ?? 0) > 0;
|
||||
if (!failed) continue;
|
||||
const failure = query.data?.providerErrors?.find((error) => error.provider === provider);
|
||||
const failureMessage = query.isError ? query.error?.message : failure?.message;
|
||||
const message = failureMessage?.trim() || null;
|
||||
const failure = query.data?.response?.providerErrors?.find(
|
||||
(error) => error.provider === provider,
|
||||
);
|
||||
const failureMessage = query.data?.requestError ?? failure?.message;
|
||||
if (failureMessage === undefined) continue;
|
||||
const message = failureMessage.trim() || null;
|
||||
rows.push({
|
||||
provider,
|
||||
label: providerLabelById.get(provider) ?? provider,
|
||||
|
||||
@@ -455,24 +455,43 @@ describe("ImportSessionSheet", () => {
|
||||
expect(screen.queryByText("No recent sessions to import.")).toBeNull();
|
||||
});
|
||||
|
||||
it("shows a fetch error state when recent provider sessions cannot be loaded", async () => {
|
||||
const fetchRecentProviderSessions = vi.fn(async () => {
|
||||
throw new Error("recent sessions unavailable");
|
||||
});
|
||||
const importAgent = vi.fn();
|
||||
|
||||
renderSheet(
|
||||
{ fetchRecentProviderSessions, importAgent } as Pick<
|
||||
DaemonClient,
|
||||
"fetchRecentProviderSessions" | "importAgent"
|
||||
>,
|
||||
{
|
||||
snapshot: { supportsSnapshot: true, entries: [createSnapshotEntry("claude")] },
|
||||
it("keeps a request error visible while Retry is pending and clears it after success", async () => {
|
||||
const retry =
|
||||
Promise.withResolvers<Awaited<ReturnType<DaemonClient["fetchRecentProviderSessions"]>>>();
|
||||
let firstRequest = true;
|
||||
const client = createRecentSessionsClient(
|
||||
async () => {
|
||||
if (firstRequest) {
|
||||
firstRequest = false;
|
||||
throw new Error("recent sessions unavailable");
|
||||
}
|
||||
return retry.promise;
|
||||
},
|
||||
async () => {
|
||||
throw new Error("Unexpected import");
|
||||
},
|
||||
);
|
||||
|
||||
await screen.findByText("Could not load Claude Code sessions");
|
||||
screen.getByTestId("import-session-retry-claude");
|
||||
renderSheet(client, {
|
||||
snapshot: { supportsSnapshot: true, entries: [createSnapshotEntry("claude")] },
|
||||
});
|
||||
|
||||
await screen.findByText("recent sessions unavailable");
|
||||
fireEvent.click(screen.getByTestId("import-session-retry-claude"));
|
||||
|
||||
try {
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("recent sessions unavailable")).toBeTruthy();
|
||||
expect(screen.getByRole("button", { name: "Retry" }).getAttribute("aria-disabled")).toBe(
|
||||
"true",
|
||||
);
|
||||
});
|
||||
} finally {
|
||||
retry.resolve({ requestId: "retry", entries: [] });
|
||||
}
|
||||
|
||||
await screen.findByText("No recent sessions to import.");
|
||||
expect(screen.queryByText("recent sessions unavailable")).toBeNull();
|
||||
});
|
||||
|
||||
it("loads recent provider sessions for the workspace and renders descriptor-owned labels", async () => {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Pressable, type PressableStateCallbackType, Text, View } from "react-native";
|
||||
import { useMutation, useQueries, useQueryClient, type QueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
queryOptions,
|
||||
useMutation,
|
||||
useQueries,
|
||||
useQueryClient,
|
||||
type QueryClient,
|
||||
} from "@tanstack/react-query";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type {
|
||||
DaemonClient,
|
||||
@@ -42,6 +48,7 @@ import {
|
||||
PER_PROVIDER_LIMIT,
|
||||
previousPageLimit,
|
||||
type ProviderErrorRow,
|
||||
type SessionsListing,
|
||||
resolveImportTarget,
|
||||
resolveProvidersToFetch,
|
||||
requiresImportSessionsHostUpgrade,
|
||||
@@ -73,10 +80,6 @@ interface ImportSessionSheetProps {
|
||||
onImported?: (agent: ImportedAgent) => void;
|
||||
}
|
||||
|
||||
type RecentSessionsResponse = Awaited<
|
||||
ReturnType<RecentProviderSessionsClient["fetchRecentProviderSessions"]>
|
||||
>;
|
||||
|
||||
type SessionsQueryKey = ReadonlyArray<string | number | null>;
|
||||
|
||||
function buildSessionsQueryRoot(serverId: string | null, cwd: string | null) {
|
||||
@@ -98,18 +101,6 @@ function buildSessionsQueryKey(input: {
|
||||
];
|
||||
}
|
||||
|
||||
interface SessionsQueryConfig {
|
||||
queryKey: SessionsQueryKey;
|
||||
enabled: boolean;
|
||||
// A provider that cannot answer stays broken until the user asks again. React
|
||||
// Query's default retry would keep the header spinner turning and pile up
|
||||
// in-flight daemon requests behind a dead provider (#2512).
|
||||
retry: false;
|
||||
refetchOnMount: true;
|
||||
placeholderData: () => RecentSessionsResponse | undefined;
|
||||
queryFn: () => Promise<RecentSessionsResponse>;
|
||||
}
|
||||
|
||||
function buildSessionsQueriesConfig(args: {
|
||||
queryClient: QueryClient;
|
||||
providersToFetch: AgentProvider[] | null;
|
||||
@@ -120,39 +111,63 @@ function buildSessionsQueriesConfig(args: {
|
||||
query: string;
|
||||
limit: number;
|
||||
hostDisconnectedMessage?: string;
|
||||
}): SessionsQueryConfig[] {
|
||||
}) {
|
||||
const { queryClient, providersToFetch, visible, client, serverId, cwd, query, limit } = args;
|
||||
const { hostDisconnectedMessage } = args;
|
||||
if (providersToFetch === null) return [];
|
||||
const enabled = visible && Boolean(client);
|
||||
const previousLimit = previousPageLimit(limit);
|
||||
return providersToFetch.map((provider) => ({
|
||||
queryKey: buildSessionsQueryKey({ serverId, cwd, query, limit, provider }),
|
||||
enabled,
|
||||
retry: false as const,
|
||||
// An import can invalidate an inactive host. Refresh its listing when observed again.
|
||||
refetchOnMount: true as const,
|
||||
// While Load more fetches the next page, keep showing the page it grew from. React Query's
|
||||
// keepPreviousData cannot do this here: useQueries gives a changed key a new observer, which
|
||||
// has no previous data, so the rows would vanish and the list would remount at the top.
|
||||
placeholderData: () =>
|
||||
previousLimit === null
|
||||
? undefined
|
||||
: queryClient.getQueryData<RecentSessionsResponse>(
|
||||
buildSessionsQueryKey({ serverId, cwd, query, limit: previousLimit, provider }),
|
||||
),
|
||||
queryFn: async () => {
|
||||
if (!client) {
|
||||
throw new Error(hostDisconnectedMessage ?? i18n.t("workspace.terminal.hostDisconnected"));
|
||||
}
|
||||
return await client.fetchRecentProviderSessions({
|
||||
...(cwd ? { cwd } : {}),
|
||||
providers: [provider],
|
||||
limit,
|
||||
...(query ? { query } : {}),
|
||||
});
|
||||
},
|
||||
}));
|
||||
const defaultStaleTime = queryClient.getDefaultOptions().queries?.staleTime;
|
||||
return providersToFetch.map((provider) => {
|
||||
const queryKey = buildSessionsQueryKey({ serverId, cwd, query, limit, provider });
|
||||
return queryOptions({
|
||||
queryKey,
|
||||
enabled,
|
||||
// Let the user retry a failed listing without an automatic retry loop.
|
||||
retry: false,
|
||||
// An import can invalidate an inactive host. Refresh its listing when observed again.
|
||||
refetchOnMount: true,
|
||||
// While Load more fetches the next page, keep showing the page it grew from. React Query's
|
||||
// keepPreviousData cannot do this here: useQueries gives a changed key a new observer, which
|
||||
// has no previous data, so the rows would vanish and the list would remount at the top.
|
||||
placeholderData: () => {
|
||||
if (previousLimit === null) return undefined;
|
||||
const previous = queryClient.getQueryData<SessionsListing>(
|
||||
buildSessionsQueryKey({ serverId, cwd, query, limit: previousLimit, provider }),
|
||||
);
|
||||
return previous?.response ? { response: previous.response, requestError: null } : undefined;
|
||||
},
|
||||
// Refetch failed listings when the sheet reopens.
|
||||
staleTime: (listingQuery) => {
|
||||
if (listingQuery.state.data?.requestError != null) return 0;
|
||||
if (typeof defaultStaleTime !== "function") return defaultStaleTime ?? 0;
|
||||
const cachedQuery = queryClient.getQueryCache().get(listingQuery.queryHash);
|
||||
return cachedQuery ? defaultStaleTime(cachedQuery) : 0;
|
||||
},
|
||||
queryFn: async (): Promise<SessionsListing> => {
|
||||
try {
|
||||
if (!client) {
|
||||
throw new Error(
|
||||
hostDisconnectedMessage ?? i18n.t("workspace.terminal.hostDisconnected"),
|
||||
);
|
||||
}
|
||||
const response = await client.fetchRecentProviderSessions({
|
||||
...(cwd ? { cwd } : {}),
|
||||
providers: [provider],
|
||||
limit,
|
||||
...(query ? { query } : {}),
|
||||
});
|
||||
return { response, requestError: null };
|
||||
} catch (error) {
|
||||
// Cache the last outcome so a new fetch cannot clear the error row.
|
||||
return {
|
||||
response: queryClient.getQueryData<SessionsListing>(queryKey)?.response,
|
||||
requestError: error instanceof Error ? error.message : String(error),
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interface SheetStatusMessagesProps {
|
||||
@@ -808,7 +823,8 @@ export function ImportSessionSheet({
|
||||
(isQueryingProviders &&
|
||||
queries.some((providerQuery) => providerQuery.isLoading || providerQuery.isPending));
|
||||
const allQueriesErrored =
|
||||
isQueryingProviders && queries.every((providerQuery) => providerQuery.isError);
|
||||
isQueryingProviders &&
|
||||
queries.every((providerQuery) => providerQuery.data?.requestError != null);
|
||||
const allQueriesSettled =
|
||||
isQueryingProviders &&
|
||||
queries.every((providerQuery) => !providerQuery.isLoading && !providerQuery.isPending);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Animated } from "react-native";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { createIndicatorClock } from "./clock";
|
||||
import { type ClockDriver, createIndicatorClock } from "./clock";
|
||||
|
||||
const PERIOD_MS = 900;
|
||||
const STEPS = 27;
|
||||
@@ -35,6 +35,44 @@ function frames(hz: number, count: number): number[] {
|
||||
return Array.from({ length: count }, (_, frame) => (frame * 1000) / hz);
|
||||
}
|
||||
|
||||
// A driver that advances nothing by itself, so the test decides when each span ends and when the
|
||||
// native driver says where a stopped clock is.
|
||||
function heldDriver() {
|
||||
const spansFromMs: number[] = [];
|
||||
const reports: ((heldMs: number) => void)[] = [];
|
||||
let onEnd: ((result: { finished: boolean }) => void) | null = null;
|
||||
function end(finished: boolean) {
|
||||
const ended = onEnd;
|
||||
onEnd = null;
|
||||
ended?.({ finished });
|
||||
}
|
||||
return {
|
||||
drive(_elapsedMs: Animated.Value, fromMs: number): ClockDriver {
|
||||
spansFromMs.push(fromMs);
|
||||
return {
|
||||
start(ended) {
|
||||
onEnd = ended;
|
||||
},
|
||||
stop(onHeld) {
|
||||
reports.push(onHeld);
|
||||
end(false);
|
||||
},
|
||||
};
|
||||
},
|
||||
/** What the native driver reports when it has counted a whole span. */
|
||||
finish: () => end(true),
|
||||
/** The native driver's answer to the oldest stop it has not answered. */
|
||||
reportHeld: (heldMs: number) => reports.shift()?.(heldMs),
|
||||
running: () => onEnd !== null,
|
||||
spansFromMs,
|
||||
};
|
||||
}
|
||||
|
||||
// The clock stops after the commit that took its last indicator away.
|
||||
async function commit(): Promise<void> {
|
||||
await Promise.resolve();
|
||||
}
|
||||
|
||||
describe("indicator clock", () => {
|
||||
test("a cycle without steps advances with every frame", () => {
|
||||
expect(positionsAt([0, 16, 450, 899, 900, 916])).toEqual([0, 16, 450, 899, 0, 16]);
|
||||
@@ -87,7 +125,7 @@ describe("indicator clock", () => {
|
||||
const shimmerPeriodMs = shimmerSteps * STEP_MS;
|
||||
let nowMs = 0;
|
||||
const elapsedMs = new Animated.Value(0);
|
||||
const clock = createIndicatorClock(elapsedMs, () => nowMs);
|
||||
const clock = createIndicatorClock(elapsedMs, () => nowMs, heldDriver().drive);
|
||||
const stop = clock.run();
|
||||
|
||||
// The shared clock has been running for a while when the shimmer appears.
|
||||
@@ -120,4 +158,113 @@ describe("indicator clock", () => {
|
||||
|
||||
expect(read(shimmer)).toBe(0);
|
||||
});
|
||||
|
||||
test("a span that ends under a running indicator is followed by one from where it ended", async () => {
|
||||
let nowMs = 0;
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(new Animated.Value(0), () => nowMs, driver.drive);
|
||||
const stop = clock.run();
|
||||
|
||||
// The JS thread hears about the end a few milliseconds after it.
|
||||
nowMs = 600_012;
|
||||
driver.finish();
|
||||
|
||||
expect(driver.running()).toBe(true);
|
||||
expect(driver.spansFromMs).toEqual([0, 600_000]);
|
||||
|
||||
stop();
|
||||
await commit();
|
||||
expect(driver.running()).toBe(false);
|
||||
});
|
||||
|
||||
test("a stopped clock holds its time and counts on from it", async () => {
|
||||
let nowMs = 0;
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(new Animated.Value(0), () => nowMs, driver.drive);
|
||||
|
||||
const stop = clock.run();
|
||||
nowMs = 5000;
|
||||
stop();
|
||||
await commit();
|
||||
expect(driver.running()).toBe(false);
|
||||
// The native driver started counting a frame after the JS thread asked.
|
||||
driver.reportHeld(4983);
|
||||
|
||||
nowMs = 90_000;
|
||||
clock.run();
|
||||
|
||||
expect(driver.spansFromMs).toEqual([0, 4983]);
|
||||
});
|
||||
|
||||
test("a clock restarted before the driver reports counts on from its own reading", async () => {
|
||||
let nowMs = 0;
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(new Animated.Value(0), () => nowMs, driver.drive);
|
||||
|
||||
const stopFirst = clock.run();
|
||||
nowMs = 5000;
|
||||
stopFirst();
|
||||
await commit();
|
||||
const stopSecond = clock.run();
|
||||
nowMs = 7000;
|
||||
stopSecond();
|
||||
await commit();
|
||||
// The answer to the first stop arrives after the second.
|
||||
driver.reportHeld(4983);
|
||||
clock.run();
|
||||
|
||||
expect(driver.spansFromMs).toEqual([0, 5000, 7000]);
|
||||
});
|
||||
|
||||
test("the clock keeps counting when one indicator takes over from another in a commit", async () => {
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(new Animated.Value(0), () => 0, driver.drive);
|
||||
|
||||
const stopChat = clock.run();
|
||||
stopChat();
|
||||
const stopSidebar = clock.run();
|
||||
await commit();
|
||||
|
||||
expect(driver.running()).toBe(true);
|
||||
expect(driver.spansFromMs).toEqual([0]);
|
||||
|
||||
stopSidebar();
|
||||
await commit();
|
||||
expect(driver.running()).toBe(false);
|
||||
});
|
||||
|
||||
test("a cycle with its own phase on a stopped clock starts where the clock will count on", async () => {
|
||||
let nowMs = 0;
|
||||
const elapsedMs = new Animated.Value(0);
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(elapsedMs, () => nowMs, driver.drive);
|
||||
const stop = clock.run();
|
||||
nowMs = 5000;
|
||||
stop();
|
||||
await commit();
|
||||
driver.reportHeld(4983);
|
||||
|
||||
const shimmer = clock.cycle(41 * STEP_MS, { steps: 41, phase: "own" });
|
||||
elapsedMs.setValue(4983);
|
||||
|
||||
expect(read(shimmer)).toBeLessThan(STEP_MS);
|
||||
});
|
||||
|
||||
test("a cycle with its own phase starts at its first step in a later span too", () => {
|
||||
let nowMs = 0;
|
||||
const elapsedMs = new Animated.Value(0);
|
||||
const driver = heldDriver();
|
||||
const clock = createIndicatorClock(elapsedMs, () => nowMs, driver.drive);
|
||||
const stop = clock.run();
|
||||
|
||||
nowMs = 600_012;
|
||||
driver.finish();
|
||||
// The second span started at 600 000 on the clock, 12 ms late on the JS thread.
|
||||
nowMs = 640_012;
|
||||
const shimmer = clock.cycle(41 * STEP_MS, { steps: 41, phase: "own" });
|
||||
elapsedMs.setValue(640_000);
|
||||
stop();
|
||||
|
||||
expect(read(shimmer)).toBeLessThan(STEP_MS);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { useEffect } from "react";
|
||||
import { Animated } from "react-native";
|
||||
import { Animated, Easing } from "react-native";
|
||||
|
||||
// A decay that never slows is a clock: with a velocity of one unit per millisecond the value is the
|
||||
// time since it started. Decay is the one native-driven animation that computes its value from the
|
||||
// frame's timestamp instead of replaying a 60 fps recording, so the motion is exact at any refresh
|
||||
// rate and never ends or loops.
|
||||
const CLOCK_CONFIG = { velocity: 1, deceleration: 1 - 1e-12, useNativeDriver: true };
|
||||
// The clock counts time in spans this long: a linear timing of one unit per millisecond, which the
|
||||
// native driver reads off the frame's timestamp. Only the end of a span comes back to the JS
|
||||
// thread, which starts the next one where that one ended.
|
||||
//
|
||||
// A decay that never slows would count without spans, but the driver ends a decay whose value did
|
||||
// not move between two frames, and two frames that carry the same millisecond are enough. A timing
|
||||
// has no such check.
|
||||
//
|
||||
// The timing is sent to the driver as one value for every 60th of a second, so a longer span costs
|
||||
// more each time the clock starts.
|
||||
const SPAN_MS = 10 * 60 * 1000;
|
||||
|
||||
// The clock starts on a frame and advances a whole frame at a time, so at 60, 90 and 120 Hz a step
|
||||
// that is a whole number of frames long would turn over exactly on a frame, and rounding would
|
||||
@@ -14,7 +20,8 @@ const CLOCK_CONFIG = { velocity: 1, deceleration: 1 - 1e-12, useNativeDriver: tr
|
||||
const STEP_LEAD = 1 / 8;
|
||||
|
||||
/**
|
||||
* Milliseconds, counted on the UI thread by React Native's native animation driver.
|
||||
* Milliseconds for which the clock has run, counted on the UI thread by React Native's native
|
||||
* animation driver.
|
||||
*
|
||||
* Views bound to it are updated by the native driver directly. Nothing reaches the JS thread, React
|
||||
* does not render, and no shadow tree is committed — which is what a Reanimated shared value costs
|
||||
@@ -37,28 +44,76 @@ export interface CycleOptions {
|
||||
export interface IndicatorClock {
|
||||
/** Where a cycle of `periodMs` currently is, as milliseconds into the cycle. */
|
||||
cycle(periodMs: number, options?: CycleOptions): Animated.AnimatedInterpolation<number>;
|
||||
/** Runs the clock until the returned function is called. It restarts from zero when idle. */
|
||||
/**
|
||||
* Runs the clock until the returned function is called. A clock nobody runs holds its time, and
|
||||
* counts on from it when it runs again, so a view bound to it stays where it stopped.
|
||||
*/
|
||||
run(): () => void;
|
||||
}
|
||||
|
||||
/** What advances the clock's value through one span, or until it is stopped. */
|
||||
export interface ClockDriver {
|
||||
start(onEnd: (result: { finished: boolean }) => void): void;
|
||||
/** Stops counting, then reports the time the clock stopped at. */
|
||||
stop(onHeld: (heldMs: number) => void): void;
|
||||
}
|
||||
|
||||
function countSpan(elapsedMs: Animated.Value, fromMs: number): ClockDriver {
|
||||
const span = Animated.timing(elapsedMs, {
|
||||
toValue: fromMs + SPAN_MS,
|
||||
duration: SPAN_MS,
|
||||
easing: Easing.linear,
|
||||
useNativeDriver: true,
|
||||
});
|
||||
return {
|
||||
start: (onEnd) => span.start(onEnd),
|
||||
stop: (onHeld) => elapsedMs.stopAnimation(onHeld),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* `now` is the JS thread's view of the time the clock reads. The native driver starts the clock a
|
||||
* frame or two after `run()` is called, so a cycle with its own phase can start a step into its
|
||||
* pass, or a step before it; the run-in before the first position hides either.
|
||||
* The native driver owns the clock's time: the JS thread never sets it, only starts and stops the
|
||||
* counting. `now` lets the JS thread follow along. The native driver starts counting a frame or two
|
||||
* after it is asked, so a cycle with its own phase can start a step into its pass, or a step
|
||||
* before it; the run-in before the first position hides either.
|
||||
*/
|
||||
export function createIndicatorClock(
|
||||
elapsedMs = new Animated.Value(0, { useNativeDriver: true }),
|
||||
now: () => number = () => performance.now(),
|
||||
drive: (elapsedMs: Animated.Value, fromMs: number) => ClockDriver = countSpan,
|
||||
): IndicatorClock {
|
||||
let runners = 0;
|
||||
let ticking: Animated.CompositeAnimation | null = null;
|
||||
let startedAtMs = 0;
|
||||
let ticking: ClockDriver | null = null;
|
||||
// While the clock counts: when, on the JS thread, it read zero.
|
||||
let zeroAtMs = 0;
|
||||
// While it does not: the time it holds.
|
||||
let heldMs = 0;
|
||||
let lastStopped: ClockDriver | null = null;
|
||||
|
||||
function currentStepStartMs(stepMs: number): number {
|
||||
if (!ticking) {
|
||||
return 0;
|
||||
}
|
||||
return Math.floor((now() - startedAtMs) / stepMs) * stepMs;
|
||||
const elapsed = ticking ? now() - zeroAtMs : heldMs;
|
||||
return Math.floor(elapsed / stepMs) * stepMs;
|
||||
}
|
||||
|
||||
function count(fromMs: number) {
|
||||
zeroAtMs = now() - fromMs;
|
||||
const driver = drive(elapsedMs, fromMs);
|
||||
ticking = driver;
|
||||
driver.start(({ finished }) => {
|
||||
if (finished && ticking === driver) count(fromMs + SPAN_MS);
|
||||
});
|
||||
}
|
||||
|
||||
function hold() {
|
||||
if (runners > 0 || !ticking) return;
|
||||
const stopped = ticking;
|
||||
ticking = null;
|
||||
lastStopped = stopped;
|
||||
// The JS thread's reading stands until the native driver reports its own.
|
||||
heldMs = now() - zeroAtMs;
|
||||
stopped.stop((reportedMs) => {
|
||||
if (!ticking && lastStopped === stopped) heldMs = reportedMs;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -76,17 +131,13 @@ export function createIndicatorClock(
|
||||
run() {
|
||||
runners += 1;
|
||||
if (!ticking) {
|
||||
elapsedMs.setValue(0);
|
||||
startedAtMs = now();
|
||||
ticking = Animated.decay(elapsedMs, CLOCK_CONFIG);
|
||||
ticking.start();
|
||||
count(heldMs);
|
||||
}
|
||||
return () => {
|
||||
runners -= 1;
|
||||
if (runners === 0) {
|
||||
ticking?.stop();
|
||||
ticking = null;
|
||||
}
|
||||
// One commit can take the last indicator away and bring another, as when a panel replaces
|
||||
// another. Stopping after the commit keeps the clock counting through that.
|
||||
if (runners === 0) queueMicrotask(hold);
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -35,15 +35,21 @@ function useReducedMotion(): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a running indicator may move right now. It holds still when the system asks for reduced
|
||||
* motion, and while nobody can see it: in a retained panel that is not showing, or in an app that
|
||||
* is in the background.
|
||||
* What a running indicator does right now.
|
||||
*
|
||||
* An indicator that is not moving draws its resting frame and runs nothing.
|
||||
* - `moving`: it runs.
|
||||
* - `held`: nobody can see it, in a retained panel that is not showing or in an app that is in the
|
||||
* background. It runs nothing and keeps its place, so it continues from there when it is seen
|
||||
* again. A panel slides into view before it counts as showing, and an indicator that dropped to
|
||||
* its resting frame would jump when the slide ends.
|
||||
* - `resting`: the system asks for reduced motion. It draws its resting frame and runs nothing.
|
||||
*/
|
||||
export function useIndicatorMotion(): boolean {
|
||||
export type IndicatorMotion = "moving" | "held" | "resting";
|
||||
|
||||
export function useIndicatorMotion(): IndicatorMotion {
|
||||
const panelActive = useRetainedPanelActive();
|
||||
const appVisible = useAppVisible();
|
||||
const reducedMotion = useReducedMotion();
|
||||
return panelActive && appVisible && !reducedMotion;
|
||||
if (reducedMotion) return "resting";
|
||||
return panelActive && appVisible ? "moving" : "held";
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ const styles = StyleSheet.create({
|
||||
* Native label shimmer: a gradient band slides behind a mask cut in the shape of the label. The
|
||||
* native animation driver moves the band; see `indicator-motion/clock.ts`. The band rides the
|
||||
* shared clock, so its steps turn over on the same frames as the status rings', and starts its own
|
||||
* pass so the highlight enters from the left when it starts moving.
|
||||
* pass so the highlight enters from the left when it appears.
|
||||
*/
|
||||
export const LabelShimmer = memo(function LabelShimmer({
|
||||
label,
|
||||
@@ -61,21 +61,23 @@ export const LabelShimmer = memo(function LabelShimmer({
|
||||
}: LabelShimmerProps) {
|
||||
const { rowSize } = measurements;
|
||||
const measured = rowSize.width > 0 && rowSize.height > 0;
|
||||
const moving = useIndicatorMotion() && measured;
|
||||
const motion = useIndicatorMotion();
|
||||
// A held band stays on the clock, so it keeps its place and its pass.
|
||||
const sweeping = motion !== "resting" && measured;
|
||||
const [gradientId] = useState(
|
||||
() => `shimmer-gradient-${Math.random().toString(36).substring(2, 9)}`,
|
||||
);
|
||||
useRunningClock(sharedIndicatorClock, moving);
|
||||
useRunningClock(sharedIndicatorClock, motion === "moving" && measured);
|
||||
|
||||
const { durationMs, steps } = getShimmerCycle(label, secondaryLabel);
|
||||
const { peakWidth, fromX, toX } = getRowSweep(rowSize.width);
|
||||
const { width, height } = rowSize;
|
||||
|
||||
const trackStyle = useMemo(() => [styles.track, { width, height }], [height, width]);
|
||||
// Built again each time the band starts moving, so each start begins a new pass.
|
||||
// Built again each time the band appears, so each appearance begins a new pass.
|
||||
const bandStyle = useMemo(
|
||||
() =>
|
||||
moving
|
||||
sweeping
|
||||
? [
|
||||
styles.band,
|
||||
{ width: peakWidth, height },
|
||||
@@ -90,7 +92,7 @@ export const LabelShimmer = memo(function LabelShimmer({
|
||||
},
|
||||
]
|
||||
: null,
|
||||
[durationMs, fromX, height, moving, peakWidth, steps, toX],
|
||||
[durationMs, fromX, height, sweeping, peakWidth, steps, toX],
|
||||
);
|
||||
const maskElement = useMemo(
|
||||
() => (
|
||||
@@ -110,7 +112,7 @@ export const LabelShimmer = memo(function LabelShimmer({
|
||||
[height, label, labelStyle, secondaryLabel, secondaryLabelStyle, width],
|
||||
);
|
||||
|
||||
if (!moving) {
|
||||
if (!sweeping) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export const LabelShimmer = memo(function LabelShimmer({
|
||||
measurements,
|
||||
}: LabelShimmerProps) {
|
||||
const { labelSpan, secondarySpan } = measurements;
|
||||
const moving = useIndicatorMotion();
|
||||
const moving = useIndicatorMotion() === "moving";
|
||||
const { durationMs, steps } = getShimmerCycle(label, secondaryLabel);
|
||||
const sweep = getTextSweep({ labelSpan, secondarySpan: secondaryLabel ? secondarySpan : null });
|
||||
|
||||
|
||||
@@ -167,6 +167,79 @@ describe("resolveMarkdownPreviewImageSource", () => {
|
||||
}),
|
||||
).toBe("C:/Users/test/repo/images/hero.png");
|
||||
});
|
||||
|
||||
it("keeps extended-length local Windows drive paths and local drive file URIs", () => {
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "\\\\?\\C:\\foo\\bar.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: "C:\\repo",
|
||||
}),
|
||||
).toBe("C:/foo/bar.png");
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "file:///C:/foo/bar.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: "C:\\repo",
|
||||
}),
|
||||
).toBe("C:/foo/bar.png");
|
||||
});
|
||||
|
||||
it.each([
|
||||
"\\\\host\\share\\x.png",
|
||||
"//host/share/x.png",
|
||||
"\\\\?\\UNC\\host\\share\\x.png",
|
||||
"file://host/share/x.png",
|
||||
"\\\\.\\pipe\\foo",
|
||||
"\\\\?\\Volume{01234567-89ab-cdef-0123-456789abcdef}",
|
||||
])("rejects UNC, remote file URI, and Windows device source %s", (source) => {
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source,
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: "C:\\repo",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("allows UNC and relative images inside a UNC workspace while rejecting paths outside it", () => {
|
||||
const uncRoot = "\\\\wsl.localhost\\Ubuntu\\home\\me\\proj";
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "\\\\wsl.localhost\\Ubuntu\\home\\me\\proj\\shot.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: uncRoot,
|
||||
}),
|
||||
).toBe("\\\\wsl.localhost\\Ubuntu\\home\\me\\proj\\shot.png");
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "file://wsl.localhost/Ubuntu/home/me/proj/shot.png?v=1#top",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: uncRoot,
|
||||
}),
|
||||
).toBe("\\\\wsl.localhost\\Ubuntu\\home\\me\\proj\\shot.png");
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "./images/hero.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: uncRoot,
|
||||
}),
|
||||
).toBe("//wsl.localhost/Ubuntu/home/me/proj/docs/images/hero.png");
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "../../../../outside.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: uncRoot,
|
||||
}),
|
||||
).toBeNull();
|
||||
expect(
|
||||
resolveMarkdownPreviewImageSource({
|
||||
source: "\\\\other\\share\\leak.png",
|
||||
markdownPath: "docs/guide.md",
|
||||
workspaceRoot: uncRoot,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("local assistant Markdown images", () => {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { localFileSourceToPath } from "@/attachments/utils";
|
||||
import {
|
||||
isUncPathWithinRoot,
|
||||
parseUncPath,
|
||||
stripLocalImageQueryAndFragment,
|
||||
} from "@getpaseo/protocol/path-utils";
|
||||
import { normalizeLocalImagePath } from "@/utils/assistant-image-source";
|
||||
import { isAbsolutePath } from "@/utils/path";
|
||||
|
||||
function trimTrailingSeparators(value: string): string {
|
||||
@@ -126,9 +131,10 @@ export function resolveMarkdownPreviewImageSource(input: {
|
||||
return source;
|
||||
}
|
||||
|
||||
const pathSource = source.replace(/[?#].*$/, "");
|
||||
const path = localFileSourceToPath(
|
||||
pathSource.startsWith("file://") ? pathSource : decodeRelativeSource(pathSource),
|
||||
const pathSource = stripLocalImageQueryAndFragment(source);
|
||||
const path = normalizeLocalImagePath(
|
||||
/^file:/i.test(pathSource) ? pathSource : decodeRelativeSource(pathSource),
|
||||
{ workspaceRoot: input.workspaceRoot },
|
||||
);
|
||||
if (!path) {
|
||||
return null;
|
||||
@@ -146,5 +152,13 @@ export function resolveMarkdownPreviewImageSource(input: {
|
||||
return path;
|
||||
}
|
||||
|
||||
return joinAbsolute(directory, path);
|
||||
const joined = joinAbsolute(directory, path);
|
||||
if (!joined) {
|
||||
return null;
|
||||
}
|
||||
const joinedUnc = parseUncPath(joined);
|
||||
if (joinedUnc && !isUncPathWithinRoot(joinedUnc, input.workspaceRoot)) {
|
||||
return null;
|
||||
}
|
||||
return joined;
|
||||
}
|
||||
|
||||
@@ -62,17 +62,24 @@ afterEach(() => {
|
||||
__setAttachmentStoreForTests(null);
|
||||
});
|
||||
|
||||
function renderMarkdownSource(text: string, initialProps: MarkdownImageContext) {
|
||||
function renderMarkdownSource(
|
||||
text: string,
|
||||
initialProps: MarkdownImageContext,
|
||||
options?: Parameters<typeof useMarkdownSource>[2],
|
||||
) {
|
||||
// No retries: a failed read settles at once. For a host's Markdown this is the state once the
|
||||
// retries have run out on a host that is slow to connect.
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
);
|
||||
const rendered = renderHook((props: MarkdownImageContext) => useMarkdownSource(text, props), {
|
||||
wrapper,
|
||||
initialProps,
|
||||
});
|
||||
const rendered = renderHook(
|
||||
(props: MarkdownImageContext) => useMarkdownSource(text, props, options),
|
||||
{
|
||||
wrapper,
|
||||
initialProps,
|
||||
},
|
||||
);
|
||||
return { ...rendered, queryClient };
|
||||
}
|
||||
|
||||
@@ -104,3 +111,32 @@ it("shows the alt text of a file image in Markdown that belongs to no host", asy
|
||||
expect(result.current.markdown.replace(PENDING_MARKDOWN_IMAGE, "pending")).toBe("Chart"),
|
||||
);
|
||||
});
|
||||
|
||||
it("never calls client.readFile when destinations are restricted to https", async () => {
|
||||
const files = createHostFiles();
|
||||
const { result, queryClient } = renderMarkdownSource(
|
||||
"   ",
|
||||
{ serverId: "srv_test", workspaceRoot: "/repo", client: files },
|
||||
{ destinations: "https" },
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(queryClient.isFetching()).toBe(0);
|
||||
expect(result.current.markdown).toBe("Local Relative Unc RemoteFile");
|
||||
});
|
||||
expect(files.reads).toEqual([]);
|
||||
});
|
||||
|
||||
it("never calls client.readFile for UNC, remote file URI, or Windows device paths in host Markdown", async () => {
|
||||
const files = createHostFiles();
|
||||
const { result, queryClient } = renderMarkdownSource(
|
||||
"   ",
|
||||
{ serverId: "srv_test", workspaceRoot: "C:/repo", client: files },
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(queryClient.isFetching()).toBe(0);
|
||||
expect(result.current.markdown).toBe("Unc SlashUnc Remote Pipe");
|
||||
});
|
||||
expect(files.reads).toEqual([]);
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user