Compare commits

..
5 Commits
Author SHA1 Message Date
b12daabe35 perf(app): row-grained replica cache persistence (#3755)
* feat(hub): guide starter setup (#3651)

* feat(hub): guide setup with provider IDs

* fix(hub): preserve login setup state

* feat(hub): select starter agent runtime

Use the connected daemon's provider snapshot so generated Hub bundles only
contain complete provider, model, and mode combinations.

* fix(hub): stage starter runtime choices

Keep providers with valid modes selectable when the daemon has no default mode, so users explicitly choose the complete runtime.

* fix(hub): scope runtime choices to workspace

Provider capabilities can vary by repository, so request the snapshot for the bundle directory that guided setup will deploy.

* fix(server): stop short start gates from undercutting provider startup budgets (#3621)

* fix(server): stop short start gates from undercutting provider startup budgets

Agent creation still failed on contended cold starts after #3578, because two
shorter gates on the same path fire before the event-stream readiness budget can
apply. A traced creation reached session.create twelve seconds in, past the 10s
session.create gate, and the agent was then killed by a bare "timeout" at fifteen
seconds from AGENT_RUN_START_TIMEOUT_MS while the SSE connect was still running.

A run-start bound of 15s wraps a path that is deliberately allowed 30s, so the
outer gate always wins and the inner budget is unreachable.

Give session.create the shared OPENCODE_SERVER_STARTUP_TIMEOUT_MS budget, since
creating the first session for a directory is part of OpenCode coming up, and
derive its error message from the constant instead of hardcoding "10s". Raise
AGENT_RUN_START_TIMEOUT_MS to 60s with a comment recording that it must stay
above the slowest provider startup budget; it stays a literal because that module
is provider-agnostic.

Related to #3571.

* test(server): drive the run start budget through a real AgentManager

The run start boundary tests replaced AgentManager.waitForAgentRunStart with a
bare timer, so they never exercised the production run-state transition or the
agent_state subscription the real wait depends on. That path could regress while
the tests stayed green.

Build the scenario on a real AgentManager with a provider session that holds its
turn start open for a configurable span, so pendingRun.started, the lifecycle
change to "running", and the agent_state notification are what the wait actually
observes. Budgets stay independent literals and the settled-before/after
assertions are unchanged.

* fix(server): describe agent run start timeouts

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>

* fix(relay): validate handshake keys (#3669)

* fix(files): keep large source previews responsive (#3665)

Large read-only files bypassed the editor's virtualization and eagerly mounted every highlighted token, which could stall the renderer for seconds and consume gigabytes of memory. Route source previews through bounded platform renderers and reject reads above their display budgets before accumulation.

* fix(hub): make guided setup choices actionable (#3677)

Show a concise login success state, scope starter choices to available Hub connections, wait for daemon capabilities, and avoid partial starter bundles when setup cannot proceed.

* Keep released agent SDK versions reproducible (#3678)

Pin the validated provider and protocol SDK dependency pair so fresh installs cannot silently float after a Paseo release. Refresh the Nix npm dependency hash for the resulting lockfile.

* feat(app): refine agent profile creation (#3680)

Keep profiles as the richer primitive while restoring the familiar star cue and clearer guidance for agent selection. Account for borders in shared field geometry so controls preserve their declared heights across form consumers.

* fix(app): restore native composer auto-growth (#3681)

Native multiline inputs were always scrollable, which kept iOS content-size measurement pinned to one line. Keep native sizing intrinsic below the cap and enable internal scrolling only after the composer reaches it.

* docs(hub): document zero-friction onboarding (#3657)

Lead with the browser-to-CLI onboarding journey, document the generated starter bundle, and align guided setup with available Hub connections and daemon-reported runtime defaults.

* Surface workspace changes from agent panes (#3682)

* feat(app): refine workspace pane actions

Prioritize Changes when available, keep Files useful before a selection, and reserve desktop diff clicks for selection so comments require the explicit affordance. Move the Changes shortcut to Shift+G to avoid consuming a likely copy variant.

* feat(app): improve access to workspace changes

* Expand workspace panel actions and keyboard navigation (#3685)

* fix(app): keep file navigation in place

Retargeting a File tab allocated a new tab identity, causing the tab track to unmount and remount during navigation. Preserve the identity for File-to-File changes while retaining new instances for cross-kind replacements.

* feat(app): expand workspace panel actions

Keep the Command Center aligned with workspace tab and pane primitives. Add explicit panel placement, focused open behavior, keyboard navigation for empty panes, and a Changes pill that toggles the visible Side panel without closing its tab.

* Restore compact and stable chat timelines (#3716)

Restore compact message and footer spacing, reserve independent composer-pill clearance for transcript content and floating controls, and keep visible web tool-call expansion from shifting the reading position.

* perf(app): defer replica persistence until user inactivity

Whole-replica capture and serialization blocked the JS thread during navigation and streaming. Defer that work until the user has been inactive while allowing long-running streams to persist without becoming the idle signal.

* Give every pane a browser-style New tab (#3715)

* feat(app): replace empty panes with New tabs

Give every retained pane an independently identified New tab, replace it in place when a destination is chosen, and preserve split close and move invariants. Keep existing workspace startup and compact explorer routing explicit, with focused unit and browser regression coverage.

* test(app): count content tabs in subagent integration

* fix(app): preserve workspace shortcut ownership

* fix(app): keep compact model options scrollable

The compact model sheet had no sheet-aware scroll owner when profiles filled its viewport, leaving the controls below them unreachable. Keep the root provider view inside Gorhom's scroll container so native sheet gestures work on both platforms.

* fix(app): order new tab launcher actions by workflow

* fix(app): show the New agent shortcut

The command center resolved New agent through the New tab binding, so it advertised Cmd+T despite creating an agent. Resolve the target-agent binding instead and cover the mapping.

* fix(app): prioritize side panel launcher actions

Lead with supporting workspace tools when the launcher is in the Side panel, while ordinary panes continue to lead with agent creation.

* fix(app): align terminal profiles header

* docs: add 0.5.0-beta.5 changelog

* test(app): align new tab launcher expectations

* chore(release): cut 0.5.0-beta.5

* fix: update lockfile signatures and Nix hash [skip ci]

* fix(app): make compact git actions menu-only

Keep compact toolbars narrow and require users to choose potentially consequential Git and workspace actions from the menu.

* fix(app): keep pinned project actions reachable (#3722)

* fix(app): keep pinned project actions reachable

Preserve an empty project shell after its final workspace is hoisted into the pinned section so project-scoped workspace creation remains available.

Co-authored-by: Agent Op <agentop718@gmail.com>

* test(app): verify pinned project workspace context

---------

Co-authored-by: Agent Op <agentop718@gmail.com>
Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>

* fix(app): stop a string SVG transform from crashing the app (#3711)

* fix(app): stop a string SVG transform from crashing the app

A root <Svg> is a real React Native view, so react-native-svg rewrites a
*string* `transform` into RN style syntax in `extractTransformSvgView`,
using a PEG parser whose grammar only accepts SVG transform functions.
Upstream lets that parser's SyntaxError escape, so any string it does not
understand takes the whole app down during render:

  SyntaxError: Expected transform functions but "n" found.
  "found": "n", "location": { "start": { "offset": 0 } }

`none` reproduces that message character for character; so does any other
CSS value (`rotate(-90deg)`, `translate(10px, 0)`). Every sibling
extractor in that file already catches the same error and degrades, so
the asymmetry is the bug: a string that is merely ignored on a <Path>
crashes on an <Svg>.

We feed that path untrusted input. The daemon scans a project for
favicon.svg / icon.svg / logo.svg (packages/server/src/utils/project-icon.ts)
and ships it to the client, where ProjectIconImage hands it to SvgCss.
Running the library's own XML parser over `<svg style="transform:none">`
yields exactly `transform: "none"` on the root, which is why the crash
starts once a host connects and the project icons render, with no
terminal involved.

Note this is *not* reachable from an RN-style array transform: the
extractor returns arrays untouched and only parses strings, so
`style={{ transform: [{ rotate: "-90deg" }] }}` (the context window meter
and the checks ring) was never a factor.

Patch the three builds a consumer can resolve - Metro takes the package's
`react-native` field (src/*.ts), Node and Vitest take main/module - and
register react-native-svg with the postinstall patch runner so the patch
actually applies. The new test pins all three.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EDwfsMWoSFfPm2cFXe5noQ

* test(app): cover parsed root SVG transforms

Exercise the dependency patch with root props produced by the library's XML and CSS parsers, including embedded style rules that can arrive through project icons. Keep dependency-patch documentation focused on the reusable install and resolution constraints.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>

* fix(pairing): warn that pairing links grant daemon access (#3734)

A pairing offer remains valid across daemon restarts, so remove the incorrect rotation guidance and warn users where the durable credential is displayed.

* fix(app): preserve timeline retry backoff (#3736)

Equivalent visibility publications were acting as implicit retry commands, so unrelated tab and layout changes could restart failed timeline work. Keep visibility identity stable and reserve immediate retries for explicit user action.

* Open the tab chooser beside the pointer (#3735)

* feat(app): open the tab chooser beside the pointer

Keep keyboard-created and empty-pane New tabs as persistent launcher surfaces, while giving pointer users an anchored chooser at the pane-local plus button. Both presentations resolve the same launch catalogue so future ordering and customization cannot drift.

* test(app): follow the anchored tab chooser

The browser helpers still searched inside the pane for persistent-launcher controls after clicking the portalled menu trigger. Exercise the menu through its own roles and stable catalogue IDs.

* fix(app): restore composer height lifecycle (#3740)

Native Fabric can omit the initial content-size callback and retain stale size after deletion. Keep the common composer surface free of platform branches while native and web adapters own their measurement mechanisms.

* fix(server): stop quota fetcher from writing provider credentials (#3442)

* fix(server): recover already-settled interrupts (#3742)

* fix(server): recover already-settled interrupts

Provider state can drift from Paseo’s tracked run. Treat an authoritative already-idle interrupt as settled and retire the captured run token so retrying can start new work without weakening ambiguous-cancellation protection.

* fix(codex): fence interruption during turn startup

Reserve foreground-start ownership before asynchronous provider setup. An interrupt can now cancel preflight before turn/start or wait for an issued start to become interruptible, preventing acknowledged cancellation from leaving unmanaged work.

* docs(changelog): prepare 0.5.0 stable release

* chore(release): cut 0.5.0

* fix: update lockfile signatures and Nix hash [skip ci]

* fix(app): stabilize native composer resizing

JavaScript height state competed with native intrinsic layout across draft and agent ownership transitions. Let native inputs own sizing and scrolling while preserving DOM measurement on web.

* docs(changelog): prepare 0.5.1 stable release

* chore(release): cut 0.5.1

* fix: update lockfile signatures and Nix hash [skip ci]

* perf(app): move replica cache validation to restore

Add an observational live measurement harness for the row-store migration baseline. Trust already-shaped cache values on persist while retaining full schema validation at the restore boundary.

* feat(app): add replica cache row store

Ship the platform storage engines behind a dark interface so the cache migration can wire them separately. Both engines share a contract, including atomic writes and destructive schema-version resets.

* feat(app): switch replica cache to row storage

Persist only changed replica entities so steady-state writes scale with the update rather than the complete cached world. Restore remains an all-or-nothing validated boundary, with whole-host byte-budget eviction.

* fix(app): harden replica row persistence

Serialize pending batches at write execution time so retries cannot overwrite newer rows or resurrect removed hosts. Reject oversized hosts before storage writes and preserve unchanged directory identities so routine reconciliation stays row-grained.

---------

Co-authored-by: BrianAguilarWasco <146237330+BrianAguilarWasco@users.noreply.github.com>
Co-authored-by: paseo-ai[bot] <266920839+paseo-ai[bot]@users.noreply.github.com>
Co-authored-by: Yuri Gui <yugui923@users.noreply.github.com>
Co-authored-by: Agent Op <agentop718@gmail.com>
Co-authored-by: Omer Cohen <639682+omercnet@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Dan Berindei <dan.berindei@gmail.com>
2026-08-24 20:45:49 +02:00
Anton LazarevandMohamed Boudra 43d27328e4 Fastlane metadata format for F-Droid releases (#2501)
* add f-droid metadata support

* share version code calculation with website

* preserve blockquoted sections in changelogs

* refactor(android): simplify stable F-Droid metadata

Generate store changelogs only for stable releases and keep native version-code ownership in the existing release module.

* test(android): run F-Droid changelog suite in CI

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-08-22 12:43:20 +02:00
nllptrxandMohamed Boudra b79b4bd5fc Feat/forge check semantics and followup fixes (#2337)
* feat(protocol): add forge check presentation metadata

Expose optional rawStatus, isManual, and requiresAction fields while keeping older check payloads backward-compatible.

* fix(gitea): model Actions jobs as tasks

Gitea's /actions/tasks endpoint returns individual jobs rather than workflow runs. Preserve sibling tasks from the latest execution, avoid collapsing same-name jobs, and enrich blocked tasks with run-level approval metadata.

* feat(app): distinguish forge check presentation states

* fix(gitlab): preserve pipeline job semantics

* refactor(app): centralize forge check presentation policy

Use one canonical category order, count shape, visual policy, and translated copy mapping across sidebar, hover-card, PR-pane, and GitLab pipeline surfaces.

* refactor: consolidate forge check handling

* feat(forge): auto-attach pasted forge references

* docs(compat): correct forge rollout metadata

* refactor(forge): model check nuances as traits

* fix(forge): harden checks from branch review

Structural Gitea Actions shadow dedup by run id (verified upstream),
rerun grouping without workflow_id, shared trait/status constants and
Gitea state mapping in the protocol package, all cloud host aliases in
pasted-link matching, logged glab job-detail failures, concurrent
approvals/pipeline fetch, checks aggregate from the same pipeline as
the job list, and removal of the unread check-level rawStatus. The
released pipeline-level rawStatus is staged for removal under
COMPAT(pipelineRawStatus).

* fix(gitea): detect fork-PR Actions approval hold as action_required

gitea.com represents a fork PR awaiting Actions approval as a run in
status "waiting" with no tasks and pending shadow commit statuses; it
does not expose need_approval. The previous mapping only set
action_required from a task with blocked+need_approval, so the gate
never surfaced (0 tasks -> early return; need_approval absent). Detect
the hold from /actions/runs: a waiting/blocked run whose PR is
cross-repo (head.repo.id != base.repo.id), or one that does expose
need_approval (self-hosted). Tag the run's pending shadow statuses
action_required. Runs are only fetched when a pending shadow has no
covering task, keeping the common path at two requests. Verified live
against gitea.com fork PR (run 715170, waiting, cross-repo).

* fix(gitea): resolve cross-fork PRs by head sha

The current-PR matcher gated candidates on the checkout owner
(giteaHeadOwner === expectedHeadOwner), which excludes every fork PR:
its head carries the fork owner while the checkout is the base repo, so
a fork PR - the only shape that can be approval-held on Gitea - never
resolved and its checks never showed in-app. GitLab has no such gate
(it resolves fork MRs from the target project by source branch). Accept
a recent PR whose head sha equals the workspace head sha regardless of
owner; the sha is an unambiguous identity, so the anti-collision owner
gate still applies when no sha match is available. Verified live against
gitea.com fork PR #6 (resolves + renders action_required).

* fix: resolve forge rebase drift

* fix: type forge auto-attach boundary

* fix(i18n): add Korean check status copy

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-08-22 12:42:54 +02:00
dac6cd141a Stream assistant text at a steady rate instead of in arrival lumps (#3612)
* Stream assistant text at a steady rate instead of in arrival lumps

Assistant text arrived in lumps and was painted that way. The daemon
coalesces one message per 60ms window, and that window carries however
many characters the model produced in it, which swings by an order of
magnitude within a turn. Painting each delta as it landed made the size
of those lumps visible.

Three changes:

- The agent stream coalescer is now leading + trailing. The first delta
  after an idle window flushes synchronously instead of waiting a full
  window, matching the invariant TerminalOutputCoalescer already
  documents. The window stays at 60ms; shrinking it would raise message
  rate on a loop that already contends with terminal frames and relay
  encryption, without making the stream smoother.

- The client reducer queue commits on a frame instead of an arbitrary
  48ms timer, with the timer kept as a ceiling so a hidden tab still
  advances.

- Assistant and reasoning text are revealed at a rate derived from the
  backlog rather than from arrival timing. Arrival changes the target,
  not the rate. The store keeps the full text and only the rendered
  slice is paced, so copy, selection, the chat outline, and scroll
  geometry all stay consistent with what is on screen.

The leading flush means a burst's first chunk lands as its own timeline
row. The projection already merges contiguous same-turn rows and clients
read the projected timeline, so history is unchanged; the server tests
that assert on raw rows were updated for the extra row.

Measured on Expo web against a local dev daemon. Mock bursty-stream
provider, 6s samples, paint-on-arrival vs paced: frames that advanced
the text 55 -> 244, chars-per-frame CV 2.66 -> 1.44, gap p50 100ms ->
17ms. Real Claude Haiku agent over 52s: 84% of frames advance the text,
CV 1.29, gap p50 and p95 both 17ms (one frame at 60Hz).

Adds a bursty-stream mock model with seeded burst sizes, a gated browser
perf spec, and docs/agent-stream-performance.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Address review: safe reveal boundaries and a testable seam

Two findings from the PR review.

Unicode boundaries. Slicing the revealed text at an arbitrary index could
strand a lone surrogate, which paints as a replacement glyph, or split an
emoji ZWJ sequence so a family briefly rendered as its members. Both were
visible for a frame or two mid-stream — the exact flicker the paced reveal
exists to remove. The rendered cut is now pulled back off surrogate pairs,
combining marks, variation selectors, skin tone modifiers, and ZWJ joins.
The reveal counter stays monotonic and only the painted boundary moves, so
a long cluster cannot stall the reveal.

Test placement. The hook test used JSDOM, @testing-library renderHook, and
monkey-patched requestAnimationFrame, all of which docs/testing.md rules
out; it prescribes fixing the missing seam instead. The reveal policy is
now a pure state machine in text-reveal.ts (begin/retarget/advance/
complete/visible) covered by plain unit tests with no environment, and the
hook is reduced to the frame-clock binding. Rendered behavior is left to
the browser spec, which no longer carries frame sampling and statistics in
its body — those moved to e2e/support/helpers/stream-smoothness.ts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Measure total painted text, not the tail message

The smoothness sampler read the length of the last assistant-message
element. A real turn emits many assistant messages, so that element keeps
changing identity and its length is not monotonic — handovers read as
resets, and a stream that was plainly moving on screen reported almost no
growth at all. Sampling the total across every assistant message fixes it.

This invalidated the numbers previously recorded for the real-agent run,
so the doc table is replaced with a fresh A/B taken with the corrected
sampler against a Claude Haiku agent: frames that advanced the text 6% ->
87%, chars-per-frame CV 4.11 -> 1.86, gap p50 317ms -> 17ms, p95 383ms ->
17ms. The paced column also reported zero Unicode defects across a stream
containing emoji, which exercises the reveal boundary clamp end to end.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* perf(agent-stream): harden paced text reveal

Use standards-compliant grapheme segmentation when available and preserve full arrivals on older runtimes. Cap reveal commits at 60Hz and measure the real browser rendering path so high-refresh displays stay smooth without rendering at hardware frame rate.

* Hold back trailing fragments split by arrival boundaries

The reveal boundary is not the only place a grapheme gets cut. The
daemon's coalescing window ends a delta wherever the window closes, so a
caught-up reveal can be handed half a cluster and paint it. Measured on a
mixed-script Haiku stream: five frames in ~350 ending in a single regional
indicator, i.e. half a flag on screen for a frame.

While the turn is streaming, a trailing fragment that cannot stand alone —
a dangling high surrogate, a trailing joiner, an odd regional indicator —
now waits for the rest of its cluster. Once the turn ends everything
received is painted, because nothing more is coming. Complements the
grapheme-boundary clamp, which handles the reveal cut; this handles the
arrival cut.

The same stream now measures one such frame in ~400 rather than five. The
remainder is a flush boundary that coincides with the end of an assistant
message, putting the two halves in different messages, which the client
cannot rejoin — that one belongs in the coalescer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-08-22 12:38:49 +02:00
Mohamed Boudra c3ae54a1a2 fix(rewind): replace long timelines without replay (#3642)
* fix(rewind): refresh canonical timeline after rewind

A rewind replaces the daemon timeline and epoch, but replaying the rebuilt history made long conversations visibly reload from the beginning. Capable clients now refresh the existing bounded tail path after a replacement signal while legacy clients retain replay compatibility.

* test(rewind): cover coherent timeline replacement

Hold rewind completion in the browser regression so it can verify the existing pending state and detect any reconstructed timeline rows before the normal tail refresh is allowed to finish.
2026-08-21 19:09:56 +02:00
169 changed files with 8747 additions and 1678 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ jobs:
filters: .github/ci-paths.yml
- name: Validate CI contracts
run: node --test scripts/ci-workflow.test.mjs scripts/daemon-launch-contract.test.mjs
run: node --test scripts/ci-workflow.test.mjs scripts/daemon-launch-contract.test.mjs scripts/sync-fdroid-changelogs.test.mjs
format:
name: format
+41 -40
View File
@@ -21,46 +21,47 @@ This is an npm workspace monorepo:
At the start of non-trivial work, list `docs/` and skim anything relevant to the task.
| Doc | What's in it |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| [docs/product.md](docs/product.md) | What Paseo is, who it's for, where it's going |
| [docs/architecture.md](docs/architecture.md) | System design, package layering, WebSocket protocol, agent lifecycle, data flow |
| [docs/agent-lifecycle.md](docs/agent-lifecycle.md) | Agent states, parent/child relationships, archive semantics, tabs vs archive, subagents track |
| [docs/data-model.md](docs/data-model.md) | File-based JSON persistence, Zod schemas, atomic writes, no migrations |
| [docs/glossary.md](docs/glossary.md) | Authoritative terminology — UI label wins, no synonyms |
| [docs/coding-standards.md](docs/coding-standards.md) | Type hygiene, error handling, state design, React patterns, file organization |
| [docs/design.md](docs/design.md) | Design system — tokens, buttons, hierarchy, density, alignment rails, states, what's forbidden |
| [docs/forms.md](docs/forms.md) | Form architecture — non-React form model, form kit, load-state gating; the schedule form is the golden example |
| [docs/hover.md](docs/hover.md) | Hover — the canonical pattern (plain View + onPointerEnter/Leave, separate inner Pressable) and the three ways agents break it |
| [docs/unistyles.md](docs/unistyles.md) | Unistyles gotchas — `useUnistyles()` is forbidden, alternatives in order |
| [docs/floating-panels.md](docs/floating-panels.md) | Anchored popovers — Portal/Modal escape for Android, lifecycle gates, keyboard-shared-value, status-bar offset, the flash |
| [docs/menus.md](docs/menus.md) | The menu engine — popover vs sheet, submenu pages, hover intent, when a decision earns a submenu |
| [docs/expo-router.md](docs/expo-router.md) | Expo Router route ownership, startup restore, and native blank-screen gotchas |
| [docs/file-icons.md](docs/file-icons.md) | Material icon theme integration for the file explorer |
| [docs/providers.md](docs/providers.md) | Adding a new agent provider end-to-end |
| [docs/forge-providers.md](docs/forge-providers.md) | Adding a git forge: registry/manifest, drop-in checklist, self-host/GHES, the two facts tiers |
| [docs/custom-providers.md](docs/custom-providers.md) | Custom provider config: Z.AI, Alibaba/Qwen, ACP agents, profiles, custom binaries |
| [docs/plugins.md](docs/plugins.md) | Local plugin manifest, directory source config, RPCs, native surfaces, and attachment sources |
| [docs/service-proxy.md](docs/service-proxy.md) | Service proxy: exposing workspace scripts at public URLs, DNS setup, reverse proxy config |
| [docs/development.md](docs/development.md) | Dev server, build sync gotchas, CLI reference, agent state, Playwright MCP |
| [docs/rpc-namespacing.md](docs/rpc-namespacing.md) | WebSocket RPC naming convention — dotted namespaces and `.request`/`.response` pairs |
| [docs/protocol-compatibility.md](docs/protocol-compatibility.md) | Why app/daemon versions drift, protocol vs feature contract, capability gating, COMPAT tagging |
| [docs/protocol-validation.md](docs/protocol-validation.md) | zod-aot generated inbound WebSocket validation, patched compiler regressions, schema-purity rules |
| [docs/terminal-performance.md](docs/terminal-performance.md) | Terminal latency pipeline, coalescing/backpressure invariants, benchmark + perf spec usage |
| [docs/file-observation.md](docs/file-observation.md) | Recursive watcher ownership, Linux constraints, teardown invariants, and Parcel comparison |
| [docs/testing.md](docs/testing.md) | TDD workflow, determinism, real dependencies over mocks, test organization |
| [docs/qa.md](docs/qa.md) | QA evidence bar for pull requests — platform matrix, version drift, performance, UI proof |
| [docs/mobile-testing.md](docs/mobile-testing.md) | Maestro and mobile test workflows |
| [docs/mobile-panels.md](docs/mobile-panels.md) | Compact left/center/right panel ownership, worklet motion, gesture revisions, and Fabric constraints |
| [docs/side-panel.md](docs/side-panel.md) | The Side panel surface — its three renderings, tab placement intents, pane lifecycle, and the routing preference |
| [docs/ad-hoc-daemon-testing.md](docs/ad-hoc-daemon-testing.md) | Isolated in-process daemon test harness |
| [docs/browser-capture-harness.md](docs/browser-capture-harness.md) | Real-Electron browser screenshot harness and compositor-surface gotcha |
| [docs/android.md](docs/android.md) | App variants, local/cloud builds, EAS workflows |
| [docs/docker.md](docs/docker.md) | Running the daemon and bundled web UI in Docker, volumes, agent images, security |
| [docs/release.md](docs/release.md) | Release playbook, draft releases, completion checklist |
| [docs/terminal-activity.md](docs/terminal-activity.md) | Terminal activity indicators — source-agnostic tracker, agent hook reporting, adding a new hook provider |
| [SECURITY.md](SECURITY.md) | Relay threat model, E2E encryption, DNS rebinding, agent auth |
| [public-docs/hub/security.md](public-docs/hub/security.md) | Public Hub guide — trust boundaries, untrusted triggers, provider controls, and output authority |
| Doc | What's in it |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [docs/product.md](docs/product.md) | What Paseo is, who it's for, where it's going |
| [docs/architecture.md](docs/architecture.md) | System design, package layering, WebSocket protocol, agent lifecycle, data flow |
| [docs/agent-lifecycle.md](docs/agent-lifecycle.md) | Agent states, parent/child relationships, archive semantics, tabs vs archive, subagents track |
| [docs/data-model.md](docs/data-model.md) | File-based JSON persistence, Zod schemas, atomic writes, no migrations |
| [docs/glossary.md](docs/glossary.md) | Authoritative terminology — UI label wins, no synonyms |
| [docs/coding-standards.md](docs/coding-standards.md) | Type hygiene, error handling, state design, React patterns, file organization |
| [docs/design.md](docs/design.md) | Design system — tokens, buttons, hierarchy, density, alignment rails, states, what's forbidden |
| [docs/forms.md](docs/forms.md) | Form architecture — non-React form model, form kit, load-state gating; the schedule form is the golden example |
| [docs/hover.md](docs/hover.md) | Hover — the canonical pattern (plain View + onPointerEnter/Leave, separate inner Pressable) and the three ways agents break it |
| [docs/unistyles.md](docs/unistyles.md) | Unistyles gotchas — `useUnistyles()` is forbidden, alternatives in order |
| [docs/floating-panels.md](docs/floating-panels.md) | Anchored popovers — Portal/Modal escape for Android, lifecycle gates, keyboard-shared-value, status-bar offset, the flash |
| [docs/menus.md](docs/menus.md) | The menu engine — popover vs sheet, submenu pages, hover intent, when a decision earns a submenu |
| [docs/expo-router.md](docs/expo-router.md) | Expo Router route ownership, startup restore, and native blank-screen gotchas |
| [docs/file-icons.md](docs/file-icons.md) | Material icon theme integration for the file explorer |
| [docs/providers.md](docs/providers.md) | Adding a new agent provider end-to-end |
| [docs/forge-providers.md](docs/forge-providers.md) | Adding a git forge: registry/manifest, drop-in checklist, self-host/GHES, the two facts tiers |
| [docs/custom-providers.md](docs/custom-providers.md) | Custom provider config: Z.AI, Alibaba/Qwen, ACP agents, profiles, custom binaries |
| [docs/plugins.md](docs/plugins.md) | Local plugin manifest, directory source config, RPCs, native surfaces, and attachment sources |
| [docs/service-proxy.md](docs/service-proxy.md) | Service proxy: exposing workspace scripts at public URLs, DNS setup, reverse proxy config |
| [docs/development.md](docs/development.md) | Dev server, build sync gotchas, CLI reference, agent state, Playwright MCP |
| [docs/rpc-namespacing.md](docs/rpc-namespacing.md) | WebSocket RPC naming convention — dotted namespaces and `.request`/`.response` pairs |
| [docs/protocol-compatibility.md](docs/protocol-compatibility.md) | Why app/daemon versions drift, protocol vs feature contract, capability gating, COMPAT tagging |
| [docs/protocol-validation.md](docs/protocol-validation.md) | zod-aot generated inbound WebSocket validation, patched compiler regressions, schema-purity rules |
| [docs/terminal-performance.md](docs/terminal-performance.md) | Terminal latency pipeline, coalescing/backpressure invariants, benchmark + perf spec usage |
| [docs/agent-stream-performance.md](docs/agent-stream-performance.md) | Assistant text pipeline — coalescing window, paced reveal, why arrival lumps are smoothed at render |
| [docs/file-observation.md](docs/file-observation.md) | Recursive watcher ownership, Linux constraints, teardown invariants, and Parcel comparison |
| [docs/testing.md](docs/testing.md) | TDD workflow, determinism, real dependencies over mocks, test organization |
| [docs/qa.md](docs/qa.md) | QA evidence bar for pull requests — platform matrix, version drift, performance, UI proof |
| [docs/mobile-testing.md](docs/mobile-testing.md) | Maestro and mobile test workflows |
| [docs/mobile-panels.md](docs/mobile-panels.md) | Compact left/center/right panel ownership, worklet motion, gesture revisions, and Fabric constraints |
| [docs/side-panel.md](docs/side-panel.md) | The Side panel surface — its three renderings, tab placement intents, pane lifecycle, and the routing preference |
| [docs/ad-hoc-daemon-testing.md](docs/ad-hoc-daemon-testing.md) | Isolated in-process daemon test harness |
| [docs/browser-capture-harness.md](docs/browser-capture-harness.md) | Real-Electron browser screenshot harness and compositor-surface gotcha |
| [docs/android.md](docs/android.md) | App variants, local/cloud builds, EAS workflows, version codes, F-Droid source builds and store metadata |
| [docs/docker.md](docs/docker.md) | Running the daemon and bundled web UI in Docker, volumes, agent images, security |
| [docs/release.md](docs/release.md) | Release playbook, draft releases, completion checklist |
| [docs/terminal-activity.md](docs/terminal-activity.md) | Terminal activity indicators — source-agnostic tracker, agent hook reporting, adding a new hook provider |
| [SECURITY.md](SECURITY.md) | Relay threat model, E2E encryption, DNS rebinding, agent auth |
| [public-docs/hub/security.md](public-docs/hub/security.md) | Public Hub guide — trust boundaries, untrusted triggers, provider controls, and output authority |
### Writing docs
+52
View File
@@ -0,0 +1,52 @@
# Agent stream performance
How assistant text gets from a provider to the screen, and why it is paced on the way. Read this before changing `packages/server/src/server/agent/agent-stream-coalescer.ts`, the reducer queue in `packages/app/src/timeline/session-stream-reducers.ts`, or the reveal in `packages/app/src/hooks/use-revealed-text.ts`.
For terminal output, which is a separate pipeline with separate budgets, see [terminal-performance.md](terminal-performance.md).
## The pipeline
```
provider deltas (every provider streams incrementally)
→ AgentStreamCoalescer (daemon, leading + trailing, ≤1 message per 60ms per agent)
→ recordTimeline: one canonical row per flushed item
→ agent_stream ws message
→ reducer queue (app, one commit per frame) → session store
→ paced reveal (app, per assistant/reasoning item) → markdown blocks → paint
```
Every provider delivers incremental text, so there is no provider that needs special handling: Claude via `includePartialMessages`, Codex via `agent_message_delta`, ACP agents via `agent_message_chunk`, Pi and OMP via `text_delta`.
## Why the reveal is paced
Arrival is lumpy and there is no fixing that at the source. A 60ms coalescing window carries however many characters the model produced in those 60ms, which swings by an order of magnitude within a single turn. Painting each delta as it lands makes the size of those lumps visible, and that is what reads as jagged.
So arrival sets a _target_ and the reveal rate is derived from the backlog instead. A burst makes the text catch up faster; it does not make the text jump. Shrinking the coalescing window does not fix this — it makes the lumps smaller and more frequent, at the cost of message rate on a daemon loop that already contends with terminal frames and per-message relay encryption.
## Invariants
- **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.
- **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.
- **The reducer queue commits on a frame, with a timer as the ceiling.** A frame callback never fires in a hidden tab, so a timer races it and wins when nothing is painting — the store has to keep advancing either way.
## Measuring
- **Smoothness (user-perceived):** `packages/app/e2e/browser/agent-stream-smoothness.spec.ts`, gated behind `PASEO_AGENT_STREAM_PERF_E2E=1`. Drives the mock provider's `bursty-stream` model and reports coefficient of variation of characters painted per frame (smoothness) plus p95 gap between visible updates (stalls). Both numbers are needed: a stalled stream is perfectly smooth.
- **Reproducing bursty arrival:** the `bursty-stream` model in `mock-load-test-agent.ts` emits uneven runs of tokens separated by idle gaps. Burst sizes come from a seeded generator, so a run repeats exactly.
- **Rate policy in isolation:** `computeRevealStep` in `packages/app/src/agent-stream/text-reveal.ts` is pure; `text-reveal.test.ts` covers convergence and burst flattening without a renderer.
Healthy numbers (2026-08, Expo web against a local dev daemon, real Claude Haiku agent, ~8.5s samples during active streaming). Setting `TEXT_REVEAL_HORIZON_MS` to 0 makes the reveal paint on arrival, which is how the baseline column was taken:
| | paint on arrival | paced |
| -------------------------------- | ---------------- | ----- |
| frames that advanced the text | 6% | 87% |
| chars-per-frame CV | 4.11 | 1.86 |
| gap between visible updates, p50 | 317ms | 17ms |
| gap between visible updates, p95 | 383ms | 17ms |
Total characters painted is roughly the same either way — the reveal changes when they land, not how many arrive.
Measure the **total** length across every `assistant-message` element, not the last one. A turn emits many assistant messages, so the tail element keeps changing identity and its length is not monotonic; sampling only the tail reads those handovers as resets and reports almost no growth. `sampleStreamFrames` does this correctly.
+34 -1
View File
@@ -15,7 +15,9 @@ EAS profiles: `development`, `production`, and `production-apk` in `packages/app
## Version codes
`packages/app/app.config.js` derives Android `versionCode` from the package version with:
`packages/app/native-release-version.js` is the single definition of native and F-Droid version-code math. Do not re-derive these numbers anywhere else — a drifted copy produces changelog files that match no published APK, and nothing fails loudly.
The base version code comes from the package version:
```text
major * 1_000_000 + minor * 1_000 + patch
@@ -145,6 +147,37 @@ Keep the excluded npm packages installed. Normal builds use them, while the F-Dr
The EAS `production-apk` profile uses the large Android resource class. Release builds compile the native ABIs and run Hermes bundling in the same Gradle invocation; the default worker can exhaust its remaining memory and kill Hermes with exit code 137 even when Gradle's own heap is correctly sized.
### F-Droid store metadata
F-Droid reads the store listing from `fastlane/metadata/android/<locale>/` **at the repo root**. This location provides the best compatibility with the F-Droid release process.
```text
fastlane/metadata/android/
├── en-US/ (F-Droid fallback locale, mandatory)
│ ├── title.txt (<=50 chars)
│ ├── short_description.txt (<=80 chars)
│ ├── full_description.txt (<=4000 chars, limited HTML)
│ ├── images/
│ │ ├── icon.png (512x512)
│ │ ├── featureGraphic.png (1024x500)
│ │ └── phoneScreenshots/ (1.png, 2.png, ...)
│ └── changelogs/ (generated — see below)
├── ja/
└── zh-CN/
```
Locale directories generally match `packages/app/src/i18n/locales.ts`, but note that `en` becomes `en-US`.
F-Droid changelogs are generated from `CHANGELOG.md`. Run `npm run fdroid:changelogs`; `npm run fdroid:changelogs:check` verifies without writing. It is wired into the npm `version` lifecycle, so a release picks it up automatically and `git add -A` stages the result.
One changelog must be generated per-ABI-split, so each version will create **four** identical version-coded entries. F-Droid caps changelogs at 500 characters, so the generator strips some content and adds a link to the full notes.
Stable sync fails loudly if `CHANGELOG.md` has no entry for the version being cut. That is intentional — the release checklist requires the entry to be committed first, so an abort here means the checklist was skipped.
Because the generator runs off the version in `package.json`, it must run **before** the tag is created: fdroidserver only reads metadata from the tag it builds, so the file for version N has to exist in the commit N points at.
Beta releases are an explicit no-op: they do not create or rewrite F-Droid changelog files. Stable releases and promotions generate the four ABI entries from their final changelog.
### React version lockstep
Keep `react` and `react-dom` pinned to the React version embedded by the current `react-native` release. React Native `0.81.x` embeds `react-native-renderer` `19.1.0`, so `packages/app` must use React `19.1.0`. Bumping React to a newer patch can build successfully but crash at JS startup on Android with `Incompatible React versions`, leaving the app on the native splash screen.
+9 -6
View File
@@ -104,7 +104,7 @@ Cross-platform React Native app that connects to one or more daemons.
- Expo Router navigation (`/h/[serverId]/workspace/[workspaceId]`, `/h/[serverId]/agent/[agentId]`, etc.). The `workspaceId` URL segment is an opaque workspace id, not a directly meaningful filesystem path.
- `HostRuntimeController` manages saved host connections, reconnection, and per-host runtime state
- `runtime/replica-cache` keeps the complete project, workspace, and active-agent directory plus one short focused timeline tail in AsyncStorage. It restores before navigation becomes ready and leaves remote hydration flags false.
- `runtime/replica-cache` keeps the complete project, workspace, and active-agent directory plus one short focused timeline tail in a row store. It restores before navigation becomes ready and leaves remote hydration flags false.
- `runtime/directory-sync` owns directory reconciliation. On reconnect it passes the persisted per-entity cursor through `project.list`, `fetch_workspaces`, and `fetch_agents`; the daemon returns each entity's latest projection when its sequence is newer, plus tombstones.
- `workspace-labels` owns one sequenced catalog replica per connected host, the deterministic cross-host projection that surfaces spanning hosts use (the filter page, the manager), and the per-host resolution a workspace row's chips use. Two hosts may give one name different colors, so a row resolves against its own host's catalog and a merged answer would be wrong there. Catalogs never synchronize between hosts; assignment creates a missing definition only on the target host. On the daemon, catalog and assignment rewrites share a journaled commit boundary. Startup recovery completes that commit before workspace or catalog publication.
- `SessionContext` wraps the daemon client for the active session
@@ -115,12 +115,15 @@ Cross-platform React Native app that connects to one or more daemons.
The replica cache paints stale data immediately while the host connects. Directory cursors are
reconciliation checkpoints; cached entities remain non-authoritative until the daemon answers.
Pending permission requests are not restored from it. AsyncStorage is not encrypted, so the cached
Pending permission requests are not restored from it. The row store is not encrypted, so the cached
timeline tail may contain source code, prompts, and tool output; encrypted-at-rest storage is a
separate product/security decision. Its serialized payload has a 32 MiB byte budget and evicts whole
host snapshots in least-recently-written order; a single oversized host is omitted rather than
partially restored. Browser and Electron builds store it in IndexedDB. Native builds use
AsyncStorage, and Android reserves 64 MiB for that database.
separate product/security decision. Agents, workspaces, and projects have individual rows; the
focused timeline tail and directory checkpoint each have one row per host. Writes serialize only
rows whose in-memory identities changed. Restore validates every row before hydration; one invalid
row clears the cache and starts cold. The 32 MiB byte budget is tracked incrementally from row
payload lengths and evicts whole hosts in least-recently-written order. After restart, that order is
an approximation rebuilt from the row store's `readAll()` order. Browser and Electron builds use
IndexedDB. Native builds use expo-sqlite.
The three directory entity types have independent monotonic sequences and share one daemon
generation. The daemon retains only the latest projection per entity and bounded tombstones, not an
+33 -3
View File
@@ -26,8 +26,9 @@ For forge `acme`, the expected end state is:
3. **App modules** - a forge splits into a pure logic half and a view half so
logic consumers (URL builders, merge-capability, native checks, and the
Node-based e2e harness) never pull the client rendering stack:
- `packages/app/src/git/forges/acme.ts` - logic: `id`, optional `urlGrammar`,
optional `facts` (schema, merge-capability, native-check fallbacks). No
- `packages/app/src/git/forges/acme.ts` - logic: `id`, optional `urlGrammar`
(source links and pasted issue/change-request reference paths), optional
`facts` (schema, merge-capability, native-check fallbacks). No
React/React-Native imports. Register in `CLIENT_FORGE_LOGIC_MODULES` in
`packages/app/src/git/forges/index.ts`.
- `packages/app/src/git/forges/acme.view.tsx` - view: `icon` (SVG component
@@ -57,8 +58,20 @@ schema-mismatched facts render neutrally instead of failing the whole message
parse. This is the version-skew win: an old client can receive facts from a
newer forge and still show the PR/MR in a neutral state.
Check results keep a stable normalized `status` for aggregation and an optional
open `traits: string[]` for composable forge-neutral refinements such as
`manual`, `action_required`, and `warning`. Consumers ignore unknown traits and
fall back to `status`; `rawStatus` preserves provider-native detail. Do not add
provider vocabulary to the normalized status union. Producers and the
presentation layer share the trait constants in
`packages/protocol/src/check-traits.ts` — use those instead of string literals
so classification and emission cannot drift apart.
Shipped GitHub compatibility stays separate:
- The forge compatibility layer first shipped in `v0.2.0-beta.1`. Its initial
six-month cleanup target is `2027-01-17`, after supported client and daemon
floors reach stable `v0.2.0`.
- `status.github` remains accepted for released peers.
- The server keeps the `COMPAT(forgeSpecific)` mirror that copies GitHub facts
into `status.github` for older clients.
@@ -112,7 +125,7 @@ rendering stack:
`acme.ts` exports a `ClientForgeLogicModule`:
- `id`
- optional `urlGrammar`
- optional `urlGrammar` (including `referencePaths` for composer auto-attachment)
- optional `facts` registration (schema, merge-capability, native-check fallbacks)
`acme.view.tsx` exports a `ClientForgeViewModule`:
@@ -181,10 +194,27 @@ are stale, run `npm run build:server`.
real shims tagged with `COMPAT(name)`.
- Gitea-family facts use `forgeSpecific.forge === "gitea"` even when the
top-level brand is Forgejo or Codeberg.
- Gitea's legacy Actions task endpoint cannot filter by commit, may enforce a
page size below the requested limit, and omits rerun-attempt numbers. Walk a
bounded number of pages using `total_count` and filter locally. Preserve
ambiguous same-run tasks: display names are not stable job identities, so
name-based deduplication can hide a real failure.
- A blocked Gitea Actions task is not necessarily manual: only add the
`action_required` trait when the matching run metadata reports
`need_approval`.
- Brand icons are bundled React components, so they cannot come from protocol
manifest data.
- Source URL grammars are app-side because blob/tree path syntax is
forge-specific. If a forge has no grammar, omit the "Open on ..." source link
rather than constructing a wrong URL.
- Pasted issue/change-request URL recognition is also app-side and registry
driven. Put the forge's route infixes in `urlGrammar.referencePaths`; the
neutral extractor matches the pasted host and full repository path against
the current remote before it invokes cwd-routed forge search. Do not add a
central forge switch or guess a self-hosted Gitea-family brand from URL shape.
- GitLab pipeline status constants belong to the GitLab adapter/client module,
not protocol.
- GitLab `manual` jobs need `allow_failure` to distinguish optional gray jobs
(`manual`) from blocking jobs (`manual` plus `action_required`). A failed
allowed-failure job carries the `warning` trait, and `canceling` remains active
until GitLab reports a terminal status.
+1
View File
@@ -436,6 +436,7 @@ This ensures the checkout ref matches the actual code on `main` with the fix inc
## Notes
- `version:all:*` bumps root + syncs workspace versions and `@getpaseo/*` dependency versions
- The npm `version` lifecycle regenerates F-Droid changelog files from `CHANGELOG.md` for stable releases only (`npm run fdroid:changelogs`) and stages them, so the release tag carries them. Betas are a no-op. A stable run **aborts the release** if `CHANGELOG.md` has no entry for the version being cut — commit the changelog entry first. See [docs/android.md](android.md) for why these files are generated per ABI.
- `release:prepare` refreshes workspace `node_modules` links to prevent stale types
- `npm run dev:desktop` and `npm run build:desktop` target the Electron desktop package in `packages/desktop`
- If `release:publish` partially fails, re-run it — npm skips already-published versions
+1 -1
View File
@@ -43,6 +43,6 @@ Terminal frames share the daemon main event loop with all agent traffic. The `ev
## Known remaining contention (follow-up candidates)
- A single large `agent_stream` message (e.g. a 250KB diff payload) measurably delays terminal echo (~100ms-class dips) — cost is split between daemon serialization and app-side parse/render on the shared browser main thread.
- A single large `agent_stream` message (e.g. a 250KB diff payload) measurably delays terminal echo (~100ms-class dips) — cost is split between daemon serialization and app-side parse/render on the shared browser main thread. See [agent-stream-performance.md](agent-stream-performance.md) for that pipeline's own budgets.
- Relay-attached clients pay pure-JS tweetnacl encryption on the daemon main loop (`packages/relay/src/encrypted-channel.ts`). Negotiated binary application frames stay binary ciphertext and avoid base64 encode/decode; text and mixed-version traffic remain base64 WebSocket text frames.
- `sendToClient` re-stringifies session messages per socket; only matters for multi-socket connections.
@@ -0,0 +1,37 @@
Paseo is a client for AI coding agents that run on your own machine. Your dev environment, in your pocket.
Paseo runs a local server called the daemon on your computer. It manages your coding agents and streams their output in real time. This app connects to that daemon, so your code never leaves your machine and there is no cloud service in between.
<b>Supported agents</b>
<ul>
<li>Claude Code</li>
<li>Codex</li>
<li>GitHub Copilot</li>
<li>OpenCode</li>
<li>Pi</li>
</ul>
You bring your own provider credentials and use your existing subscriptions. Paseo adds no markup and no inference costs of its own.
<b>What you can do</b>
<ul>
<li>Start agents, watch them work, and answer their questions from your phone</li>
<li>Run several agents in parallel across projects and git worktrees</li>
<li>Review diffs, browse commit history, and edit files</li>
<li>Work with pull requests from GitHub, GitLab, Gitea, Forgejo, and Codeberg</li>
<li>Open a terminal in any workspace</li>
<li>Dictate prompts or talk through a problem in voice mode</li>
<li>Schedule agents to run on a recurring basis</li>
</ul>
<b>Privacy</b>
No telemetry, no tracking, no account required. The app talks only to daemons you point it at. Remote access goes through an end-to-end encrypted relay that cannot read your traffic, or over your own network or VPN if you prefer.
<b>You need a daemon to connect to</b>
This app is not useful on its own. Install the Paseo daemon on the computer where your code and agent CLIs live, then pair this app with it from Settings. The desktop app bundles the daemon, or you can run it from npm, Docker, or Nix.
Setup instructions: https://paseo.sh
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1 @@
../../../../../../packages/website/public/phone-1.png
@@ -0,0 +1 @@
../../../../../../packages/website/public/phone-2.png
@@ -0,0 +1 @@
../../../../../../packages/website/public/phone-3.png
@@ -0,0 +1 @@
Monitor and control your local AI coding agents from anywhere
@@ -0,0 +1 @@
Paseo
@@ -0,0 +1,37 @@
Paseo は、自分のマシン上で動作する AI コーディングエージェントのクライアントです。あなたの開発環境を、ポケットの中に。
Paseo はデーモンと呼ばれるローカルサーバーをあなたのコンピューター上で実行します。デーモンがコーディングエージェントを管理し、その出力をリアルタイムに配信します。このアプリはそのデーモンに接続するため、コードがマシンの外に出ることはなく、間にクラウドサービスも入りません。
<b>対応エージェント</b>
<ul>
<li>Claude Code</li>
<li>Codex</li>
<li>GitHub Copilot</li>
<li>OpenCode</li>
<li>Pi</li>
</ul>
プロバイダーの認証情報はご自身のものを使用し、既存のサブスクリプションをそのまま活用できます。Paseo が独自の手数料や推論コストを追加することはありません。
<b>できること</b>
<ul>
<li>スマートフォンからエージェントを起動し、作業を確認し、質問に回答する</li>
<li>プロジェクトや git worktree をまたいで複数のエージェントを並列実行する</li>
<li>差分のレビュー、コミット履歴の閲覧、ファイルの編集</li>
<li>GitHub、GitLab、Gitea、Forgejo、Codeberg のプルリクエストを扱う</li>
<li>任意のワークスペースでターミナルを開く</li>
<li>音声でプロンプトを入力したり、音声モードで問題を相談する</li>
<li>エージェントを定期実行するようスケジュールする</li>
</ul>
<b>プライバシー</b>
テレメトリー、トラッキング、アカウント登録は一切ありません。アプリは、あなたが指定したデーモンにのみ通信します。リモートアクセスは通信内容を読み取れないエンドツーエンド暗号化リレーを経由するか、ご自身のネットワークや VPN を利用できます。
<b>接続先のデーモンが必要です</b>
このアプリは単体では機能しません。コードとエージェント CLI があるコンピューターに Paseo デーモンをインストールし、設定画面からこのアプリをペアリングしてください。デスクトップアプリにはデーモンが同梱されています。npm、Docker、Nix から実行することもできます。
セットアップ手順: https://paseo.sh
@@ -0,0 +1 @@
ローカルのAIコーディングエージェントをどこからでも操作
@@ -0,0 +1,37 @@
Paseo 是运行在你自己机器上的 AI 编程 agents 的客户端。把你的开发环境装进口袋。
Paseo 会在你的电脑上运行一个名为 daemon 的本地服务,由它管理编程 agents 并实时推送输出。本应用连接到该 daemon,因此你的代码不会离开你的机器,中间也没有任何云服务。
<b>支持的 agents</b>
<ul>
<li>Claude Code</li>
<li>Codex</li>
<li>GitHub Copilot</li>
<li>OpenCode</li>
<li>Pi</li>
</ul>
你使用自己的提供商凭据和现有订阅。Paseo 不加价,也不产生自己的推理费用。
<b>你可以做什么</b>
<ul>
<li>在手机上启动 agents、查看进展并回答它们的提问</li>
<li>跨项目和 git worktree 并行运行多个 agents</li>
<li>审查差异、浏览提交历史、编辑文件</li>
<li>处理来自 GitHub、GitLab、Gitea、Forgejo 和 Codeberg 的合并请求</li>
<li>在任意工作区打开终端</li>
<li>用语音输入提示,或在语音模式下讨论问题</li>
<li>将 agents 设置为定期运行</li>
</ul>
<b>隐私</b>
没有遥测、没有追踪、无需账号。应用只与你指定的 daemon 通信。远程访问通过无法读取你流量的端到端加密中继,或者你也可以使用自己的网络或 VPN。
<b>你需要一个可连接的 daemon</b>
本应用无法独立使用。请在存放代码和 agent CLI 的电脑上安装 Paseo daemon,然后在设置中将本应用与其配对。桌面应用已内置 daemon,你也可以通过 npm、Docker 或 Nix 运行。
安装说明:https://paseo.sh
@@ -0,0 +1 @@
随时随地监控和控制本地的 AI 编程 agents
+1 -1
View File
@@ -1 +1 @@
sha256-mF8N1sBkSt2/ZgtB511lqv1knlQ0lmicZxsoucbWZfE=
sha256-13Q44pEU+V2M/wnitVAlBarYxAqWkGkXrE+w5qUCf7o=
+43
View File
@@ -15070,6 +15070,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/await-lock": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/await-lock/-/await-lock-2.2.2.tgz",
"integrity": "sha512-aDczADvlvTGajTDjcjpJMqRkOF6Qdz3YbPZm/PyW6tKPkx2hlYBzxMhEywM/tU72HrVZjgl5VCdRuMlA7pZ8Gw==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.13.6",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.6.tgz",
@@ -21336,6 +21342,20 @@
"node": ">=8.0"
}
},
"node_modules/expo-sqlite": {
"version": "16.0.10",
"resolved": "https://registry.npmjs.org/expo-sqlite/-/expo-sqlite-16.0.10.tgz",
"integrity": "sha512-tUOKxE9TpfneRG3eOfbNfhN9236SJ7IiUnP8gCqU7umd9DtgDGB/5PhYVVfl+U7KskgolgNoB9v9OZ9iwXN8Eg==",
"license": "MIT",
"dependencies": {
"await-lock": "^2.2.2"
},
"peerDependencies": {
"expo": "*",
"react": "*",
"react-native": "*"
}
},
"node_modules/expo-system-ui": {
"version": "6.0.9",
"resolved": "https://registry.npmjs.org/expo-system-ui/-/expo-system-ui-6.0.9.tgz",
@@ -21781,6 +21801,16 @@
"license": "MIT",
"optional": true
},
"node_modules/fake-indexeddb": {
"version": "6.2.5",
"resolved": "https://registry.npmjs.org/fake-indexeddb/-/fake-indexeddb-6.2.5.tgz",
"integrity": "sha512-CGnyrvbhPlWYMngksqrSSUT1BAVP49dZocrHuK0SvtR0D5TMs5wP0o3j7jexDJW01KSadjBp1M/71o/KR3nD1w==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=18"
}
},
"node_modules/fast-copy": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.0.2.tgz",
@@ -36200,6 +36230,7 @@
"expo-router": "~6.0.13",
"expo-sharing": "^14.0.8",
"expo-splash-screen": "~31.0.10",
"expo-sqlite": "~16.0.10",
"expo-system-ui": "~6.0.7",
"fast-deep-equal": "^3.1.3",
"htmlparser2": "^12.0.0",
@@ -36241,6 +36272,7 @@
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"@types/markdown-it": "^14.1.2",
"@types/node": "~22.19.0",
"@types/qrcode": "^1.5.6",
"@types/react": "~19.2.0",
"@types/turndown": "^5.0.6",
@@ -36254,6 +36286,7 @@
"eslint": "^9.25.0",
"eslint-config-expo": "~10.0.0",
"expo-gradle-jvmargs": "^1.1.2",
"fake-indexeddb": "^6.2.5",
"jsdom": "^20.0.3",
"material-icon-theme": "^5.32.0",
"playwright": "^1.56.1",
@@ -36791,6 +36824,16 @@
"node": ">=18"
}
},
"packages/app/node_modules/@types/node": {
"version": "22.19.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.21.tgz",
"integrity": "sha512-VMeFBSCKQKmm2swI2kW51SFusDqekC6q9trBCvJ/JliDchFSuoYYKN7yVNjPthP1HKZcx3U1gI/wTcEBjEFKTA==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
}
},
"packages/app/node_modules/@xterm/addon-clipboard": {
"version": "0.3.0-beta.213",
"resolved": "https://registry.npmjs.org/@xterm/addon-clipboard/-/addon-clipboard-0.3.0-beta.213.tgz",
+3 -1
View File
@@ -84,6 +84,8 @@
"android:release": "npm run android:production --workspace=@getpaseo/app",
"android:clear": "npm run android:clear --workspace=@getpaseo/app",
"android:clean": "npm run android:clean --workspace=@getpaseo/app",
"fdroid:changelogs": "node scripts/sync-fdroid-changelogs.mjs",
"fdroid:changelogs:check": "node scripts/sync-fdroid-changelogs.mjs --check",
"ios": "npm run ios --workspace=@getpaseo/app",
"web": "npm run web --workspace=@getpaseo/app",
"dev:desktop": "cross-env PASEO_LISTEN=127.0.0.1:6768 npm run dev --workspace=@getpaseo/desktop",
@@ -91,7 +93,7 @@
"build:desktop": "npm run build:app-deps:clean && cd packages/app && cross-env PASEO_WEB_PLATFORM=electron npx expo export --platform web && cd ../.. && npm run build --workspace=@getpaseo/desktop --",
"db:query": "npm run db:query --workspace=@getpaseo/server --",
"cli": "./scripts/dev-home.sh npx tsx packages/cli/src/index.js",
"version": "npm run version:sync-internal && npm run release:prepare && git add -A",
"version": "npm run version:sync-internal && npm run fdroid:changelogs && npm run release:prepare && git add -A",
"version:sync-internal": "node scripts/sync-workspace-versions.mjs",
"release:prepare": "npm install --workspaces --include-workspace-root",
"version:all:patch": "node scripts/set-release-version.mjs --mode patch",
@@ -3,10 +3,13 @@ import { expect, test, type Page } from "../support/fixtures";
import { expectAgentIdle, expectAgentReadyToInterrupt } from "../support/helpers/agent-stream";
import {
cancelAgent,
fillComposerDraft,
expectComposerDraft,
expectComposerVisible,
submitMessage,
} from "../support/helpers/composer";
import { expectNearBottom, scrollChatAwayFromBottom } from "../support/helpers/agent-bottom-anchor";
import { holdRewindCompletion } from "../support/helpers/agent-timeline-gate";
import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent";
async function completeSubmittedTurn(
@@ -42,9 +45,13 @@ async function expectTurnCompletesNormally(
}
test.describe("Agent message rewind", () => {
test("rewinds a submitted prompt and restores it to the composer", async ({ page }) => {
test("rewinds a submitted prompt without replaying history and preserves a human draft", async ({
page,
}) => {
test.setTimeout(90_000);
const prompt = "Restore this submitted prompt after rewind.";
const retainedPrompt = "Keep this completed turn after rewind.";
const rewoundPrompt = "Remove this completed turn after rewind.";
const preservedDraft = "Keep this human draft after rewind.";
const agent = await seedMockAgentWorkspace({
repoPrefix: "message-rewind-roundtrip-",
title: "Message rewind roundtrip",
@@ -52,14 +59,30 @@ test.describe("Agent message rewind", () => {
});
try {
const rewindCompletion = await holdRewindCompletion(page, agent.agentId);
await openAgentRoute(page, agent);
await expectComposerVisible(page);
const userMessage = await completeSubmittedTurn(page, agent, prompt);
await completeSubmittedTurn(page, agent, retainedPrompt);
const userMessage = await completeSubmittedTurn(page, agent, rewoundPrompt);
await scrollChatAwayFromBottom(page, {
deltaY: -900,
minDistanceFromBottom: 300,
});
await fillComposerDraft(page, preservedDraft);
rewindCompletion.clearTimelineStreamCount();
await rewindConversation(page, userMessage, prompt);
const rewind = rewindConversation(page, userMessage, rewoundPrompt);
await rewindCompletion.waitForDelayedResponse();
await expect(page.getByTestId("rewind-menu-conversation")).toBeDisabled();
expect(rewindCompletion.timelineStreamCount()).toBe(0);
rewindCompletion.release();
await rewind;
await expect(page.getByText("(end of synthetic stream)", { exact: true })).toHaveCount(0);
await expectComposerDraft(page, prompt);
await expect(page.getByTestId("user-message").filter({ hasText: rewoundPrompt })).toHaveCount(
0,
);
await expectComposerDraft(page, preservedDraft);
await expectNearBottom(page);
} finally {
await agent.cleanup();
}
@@ -0,0 +1,151 @@
import { test, expect } from "../support/fixtures";
import { awaitAssistantMessage } from "../support/helpers/agent-stream";
import { startRunningMockAgent } from "../support/helpers/composer";
import {
sampleStreamFrames,
summarizeStreamSmoothness,
} from "../support/helpers/stream-smoothness";
/**
* Streaming smoothness, measured on the path the user actually sees.
*
* The mock provider's "bursty-stream" model emits tokens in uneven runs separated
* by idle gaps, which is how real models arrive. Sampling and the statistics live
* in ../support/helpers/stream-smoothness.ts, which also documents what the two
* numbers mean.
*
* Budgets are deliberately loose. This spec exists to catch a regression in the
* shape of the stream, not to pin exact numbers on shared CI hardware. For
* reference, on a local dev daemon the paced reveal measures a CV around 1.3–1.5
* against 2.7 when painting deltas as they arrive.
*/
const SAMPLE_WINDOW_MS = 6_000;
const CHARS_PER_FRAME_CV_BUDGET = 2;
const UPDATE_GAP_P95_BUDGET_MS = 250;
const REACT_COMMIT_P95_BUDGET_MS = 12;
const REACT_COMMIT_COUNT_BUDGET = 600;
const RUN_AGENT_STREAM_PERF = process.env.PASEO_AGENT_STREAM_PERF_E2E === "1";
const agentStreamPerfDescribe = RUN_AGENT_STREAM_PERF ? test.describe : test.describe.skip;
interface ReactCommit {
id: string;
phase: "mount" | "update" | "nested-update";
actualDuration: number;
baseDuration: number;
startTime: number;
commitTime: number;
}
agentStreamPerfDescribe("Agent stream smoothness", () => {
test("reveals bursty model output at a steady rate", async ({ page }, testInfo) => {
test.setTimeout(120_000);
await page.addInitScript(() => {
Reflect.set(globalThis, "__PASEO_RENDER_PROFILE_ENABLED__", true);
});
const agent = await startRunningMockAgent(page, {
prefix: "stream-smoothness-",
model: "bursty-stream",
prompt: "Stream bursty output for smoothness measurement.",
});
try {
await awaitAssistantMessage(page);
await page.evaluate(() => {
const reset = Reflect.get(globalThis, "__PASEO_RESET_RENDER_PROFILE__");
if (typeof reset !== "function") {
throw new Error("Render profiler did not initialize");
}
reset();
});
const samples = await sampleStreamFrames(page, { sampleWindowMs: SAMPLE_WINDOW_MS });
const report = summarizeStreamSmoothness(samples, SAMPLE_WINDOW_MS);
const reactCommits = await readStreamReactCommits(page);
const reactReport = summarizeReactCommits(reactCommits);
await testInfo.attach("agent-stream-smoothness-report", {
body: JSON.stringify(report, null, 2),
contentType: "application/json",
});
await testInfo.attach("agent-stream-react-profile", {
body: JSON.stringify(reactReport, null, 2),
contentType: "application/json",
});
console.log(`[perf] Agent stream React: ${JSON.stringify(reactReport)}`);
console.log(`[perf] Agent stream smoothness: ${JSON.stringify(report)}`);
expect(
report.growthFrames,
"the stream must actually produce text during the sample window",
).toBeGreaterThan(20);
expect(
report.charsPerFrameCv,
`characters painted per frame should be steady (cv < ${CHARS_PER_FRAME_CV_BUDGET})`,
).toBeLessThan(CHARS_PER_FRAME_CV_BUDGET);
expect(
report.updateGapP95Ms,
`the text should not stall (p95 gap < ${UPDATE_GAP_P95_BUDGET_MS}ms)`,
).toBeLessThan(UPDATE_GAP_P95_BUDGET_MS);
expect(reactReport.count, "streaming should produce measured React commits").toBeGreaterThan(
20,
);
expect(
reactReport.count,
`the reveal should cap commits below ${REACT_COMMIT_COUNT_BUDGET} per sample window`,
).toBeLessThan(REACT_COMMIT_COUNT_BUDGET);
expect(
reactReport.actualDurationP95Ms,
`React commits should stay below ${REACT_COMMIT_P95_BUDGET_MS}ms at p95`,
).toBeLessThan(REACT_COMMIT_P95_BUDGET_MS);
} finally {
await agent.cleanup();
}
});
});
async function readStreamReactCommits(
page: Parameters<typeof sampleStreamFrames>[0],
): Promise<ReactCommit[]> {
return await page.evaluate(() => {
const samples = Reflect.get(globalThis, "__PASEO_RENDER_PROFILE__");
if (!Array.isArray(samples)) {
return [];
}
return samples.filter(
(sample): sample is ReactCommit =>
typeof sample === "object" &&
sample !== null &&
typeof Reflect.get(sample, "id") === "string" &&
Reflect.get(sample, "id").startsWith("AgentStreamSection:"),
);
});
}
function summarizeReactCommits(commits: readonly ReactCommit[]) {
const durations = commits
.map((commit) => commit.actualDuration)
.sort((left, right) => left - right);
const total = durations.reduce((sum, duration) => sum + duration, 0);
return {
count: commits.length,
actualDurationTotalMs: round2(total),
actualDurationMeanMs: round2(commits.length > 0 ? total / commits.length : 0),
actualDurationP50Ms: percentile(durations, 50),
actualDurationP95Ms: percentile(durations, 95),
actualDurationMaxMs: durations.at(-1) ?? 0,
};
}
function round2(value: number): number {
return Math.round(value * 100) / 100;
}
function percentile(sorted: readonly number[], percentileValue: number): number {
if (sorted.length === 0) {
return 0;
}
return sorted[
Math.min(sorted.length - 1, Math.floor((sorted.length - 1) * (percentileValue / 100)))
];
}
+3 -3
View File
@@ -102,11 +102,11 @@ test.describe("PR pane", () => {
await expectPrPaneTitle(page, "Work in progress");
});
test("renders check pills with correct passed/failed/pending counts", async ({ page }) => {
test("renders check pills with correct success/failure/pending counts", async ({ page }) => {
await gotoWorkspace(page, workspaceByTitle.get("PR with mixed checks")!);
await openPrPane(page);
await expectPrPaneCheckSummary(page, { passed: 2, failed: 1, pending: 1 });
await expectPrPaneCheckSummary(page, { success: 2, failure: 1, pending: 1 });
});
test("renders activity rows with correct count", async ({ page }) => {
@@ -120,7 +120,7 @@ test.describe("PR pane", () => {
await gotoWorkspace(page, workspaceByTitle.get("PR with no checks")!);
await openPrPane(page);
await expectPrPaneCheckSummary(page, { passed: 0, failed: 0, pending: 0 });
await expectPrPaneCheckSummary(page, { success: 0, failure: 0, pending: 0 });
await expectPrPaneTitle(page, "PR with no checks");
});
});
@@ -0,0 +1,50 @@
import { mkdir, writeFile } from "node:fs/promises";
import path from "node:path";
import { expect, test } from "@playwright/test";
import {
beginReplicaCacheObservation,
finishReplicaCacheObservation,
installReplicaCacheMeasurement,
measureReplicaCacheRestore,
type ReplicaCacheMeasurementReport,
} from "../support/helpers/replica-cache-measurement";
const RUN_MEASUREMENT = process.env.PASEO_REPLICA_CACHE_MEASUREMENT === "1";
const TARGET_URL = process.env.PASEO_REPLICA_CACHE_MEASUREMENT_URL;
const REPORT_PATH = process.env.PASEO_REPLICA_CACHE_MEASUREMENT_REPORT;
const OBSERVATION_MS = Number(process.env.PASEO_REPLICA_CACHE_MEASUREMENT_MS ?? 60_000);
const HYDRATED_SELECTOR =
process.env.PASEO_REPLICA_CACHE_HYDRATED_SELECTOR ??
'[data-testid="agent-chat-scroll"], [data-testid^="sidebar-workspace-row-"]';
const measurementDescribe = RUN_MEASUREMENT ? test.describe : test.describe.skip;
measurementDescribe("Replica cache live measurement", () => {
test("observes persistence and cached restore without mutating the daemon", async ({
page,
}, testInfo) => {
test.setTimeout(OBSERVATION_MS + 90_000);
expect(TARGET_URL, "PASEO_REPLICA_CACHE_MEASUREMENT_URL must be a full app URL").toBeTruthy();
expect(REPORT_PATH, "PASEO_REPLICA_CACHE_MEASUREMENT_REPORT must be set").toBeTruthy();
await installReplicaCacheMeasurement(page);
await page.goto(TARGET_URL!, { waitUntil: "domcontentloaded" });
await page.waitForLoadState("networkidle").catch(() => undefined);
const observation = await beginReplicaCacheObservation(page);
await page.waitForTimeout(OBSERVATION_MS);
const observed = await finishReplicaCacheObservation(page, observation, TARGET_URL!);
const restoreMs = await measureReplicaCacheRestore(page, TARGET_URL!, HYDRATED_SELECTOR);
const report: ReplicaCacheMeasurementReport = { ...observed, restoreMs };
await mkdir(path.dirname(REPORT_PATH!), { recursive: true });
await writeFile(REPORT_PATH!, `${JSON.stringify(report, null, 2)}\n`);
await testInfo.attach("replica-cache-measurement", {
body: JSON.stringify(report, null, 2),
contentType: "application/json",
});
console.log(`[measurement] Replica cache: ${JSON.stringify(report)}`);
expect(report.observationMs).toBeGreaterThanOrEqual(OBSERVATION_MS);
});
});
@@ -14,7 +14,7 @@ import {
const RUN_REPLICA_CACHE_PERF = process.env.PASEO_REPLICA_CACHE_PERF_E2E === "1";
const MAX_STREAM_WRITES = 12;
const MAX_SERIALIZED_CHARS = 190_000;
const MAX_SERIALIZED_CHARS = 45_000;
const test = base.extend<{ replicaCacheAgent: MockAgentWorkspace }>({
replicaCacheAgent: async ({ page: _page }, provide) => {
+6
View File
@@ -196,6 +196,12 @@ async function loadHarnessEnvironment(repoRoot: string): Promise<void> {
}
export default async function globalSetup() {
if (process.env.PASEO_REPLICA_CACHE_MEASUREMENT === "1") {
if (!process.env.PASEO_REPLICA_CACHE_MEASUREMENT_URL) {
throw new Error("PASEO_REPLICA_CACHE_MEASUREMENT_URL must be set for live measurement");
}
return;
}
const repoRoot = path.resolve(__dirname, "../../../..");
await loadHarnessEnvironment(repoRoot);
@@ -27,6 +27,13 @@ export interface DaemonHydrationGate {
release(): void;
}
export interface RewindCompletionGate {
clearTimelineStreamCount(): void;
release(): void;
timelineStreamCount(): number;
waitForDelayedResponse(): Promise<void>;
}
export interface PromptJumpRequestTracker {
requests(): Array<{ cursorSeq: number | null; limit: number | null; mergeWindow: boolean }>;
}
@@ -255,6 +262,62 @@ export async function holdDaemonHydration(page: Page): Promise<DaemonHydrationGa
};
}
export async function holdRewindCompletion(
page: Page,
agentId: string,
): Promise<RewindCompletionGate> {
let released = false;
let timelineStreamCount = 0;
const delayedForwards: Array<() => void> = [];
let resolveDelayedResponse: (() => void) | null = null;
const delayedResponse = new Promise<void>((resolve) => {
resolveDelayedResponse = resolve;
});
await page.routeWebSocket(daemonWsRoutePattern(), (ws) => {
const server = ws.connectToServer();
ws.onMessage((message) => server.send(message));
server.onMessage((message) => {
const sessionMessage = getSessionMessage(message);
const payload = sessionMessage ? getPayload(sessionMessage) : null;
const streamEvent = payload?.event;
if (
sessionMessage?.type === "agent_stream" &&
payload?.agentId === agentId &&
streamEvent &&
typeof streamEvent === "object" &&
(streamEvent as { type?: unknown }).type === "timeline"
) {
timelineStreamCount += 1;
}
if (
!released &&
sessionMessage?.type === "agent.rewind.response" &&
payload?.agentId === agentId
) {
delayedForwards.push(() => ws.send(message));
resolveDelayedResponse?.();
return;
}
ws.send(message);
});
});
return {
clearTimelineStreamCount() {
timelineStreamCount = 0;
},
release() {
released = true;
for (const forward of delayedForwards.splice(0)) {
forward();
}
},
timelineStreamCount: () => timelineStreamCount,
waitForDelayedResponse: () => delayedResponse,
};
}
export async function delayCreatedAgentInitialTailResponse(
page: Page,
): Promise<CreatedAgentTimelineGate> {
+4 -3
View File
@@ -1,4 +1,5 @@
import { expect, type Page } from "@playwright/test";
import type { CheckPresentationCounts } from "@/git/check-presentation";
import { getStateLabel } from "@/git/pull-request-panel/data";
import { openPullRequestPanel } from "./workspace-tabs";
@@ -29,10 +30,10 @@ async function assertCheckPill(page: Page, testId: string, count: number): Promi
export async function expectPrPaneCheckSummary(
page: Page,
counts: { passed: number; failed: number; pending: number },
counts: Pick<CheckPresentationCounts, "success" | "failure" | "pending">,
): Promise<void> {
await assertCheckPill(page, "pr-pane-check-passed", counts.passed);
await assertCheckPill(page, "pr-pane-check-failed", counts.failed);
await assertCheckPill(page, "pr-pane-check-success", counts.success);
await assertCheckPill(page, "pr-pane-check-failure", counts.failure);
await assertCheckPill(page, "pr-pane-check-pending", counts.pending);
}
@@ -0,0 +1,312 @@
import type { CDPSession, Page } from "@playwright/test";
const REPLICA_CACHE_DATABASE = "paseo-replica-row-store";
const REPLICA_CACHE_ROWS_STORE = "rows";
const PERSIST_FRAME_NAMES = [
"captureSessions",
"captureHost",
"queueReplicaChanges",
"apply",
"safeParse",
"stringify",
"setItem",
"measuredPut",
] as const;
const PERSIST_STACK_ANCHORS = new Set([
"captureSessions",
"captureHost",
"queueReplicaChanges",
"persist",
"flushPending",
"measuredPut",
]);
export interface ReplicaCacheMeasurementReport {
targetUrl: string;
observationMs: number;
persistCpuMs: number;
persistCpuFrames: Record<string, number>;
flushes: number;
bytesWritten: {
total: number;
perFlush: number[];
};
redundantWrites: number;
storageDurationMs: number;
longTasks: {
count: number;
totalDurationMs: number;
maximumDurationMs: number;
durationsMs: number[];
};
restoreMs: number | null;
}
interface BrowserMeasurementState {
flushes: Array<{ bytes: number; durationMs: number }>;
longTasks: number[];
redundantWrites: number;
}
interface ProfileNode {
id: number;
callFrame: { functionName: string; url: string };
parent?: number;
}
interface SamplingProfile {
nodes: ProfileNode[];
samples?: number[];
timeDeltas?: number[];
}
declare global {
interface Window {
__replicaCacheMeasurement?: BrowserMeasurementState;
__replicaCacheRestoreReadStartedAt?: number;
}
}
export async function installReplicaCacheMeasurement(page: Page): Promise<void> {
await page.addInitScript(
({ databaseName, storeName }) => {
const encoder = new TextEncoder();
const transactionWrites = new WeakMap<
IDBTransaction,
Array<
| { type: "put"; key: string; value: string; bytes: number; startedAt: number }
| { type: "delete"; key: string; bytes: 0; startedAt: number }
>
>();
const lastValues = new Map<string, string>();
const resolveStorageKey = (
store: IDBObjectStore,
value: unknown,
explicitKey: IDBValidKey | undefined,
): unknown => {
if (explicitKey !== undefined) return explicitKey;
if (value === null || typeof value !== "object") return null;
if (Array.isArray(store.keyPath)) {
return store.keyPath.map((part) => Reflect.get(value, part));
}
return typeof store.keyPath === "string" ? Reflect.get(value, store.keyPath) : null;
};
window.__replicaCacheMeasurement = {
flushes: [],
longTasks: [],
redundantWrites: 0,
};
const observeTransaction = (transaction: IDBTransaction) => {
let writes = transactionWrites.get(transaction);
if (writes) return writes;
writes = [];
transactionWrites.set(transaction, writes);
transaction.addEventListener("complete", () => {
const state = window.__replicaCacheMeasurement;
if (!state || writes!.length === 0) return;
let bytes = 0;
let startedAt = Number.POSITIVE_INFINITY;
for (const write of writes!) {
bytes += write.bytes;
startedAt = Math.min(startedAt, write.startedAt);
if (write.type === "put") {
if (lastValues.get(write.key) === write.value) state.redundantWrites += 1;
lastValues.set(write.key, write.value);
} else {
lastValues.delete(write.key);
}
}
state.flushes.push({ bytes, durationMs: performance.now() - startedAt });
});
return writes;
};
const originalPut = IDBObjectStore.prototype.put;
IDBObjectStore.prototype.put = function measuredPut(value: unknown, key?: IDBValidKey) {
const request =
key === undefined ? originalPut.call(this, value) : originalPut.call(this, value, key);
if (this.transaction.db.name !== databaseName || this.name !== storeName) return request;
const rowPayload =
value && typeof value === "object" ? Reflect.get(value, "payload") : undefined;
let serialized = JSON.stringify(value);
if (typeof value === "string") serialized = value;
if (typeof rowPayload === "string") serialized = rowPayload;
const storageKey = JSON.stringify(resolveStorageKey(this, value, key));
observeTransaction(this.transaction).push({
type: "put",
key: `${this.name}:${storageKey}`,
value: serialized,
bytes: encoder.encode(serialized).byteLength,
startedAt: performance.now(),
});
return request;
};
const originalDelete = IDBObjectStore.prototype.delete;
IDBObjectStore.prototype.delete = function measuredDelete(query: IDBValidKey | IDBKeyRange) {
const request = originalDelete.call(this, query);
if (this.transaction.db.name !== databaseName || this.name !== storeName) return request;
observeTransaction(this.transaction).push({
type: "delete",
key: `${this.name}:${JSON.stringify(query)}`,
bytes: 0,
startedAt: performance.now(),
});
return request;
};
const markRestoreRead = (store: IDBObjectStore) => {
if (
store.transaction.db.name === databaseName &&
store.name === storeName &&
store.transaction.mode === "readonly" &&
window.__replicaCacheRestoreReadStartedAt === undefined
) {
window.__replicaCacheRestoreReadStartedAt = performance.now();
}
};
const originalGet = IDBObjectStore.prototype.get;
IDBObjectStore.prototype.get = function measuredGet(query: IDBValidKey | IDBKeyRange) {
markRestoreRead(this);
return originalGet.call(this, query);
};
const originalGetAll = IDBObjectStore.prototype.getAll;
IDBObjectStore.prototype.getAll = function measuredGetAll(
query?: IDBValidKey | IDBKeyRange | null,
count?: number,
) {
markRestoreRead(this);
return originalGetAll.call(this, query, count);
};
const originalOpenCursor = IDBObjectStore.prototype.openCursor;
IDBObjectStore.prototype.openCursor = function measuredOpenCursor(
query?: IDBValidKey | IDBKeyRange | null,
direction?: IDBCursorDirection,
) {
markRestoreRead(this);
return originalOpenCursor.call(this, query, direction);
};
if (typeof PerformanceObserver !== "undefined") {
const observer = new PerformanceObserver((entries) => {
const state = window.__replicaCacheMeasurement;
if (!state) return;
for (const entry of entries.getEntries()) state.longTasks.push(entry.duration);
});
try {
observer.observe({ type: "longtask", buffered: true });
} catch {
// Chromium exposes Long Tasks; leave an empty list on runtimes that do not.
}
}
},
{ databaseName: REPLICA_CACHE_DATABASE, storeName: REPLICA_CACHE_ROWS_STORE },
);
}
export async function beginReplicaCacheObservation(
page: Page,
): Promise<{ cdp: CDPSession; startedAt: number }> {
await page.evaluate(() => {
const state = window.__replicaCacheMeasurement;
if (!state) throw new Error("Replica cache measurement is not installed");
state.flushes = [];
state.longTasks = [];
state.redundantWrites = 0;
});
const cdp = await page.context().newCDPSession(page);
await cdp.send("Profiler.enable");
await cdp.send("Profiler.setSamplingInterval", { interval: 100 });
await cdp.send("Profiler.start");
return { cdp, startedAt: Date.now() };
}
export async function finishReplicaCacheObservation(
page: Page,
observation: { cdp: CDPSession; startedAt: number },
targetUrl: string,
): Promise<Omit<ReplicaCacheMeasurementReport, "restoreMs">> {
const result = (await observation.cdp.send("Profiler.stop")) as { profile: SamplingProfile };
await observation.cdp.detach();
const browser = await page.evaluate(() => {
const state = window.__replicaCacheMeasurement;
if (!state) throw new Error("Replica cache measurement is not installed");
return state;
});
const cpu = summarizePersistCpu(result.profile);
const bytesPerFlush = browser.flushes.map((flush) => flush.bytes);
const longTaskDurations = browser.longTasks;
return {
targetUrl,
observationMs: Date.now() - observation.startedAt,
persistCpuMs: cpu.totalMs,
persistCpuFrames: cpu.byFrame,
flushes: browser.flushes.length,
bytesWritten: {
total: bytesPerFlush.reduce((sum, bytes) => sum + bytes, 0),
perFlush: bytesPerFlush,
},
redundantWrites: browser.redundantWrites,
storageDurationMs: browser.flushes.reduce((sum, flush) => sum + flush.durationMs, 0),
longTasks: {
count: longTaskDurations.length,
totalDurationMs: longTaskDurations.reduce((sum, duration) => sum + duration, 0),
maximumDurationMs: Math.max(0, ...longTaskDurations),
durationsMs: longTaskDurations,
},
};
}
export async function measureReplicaCacheRestore(
page: Page,
targetUrl: string,
hydratedSelector: string,
): Promise<number | null> {
await page.routeWebSocket(/\/ws(?:\?|$)/, async (socket) => {
await socket.close({ code: 1000, reason: "Hold reconnect until cached replica paints" });
});
await page.goto(targetUrl, { waitUntil: "domcontentloaded" });
const restoredAt = await page.waitForFunction(
(selector) => {
const startedAt = window.__replicaCacheRestoreReadStartedAt;
if (startedAt === undefined) return null;
const element = document.querySelector(selector);
if (!element || !(element instanceof HTMLElement) || element.offsetParent === null)
return null;
return performance.now();
},
hydratedSelector,
{ timeout: 30_000 },
);
const restoredAtMs = await restoredAt.jsonValue();
const startedAtMs = await page.evaluate(() => window.__replicaCacheRestoreReadStartedAt ?? null);
return typeof restoredAtMs === "number" && startedAtMs !== null
? restoredAtMs - startedAtMs
: null;
}
function summarizePersistCpu(profile: SamplingProfile): {
totalMs: number;
byFrame: Record<string, number>;
} {
const nodes = new Map(profile.nodes.map((node) => [node.id, node]));
const byFrame: Record<string, number> = {};
let totalMicroseconds = 0;
for (const [index, sampleId] of (profile.samples ?? []).entries()) {
const delta = profile.timeDeltas?.[index] ?? 0;
const stackFunctions = new Set<string>();
let node = nodes.get(sampleId);
while (node) {
stackFunctions.add(node.callFrame.functionName);
node = node.parent === undefined ? undefined : nodes.get(node.parent);
}
if (![...stackFunctions].some((name) => PERSIST_STACK_ANCHORS.has(name))) continue;
const matched = PERSIST_FRAME_NAMES.filter((name) => stackFunctions.has(name));
if (matched.length === 0) continue;
totalMicroseconds += delta;
for (const pattern of matched) byFrame[pattern] = (byFrame[pattern] ?? 0) + delta / 1_000;
}
return { totalMs: totalMicroseconds / 1_000, byFrame };
}
@@ -1,26 +1,49 @@
import type { Page } from "@playwright/test";
const DATABASE_NAME = "paseo-replica-cache";
const STORE_NAME = "key-value";
const STORAGE_KEY = "@paseo:replica-cache";
const DATABASE_NAME = "paseo-replica-row-store";
const STORE_NAME = "rows";
const SINGLETON_ID = "singleton";
type ReplicaRowKind = "agent" | "workspace" | "project" | "timeline" | "checkpoint";
interface ReplicaRowRecord {
serverId: string;
kind: ReplicaRowKind;
id: string;
payload: string;
}
interface ReplicaCacheHostRecord {
serverId: string;
agents: Array<Record<string, unknown>>;
workspaces: Array<Record<string, unknown>>;
projects: Array<Record<string, unknown>>;
timeline?: {
agentId?: string;
items?: Array<Record<string, unknown>>;
range?: {
endSeq?: number;
epoch?: string;
startSeq?: number;
} | null;
} | null;
directorySync?: unknown;
}
export interface ReplicaCacheRecord {
version?: number;
hosts?: Array<{
timeline?: {
agentId?: string;
items?: Array<Record<string, unknown>>;
range?: {
endSeq?: number;
epoch?: string;
startSeq?: number;
} | null;
} | null;
}>;
hosts?: ReplicaCacheHostRecord[];
}
interface ReplicaCacheWriteObserverState {
lastValue: string | null;
lastValues: Record<string, string>;
redundantWrites: number;
serializedChars: number;
storageDurationMs: number;
writes: number;
}
interface ReplicaCacheWriteObserverReport {
redundantWrites: number;
serializedChars: number;
storageDurationMs: number;
@@ -33,11 +56,10 @@ declare global {
}
}
async function readStoredValue(input: {
async function readRows(input: {
databaseName: string;
storeName: string;
storageKey: string;
}): Promise<string | null> {
}): Promise<ReplicaRowRecord[]> {
const database = await new Promise<IDBDatabase>((resolve, reject) => {
const request = indexedDB.open(input.databaseName, 1);
request.addEventListener("success", () => resolve(request.result));
@@ -47,26 +69,103 @@ async function readStoredValue(input: {
const request = database
.transaction(input.storeName, "readonly")
.objectStore(input.storeName)
.get(input.storageKey);
request.addEventListener("success", () =>
resolve(typeof request.result === "string" ? request.result : null),
);
.getAll();
request.addEventListener("success", () => resolve(request.result));
request.addEventListener("error", () => reject(request.error));
});
}
function assembleCache(rows: ReplicaRowRecord[]): ReplicaCacheRecord {
const hosts = new Map<string, ReplicaCacheHostRecord>();
for (const row of rows) {
const host = hosts.get(row.serverId) ?? {
serverId: row.serverId,
agents: [],
workspaces: [],
projects: [],
timeline: null,
};
const payload = JSON.parse(row.payload) as Record<string, unknown>;
switch (row.kind) {
case "agent":
host.agents.push(payload);
break;
case "workspace":
host.workspaces.push(payload);
break;
case "project":
host.projects.push(payload);
break;
case "timeline":
host.timeline = payload;
break;
case "checkpoint":
host.directorySync = payload;
break;
}
hosts.set(row.serverId, host);
}
return { version: 6, hosts: [...hosts.values()] };
}
export async function readReplicaCache(page: Page): Promise<ReplicaCacheRecord | null> {
const raw = await page.evaluate(readStoredValue, {
const rows = await page.evaluate(readRows, {
databaseName: DATABASE_NAME,
storeName: STORE_NAME,
storageKey: STORAGE_KEY,
});
return raw ? (JSON.parse(raw) as ReplicaCacheRecord) : null;
return rows.length > 0 ? assembleCache(rows) : null;
}
export async function writeReplicaCache(page: Page, value: ReplicaCacheRecord): Promise<void> {
const rows: ReplicaRowRecord[] = [];
for (const host of value.hosts ?? []) {
for (const agent of host.agents) {
const snapshot = agent.snapshot;
if (!snapshot || typeof snapshot !== "object") continue;
const id = Reflect.get(snapshot, "id");
if (typeof id === "string") {
rows.push({ serverId: host.serverId, kind: "agent", id, payload: JSON.stringify(agent) });
}
}
for (const workspace of host.workspaces) {
if (typeof workspace.id === "string") {
rows.push({
serverId: host.serverId,
kind: "workspace",
id: workspace.id,
payload: JSON.stringify(workspace),
});
}
}
for (const project of host.projects) {
if (typeof project.projectId === "string") {
rows.push({
serverId: host.serverId,
kind: "project",
id: project.projectId,
payload: JSON.stringify(project),
});
}
}
if (host.timeline) {
rows.push({
serverId: host.serverId,
kind: "timeline",
id: SINGLETON_ID,
payload: JSON.stringify(host.timeline),
});
}
if (host.directorySync !== undefined) {
rows.push({
serverId: host.serverId,
kind: "checkpoint",
id: SINGLETON_ID,
payload: JSON.stringify(host.directorySync),
});
}
}
await page.evaluate(
async ({ databaseName, storeName, storageKey, raw }) => {
async ({ databaseName, storeName, nextRows }) => {
const database = await new Promise<IDBDatabase>((resolve, reject) => {
const request = indexedDB.open(databaseName, 1);
request.addEventListener("success", () => resolve(request.result));
@@ -74,26 +173,23 @@ export async function writeReplicaCache(page: Page, value: ReplicaCacheRecord):
});
await new Promise<void>((resolve, reject) => {
const transaction = database.transaction(storeName, "readwrite");
transaction.objectStore(storeName).put(raw, storageKey);
const store = transaction.objectStore(storeName);
store.clear();
for (const row of nextRows) store.put(row);
transaction.addEventListener("complete", () => resolve());
transaction.addEventListener("error", () => reject(transaction.error));
transaction.addEventListener("abort", () => reject(transaction.error));
});
},
{
databaseName: DATABASE_NAME,
storeName: STORE_NAME,
storageKey: STORAGE_KEY,
raw: JSON.stringify(value),
},
{ databaseName: DATABASE_NAME, storeName: STORE_NAME, nextRows: rows },
);
}
export async function observeReplicaCacheStorageWrites(page: Page): Promise<void> {
await page.addInitScript(
({ databaseName, storeName, storageKey }) => {
({ databaseName, storeName }) => {
window.__replicaCacheWriteObserver = {
lastValue: null,
lastValues: {},
redundantWrites: 0,
serializedChars: 0,
storageDurationMs: 0,
@@ -106,51 +202,71 @@ export async function observeReplicaCacheStorageWrites(page: Page): Promise<void
if (
this.transaction.db.name !== databaseName ||
this.name !== storeName ||
key !== storageKey ||
typeof value !== "string"
!value ||
typeof value !== "object"
) {
return request;
}
const serverId = Reflect.get(value, "serverId");
const kind = Reflect.get(value, "kind");
const id = Reflect.get(value, "id");
const payload = Reflect.get(value, "payload");
if (
typeof serverId !== "string" ||
typeof kind !== "string" ||
typeof id !== "string" ||
typeof payload !== "string"
) {
return request;
}
const rowKey = `${serverId}:${kind}:${id}`;
const startedAt = performance.now();
request.addEventListener("success", () => {
const state = window.__replicaCacheWriteObserver;
if (!state) return;
if (state.lastValue === value) state.redundantWrites += 1;
state.lastValue = value;
if (state.lastValues[rowKey] === payload) state.redundantWrites += 1;
state.lastValues[rowKey] = payload;
state.writes += 1;
state.serializedChars += value.length;
state.serializedChars += payload.length;
state.storageDurationMs += performance.now() - startedAt;
});
return request;
};
},
{ databaseName: DATABASE_NAME, storeName: STORE_NAME, storageKey: STORAGE_KEY },
{ databaseName: DATABASE_NAME, storeName: STORE_NAME },
);
}
export async function resetReplicaCacheStorageWriteObserver(page: Page): Promise<void> {
const lastValue = await page.evaluate(readStoredValue, {
const rows = await page.evaluate(readRows, {
databaseName: DATABASE_NAME,
storeName: STORE_NAME,
storageKey: STORAGE_KEY,
});
await page.evaluate((value) => {
const lastValues = Object.fromEntries(
rows.map((row) => [`${row.serverId}:${row.kind}:${row.id}`, row.payload]),
);
await page.evaluate((values) => {
window.__replicaCacheWriteObserver = {
lastValue: value,
lastValues: values,
redundantWrites: 0,
serializedChars: 0,
storageDurationMs: 0,
writes: 0,
};
}, lastValue);
}, lastValues);
}
export async function readReplicaCacheStorageWriteObserver(
page: Page,
): Promise<ReplicaCacheWriteObserverState> {
): Promise<ReplicaCacheWriteObserverReport> {
return page.evaluate(() => {
const state = window.__replicaCacheWriteObserver;
if (!state) throw new Error("Replica cache write observer is not installed");
return state;
return {
redundantWrites: state.redundantWrites,
serializedChars: state.serializedChars,
storageDurationMs: state.storageDurationMs,
writes: state.writes,
};
});
}
@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { summarizeStreamSmoothness } from "./stream-smoothness";
describe("summarizeStreamSmoothness", () => {
it("reports canonical handover snaps separately from paced growth", () => {
const report = summarizeStreamSmoothness(
[
{ timestampMs: 0, growthChars: 0, firstPaintChars: 0 },
{ timestampMs: 10, growthChars: 4, firstPaintChars: 0 },
{ timestampMs: 20, growthChars: 100, firstPaintChars: 30 },
{ timestampMs: 30, growthChars: 4, firstPaintChars: 0 },
{ timestampMs: 40, growthChars: 0, firstPaintChars: 0 },
],
40,
);
expect(report).toMatchObject({
frames: 3,
growthFrames: 2,
charsPainted: 8,
maxCharsInOneFrame: 4,
firstPaintFrames: 1,
firstPaintChars: 30,
handoverGrowthFrames: 1,
handoverGrowthChars: 100,
maxHandoverGrowthCharsInOneFrame: 100,
updateGapP95Ms: 10,
});
});
});
@@ -0,0 +1,215 @@
import type { Page } from "@playwright/test";
/**
* Frame-level sampling of the streaming assistant message, and the two numbers
* that describe how it reads:
*
* - `charsPerFrameCv` — coefficient of variation of characters painted per frame.
* This is the smoothness metric. Painting deltas as they land tracks the
* arrival lumps, so it is high; pacing the reveal flattens it.
* - `updateGapP95Ms` — how long the text can sit unchanged mid-stream. This is
* the stall metric, and it is what stops smoothness being bought with lag.
*
* Both are needed. A stream that never updates is perfectly smooth.
*/
export interface StreamFrameSample {
timestampMs: number;
growthChars: number;
firstPaintChars: number;
}
export interface StreamSmoothnessReport {
sampleWindowMs: number;
frames: number;
growthFrames: number;
charsPainted: number;
meanCharsPerFrame: number;
maxCharsInOneFrame: number;
charsPerFrameCv: number;
firstPaintFrames: number;
firstPaintChars: number;
maxFirstPaintCharsInOneFrame: number;
handoverGrowthFrames: number;
handoverGrowthChars: number;
maxHandoverGrowthCharsInOneFrame: number;
updateGapP50Ms: number;
updateGapP95Ms: number;
updateGapMaxMs: number;
}
/**
* Record text growth on every mounted assistant message once per frame.
*
* Message occurrence identity separates paced growth from first paint. Completed markdown
* blocks move into canonical timeline rows while a turn streams, remounting text
* that was already visible. Counting the new node's full length as growth would
* report that handover as a large reveal even though no text appeared on screen.
* First paints stay in the report as a separate diagnostic.
*
* Runs entirely in the page so the sampling clock is the same clock the reveal
* runs on. Waits for the text to start moving first, so a slow model's
* time-to-first-token is not counted as a stall.
*/
export async function sampleStreamFrames(
page: Page,
options: { sampleWindowMs: number; startTimeoutMs?: number },
): Promise<StreamFrameSample[]> {
const startTimeoutMs = options.startTimeoutMs ?? 60_000;
return await page.evaluate(
async ({ sampleWindowMs, startTimeoutMs: waitMs }) => {
const readLength = () => {
let total = 0;
for (const node of document.querySelectorAll('[data-testid="assistant-message"]')) {
total += node.textContent?.length ?? 0;
}
return total;
};
const waitStart = performance.now();
const base = readLength();
await new Promise<void>((resolve) => {
const poll = () => {
if (readLength() > base + 20 || performance.now() - waitStart > waitMs) {
resolve();
return;
}
requestAnimationFrame(poll);
};
requestAnimationFrame(poll);
});
let previousLengths = new Map<string, number>();
for (const node of document.querySelectorAll('[data-testid="assistant-message"]')) {
const key = node.getAttribute("data-reveal-key");
const length = Number(node.getAttribute("data-reveal-length"));
if (key !== null && Number.isFinite(length)) {
previousLengths.set(key, length);
}
}
const samples: Array<{
timestampMs: number;
growthChars: number;
firstPaintChars: number;
}> = [];
await new Promise<void>((resolve) => {
const start = performance.now();
const tick = (now: number) => {
const currentLengths = new Map<string, number>();
let growthChars = 0;
let firstPaintChars = 0;
for (const node of document.querySelectorAll('[data-testid="assistant-message"]')) {
const key = node.getAttribute("data-reveal-key");
const currentLength = Number(node.getAttribute("data-reveal-length"));
if (key === null || !Number.isFinite(currentLength)) {
continue;
}
const previousLength = previousLengths.get(key);
if (previousLength === undefined || currentLength < previousLength) {
firstPaintChars += currentLength;
} else {
const nodeGrowth = currentLength - previousLength;
growthChars += nodeGrowth;
}
currentLengths.set(key, currentLength);
}
samples.push({
timestampMs: now,
growthChars,
firstPaintChars,
});
previousLengths = currentLengths;
if (now - start >= sampleWindowMs) {
resolve();
return;
}
requestAnimationFrame(tick);
};
requestAnimationFrame(tick);
});
return samples;
},
{ sampleWindowMs: options.sampleWindowMs, startTimeoutMs },
);
}
export function computePercentile(samples: readonly number[], percentile: number): number {
if (samples.length === 0) {
return 0;
}
const sorted = [...samples].sort((a, b) => a - b);
return sorted[Math.max(0, Math.ceil((percentile / 100) * sorted.length) - 1)];
}
function round2(value: number): number {
return Math.round(value * 100) / 100;
}
/**
* Reduce frame samples to the report. Frames outside the streaming window are
* dropped: leading idle is time-to-first-token, and trailing idle means the turn
* ended mid-sample. First-paint frames are structural handovers. Existing blocks
* may also snap complete on those frames, so their growth is reported separately
* from the paced-growth CV.
*/
export function summarizeStreamSmoothness(
samples: readonly StreamFrameSample[],
sampleWindowMs: number,
): StreamSmoothnessReport {
const deltas: number[] = [];
const gapsMs: number[] = [];
let lastUpdateAtMs: number | null = null;
let firstGrowth = -1;
let lastGrowth = -1;
const handoverGrowths: number[] = [];
for (let index = 0; index < samples.length; index += 1) {
const sample = samples[index];
const isHandover = sample.firstPaintChars > 0;
const growth = isHandover ? 0 : sample.growthChars;
if (isHandover && sample.growthChars > 0) {
handoverGrowths.push(sample.growthChars);
lastUpdateAtMs = sample.timestampMs;
}
deltas.push(growth);
if (growth > 0) {
if (firstGrowth === -1) {
firstGrowth = deltas.length - 1;
}
lastGrowth = deltas.length - 1;
if (lastUpdateAtMs !== null) {
gapsMs.push(samples[index].timestampMs - lastUpdateAtMs);
}
lastUpdateAtMs = samples[index].timestampMs;
}
}
const active = firstGrowth === -1 ? [] : deltas.slice(firstGrowth, lastGrowth + 1);
const charsPainted = active.reduce((sum, delta) => sum + delta, 0);
const mean = active.length > 0 ? charsPainted / active.length : 0;
const variance =
active.length > 0
? active.reduce((sum, delta) => sum + (delta - mean) ** 2, 0) / active.length
: 0;
const firstPaints = samples.map((sample) => sample.firstPaintChars).filter((chars) => chars > 0);
return {
sampleWindowMs,
frames: active.length,
growthFrames: active.filter((delta) => delta > 0).length,
charsPainted,
meanCharsPerFrame: round2(mean),
maxCharsInOneFrame: active.length > 0 ? Math.max(...active) : 0,
charsPerFrameCv: mean === 0 ? Number.POSITIVE_INFINITY : round2(Math.sqrt(variance) / mean),
firstPaintFrames: firstPaints.length,
firstPaintChars: firstPaints.reduce((sum, chars) => sum + chars, 0),
maxFirstPaintCharsInOneFrame: firstPaints.length > 0 ? Math.max(...firstPaints) : 0,
handoverGrowthFrames: handoverGrowths.length,
handoverGrowthChars: handoverGrowths.reduce((sum, chars) => sum + chars, 0),
maxHandoverGrowthCharsInOneFrame: handoverGrowths.length > 0 ? Math.max(...handoverGrowths) : 0,
updateGapP50Ms: round2(computePercentile(gapsMs, 50)),
updateGapP95Ms: round2(computePercentile(gapsMs, 95)),
updateGapMaxMs: gapsMs.length > 0 ? round2(Math.max(...gapsMs)) : 0,
};
}
+24 -2
View File
@@ -1,5 +1,11 @@
const versionPattern = /^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/;
const stableIosBuildSlot = 999;
const FDROID_ABI_VERSION_CODE_SUFFIXES = {
"armeabi-v7a": 1,
"arm64-v8a": 2,
x86: 3,
x86_64: 4,
};
function getNativeReleaseVersion(version) {
const match = versionPattern.exec(version);
@@ -21,7 +27,11 @@ function getNativeReleaseVersion(version) {
}
const versionCode = major * 1_000_000 + minor * 1_000 + patch;
if (!Number.isSafeInteger(versionCode) || versionCode <= 0 || versionCode > 2_100_000_000) {
if (
!Number.isSafeInteger(versionCode) ||
versionCode <= 0 ||
versionCode * 10 + 9 > 2_100_000_000
) {
throw new Error(`Derived Android versionCode is out of range: ${versionCode}`);
}
@@ -38,4 +48,16 @@ function getNativeReleaseVersion(version) {
};
}
module.exports = { getNativeReleaseVersion };
function getFdroidVersionCodes(version) {
const { androidVersionCode } = getNativeReleaseVersion(version);
return Object.entries(FDROID_ABI_VERSION_CODE_SUFFIXES).map(([abi, suffix]) => ({
abi,
versionCode: androidVersionCode * 10 + suffix,
}));
}
module.exports = {
FDROID_ABI_VERSION_CODE_SUFFIXES,
getFdroidVersionCodes,
getNativeReleaseVersion,
};
+20 -1
View File
@@ -1,6 +1,10 @@
import { describe, expect, it } from "vitest";
const { getNativeReleaseVersion } = require("./native-release-version");
const {
FDROID_ABI_VERSION_CODE_SUFFIXES,
getFdroidVersionCodes,
getNativeReleaseVersion,
} = require("./native-release-version");
describe("native release version", () => {
it("reserves the final iOS build slot for a stable release", () => {
@@ -24,4 +28,19 @@ describe("native release version", () => {
"iOS beta number must be between 1 and 998",
);
});
it("derives one F-Droid version code per published ABI", () => {
expect(FDROID_ABI_VERSION_CODE_SUFFIXES).toEqual({
"armeabi-v7a": 1,
"arm64-v8a": 2,
x86: 3,
x86_64: 4,
});
expect(getFdroidVersionCodes("0.5.0")).toEqual([
{ abi: "armeabi-v7a", versionCode: 50001 },
{ abi: "arm64-v8a", versionCode: 50002 },
{ abi: "x86", versionCode: 50003 },
{ abi: "x86_64", versionCode: 50004 },
]);
});
});
+4
View File
@@ -23,6 +23,7 @@
"test:browser": "vitest run --project browser",
"test:e2e": "playwright test --project=browser",
"test:e2e:diff-performance": "cross-env PASEO_DIFF_PERF_E2E=1 playwright test --project=browser e2e/browser/diff-performance.spec.ts",
"test:e2e:stream-smoothness": "cross-env PASEO_AGENT_STREAM_PERF_E2E=1 playwright test --project=browser e2e/browser/agent-stream-smoothness.spec.ts",
"test:e2e:real": "cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=real-provider",
"test:e2e:relay-deployment": "npm --prefix ../.. run build:server && npm --prefix ../.. run build:daemon-web-ui && cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=relay-deployment e2e/browser/relay-deployment-reconnect.real.spec.ts",
"test:e2e:ui": "playwright test --ui",
@@ -95,6 +96,7 @@
"expo-router": "~6.0.13",
"expo-sharing": "^14.0.8",
"expo-splash-screen": "~31.0.10",
"expo-sqlite": "~16.0.10",
"expo-system-ui": "~6.0.7",
"fast-deep-equal": "^3.1.3",
"htmlparser2": "^12.0.0",
@@ -136,6 +138,7 @@
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"@types/markdown-it": "^14.1.2",
"@types/node": "~22.19.0",
"@types/qrcode": "^1.5.6",
"@types/react": "~19.2.0",
"@types/turndown": "^5.0.6",
@@ -149,6 +152,7 @@
"eslint": "^9.25.0",
"eslint-config-expo": "~10.0.0",
"expo-gradle-jvmargs": "^1.1.2",
"fake-indexeddb": "^6.2.5",
"jsdom": "^20.0.3",
"material-icon-theme": "^5.32.0",
"playwright": "^1.56.1",
@@ -1,6 +1,7 @@
const fs = require("node:fs/promises");
const path = require("node:path");
const { withAppBuildGradle, withDangerousMod, withSettingsGradle } = require("expo/config-plugins");
const { FDROID_ABI_VERSION_CODE_SUFFIXES } = require("../native-release-version");
const EXCLUDED_ANDROID_MODULES = [
"expo-camera",
@@ -11,12 +12,15 @@ const EXCLUDED_ANDROID_MODULES = [
"expo-dev-menu-interface",
];
// Generated from the shared suffix table so the Groovy literal can never drift
// from the version codes the F-Droid changelog filenames are derived from.
const FDROID_ABI_VERSION_CODE_ENTRIES = Object.entries(FDROID_ABI_VERSION_CODE_SUFFIXES)
.map(([abi, suffix]) => ` "${abi}": ${suffix},`)
.join("\n");
const FDROID_ABI_VERSION_CODE_BLOCK = `// Paseo F-Droid single-ABI version codes
def paseoAbiVersionCodes = [
"armeabi-v7a": 1,
"arm64-v8a": 2,
"x86": 3,
"x86_64": 4,
${FDROID_ABI_VERSION_CODE_ENTRIES}
]
def paseoArchitectures = (findProperty("reactNativeArchitectures") ?: "")
.toString()
@@ -10,7 +10,7 @@ export interface BottomAnchorRouteRequest {
}
export interface BottomAnchorLocalRequest {
reason: "jump-to-bottom" | "message-sent";
reason: "jump-to-bottom" | "message-sent" | "rewind";
agentId: string;
}
@@ -0,0 +1,277 @@
import { describe, expect, it } from "vitest";
import {
advanceTextReveal,
beginTextReveal,
clampToSafeRevealBoundary,
completeTextReveal,
computeRevealStep,
nextTextRevealFrame,
isTextRevealSettled,
retargetTextReveal,
TEXT_REVEAL_FRAME_INTERVAL_MS,
TEXT_REVEAL_HORIZON_MS,
visibleRevealedText,
} from "./text-reveal";
describe("computeRevealStep", () => {
it("reveals nothing when there is no backlog", () => {
expect(computeRevealStep({ backlog: 0, elapsedMs: 16 })).toBe(0);
expect(computeRevealStep({ backlog: -5, elapsedMs: 16 })).toBe(0);
});
it("drains the backlog over the horizon", () => {
const step = computeRevealStep({ backlog: 300, elapsedMs: TEXT_REVEAL_HORIZON_MS / 2 });
expect(step).toBe(150);
});
it("reveals the whole backlog once a frame covers the horizon", () => {
expect(computeRevealStep({ backlog: 42, elapsedMs: TEXT_REVEAL_HORIZON_MS })).toBe(42);
expect(computeRevealStep({ backlog: 42, elapsedMs: TEXT_REVEAL_HORIZON_MS * 10 })).toBe(42);
});
it("scales the rate with the backlog so a faster model reveals faster", () => {
const slow = computeRevealStep({ backlog: 20, elapsedMs: 16 });
const fast = computeRevealStep({ backlog: 200, elapsedMs: 16 });
expect(fast).toBeGreaterThan(slow);
});
it("always advances at least one character so the tail finishes", () => {
expect(computeRevealStep({ backlog: 1, elapsedMs: 1 })).toBe(1);
expect(computeRevealStep({ backlog: 2, elapsedMs: 0.01 })).toBe(1);
});
it("never overshoots the backlog", () => {
for (const backlog of [1, 3, 7, 50]) {
expect(computeRevealStep({ backlog, elapsedMs: 120 })).toBeLessThanOrEqual(backlog);
}
});
it("reveals nothing when no time has passed", () => {
expect(computeRevealStep({ backlog: 100, elapsedMs: 0 })).toBe(0);
expect(computeRevealStep({ backlog: 100, elapsedMs: -16 })).toBe(0);
});
it("converges within a bounded number of frames at 60Hz", () => {
let remaining = 500;
let frames = 0;
while (remaining > 0) {
remaining -= computeRevealStep({ backlog: remaining, elapsedMs: 16 });
frames += 1;
expect(frames).toBeLessThan(120);
}
expect(remaining).toBe(0);
});
it("keeps per-frame steps smooth for a bursty arrival pattern", () => {
// A lumpy arrival sequence: the daemon's coalescing window carries wildly
// different character counts depending on model throughput.
const arrivals = [4, 180, 6, 240, 2, 90, 300, 8];
const steps: number[] = [];
let backlog = 0;
for (const arrival of arrivals) {
backlog += arrival;
// ~60ms of frames between coalesced flushes.
for (let frame = 0; frame < 4; frame += 1) {
const step = computeRevealStep({ backlog, elapsedMs: 16 });
backlog -= step;
steps.push(step);
}
}
// Painting arrivals directly would swing from 2 to 300 characters in one
// paint. Pacing keeps the largest single paint far below the largest arrival.
expect(Math.max(...steps)).toBeLessThan(Math.max(...arrivals) / 2);
expect(Math.min(...steps)).toBeGreaterThan(0);
});
});
describe("clampToSafeRevealBoundary", () => {
it("leaves boundaries in plain text alone", () => {
expect(clampToSafeRevealBoundary("hello world", 5)).toBe(5);
});
it("clamps the ends", () => {
expect(clampToSafeRevealBoundary("hello", -3)).toBe(0);
expect(clampToSafeRevealBoundary("hello", 99)).toBe(5);
});
it("never splits a surrogate pair", () => {
// "a😀b" — the emoji occupies indices 1 and 2.
const text = "a😀b";
expect(clampToSafeRevealBoundary(text, 2)).toBe(1);
expect(clampToSafeRevealBoundary(text, 3)).toBe(3);
});
it("does not strand a combining mark", () => {
// "e" + combining acute; cutting at 1 would show a bare "e" then reflow.
const text = `éx`;
expect(clampToSafeRevealBoundary(text, 1)).toBe(0);
expect(clampToSafeRevealBoundary(text, 2)).toBe(2);
});
it("does not split an emoji ZWJ sequence", () => {
// Family emoji: person ZWJ person ZWJ child.
const family = "\u{1F468}‍\u{1F469}‍\u{1F467}";
const text = `${family}!`;
for (let index = 1; index < family.length; index += 1) {
expect(clampToSafeRevealBoundary(text, index)).toBe(0);
}
expect(clampToSafeRevealBoundary(text, family.length)).toBe(family.length);
});
it("does not split a skin tone modifier from its base", () => {
const text = "\u{1F44D}\u{1F3FD} nice";
expect(clampToSafeRevealBoundary(text, 2)).toBe(0);
expect(clampToSafeRevealBoundary(text, 4)).toBe(4);
});
it("does not strand a variation selector", () => {
const text = "❤️ done";
expect(clampToSafeRevealBoundary(text, 1)).toBe(0);
expect(clampToSafeRevealBoundary(text, 2)).toBe(2);
});
it("does not split extended grapheme clusters", () => {
for (const { text, boundaries } of [
{ text: "a🇺🇸b", boundaries: [0, 1, 5, 6] },
{ text: "a가b", boundaries: [0, 1, 3, 4] },
{ text: "aकःb", boundaries: [0, 1, 3, 4] },
]) {
for (let index = 1; index < text.length; index += 1) {
const expected = boundaries.toReversed().find((boundary) => boundary <= index);
expect(clampToSafeRevealBoundary(text, index)).toBe(expected);
}
}
});
});
describe("nextTextRevealFrame", () => {
it("caps a high-refresh frame clock at 60Hz", () => {
expect(nextTextRevealFrame(null, 0)).toEqual({
elapsedMs: TEXT_REVEAL_FRAME_INTERVAL_MS,
frameAtMs: 0,
});
expect(nextTextRevealFrame(0, 8)).toBeNull();
expect(nextTextRevealFrame(0, 17)).toEqual({
elapsedMs: 17,
frameAtMs: expect.closeTo(TEXT_REVEAL_FRAME_INTERVAL_MS, 5),
});
});
});
describe("text reveal state", () => {
it("reveals the first text it sees in full", () => {
const state = beginTextReveal("already here");
expect(visibleRevealedText(state)).toBe("already here");
expect(isTextRevealSettled(state)).toBe(true);
});
it("paces growth instead of painting it whole", () => {
let state = beginTextReveal("a");
state = retargetTextReveal(state, `a${"b".repeat(300)}`);
expect(visibleRevealedText(state)).toBe("a");
state = advanceTextReveal(state, 16);
const shown = visibleRevealedText(state);
expect(shown.length).toBeGreaterThan(1);
expect(shown.length).toBeLessThan(301);
});
it("catches up to the full text across frames", () => {
const full = `a${"b".repeat(200)}`;
let state = retargetTextReveal(beginTextReveal("a"), full);
for (let frame = 0; frame < 60 && !isTextRevealSettled(state); frame += 1) {
state = advanceTextReveal(state, 16);
}
expect(isTextRevealSettled(state)).toBe(true);
expect(visibleRevealedText(state)).toBe(full);
});
it("releases everything when the turn completes", () => {
const full = `a${"b".repeat(500)}`;
let state = advanceTextReveal(retargetTextReveal(beginTextReveal("a"), full), 16);
expect(visibleRevealedText(state)).not.toBe(full);
state = completeTextReveal(state);
expect(visibleRevealedText(state)).toBe(full);
});
it("only ever paints a prefix of the real text", () => {
const full = "the quick brown fox jumps over the lazy dog";
let state = retargetTextReveal(beginTextReveal("the "), full);
for (let frame = 0; frame < 20; frame += 1) {
expect(full.startsWith(visibleRevealedText(state))).toBe(true);
state = advanceTextReveal(state, 16);
}
});
it("clamps when the slot switches to a shorter message", () => {
const state = retargetTextReveal(beginTextReveal("a long streaming message"), "short");
expect(visibleRevealedText(state)).toBe("short");
});
it("never paints a lone surrogate while streaming emoji", () => {
const full = `progress ${"\u{1F680}".repeat(40)} done`;
let state = retargetTextReveal(beginTextReveal("progress "), full);
for (let frame = 0; frame < 200 && !isTextRevealSettled(state); frame += 1) {
const shown = visibleRevealedText(state);
// A stranded surrogate would make the painted prefix un-decodable.
expect(shown).toBe(Array.from(shown).join(""));
expect(full.startsWith(shown)).toBe(true);
state = advanceTextReveal(state, 16);
}
expect(visibleRevealedText(completeTextReveal(state))).toBe(full);
});
it("a long cluster cannot stall the reveal", () => {
// The rendered boundary backs up over this cluster, but the counter does not,
// so the reveal still finishes.
const full = `x${"́".repeat(40)}y`;
let state = retargetTextReveal(beginTextReveal("x"), full);
for (let frame = 0; frame < 200 && !isTextRevealSettled(state); frame += 1) {
state = advanceTextReveal(state, 16);
}
expect(isTextRevealSettled(state)).toBe(true);
expect(visibleRevealedText(state)).toBe(full);
});
});
describe("trailing fragments from arrival boundaries", () => {
it("holds back half a flag while more text is coming", () => {
// The daemon's coalescing window can end a delta mid-cluster, so a caught-up
// reveal can be handed a single regional indicator.
const halfFlag = "flags: \u{1F1EC}";
const state = beginTextReveal(halfFlag);
expect(visibleRevealedText(state, { streaming: true })).toBe("flags: ");
// Once the turn ends nothing more is coming, so paint what there is.
expect(visibleRevealedText(state, { streaming: false })).toBe(halfFlag);
});
it("paints the flag once its second half arrives", () => {
const whole = "flags: \u{1F1EC}\u{1F1E7}";
expect(visibleRevealedText(beginTextReveal(whole), { streaming: true })).toBe(whole);
});
it("keeps an even run of regional indicators intact", () => {
const twoFlags = "\u{1F1EC}\u{1F1E7}\u{1F1EB}\u{1F1F7}";
expect(visibleRevealedText(beginTextReveal(twoFlags), { streaming: true })).toBe(twoFlags);
});
it("holds back a dangling joiner", () => {
expect(
visibleRevealedText(beginTextReveal("family: \u{1F468}\u200D"), { streaming: true }),
).toBe("family: \u{1F468}");
});
it("holds back a dangling high surrogate", () => {
const loneHigh = `broken: ${String.fromCharCode(0xd83d)}`;
expect(visibleRevealedText(beginTextReveal(loneHigh), { streaming: true })).toBe("broken: ");
});
it("leaves ordinary trailing text alone", () => {
const prose = "just some prose";
expect(visibleRevealedText(beginTextReveal(prose), { streaming: true })).toBe(prose);
});
});
@@ -0,0 +1,240 @@
/**
* Paced reveal for streaming assistant text.
*
* Deltas arrive lumpy: the daemon coalesces one message per 60ms window, carrying
* however many characters the model happened to produce in that window. Painting
* each delta as it lands makes the size of those lumps visible, which is what
* reads as jagged. So arrival changes the *target* and the reveal rate is derived
* from the backlog instead — a burst makes the text catch up faster, it doesn't
* make it jump.
*
* The store keeps the full text. Only the rendered slice is paced, so copy,
* selection, the chat outline, and scroll geometry all stay consistent with what
* is on screen.
*
* Everything here is pure. The only thing the React hook adds is a frame clock,
* which keeps the policy testable without a renderer.
*/
// Backlog is drained over this horizon. Shorter feels more like the raw arrival
// pattern; longer adds lag the user can notice at the end of a turn.
export const TEXT_REVEAL_HORIZON_MS = 150;
/** Reveal at most once per 60Hz frame, even on high-refresh displays. */
export const TEXT_REVEAL_FRAME_INTERVAL_MS = 1000 / 60;
// A frame's elapsed time is clamped to this before it is used, so a long stall
// (backgrounded tab, blocked main thread) doesn't produce a wild step from one
// enormous delta.
const MAX_ELAPSED_MS = 250;
/**
* Characters to reveal on this frame. Proportional to the backlog, so the reveal
* accelerates when the model runs ahead and settles when it doesn't, with a
* one-character floor so the tail always finishes.
*/
export function computeRevealStep(input: {
backlog: number;
elapsedMs: number;
horizonMs?: number;
}): number {
const { backlog } = input;
if (backlog <= 0) {
return 0;
}
const horizonMs = input.horizonMs ?? TEXT_REVEAL_HORIZON_MS;
if (horizonMs <= 0) {
return backlog;
}
const elapsedMs = Math.min(Math.max(input.elapsedMs, 0), MAX_ELAPSED_MS);
if (elapsedMs <= 0) {
return 0;
}
if (elapsedMs >= horizonMs) {
return backlog;
}
const step = Math.ceil((backlog * elapsedMs) / horizonMs);
return Math.min(backlog, Math.max(1, step));
}
const ZERO_WIDTH_JOINER = 0x200d;
const graphemeSegmenter =
typeof Intl.Segmenter === "function"
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
: null;
/**
* Pacing needs a conformant grapheme segmenter. Older runtimes paint each
* arrival whole instead of risking a transient broken glyph.
*/
export function isTextRevealPacingSupported(): boolean {
return graphemeSegmenter !== null;
}
/**
* Pull a cut index back to somewhere it is safe to slice.
*
* A raw `slice` at an arbitrary index can split a grapheme cluster, which makes
* one visible glyph briefly render as separate parts while the text is streaming.
*
* This only moves the *rendered* boundary. The reveal counter stays monotonic, so
* a long cluster can never stall the reveal — the next frame steps past it.
*/
export function clampToSafeRevealBoundary(text: string, index: number): number {
if (index <= 0) {
return 0;
}
if (index >= text.length) {
return text.length;
}
const segment = graphemeSegmenter?.segment(text).containing(index);
return segment?.index ?? 0;
}
export interface TextRevealFrame {
elapsedMs: number;
frameAtMs: number;
}
/**
* Keep reveal commits at 60Hz while carrying timing remainder forward so a
* high-refresh display does not make the reveal render at hardware frame rate.
*/
export function nextTextRevealFrame(
previousFrameAtMs: number | null,
timestampMs: number,
): TextRevealFrame | null {
const elapsedMs =
previousFrameAtMs === null ? TEXT_REVEAL_FRAME_INTERVAL_MS : timestampMs - previousFrameAtMs;
if (elapsedMs < TEXT_REVEAL_FRAME_INTERVAL_MS) {
return null;
}
return {
elapsedMs,
frameAtMs: timestampMs - (elapsedMs % TEXT_REVEAL_FRAME_INTERVAL_MS),
};
}
export interface TextRevealState {
/** The full text as the store knows it. */
readonly target: string;
/** How much of it has been released. Monotonic within a message. */
readonly revealed: number;
}
/**
* First sight of a text is revealed whole. Only growth is paced, which 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.
*/
export function beginTextReveal(text: string): TextRevealState {
return { target: text, revealed: text.length };
}
/** Point the reveal at newly arrived text without changing how much is shown. */
export function retargetTextReveal(state: TextRevealState, text: string): TextRevealState {
if (state.target === text) {
return state;
}
// A shorter string means this slot is showing a different message than the one
// the reveal position belongs to.
return { target: text, revealed: Math.min(state.revealed, text.length) };
}
/** Release one frame's worth of characters. */
export function advanceTextReveal(
state: TextRevealState,
elapsedMs: number,
horizonMs?: number,
): TextRevealState {
const step = computeRevealStep({
backlog: state.target.length - state.revealed,
elapsedMs,
...(horizonMs !== undefined ? { horizonMs } : {}),
});
if (step <= 0) {
return state;
}
return { target: state.target, revealed: Math.min(state.target.length, state.revealed + step) };
}
/** Release everything, for when the turn ends and nothing may be held back. */
export function completeTextReveal(state: TextRevealState): TextRevealState {
if (state.revealed >= state.target.length) {
return state;
}
return { target: state.target, revealed: state.target.length };
}
export function isTextRevealSettled(state: TextRevealState): boolean {
return state.revealed >= state.target.length;
}
/**
* Hold back a trailing fragment that cannot stand on its own.
*
* The reveal boundary is not the only place a cluster gets cut. The daemon's
* coalescing window ends a delta wherever the window closes, so a caught-up
* reveal can be handed half a flag and paint it — measured on a mixed-script
* stream as frames ending in a single regional indicator. Only fragments that
* are certainly waiting on more input are withheld: a dangling high surrogate, a
* trailing joiner, or an odd regional indicator.
*/
function trimIncompleteTrailingCluster(text: string): string {
if (text.length === 0) {
return text;
}
const lastUnit = text.charCodeAt(text.length - 1);
if (lastUnit >= 0xd800 && lastUnit <= 0xdbff) {
return text.slice(0, -1);
}
if (lastUnit === ZERO_WIDTH_JOINER) {
return text.slice(0, -1);
}
const trailingRegionalIndicators = countTrailingRegionalIndicators(text);
if (trailingRegionalIndicators % 2 === 1) {
return text.slice(0, -2);
}
return text;
}
/** Number of regional indicators at the end of `text`. A flag is a pair. */
function countTrailingRegionalIndicators(text: string): number {
let count = 0;
let cursor = text.length;
while (cursor >= 2) {
const codePoint = text.codePointAt(cursor - 2);
if (codePoint === undefined || codePoint < 0x1f1e6 || codePoint > 0x1f1ff) {
break;
}
count += 1;
cursor -= 2;
}
return count;
}
/**
* What should actually be painted this frame.
*
* `streaming` says whether more text is still expected. While it is, a trailing
* fragment waits for the rest of its cluster; once the turn ends everything
* received is painted, because nothing more is coming.
*/
export function visibleRevealedText(
state: TextRevealState,
options?: { streaming?: boolean },
): string {
if (state.revealed >= state.target.length) {
return options?.streaming ? trimIncompleteTrailingCluster(state.target) : state.target;
}
return state.target.slice(0, clampToSafeRevealBoundary(state.target, state.revealed));
}
+37 -5
View File
@@ -51,6 +51,7 @@ import type {
} from "@getpaseo/protocol/agent-types";
import type { AgentScreenAgent } from "@/hooks/use-agent-screen-state-machine";
import { useSessionStore } from "@/stores/session-store";
import { useRevealedText } from "@/hooks/use-revealed-text";
import { useFileExplorerActions } from "@/hooks/use-file-explorer-actions";
import { useLoadOlderAgentHistory } from "@/hooks/use-load-older-agent-history";
import { useSettings } from "@/hooks/use-settings";
@@ -717,15 +718,13 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
const renderThoughtItem = useCallback(
(layoutItem: StreamLayoutItem, item: Extract<StreamItem, { kind: "thought" }>) => {
return (
<ToolCallSlot
<ThoughtSlot
itemId={item.id}
onInlineDetailsExpandedChangeByItemId={setInlineDetailsExpanded}
toolName="thinking"
args={item.text}
status={item.status === "ready" ? "completed" : "executing"}
text={item.text}
status={item.status}
isLastInSequence={layoutItem.isLastInToolSequence}
defaultExpanded={autoExpandReasoning}
forceInline={autoExpandReasoning}
/>
);
},
@@ -1230,6 +1229,39 @@ interface ToolCallSlotProps extends Omit<
onInlineDetailsExpandedChangeByItemId: (itemId: string, expanded: boolean) => void;
}
interface ThoughtSlotProps {
itemId: string;
onInlineDetailsExpandedChangeByItemId: (itemId: string, expanded: boolean) => void;
text: string;
status: Extract<StreamItem, { kind: "thought" }>["status"];
isLastInSequence: boolean;
defaultExpanded: boolean;
}
// Reasoning text is paced the same way assistant text is; see @/hooks/use-revealed-text.
function ThoughtSlot({
itemId,
onInlineDetailsExpandedChangeByItemId,
text,
status,
isLastInSequence,
defaultExpanded,
}: ThoughtSlotProps) {
const revealedText = useRevealedText(text, status === "ready" ? "complete" : "streaming");
return (
<ToolCallSlot
itemId={itemId}
onInlineDetailsExpandedChangeByItemId={onInlineDetailsExpandedChangeByItemId}
toolName="thinking"
args={revealedText}
status={status === "ready" ? "completed" : "executing"}
isLastInSequence={isLastInSequence}
defaultExpanded={defaultExpanded}
forceInline={defaultExpanded}
/>
);
}
function ToolCallSlot({
itemId,
onInlineDetailsExpandedChangeByItemId,
+3 -1
View File
@@ -110,7 +110,9 @@ export type UserComposerAttachment =
| PluginResourceComposerAttachment
| { kind: "forge_issue"; item: ForgeSearchItem }
| { kind: "forge_change_request"; item: ForgeSearchItem }
// COMPAT(githubAttachmentKinds): added in v0.1.106, remove after 2026-12-28 once daemon floor >= v0.1.106
// COMPAT(githubAttachmentKinds): legacy persisted attachment kinds retained
// when forge-neutral kinds shipped in v0.2.0-beta.1. Remove after 2027-01-17
// once supported floors are >= v0.2.0 and old drafts no longer need them.
| { kind: "github_issue"; item: ForgeSearchItem }
| {
kind: "github_pr";
@@ -0,0 +1,16 @@
import Svg, { Circle, Path } from "react-native-svg";
import type { SvgPathIconProps } from "./svg-path-icon";
// Forge-neutral rendering of GitLab's manual-status gear, aligned with the
// proportions of the other pipeline status icons.
const MANUAL_STATUS_GEAR_PATH =
"M10.5 7.63V6.37l-.787-.13c-.044-.175-.132-.349-.263-.61l.481-.652-.918-.913-.657.478a2.346 2.346 0 0 0-.612-.26L7.656 3.5H6.388l-.132.783c-.219.043-.394.13-.612.26l-.657-.478-.918.913.437.652c-.131.218-.175.392-.262.61l-.744.086v1.261l.787.13c.044.218.132.392.263.61l-.438.651.92.913.655-.434c.175.086.394.173.613.26l.131.783h1.313l.131-.783c.219-.043.394-.13.613-.26l.656.478.918-.913-.48-.652c.13-.218.218-.435.262-.61l.656-.13zM7 8.283a1.285 1.285 0 0 1-1.313-1.305c0-.739.57-1.304 1.313-1.304.744 0 1.313.565 1.313 1.304 0 .74-.57 1.305-1.313 1.305z";
export function ManualStatusIcon({ size = 16, color = "currentColor" }: SvgPathIconProps) {
return (
<Svg width={size} height={size} viewBox="-0.5 -0.5 15 15">
<Circle cx={7} cy={7} r={6.25} fill="none" stroke={color} strokeWidth={1.25} />
<Path d={MANUAL_STATUS_GEAR_PATH} fill={color} />
</Svg>
);
}
+14 -2
View File
@@ -75,12 +75,14 @@ import { HighlightedCodeBlock } from "@/components/highlighted-code-block";
import { MarkdownFenceBlock } from "@/components/markdown/fence";
import type { MarkdownPhase } from "@/components/markdown/fence/types";
import { splitMarkdownBlocks } from "@/utils/split-markdown-blocks";
import { useRevealedText } from "@/hooks/use-revealed-text";
import { colorMarkdownLinkChildren } from "@/components/markdown/link-children";
import { createAssistantMarkdownParser } from "@/utils/assistant-markdown-parser";
import { formatDuration, formatMessageTimestamp } from "@/utils/time";
import { writeMarkdownToRichClipboard } from "@/utils/rich-clipboard";
import { getDefaultMarkdownClipboardEnvironment } from "@/utils/rich-clipboard-default-environment";
import { setAssistantMarkdownBlockHeight } from "@/utils/assistant-message-height-estimate";
import { isRenderProfileEnabled } from "@/utils/render-profiler";
import { getAgentAttachmentPillContent } from "@/attachments/attachment-pill-content";
import { PlanCard } from "./plan-card";
import { useToolCallSheet } from "./tool-call-sheet";
@@ -1459,6 +1461,9 @@ export const AssistantMessage = memo(function AssistantMessage({
phase,
}: AssistantMessageProps) {
const markdownParser = useMemo(createAssistantMarkdownParser, []);
// Paint a paced prefix while the turn is streaming so text arrives at a steady
// rate instead of in whatever lumps the daemon's coalescing window produced.
const revealedMessage = useRevealedText(message, phase);
const fileLinkActions = useAssistantFileLinkActions();
const handleMarkdownLinkPress = useStableEvent((url: string) => {
@@ -1897,7 +1902,7 @@ export const AssistantMessage = memo(function AssistantMessage({
};
}, [client, fileLinkActions, markdownParser, occurrenceKey, phase, serverId, workspaceRoot]);
const blocks = useMemo(() => splitMarkdownBlocks(message), [message]);
const blocks = useMemo(() => splitMarkdownBlocks(revealedMessage), [revealedMessage]);
const keyedBlocks = useMemo(
() => blocks.map((block, index) => ({ key: `block:${index}`, block })),
[blocks],
@@ -1913,9 +1918,16 @@ export const AssistantMessage = memo(function AssistantMessage({
],
[spacing],
);
const revealDataSet = useMemo(
() =>
isRenderProfileEnabled()
? { revealKey: occurrenceKey, revealLength: String(revealedMessage.length) }
: undefined,
[occurrenceKey, revealedMessage.length],
);
return (
<View testID="assistant-message" style={assistantContainerStyle}>
<View testID="assistant-message" dataSet={revealDataSet} style={assistantContainerStyle}>
{keyedBlocks.map(({ key, block }, index) => (
<AssistantMessageBlockContainer
key={key}
@@ -9,12 +9,13 @@ import {
} from "react";
interface RewindComposerRestoreContextValue {
restoreTextIfComposerEmpty: (text: string) => void;
completeRewind: (text: string) => void;
}
interface RewindComposerRestoreProviderProps {
text: string;
setText: (text: string) => void;
onRewindComplete: () => void;
children: ReactNode;
}
@@ -33,6 +34,7 @@ export function restoreComposerTextIfEmpty(input: {
export function RewindComposerRestoreProvider({
text,
setText,
onRewindComplete,
children,
}: RewindComposerRestoreProviderProps) {
const textRef = useRef(text);
@@ -41,7 +43,7 @@ export function RewindComposerRestoreProvider({
textRef.current = text;
}, [text]);
const restoreTextIfComposerEmpty = useCallback(
const completeRewind = useCallback(
(rewoundText: string) => {
const nextText = restoreComposerTextIfEmpty({
currentText: textRef.current,
@@ -50,11 +52,12 @@ export function RewindComposerRestoreProvider({
if (nextText !== textRef.current) {
setText(nextText);
}
onRewindComplete();
},
[setText],
[onRewindComplete, setText],
);
const value = useMemo(() => ({ restoreTextIfComposerEmpty }), [restoreTextIfComposerEmpty]);
const value = useMemo(() => ({ completeRewind }), [completeRewind]);
return (
<RewindComposerRestoreContext.Provider value={value}>
@@ -52,7 +52,7 @@ export function useRewindAgentMutation(input: UseRewindAgentMutationInput): {
if (!shouldRestoreComposerForRewindMode(variables.mode)) {
return;
}
composerRestore?.restoreTextIfComposerEmpty(variables.rewoundText);
composerRestore?.completeRewind(variables.rewoundText);
},
onError: (error) => {
toast.error(error instanceof Error ? error.message : t("rewind.errors.failed"));
@@ -14,9 +14,6 @@ import { FadeIn, FadeOut } from "react-native-reanimated";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import {
Check,
CircleCheck,
CircleDot,
CircleX,
Copy,
ExternalLink,
FileDiff,
@@ -42,6 +39,14 @@ import { useIsCompactFormFactor } from "@/constants/layout";
import { FloatingSurface } from "@/components/ui/floating";
import { isWeb } from "@/constants/platform";
import { useHosts } from "@/runtime/host-runtime";
import {
COUNTED_CHECK_PRESENTATIONS,
countCheckPresentations,
type CountedCheckPresentation,
} from "@/git/check-presentation";
import { formatCheckPresentationCountsLabel } from "@/git/check-presentation-copy";
import { CheckPresentationIcon, getCheckPresentationTone } from "@/git/check-presentation.view";
import { buildForgeChecksUrl } from "@/git/forge-url";
interface Rect {
x: number;
@@ -355,17 +360,11 @@ function HostRow({ serverId }: { serverId: string }): ReactElement | null {
}
const ThemedExternalLink = withUnistyles(ExternalLink);
const ThemedCircleCheck = withUnistyles(CircleCheck);
const ThemedCircleDot = withUnistyles(CircleDot);
const ThemedCircleX = withUnistyles(CircleX);
const ThemedCopy = withUnistyles(Copy);
const ThemedCheck = withUnistyles(Check);
const foregroundColorMapping = (theme: Theme) => ({ color: theme.colors.foreground });
const foregroundMutedColorMapping = (theme: Theme) => ({ color: theme.colors.foregroundMuted });
const successColorMapping = (theme: Theme) => ({ color: theme.colors.statusSuccess });
const warningColorMapping = (theme: Theme) => ({ color: theme.colors.statusWarning });
const dangerColorMapping = (theme: Theme) => ({ color: theme.colors.statusDanger });
function InfoRow({
icon: Icon,
@@ -455,51 +454,28 @@ function CopyableInfoRow({
);
}
function getChecksSummaryCounts(checks: NonNullable<PrHint["checks"]>) {
return checks.reduce(
(counts, check) => {
if (check.status === "success") counts.passed += 1;
else if (check.status === "failure") counts.failed += 1;
else if (check.status !== "skipped" && check.status !== "cancelled") counts.pending += 1;
return counts;
},
{ passed: 0, failed: 0, pending: 0 },
function ChecksSummaryPill({
count,
presentation,
}: {
count: number;
presentation: CountedCheckPresentation;
}) {
if (count === 0) return null;
return (
<View style={styles.checksSummaryPill}>
<CheckPresentationIcon presentation={presentation} size={12} />
<Text style={checksSummaryTextStyle(presentation)}>{count}</Text>
</View>
);
}
function ChecksSummaryPill({
count,
kind,
}: {
count: number;
kind: "passed" | "failed" | "pending";
}) {
if (count === 0) return null;
if (kind === "passed") {
return (
<View style={styles.checksSummaryPill}>
<ThemedCircleCheck size={12} uniProps={successColorMapping} />
<Text style={styles.checksStatusTextPassed}>{count}</Text>
</View>
);
}
if (kind === "failed") {
return (
<View style={styles.checksSummaryPill}>
<ThemedCircleX size={12} uniProps={dangerColorMapping} />
<Text style={styles.checksStatusTextFailed}>{count}</Text>
</View>
);
}
return (
<View style={styles.checksSummaryPill}>
<ThemedCircleDot size={12} uniProps={warningColorMapping} />
<Text style={styles.checksStatusTextPending}>{count}</Text>
</View>
);
function checksSummaryTextStyle(presentation: CountedCheckPresentation) {
const tone = getCheckPresentationTone(presentation);
if (tone === "success") return styles.checksStatusTextPassed;
if (tone === "danger") return styles.checksStatusTextFailed;
if (tone === "warning") return styles.checksStatusTextPending;
return styles.checksStatusTextMuted;
}
function ChecksSummaryContent({
@@ -512,7 +488,7 @@ function ChecksSummaryContent({
hovered: boolean;
}) {
const { t } = useTranslation();
const { passed, failed, pending } = getChecksSummaryCounts(checks);
const counts = countCheckPresentations(checks);
const labelStyle = hovered
? [styles.checksSummaryLabel, styles.checksSummaryLabelHovered]
@@ -529,9 +505,13 @@ function ChecksSummaryContent({
)}
<Text style={labelStyle}>{t("workspace.git.pr.sections.checks")}</Text>
<View style={styles.checksSummaryCounts}>
<ChecksSummaryPill count={passed} kind="passed" />
<ChecksSummaryPill count={failed} kind="failed" />
<ChecksSummaryPill count={pending} kind="pending" />
{COUNTED_CHECK_PRESENTATIONS.map((presentation) => (
<ChecksSummaryPill
key={presentation}
count={counts[presentation]}
presentation={presentation}
/>
))}
</View>
</>
);
@@ -546,9 +526,16 @@ function ChecksSummaryPressable({
forge: PrHint["forge"];
url: string;
}) {
const { t } = useTranslation();
const counts = countCheckPresentations(checks);
const accessibilityLabel = formatCheckPresentationCountsLabel(
counts,
t("workspace.git.pr.sections.checks"),
t,
);
const handlePress = useCallback(() => {
void openExternalUrl(`${url}/checks`);
}, [url]);
void openExternalUrl(buildForgeChecksUrl(forge, url) ?? url);
}, [forge, url]);
const renderChildren = useCallback(
({ hovered }: { pressed: boolean; hovered?: boolean }) => (
@@ -558,7 +545,12 @@ function ChecksSummaryPressable({
);
return (
<Pressable style={checksSummaryPressableStyle} onPress={handlePress}>
<Pressable
accessibilityLabel={accessibilityLabel}
accessibilityRole="link"
style={checksSummaryPressableStyle}
onPress={handlePress}
>
{renderChildren}
</Pressable>
);
@@ -672,4 +664,9 @@ const styles = StyleSheet.create((theme) => ({
fontWeight: theme.fontWeight.normal,
color: theme.colors.statusSuccess,
},
checksStatusTextMuted: {
fontSize: theme.fontSize.sm,
fontWeight: theme.fontWeight.normal,
color: theme.colors.foregroundMuted,
},
}));
+25 -25
View File
@@ -21,15 +21,15 @@ import {
cancelComposerAgent,
dispatchComposerAgentMessage,
editQueuedComposerMessage,
findGithubItemByOption,
isAttachmentSelectedForGithubItem,
findForgeItemByOption,
isAttachmentSelectedForForgeItem,
openComposerAttachment,
pickAndPersistImages,
queueComposerMessage,
removeComposerAttachmentAtIndex,
sendQueuedComposerMessageNow,
toggleGithubAttachment,
toggleGithubAttachmentFromPicker,
toggleForgeAttachment,
toggleForgeAttachmentFromPicker,
type MessageSubmissionWriter,
type AttachmentPersister,
type ComposerCancelClient,
@@ -961,19 +961,19 @@ describe("openComposerAttachment", () => {
});
});
describe("toggleGithubAttachment", () => {
describe("toggleForgeAttachment", () => {
it("appends a GitHub issue when not already attached", () => {
const next = toggleGithubAttachment([], issueItem);
const next = toggleForgeAttachment([], issueItem);
expect(next).toEqual([{ kind: "forge_issue", item: issueItem }]);
});
it("appends a GitHub PR when not already attached", () => {
const next = toggleGithubAttachment([], prItem);
const next = toggleForgeAttachment([], prItem);
expect(next).toEqual([{ kind: "forge_change_request", item: prItem }]);
});
it("removes an existing GitHub item with the same kind+number", () => {
const next = toggleGithubAttachment([{ kind: "github_issue", item: issueItem }], issueItem);
const next = toggleForgeAttachment([{ kind: "github_issue", item: issueItem }], issueItem);
expect(next).toEqual([]);
});
@@ -983,7 +983,7 @@ describe("toggleGithubAttachment", () => {
{ kind: "github_pr", item: prItem },
];
const otherIssue: ForgeSearchItem = { ...issueItem, number: 999 };
const next = toggleGithubAttachment(start, otherIssue);
const next = toggleForgeAttachment(start, otherIssue);
expect(next).toEqual([
{ kind: "github_issue", item: issueItem },
{ kind: "github_pr", item: prItem },
@@ -992,41 +992,41 @@ describe("toggleGithubAttachment", () => {
});
});
describe("toggleGithubAttachmentFromPicker", () => {
describe("toggleForgeAttachmentFromPicker", () => {
it("marks an existing GitHub item as removed when picker toggle removes it", () => {
const markGithubAttachmentRemoved = vi.fn();
const markForgeAttachmentRemoved = vi.fn();
const attachment: UserComposerAttachment = { kind: "github_pr", item: prItem };
const next = toggleGithubAttachmentFromPicker({
const next = toggleForgeAttachmentFromPicker({
current: [attachment],
item: prItem,
markGithubAttachmentRemoved,
markForgeAttachmentRemoved,
});
expect(next).toEqual([]);
expect(markGithubAttachmentRemoved).toHaveBeenCalledTimes(1);
expect(markGithubAttachmentRemoved).toHaveBeenCalledWith(attachment);
expect(markForgeAttachmentRemoved).toHaveBeenCalledTimes(1);
expect(markForgeAttachmentRemoved).toHaveBeenCalledWith(attachment);
});
it("does not mark a GitHub item removed when picker toggle adds it", () => {
const markGithubAttachmentRemoved = vi.fn();
const markForgeAttachmentRemoved = vi.fn();
const next = toggleGithubAttachmentFromPicker({
const next = toggleForgeAttachmentFromPicker({
current: [],
item: issueItem,
markGithubAttachmentRemoved,
markForgeAttachmentRemoved,
});
expect(next).toEqual([{ kind: "forge_issue", item: issueItem }]);
expect(markGithubAttachmentRemoved).not.toHaveBeenCalled();
expect(markForgeAttachmentRemoved).not.toHaveBeenCalled();
});
});
describe("findGithubItemByOption / isAttachmentSelectedForGithubItem", () => {
describe("findForgeItemByOption / isAttachmentSelectedForForgeItem", () => {
it("locates items via their composite kind:number id", () => {
expect(findGithubItemByOption([issueItem, prItem], "issue:101")).toBe(issueItem);
expect(findGithubItemByOption([issueItem, prItem], "change_request:202")).toBe(prItem);
expect(findGithubItemByOption([issueItem], "change_request:404")).toBeUndefined();
expect(findForgeItemByOption([issueItem, prItem], "issue:101")).toBe(issueItem);
expect(findForgeItemByOption([issueItem, prItem], "change_request:202")).toBe(prItem);
expect(findForgeItemByOption([issueItem], "change_request:404")).toBeUndefined();
});
it("recognizes when an attachment list already contains a matching GitHub item", () => {
@@ -1035,7 +1035,7 @@ describe("findGithubItemByOption / isAttachmentSelectedForGithubItem", () => {
{ kind: "github_issue", item: issueItem },
reviewWorkspaceAttachment("ignored"),
];
expect(isAttachmentSelectedForGithubItem(attachments, issueItem)).toBe(true);
expect(isAttachmentSelectedForGithubItem(attachments, prItem)).toBe(false);
expect(isAttachmentSelectedForForgeItem(attachments, issueItem)).toBe(true);
expect(isAttachmentSelectedForForgeItem(attachments, prItem)).toBe(false);
});
});
+11 -11
View File
@@ -356,7 +356,9 @@ function isForgeAttachment(
return (
attachment.kind === "forge_issue" ||
attachment.kind === "forge_change_request" ||
// COMPAT(githubAttachmentKinds): added in v0.1.106, remove after 2026-12-28 once daemon floor >= v0.1.106
// COMPAT(githubAttachmentKinds): accept legacy persisted attachment kinds
// until 2027-01-17, when supported floors are >= v0.2.0 and old drafts no
// longer require them.
attachment.kind === "github_issue" ||
attachment.kind === "github_pr"
);
@@ -376,17 +378,17 @@ export function toggleForgeAttachment(
return [...current, buildForgeAttachment(item)];
}
interface ToggleGithubAttachmentFromPickerInput {
interface ToggleForgeAttachmentFromPickerInput {
current: UserComposerAttachment[];
item: ForgeSearchItem;
markGithubAttachmentRemoved: (attachment: UserComposerAttachment) => void;
markForgeAttachmentRemoved: (attachment: UserComposerAttachment) => void;
}
export function toggleGithubAttachmentFromPicker({
export function toggleForgeAttachmentFromPicker({
current,
item,
markGithubAttachmentRemoved,
}: ToggleGithubAttachmentFromPickerInput): UserComposerAttachment[] {
markForgeAttachmentRemoved,
}: ToggleForgeAttachmentFromPickerInput): UserComposerAttachment[] {
const existingAttachment = current.find(
(attachment) =>
isForgeAttachment(attachment) &&
@@ -394,19 +396,19 @@ export function toggleGithubAttachmentFromPicker({
attachment.item.number === item.number,
);
if (existingAttachment) {
markGithubAttachmentRemoved(existingAttachment);
markForgeAttachmentRemoved(existingAttachment);
}
return toggleForgeAttachment(current, item);
}
export function findGithubItemByOption(
export function findForgeItemByOption(
items: readonly ForgeSearchItem[],
optionId: string,
): ForgeSearchItem | undefined {
return items.find((candidate) => `${candidate.kind}:${candidate.number}` === optionId);
}
export function isAttachmentSelectedForGithubItem(
export function isAttachmentSelectedForForgeItem(
current: readonly ComposerAttachment[],
item: ForgeSearchItem,
): boolean {
@@ -417,5 +419,3 @@ export function isAttachmentSelectedForGithubItem(
attachment.item.number === item.number,
);
}
export const toggleGithubAttachment = toggleForgeAttachment;
@@ -21,7 +21,9 @@ interface SplitComposerAttachmentsOptions {
export function resolveComposerAttachmentSubmitFormat(input: {
supportsForgeAttachments?: boolean;
}): ComposerAttachmentSubmitFormat {
// COMPAT(forgeSearch): added in v0.1.106, remove github_search fallback after 2026-12-28.
// COMPAT(githubAttachmentKinds): emit legacy GitHub attachments for daemons
// predating forge-neutral attachments. Remove after 2027-01-17 once the
// supported daemon floor is >= v0.2.0.
return input.supportsForgeAttachments === false ? "legacy-github" : "forge";
}
@@ -34,7 +36,9 @@ export function splitComposerAttachmentsForSubmit(
} {
const images: ImageAttachment[] = [];
const agentAttachments: AgentAttachment[] = [];
// COMPAT(forgeSearch): added in v0.1.106, remove github_search fallback after 2026-12-28.
// COMPAT(githubAttachmentKinds): emit legacy GitHub attachments for daemons
// predating forge-neutral attachments. Remove after 2027-01-17 once the
// supported daemon floor is >= v0.2.0.
const buildSearchAttachment =
options.format === "legacy-github"
? buildLegacyGitHubAttachmentFromSearchItem
@@ -9,7 +9,7 @@ import { describe, expect, it, vi } from "vitest";
import type { UserComposerAttachment } from "@/attachments/types";
import type { ForgeSearchClient } from "@/git/use-forge-search-query";
import type { ForgeSearchItem, ForgeSearchResponse } from "@getpaseo/protocol/messages";
import { useComposerGithubAutoAttach } from "./auto-attach";
import { useComposerForgeAutoAttach } from "./forge-auto-attach";
type ForgeSearchPayload = ForgeSearchResponse["payload"];
@@ -48,6 +48,31 @@ const issue202: ForgeSearchItem = {
headRefName: null,
};
const gitlabMr73: ForgeSearchItem = {
forge: "gitlab",
kind: "change_request",
number: 73,
title: "Attach MR",
url: "https://gitlab.com/acme/paseo/-/merge_requests/73",
state: "opened",
body: null,
labels: [],
projectPath: "acme/paseo",
baseRefName: "main",
headRefName: "feature",
};
const giteaIssue27: ForgeSearchItem = {
forge: "gitea",
kind: "issue",
number: 27,
title: "Attach Gitea issue",
url: "https://gitea.example.com/acme/paseo/issues/27",
state: "open",
body: null,
labels: [],
};
interface SearchCall {
cwd: string;
query: string;
@@ -58,8 +83,8 @@ interface HarnessInput {
initialAttachments?: UserComposerAttachment[];
initialCwd?: string;
initialText?: string;
onPullRequestDetected?: () => void;
onPullRequestAdded?: (item: ForgeSearchItem) => void;
onChangeRequestDetected?: () => void;
onChangeRequestAdded?: (item: ForgeSearchItem) => void;
remote?: string | null;
}
@@ -111,7 +136,7 @@ function useHarness(client: ForgeSearchClient, input: HarnessInput = {}) {
const [attachments, setAttachments] = useState<UserComposerAttachment[]>(
input.initialAttachments ?? [],
);
const autoAttach = useComposerGithubAutoAttach({
const autoAttach = useComposerForgeAutoAttach({
text,
remoteUrl: input.remote ?? remoteUrl,
attachments,
@@ -120,8 +145,8 @@ function useHarness(client: ForgeSearchClient, input: HarnessInput = {}) {
serverId: "server-1",
cwd: workingDirectory,
setAttachments,
onPullRequestDetected: input.onPullRequestDetected,
onPullRequestAdded: input.onPullRequestAdded,
onChangeRequestDetected: input.onChangeRequestDetected,
onChangeRequestAdded: input.onChangeRequestAdded,
});
return {
@@ -132,7 +157,7 @@ function useHarness(client: ForgeSearchClient, input: HarnessInput = {}) {
attachments,
setAttachments,
isResolving: autoAttach.isResolving,
markGithubAttachmentRemoved: autoAttach.markGithubAttachmentRemoved,
markForgeAttachmentRemoved: autoAttach.markForgeAttachmentRemoved,
};
}
@@ -143,12 +168,12 @@ async function flushDebounce() {
});
}
describe("useComposerGithubAutoAttach", () => {
describe("useComposerForgeAutoAttach", () => {
it("adds a matching pasted GitHub PR URL as a composer attachment", async () => {
vi.useFakeTimers();
const client = createSearchClient([pr101]);
const onPullRequestDetected = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestDetected }), {
const onChangeRequestDetected = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestDetected }), {
wrapper: createWrapper(),
});
@@ -156,7 +181,7 @@ describe("useComposerGithubAutoAttach", () => {
result.current.setText("Please review https://github.com/acme/paseo/pull/101");
});
expect(result.current.isResolving).toBe(true);
expect(onPullRequestDetected).toHaveBeenCalledTimes(1);
expect(onChangeRequestDetected).toHaveBeenCalledTimes(1);
await flushDebounce();
expect(result.current.attachments).toEqual([{ kind: "forge_change_request", item: pr101 }]);
@@ -165,6 +190,56 @@ describe("useComposerGithubAutoAttach", () => {
vi.useRealTimers();
});
it("adds a matching pasted GitLab MR URL as a composer attachment", async () => {
vi.useFakeTimers();
const client = createSearchClient([gitlabMr73]);
const onChangeRequestDetected = vi.fn();
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(
() =>
useHarness(client, {
onChangeRequestDetected,
onChangeRequestAdded,
remote: "git@gitlab.com:acme/paseo.git",
}),
{ wrapper: createWrapper() },
);
act(() => {
result.current.setText("Review https://gitlab.com/acme/paseo/-/merge_requests/73/diffs");
});
await flushDebounce();
expect(result.current.attachments).toEqual([
{ kind: "forge_change_request", item: gitlabMr73 },
]);
expect(onChangeRequestDetected).toHaveBeenCalledTimes(1);
expect(onChangeRequestAdded).toHaveBeenCalledWith(gitlabMr73);
expect(client.calls).toEqual([{ cwd, query: "73", limit: 20 }]);
vi.useRealTimers();
});
it("adds a matching pasted self-hosted Gitea issue URL", async () => {
vi.useFakeTimers();
const client = createSearchClient([giteaIssue27]);
const { result } = renderHook(
() =>
useHarness(client, {
remote: "git@gitea.example.com:acme/paseo.git",
}),
{ wrapper: createWrapper() },
);
act(() => {
result.current.setText("See https://gitea.example.com/acme/paseo/issues/27");
});
await flushDebounce();
expect(result.current.attachments).toEqual([{ kind: "forge_issue", item: giteaIssue27 }]);
expect(client.calls).toEqual([{ cwd, query: "27", limit: 20 }]);
vi.useRealTimers();
});
it("ignores URLs that do not match the current remote", async () => {
vi.useFakeTimers();
const client = createSearchClient([pr101]);
@@ -207,7 +282,7 @@ describe("useComposerGithubAutoAttach", () => {
});
act(() => {
result.current.markGithubAttachmentRemoved(initialAttachments[0]);
result.current.markForgeAttachmentRemoved(initialAttachments[0]);
result.current.setAttachments([]);
result.current.setText("Re-pasted https://github.com/acme/paseo/pull/101");
});
@@ -251,8 +326,8 @@ describe("useComposerGithubAutoAttach", () => {
.mockReturnValueOnce(firstLookup.promise)
.mockReturnValueOnce(secondLookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -267,7 +342,7 @@ describe("useComposerGithubAutoAttach", () => {
secondLookup.resolve(githubPayload([pr202], "search-202"));
await Promise.resolve();
});
expect(onPullRequestAdded).not.toHaveBeenCalled();
expect(onChangeRequestAdded).not.toHaveBeenCalled();
expect(result.current.attachments).toEqual([]);
await act(async () => {
@@ -275,7 +350,7 @@ describe("useComposerGithubAutoAttach", () => {
await Promise.resolve();
});
await vi.waitFor(() => {
expect(onPullRequestAdded.mock.calls).toEqual([[pr101], [pr202]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr101], [pr202]]);
expect(result.current.attachments).toEqual([
{ kind: "forge_change_request", item: pr101 },
{ kind: "forge_change_request", item: pr202 },
@@ -294,8 +369,8 @@ describe("useComposerGithubAutoAttach", () => {
.mockReturnValueOnce(firstLookup.promise)
.mockReturnValueOnce(secondLookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -315,7 +390,7 @@ describe("useComposerGithubAutoAttach", () => {
secondLookup.resolve(githubPayload([pr202], "search-202"));
await Promise.resolve();
});
expect(onPullRequestAdded).not.toHaveBeenCalled();
expect(onChangeRequestAdded).not.toHaveBeenCalled();
expect(result.current.attachments).toEqual([]);
expect(result.current.isResolving).toBe(true);
@@ -324,7 +399,7 @@ describe("useComposerGithubAutoAttach", () => {
await Promise.resolve();
});
await vi.waitFor(() => {
expect(onPullRequestAdded.mock.calls).toEqual([[pr101], [pr202]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr101], [pr202]]);
expect(result.current.attachments).toEqual([
{ kind: "forge_change_request", item: pr101 },
{ kind: "forge_change_request", item: pr202 },
@@ -338,8 +413,8 @@ describe("useComposerGithubAutoAttach", () => {
it("uses the latest pull request order when URLs are reordered during debounce", async () => {
vi.useFakeTimers();
const client = createSearchClient([pr101, pr202]);
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -355,7 +430,7 @@ describe("useComposerGithubAutoAttach", () => {
});
await flushDebounce();
expect(onPullRequestAdded.mock.calls).toEqual([[pr202], [pr101]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr202], [pr101]]);
expect(client.calls).toEqual([
{ cwd, query: "202", limit: 20 },
{ cwd, query: "101", limit: 20 },
@@ -373,8 +448,8 @@ describe("useComposerGithubAutoAttach", () => {
.mockReturnValueOnce(firstLookup.promise)
.mockReturnValueOnce(secondLookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -395,7 +470,7 @@ describe("useComposerGithubAutoAttach", () => {
firstLookup.resolve(githubPayload([pr101], "search-101"));
await Promise.resolve();
});
expect(onPullRequestAdded).not.toHaveBeenCalled();
expect(onChangeRequestAdded).not.toHaveBeenCalled();
expect(result.current.attachments).toEqual([]);
expect(result.current.isResolving).toBe(true);
@@ -404,7 +479,7 @@ describe("useComposerGithubAutoAttach", () => {
await Promise.resolve();
});
await vi.waitFor(() => {
expect(onPullRequestAdded.mock.calls).toEqual([[pr202], [pr101]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr202], [pr101]]);
expect(result.current.attachments).toEqual([
{ kind: "forge_change_request", item: pr202 },
{ kind: "forge_change_request", item: pr101 },
@@ -425,8 +500,8 @@ describe("useComposerGithubAutoAttach", () => {
.mockReturnValueOnce(firstLookup.promise)
.mockReturnValueOnce(secondLookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -451,7 +526,7 @@ describe("useComposerGithubAutoAttach", () => {
await Promise.resolve();
});
await vi.waitFor(() => {
expect(onPullRequestAdded.mock.calls).toEqual([[pr101]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr101]]);
});
vi.useRealTimers();
});
@@ -462,8 +537,8 @@ describe("useComposerGithubAutoAttach", () => {
const client: ForgeSearchClient = {
searchForge: vi.fn().mockReturnValue(lookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -491,7 +566,7 @@ describe("useComposerGithubAutoAttach", () => {
await vi.waitFor(() => {
expect(result.current.attachments).toEqual([{ kind: "forge_change_request", item: pr101 }]);
expect(result.current.isResolving).toBe(false);
expect(onPullRequestAdded.mock.calls).toEqual([[pr101]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr101]]);
});
vi.useRealTimers();
});
@@ -506,8 +581,8 @@ describe("useComposerGithubAutoAttach", () => {
.mockReturnValueOnce(firstLookup.promise)
.mockReturnValueOnce(secondLookup.promise),
};
const onPullRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onPullRequestAdded }), {
const onChangeRequestAdded = vi.fn();
const { result } = renderHook(() => useHarness(client, { onChangeRequestAdded }), {
wrapper: createWrapper(),
});
@@ -522,7 +597,7 @@ describe("useComposerGithubAutoAttach", () => {
secondLookup.resolve(githubPayload([pr202], "search-202"));
await Promise.resolve();
});
expect(onPullRequestAdded).not.toHaveBeenCalled();
expect(onChangeRequestAdded).not.toHaveBeenCalled();
expect(result.current.isResolving).toBe(true);
act(() => {
@@ -531,7 +606,7 @@ describe("useComposerGithubAutoAttach", () => {
await flushDebounce();
await vi.waitFor(() => {
expect(onPullRequestAdded.mock.calls).toEqual([[pr202]]);
expect(onChangeRequestAdded.mock.calls).toEqual([[pr202]]);
expect(result.current.isResolving).toBe(false);
});
@@ -11,13 +11,13 @@ import {
} from "react";
import type { ComposerAttachment, UserComposerAttachment } from "@/attachments/types";
import { buildForgeSearchQueryOptions, type ForgeSearchClient } from "@/git/use-forge-search-query";
import { extractGithubRefs, type GithubRef } from "@/utils/github-refs";
import { extractForgeRefs, type ForgeRef } from "@/git/forge-refs";
import type { ForgeSearchItem } from "@getpaseo/protocol/messages";
import { isAttachmentSelectedForGithubItem, toggleGithubAttachment } from "../actions";
import { isAttachmentSelectedForForgeItem, toggleForgeAttachment } from "./actions";
const AUTO_ATTACH_DEBOUNCE_MS = 300;
interface ComposerGithubAutoAttachInput {
interface ComposerForgeAutoAttachInput {
text: string;
remoteUrl: string | null | undefined;
attachments: UserComposerAttachment[];
@@ -27,29 +27,29 @@ interface ComposerGithubAutoAttachInput {
cwd: string;
supportsForgeSearch?: boolean;
setAttachments: Dispatch<SetStateAction<UserComposerAttachment[]>>;
onPullRequestDetected?: () => void;
onPullRequestAdded?: (item: ForgeSearchItem) => void;
onChangeRequestDetected?: () => void;
onChangeRequestAdded?: (item: ForgeSearchItem) => void;
}
interface ComposerGithubAutoAttachResult {
interface ComposerForgeAutoAttachResult {
isResolving: boolean;
markGithubAttachmentRemoved: (attachment: ComposerAttachment | undefined) => void;
markForgeAttachmentRemoved: (attachment: ComposerAttachment | undefined) => void;
}
interface ActiveGithubLookup {
interface ActiveForgeLookup {
invalidate: (keys: readonly string[]) => void;
invalidateIrrelevant: (current: ComposerGithubAutoAttachInput) => void;
invalidateIrrelevant: (current: ComposerForgeAutoAttachInput) => void;
hasPending: (key: string) => boolean;
}
export function useComposerGithubAutoAttach(
params: ComposerGithubAutoAttachInput,
): ComposerGithubAutoAttachResult {
export function useComposerForgeAutoAttach(
params: ComposerForgeAutoAttachInput,
): ComposerForgeAutoAttachResult {
const queryClient = useQueryClient();
const latestRef = useRef(params);
const removedRefKeysRef = useRef(new Set<string>());
const presentPullRequestKeysRef = useRef(new Set<string>());
const activeLookupsRef = useRef(new Set<ActiveGithubLookup>());
const presentChangeRequestKeysRef = useRef(new Set<string>());
const activeLookupsRef = useRef(new Set<ActiveForgeLookup>());
const previousTargetRef = useRef({ serverId: params.serverId, cwd: params.cwd });
const [resolvingRefCounts, setResolvingRefCounts] = useState<ReadonlyMap<string, number>>(
() => new Map(),
@@ -58,15 +58,15 @@ export function useComposerGithubAutoAttach(
latestRef.current = params;
const lookupCandidateKey = getLookupCandidateKey(params, removedRefKeysRef.current);
const lookupRelevanceKey = getLookupRelevanceKey(params, removedRefKeysRef.current);
const presentPullRequestKey = getPresentPullRequestKey(params);
const presentChangeRequestKey = getPresentChangeRequestKey(params);
const hasClient = params.client !== null;
useEffect(() => {
notifyNewPullRequestRefs({
notifyNewChangeRequestRefs({
params: latestRef.current,
presentPullRequestKeysRef,
presentChangeRequestKeysRef,
});
}, [presentPullRequestKey]);
}, [presentChangeRequestKey]);
useEffect(() => {
const current = latestRef.current;
@@ -99,11 +99,11 @@ export function useComposerGithubAutoAttach(
return;
}
const refKeys = refs.map(githubRefKey);
const refKeys = refs.map(forgeRefKey);
setResolvingRefCounts((current) => addKeys(current, refKeys));
const unreleasedRefKeys = new Set(refKeys);
let lookupStarted = false;
let lookup: ActiveGithubLookup | null = null;
let lookup: ActiveForgeLookup | null = null;
const releaseResolving = (keys: readonly string[]) => {
const keysToRelease = keys.filter((key) => unreleasedRefKeys.delete(key));
if (keysToRelease.length === 0) return;
@@ -147,7 +147,7 @@ export function useComposerGithubAutoAttach(
queryClient,
]);
const markGithubAttachmentRemoved = useCallback((attachment: ComposerAttachment | undefined) => {
const markForgeAttachmentRemoved = useCallback((attachment: ComposerAttachment | undefined) => {
const key = attachmentKey(attachment);
if (key) {
removedRefKeysRef.current.add(key);
@@ -157,55 +157,55 @@ export function useComposerGithubAutoAttach(
return useMemo(
() => ({
isResolving: resolvingRefCounts.size > 0,
markGithubAttachmentRemoved,
markForgeAttachmentRemoved,
}),
[markGithubAttachmentRemoved, resolvingRefCounts.size],
[markForgeAttachmentRemoved, resolvingRefCounts.size],
);
}
function getLookupCandidateKey(
params: ComposerGithubAutoAttachInput,
params: ComposerForgeAutoAttachInput,
removedRefKeys: ReadonlySet<string>,
): string {
return getLookupCandidateRefs(params, removedRefKeys).map(githubRefKey).join("|");
return getLookupCandidateRefs(params, removedRefKeys).map(forgeRefKey).join("|");
}
function getLookupCandidateRefs(
params: ComposerGithubAutoAttachInput,
params: ComposerForgeAutoAttachInput,
removedRefKeys: ReadonlySet<string>,
): GithubRef[] {
return extractGithubRefs(params.text, params.remoteUrl).filter((ref) => {
const key = githubRefKey(ref);
return !removedRefKeys.has(key) && !hasGithubAttachment(params.attachments, ref);
): ForgeRef[] {
return extractForgeRefs(params.text, params.remoteUrl).filter((ref) => {
const key = forgeRefKey(ref);
return !removedRefKeys.has(key) && !hasForgeAttachment(params.attachments, ref);
});
}
function didLookupSourceOrderChange(
originalKeys: readonly string[],
current: ComposerGithubAutoAttachInput,
current: ComposerForgeAutoAttachInput,
removedRefKeys: ReadonlySet<string>,
): boolean {
const currentKeys = getLookupCandidateRefs(current, removedRefKeys).map(githubRefKey);
const currentKeys = getLookupCandidateRefs(current, removedRefKeys).map(forgeRefKey);
const currentKeySet = new Set(currentKeys);
const retainedOriginalKeys = originalKeys.filter((key) => currentKeySet.has(key));
return currentKeys.join("|") !== retainedOriginalKeys.join("|");
}
function getLookupRelevanceKey(
params: ComposerGithubAutoAttachInput,
params: ComposerForgeAutoAttachInput,
removedRefKeys: ReadonlySet<string>,
): string {
return extractGithubRefs(params.text, params.remoteUrl)
.map(githubRefKey)
return extractForgeRefs(params.text, params.remoteUrl)
.map(forgeRefKey)
.filter((key) => !removedRefKeys.has(key))
.sort()
.join("|");
}
function getPresentPullRequestKey(params: ComposerGithubAutoAttachInput): string {
return extractGithubRefs(params.text, params.remoteUrl)
.filter((ref) => ref.kind === "pull")
.map(githubRefKey)
function getPresentChangeRequestKey(params: ComposerForgeAutoAttachInput): string {
return extractForgeRefs(params.text, params.remoteUrl)
.filter((ref) => ref.kind === "change_request")
.map(forgeRefKey)
.sort()
.join("|");
}
@@ -216,15 +216,15 @@ function isLookupContextStillRelevant({
current,
removedRefKeys,
}: {
ref: GithubRef;
initial: ComposerGithubAutoAttachInput;
current: ComposerGithubAutoAttachInput;
ref: ForgeRef;
initial: ComposerForgeAutoAttachInput;
current: ComposerForgeAutoAttachInput;
removedRefKeys: ReadonlySet<string>;
}): boolean {
return (
current.client !== null &&
current.isConnected &&
!removedRefKeys.has(githubRefKey(ref)) &&
!removedRefKeys.has(forgeRefKey(ref)) &&
isSameLookupTarget(initial, current) &&
isRefStillPresent(ref, current)
);
@@ -235,7 +235,7 @@ function suppressRefsCarriedAcrossTargets({
previousTargetRef,
removedRefKeys,
}: {
params: ComposerGithubAutoAttachInput;
params: ComposerForgeAutoAttachInput;
previousTargetRef: RefObject<{ serverId: string; cwd: string }>;
removedRefKeys: Set<string>;
}): void {
@@ -247,29 +247,29 @@ function suppressRefsCarriedAcrossTargets({
previousTargetRef.current = { serverId: params.serverId, cwd: params.cwd };
if (!targetChanged) return;
for (const ref of extractGithubRefs(params.text, params.remoteUrl)) {
removedRefKeys.add(githubRefKey(ref));
for (const ref of extractForgeRefs(params.text, params.remoteUrl)) {
removedRefKeys.add(forgeRefKey(ref));
}
}
function notifyNewPullRequestRefs({
function notifyNewChangeRequestRefs({
params,
presentPullRequestKeysRef,
presentChangeRequestKeysRef,
}: {
params: ComposerGithubAutoAttachInput;
presentPullRequestKeysRef: RefObject<Set<string>>;
params: ComposerForgeAutoAttachInput;
presentChangeRequestKeysRef: RefObject<Set<string>>;
}): void {
const currentKeys = new Set(
extractGithubRefs(params.text, params.remoteUrl)
.filter((ref) => ref.kind === "pull")
.map(githubRefKey),
extractForgeRefs(params.text, params.remoteUrl)
.filter((ref) => ref.kind === "change_request")
.map(forgeRefKey),
);
for (const key of currentKeys) {
if (!presentPullRequestKeysRef.current.has(key)) {
params.onPullRequestDetected?.();
if (!presentChangeRequestKeysRef.current.has(key)) {
params.onChangeRequestDetected?.();
}
}
presentPullRequestKeysRef.current = currentKeys;
presentChangeRequestKeysRef.current = currentKeys;
}
function addKeys(
@@ -310,14 +310,14 @@ function attachRefs({
onSettled,
onComplete,
}: {
refs: GithubRef[];
initial: ComposerGithubAutoAttachInput;
refs: ForgeRef[];
initial: ComposerForgeAutoAttachInput;
queryClient: QueryClient;
latestRef: RefObject<ComposerGithubAutoAttachInput>;
latestRef: RefObject<ComposerForgeAutoAttachInput>;
removedRefKeys: Set<string>;
onSettled: (key: string) => void;
onComplete: (lookup: ActiveGithubLookup) => void;
}): ActiveGithubLookup {
onComplete: (lookup: ActiveForgeLookup) => void;
}): ActiveForgeLookup {
const outcomes = refs.map(() => ({
settled: false,
item: null as ForgeSearchItem | null,
@@ -332,16 +332,16 @@ function attachRefs({
if (item) {
latestRef.current.setAttachments((attachments) => {
if (
removedRefKeys.has(githubRefKey(ref)) ||
isAttachmentSelectedForGithubItem(attachments, item)
removedRefKeys.has(forgeRefKey(ref)) ||
isAttachmentSelectedForForgeItem(attachments, item)
) {
return attachments;
}
return toggleGithubAttachment(attachments, item);
return toggleForgeAttachment(attachments, item);
});
}
if (item?.kind === "change_request") {
latestRef.current.onPullRequestAdded?.(item);
latestRef.current.onChangeRequestAdded?.(item);
}
}
if (!didComplete && nextOutcomeIndex === outcomes.length) {
@@ -357,7 +357,7 @@ function attachRefs({
};
refs.forEach((ref, index) => {
const key = githubRefKey(ref);
const key = forgeRefKey(ref);
void attachRef({ ref, key, queryClient, latestRef, removedRefKeys })
.then((item) => settleOutcome(index, item))
.finally(() => {
@@ -365,12 +365,12 @@ function attachRefs({
});
});
const lookup: ActiveGithubLookup = {
const lookup: ActiveForgeLookup = {
invalidate(keys) {
const invalidKeys = new Set(keys);
const newlySettledKeys: string[] = [];
refs.forEach((ref, index) => {
const key = githubRefKey(ref);
const key = forgeRefKey(ref);
if (!invalidKeys.has(key) || index < nextOutcomeIndex) return;
if (!outcomes[index].settled) newlySettledKeys.push(key);
outcomes[index] = { settled: true, item: null };
@@ -382,14 +382,14 @@ function attachRefs({
lookup.invalidate(
refs.flatMap((ref, index) =>
isLookupContextStillRelevant({ ref, initial, current, removedRefKeys }) &&
(outcomes[index].settled || !hasGithubAttachment(current.attachments, ref))
(outcomes[index].settled || !hasForgeAttachment(current.attachments, ref))
? []
: [githubRefKey(ref)],
: [forgeRefKey(ref)],
),
);
},
hasPending(key) {
const index = refs.findIndex((ref) => githubRefKey(ref) === key);
const index = refs.findIndex((ref) => forgeRefKey(ref) === key);
return index >= 0 && !outcomes[index].settled;
},
};
@@ -403,10 +403,10 @@ async function attachRef({
latestRef,
removedRefKeys,
}: {
ref: GithubRef;
ref: ForgeRef;
key: string;
queryClient: QueryClient;
latestRef: RefObject<ComposerGithubAutoAttachInput>;
latestRef: RefObject<ComposerForgeAutoAttachInput>;
removedRefKeys: Set<string>;
}): Promise<ForgeSearchItem | null> {
const snapshot = latestRef.current;
@@ -414,11 +414,11 @@ async function attachRef({
return null;
}
const search = await fetchGithubRefSearch({ ref, snapshot, queryClient });
const search = await fetchForgeRefSearch({ ref, snapshot, queryClient });
if (!search) {
return null;
}
const item = search.items.find((candidate) => githubItemMatchesRef(candidate, ref));
const item = search.items.find((candidate) => forgeItemMatchesRef(candidate, ref));
const current = latestRef.current;
if (
!item ||
@@ -429,7 +429,7 @@ async function attachRef({
return null;
}
if (isAttachmentSelectedForGithubItem(current.attachments, item)) {
if (isAttachmentSelectedForForgeItem(current.attachments, item)) {
return null;
}
return item;
@@ -440,31 +440,31 @@ function refsReadyForLookup({
removedRefKeys,
activeLookups,
}: {
params: ComposerGithubAutoAttachInput;
params: ComposerForgeAutoAttachInput;
removedRefKeys: Set<string>;
activeLookups: ReadonlySet<ActiveGithubLookup>;
}): GithubRef[] {
activeLookups: ReadonlySet<ActiveForgeLookup>;
}): ForgeRef[] {
if (!params.client || !params.isConnected || params.cwd.trim().length === 0) {
return [];
}
return extractGithubRefs(params.text, params.remoteUrl).filter((ref) => {
const key = githubRefKey(ref);
return extractForgeRefs(params.text, params.remoteUrl).filter((ref) => {
const key = forgeRefKey(ref);
return (
!removedRefKeys.has(key) &&
![...activeLookups].some((lookup) => lookup.hasPending(key)) &&
!hasGithubAttachment(params.attachments, ref)
!hasForgeAttachment(params.attachments, ref)
);
});
}
async function fetchGithubRefSearch({
async function fetchForgeRefSearch({
ref,
snapshot,
queryClient,
}: {
ref: GithubRef;
snapshot: ComposerGithubAutoAttachInput;
ref: ForgeRef;
snapshot: ComposerForgeAutoAttachInput;
queryClient: QueryClient;
}) {
if (!snapshot.client) {
@@ -487,15 +487,15 @@ async function fetchGithubRefSearch({
}
}
function isRefStillPresent(ref: GithubRef, params: ComposerGithubAutoAttachInput): boolean {
return extractGithubRefs(params.text, params.remoteUrl).some(
(candidate) => githubRefKey(candidate) === githubRefKey(ref),
function isRefStillPresent(ref: ForgeRef, params: ComposerForgeAutoAttachInput): boolean {
return extractForgeRefs(params.text, params.remoteUrl).some(
(candidate) => forgeRefKey(candidate) === forgeRefKey(ref),
);
}
function isSameLookupTarget(
initial: ComposerGithubAutoAttachInput,
current: ComposerGithubAutoAttachInput,
initial: ComposerForgeAutoAttachInput,
current: ComposerForgeAutoAttachInput,
): boolean {
return (
initial.serverId === current.serverId &&
@@ -504,30 +504,28 @@ function isSameLookupTarget(
);
}
function hasGithubAttachment(attachments: UserComposerAttachment[], ref: GithubRef): boolean {
return attachments.some((attachment) => attachmentKey(attachment) === githubRefKey(ref));
function hasForgeAttachment(attachments: UserComposerAttachment[], ref: ForgeRef): boolean {
return attachments.some((attachment) => attachmentKey(attachment) === forgeRefKey(ref));
}
function githubItemMatchesRef(item: ForgeSearchItem, ref: GithubRef): boolean {
return item.kind === githubItemKind(ref) && item.number === ref.number;
function forgeItemMatchesRef(item: ForgeSearchItem, ref: ForgeRef): boolean {
return item.kind === forgeItemKind(ref) && item.number === ref.number;
}
function githubItemKind(ref: GithubRef): ForgeSearchItem["kind"] {
return ref.kind === "pull" ? "change_request" : "issue";
function forgeItemKind(ref: ForgeRef): ForgeSearchItem["kind"] {
return ref.kind === "change_request" ? "change_request" : "issue";
}
function githubRefKey(ref: GithubRef): string {
return `${githubItemKind(ref)}:${ref.number}`;
function forgeRefKey(ref: ForgeRef): string {
return `${forgeItemKind(ref)}:${ref.number}`;
}
function attachmentKey(attachment: ComposerAttachment | undefined): string | null {
if (
!attachment ||
attachment.kind === "image" ||
(attachment.kind !== "forge_change_request" &&
attachment.kind !== "forge_issue" &&
attachment.kind !== "github_pr" &&
attachment.kind !== "github_issue")
attachment?.kind !== "forge_change_request" &&
attachment?.kind !== "forge_issue" &&
attachment?.kind !== "github_pr" &&
attachment?.kind !== "github_issue"
) {
return null;
}
+22 -22
View File
@@ -62,14 +62,14 @@ import {
cancelComposerAgent,
dispatchComposerAgentMessage,
editQueuedComposerMessage,
findGithubItemByOption,
isAttachmentSelectedForGithubItem,
findForgeItemByOption,
isAttachmentSelectedForForgeItem,
openComposerAttachment,
pickAndPersistImages,
queueComposerMessage,
removeComposerAttachmentAtIndex,
sendQueuedComposerMessageNow,
toggleGithubAttachmentFromPicker,
toggleForgeAttachmentFromPicker,
uploadFileAttachments,
type AttachmentPersister,
type QueueWriter,
@@ -132,7 +132,7 @@ import { useCheckoutStatusQuery } from "@/git/use-status-query";
import { useCheckoutPrStatusQuery } from "@/git/use-pr-status-query";
import { getForgePresentation } from "@/git/forge";
import { ForgeBrandIcon } from "@/git/forge-icon";
import { useComposerGithubAutoAttach } from "./github/auto-attach";
import { useComposerForgeAutoAttach } from "./forge-auto-attach";
import { readClipboardImage } from "./clipboard-image";
import { normalizeNativePastedImages, type NativePastedFile } from "./native-pasted-image";
import { PluginResourceAttachmentPill, usePluginAttachmentPicker } from "@/plugins";
@@ -924,8 +924,8 @@ interface ComposerProps {
submitIcon?: "arrow" | "return";
/** Externally controlled loading state. When true, disables the submit button. */
isSubmitLoading?: boolean;
/** When true, waits for pasted GitHub links to resolve before enabling submit. */
waitForGithubAutoAttachOnSubmit?: boolean;
/** When true, waits for pasted forge links to resolve before enabling submit. */
waitForForgeAutoAttachOnSubmit?: boolean;
submitBehavior?: "clear" | "preserve-and-lock";
/** When true, blurs the input immediately when submitting. */
blurOnSubmit?: boolean;
@@ -936,8 +936,8 @@ interface ComposerProps {
attachmentScopeKeys?: readonly string[];
onOpenWorkspaceAttachment?: (attachment: WorkspaceComposerAttachment) => void;
onChangeAttachments: (updater: AttachmentListUpdater) => void;
onGithubPrDetected?: () => void;
onGithubPrAutoAttach?: (item: ForgeSearchItem) => void;
onForgeChangeRequestDetected?: () => void;
onForgeChangeRequestAutoAttach?: (item: ForgeSearchItem) => void;
cwd: string;
clearDraft: (lifecycle: "sent" | "abandoned") => void;
/** When true, auto-focuses the text input on web. */
@@ -1148,7 +1148,7 @@ function ComposerContentImpl({
submitButtonTestID,
submitIcon = "arrow",
isSubmitLoading = false,
waitForGithubAutoAttachOnSubmit = false,
waitForForgeAutoAttachOnSubmit = false,
submitBehavior = "clear",
blurOnSubmit = false,
value,
@@ -1158,8 +1158,8 @@ function ComposerContentImpl({
attachmentScopeKeys = EMPTY_ATTACHMENT_SCOPE_KEYS,
onOpenWorkspaceAttachment,
onChangeAttachments,
onGithubPrDetected,
onGithubPrAutoAttach,
onForgeChangeRequestDetected,
onForgeChangeRequestAutoAttach,
cwd,
clearDraft,
autoFocus = false,
@@ -1235,7 +1235,7 @@ function ComposerContentImpl({
const supportsForgeSearch = useSessionStore(
(state) => state.sessions[serverId]?.serverInfo?.features?.forgeSearch === true,
);
const githubAutoAttach = useComposerGithubAutoAttach({
const forgeAutoAttach = useComposerForgeAutoAttach({
text: userInput,
remoteUrl: resolveCheckoutRemoteUrl(checkoutStatusQuery.status),
attachments,
@@ -1245,8 +1245,8 @@ function ComposerContentImpl({
cwd,
supportsForgeSearch,
setAttachments: setSelectedAttachments,
onPullRequestDetected: onGithubPrDetected,
onPullRequestAdded: onGithubPrAutoAttach,
onChangeRequestDetected: onForgeChangeRequestDetected,
onChangeRequestAdded: onForgeChangeRequestAutoAttach,
});
const [cursorIndex, setCursorIndex] = useState(0);
const cursorPublication = useMemo(() => new AfterPaintPublication<number>(setCursorIndex), []);
@@ -1734,7 +1734,7 @@ function ComposerContentImpl({
const handleRemoveAttachment = useCallback(
(index: number) => {
githubAutoAttach.markGithubAttachmentRemoved(selectedAttachments[index]);
forgeAutoAttach.markForgeAttachmentRemoved(selectedAttachments[index]);
const didRemoveWorkspaceAttachment = removeAttachment({
selectedAttachments,
index,
@@ -1746,7 +1746,7 @@ function ComposerContentImpl({
removeComposerAttachmentAtIndex({ attachments: prev, index, deleteAttachments }),
);
},
[githubAutoAttach, removeAttachment, selectedAttachments, setSelectedAttachments],
[forgeAutoAttach, removeAttachment, selectedAttachments, setSelectedAttachments],
);
const handleOpenAttachment = useCallback(
@@ -2082,10 +2082,10 @@ function ComposerContentImpl({
const handleToggleGithubItem = useCallback(
(item: ForgeSearchItem) => {
const nextAttachments = toggleGithubAttachmentFromPicker({
const nextAttachments = toggleForgeAttachmentFromPicker({
current: attachments,
item,
markGithubAttachmentRemoved: githubAutoAttach.markGithubAttachmentRemoved,
markForgeAttachmentRemoved: forgeAutoAttach.markForgeAttachmentRemoved,
});
setSelectedAttachments(nextAttachments);
setIsGithubPickerOpen(false);
@@ -2093,7 +2093,7 @@ function ComposerContentImpl({
},
[
attachments,
githubAutoAttach,
forgeAutoAttach,
setSelectedAttachments,
setGithubSearchQuery,
setIsGithubPickerOpen,
@@ -2154,11 +2154,11 @@ function ComposerContentImpl({
const renderGithubPickerOption = useCallback(
({ option, active }: { option: ComboboxOption; selected: boolean; active: boolean }) => {
const item = findGithubItemByOption(githubSearchItems, option.id);
const item = findForgeItemByOption(githubSearchItems, option.id);
if (!item) {
return <View key={option.id} />;
}
const selected = isAttachmentSelectedForGithubItem(selectedAttachments, item);
const selected = isAttachmentSelectedForForgeItem(selectedAttachments, item);
return (
<GithubPickerOption
key={option.id}
@@ -2220,7 +2220,7 @@ function ComposerContentImpl({
const isSubmitLoadingVisible =
isProcessing || isSubmitLoading || isUploadingFile || pendingNativeImagePastes > 0;
const isSubmitDisabled =
isSubmitLoadingVisible || (waitForGithubAutoAttachOnSubmit && githubAutoAttach.isResolving);
isSubmitLoadingVisible || (waitForForgeAutoAttachOnSubmit && forgeAutoAttach.isResolving);
// Disable drops while submitting/uploading: the submit path clears and restores attachments,
// so a drop in that window would be lost or land on a locked draft. `disabled` hides the
@@ -23,6 +23,7 @@ import {
isTimelineResumeSnapshotAuthoritative,
planTimelineTailFetch,
} from "@/timeline/timeline-sync-plan";
import { requestTimelineReplacement } from "@/timeline/timeline-replacement";
import {
createViewedTimelineSync,
type TimelineDeliveryMode,
@@ -794,6 +795,19 @@ function SessionProviderInternal({ children, serverId, client }: SessionProvider
applyTimelineResponse(message.payload);
});
const unsubTimelineReplacement = client.on("agent.timeline.replacement", (message) => {
if (message.type !== "agent.timeline.replacement") return;
void requestTimelineReplacement(
{
fetchAgentTimeline: (agentId, request) =>
getHostRuntimeStore().fetchAgentTimeline(serverId, agentId, request),
},
message.payload.agentId,
).catch((error: unknown) => {
console.warn("[Session] timeline replacement refresh failed", { serverId, error });
});
});
const unsubProviderSubagentUpdate = client.on("agent.provider_subagents.update", (message) => {
if (message.type !== "agent.provider_subagents.update") return;
useProviderSubagentStore.getState().applyUpdate(serverId, message.payload);
@@ -989,6 +1003,7 @@ function SessionProviderInternal({ children, serverId, client }: SessionProvider
});
return () => {
unsubTimelineReplacement();
unsubAgentStream();
unsubAgentTimeline();
unsubProviderSubagentUpdate();
+9 -6
View File
@@ -50,8 +50,9 @@ function resolveAutoMergeActionsRpc(serverId: string): AutoMergeActionsRpc {
if (session?.serverInfo?.features?.checkoutForgeSetAutoMerge === true) {
return "forge";
}
// COMPAT(githubAutoMergeRpc): added in v0.1.106, remove after 2026-12-28 once
// all supported clients use checkout.forge.set_auto_merge.*.
// COMPAT(githubAutoMergeRpc): use the legacy GitHub RPC with daemons that
// predate checkout.forge.set_auto_merge.*. Remove after 2027-01-17 once the
// supported daemon floor is >= v0.2.0.
if (session?.serverInfo?.features?.checkoutGithubSetAutoMerge === true) {
return "github";
}
@@ -298,8 +299,9 @@ export const useCheckoutGitActionsStore = create<CheckoutGitActionsStoreState>()
actionId: `enable-pr-auto-merge-${method}`,
run: async () => {
const client = resolveClient(serverId);
// COMPAT(githubAutoMergeRpc): added in v0.1.106, remove after 2026-12-28 once
// all supported clients use checkout.forge.set_auto_merge.*.
// COMPAT(githubAutoMergeRpc): use the legacy GitHub RPC with daemons
// that predate checkout.forge.set_auto_merge.*. Remove after 2027-01-17
// once the supported daemon floor is >= v0.2.0.
const payload =
rpc === "forge"
? await client.checkoutForgeSetAutoMerge(cwd, { enabled: true, method })
@@ -319,8 +321,9 @@ export const useCheckoutGitActionsStore = create<CheckoutGitActionsStoreState>()
actionId: "disable-pr-auto-merge",
run: async () => {
const client = resolveClient(serverId);
// COMPAT(githubAutoMergeRpc): added in v0.1.106, remove after 2026-12-28 once
// all supported clients use checkout.forge.set_auto_merge.*.
// COMPAT(githubAutoMergeRpc): use the legacy GitHub RPC with daemons
// that predate checkout.forge.set_auto_merge.*. Remove after 2027-01-17
// once the supported daemon floor is >= v0.2.0.
const payload =
rpc === "forge"
? await client.checkoutForgeSetAutoMerge(cwd, { enabled: false })
@@ -0,0 +1,36 @@
import { beforeAll, describe, expect, it } from "vitest";
import { i18n } from "@/i18n/i18next";
import {
formatCheckPresentationCountsLabel,
getCheckPresentationStatusLabel,
} from "./check-presentation-copy";
describe("check presentation copy", () => {
beforeAll(async () => {
await i18n.changeLanguage("en");
});
it("formats counts in canonical presentation order and omits empty categories", () => {
expect(
formatCheckPresentationCountsLabel(
{
success: 2,
failure: 0,
warning: 1,
actionRequired: 1,
manual: 1,
pending: 0,
},
"Checks",
i18n.t,
),
).toBe("Checks, Passed: 2, Warnings: 1, Action required: 1, Manual: 1");
});
it("uses presentation policy for row status labels", () => {
expect(
getCheckPresentationStatusLabel({ status: "success", traits: ["warning"] }, i18n.t),
).toBe("Warning");
expect(getCheckPresentationStatusLabel({ status: "cancelled" }, i18n.t)).toBe("Cancelled");
});
});
@@ -0,0 +1,55 @@
import type { TFunction } from "i18next";
import {
COUNTED_CHECK_PRESENTATIONS,
classifyCheck,
type CheckPresentationCounts,
type CountedCheckPresentation,
type PresentableCheck,
} from "./check-presentation";
const CHECK_PRESENTATION_COUNT_KEYS = {
success: "sidebar.workspace.checks.passed",
failure: "sidebar.workspace.checks.failed",
warning: "sidebar.workspace.checks.warning",
actionRequired: "sidebar.workspace.checks.actionRequired",
manual: "sidebar.workspace.checks.manual",
pending: "sidebar.workspace.checks.pending",
} as const satisfies Record<CountedCheckPresentation, string>;
const CHECK_PRESENTATION_STATUS_KEYS = {
success: "workspace.git.pr.accessibility.checkStatus.passed",
failure: "workspace.git.pr.accessibility.checkStatus.failed",
warning: "workspace.git.pr.accessibility.checkStatus.warning",
actionRequired: "workspace.git.pr.accessibility.checkStatus.actionRequired",
manual: "workspace.git.pr.accessibility.checkStatus.manual",
pending: "workspace.git.pr.accessibility.checkStatus.pending",
} as const satisfies Record<CountedCheckPresentation, string>;
export function getCheckPresentationCountLabel(
presentation: CountedCheckPresentation,
count: number,
t: TFunction,
): string {
return t(CHECK_PRESENTATION_COUNT_KEYS[presentation], { count });
}
export function formatCheckPresentationCountsLabel(
counts: CheckPresentationCounts,
heading: string,
t: TFunction,
): string {
const labels = COUNTED_CHECK_PRESENTATIONS.flatMap((presentation) => {
const count = counts[presentation];
return count > 0 ? [getCheckPresentationCountLabel(presentation, count, t)] : [];
});
return [heading, ...labels].join(", ");
}
export function getCheckPresentationStatusLabel(check: PresentableCheck, t: TFunction): string {
const presentation = classifyCheck(check);
if (presentation !== "ignored") return t(CHECK_PRESENTATION_STATUS_KEYS[presentation]);
if (check.status === "cancelled") {
return t("workspace.git.pr.accessibility.checkStatus.cancelled");
}
return t("workspace.git.pr.accessibility.checkStatus.skipped");
}
@@ -0,0 +1,42 @@
import { describe, expect, it } from "vitest";
import { classifyCheck, countCheckPresentations } from "./check-presentation";
describe("check presentation", () => {
it.each([
[{ status: "failure", traits: ["warning", "action_required"] }, "actionRequired"],
[{ status: "pending", traits: ["manual", "action_required"] }, "actionRequired"],
[{ status: "success", traits: ["action_required"] }, "actionRequired"],
[{ status: "success", traits: ["warning"] }, "warning"],
[{ status: "skipped", traits: ["manual"] }, "manual"],
[{ status: "success" }, "success"],
[{ status: "failure" }, "failure"],
[{ status: "skipped" }, "ignored"],
[{ status: "cancelled" }, "ignored"],
[{ status: "pending" }, "pending"],
[{ status: "success", traits: ["future-forge-trait"] }, "success"],
[{ status: "future-provider-state" }, "pending"],
] as const)("classifies %o as %s", (check, expected) => {
expect(classifyCheck(check)).toBe(expected);
});
it("counts mutually exclusive presentation categories", () => {
expect(
countCheckPresentations([
{ status: "success" },
{ status: "failure" },
{ status: "success", traits: ["warning"] },
{ status: "pending", traits: ["action_required"] },
{ status: "pending" },
{ status: "skipped", traits: ["manual"] },
{ status: "skipped" },
]),
).toEqual({
success: 1,
failure: 1,
warning: 1,
actionRequired: 1,
manual: 1,
pending: 1,
});
});
});
@@ -0,0 +1,59 @@
import {
CHECK_TRAIT_ACTION_REQUIRED,
CHECK_TRAIT_MANUAL,
CHECK_TRAIT_WARNING,
} from "@getpaseo/protocol/check-traits";
export interface PresentableCheck {
status: string;
traits?: readonly string[];
}
export const COUNTED_CHECK_PRESENTATIONS = [
"success",
"failure",
"warning",
"actionRequired",
"manual",
"pending",
] as const;
export type CountedCheckPresentation = (typeof COUNTED_CHECK_PRESENTATIONS)[number];
export type CheckPresentation = CountedCheckPresentation | "ignored";
export const ATTENTION_CHECK_PRESENTATIONS = [
"failure",
"warning",
"actionRequired",
] as const satisfies readonly CountedCheckPresentation[];
export type CheckPresentationCounts = Record<CountedCheckPresentation, number>;
export function classifyCheck(check: PresentableCheck): CheckPresentation {
const traits = check.traits ?? [];
if (traits.includes(CHECK_TRAIT_ACTION_REQUIRED)) return "actionRequired";
if (traits.includes(CHECK_TRAIT_WARNING)) return "warning";
if (traits.includes(CHECK_TRAIT_MANUAL)) return "manual";
if (check.status === "success") return "success";
if (check.status === "failure") return "failure";
if (check.status === "skipped" || check.status === "cancelled") return "ignored";
return "pending";
}
export function countCheckPresentations(
checks: readonly PresentableCheck[],
): CheckPresentationCounts {
const counts: CheckPresentationCounts = {
success: 0,
failure: 0,
warning: 0,
actionRequired: 0,
manual: 0,
pending: 0,
};
for (const check of checks) {
const presentation = classifyCheck(check);
if (presentation !== "ignored") counts[presentation] += 1;
}
return counts;
}
@@ -0,0 +1,83 @@
import type { ReactNode } from "react";
import { withUnistyles } from "react-native-unistyles";
import { CircleCheck, CircleDot, CircleSlash, CircleX } from "lucide-react-native";
import { ManualStatusIcon } from "@/components/icons/manual-status-icon";
import type { Theme } from "@/styles/theme";
import type { CheckPresentation } from "./check-presentation";
const ThemedCircleCheck = withUnistyles(CircleCheck);
const ThemedCircleDot = withUnistyles(CircleDot);
const ThemedCircleSlash = withUnistyles(CircleSlash);
const ThemedCircleX = withUnistyles(CircleX);
const ThemedManualStatusIcon = withUnistyles(ManualStatusIcon);
const foregroundMutedColorMapping = (theme: Theme) => ({ color: theme.colors.foregroundMuted });
const successColorMapping = (theme: Theme) => ({ color: theme.colors.statusSuccess });
const dangerColorMapping = (theme: Theme) => ({ color: theme.colors.statusDanger });
const warningColorMapping = (theme: Theme) => ({ color: theme.colors.statusWarning });
export type CheckPresentationTone = "success" | "danger" | "warning" | "muted";
interface CheckPresentationViewPolicy {
tone: CheckPresentationTone;
renderIcon: (size: number) => ReactNode;
}
const CHECK_PRESENTATION_VIEW_POLICY: Record<CheckPresentation, CheckPresentationViewPolicy> = {
success: {
tone: "success",
renderIcon(size) {
return <ThemedCircleCheck size={size} uniProps={successColorMapping} />;
},
},
failure: {
tone: "danger",
renderIcon(size) {
return <ThemedCircleX size={size} uniProps={dangerColorMapping} />;
},
},
warning: {
tone: "warning",
renderIcon(size) {
return <ThemedCircleX size={size} uniProps={warningColorMapping} />;
},
},
actionRequired: {
tone: "warning",
renderIcon(size) {
return <ThemedManualStatusIcon size={size} uniProps={warningColorMapping} />;
},
},
manual: {
tone: "muted",
renderIcon(size) {
return <ThemedManualStatusIcon size={size} uniProps={foregroundMutedColorMapping} />;
},
},
pending: {
tone: "warning",
renderIcon(size) {
return <ThemedCircleDot size={size} uniProps={warningColorMapping} />;
},
},
ignored: {
tone: "muted",
renderIcon(size) {
return <ThemedCircleSlash size={size} uniProps={foregroundMutedColorMapping} />;
},
},
};
export function getCheckPresentationTone(presentation: CheckPresentation): CheckPresentationTone {
return CHECK_PRESENTATION_VIEW_POLICY[presentation].tone;
}
export function CheckPresentationIcon({
presentation,
size,
}: {
presentation: CheckPresentation;
size: number;
}): ReactNode {
return CHECK_PRESENTATION_VIEW_POLICY[presentation].renderIcon(size);
}
@@ -27,6 +27,20 @@ export interface ForgeUrlGrammar {
blobInfix: string;
/** Line/range anchor, e.g. github "#L1-L5" vs gitlab "#L1-5". */
lineAnchor: (start: number, end?: number) => string;
/** Suffix for the change request's checks/pipelines overview. */
changeRequestChecksSuffix?: string;
/**
* Web-path infixes used when recognizing pasted links for this forge. The
* parser anchors each infix after the current remote's full repository path,
* so links for another repository are never auto-attached.
*/
referencePaths?: readonly ForgeReferencePath[];
}
export interface ForgeReferencePath {
kind: "change_request" | "issue";
/** Path between the repository path and the numeric local id. */
infix: string;
}
/** Line/range anchor shared by every GitHub-family forge (github, gitea, forgejo, codeberg). */
@@ -39,6 +53,10 @@ export const GITEA_FAMILY_URL_GRAMMAR: ForgeUrlGrammar = {
treeInfix: "/src/branch/",
blobInfix: "/src/branch/",
lineAnchor: GITHUB_LINE_ANCHOR,
referencePaths: [
{ kind: "change_request", infix: "/pulls/" },
{ kind: "issue", infix: "/issues/" },
],
};
export type ForgeSpecificEnvelope = { forge: string } & Record<string, unknown>;
+104
View File
@@ -0,0 +1,104 @@
import { describe, expect, it } from "vitest";
import { extractForgeRefs, parseForgeRef } from "./forge-refs";
describe("parseForgeRef", () => {
it.each([
[
"GitHub pull request",
"git@github.com:getpaseo/paseo.git",
"https://github.com/getpaseo/paseo/pull/994/files?diff=split#discussion_r123",
{ kind: "change_request", number: 994 },
],
[
"GitHub issue",
"https://github.com/getpaseo/paseo.git",
"https://github.com/getpaseo/paseo/issues/456",
{ kind: "issue", number: 456 },
],
[
"nested GitLab merge request",
"git@gitlab.com:group/subgroup/project.git",
"https://gitlab.com/group/subgroup/project/-/merge_requests/73/diffs",
{ kind: "change_request", number: 73 },
],
[
"GitLab issue",
"https://gitlab.com/group/project.git",
"https://gitlab.com/group/project/-/issues/19#note_1",
{ kind: "issue", number: 19 },
],
[
"self-hosted Gitea pull request",
"ssh://git@git.example.com/acme/project.git",
"https://git.example.com/acme/project/pulls/31/files",
{ kind: "change_request", number: 31 },
],
[
"Forgejo issue",
"git@forgejo.example.com:acme/project.git",
"https://forgejo.example.com/acme/project/issues/27",
{ kind: "issue", number: 27 },
],
[
"Codeberg pull request",
"git@codeberg.org:acme/project.git",
"https://codeberg.org/acme/project/pulls/8",
{ kind: "change_request", number: 8 },
],
])("parses a matching %s URL", (_label, remote, text, expected) => {
expect(parseForgeRef(text, remote)).toEqual(expected);
});
it("canonicalizes a cloud SSH alias to its web host", () => {
expect(
parseForgeRef(
"https://github.com/getpaseo/paseo/pull/994",
"ssh://git@ssh.github.com/getpaseo/paseo.git",
),
).toEqual({ kind: "change_request", number: 994 });
});
it("ignores another host, repository, and malformed local id", () => {
const remote = "git@gitlab.com:group/project.git";
expect(
parseForgeRef("https://other.example/group/project/-/merge_requests/1", remote),
).toBeNull();
expect(parseForgeRef("https://gitlab.com/group/other/-/merge_requests/1", remote)).toBeNull();
expect(
parseForgeRef("https://gitlab.com/group/project/-/merge_requests/1oops", remote),
).toBeNull();
});
it("does not apply another forge's route grammar to a known cloud host", () => {
expect(
parseForgeRef(
"https://github.com/getpaseo/paseo/pulls/31",
"git@github.com:getpaseo/paseo.git",
),
).toBeNull();
expect(
parseForgeRef("https://gitlab.com/group/project/pull/31", "git@gitlab.com:group/project.git"),
).toBeNull();
});
});
describe("extractForgeRefs", () => {
it("extracts matching references in text order and deduplicates them", () => {
const text = [
"[MR](https://gitlab.com/group/project/-/merge_requests/12/diffs).",
"https://gitlab.com/group/project/-/issues/34#note_1,",
"https://gitlab.com/group/project/-/merge_requests/12",
"https://gitlab.com/group/other/-/issues/99",
].join("\n");
expect(extractForgeRefs(text, "git@gitlab.com:group/project.git")).toEqual([
{ kind: "change_request", number: 12 },
{ kind: "issue", number: 34 },
]);
});
it("returns no references without text or a valid remote", () => {
expect(extractForgeRefs("", "git@github.com:getpaseo/paseo.git")).toEqual([]);
expect(extractForgeRefs("https://github.com/getpaseo/paseo/pull/1", null)).toEqual([]);
});
});
+145
View File
@@ -0,0 +1,145 @@
import { FORGE_DEFINITIONS } from "@getpaseo/protocol/forge-manifest";
import { normalizeHost, parseGitRemoteLocation } from "@getpaseo/protocol/git-remote";
import type { ForgeReferencePath } from "@/git/client-forge-module";
import { CLIENT_FORGE_LOGIC_MODULES } from "@/git/forges";
export interface ForgeRef {
kind: ForgeReferencePath["kind"];
number: number;
}
const WEB_URL_PATTERN = /https?:\/\/[^\s<>"'`)\]]+/giu;
const TRAILING_SENTENCE_PUNCTUATION = /[.,;:!]+$/u;
interface RemoteReferenceTarget {
webHosts: ReadonlySet<string>;
repoPath: string;
/** Known cloud forge ids, or null when a self-hosted domain is unresolved. */
forgeIds: ReadonlySet<string> | null;
}
/**
* Finds issue and change-request URLs belonging to the current repository.
* Route syntax comes entirely from the app forge registry: adding a forge's
* `urlGrammar.referencePaths` makes composer auto-attachment work without a
* central forge switch.
*/
export function extractForgeRefs(
text: string | null | undefined,
remoteUrl: string | null | undefined,
): ForgeRef[] {
const target = resolveRemoteReferenceTarget(remoteUrl);
const body = text?.trim();
if (!target || !body) {
return [];
}
const refs: ForgeRef[] = [];
const seen = new Set<string>();
for (const match of body.matchAll(WEB_URL_PATTERN)) {
const candidate = parsePastedWebUrl(match[0]);
if (!candidate || !target.webHosts.has(normalizeHost(candidate.hostname))) {
continue;
}
const pathname = decodePathname(candidate.pathname);
if (!pathname) {
continue;
}
for (const referencePath of registeredReferencePaths(target.forgeIds)) {
const ref = parseReferencePath(pathname, target.repoPath, referencePath);
if (!ref) {
continue;
}
const key = forgeRefKey(ref);
if (!seen.has(key)) {
seen.add(key);
refs.push(ref);
}
break;
}
}
return refs;
}
export function parseForgeRef(
text: string | null | undefined,
remoteUrl: string | null | undefined,
): ForgeRef | null {
return extractForgeRefs(text, remoteUrl)[0] ?? null;
}
function resolveRemoteReferenceTarget(
remoteUrl: string | null | undefined,
): RemoteReferenceTarget | null {
if (!remoteUrl) {
return null;
}
const remote = parseGitRemoteLocation(remoteUrl);
if (!remote) {
return null;
}
const webHosts = new Set([remote.host]);
const forgeIds = new Set<string>();
for (const definition of FORGE_DEFINITIONS) {
const cloudHosts = definition.cloudHosts?.map(normalizeHost) ?? [];
if (cloudHosts.includes(remote.host)) {
forgeIds.add(definition.id);
for (const host of cloudHosts) {
webHosts.add(host);
}
}
}
return {
webHosts,
repoPath: remote.path,
forgeIds: forgeIds.size > 0 ? forgeIds : null,
};
}
function parsePastedWebUrl(raw: string): URL | null {
try {
const parsed = new URL(raw.replace(TRAILING_SENTENCE_PUNCTUATION, ""));
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed : null;
} catch {
return null;
}
}
function decodePathname(pathname: string): string | null {
try {
return decodeURIComponent(pathname);
} catch {
return null;
}
}
function registeredReferencePaths(
forgeIds: ReadonlySet<string> | null,
): readonly ForgeReferencePath[] {
return CLIENT_FORGE_LOGIC_MODULES.flatMap((module) =>
!forgeIds || forgeIds.has(module.id) ? (module.urlGrammar?.referencePaths ?? []) : [],
);
}
function parseReferencePath(
pathname: string,
repoPath: string,
referencePath: ForgeReferencePath,
): ForgeRef | null {
const prefix = `/${repoPath}${referencePath.infix}`;
if (!pathname.toLowerCase().startsWith(prefix.toLowerCase())) {
return null;
}
const suffix = pathname.slice(prefix.length);
const numberText = suffix.match(/^(\d+)(?:\/|$)/u)?.[1];
if (!numberText) {
return null;
}
const number = Number.parseInt(numberText, 10);
return Number.isSafeInteger(number) && number > 0 ? { kind: referencePath.kind, number } : null;
}
function forgeRefKey(ref: ForgeRef): string {
return `${ref.kind}:${ref.number}`;
}
+26 -1
View File
@@ -1,5 +1,30 @@
import { describe, expect, it } from "vitest";
import { buildForgeBlobUrl, buildForgeBranchTreeUrl, hasForgeWebUrls } from "./forge-url";
import {
buildForgeBlobUrl,
buildForgeBranchTreeUrl,
buildForgeChecksUrl,
hasForgeWebUrls,
} from "./forge-url";
describe("buildForgeChecksUrl", () => {
it.each([
[
"github",
"https://github.com/acme/repo/pull/12",
"https://github.com/acme/repo/pull/12/checks",
],
[
"gitlab",
"https://gitlab.com/acme/repo/-/merge_requests/12",
"https://gitlab.com/acme/repo/-/merge_requests/12/pipelines",
],
["codeberg", "https://codeberg.org/acme/repo/pulls/12", null],
["bitbucket", "https://bitbucket.org/acme/repo/pull-requests/12", null],
["gitlab", "not a url", null],
] as const)("maps the %s checks URL", (forge, url, expected) => {
expect(buildForgeChecksUrl(forge, url)).toBe(expected);
});
});
describe("buildForgeBranchTreeUrl", () => {
it("builds a branch-specific GitHub tree URL", () => {
+17
View File
@@ -27,6 +27,23 @@ export interface ForgeBranchTreeUrlInput {
branch: string | null | undefined;
}
export function buildForgeChecksUrl(forge: string, changeRequestUrl: string): string | null {
const suffix = getClientForgeLogicModule(forge)?.urlGrammar?.changeRequestChecksSuffix;
if (!suffix) {
return null;
}
try {
const url = new URL(changeRequestUrl);
if (url.protocol !== "http:" && url.protocol !== "https:") {
return null;
}
url.pathname = `${url.pathname.replace(/\/$/, "")}${suffix}`;
return url.toString();
} catch {
return null;
}
}
interface ForgeWebLocation {
host: string;
/** Non-default port for a self-hosted http(s) origin, or undefined. */
+4 -14
View File
@@ -7,7 +7,8 @@ import {
type MergeCapability,
} from "@/git/client-forge-module";
import type { CheckoutPrMergeMethod } from "@getpaseo/protocol/messages";
import { mapCheckStatus, type CheckStatus } from "@/git/pull-request-panel/check-status";
import { CHECK_TRAIT_WARNING } from "@getpaseo/protocol/check-traits";
import { mapGiteaCommitState } from "@getpaseo/protocol/gitea-status";
const GiteaMergeFactsSchema = z
.object({
@@ -20,18 +21,6 @@ const GiteaMergeFactsSchema = z
type GiteaMergeFacts = z.infer<typeof GiteaMergeFactsSchema>;
// forgeSpecific.ciStatus carries Gitea's raw aggregate CI string. Server twin:
// packages/server/src/services/gitea-service.ts (mapGiteaCommitStatus) — "warning"
// and "error" are terminal, non-passing states, but the generic mapCheckStatus
// would show them as pending, so interpret them here where the module owns Gitea
// facts.
function mapGiteaCiStatus(ciStatus: string): CheckStatus {
if (ciStatus === "warning" || ciStatus === "error") {
return "failure";
}
return mapCheckStatus(ciStatus);
}
const GITEA_MERGE_METHODS: CheckoutPrMergeMethod[] = ["merge", "squash", "rebase"];
function deriveGiteaMergeCapability(gitea: GiteaMergeFacts): MergeCapability {
@@ -62,7 +51,8 @@ export const giteaForgeLogic = {
return {
provider: forge,
name: "CI",
status: mapGiteaCiStatus(facts.ciStatus),
status: mapGiteaCommitState(facts.ciStatus),
...(facts.ciStatus === "warning" ? { traits: [CHECK_TRAIT_WARNING] } : {}),
url: status.url,
};
},
+5
View File
@@ -86,6 +86,11 @@ export const githubForgeLogic = {
treeInfix: "/tree/",
blobInfix: "/blob/",
lineAnchor: GITHUB_LINE_ANCHOR,
changeRequestChecksSuffix: "/checks",
referencePaths: [
{ kind: "change_request", infix: "/pull/" },
{ kind: "issue", infix: "/issues/" },
],
},
facts: defineForgeFacts({
family: "github",
+49 -26
View File
@@ -4,29 +4,25 @@ import {
type ClientForgeLogicModule,
type MergeCapability,
} from "@/git/client-forge-module";
import type { CheckoutPrMergeMethod } from "@getpaseo/protocol/messages";
import type { CheckoutPipelineJob, CheckoutPrMergeMethod } from "@getpaseo/protocol/messages";
import {
CHECK_TRAIT_ACTION_REQUIRED,
CHECK_TRAIT_MANUAL,
CHECK_TRAIT_WARNING,
} from "@getpaseo/protocol/check-traits";
import { GITLAB_ACTIVE_PIPELINE_STATUS_SET } from "@getpaseo/protocol/gitlab-pipeline";
import type { CheckStatus } from "@/git/pull-request-panel/check-status";
import {
classifyCheck,
countCheckPresentations,
type CheckPresentation,
type CheckPresentationCounts,
type PresentableCheck,
} from "@/git/check-presentation";
const gitlabLineAnchor = (start: number, end?: number): string =>
end && end > start ? `#L${start}-${end}` : `#L${start}`;
/**
* Canonical set of GitLab pipeline statuses that count as "still active" (a
* pipeline that has not reached a terminal state). Server-side twin:
* packages/server/src/services/gitlab-facts.ts (GITLAB_ACTIVE_PIPELINE_STATUSES),
* duplicated because the app can't depend on the server package.
*/
const GITLAB_ACTIVE_PIPELINE_STATUSES = [
"created",
"waiting_for_resource",
"preparing",
"pending",
"running",
"scheduled",
] as const;
const GITLAB_ACTIVE_PIPELINE_STATUS_SET = new Set<string>(GITLAB_ACTIVE_PIPELINE_STATUSES);
export function isPipelineActiveStatus(status: string): boolean {
return GITLAB_ACTIVE_PIPELINE_STATUS_SET.has(status);
}
@@ -38,23 +34,45 @@ export function mapPipelineStatus(status: string): CheckStatus {
return "success";
case "failed":
return "failure";
case "running":
case "pending":
case "created":
case "waiting_for_resource":
case "preparing":
case "scheduled":
case "manual":
return "pending";
case "canceled":
case "cancelled":
case "skipped":
return "skipped";
default:
// "manual" and every active transitional status (see
// GITLAB_ACTIVE_PIPELINE_STATUSES) render as pending.
return "pending";
}
}
type GitlabPipelineJobPresentationInput = Pick<CheckoutPipelineJob, "status" | "allowFailure">;
function toPresentableGitlabPipelineJob(job: GitlabPipelineJobPresentationInput): PresentableCheck {
const status = mapPipelineStatus(job.status);
if (job.status === "manual") {
return {
status,
traits: job.allowFailure
? [CHECK_TRAIT_MANUAL]
: [CHECK_TRAIT_MANUAL, CHECK_TRAIT_ACTION_REQUIRED],
};
}
if (status === "failure" && job.allowFailure) return { status, traits: [CHECK_TRAIT_WARNING] };
return { status };
}
export function classifyGitlabPipelineJob(
job: GitlabPipelineJobPresentationInput,
): CheckPresentation {
return classifyCheck(toPresentableGitlabPipelineJob(job));
}
export function countGitlabPipelineJobs(
jobs: readonly CheckoutPipelineJob[],
): CheckPresentationCounts {
return countCheckPresentations(jobs.map(toPresentableGitlabPipelineJob));
}
const GitlabMergeFactsSchema = z
.object({
forge: z.literal("gitlab"),
@@ -146,6 +164,11 @@ export const gitlabForgeLogic = {
treeInfix: "/-/tree/",
blobInfix: "/-/blob/",
lineAnchor: gitlabLineAnchor,
changeRequestChecksSuffix: "/pipelines",
referencePaths: [
{ kind: "change_request", infix: "/-/merge_requests/" },
{ kind: "issue", infix: "/-/issues/" },
],
},
facts: defineForgeFacts({
family: "gitlab",
+31 -48
View File
@@ -12,24 +12,23 @@ import {
} from "@/git/client-forge-module";
import { openExternalUrl } from "@/utils/open-external-url";
import { formatDuration } from "@/utils/time";
import { COUNTED_CHECK_PRESENTATIONS } from "@/git/check-presentation";
import { CheckPresentationIcon } from "@/git/check-presentation.view";
import {
CheckStatusIcon,
CheckPresentationSummaryPill,
Section,
SUMMARY_DANGER_ICON,
SUMMARY_SUCCESS_ICON,
SUMMARY_WARNING_ICON,
SummaryPill,
foregroundMutedColorMapping,
sectionKitStyles,
successColorMapping,
} from "@/git/pull-request-panel/section-kit";
import { useGitLabPipeline } from "@/git/pull-request-panel/use-pipeline";
import {
classifyGitlabPipelineJob,
deriveGitlabApprovals,
deriveGitlabPipelineSummary,
countGitlabPipelineJobs,
GitlabMergeFactsSchema,
isPipelineActiveStatus,
mapPipelineStatus,
type GitlabApprovals,
type GitlabMergeFacts,
type GitlabPipelineSummary,
@@ -99,23 +98,6 @@ function formatPipelineDuration(seconds: number | null): string {
return formatDuration(seconds * 1000);
}
interface PipelineJobCounts {
passed: number;
failed: number;
pending: number;
}
function countPipelineJobs(jobs: CheckoutPipelineJob[]): PipelineJobCounts {
const counts: PipelineJobCounts = { passed: 0, failed: 0, pending: 0 };
for (const job of jobs) {
const status = mapPipelineStatus(job.status);
if (status === "success") counts.passed += 1;
else if (status === "failure") counts.failed += 1;
else if (status === "pending") counts.pending += 1;
}
return counts;
}
function GitLabPipelineSection({
serverId,
cwd,
@@ -144,13 +126,13 @@ function GitLabPipelineSection({
});
const counts = useMemo(
() => countPipelineJobs((pipeline?.stages ?? []).flatMap((stage) => stage.jobs)),
() => countGitlabPipelineJobs((pipeline?.stages ?? []).flatMap((stage) => stage.jobs)),
[pipeline],
);
const totalCounted = counts.passed + counts.failed + counts.pending;
const totalCounted = Object.values(counts).reduce((total, count) => total + count, 0);
const showBreakdown = !isPlaceholderData && totalCounted > 0;
const displayCounts = showBreakdown ? counts : { passed: 0, failed: 0, pending: 0 };
const displayCounts = showBreakdown ? counts : countGitlabPipelineJobs([]);
const handleOpenPipeline = useCallback(() => {
if (summary.url) {
@@ -160,25 +142,15 @@ function GitLabPipelineSection({
const sectionSummary = (
<>
<SummaryPill
count={displayCounts.passed}
icon={SUMMARY_SUCCESS_ICON}
variant="success"
testID="pr-pane-pipeline-passed"
/>
<SummaryPill
count={displayCounts.failed}
icon={SUMMARY_DANGER_ICON}
variant="danger"
testID="pr-pane-pipeline-failed"
/>
<SummaryPill
count={displayCounts.pending}
icon={SUMMARY_WARNING_ICON}
variant="warning"
testID="pr-pane-pipeline-pending"
/>
{showBreakdown ? null : <CheckStatusIcon status={summary.status} />}
{COUNTED_CHECK_PRESENTATIONS.map((presentation) => (
<CheckPresentationSummaryPill
key={presentation}
count={displayCounts[presentation]}
presentation={presentation}
testID={`pr-pane-pipeline-${presentation}`}
/>
))}
{showBreakdown ? null : <GitLabPipelineStatusIcon status={summary.rawStatus} />}
</>
);
@@ -195,7 +167,7 @@ function GitLabPipelineSection({
disabled={!summary.url}
testID="pr-pane-pipeline-link"
>
<CheckStatusIcon status={summary.status} />
<GitLabPipelineStatusIcon status={summary.rawStatus} />
<Text style={sectionKitStyles.checkName} numberOfLines={1}>
{`Pipeline #${summary.id}`}
</Text>
@@ -234,7 +206,7 @@ function PipelineStageGroup({ stage }: { stage: CheckoutPipelineStage }) {
return (
<View>
<View style={styles.pipelineStageHeader}>
<CheckStatusIcon status={mapPipelineStatus(stage.status)} />
<GitLabPipelineStatusIcon status={stage.status} />
<Text style={styles.pipelineStageName} numberOfLines={1}>
{stage.name}
</Text>
@@ -256,7 +228,7 @@ function PipelineJobRow({ job }: { job: CheckoutPipelineJob }) {
const duration = formatPipelineDuration(job.durationSeconds);
return (
<Pressable onPress={handlePress} style={jobRowPressableStyle} disabled={!job.url}>
<CheckStatusIcon status={mapPipelineStatus(job.status)} />
<GitLabPipelineStatusIcon status={job.status} allowFailure={job.allowFailure} />
<Text style={sectionKitStyles.checkName} numberOfLines={1}>
{job.name}
</Text>
@@ -272,6 +244,17 @@ function PipelineJobRow({ job }: { job: CheckoutPipelineJob }) {
);
}
function GitLabPipelineStatusIcon({
status,
allowFailure = false,
}: {
status: string;
allowFailure?: boolean;
}) {
const presentation = classifyGitlabPipelineJob({ status, allowFailure });
return <CheckPresentationIcon presentation={presentation} size={14} />;
}
export const gitlabForgeView = {
id: "gitlab",
icon: GitLabIcon,
+4 -5
View File
@@ -31,11 +31,10 @@ function deriveForgeMergeCapability(facts: unknown): MergeCapability | null {
* Per-forge derivation lives on client forge modules; this stays the single
* neutral entry point the action policy reads.
*
* COMPAT(forgeSpecific): added in v0.1.106, remove after 2026-12-27. A daemon
* predating forgeSpecific emits only the legacy `status.github` field. When
* forgeSpecific is absent we synthesize the github arm from those legacy facts
* so GitHub merge-method restrictions and auto-merge state are not lost against
* an old daemon.
* COMPAT(forgeSpecific): forgeSpecific shipped in v0.2.0-beta.1. A daemon
* predating it emits only the legacy `status.github` field. When forgeSpecific
* is absent we synthesize the GitHub arm from those legacy facts. Remove after
* 2027-01-17 once the supported daemon floor is >= v0.2.0.
*/
export function deriveMergeCapability(
forgeSpecific: unknown,
+8 -2
View File
@@ -1,4 +1,5 @@
import { normalizeForge, type Forge } from "@/git/forge";
import type { PresentableCheck } from "@/git/check-presentation";
export interface PrHint {
url: string;
@@ -6,16 +7,21 @@ export interface PrHint {
state: "open" | "merged" | "closed";
/** Forge backing this change request, so badges render the right brand mark. */
forge: Forge;
checks?: Array<{ name: string; status: string; url: string | null }>;
checks?: PrHintCheck[];
checksStatus?: "none" | "pending" | "success" | "failure";
reviewDecision?: "approved" | "changes_requested" | "pending" | null;
}
export interface PrHintCheck extends PresentableCheck {
name: string;
url: string | null;
}
interface PrStatusLike {
url: string;
state: string;
isMerged: boolean;
checks?: Array<{ name: string; status: string; url: string | null }>;
checks?: PrHintCheck[];
checksStatus?: string;
reviewDecision?: string | null;
forge?: string;
+3 -2
View File
@@ -12,8 +12,9 @@ export function normalizeCheckoutPrStatusPayload(
): CheckoutPrStatusPayload {
return {
...payload,
// COMPAT(forgeAuthState): added in v0.1.106, remove after 2026-12-27 once
// all supported daemons send authState.
// COMPAT(forgeAuthState): normalize the legacy GitHub boolean for daemons
// predating v0.2.0-beta.1. Remove after 2027-01-17 once the supported daemon
// floor is >= v0.2.0.
authState:
parseForgeAuthState(payload.authState) ??
(payload.githubFeaturesEnabled ? "authenticated" : "unauthenticated"),
@@ -1,10 +1,12 @@
import { useCallback, useState } from "react";
import type { CheckStatus } from "./check-status";
import type { CheckPresentation } from "@/git/check-presentation";
/** Per-mounted PR panel state; never shared with another tab instance. */
export function useCheckGroupState() {
const [collapsedGroups, setCollapsedGroups] = useState<ReadonlySet<CheckStatus>>(() => new Set());
const toggle = useCallback((status: CheckStatus) => {
const [collapsedGroups, setCollapsedGroups] = useState<ReadonlySet<CheckPresentation>>(
() => new Set(),
);
const toggle = useCallback((status: CheckPresentation) => {
setCollapsedGroups((current) => {
const next = new Set(current);
if (!next.delete(status)) next.add(status);
@@ -4,19 +4,17 @@
* maps its raw CI strings onto this frozen union. Forge-specific vocabularies
* (e.g. GitLab pipeline statuses) live in the owning forge module.
*/
export type CheckStatus = "success" | "failure" | "pending" | "skipped";
export type CheckStatus = "success" | "failure" | "pending" | "skipped" | "cancelled";
export function mapCheckStatus(status: string): CheckStatus {
if (
status === "success" ||
status === "failure" ||
status === "pending" ||
status === "skipped"
status === "skipped" ||
status === "cancelled"
) {
return status;
}
if (status === "cancelled") {
return "skipped";
}
return "pending";
}
@@ -1,7 +1,7 @@
import Svg, { Circle } from "react-native-svg";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import type { Theme } from "@/styles/theme";
import type { CheckStatus } from "./check-status";
import type { CheckPresentation } from "@/git/check-presentation";
import type { ChecksSummary } from "./checks-summary";
/**
@@ -18,20 +18,23 @@ const SEGMENT_GAP = 2;
/** Floor for a segment, so one failure among twenty checks is still a visible mark. */
const MIN_SEGMENT = 1.5;
type ChecksPalette = Record<CheckStatus, string> & { track: string };
type ChecksPalette = Record<CheckPresentation, string> & { track: string };
const paletteMapping = (theme: Theme): { palette: ChecksPalette } => ({
palette: {
actionRequired: theme.colors.statusWarning,
warning: theme.colors.statusWarning,
failure: theme.colors.statusDanger,
pending: theme.colors.statusWarning,
manual: theme.colors.foregroundMuted,
success: theme.colors.statusSuccess,
skipped: theme.colors.foregroundExtraMuted,
ignored: theme.colors.foregroundExtraMuted,
track: theme.colors.surface3,
},
});
interface RingSegment {
status: CheckStatus;
status: CheckPresentation;
/** Painted arc length. */
dash: number;
/** Distance from twelve o'clock to where this segment starts. */
@@ -5,12 +5,13 @@ import { ChevronDown, ChevronRight, MessageSquarePlus } from "lucide-react-nativ
import { Button } from "@/components/ui/button";
import { openExternalUrl } from "@/utils/open-external-url";
import { ICON_SIZE } from "@/styles/theme";
import type { CheckStatus } from "./check-status";
import { classifyCheck, type CheckPresentation } from "@/git/check-presentation";
import { CheckPresentationIcon } from "@/git/check-presentation.view";
import { ChecksRing } from "./checks-ring";
import { summarizeChecks, type ChecksGroup } from "./checks-summary";
import { canAddPullRequestCheckLogsToChat } from "./context-attachment";
import type { PrPaneCheck } from "./data";
import { CheckStatusIcon, foregroundMutedColorMapping, sectionKitStyles } from "./section-kit";
import { foregroundMutedColorMapping, sectionKitStyles } from "./section-kit";
import { useCheckGroupState } from "./check-group-state";
const ThemedChevronDown = withUnistyles(ChevronDown);
@@ -26,10 +27,13 @@ const LIST_MAX_HEIGHT = 268;
* The three statuses the pane has always labelled for tests. Skipped has no id because
* nothing asserts on it.
*/
const PART_TEST_ID: Partial<Record<CheckStatus, string>> = {
const PART_TEST_ID: Partial<Record<CheckPresentation, string>> = {
actionRequired: "pr-pane-check-action-required",
warning: "pr-pane-check-warning",
success: "pr-pane-check-passed",
failure: "pr-pane-check-failed",
pending: "pr-pane-check-pending",
manual: "pr-pane-check-manual",
};
/**
@@ -137,7 +141,7 @@ function CheckGroup({
}: {
group: ChecksGroup;
collapsed: boolean;
onToggle: (status: CheckStatus) => void;
onToggle: (status: CheckPresentation) => void;
attachEnabled: boolean;
loadingCheckKeys: ReadonlySet<string>;
onAddLogsToChat: (check: PrPaneCheck) => void;
@@ -194,7 +198,7 @@ function CheckRow({
);
return (
<Pressable onPress={handlePress} style={rowPressableStyle} testID="pr-pane-check-row">
<CheckStatusIcon status={check.status} />
<CheckPresentationIcon presentation={classifyCheck(check)} size={14} />
<Text style={sectionKitStyles.checkName} numberOfLines={1}>
{check.name}
</Text>
@@ -1,4 +1,4 @@
import type { CheckStatus } from "./check-status";
import { classifyCheck, type CheckPresentation } from "@/git/check-presentation";
import type { PrPaneCheck } from "./data";
/**
@@ -6,25 +6,32 @@ import type { PrPaneCheck } from "./data";
* waiting on, then what needs no attention. Skipped trails everything because it is the
* only status that says nothing about whether the run is going well.
*/
const STATUS_ORDER = [
const PRESENTATION_ORDER = [
"actionRequired",
"warning",
"failure",
"pending",
"manual",
"success",
"skipped",
] as const satisfies readonly CheckStatus[];
"ignored",
] as const satisfies readonly CheckPresentation[];
/** How each status reads inside a count phrase: "2 failing", "4 in progress". */
const STATUS_NOUN: Record<CheckStatus, string> = {
const PRESENTATION_NOUN: Record<CheckPresentation, string> = {
actionRequired: "needs action",
warning: "warning",
failure: "failing",
pending: "in progress",
manual: "manual",
success: "successful",
skipped: "skipped",
ignored: "skipped",
};
/** The worst thing happening in the run, which is what the headline and the ring report. */
export type ChecksOutcome = "failure" | "pending" | "success" | "none";
export type ChecksOutcome = "actionRequired" | "failure" | "pending" | "success" | "none";
const OUTCOME_HEADLINE: Record<ChecksOutcome, string> = {
actionRequired: "Some checks need your attention",
failure: "Some checks were not successful",
pending: "Some checks haven't completed yet",
success: "All checks have passed",
@@ -32,14 +39,14 @@ const OUTCOME_HEADLINE: Record<ChecksOutcome, string> = {
};
export interface ChecksCountPart {
status: CheckStatus;
status: CheckPresentation;
count: number;
/** e.g. "2 failing" */
text: string;
}
export interface ChecksGroup {
status: CheckStatus;
status: CheckPresentation;
/** e.g. "2 failing checks" */
label: string;
checks: readonly PrPaneCheck[];
@@ -69,20 +76,20 @@ export function summarizeChecks(checks: readonly PrPaneCheck[]): ChecksSummary {
const groups: ChecksGroup[] = [];
const parts: ChecksCountPart[] = [];
for (const status of STATUS_ORDER) {
const matching = checks.filter((check) => check.status === status);
for (const status of PRESENTATION_ORDER) {
const matching = checks.filter((check) => classifyCheck(check) === status);
if (matching.length === 0) {
continue;
}
groups.push({
status,
label: `${matching.length} ${STATUS_NOUN[status]} ${countNoun(matching.length)}`,
label: `${matching.length} ${PRESENTATION_NOUN[status]} ${countNoun(matching.length)}`,
checks: matching,
});
parts.push({
status,
count: matching.length,
text: `${matching.length} ${STATUS_NOUN[status]}`,
text: `${matching.length} ${PRESENTATION_NOUN[status]}`,
});
}
@@ -107,7 +114,15 @@ function selectOutcome(checks: readonly PrPaneCheck[]): ChecksOutcome {
if (checks.length === 0) {
return "none";
}
if (checks.some((check) => check.status === "failure")) {
if (checks.some((check) => classifyCheck(check) === "actionRequired")) {
return "actionRequired";
}
if (
checks.some((check) => {
const presentation = classifyCheck(check);
return presentation === "failure" || presentation === "warning";
})
) {
return "failure";
}
if (checks.some((check) => check.status === "pending")) {
@@ -1,9 +1,14 @@
import { describe, expect, it } from "vitest";
import type {
CheckoutPipelineJob,
CheckoutPrStatusResponse,
PullRequestTimelineResponse,
} from "@getpaseo/protocol/messages";
import { isPipelineActiveStatus, mapPipelineStatus } from "@/git/forges/gitlab";
import {
countGitlabPipelineJobs,
isPipelineActiveStatus,
mapPipelineStatus,
} from "@/git/forges/gitlab";
import { IDENTITY_COLOR_NAMES, identityColor } from "@/styles/identity-colors";
import {
deriveAvatarColor,
@@ -108,7 +113,7 @@ describe("mapPrPaneData", () => {
);
});
it("drops checks with null URLs to preserve the pressable check contract", () => {
it("keeps checks with null URLs by linking them to the pull request", () => {
const data = mapPrPaneData(
status({
checks: [
@@ -126,6 +131,12 @@ describe("mapPrPaneData", () => {
status: "success",
url: "https://example.com/checks/1",
},
{
provider: "github",
name: "legacy status",
status: "pending",
url: "https://github.com/getpaseo/paseo/pull/42",
},
]);
});
@@ -141,9 +152,20 @@ describe("mapPrPaneData", () => {
duration: "1m",
},
{ name: "failure", status: "failure", url: "https://example.com/2" },
{ name: "pending", status: "pending", url: "https://example.com/3" },
{
name: "approval",
status: "pending",
traits: ["action_required"],
url: "https://example.com/3",
},
{ name: "skipped", status: "skipped", url: "https://example.com/4" },
{ name: "cancelled", status: "cancelled", url: "https://example.com/5" },
{
name: "manual",
status: "skipped",
traits: ["manual"],
url: "https://example.com/6",
},
],
}),
baseTimeline,
@@ -159,9 +181,27 @@ describe("mapPrPaneData", () => {
url: "https://example.com/1",
},
{ provider: "github", name: "failure", status: "failure", url: "https://example.com/2" },
{ provider: "github", name: "pending", status: "pending", url: "https://example.com/3" },
{
provider: "github",
name: "approval",
status: "pending",
traits: ["action_required"],
url: "https://example.com/3",
},
{ provider: "github", name: "skipped", status: "skipped", url: "https://example.com/4" },
{ provider: "github", name: "cancelled", status: "skipped", url: "https://example.com/5" },
{
provider: "github",
name: "cancelled",
status: "cancelled",
url: "https://example.com/5",
},
{
provider: "github",
name: "manual",
status: "skipped",
traits: ["manual"],
url: "https://example.com/6",
},
]);
});
@@ -588,7 +628,7 @@ describe("mapPrPaneData", () => {
]);
});
it("keeps Forgejo branding for aggregate Gitea-family CI status", () => {
it("keeps Forgejo branding and warning presentation for aggregate CI status", () => {
const data = mapPrPaneData(
status({
forge: "forgejo",
@@ -598,7 +638,7 @@ describe("mapPrPaneData", () => {
forge: "gitea",
mergeable: true,
hasMerged: false,
ciStatus: "failure",
ciStatus: "warning",
},
}),
baseTimeline,
@@ -611,6 +651,7 @@ describe("mapPrPaneData", () => {
provider: "forgejo",
name: "CI",
status: "failure",
traits: ["warning"],
url: "https://forgejo.example.com/group/repo/pulls/7",
},
]);
@@ -667,16 +708,48 @@ describe("mapPipelineStatus", () => {
expect(mapPipelineStatus("created")).toBe("pending");
expect(mapPipelineStatus("waiting_for_resource")).toBe("pending");
expect(mapPipelineStatus("preparing")).toBe("pending");
expect(mapPipelineStatus("canceling")).toBe("pending");
expect(mapPipelineStatus("scheduled")).toBe("pending");
expect(mapPipelineStatus("anything-else")).toBe("pending");
});
it("separates blocking outcomes from allowed failures and optional manual jobs", () => {
const job = (id: number, jobStatus: string, allowFailure: boolean): CheckoutPipelineJob => ({
id,
name: `job-${id}`,
stage: "test",
status: jobStatus,
rawStatus: jobStatus,
url: null,
allowFailure,
durationSeconds: null,
});
expect(
countGitlabPipelineJobs([
job(1, "success", false),
job(2, "failed", false),
job(3, "failed", true),
job(4, "pending", false),
job(5, "manual", true),
job(6, "manual", false),
]),
).toEqual({
success: 1,
failure: 1,
warning: 1,
actionRequired: 1,
manual: 1,
pending: 1,
});
});
it("marks running and queued pipeline statuses as live for polling", () => {
expect(isPipelineActiveStatus("running")).toBe(true);
expect(isPipelineActiveStatus("pending")).toBe(true);
expect(isPipelineActiveStatus("created")).toBe(true);
expect(isPipelineActiveStatus("waiting_for_resource")).toBe(true);
expect(isPipelineActiveStatus("preparing")).toBe(true);
expect(isPipelineActiveStatus("canceling")).toBe(true);
expect(isPipelineActiveStatus("scheduled")).toBe(true);
expect(isPipelineActiveStatus("success")).toBe(false);
expect(isPipelineActiveStatus("failed")).toBe(false);
+24 -25
View File
@@ -3,6 +3,7 @@ import type {
PullRequestTimelineResponse,
} from "@getpaseo/protocol/messages";
import { type Forge, getForgePresentation } from "@/git/forge";
import type { PresentableCheck } from "@/git/check-presentation";
import { parseClientForgeFacts } from "@/git/forges";
import type { ForgeSpecificStatusFacts } from "@/git/merge-capability";
import { deriveIdentityColorName, identityColor } from "@/styles/identity-colors";
@@ -22,7 +23,7 @@ export interface PullRequestProviderMetadata {
url?: string | null;
}
export interface PrPaneCheck {
export interface PrPaneCheck extends PresentableCheck {
provider: PullRequestProvider;
name: string;
workflow?: string;
@@ -32,6 +33,8 @@ export interface PrPaneCheck {
* running one has been going ("running 2m"). Absent when the forge reports neither.
*/
timing?: string;
isManual?: boolean;
requiresAction?: boolean;
url: string;
/**
* Forge-neutral reference for fetching this check's detail/logs on demand. Any
@@ -201,7 +204,7 @@ function derivePrState(status: NonNullable<CheckoutPrStatus>): PrState {
}
function mapChecks(status: NonNullable<CheckoutPrStatus>, forge: Forge): PrPaneCheck[] {
const checks = (status.checks ?? []).flatMap((check) => mapCheck(check, forge));
const checks = (status.checks ?? []).map((check) => mapCheck(check, forge, status.url));
if (checks.length > 0) {
return checks;
}
@@ -211,31 +214,27 @@ function mapChecks(status: NonNullable<CheckoutPrStatus>, forge: Forge): PrPaneC
function mapCheck(
check: NonNullable<CheckoutPrStatus>["checks"][number],
forge: Forge,
): PrPaneCheck[] {
if (check.url === null) {
return [];
}
fallbackUrl: string,
): PrPaneCheck {
const status = mapCheckStatus(check.status);
const timing = formatCheckTiming(check.duration, status);
return [
{
provider: forge,
name: check.name,
status,
url: check.url,
...(check.workflow ? { workflow: check.workflow } : {}),
...(timing ? { timing } : {}),
...(check.checkRunId !== undefined || check.workflowRunId !== undefined
? {
detailRef: {
...(check.checkRunId !== undefined ? { checkRunId: check.checkRunId } : {}),
...(check.workflowRunId !== undefined ? { workflowRunId: check.workflowRunId } : {}),
},
}
: {}),
},
];
return {
provider: forge,
name: check.name,
status,
...(check.traits ? { traits: check.traits } : {}),
url: check.url ?? fallbackUrl,
...(check.workflow ? { workflow: check.workflow } : {}),
...(timing ? { timing } : {}),
...(check.checkRunId !== undefined || check.workflowRunId !== undefined
? {
detailRef: {
...(check.checkRunId !== undefined ? { checkRunId: check.checkRunId } : {}),
...(check.workflowRunId !== undefined ? { workflowRunId: check.workflowRunId } : {}),
},
}
: {}),
};
}
/**
@@ -135,6 +135,7 @@ describe("getNativeFallbackChecks", () => {
provider: "gitea",
name: "CI",
status: "failure",
traits: ["warning"],
url: "https://gitea.com/group/repo/pulls/7",
},
]);
@@ -66,6 +66,7 @@ import { ChecksSection, getCheckIdentity } from "./checks-section";
import { getActivityVerb, getStateLabel } from "./data";
import type { PrPaneActivity, PrPaneCheck, PrPaneData, PrState } from "./data";
import type { ForgeSpecificStatusFacts } from "@/git/merge-capability";
import { CheckPresentationIcon } from "@/git/check-presentation.view";
import {
buildPrTimeline,
type PrReviewEntry,
@@ -74,8 +75,6 @@ import {
} from "./timeline";
import {
Section,
SUMMARY_DANGER_ICON,
SUMMARY_SUCCESS_ICON,
SummaryPill,
dangerColorMapping,
foregroundMutedColorMapping,
@@ -129,6 +128,8 @@ const PR_STATE_PRESENTATION: Record<PrState, PrStatePresentation> = {
const SUMMARY_COMMENT_ICON = (
<ThemedMessageSquare size={11} uniProps={foregroundMutedColorMapping} />
);
const SUMMARY_APPROVAL_ICON = <CheckPresentationIcon presentation="success" size={12} />;
const SUMMARY_CHANGES_REQUESTED_ICON = <CheckPresentationIcon presentation="failure" size={12} />;
const ADD_TO_CHAT_MENU_ICON = (
<ThemedMessageSquarePlus size={14} uniProps={foregroundMutedColorMapping} />
);
@@ -205,8 +206,9 @@ export function PullRequestPane({
);
const toast = useToast();
const daemonClient = useHostRuntimeClient(serverId);
// COMPAT(githubCheckDetailsRpc): added in v0.1.106, remove after 2026-12-28 once
// all supported clients use checkout.forge.get_check_details.*.
// COMPAT(githubCheckDetailsRpc): recognize the legacy capability on daemons
// predating checkout.forge.get_check_details.*. Remove after 2027-01-17 once
// the supported daemon floor is >= v0.2.0.
const canFetchGitHubCheckDetails = useSessionStore(
(state) => state.sessions[serverId]?.serverInfo?.features?.githubCheckDetails === true,
);
@@ -395,8 +397,9 @@ export function PullRequestPane({
workflowRunId: ref.workflowRunId,
changeRequestNumber: data.number,
};
// COMPAT(githubCheckDetailsRpc): added in v0.1.106, remove after 2026-12-28 once
// all supported clients use checkout.forge.get_check_details.*.
// COMPAT(githubCheckDetailsRpc): use the legacy GitHub RPC with
// daemons predating checkout.forge.get_check_details.*. Remove after
// 2027-01-17 once the supported daemon floor is >= v0.2.0.
const payload = canFetchForgeCheckDetails
? await daemonClient.checkoutForgeGetCheckDetails(request)
: await daemonClient.checkoutGithubGetCheckDetails(request);
@@ -570,8 +573,12 @@ export function PullRequestPane({
onToggle={handleToggleActivity}
summary={
<>
<SummaryPill count={approvals} icon={SUMMARY_SUCCESS_ICON} variant="success" />
<SummaryPill count={changesRequested} icon={SUMMARY_DANGER_ICON} variant="danger" />
<SummaryPill count={approvals} icon={SUMMARY_APPROVAL_ICON} variant="success" />
<SummaryPill
count={changesRequested}
icon={SUMMARY_CHANGES_REQUESTED_ICON}
variant="danger"
/>
<SummaryPill count={commentCount} icon={SUMMARY_COMMENT_ICON} variant="muted" />
</>
}
@@ -1,24 +1,18 @@
import React, { type ReactNode } from "react";
import { Pressable, Text, View } from "react-native";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import {
ChevronDown,
ChevronRight,
CircleCheck,
CircleDot,
CircleSlash,
CircleX,
} from "lucide-react-native";
import type { CountedCheckPresentation } from "@/git/check-presentation";
import { CONTROL_HEIGHTS } from "@/components/ui/control-geometry";
import {
CheckPresentationIcon,
getCheckPresentationTone,
type CheckPresentationTone,
} from "@/git/check-presentation.view";
import { ChevronDown, ChevronRight } from "lucide-react-native";
import type { Theme } from "@/styles/theme";
import type { CheckStatus } from "./check-status";
const ThemedChevronDown = withUnistyles(ChevronDown);
const ThemedChevronRight = withUnistyles(ChevronRight);
const ThemedCircleCheck = withUnistyles(CircleCheck);
const ThemedCircleDot = withUnistyles(CircleDot);
const ThemedCircleSlash = withUnistyles(CircleSlash);
const ThemedCircleX = withUnistyles(CircleX);
export const foregroundMutedColorMapping = (theme: Theme) => ({
color: theme.colors.foregroundMuted,
@@ -27,22 +21,30 @@ export const successColorMapping = (theme: Theme) => ({ color: theme.colors.stat
export const dangerColorMapping = (theme: Theme) => ({ color: theme.colors.statusDanger });
export const warningColorMapping = (theme: Theme) => ({ color: theme.colors.statusWarning });
export const SUMMARY_SUCCESS_ICON = <ThemedCircleCheck size={12} uniProps={successColorMapping} />;
export const SUMMARY_DANGER_ICON = <ThemedCircleX size={12} uniProps={dangerColorMapping} />;
export const SUMMARY_WARNING_ICON = <ThemedCircleDot size={12} uniProps={warningColorMapping} />;
interface SectionProps {
title: string;
open: boolean;
onToggle: () => void;
summary: ReactNode;
children: ReactNode;
accessibilityLabel?: string;
}
export function Section({ title, open, onToggle, summary, children }: SectionProps) {
export function Section({
title,
open,
onToggle,
summary,
children,
accessibilityLabel,
}: SectionProps) {
return (
<View>
<Pressable style={sectionKitStyles.sectionHeader} onPress={onToggle}>
<Pressable
accessibilityLabel={accessibilityLabel}
style={sectionKitStyles.sectionHeader}
onPress={onToggle}
>
{open ? (
<ThemedChevronDown size={14} uniProps={foregroundMutedColorMapping} />
) : (
@@ -56,7 +58,7 @@ export function Section({ title, open, onToggle, summary, children }: SectionPro
);
}
export type SummaryPillVariant = "success" | "danger" | "warning" | "muted";
export type SummaryPillVariant = CheckPresentationTone;
export function SummaryPill({
count,
@@ -85,11 +87,22 @@ function summaryPillTextStyle(variant: SummaryPillVariant) {
return sectionKitStyles.summaryPillMutedText;
}
export function CheckStatusIcon({ status }: { status: CheckStatus }) {
if (status === "success") return <ThemedCircleCheck size={14} uniProps={successColorMapping} />;
if (status === "failure") return <ThemedCircleX size={14} uniProps={dangerColorMapping} />;
if (status === "pending") return <ThemedCircleDot size={14} uniProps={warningColorMapping} />;
return <ThemedCircleSlash size={14} uniProps={foregroundMutedColorMapping} />;
export function CheckPresentationSummaryPill({
count,
presentation,
testID,
}: {
count: number;
presentation: CountedCheckPresentation;
testID?: string;
}) {
if (count === 0) return null;
return (
<View style={sectionKitStyles.summaryPill} testID={testID}>
<CheckPresentationIcon presentation={presentation} size={12} />
<Text style={summaryPillTextStyle(getCheckPresentationTone(presentation))}>{count}</Text>
</View>
);
}
export const sectionKitStyles = StyleSheet.create((theme) => ({
@@ -95,8 +95,9 @@ export function buildForgeSearchQueryOptions(input: ForgeSearchQueryInput) {
const request = input.kinds
? { cwd: input.cwd, query, limit: 20, kinds: input.kinds }
: { cwd: input.cwd, query, limit: 20 };
// COMPAT(githubSearchRpc): added in v0.1.106, remove after 2026-12-28 once
// clients use forge.search.*.
// COMPAT(githubSearchRpc): use the legacy GitHub RPC with daemons that
// predate forge.search.*. Remove after 2027-01-17 once the supported
// daemon floor is >= v0.2.0.
if (transport === "github" && input.client.searchGitHub) {
return normalizeLegacyGitHubSearchPayload(
await input.client.searchGitHub(toLegacyGitHubSearchRequest(request)),
@@ -125,7 +126,8 @@ function normalizeForgeSearchPayload(payload: ForgeSearchResponse["payload"]): F
function normalizeLegacyGitHubSearchPayload(
payload: GitHubSearchResponse["payload"],
): ForgeSearchPayload {
// COMPAT(githubSearchAuthState): added in v0.1.106, remove after 2026-12-28.
// COMPAT(githubSearchAuthState): normalize the legacy GitHub search response
// until 2027-01-17, when the supported daemon floor is >= v0.2.0.
const featuresEnabled = payload.featuresEnabled ?? payload.githubFeaturesEnabled ?? true;
return {
items: payload.items.flatMap((item) => {
@@ -0,0 +1,87 @@
import { useEffect, useRef, useState } from "react";
import {
advanceTextReveal,
beginTextReveal,
completeTextReveal,
isTextRevealPacingSupported,
isTextRevealSettled,
nextTextRevealFrame,
retargetTextReveal,
type TextRevealState,
visibleRevealedText,
} from "@/agent-stream/text-reveal";
import type { MarkdownPhase } from "@/components/markdown/fence/types";
/**
* Binds the paced reveal in @/agent-stream/text-reveal to a frame clock.
*
* All of the policy — what is revealed when, and where it is safe to cut — lives
* in that module and is tested there. This hook only owns the requestAnimationFrame
* wiring, so the rendered behavior is covered end to end by
* `packages/app/e2e/browser/agent-stream-smoothness.spec.ts`.
*/
export function useRevealedText(text: string, phase: MarkdownPhase): string {
const pacingSupported = isTextRevealPacingSupported();
const stateRef = useRef<TextRevealState>(beginTextReveal(text));
const [, forceRender] = useState(0);
const frameRef = useRef<number | null>(null);
const lastFrameAtRef = useRef<number | null>(null);
stateRef.current = retargetTextReveal(stateRef.current, text);
useEffect(() => {
const settle = () => {
lastFrameAtRef.current = null;
const next = completeTextReveal(stateRef.current);
if (next !== stateRef.current) {
stateRef.current = next;
forceRender((tick) => tick + 1);
}
};
if (!pacingSupported || phase !== "streaming") {
settle();
return;
}
if (isTextRevealSettled(stateRef.current)) {
lastFrameAtRef.current = null;
return;
}
if (typeof requestAnimationFrame !== "function") {
settle();
return;
}
const tick = (timestamp: number) => {
frameRef.current = null;
const frame = nextTextRevealFrame(lastFrameAtRef.current, timestamp);
if (!frame) {
frameRef.current = requestAnimationFrame(tick);
return;
}
lastFrameAtRef.current = frame.frameAtMs;
const next = advanceTextReveal(stateRef.current, frame.elapsedMs);
if (next !== stateRef.current) {
stateRef.current = next;
forceRender((count) => count + 1);
}
if (!isTextRevealSettled(stateRef.current)) {
frameRef.current = requestAnimationFrame(tick);
}
};
frameRef.current = requestAnimationFrame(tick);
return () => {
if (frameRef.current !== null) {
cancelAnimationFrame(frameRef.current);
frameRef.current = null;
}
};
}, [text, pacingSupported, phase]);
return pacingSupported
? visibleRevealedText(stateRef.current, { streaming: phase === "streaming" })
: text;
}
+18
View File
@@ -310,6 +310,16 @@ describe("translation resources", () => {
expect(en.workspace.git.pr.empty.pipelineJobsLoadFailed).toBe("Could not load pipeline jobs");
expect(en.workspace.git.pr.empty.allowedToFail).toBe("allowed to fail");
expect(en.workspace.git.pr.approvals).toBe("{{given}} of {{required}} approvals");
expect(en.workspace.git.pr.accessibility.checkStatus).toEqual({
passed: "Passed",
failed: "Failed",
warning: "Warning",
actionRequired: "Action required",
manual: "Manual",
pending: "Pending",
skipped: "Skipped",
cancelled: "Cancelled",
});
expect(en.review.comment.placeholder).toBe("Leave a comment");
});
@@ -438,6 +448,14 @@ describe("translation resources", () => {
expect(en.sidebar.workspace.actions.createWorkspaceFor).toBe(
"Create a new workspace for {{projectName}}",
);
expect(en.sidebar.workspace.checks).toEqual({
passed: "Passed: {{count}}",
failed: "Failed: {{count}}",
warning: "Warnings: {{count}}",
actionRequired: "Action required: {{count}}",
manual: "Manual: {{count}}",
pending: "Pending: {{count}}",
});
expect(en.sidebar.project.empty.title).toBe("No projects yet");
expect(en.sidebar.project.empty.description).toBe("Add a project to get started");
expect(en.settings.projectList.hostLoadFailed).toBe(
+18
View File
@@ -936,6 +936,16 @@ export const ar: TranslationResources = {
accessibility: {
pullRequest: "سحب الطلب #{{number}}",
pullRequest_mr: "طلب دمج !{{number}}",
checkStatus: {
passed: "ناجح",
failed: "فاشل",
warning: "تحذير",
actionRequired: "إجراء مطلوب",
manual: "يدوي",
pending: "قيد الانتظار",
skipped: "تم التخطي",
cancelled: "تم الإلغاء",
},
},
states: {
draft: "مسودة",
@@ -1126,6 +1136,14 @@ export const ar: TranslationResources = {
serviceUnhealthy: "الخدمة {{name}} غير سليمة",
creating: "جارٍ الإنشاء...",
},
checks: {
passed: "ناجحة: {{count}}",
failed: "فاشلة: {{count}}",
warning: "تحذيرات: {{count}}",
actionRequired: "إجراء مطلوب: {{count}}",
manual: "يدوية: {{count}}",
pending: "قيد الانتظار: {{count}}",
},
actions: {
menu: "إجراءات Workspace",
newWorkspace: "مساحة عمل جديدة",
+18
View File
@@ -945,6 +945,16 @@ export const en = {
accessibility: {
pullRequest: "Pull request #{{number}}",
pullRequest_mr: "Merge request !{{number}}",
checkStatus: {
passed: "Passed",
failed: "Failed",
warning: "Warning",
actionRequired: "Action required",
manual: "Manual",
pending: "Pending",
skipped: "Skipped",
cancelled: "Cancelled",
},
},
states: {
draft: "Draft",
@@ -1135,6 +1145,14 @@ export const en = {
serviceUnhealthy: "Service {{name}} unhealthy",
creating: "Creating...",
},
checks: {
passed: "Passed: {{count}}",
failed: "Failed: {{count}}",
warning: "Warnings: {{count}}",
actionRequired: "Action required: {{count}}",
manual: "Manual: {{count}}",
pending: "Pending: {{count}}",
},
actions: {
menu: "Workspace actions",
newWorkspace: "New workspace",
+18
View File
@@ -967,6 +967,16 @@ export const es: TranslationResources = {
accessibility: {
pullRequest: "Solicitud de extracción n.°{{number}}",
pullRequest_mr: "Solicitud de fusión !{{number}}",
checkStatus: {
passed: "Superado",
failed: "Fallido",
warning: "Advertencia",
actionRequired: "Acción requerida",
manual: "Manual",
pending: "Pendiente",
skipped: "Omitido",
cancelled: "Cancelado",
},
},
states: {
draft: "Borrador",
@@ -1160,6 +1170,14 @@ export const es: TranslationResources = {
serviceUnhealthy: "Servicio {{name}} con fallos",
creating: "Creando...",
},
checks: {
passed: "Superados: {{count}}",
failed: "Fallidos: {{count}}",
warning: "Advertencias: {{count}}",
actionRequired: "Acción requerida: {{count}}",
manual: "Manuales: {{count}}",
pending: "Pendientes: {{count}}",
},
actions: {
menu: "AccionesWorkspace",
newWorkspace: "Nuevo espacio de trabajo",
+18
View File
@@ -966,6 +966,16 @@ export const fr: TranslationResources = {
accessibility: {
pullRequest: "Demande de tirage #{{number}}",
pullRequest_mr: "Demande de fusion !{{number}}",
checkStatus: {
passed: "Réussi",
failed: "Échec",
warning: "Avertissement",
actionRequired: "Action requise",
manual: "Manuel",
pending: "En attente",
skipped: "Ignoré",
cancelled: "Annulé",
},
},
states: {
draft: "Brouillon",
@@ -1160,6 +1170,14 @@ export const fr: TranslationResources = {
serviceUnhealthy: "Service {{name}} en échec",
creating: "Création...",
},
checks: {
passed: "Réussis : {{count}}",
failed: "Échecs : {{count}}",
warning: "Avertissements : {{count}}",
actionRequired: "Action requise : {{count}}",
manual: "Manuels : {{count}}",
pending: "En attente : {{count}}",
},
actions: {
menu: "ActionsWorkspace",
newWorkspace: "Nouvel espace de travail",
+18
View File
@@ -947,6 +947,16 @@ export const ja: TranslationResources = {
accessibility: {
pullRequest: "プルリクエスト#{{number}}",
pullRequest_mr: "マージリクエスト !{{number}}",
checkStatus: {
passed: "成功",
failed: "失敗",
warning: "警告",
actionRequired: "操作が必要",
manual: "手動",
pending: "保留中",
skipped: "スキップ済み",
cancelled: "キャンセル済み",
},
},
states: {
draft: "ドラフト",
@@ -1138,6 +1148,14 @@ export const ja: TranslationResources = {
serviceUnhealthy: "サービス {{name}} 異常",
creating: "作成中...",
},
checks: {
passed: "成功: {{count}}",
failed: "失敗: {{count}}",
warning: "警告: {{count}}",
actionRequired: "操作が必要: {{count}}",
manual: "手動: {{count}}",
pending: "保留中: {{count}}",
},
actions: {
menu: "ワークスペースアクション",
newWorkspace: "新しいワークスペース",
+18
View File
@@ -943,6 +943,16 @@ export const ko: TranslationResources = {
accessibility: {
pullRequest: "풀 리퀘스트 #{{number}}",
pullRequest_mr: "병합 요청 !{{number}}",
checkStatus: {
passed: "통과",
failed: "실패",
warning: "경고",
actionRequired: "조치 필요",
manual: "수동",
pending: "대기 중",
skipped: "건너뜀",
cancelled: "취소됨",
},
},
states: {
draft: "초안",
@@ -1133,6 +1143,14 @@ export const ko: TranslationResources = {
serviceUnhealthy: "서비스 {{name}} 비정상",
creating: "생성하는 중...",
},
checks: {
passed: "통과: {{count}}개",
failed: "실패: {{count}}개",
warning: "경고: {{count}}개",
actionRequired: "조치 필요: {{count}}개",
manual: "수동: {{count}}개",
pending: "대기 중: {{count}}개",
},
actions: {
menu: "워크스페이스 작업",
newWorkspace: "새 워크스페이스",
+18
View File
@@ -958,6 +958,16 @@ export const ptBR: TranslationResources = {
accessibility: {
pullRequest: "Pull request #{{number}}",
pullRequest_mr: "Merge request !{{number}}",
checkStatus: {
passed: "Aprovado",
failed: "Falhou",
warning: "Aviso",
actionRequired: "Ação necessária",
manual: "Manual",
pending: "Pendente",
skipped: "Ignorado",
cancelled: "Cancelado",
},
},
states: {
draft: "Rascunho",
@@ -1151,6 +1161,14 @@ export const ptBR: TranslationResources = {
serviceUnhealthy: "Serviço {{name}} com falha",
creating: "Criando...",
},
checks: {
passed: "Aprovados: {{count}}",
failed: "Falhas: {{count}}",
warning: "Avisos: {{count}}",
actionRequired: "Ação necessária: {{count}}",
manual: "Manuais: {{count}}",
pending: "Pendentes: {{count}}",
},
actions: {
menu: "Ações do workspace",
newWorkspace: "Novo workspace",
+18
View File
@@ -951,6 +951,16 @@ export const ru: TranslationResources = {
accessibility: {
pullRequest: "PR #{{number}}",
pullRequest_mr: "MR !{{number}}",
checkStatus: {
passed: "Успешно",
failed: "Ошибка",
warning: "Предупреждение",
actionRequired: "Требуется действие",
manual: "Вручную",
pending: "Ожидание",
skipped: "Пропущено",
cancelled: "Отменено",
},
},
states: {
draft: "Черновик",
@@ -1142,6 +1152,14 @@ export const ru: TranslationResources = {
serviceUnhealthy: "Сервис {{name}} работает некорректно",
creating: "Создание...",
},
checks: {
passed: "Успешные: {{count}}",
failed: "Ошибки: {{count}}",
warning: "Предупреждения: {{count}}",
actionRequired: "Требуется действие: {{count}}",
manual: "Вручную: {{count}}",
pending: "Ожидают: {{count}}",
},
actions: {
menu: "Действия рабочего пространства",
newWorkspace: "Новое рабочее пространство",
+18
View File
@@ -928,6 +928,16 @@ export const zhCN: TranslationResources = {
accessibility: {
pullRequest: "Pull request #{{number}}",
pullRequest_mr: "合并请求 !{{number}}",
checkStatus: {
passed: "成功",
failed: "失败",
warning: "警告",
actionRequired: "需要操作",
manual: "手动",
pending: "等待中",
skipped: "已跳过",
cancelled: "已取消",
},
},
states: {
draft: "Draft",
@@ -1116,6 +1126,14 @@ export const zhCN: TranslationResources = {
serviceUnhealthy: "服务 {{name}} 异常",
creating: "正在创建...",
},
checks: {
passed: "成功: {{count}}",
failed: "失败: {{count}}",
warning: "警告: {{count}}",
actionRequired: "需要操作: {{count}}",
manual: "手动: {{count}}",
pending: "等待中: {{count}}",
},
actions: {
menu: "Workspace 操作",
newWorkspace: "新建 workspace",
+8
View File
@@ -1046,6 +1046,10 @@ function ChatAgentContent({
streamViewRef.current?.scrollToBottom("message-sent");
}, [agentId]);
const handleRewindComplete = useCallback(() => {
streamViewRef.current?.scrollToBottom("rewind");
}, []);
const retryAgentLoad = useCallback(() => setMissingAgentState({ kind: "idle" }), []);
const retryTimelineSync = useCallback(() => {
@@ -1186,6 +1190,7 @@ function ChatAgentContent({
animatedContentStyle={animatedContentStyle}
handleComposerHeightChange={handleComposerHeightChange}
handleMessageSent={handleMessageSent}
handleRewindComplete={handleRewindComplete}
showHistorySyncOverlay={showHistorySyncOverlay}
showHistorySyncError={showHistorySyncError}
isRetryingHistorySync={isRetryingHistorySync}
@@ -1215,6 +1220,7 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
animatedContentStyle,
handleComposerHeightChange,
handleMessageSent,
handleRewindComplete,
showHistorySyncOverlay,
showHistorySyncError,
isRetryingHistorySync,
@@ -1240,6 +1246,7 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
animatedContentStyle: object[];
handleComposerHeightChange: (height: number) => void;
handleMessageSent: () => void;
handleRewindComplete: () => void;
showHistorySyncOverlay: boolean;
showHistorySyncError: boolean;
isRetryingHistorySync: boolean;
@@ -1365,6 +1372,7 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
<RewindComposerRestoreProvider
text={agentInputDraft.text}
setText={agentInputDraft.replaceText}
onRewindComplete={handleRewindComplete}
>
<View style={styles.root}>
<FileDropZone style={styles.container} disabled={isArchivingCurrentAgent}>
@@ -0,0 +1,4 @@
import AsyncStorage from "@react-native-async-storage/async-storage";
import type { ProjectIconCacheStorage } from "./icon-cache";
export const projectIconCacheStorage: ProjectIconCacheStorage = AsyncStorage;
@@ -0,0 +1,46 @@
import type { ProjectIconCacheStorage } from "./icon-cache";
const DATABASE_NAME = "paseo-project-icon-cache";
const STORE_NAME = "key-value";
let databasePromise: Promise<IDBDatabase> | null = null;
function openDatabase(): Promise<IDBDatabase> {
databasePromise ??= new Promise((resolve, reject) => {
const request = indexedDB.open(DATABASE_NAME, 1);
request.addEventListener("upgradeneeded", () => {
if (!request.result.objectStoreNames.contains(STORE_NAME)) {
request.result.createObjectStore(STORE_NAME);
}
});
request.addEventListener("success", () => resolve(request.result));
request.addEventListener("error", () =>
reject(request.error ?? new Error("Failed to open project icon cache")),
);
});
return databasePromise;
}
async function getItem(key: string): Promise<string | null> {
const database = await openDatabase();
return new Promise((resolve, reject) => {
const request = database.transaction(STORE_NAME, "readonly").objectStore(STORE_NAME).get(key);
request.addEventListener("success", () =>
resolve(typeof request.result === "string" ? request.result : null),
);
request.addEventListener("error", () => reject(request.error));
});
}
async function setItem(key: string, value: string): Promise<void> {
const database = await openDatabase();
return new Promise((resolve, reject) => {
const transaction = database.transaction(STORE_NAME, "readwrite");
transaction.objectStore(STORE_NAME).put(value, key);
transaction.addEventListener("complete", () => resolve());
transaction.addEventListener("error", () => reject(transaction.error));
transaction.addEventListener("abort", () => reject(transaction.error));
});
}
export const projectIconCacheStorage: ProjectIconCacheStorage = { getItem, setItem };
+2 -2
View File
@@ -1,6 +1,6 @@
import type { ProjectIcon } from "@getpaseo/protocol/messages";
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
import { replicaCacheStorage } from "@/runtime/replica-cache/storage";
import { projectIconCacheStorage } from "./icon-cache-storage";
import type { ProjectIconTarget } from "./icon-target";
const STORAGE_KEY = "@paseo:project-icon-cache";
@@ -197,7 +197,7 @@ export class ProjectIconCache {
}
}
export const projectIconCache = new ProjectIconCache(replicaCacheStorage);
export const projectIconCache = new ProjectIconCache(projectIconCacheStorage);
function resolveLookup(
target: Pick<ProjectIconTarget, "projectId" | "iconWorkingDir">,
@@ -149,6 +149,52 @@ it("commits the authoritative snapshot before buffered project updates", () => {
store.clearSession(serverId);
});
it("preserves unchanged project identity when another project changes", () => {
const serverId = "project-identity";
const store = useSessionStore.getState();
store.initializeSession(serverId, null as unknown as DaemonClient);
const replica = new WorkspaceDirectoryReplica(serverId);
const first = normalizeProjectDescriptor({
projectId: "first",
projectDisplayName: "First",
projectRootPath: "/repo/first",
projectKind: "git",
});
const second = normalizeProjectDescriptor({
projectId: "second",
projectDisplayName: "Second",
projectRootPath: "/repo/second",
projectKind: "git",
});
replica.commitSnapshot(
{
workspaces: new Map(),
projects: new Map([
["first", first],
["second", second],
]),
},
[],
);
const previousSecond = useSessionStore.getState().sessions[serverId]?.projects.get("second");
replica.commitSnapshot(
{
workspaces: new Map(),
projects: new Map([
["first", { ...first, projectDisplayName: "Updated" }],
["second", { ...second }],
]),
},
[],
);
expect(useSessionStore.getState().sessions[serverId]?.projects.get("second")).toBe(
previousSecond,
);
store.clearSession(serverId);
});
it("does not invent a null-key project from a workspace update", () => {
const serverId = "workspace-before-project-update";
const store = useSessionStore.getState();

Some files were not shown because too many files have changed in this diff Show More