Compare commits

..
Author SHA1 Message Date
Marcel Wysocki ad738c02b5 fix(server): stop the Linux watcher reporting a deleted directory under its own name (#9289)
inotify names a watched directory's own deletion after the directory, and
fs.watch passes that name as the filename. The Linux backend resolved it
against the directory, so removing `dir/` also reported a delete for
`dir/dir`, and removing `dir/nested/` one for `dir/nested/nested`.

When `<dir>/<basename(dir)>` is missing, the backend now checks whether the
watched directory itself is gone and drops the event in that case; the
parent watcher and reconciliation already report the directory. A real
child named like its directory is still reported.
2026-12-06 15:12:42 +00:00
neihyud c5caa9a009 Show provider CLI versions as plain text when the CLI styles its output (#10616)
Some provider CLIs color their `--version` output even when piped, and the
escape codes showed up in the provider settings version row. Strip them in
readCommandVersionOutput, which the version label, Codex version checks and
diagnostics all read from.

Fixes #10316
2026-12-06 14:12:41 +00:00
SunicemanandShane Su d69527bbe5 Show platform-specific crash log hints for local speech workers (#11219)
Co-authored-by: Shane Su <26364206+suniceman@users.noreply.github.com>
2026-12-06 13:43:04 +00:00
Mohamed Boudra 99045250d0 fix(gpui): switch experimental desktop release to manual timestamped tags and fix Linux/macOS CI builds (#12233)
* fix(gpui): update nightly release in place with experimental title and notes

Previously the GPUI nightly workflow staged and published a brand-new release every night, which sent daily release notification emails to repository watchers. Updating the existing gpui-nightly prerelease in place preserves the same release ID, refreshes the tag and assets, deletes stale assets, and avoids repeat watcher emails while keeping initial draft staging when the release does not exist yet.

* fix(gpui): install fontconfig and freetype dev packages on Linux

yeslogic-fontconfig-sys requires fontconfig via pkg-config on ubuntu-24.04 (failed in run 47633672297); install libfontconfig-dev and libfreetype-dev alongside the existing X11/Wayland/Vulkan build dependencies.

* fix(gpui): back up existing nightly assets and defer tag update until upload succeeds

Addresses review feedback on in-place nightly updates: download existing release assets into a temporary backup before replacing them, move refs/tags/gpui-nightly only after all uploads are verified, and restore the backed-up assets and prior tag SHA if any step fails before the release metadata PATCH completes.

* fix(gpui): cache native deps with target and keep untouched assets on rollback

Restoring .artifacts/gpui/macos/target without RN_GPUI_NATIVE_DEPS_CACHE caused CMake regeneration to fail with missing OpenSSL::SSL and OpenSSL::Crypto targets on macOS. Set RN_GPUI_NATIVE_DEPS_CACHE inside .artifacts/gpui/{macos,linux}/native-deps, cache it alongside target under v2 keys, and clear restored CMakeCache.txt before configure. Also skip re-uploading assets whose IDs are unchanged during in-place rollback and report any rollback errors.

* fix(gpui): retry selective asset uploads during in-place rollback

Keep skipping untouched asset IDs when rolling back a failed in-place nightly release update, while routing only replaced or deleted backup files through scripts/upload-release-assets.mjs so transient upload failures retain retries.

* feat(gpui): switch experimental desktop release to manual timestamped tags

Implements Decision D622: remove the daily cron schedule from .github/workflows/gpui-nightly.yml so builds are manual-only (workflow_dispatch), rename the workflow and artifacts to GPUI Experimental, and stage-then-promote each run to a unique timestamped tag (gpui-experimental-DD-MM-YYYY-HHMM) with title Paseo GPUI Experimental DD-MM-YYYY HH:MM UTC and the approved Simple English release notes.

* fix(gpui): clean up newly created tag when promotion fails

Addresses review feedback on experimental release staging: track whether the current run created the timestamped tag and delete that ref alongside the staging draft if the promotion PATCH fails.
2026-12-06 20:37:13 +07:00
Mohamed Boudra 7f07d3e028 Unify desktop window chrome and bring GPUI to frameless parity (#12234)
* refactor(app): unify desktop window chrome behind platform seam

Extract renderer-agnostic window-chrome primitives so shared headers, sidebars, tabs, and window controls no longer gate on isNative or Electron globals directly:

- Add @/desktop/window-chrome-host (.ts no-op default and .web.ts Electron adapter) and migrate WindowChromeProvider, DesktopWindowControlsSync, and DesktopWindowControls onto it.
- Add @/components/desktop/caption-button and migrate DesktopWindowControls off raw Pressable and Electron window calls.
- Add @/components/desktop/titlebar-drag-surface (.tsx plain View and .web.tsx wrapping TitlebarDragRegion) and migrate header, sidebar, split pane, settings, drawer, and splash mount sites while keeping Electron drag/no-drag DOM/CSS behavior intact.
- Place explorerControls.titlebarAction after sharedExplorer so paint and hit-test order does not rely on zIndex, and tighten non-overflowing tab scroll width.

* test(app): assert drag overlay and 4px resizer styles in chrome seam test

* test(app): inject Electron deps in window-chrome-host and test default noop host

* refactor(app): remove unused Electron window command wrappers

* fix(app): initialize Electron window-chrome host lazily without platform gate import

* fix(app): preserve Explorer titlebar toggle header Tab order

* feat(gpui): implement desktop window chrome parity

Implements the .gpui.* platform adapters for Paseo's renderer-agnostic window chrome seam, bumps @react-native-gpui/* dependencies to paseo-6, and updates desktop*.json + main.rs so desktop.json is the single source of truth (1200x800, titleBar: hidden, menuBar: false, macOS trafficLightPosition {x: 16, y: 10}).

Uses DesktopWindowControlNativeComponent (codegenNativeComponent) so Bridgeless Fabric receives a static view config without touching UIManager, normalizes SafeArea top inset to 0 in window-layout/index.gpui.tsx for integrated 36px headers, and re-syncs menuSetMenuBarVisible(false, 1) on Linux/Windows so the initial surface reclaims the 26px menu strip.

* fix(app): pass system chrome appearance and action-only caption contract

Resolves two review findings:
- Pass "system" from DesktopWindowControlsSync when theme is "auto" (or missing-plugin fallback) so macOS GPUI clears NSWindow.setAppearance instead of locking dark/light across Light -> Dark -> System.
- Make DesktopCaptionButton action-only across web and GPUI adapters so GPUI does not accept and ignore a shared onPress prop.
2026-12-06 20:23:10 +07:00
129 changed files with 2406 additions and 2179 deletions
+99 -109
View File
@@ -1,8 +1,6 @@
name: GPUI Nightly
name: GPUI Experimental
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
platform:
@@ -15,7 +13,7 @@ on:
- macos
- linux
publish:
description: "Publish built artifacts to the rolling gpui-nightly prerelease."
description: "Publish built artifacts as a timestamped gpui-experimental prerelease."
required: false
default: "true"
type: choice
@@ -24,7 +22,7 @@ on:
- "false"
concurrency:
group: gpui-nightly-${{ github.ref }}
group: gpui-experimental-${{ github.ref }}
cancel-in-progress: false
permissions:
@@ -38,8 +36,8 @@ env:
jobs:
build-macos:
name: gpui-nightly (macos-latest, arm64)
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
name: gpui-experimental (macos-latest, arm64)
if: ${{ inputs.platform == 'all' || inputs.platform == 'macos' }}
runs-on: macos-latest
timeout-minutes: 60
permissions:
@@ -64,9 +62,13 @@ jobs:
~/.cargo/registry
~/.cargo/git
.artifacts/gpui/macos/target
key: gpui-nightly-cargo-macos26-arm64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
.artifacts/gpui/macos/native-deps
key: gpui-nightly-cargo-v2-macos26-arm64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
restore-keys: |
gpui-nightly-cargo-macos26-arm64-
gpui-nightly-cargo-v2-macos26-arm64-
- name: Clear restored CMake cache before configure
run: find .artifacts/gpui/macos/target -name CMakeCache.txt -delete 2>/dev/null || true
- name: Install macOS build tools
run: command -v ninja >/dev/null || brew install ninja
@@ -89,12 +91,11 @@ jobs:
NODE_OPTIONS: --max-old-space-size=6144
CARGO_BUILD_JOBS: "4"
PASEO_RENDERER: gpui
RN_GPUI_NATIVE_DEPS_CACHE: ${{ github.workspace }}/.artifacts/gpui/macos/native-deps
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
repo_root="$PWD"
# Drop restored CMake state because native-deps is not cached across runners.
rm -rf "$repo_root/.artifacts/gpui/macos/target/rn-gpui-cmake"
cd packages/app/gpui
CARGO_TARGET_DIR="$repo_root/.artifacts/gpui/macos/target" \
node node_modules/react-native/cli.js package-desktop \
@@ -186,11 +187,11 @@ jobs:
xcrun stapler staple "$app_path"
spctl --assess --type execute -v "$app_path"
out_dir="$RUNNER_TEMP/gpui-nightly-macos-arm64"
out_dir="$RUNNER_TEMP/gpui-experimental-macos-arm64"
rm -rf "$out_dir"
node scripts/gpui.mjs package-macos-dmg "$app_path" "$out_dir"
dmg_path="$out_dir/Paseo-GPUI-nightly-macos-arm64.dmg"
dmg_path="$out_dir/Paseo-GPUI-experimental-macos-arm64.dmg"
codesign --force --sign "$sign_identity" --timestamp "$dmg_path"
xcrun notarytool submit "$dmg_path" \
--apple-id "$APPLE_ID" \
@@ -212,7 +213,7 @@ jobs:
node packages/app/gpui/verify-macos-package.mjs "$app_path" --require-asset-catalog
codesign -d --entitlements :- "$app_path" 2>&1 | grep -q "com.apple.security.cs.allow-jit"
out_dir="$RUNNER_TEMP/gpui-nightly-macos-arm64"
out_dir="$RUNNER_TEMP/gpui-experimental-macos-arm64"
rm -rf "$out_dir"
node scripts/gpui.mjs package-macos-dmg "$app_path" "$out_dir"
@@ -225,18 +226,18 @@ jobs:
fi
- name: Generate macOS checksums
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-nightly-macos-arm64" "SHA256SUMS-gpui-nightly-macos-arm64.txt"
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-experimental-macos-arm64" "SHA256SUMS-gpui-experimental-macos-arm64.txt"
- name: Upload macOS nightly artifact
- name: Upload macOS experimental artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: gpui-nightly-macos-arm64
path: ${{ runner.temp }}/gpui-nightly-macos-arm64
name: gpui-experimental-macos-arm64
path: ${{ runner.temp }}/gpui-experimental-macos-arm64
retention-days: 7
build-linux:
name: gpui-nightly (ubuntu-24.04, x64)
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
name: gpui-experimental (ubuntu-24.04, x64)
if: ${{ inputs.platform == 'all' || inputs.platform == 'linux' }}
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
@@ -261,9 +262,13 @@ jobs:
~/.cargo/registry
~/.cargo/git
.artifacts/gpui/linux/target
key: gpui-nightly-cargo-linux-x64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
.artifacts/gpui/linux/native-deps
key: gpui-nightly-cargo-v2-linux-x64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
restore-keys: |
gpui-nightly-cargo-linux-x64-
gpui-nightly-cargo-v2-linux-x64-
- name: Clear restored CMake cache before configure
run: find .artifacts/gpui/linux/target -name CMakeCache.txt -delete 2>/dev/null || true
- name: Install Linux GPUI build dependencies
run: |
@@ -275,6 +280,8 @@ jobs:
ninja-build \
pkg-config \
libssl-dev \
libfontconfig-dev \
libfreetype-dev \
libvulkan-dev \
libwayland-dev \
libx11-xcb-dev \
@@ -306,25 +313,26 @@ jobs:
CARGO_BUILD_JOBS: "4"
CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/gpui/linux/target
PASEO_RENDERER: gpui
RN_GPUI_NATIVE_DEPS_CACHE: ${{ github.workspace }}/.artifacts/gpui/linux/native-deps
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/gpui.mjs package-linux --out "${{ runner.temp }}/gpui-nightly-linux-x64"
run: node scripts/gpui.mjs package-linux --out "${{ runner.temp }}/gpui-experimental-linux-x64"
- name: Generate Linux checksums
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-nightly-linux-x64" "SHA256SUMS-gpui-nightly-linux-x64.txt"
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-experimental-linux-x64" "SHA256SUMS-gpui-experimental-linux-x64.txt"
- name: Upload Linux nightly artifact
- name: Upload Linux experimental artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: gpui-nightly-linux-x64
path: ${{ runner.temp }}/gpui-nightly-linux-x64
name: gpui-experimental-linux-x64
path: ${{ runner.temp }}/gpui-experimental-linux-x64
retention-days: 7
publish:
name: Publish gpui-nightly prerelease
name: Publish gpui-experimental prerelease
needs: [build-macos, build-linux]
if: ${{ !cancelled() && (github.event_name != 'workflow_dispatch' || github.event.inputs.publish != 'false') && needs.build-macos.result == 'success' && needs.build-linux.result == 'success' }}
if: ${{ !cancelled() && inputs.publish != 'false' && needs.build-macos.result == 'success' && needs.build-linux.result == 'success' }}
concurrency:
group: gpui-nightly-release
group: gpui-experimental-release
cancel-in-progress: false
runs-on: ubuntu-latest
permissions:
@@ -338,142 +346,124 @@ jobs:
with:
node-version: "22"
- name: Download built nightly artifacts
- name: Download built experimental artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: gpui-nightly-*
path: ${{ runner.temp }}/nightly-assets
pattern: gpui-experimental-*
path: ${{ runner.temp }}/experimental-assets
merge-multiple: true
- name: Publish rolling gpui-nightly prerelease
- name: Publish gpui-experimental prerelease
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
assets_dir="${RUNNER_TEMP}/nightly-assets"
notes_file="${RUNNER_TEMP}/gpui-nightly-notes.md"
build_date="$(date -u +"%Y-%m-%d %H:%M UTC")"
assets_dir="${RUNNER_TEMP}/experimental-assets"
notes_file="${RUNNER_TEMP}/gpui-experimental-notes.md"
now_utc="$(date -u +'%d-%m-%Y-%H%M|%d-%m-%Y %H:%M|%Y-%m-%d %H:%M UTC')"
IFS='|' read -r tag_timestamp title_timestamp build_date <<< "$now_utc"
short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-9)"
tag="gpui-experimental-${tag_timestamp}"
release_title="Paseo GPUI Experimental ${title_timestamp} UTC"
cat > "${assets_dir}/SHA256SUMS-gpui-nightly.txt" <<'EOF'
EOF
rm -f "${assets_dir}/SHA256SUMS-gpui-nightly.txt"
if compgen -G "${assets_dir}/SHA256SUMS-gpui-nightly-*.txt" > /dev/null; then
cat "${assets_dir}"/SHA256SUMS-gpui-nightly-*.txt > "${assets_dir}/SHA256SUMS-gpui-nightly.txt"
rm -f "${assets_dir}"/SHA256SUMS-gpui-nightly-*.txt
rm -f "${assets_dir}/SHA256SUMS-gpui-experimental.txt"
if compgen -G "${assets_dir}/SHA256SUMS-gpui-experimental-*.txt" > /dev/null; then
cat "${assets_dir}"/SHA256SUMS-gpui-experimental-*.txt > "${assets_dir}/SHA256SUMS-gpui-experimental.txt"
rm -f "${assets_dir}"/SHA256SUMS-gpui-experimental-*.txt
fi
expected_assets=()
for file in "${assets_dir}"/*; do
[[ -f "$file" && "$file" != *.yml ]] || continue
expected_assets+=("$(basename "$file")")
done
if [[ ${#expected_assets[@]} -eq 0 ]]; then
echo "::error::No release artifacts found in ${assets_dir}" >&2
exit 1
fi
{
echo "## Paseo GPUI Nightly Preview"
echo "This build is the native desktop app for Paseo. It runs on GPUI instead of Electron."
echo ""
echo "- **Build date:** ${build_date}"
echo "- **Commit:** \`${GITHUB_SHA}\` (\`${short_sha}\`)"
echo "- **JS engine:** V8 14.6 (\`@react-native-gpui/v8\`)"
echo "- **Targets:** macOS arm64 (\`.dmg\`, \`.zip\`), Linux x64 (\`.tar.gz\`)"
echo "It is under heavy development and is not ready for daily use. It is not a Paseo beta."
echo ""
echo "### Preview Limitations"
echo "If you want to use Paseo normally, download the [latest release](https://github.com/getpaseo/paseo/releases/latest)."
echo ""
echo "- Connects to a separately running Paseo daemon (defaults to \`localhost:6767\` or remote hosts); does not bundle the daemon."
echo "- \`HtmlFrame\` / HTML previews and Mermaid diagrams render placeholders / source fallback (no embedded WebView backend)."
echo "- Embedded terminal and Skia diff views are not yet ported to GPUI."
echo "This app connects to a running Paseo daemon. It does not bundle the daemon."
echo ""
echo "- Commit: \`${GITHUB_SHA}\` (\`${short_sha}\`)"
echo "- Built: \`${build_date}\`"
echo ""
echo "### SHA-256 Checksums"
echo ""
echo '```'
if [[ -f "${assets_dir}/SHA256SUMS-gpui-nightly.txt" ]]; then
cat "${assets_dir}/SHA256SUMS-gpui-nightly.txt"
if [[ -f "${assets_dir}/SHA256SUMS-gpui-experimental.txt" ]]; then
cat "${assets_dir}/SHA256SUMS-gpui-experimental.txt"
else
echo "(no checksums generated)"
fi
echo '```'
} > "${notes_file}"
tag="gpui-nightly"
staging_tag="gpui-nightly-stage-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
repo="${{ github.repository }}"
staging_tag="gpui-experimental-stage-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
staging_id=""
old_id=""
old_sha=""
swapping="false"
created_tag=""
cleanup_staging() {
local ec=$?
set +e
if [[ "$swapping" == "true" && $ec -ne 0 && -n "$old_id" && -n "$old_sha" ]]; then
gh api "repos/${{ github.repository }}/git/refs/tags/${tag}" \
-X PATCH -f sha="${old_sha}" -F force=true > /dev/null 2>&1 || true
gh api "repos/${{ github.repository }}/releases/${old_id}" \
-X PATCH -f tag_name="$tag" -F draft=false -F prerelease=true -f make_latest="false" > /dev/null 2>&1 || true
return 0
if [[ -n "$staging_id" ]]; then
gh api "repos/${repo}/releases/${staging_id}" -X DELETE > /dev/null 2>&1 || true
fi
if [[ -n "$staging_id" && "$swapping" != "true" ]]; then
gh api "repos/${{ github.repository }}/releases/${staging_id}" -X DELETE > /dev/null 2>&1 || true
if [[ -n "$created_tag" ]]; then
gh api "repos/${repo}/git/refs/tags/${created_tag}" -X DELETE > /dev/null 2>&1 || true
fi
return "$ec"
}
trap cleanup_staging EXIT
# Stage and verify the full asset set on a draft first so upload failures never touch
# the public gpui-nightly release or its downloads.
# Stage and verify the full asset set on a draft first so upload failures never
# publish a half-empty release.
gh release create "$staging_tag" \
--repo "${{ github.repository }}" \
--title "Paseo GPUI Nightly (${short_sha})" \
--repo "$repo" \
--title "$release_title" \
--notes-file "${notes_file}" \
--draft \
--prerelease \
--latest=false \
--target "${GITHUB_SHA}"
staging_id="$(gh release view "$staging_tag" --repo "${{ github.repository }}" --json databaseId --jq '.databaseId')"
node scripts/upload-release-assets.mjs "$staging_tag" "${assets_dir}" "${{ github.repository }}"
staging_id="$(gh release view "$staging_tag" --repo "$repo" --json databaseId --jq '.databaseId')"
node scripts/upload-release-assets.mjs "$staging_tag" "${assets_dir}" "$repo"
uploaded_assets="$(gh release view "$staging_tag" --repo "${{ github.repository }}" --json assets --jq '.assets[].name')"
for file in "${assets_dir}"/*; do
[[ -f "$file" ]] || continue
name="$(basename "$file")"
if ! grep -Fxq "$name" <<< "$uploaded_assets"; then
echo "::error::Missing staged release asset: ${name}"
assets_list="$(gh api "repos/${repo}/releases/${staging_id}/assets?per_page=100" --paginate --jq '.[].name')"
for name in "${expected_assets[@]}"; do
if ! grep -Fxq "$name" <<< "$assets_list"; then
echo "::error::Missing release asset: ${name}" >&2
exit 1
fi
done
if old_id="$(gh release view "$tag" --repo "${{ github.repository }}" --json databaseId --jq '.databaseId' 2>/dev/null)"; then
old_sha="$(gh api "repos/${{ github.repository }}/git/refs/tags/${tag}" --jq '.object.sha' 2>/dev/null || true)"
swapping="true"
# Hold the prior release as a draft rather than deleting it before promotion completes.
gh api "repos/${{ github.repository }}/releases/${old_id}" \
-X PATCH \
-F draft=true > /dev/null
else
old_id=""
swapping="true"
fi
gh api "repos/${repo}/git/refs" \
-X POST \
-f ref="refs/tags/${tag}" \
-f sha="${GITHUB_SHA}"
created_tag="$tag"
if gh api "repos/${{ github.repository }}/git/refs/tags/${tag}" > /dev/null 2>&1; then
gh api "repos/${{ github.repository }}/git/refs/tags/${tag}" \
-X PATCH \
-f sha="${GITHUB_SHA}" \
-F force=true
else
gh api "repos/${{ github.repository }}/git/refs" \
-X POST \
-f ref="refs/tags/${tag}" \
-f sha="${GITHUB_SHA}"
fi
promoted_draft="$(gh api "repos/${{ github.repository }}/releases/${staging_id}" \
promoted_draft="$(gh api "repos/${repo}/releases/${staging_id}" \
-X PATCH \
-f tag_name="$tag" \
-f target_commitish="${GITHUB_SHA}" \
-f name="$release_title" \
-F body=@"${notes_file}" \
-F draft=false \
-F prerelease=true \
-f make_latest="false" \
--jq '.draft')"
if [[ "$promoted_draft" != "false" ]]; then
echo "::error::Promoted release is still a draft"
echo "::error::Promoted release is still a draft" >&2
exit 1
fi
swapping="false"
staging_id=""
if [[ -n "$old_id" ]]; then
gh api "repos/${{ github.repository }}/releases/${old_id}" -X DELETE > /dev/null 2>&1 || true
fi
created_tag=""
+1 -1
View File
@@ -632,7 +632,7 @@
"packages/app/src/components/combined-model-selector.tsx",
"packages/app/src/components/compact-explorer-sidebar.tsx",
"packages/app/src/components/context-window-meter.tsx",
"packages/app/src/components/desktop/window-controls.tsx",
"packages/app/src/components/desktop/caption-button.tsx",
"packages/app/src/components/dictation-controls.tsx",
"packages/app/src/components/download-toast.tsx",
"packages/app/src/components/file-explorer-pane.tsx",
-12
View File
@@ -24,18 +24,6 @@ value.
Animate only `transform` and `opacity`. Anything else is painted on the main thread every frame.
## The waiting mark
A workspace or agent with no turn running and counted background work alive shows the waiting mark
instead of the ring: one 10 px circle stroked with eight equal dashes and gaps, so each dash is a
short arc with its ends cut along the radius. It has no centre dot and does not move, so it needs
none of the machinery above. It is centred in the running ring's frame
(`components/status-ring/waiting.tsx`). Draw it wherever the ring shows for this state and nowhere
else. The frame and its knockout stay the running ring's size so a row never changes height when the
state changes; the smaller ring only leaves more space between the mark and the icon it sits on.
It is `react-native-svg`, the same on web and native. The whole `Svg` is wrapped in
`withUnistyles`, as in the context window ring, so the stroke follows theme changes.
## Hidden panels
A phone's sidebar slides into view before its panel counts as showing: the panel's active signal
@@ -1,139 +0,0 @@
import type { Page } from "@playwright/test";
import { test, expect } from "../support/fixtures";
import { gotoAppShell } from "../support/helpers/app";
import { seedMockAgentWorkspace, type MockAgentWorkspace } from "../support/helpers/mock-agent";
import { getServerId } from "../support/helpers/server-id";
import {
listOfferedSidebarSorts,
pinWorkspaceFromSidebar,
readSidebarSortValue,
selectSidebarGrouping,
selectSidebarSort,
} from "../support/helpers/sidebar";
const FINISH_MS = 20_000;
async function seedFinishedWorkspace(title: string): Promise<MockAgentWorkspace> {
const workspace = await seedMockAgentWorkspace({
repoPrefix: "sidebar-ungrouped-",
title,
initialPrompt: "Finish this turn.",
});
await workspace.client.waitForFinish(workspace.agentId, FINISH_MS);
return workspace;
}
/** The workspace ids in the flat list, top to bottom. Pinned rows are not part of it. */
async function flatListOrder(page: Page): Promise<string[]> {
const rows = page
.getByTestId("sidebar-status-group-rows-all")
.locator('[data-testid^="sidebar-workspace-row-"]');
const testIds = await rows.evaluateAll((elements) =>
elements.map((element) => element.getAttribute("data-testid") ?? ""),
);
const prefix = `sidebar-workspace-row-${getServerId()}:`;
return testIds.map((testId) => testId.slice(prefix.length));
}
async function expectFlatListOrder(page: Page, workspaces: MockAgentWorkspace[]): Promise<void> {
await expect
.poll(() => flatListOrder(page), { timeout: 30_000 })
.toEqual(workspaces.map((workspace) => workspace.workspaceId));
}
test.describe("Sidebar group: none", () => {
test.describe.configure({ timeout: 180_000 });
const seeded: MockAgentWorkspace[] = [];
test.afterEach(async () => {
for (const workspace of seeded.splice(0)) await workspace.cleanup();
});
test("shows one flat list, sorts it, and gives Project and Status grouping back unchanged", async ({
page,
}) => {
const first = await seedFinishedWorkspace("First");
const second = await seedFinishedWorkspace("Second");
const third = await seedFinishedWorkspace("Third");
seeded.push(first, second, third);
await gotoAppShell(page);
await expect(page.getByTestId("sidebar-project-workspace-list-scroll")).toBeVisible({
timeout: 30_000,
});
// Project grouping keeps Manual, which only it offers.
await selectSidebarSort(page, "manual");
expect(await readSidebarSortValue(page)).toContain("Manual");
// 1. Group: None is one list with no group headers; a pinned row stays in Pinned above it.
await selectSidebarGrouping(page, "none");
await expect(page.getByTestId("sidebar-status-list-scroll")).toBeVisible({ timeout: 30_000 });
await pinWorkspaceFromSidebar(page, third.workspaceId);
await expect(
page
.getByTestId("sidebar-pinned-section")
.getByTestId(`sidebar-workspace-row-${getServerId()}:${third.workspaceId}`),
).toBeVisible({ timeout: 30_000 });
await expect(page.locator('[data-testid^="sidebar-status-group-attention"]')).toHaveCount(0);
await expect(page.locator('[data-testid^="sidebar-project-row-"]')).toHaveCount(0);
await expectFlatListOrder(page, [second, first]);
// 2. The sorts under None, and Manual is not one of them: the stored Manual reads as Created.
expect(await listOfferedSidebarSorts(page)).toEqual(["created", "lastPrompt", "statusChange"]);
expect(await readSidebarSortValue(page)).toContain("Created");
await first.client.sendAgentMessage(first.agentId, "Finish this turn again.");
await first.client.waitForFinish(first.agentId, FINISH_MS);
await selectSidebarSort(page, "lastPrompt");
await expectFlatListOrder(page, [first, second]);
// 3. Status change: a workspace whose status changes moves to the top.
await selectSidebarSort(page, "statusChange");
await second.client.clearWorkspaceAttention(second.workspaceId);
await expectFlatListOrder(page, [second, first]);
await first.client.clearWorkspaceAttention(first.workspaceId);
await expectFlatListOrder(page, [first, second]);
// 6. Reloading keeps the choice.
await page.reload();
await expect(page.getByTestId("sidebar-status-list-scroll")).toBeVisible({ timeout: 30_000 });
expect(await readSidebarSortValue(page)).toContain("Status change");
await expectFlatListOrder(page, [first, second]);
// 4. Project grouping reads a sort it does not offer as Created ...
await selectSidebarGrouping(page, "project");
await expect(page.getByTestId("sidebar-project-workspace-list-scroll")).toBeVisible({
timeout: 30_000,
});
expect(await listOfferedSidebarSorts(page)).toEqual(["manual", "created", "lastPrompt"]);
expect(await readSidebarSortValue(page)).toContain("Created");
// ... and Status grouping offers no sort at all.
await selectSidebarGrouping(page, "status");
await expect(page.getByTestId("sidebar-status-group-done")).toBeVisible({ timeout: 30_000 });
expect(await readSidebarSortValue(page)).toBeNull();
});
test("Project grouping gets the stored Manual sort back after a visit to None", async ({
page,
}) => {
const only = await seedFinishedWorkspace("Only");
seeded.push(only);
await gotoAppShell(page);
await expect(page.getByTestId("sidebar-project-workspace-list-scroll")).toBeVisible({
timeout: 30_000,
});
await selectSidebarSort(page, "manual");
await selectSidebarGrouping(page, "none");
await expect(page.getByTestId("sidebar-status-list-scroll")).toBeVisible({ timeout: 30_000 });
await selectSidebarGrouping(page, "project");
await expect(page.getByTestId("sidebar-project-workspace-list-scroll")).toBeVisible({
timeout: 30_000,
});
expect(await readSidebarSortValue(page)).toContain("Manual");
});
});
@@ -27,14 +27,7 @@ import { expectWorkspaceHeader, waitForSidebarHydration } from "../support/helpe
import { getVisibleWorkspaceAgentTabIds } from "../support/helpers/workspace-tabs";
type NewWorkspaceDaemonClient = Awaited<ReturnType<typeof connectNewWorkspaceDaemonClient>>;
type WorkspaceIndicator =
| "attention"
| "done"
| "failed"
| "loading"
| "needs_input"
| "running"
| "waiting";
type WorkspaceIndicator = "attention" | "done" | "failed" | "loading" | "needs_input" | "running";
interface CreatedAgentAssertion {
workspaceId: string;
@@ -133,7 +126,6 @@ async function expectWorkspaceRowHasOnlyIndicator(
"loading",
"needs_input",
"running",
"waiting",
] satisfies WorkspaceIndicator[]) {
const locator = row.locator(`[data-testid="workspace-status-indicator-${indicator}"]`);
if (indicator === input.indicator) {
@@ -1,147 +0,0 @@
import type { Page } from "@playwright/test";
import { test, expect } from "../support/fixtures";
import {
openAgentRoute,
seedMockAgentWorkspace,
type MockAgentWorkspace,
} from "../support/helpers/mock-agent";
import { getServerId } from "../support/helpers/server-id";
import { selectSidebarStatusGrouping } from "../support/helpers/sidebar";
import { seedParentWithSubagent, seedSubagent } from "../support/helpers/subagents";
import { seedWorkspace } from "../support/helpers/seed-client";
const BACKGROUND_COMMAND_MS = 20_000;
function workspaceRow(page: Page, workspaceId: string) {
return page.getByTestId(`sidebar-workspace-row-${getServerId()}:${workspaceId}`);
}
async function rowHeight(page: Page, workspaceId: string): Promise<number> {
const box = await workspaceRow(page, workspaceId).boundingBox();
if (!box) throw new Error("workspace row is not laid out");
return box.height;
}
async function seedBackgroundShellAgent(
title: string,
commandMs = BACKGROUND_COMMAND_MS,
): Promise<MockAgentWorkspace> {
return await seedMockAgentWorkspace({
repoPrefix: "waiting-status-",
title,
initialPrompt: `Please start a background shell command for ${commandMs}ms.`,
});
}
test.describe("Waiting on background work", () => {
test.describe.configure({ timeout: 120_000 });
const seeded: MockAgentWorkspace[] = [];
test.afterEach(async () => {
for (const workspace of seeded.splice(0)) await workspace.cleanup();
});
test("the agent's tab shows waiting, not running, once its turn has ended", async ({ page }) => {
// The app opens after the agent exists, so the command must outlast a slow startup.
const subject = await seedBackgroundShellAgent("Tab subject", 90_000);
seeded.push(subject);
await openAgentRoute(page, { workspaceId: subject.workspaceId, agentId: subject.agentId });
await expect(page.getByLabel("Agent waiting").first()).toBeVisible({ timeout: 30_000 });
await expect(page.getByLabel("Agent running")).toHaveCount(0);
const pill = page.getByTestId("background-work");
await expect(pill.getByTestId("status-waiting-ring")).toBeVisible();
await expect(pill.getByTestId("status-ring")).toHaveCount(0);
});
test("the row shows the waiting mark at a steady height, then the unread dot when the command ends", async ({
page,
}) => {
const other = await seedMockAgentWorkspace({
repoPrefix: "waiting-status-other-",
title: "Other agent",
initialPrompt: "Finish this turn.",
});
seeded.push(other);
await other.client.waitForFinish(other.agentId, 20_000);
await other.client.clearWorkspaceAttention(other.workspaceId);
await openAgentRoute(page, { workspaceId: other.workspaceId, agentId: other.agentId });
// The command's timer starts when the agent is seeded, so seed it once the app is open.
const subject = await seedBackgroundShellAgent("Row subject");
seeded.push(subject);
const row = workspaceRow(page, subject.workspaceId);
await expect(row.getByTestId("workspace-status-indicator-waiting")).toBeVisible({
timeout: 30_000,
});
const waitingHeight = await rowHeight(page, subject.workspaceId);
await expect(row.getByTestId("workspace-status-indicator-attention")).toBeVisible({
timeout: BACKGROUND_COMMAND_MS + 15_000,
});
expect(await rowHeight(page, subject.workspaceId)).toBe(waitingHeight);
});
test("status grouping files the row under Waiting, then under Ready to review", async ({
page,
}) => {
const other = await seedMockAgentWorkspace({
repoPrefix: "waiting-status-other-",
title: "Other agent",
initialPrompt: "Finish this turn.",
});
seeded.push(other);
await other.client.waitForFinish(other.agentId, 20_000);
await other.client.clearWorkspaceAttention(other.workspaceId);
await openAgentRoute(page, { workspaceId: other.workspaceId, agentId: other.agentId });
await selectSidebarStatusGrouping(page);
const subject = await seedBackgroundShellAgent("Grouped subject");
seeded.push(subject);
const rowTestId = `sidebar-workspace-row-${getServerId()}:${subject.workspaceId}`;
const group = (bucket: string) => page.getByTestId(`sidebar-status-group-rows-${bucket}`);
await expect(group("waiting").getByTestId(rowTestId)).toBeVisible({ timeout: 30_000 });
await expect(page.getByTestId("sidebar-status-group-waiting")).toContainText("Waiting");
await expect(group("running").getByTestId(rowTestId)).toHaveCount(0);
await expect(group("attention").getByTestId(rowTestId)).toBeVisible({
timeout: BACKGROUND_COMMAND_MS + 15_000,
});
await expect(group("waiting").getByTestId(rowTestId)).toHaveCount(0);
});
test("the subagent pill counts a child that only waits on background work as waiting", async ({
page,
}) => {
const workspace = await seedWorkspace({ repoPrefix: "waiting-status-pill-" });
try {
const agents = await seedParentWithSubagent(workspace, {
parentTitle: "Pill parent",
childTitle: "Working child",
});
const waitingChild = await seedSubagent(workspace, {
parentId: agents.parent.id,
title: "Waiting child",
});
await workspace.client.sendAgentMessage(
agents.child.id,
"Please hold a running shell tool call for 90000ms.",
);
await workspace.client.sendAgentMessage(
waitingChild.id,
"Please start a background shell command for 90000ms.",
);
await openAgentRoute(page, { workspaceId: agents.workspaceId, agentId: agents.parent.id });
const pill = page.getByTestId("subagents-track-header");
await expect(pill).toContainText("1 working", { timeout: 30_000 });
await expect(pill).toContainText("1 waiting");
await expect(pill.getByTestId("status-waiting-ring")).toHaveCount(1);
} finally {
await workspace.cleanup();
}
});
});
@@ -290,38 +290,6 @@ export async function selectSidebarStatusGrouping(page: Page): Promise<void> {
await page.getByTestId("sidebar-grouping-status").click();
}
export type SidebarGrouping = "project" | "status" | "none";
export type SidebarSortChoice = "manual" | "created" | "lastPrompt" | "statusChange";
export async function selectSidebarGrouping(page: Page, grouping: SidebarGrouping): Promise<void> {
await openSidebarDisplayPage(page, "sidebar-display-grouping");
await page.getByTestId(`sidebar-grouping-${grouping}`).click();
}
export async function selectSidebarSort(page: Page, sort: SidebarSortChoice): Promise<void> {
await openSidebarDisplayPage(page, "sidebar-display-sort");
await page.getByTestId(`sidebar-sort-${sort}`).click();
}
/** The sorts the Sort page offers, in the order it lists them. */
export async function listOfferedSidebarSorts(page: Page): Promise<string[]> {
await openSidebarDisplayPage(page, "sidebar-display-sort");
const ids = await page
.locator('[data-testid^="sidebar-sort-"]')
.evaluateAll((elements) => elements.map((element) => element.getAttribute("data-testid")));
await closeSidebarDisplayPreferences(page);
return ids.map((id) => (id ?? "").replace("sidebar-sort-", ""));
}
/** What the Sort row on the menu's first page currently reads, or null when there is no row. */
export async function readSidebarSortValue(page: Page): Promise<string | null> {
await page.getByTestId("sidebar-display-preferences-menu").click();
const row = page.getByTestId("sidebar-display-sort");
const text = (await row.count()) === 0 ? null : await row.innerText();
await closeSidebarDisplayPreferences(page);
return text;
}
export async function openMobileAgentSidebar(page: Page): Promise<void> {
await page.getByRole("button", { name: "Open menu" }).click();
}
+7
View File
@@ -1,5 +1,12 @@
{
"identifier": "sh.paseo.gpui",
"icon": "../../../desktop/assets/icon.png",
"window": {
"title": "Paseo",
"width": 1200,
"height": 800,
"titleBar": "hidden",
"menuBar": false
},
"bundle": { "macos": { "minimumSystemVersion": "15.0" } }
}
@@ -1,5 +1,8 @@
{
"icon": "../../../desktop/assets/icon.icns",
"window": {
"trafficLightPosition": { "x": 16, "y": 10 }
},
"bundle": {
"macos": {
"entitlements": "desktop/entitlements.mac.adhoc.plist"
-2
View File
@@ -17,8 +17,6 @@ fn main() {
env!("RN_GPUI_APP_ID"),
)
.js_engine("v8")
.window_title("Paseo GPUI")
.window_size(1024.0, 768.0)
.dev_menu(true);
let app_id = config.app_id.clone();
let config = config.configure_window(move |options| {
+61 -1
View File
@@ -202,6 +202,39 @@ const CASES = [
native: path.join(APP_DIR, "src/components/ui/press-highlight.native.tsx"),
web: path.join(APP_DIR, "src/components/ui/press-highlight.tsx"),
},
{
label: "window chrome host",
origin: path.join(APP_DIR, "src/utils/desktop-window.tsx"),
specifier: "../desktop/window-chrome-host",
gpui: path.join(APP_DIR, "src/desktop/window-chrome-host.gpui.ts"),
native: path.join(APP_DIR, "src/desktop/window-chrome-host.ts"),
web: path.join(APP_DIR, "src/desktop/window-chrome-host.web.ts"),
},
{
label: "titlebar drag surface",
origin: path.join(APP_DIR, "src/components/headers/screen-header.tsx"),
specifier: "../desktop/titlebar-drag-surface",
gpui: path.join(APP_DIR, "src/components/desktop/titlebar-drag-surface.gpui.tsx"),
native: path.join(APP_DIR, "src/components/desktop/titlebar-drag-surface.tsx"),
web: path.join(APP_DIR, "src/components/desktop/titlebar-drag-surface.web.tsx"),
},
{
label: "caption button",
origin: path.join(APP_DIR, "src/components/desktop/window-controls.tsx"),
specifier: "./caption-button",
gpui: path.join(APP_DIR, "src/components/desktop/caption-button.gpui.tsx"),
native: path.join(APP_DIR, "src/components/desktop/caption-button.tsx"),
web: path.join(APP_DIR, "src/components/desktop/caption-button.tsx"),
},
{
label: "window layout",
origin: path.join(APP_DIR, "src/utils/desktop-window.tsx"),
specifier: "../window-layout",
gpui: path.join(APP_DIR, "src/window-layout/index.gpui.tsx"),
ios: path.join(APP_DIR, "src/window-layout/index.ios.tsx"),
native: path.join(APP_DIR, "src/window-layout/index.tsx"),
web: path.join(APP_DIR, "src/window-layout/index.tsx"),
},
];
afterEach(() => {
@@ -223,6 +256,31 @@ describe("GPUI Metro platform rule", () => {
).toBe(item.gpui);
}
// GPUI must resolve @/ alias specifiers for window chrome modules to .gpui.*.
for (const [alias, expected] of [
[
"@/desktop/window-chrome-host",
path.join(APP_DIR, "src/desktop/window-chrome-host.gpui.ts"),
],
[
"@/components/desktop/titlebar-drag-surface",
path.join(APP_DIR, "src/components/desktop/titlebar-drag-surface.gpui.tsx"),
],
[
"@/components/desktop/caption-button",
path.join(APP_DIR, "src/components/desktop/caption-button.gpui.tsx"),
],
["@/window-layout", path.join(APP_DIR, "src/window-layout/index.gpui.tsx")],
] as const) {
const ctx = createResolutionContext(
path.join(APP_DIR, "src/app/_layout.tsx"),
config.resolver.sourceExts,
true,
resolver,
);
expect(config.resolver.resolveRequest(ctx, alias, "desktop").filePath, alias).toBe(expected);
}
// GPUI must not pick Electron's .electron.* files as "desktop".
const browserCtx = createResolutionContext(
path.join(APP_DIR, "src/components/split-container.tsx"),
@@ -259,7 +317,9 @@ describe("GPUI Metro platform rule", () => {
item.specifier,
target.platform,
).filePath;
expect(filePath, `${target.platform}: ${item.label}`).toBe(item[target.expected]);
const expected =
target.platform === "ios" && "ios" in item && item.ios ? item.ios : item[target.expected];
expect(filePath, `${target.platform}: ${item.label}`).toBe(expected);
expect(filePath).not.toContain(".gpui.");
}
}
+25 -25
View File
@@ -15,17 +15,17 @@
"@formatjs/intl-numberformat": "^9.5.0",
"@formatjs/intl-pluralrules": "^6.4.0",
"@formatjs/intl-segmenter": "^12.3.0",
"@react-native-gpui/codegen": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"@react-native-gpui/core": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-core-0.87.0-alpha.5.tgz",
"@react-native-gpui/fs": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"@react-native-gpui/gesture-handler": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"@react-native-gpui/hermes": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"@react-native-gpui/reanimated": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"@react-native-gpui/safe-area-context": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"@react-native-gpui/screens": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"@react-native-gpui/svg": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"@react-native-gpui/v8": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"@react-native-gpui/worklets": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"@react-native-gpui/codegen": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"@react-native-gpui/core": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-core-0.87.0-alpha.5.tgz",
"@react-native-gpui/fs": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"@react-native-gpui/gesture-handler": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"@react-native-gpui/hermes": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"@react-native-gpui/reanimated": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"@react-native-gpui/safe-area-context": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"@react-native-gpui/screens": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"@react-native-gpui/svg": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"@react-native-gpui/v8": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"@react-native-gpui/worklets": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"@react-native/assets-registry": "^0.87.1",
"react": "19.2.3",
"react-native": "0.87.1",
@@ -38,7 +38,7 @@
},
"devDependencies": {
"@react-native-community/cli": "20.2.0",
"@react-native-gpui/cli": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"@react-native-gpui/cli": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"@react-native/babel-preset": "0.87.1",
"@react-native/metro-config": "0.87.1",
"typescript": "^5.8.3"
@@ -1535,7 +1535,7 @@
},
"node_modules/@react-native-gpui/cli": {
"version": "0.87.0-alpha.5",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"integrity": "sha512-UFtxDVt2+S/S4v0GRSM611jfPbE76Ah8/7F4sm/OgfxnyHFKrc6pFXlDYZvWx5i8jnH0WQESoH4azUneR62Nxw==",
"dev": true,
"license": "MIT",
@@ -1545,7 +1545,7 @@
},
"node_modules/@react-native-gpui/codegen": {
"version": "0.87.0-alpha.2",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"integrity": "sha512-VIQDIUELddQTWI5NyAXkopzwCGtEh28LQDpNKsWn4kfomxK1uJ2/TaDjnokw7oQ6ZX/2nJL4hPsmOapvpdpgxg==",
"license": "MIT",
"dependencies": {
@@ -1554,8 +1554,8 @@
},
"node_modules/@react-native-gpui/core": {
"version": "0.87.0-alpha.5",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-core-0.87.0-alpha.5.tgz",
"integrity": "sha512-KMP26Y4940QDk+MRF3jPmq3E8Pg3y0c6/Uln2IWrTbJ4+BdQQsWw+v3ykyj9iPPA1IlQLEWaBVDoq7L6DXiXVg==",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-core-0.87.0-alpha.5.tgz",
"integrity": "sha512-0rGzTzIJ1/xsxIYxnvx6JNMVrGgu+cW/3MGLtrlJy3/lS0Lkmx6Havv6zjQKnF40FZemFFeV/DfQ/QG32XPK8Q==",
"license": "MIT",
"dependencies": {
"@react-native-gpui/codegen": "0.87.0-alpha.2",
@@ -1569,7 +1569,7 @@
},
"node_modules/@react-native-gpui/fs": {
"version": "0.0.1-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"integrity": "sha512-rY8P9oeP/b5bD4Eqyar+7HG1zii0SeqNkTRFnxrYe9kFBbWZjIlHIuI3gMJzJxeDklbGkx4P4DgpLiXQafv3rQ==",
"license": "MIT",
"peerDependencies": {
@@ -1578,7 +1578,7 @@
},
"node_modules/@react-native-gpui/gesture-handler": {
"version": "3.3.0-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"integrity": "sha512-r49zj2PVzKNdsktSFu7nr6lcHLaJLqEwU/NYMxKmoOxL3Wew4HWHIgq9wskQI30CrRAwCdwqXMbgMdTIid+GjQ==",
"license": "MIT",
"peerDependencies": {
@@ -1590,13 +1590,13 @@
},
"node_modules/@react-native-gpui/hermes": {
"version": "0.87.0-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"integrity": "sha512-Hn7rdXbmOi63i5u02j2dFTyBN73573tsxigu2zS1qo0jCgezc/LwAZruU3p94UQ4/GU2OIyvro3zCSvT+qzr2w==",
"license": "MIT"
},
"node_modules/@react-native-gpui/reanimated": {
"version": "4.7.0-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"integrity": "sha512-eclRX3zcObjBfnn6QTkIah9lqc1raoV6X4yC84AF7PZVp+5OddpXlwMxlZSVLdGxSfQ6YjOih3LphrzUNJkahA==",
"license": "MIT",
"peerDependencies": {
@@ -1608,7 +1608,7 @@
},
"node_modules/@react-native-gpui/safe-area-context": {
"version": "5.10.0-alpha.0",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"integrity": "sha512-j+RyCz5J+rQW4FYYNCMvoQSAPnAmgI0iPcCTGmKzSwRcFEx6GZJ8UbosxW1+YbsmiL8hIdEF3baOMYFkr068ZA==",
"license": "MIT",
"peerDependencies": {
@@ -1618,7 +1618,7 @@
},
"node_modules/@react-native-gpui/screens": {
"version": "4.28.0-alpha.2",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"integrity": "sha512-ynH6vfr7kIC2tYTSpfZul1i1NKaSiVYJtNyW+/zT5lO3BfuM4Ya68nr0Zc1LUEuczqN2kWpsuQp9YulSql156Q==",
"license": "MIT",
"peerDependencies": {
@@ -1628,7 +1628,7 @@
},
"node_modules/@react-native-gpui/svg": {
"version": "15.15.0-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"integrity": "sha512-8rgCGIzRfOtUwDCHseAnxonVvmd0qM3dyH7X5p6kCAMuJok2nD/zR45CobxbtWS0dU+nU/T6MJ6th6ENMmRDVg==",
"license": "MIT",
"peerDependencies": {
@@ -1638,13 +1638,13 @@
},
"node_modules/@react-native-gpui/v8": {
"version": "0.87.0-alpha.0",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"integrity": "sha512-NhVYj74T+ZDPDS4EoMaguLeW+dbC+aI+R1JlPJmpPal6MNdgz7iwwo18mWWQ+B0hTz4ov0WB3h3um9rprl8jGw==",
"license": "MIT"
},
"node_modules/@react-native-gpui/worklets": {
"version": "0.13.0-alpha.1",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"integrity": "sha512-TTN9CFwirHVojJM4s6UHUPU/3qA1zdCcUrokS5gf+G9lmdpKKV3sCr7Cqpdr8MzAAC/4ohpou13JZIbnyP3dSg==",
"license": "MIT",
"peerDependencies": {
+12 -12
View File
@@ -10,17 +10,17 @@
"@formatjs/intl-numberformat": "^9.5.0",
"@formatjs/intl-pluralrules": "^6.4.0",
"@formatjs/intl-segmenter": "^12.3.0",
"@react-native-gpui/codegen": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"@react-native-gpui/core": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-core-0.87.0-alpha.5.tgz",
"@react-native-gpui/fs": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"@react-native-gpui/gesture-handler": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"@react-native-gpui/hermes": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"@react-native-gpui/reanimated": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"@react-native-gpui/safe-area-context": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"@react-native-gpui/screens": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"@react-native-gpui/svg": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"@react-native-gpui/v8": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"@react-native-gpui/worklets": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"@react-native-gpui/codegen": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
"@react-native-gpui/core": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-core-0.87.0-alpha.5.tgz",
"@react-native-gpui/fs": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-fs-0.0.1-alpha.1.tgz",
"@react-native-gpui/gesture-handler": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
"@react-native-gpui/hermes": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
"@react-native-gpui/reanimated": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
"@react-native-gpui/safe-area-context": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
"@react-native-gpui/screens": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-screens-4.28.0-alpha.2.tgz",
"@react-native-gpui/svg": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-svg-15.15.0-alpha.1.tgz",
"@react-native-gpui/v8": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-v8-0.87.0-alpha.0.tgz",
"@react-native-gpui/worklets": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
"@react-native/assets-registry": "^0.87.1",
"react": "19.2.3",
"react-native": "0.87.1",
@@ -33,7 +33,7 @@
},
"devDependencies": {
"@react-native-community/cli": "20.2.0",
"@react-native-gpui/cli": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"@react-native-gpui/cli": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
"@react-native/babel-preset": "0.87.1",
"@react-native/metro-config": "0.87.1",
"typescript": "^5.8.3"
+1 -1
View File
@@ -72,7 +72,7 @@ export function buildAgentDescriptor(input: {
return {
label: label ?? "",
subtitle:
statusBucket === "waiting"
statusBucket === "running" && !input.isTurnActive && input.status !== "running"
? i18n.t("message.backgroundWork.running")
: `${formatProviderLabel(provider)} agent`,
tooltip: label ?? `${formatProviderLabel(provider)} agent`,
@@ -9,7 +9,7 @@ import Trash2 from "lucide-react-native/icons/trash";
import X from "lucide-react-native/icons/x";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import type { AgentProfile } from "@getpaseo/protocol/messages";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { Button } from "@/components/ui/button";
import { DismissBackdrop } from "@/components/ui/dismiss-backdrop";
import {
@@ -182,8 +182,7 @@ function DrawerHeader({
const showSteppers = mode === "edit" && Boolean(onStepPrev && onStepNext);
return (
<View style={styles.headerChrome}>
<TitlebarDragRegion />
<TitlebarDragSurface style={styles.headerChrome}>
<WindowChromeSafeArea placement="below" />
<View style={styles.header}>
<View style={styles.headerIdentity}>
@@ -246,7 +245,7 @@ function DrawerHeader({
</ToolbarButton>
</View>
</View>
</View>
</TitlebarDragSurface>
);
}
+22 -12
View File
@@ -36,7 +36,8 @@ import { AppState, useWindowDimensions, View } from "react-native";
import { GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
import { KeyboardProvider } from "react-native-keyboard-controller";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { AppearanceProvider } from "@/appearance/provider";
import { AppearanceProvider, useContributedThemes } from "@/appearance/provider";
import { resolveWindowChromeAppearance } from "@/appearance/theme-catalog";
import { CommandCenter } from "@/command-center/command-center";
import { WorkspaceSwitcherHud } from "@/workspace-switcher";
import { CommandCenterRootActions } from "@/command-center/root-registration";
@@ -81,7 +82,7 @@ import {
resolveSidebarActivity,
resolveLeftSidebarPresentation,
} from "@/components/desktop-sidebar-layout";
import { isNative, isWeb } from "@/constants/platform";
import { isWeb } from "@/constants/platform";
import { HorizontalScrollProvider } from "@/contexts/horizontal-scroll-context";
import { SessionProvider } from "@/contexts/session-context";
import { SidebarCalloutProvider } from "@/contexts/sidebar-callout-context";
@@ -106,7 +107,7 @@ import { AgentNavigationListener } from "@/desktop/agent-navigation";
import { LegacyAgentSkillsMigration } from "@/agent-skills/legacy-migration";
import { legacyFavoriteProfileMigration } from "@/agent-profiles/migration";
import { listenToDesktopEvent } from "@/desktop/electron/events";
import { updateDesktopWindowChrome } from "@/desktop/electron/window";
import { desktopWindowChromeHost } from "@/desktop/window-chrome-host";
import { getDesktopHost } from "@/desktop/host";
import { loadDesktopSettings } from "@/desktop/settings/desktop-settings";
import { RosettaCalloutSource } from "@/desktop/updates/rosetta-callout-source";
@@ -696,19 +697,28 @@ function ProvidersWrapper({ children }: { children: ReactNode }) {
}
function DesktopWindowControlsSync() {
const { isLoading } = useAppSettings();
const { settings, isLoading } = useAppSettings();
const { selected: selectedPluginTheme } = useContributedThemes();
const { theme } = useUnistyles();
const surface0 = theme.colors.surface0;
const appearance = resolveWindowChromeAppearance({
theme: settings.theme,
hasContributedTheme: selectedPluginTheme !== null,
colorScheme: theme.colorScheme,
});
useEffect(() => {
if (isLoading || isNative) return;
void updateDesktopWindowChrome({
backgroundColor: surface0,
trafficLightOffsetY: -4,
}).catch((error) => {
console.warn("[DesktopWindow] Failed to update window controls overlay", error);
});
}, [isLoading, surface0]);
if (isLoading) return;
void desktopWindowChromeHost
.updateChrome({
backgroundColor: surface0,
appearance,
trafficLightOffsetY: -4,
})
.catch((error) => {
console.warn("[DesktopWindow] Failed to update window controls overlay", error);
});
}, [appearance, isLoading, surface0]);
return null;
}
@@ -70,3 +70,20 @@ export function resolveThemeCatalog(input: ResolveThemeCatalogInput): ThemeCatal
return [...builtIn, ...contributed];
}
/**
* Resolves the native window chrome appearance from the user's theme preference.
* Keeps `"system"` when following the OS (including missing-plugin fallback) so
* desktop windows do not lock `NSWindow.appearance` to the current effective colorScheme.
*/
export function resolveWindowChromeAppearance(input: {
theme: ThemePreference;
hasContributedTheme: boolean;
colorScheme: "light" | "dark";
}): "light" | "dark" | "system" {
const effectiveTheme =
input.theme === PLUGIN_THEME_PREFERENCE && !input.hasContributedTheme
? FALLBACK_THEME_PREFERENCE
: input.theme;
return effectiveTheme === "auto" ? "system" : input.colorScheme;
}
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { darkTheme } from "@/styles/theme";
import { resolveThemeCatalog } from "./theme-catalog";
import { resolveThemeCatalog, resolveWindowChromeAppearance } from "./theme-catalog";
import type { PluginThemeOption } from "@/plugins/themes";
const PLUGIN_THEME: PluginThemeOption = {
@@ -68,4 +68,43 @@ describe("resolveThemeCatalog", () => {
missingPlugin.find((option) => option.id === "auto")?.select();
expect(selected).toEqual(["auto"]);
});
it("maps auto and missing plugin fallback to system chrome appearance across Light -> Dark -> System", () => {
expect(
resolveWindowChromeAppearance({
theme: "auto",
hasContributedTheme: false,
colorScheme: "light",
}),
).toBe("system");
expect(
resolveWindowChromeAppearance({
theme: "dark",
hasContributedTheme: false,
colorScheme: "dark",
}),
).toBe("dark");
// Switching back to System ("auto") while theme.colorScheme still reads "dark" must emit "system".
expect(
resolveWindowChromeAppearance({
theme: "auto",
hasContributedTheme: false,
colorScheme: "dark",
}),
).toBe("system");
expect(
resolveWindowChromeAppearance({
theme: "plugin",
hasContributedTheme: true,
colorScheme: "dark",
}),
).toBe("dark");
expect(
resolveWindowChromeAppearance({
theme: "plugin",
hasContributedTheme: false,
colorScheme: "dark",
}),
).toBe("system");
});
});
+1 -4
View File
@@ -18,12 +18,9 @@ function kindKey(kind: string): "shell" | "monitor" | "heartbeat" | "other" {
export function BackgroundWorkTrack({
model,
count,
bucket,
}: {
model: ReturnType<typeof createHostBackgroundWorkModel>;
count: number;
/** `running` while the agent's turn runs; `waiting` once only its background work is alive. */
bucket: "running" | "waiting";
}) {
const { t } = useTranslation();
const { items, status, stops } = useSyncExternalStore(
@@ -43,7 +40,7 @@ export function BackgroundWorkTrack({
panelTitle={t("message.backgroundWork.title")}
segments={[
{
bucket,
bucket: "running",
text:
visibleCount === 1
? t("message.backgroundWork.pillOne")
@@ -0,0 +1,15 @@
import { codegenNativeComponent, type CodegenTypes, type ViewProps } from "react-native";
export type ControlStateEvent = Readonly<{
hovered: boolean;
pressed: boolean;
maximized: boolean;
}>;
export interface NativeProps extends ViewProps {
action?: CodegenTypes.WithDefault<"minimize" | "maximize" | "close", "close">;
disabled?: CodegenTypes.WithDefault<boolean, false>;
onControlStateChange?: CodegenTypes.DirectEventHandler<ControlStateEvent>;
}
export default codegenNativeComponent<NativeProps>("DesktopWindowControl");
@@ -0,0 +1,42 @@
import { useCallback, useState, type ReactNode } from "react";
import type { NativeSyntheticEvent, StyleProp, ViewStyle } from "react-native";
import DesktopWindowControl, {
type ControlStateEvent,
} from "./DesktopWindowControlNativeComponent";
export interface DesktopCaptionButtonProps {
action: "minimize" | "maximize" | "close";
label: string;
style?: StyleProp<ViewStyle>;
children: (state: { hovered: boolean; pressed: boolean }) => ReactNode;
}
export function DesktopCaptionButton({
action,
label,
style,
children,
}: DesktopCaptionButtonProps) {
const [state, setState] = useState({ hovered: false, pressed: false });
const handleControlStateChange = useCallback((event: NativeSyntheticEvent<ControlStateEvent>) => {
const { hovered, pressed } = event.nativeEvent;
setState((previous) =>
previous.hovered === hovered && previous.pressed === pressed
? previous
: { hovered, pressed },
);
}, []);
return (
<DesktopWindowControl
action={action}
accessibilityRole="button"
accessibilityLabel={label}
style={style}
onControlStateChange={handleControlStateChange}
>
{children(state)}
</DesktopWindowControl>
);
}
@@ -0,0 +1,55 @@
import { useCallback, type ReactNode } from "react";
import {
Pressable,
type PressableStateCallbackType,
type StyleProp,
type ViewStyle,
} from "react-native";
import { desktopWindowChromeHost } from "@/desktop/window-chrome-host";
export interface DesktopCaptionButtonProps {
action: "minimize" | "maximize" | "close";
label: string;
style?: StyleProp<ViewStyle>;
children: (state: { hovered: boolean; pressed: boolean }) => ReactNode;
}
function executeCaptionAction(action: DesktopCaptionButtonProps["action"]): void {
if (action === "minimize") {
void desktopWindowChromeHost.minimize();
return;
}
if (action === "maximize") {
void desktopWindowChromeHost.toggleMaximize();
return;
}
void desktopWindowChromeHost.close();
}
export function DesktopCaptionButton({
action,
label,
style,
children,
}: DesktopCaptionButtonProps) {
const handlePress = useCallback(() => {
executeCaptionAction(action);
}, [action]);
const renderChildren = useCallback(
(state: PressableStateCallbackType & { hovered?: boolean }) =>
children({ hovered: Boolean(state.hovered), pressed: state.pressed }),
[children],
);
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={label}
onPress={handlePress}
style={style}
>
{renderChildren}
</Pressable>
);
}
@@ -0,0 +1,9 @@
import { View, type ViewProps } from "react-native";
import type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export function TitlebarDragSurface({ draggable = true, ...props }: TitlebarDragSurfaceProps) {
const dragProps = { desktopDragRegion: draggable } as ViewProps;
return <View {...props} {...dragProps} />;
}
@@ -0,0 +1,11 @@
import { View } from "react-native";
import type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export function TitlebarDragSurface({
draggable: _draggable = true,
...props
}: TitlebarDragSurfaceProps) {
return <View {...props} />;
}
@@ -0,0 +1,6 @@
import type { ViewProps } from "react-native";
export interface TitlebarDragSurfaceProps extends ViewProps {
/** Whether empty non-interactive regions of this surface drag the window. Defaults to true. */
draggable?: boolean;
}
@@ -0,0 +1,18 @@
import { View } from "react-native";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export type { TitlebarDragSurfaceProps } from "./titlebar-drag-surface.types";
export function TitlebarDragSurface({
draggable = true,
children,
...props
}: TitlebarDragSurfaceProps) {
return (
<View {...props}>
{draggable ? <TitlebarDragRegion /> : null}
{children}
</View>
);
}
@@ -0,0 +1,154 @@
import React, { act } from "react";
import { createRoot } from "react-dom/client";
import { Text } from "react-native";
import { afterEach, describe, expect, it, vi } from "vitest";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface.web";
import { DesktopWindowControls } from "@/components/desktop/window-controls";
import { i18n } from "@/i18n/i18next";
import { WindowChromeProvider } from "@/utils/desktop-window";
vi.stubGlobal("React", React);
const container = document.createElement("div");
document.body.appendChild(container);
const root = createRoot(container);
afterEach(() => {
act(() => root.render(null));
delete (window as { paseoDesktop?: unknown }).paseoDesktop;
});
function installElectronDesktop(mode: "native-mac" | "custom-windows" | "custom-linux") {
let isFullscreen = false;
let isMaximized = false;
let resizeHandler: (() => void) | null = null;
const actions: string[] = [];
Object.assign(window, {
paseoDesktop: {
platform: mode === "native-mac" ? "darwin" : "linux",
windowChromeMode: mode,
window: {
getCurrentWindow: () => ({
minimize: async () => {
actions.push("minimize");
},
toggleMaximize: async () => {
actions.push("toggleMaximize");
},
close: async () => {
actions.push("close");
},
isFullscreen: async () => isFullscreen,
isMaximized: async () => isMaximized,
onResized: (handler: () => void) => {
resizeHandler = handler;
return () => {
if (resizeHandler === handler) resizeHandler = null;
};
},
}),
},
},
});
return {
actions,
async emitResize(next: { isFullscreen?: boolean; isMaximized?: boolean }) {
if (next.isFullscreen !== undefined) isFullscreen = next.isFullscreen;
if (next.isMaximized !== undefined) isMaximized = next.isMaximized;
await act(async () => {
resizeHandler?.();
await Promise.resolve();
await Promise.resolve();
});
},
};
}
describe("window chrome seam", () => {
it("renders no drag region outside Electron and renders drag overlay + resizer in Electron", () => {
act(() =>
root.render(
<TitlebarDragSurface testID="drag-surface">
<Text>Title</Text>
</TitlebarDragSurface>,
),
);
expect(container.querySelector("[data-window-drag-region]")).toBeNull();
installElectronDesktop("custom-linux");
act(() =>
root.render(
<>
<TitlebarDragSurface testID="drag-surface-on">
<Text>Title</Text>
</TitlebarDragSurface>
<TitlebarDragSurface testID="drag-surface-off" draggable={false}>
<Text>Static</Text>
</TitlebarDragSurface>
</>,
),
);
const onSurface = container.querySelector('[data-testid="drag-surface-on"]');
const offSurface = container.querySelector('[data-testid="drag-surface-off"]');
const dragRegions = onSurface?.querySelectorAll("[data-window-drag-region]");
expect(dragRegions?.length).toBe(1);
const dragOverlay = dragRegions?.[0] as HTMLElement;
expect(getComputedStyle(dragOverlay).position).toBe("absolute");
expect(getComputedStyle(dragOverlay).getPropertyValue("-webkit-app-region")).toBe("drag");
const resizer = dragOverlay.nextElementSibling as HTMLElement | null;
expect(resizer).not.toBeNull();
expect(getComputedStyle(resizer as HTMLElement).position).toBe("absolute");
expect(getComputedStyle(resizer as HTMLElement).top).toBe("0px");
expect(getComputedStyle(resizer as HTMLElement).height).toBe("4px");
expect(getComputedStyle(resizer as HTMLElement).getPropertyValue("-webkit-app-region")).toBe(
"no-drag",
);
expect(offSurface?.querySelectorAll("[data-window-drag-region]").length).toBe(0);
expect(
[...(offSurface?.querySelectorAll("div") ?? [])].some(
(node) => getComputedStyle(node).getPropertyValue("-webkit-app-region") === "no-drag",
),
).toBe(false);
});
it("drives DesktopWindowControls through WindowChromeProvider and DesktopCaptionButton", async () => {
await i18n.changeLanguage("en");
const electron = installElectronDesktop("custom-linux");
await act(async () => {
root.render(
<WindowChromeProvider>
<DesktopWindowControls />
</WindowChromeProvider>,
);
await Promise.resolve();
await Promise.resolve();
});
const controls = container.querySelector('[data-testid="desktop-window-controls"]');
expect(controls?.getAttribute("data-window-no-drag")).toBe("");
const minimizeBtn = container.querySelector('[aria-label="Minimize window"]');
const maximizeBtn = container.querySelector('[aria-label="Maximize window"]');
const closeBtn = container.querySelector('[aria-label="Close window"]');
expect(minimizeBtn).not.toBeNull();
expect(maximizeBtn).not.toBeNull();
expect(closeBtn).not.toBeNull();
await act(async () => {
(minimizeBtn as HTMLElement).click();
(maximizeBtn as HTMLElement).click();
(closeBtn as HTMLElement).click();
await Promise.resolve();
});
expect(electron.actions).toEqual(["minimize", "toggleMaximize", "close"]);
await electron.emitResize({ isMaximized: true });
expect(container.querySelector('[aria-label="Restore window"]')).not.toBeNull();
await electron.emitResize({ isFullscreen: true });
expect(container.querySelector('[data-testid="desktop-window-controls"]')).toBeNull();
});
});
@@ -1,18 +1,17 @@
import { useCallback, useMemo } from "react";
import { Pressable, View } from "react-native";
import { View } from "react-native";
import Svg, { Line, Rect } from "react-native-svg";
import { useTranslation } from "react-i18next";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import {
closeDesktopWindow,
minimizeDesktopWindow,
toggleDesktopMaximize,
} from "@/desktop/electron/window";
DesktopCaptionButton,
type DesktopCaptionButtonProps,
} from "@/components/desktop/caption-button";
import { WINDOW_NO_DRAG_DATASET } from "@/components/desktop/titlebar-drag-region";
import {
getDesktopWindowControlsPresentation,
type DesktopWindowControlsPresentation,
} from "@/desktop/window-chrome-presentation";
import { WINDOW_NO_DRAG_DATASET } from "@/components/desktop/titlebar-drag-region";
import { useCustomDesktopWindowControls } from "@/utils/desktop-window";
import type { Theme } from "@/styles/theme";
@@ -81,18 +80,18 @@ const mutedGlyphMapping = (theme: Theme) => ({ color: theme.colors.foregroundMut
const whiteGlyphMapping = () => ({ color: "#ffffff" });
function WindowControl({
action,
kind,
label,
onPress,
presentation,
}: {
action: DesktopCaptionButtonProps["action"];
kind: WindowControlKind;
label: string;
onPress: () => void;
presentation: DesktopWindowControlsPresentation;
}) {
const glyph = useCallback(
({ hovered, pressed }: { hovered?: boolean; pressed: boolean }) => {
({ hovered, pressed }: { hovered: boolean; pressed: boolean }) => {
const highlighted = hovered || pressed;
const closeHighlighted = kind === "close" && highlighted;
return (
@@ -122,23 +121,15 @@ function WindowControl({
[presentation.controlWidth],
);
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={label}
onPress={onPress}
style={controlStyle}
>
<DesktopCaptionButton action={action} label={label} style={controlStyle}>
{glyph}
</Pressable>
</DesktopCaptionButton>
);
}
export function DesktopWindowControls() {
const { t } = useTranslation();
const { visible, mode, isMaximized } = useCustomDesktopWindowControls();
const minimize = useCallback(() => void minimizeDesktopWindow(), []);
const toggleMaximize = useCallback(() => void toggleDesktopMaximize(), []);
const close = useCallback(() => void closeDesktopWindow(), []);
if (!visible || !mode) return null;
const presentation = getDesktopWindowControlsPresentation(mode);
@@ -149,23 +140,23 @@ export function DesktopWindowControls() {
testID="desktop-window-controls"
>
<WindowControl
action="minimize"
kind="minimize"
label={t("desktop.windowControls.minimize")}
onPress={minimize}
presentation={presentation}
/>
<WindowControl
action="maximize"
kind={isMaximized ? "restore" : "maximize"}
label={t(
isMaximized ? "desktop.windowControls.restore" : "desktop.windowControls.maximize",
)}
onPress={toggleMaximize}
presentation={presentation}
/>
<WindowControl
action="close"
kind="close"
label={t("desktop.windowControls.close")}
onPress={close}
presentation={presentation}
/>
</View>
@@ -5,7 +5,7 @@ import { router } from "expo-router";
import ArrowLeft from "lucide-react-native/icons/arrow-left";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { StyleSheet, withUnistyles } from "react-native-unistyles";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { HeaderToggleButton } from "@/components/headers/header-toggle-button";
import { SidebarMenuToggle } from "@/components/headers/sidebar-menu-toggle";
import {
@@ -77,30 +77,31 @@ export function CompactHeader({
return (
<IconButtonChromeProvider value="header-island">
<WindowChromeSafeArea placement="inline" style={styles.chromeContainer}>
<TitlebarDragRegion />
<View style={rootStyle}>
<View
style={[
usesTitlebarHeight ? styles.titlebarRow : styles.row,
inDesktopTitlebar && styles.desktopTitlebarDividerSpace,
]}
>
<View style={styles.island}>
{navigation === "menu" ? <SidebarMenuToggle /> : <BackButton onBack={onBack} />}
<TitlebarDragSurface style={styles.chromeContainer}>
<WindowChromeSafeArea placement="inline">
<View style={rootStyle}>
<View
style={[
usesTitlebarHeight ? styles.titlebarRow : styles.row,
inDesktopTitlebar && styles.desktopTitlebarDividerSpace,
]}
>
<View style={styles.island}>
{navigation === "menu" ? <SidebarMenuToggle /> : <BackButton onBack={onBack} />}
</View>
<View style={styles.titleGroup}>
<CompactHeaderTitle
loading={loading}
title={title}
titleTestID={titleTestID}
subtitle={subtitle}
/>
</View>
{actions ? <View style={styles.island}>{actions}</View> : null}
</View>
<View style={styles.titleGroup}>
<CompactHeaderTitle
loading={loading}
title={title}
titleTestID={titleTestID}
subtitle={subtitle}
/>
</View>
{actions ? <View style={styles.island}>{actions}</View> : null}
</View>
</View>
</WindowChromeSafeArea>
</WindowChromeSafeArea>
</TitlebarDragSurface>
</IconButtonChromeProvider>
);
}
@@ -11,7 +11,7 @@ import {
useIsCompactFormFactor,
} from "@/constants/layout";
import { WindowChromeSafeArea } from "@/utils/desktop-window";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
interface ScreenHeaderProps {
left?: ReactNode;
@@ -52,16 +52,17 @@ export function ScreenHeader({
return (
<ComposerDockBackground style={styles.header} testID="composer-dock-header">
<View style={innerStyle}>
<WindowChromeSafeArea
placement="inline"
horizontalPadding={baseHorizontalPadding}
onLayout={onRowLayout}
style={rowStyle}
>
<TitlebarDragRegion />
<View style={leftCombinedStyle}>{left}</View>
<View style={rightCombinedStyle}>{right}</View>
</WindowChromeSafeArea>
<TitlebarDragSurface style={styles.dragSurface}>
<WindowChromeSafeArea
placement="inline"
horizontalPadding={baseHorizontalPadding}
onLayout={onRowLayout}
style={rowStyle}
>
<View style={leftCombinedStyle}>{left}</View>
<View style={rightCombinedStyle}>{right}</View>
</WindowChromeSafeArea>
</TitlebarDragSurface>
</View>
</ComposerDockBackground>
);
@@ -72,6 +73,9 @@ const styles = StyleSheet.create((theme) => ({
backgroundColor: theme.colors.surface0,
},
inner: {},
dragSurface: {
position: "relative",
},
row: {
position: "relative",
height: {
+7 -7
View File
@@ -35,7 +35,7 @@ import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from "react-nativ
import { scheduleOnRN } from "react-native-worklets";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { SidebarCloseButton } from "@/components/headers/sidebar-close-button";
import {
resolveDesktopSidebarInsetLeft,
@@ -868,8 +868,7 @@ function DesktopSidebar({
<View style={desktopSidebarBorderStyle}>
<View style={styles.sidebarDragArea}>
{showsChromeRow ? (
<View style={styles.desktopChromeRow}>
<TitlebarDragRegion />
<TitlebarDragSurface style={styles.desktopChromeRow}>
{DEV_BUILD_LABEL ? (
<View
pointerEvents="none"
@@ -883,12 +882,13 @@ function DesktopSidebar({
</Text>
</View>
) : null}
</View>
</TitlebarDragSurface>
) : null}
{showsDragStrip ? (
<View style={styles.desktopDragStrip} testID="sidebar-nav-drag-strip">
<TitlebarDragRegion />
</View>
<TitlebarDragSurface
style={styles.desktopDragStrip}
testID="sidebar-nav-drag-strip"
/>
) : null}
</View>
{hasNavRows ? (
@@ -17,7 +17,6 @@ import Clock from "lucide-react-native/icons/clock";
import Diff from "lucide-react-native/icons/diff";
import EyeOff from "lucide-react-native/icons/eye-off";
import Folder from "lucide-react-native/icons/folder";
import List from "lucide-react-native/icons/list";
import GitBranch from "lucide-react-native/icons/git-branch";
import GitPullRequest from "lucide-react-native/icons/git-pull-request";
import Globe from "lucide-react-native/icons/globe";
@@ -51,12 +50,6 @@ import {
} from "@/stores/sidebar-view-store";
import { workspaceLabelKey, type WorkspaceLabelColor } from "@getpaseo/protocol/workspace-labels";
import type { WorkspaceTitleSource } from "@/hooks/use-settings";
import {
offeredSidebarSorts,
resolveSidebarSort,
sortNeedsHostSortTimes,
type SidebarSort,
} from "../sidebar-sort";
import { SIDEBAR_CHECKS_DISPLAYS, type SidebarChecksDisplay } from "./checks-display";
import { useSidebarDisplayPreferences, type SidebarTrailingChoice } from "./model";
import { SIDEBAR_ROW_ITEMS, type SidebarRowItem } from "./row-items";
@@ -97,7 +90,6 @@ type OptionIcon = ComponentType<{
const GROUPING_ICONS: Record<SidebarGroupMode, OptionIcon> = {
project: withUnistyles(Folder),
status: withUnistyles(CircleDashed),
none: withUnistyles(List),
};
const TITLE_SOURCE_ICONS: Record<WorkspaceTitleSource, OptionIcon> = {
@@ -129,21 +121,13 @@ const TRAILING_ICONS: Record<SidebarTrailingChoice, OptionIcon> = {
timestamp: withUnistyles(Clock),
};
const GROUPING_MODES: readonly SidebarGroupMode[] = ["project", "status", "none"];
const GROUPING_MODES: readonly SidebarGroupMode[] = ["project", "status"];
const TITLE_SOURCES: readonly WorkspaceTitleSource[] = ["title", "branch"];
const TRAILING_CHOICES: readonly SidebarTrailingChoice[] = ["diff", "timestamp"];
const GROUPING_LABEL_KEYS: Record<SidebarGroupMode, string> = {
project: "sidebar.display.grouping.project",
status: "sidebar.display.grouping.status",
none: "sidebar.display.grouping.none",
};
const SORT_LABEL_KEYS: Record<SidebarSort, string> = {
manual: "sidebar.display.sort.manual",
created: "sidebar.display.sort.created",
lastPrompt: "sidebar.display.sort.lastPrompt",
statusChange: "sidebar.display.sort.statusChange",
};
const TITLE_SOURCE_LABEL_KEYS: Record<WorkspaceTitleSource, string> = {
@@ -198,7 +182,6 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
[],
);
const sortChoice = resolveSidebarSort(preferences.grouping, preferences.workspaceSort);
const showHostFilter = hosts.length > 1;
// One project is the whole sidebar, so filtering to it is a no-op with a menu row attached.
const showProjectFilter = allProjects.length > 1;
@@ -258,17 +241,12 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
},
];
if (sortChoice !== null) {
if (preferences.grouping === "project") {
definitions.push({
id: "sort",
title: t("sidebar.display.sort.label"),
content: (
<SortPage
grouping={preferences.grouping}
selectedSort={sortChoice}
onSelect={preferences.setWorkspaceSort}
hostSortTimesSupported={workspaceSortSupported}
/>
<SortPage preferences={preferences} automaticSortSupported={workspaceSortSupported} />
),
});
}
@@ -306,7 +284,6 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
}, [
t,
preferences,
sortChoice,
workspaceSortSupported,
hosts,
showHostFilter,
@@ -347,15 +324,14 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
>
{t("sidebar.display.grouping.label")}
</MenuSubTrigger>
{sortChoice !== null ? (
{preferences.grouping === "project" ? (
<MenuSubTrigger
id="sort"
value={
workspaceSortSupported || !sortNeedsHostSortTimes(sortChoice)
? t(SORT_LABEL_KEYS[sortChoice])
workspaceSortSupported || preferences.workspaceSort === "manual"
? t(`sidebar.display.sort.${preferences.workspaceSort}`)
: undefined
}
testID="sidebar-display-sort"
>
{t("sidebar.display.sort.label")}
</MenuSubTrigger>
@@ -427,61 +403,38 @@ export function SidebarDisplayPreferencesMenu(): ReactElement {
}
function SortPage({
grouping,
selectedSort,
onSelect,
hostSortTimesSupported,
preferences,
automaticSortSupported,
}: {
grouping: SidebarGroupMode;
selectedSort: SidebarSort;
onSelect: (sort: SidebarSort) => void;
hostSortTimesSupported: boolean;
}): ReactNode {
const { t } = useTranslation();
const items: ReactElement[] = [];
let updateHostShown = false;
for (const sort of offeredSidebarSorts(grouping)) {
if (sortNeedsHostSortTimes(sort) && !hostSortTimesSupported) {
// One row stands in for every sort this host cannot do.
if (!updateHostShown) {
items.push(
<MenuItem key="updateHost" disabled>
{t("sidebar.display.sort.updateHost")}
</MenuItem>,
);
updateHostShown = true;
}
continue;
}
items.push(
<SortOption
key={sort}
sort={sort}
selected={sort === selectedSort}
onSelect={onSelect}
label={t(SORT_LABEL_KEYS[sort])}
/>,
);
}
return items;
}
function SortOption({
sort,
selected,
onSelect,
label,
}: {
sort: SidebarSort;
selected: boolean;
onSelect: (sort: SidebarSort) => void;
label: string;
preferences: Preferences;
automaticSortSupported: boolean;
}): ReactElement {
const handleSelect = useCallback(() => onSelect(sort), [onSelect, sort]);
const { t } = useTranslation();
const { setWorkspaceSort } = preferences;
const selectManual = useCallback(() => setWorkspaceSort("manual"), [setWorkspaceSort]);
const selectCreated = useCallback(() => setWorkspaceSort("created"), [setWorkspaceSort]);
const selectLastPrompt = useCallback(() => setWorkspaceSort("lastPrompt"), [setWorkspaceSort]);
return (
<MenuItem selected={selected} onSelect={handleSelect} testID={`sidebar-sort-${sort}`}>
{label}
</MenuItem>
<>
<MenuItem selected={preferences.workspaceSort === "manual"} onSelect={selectManual}>
{t("sidebar.display.sort.manual")}
</MenuItem>
{automaticSortSupported ? (
<>
<MenuItem selected={preferences.workspaceSort === "created"} onSelect={selectCreated}>
{t("sidebar.display.sort.created")}
</MenuItem>
<MenuItem
selected={preferences.workspaceSort === "lastPrompt"}
onSelect={selectLastPrompt}
>
{t("sidebar.display.sort.lastPrompt")}
</MenuItem>
</>
) : (
<MenuItem disabled>{t("sidebar.display.sort.updateHost")}</MenuItem>
)}
</>
);
}
@@ -1,4 +1,4 @@
import type { SidebarSort } from "../sidebar-sort";
import type { WorkspaceSort } from "@/projects/workspace-structure";
import { useCallback, useMemo } from "react";
import {
useAppSettings,
@@ -26,8 +26,8 @@ export interface SidebarDisplayPreferences {
showBackground: boolean;
toggleBackground: () => void;
grouping: SidebarGroupMode;
workspaceSort: SidebarSort;
setWorkspaceSort: (sort: SidebarSort) => void;
workspaceSort: WorkspaceSort;
setWorkspaceSort: (sort: WorkspaceSort) => void;
setGrouping: (mode: SidebarGroupMode) => void;
titleSource: WorkspaceTitleSource;
setTitleSource: (source: WorkspaceTitleSource) => void;
@@ -21,7 +21,6 @@ import {
STATUS_INDICATOR_FILLED_DOT_SIZE,
} from "@/utils/status-indicator-geometry";
import { StatusRing } from "@/components/status-ring";
import { StatusWaitingRing } from "@/components/status-ring/waiting";
import { getStatusRingOffset } from "@/components/status-ring/geometry";
import type { SidebarSurfaceBackdrop } from "@/styles/surface-backdrop";
@@ -181,7 +180,7 @@ function ProjectStatusBadge({
// Running skips the shell. The ring is wider than the 12pt shell and carries its own knockout,
// so nesting it inside would clip it against the very thing that was meant to separate it from
// the icon. It anchors to the same corner instead, growing around the centre the dot had.
if (content.kind === "dot" && (content.bucket === "running" || content.bucket === "waiting")) {
if (content.kind === "dot" && content.bucket === "running") {
return (
<View
role="status"
@@ -189,11 +188,7 @@ function ProjectStatusBadge({
style={styles.statusRingAnchor}
testID="project-status-badge"
>
{content.bucket === "waiting" ? (
<StatusWaitingRing backdrop={backdrop} />
) : (
<StatusRing backdrop={backdrop} />
)}
<StatusRing backdrop={backdrop} />
</View>
);
}
@@ -262,7 +257,7 @@ function ProjectInlineChevron({ chevron }: { chevron: "expand" | "collapse" | nu
function getStatusDotColorStyle(bucket: ProjectStatusBadgeDotBucket): ViewStyle {
if (bucket === "failed") return styles.statusDotFailed;
if (bucket === "running" || bucket === "waiting") return styles.statusDotRunning;
if (bucket === "running") return styles.statusDotRunning;
return styles.statusDotAttention;
}
@@ -26,8 +26,6 @@ function workspace(
currentBranch: "main",
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -7,8 +7,7 @@ export interface SidebarWorkspaceGroup {
key: string;
label: string;
rows: SidebarWorkspaceEntry[];
/** The header's icon. Null is a group with no header, whose rows cannot be collapsed. */
leading: { kind: "status"; bucket: StatusBucket } | null;
leading: { kind: "status"; bucket: StatusBucket };
}
export function statusWorkspaceGroups(groups: readonly StatusGroup[]): SidebarWorkspaceGroup[] {
@@ -62,7 +62,6 @@ export function SidebarModelProvider({
const list = useSidebarWorkspacesList({ enabled: modelActive });
const showBackground = useSidebarViewStore((state) => state.showBackground);
const groupMode = useSidebarViewStore((state) => state.groupMode);
const workspaceSort = useSidebarViewStore((state) => state.workspaceSort);
const labelFilter = useSidebarViewStore((state) => state.labelFilter);
const projectFilters = useSidebarViewStore((state) => state.projectFilters);
const reconcileLabelFilter = useSidebarViewStore((state) => state.reconcileLabelFilter);
@@ -161,8 +160,6 @@ export function SidebarModelProvider({
workspaceEntriesByKey: filteredWorkspaceEntriesByKey,
projectNamesByViewKey: list.projectNamesByViewKey,
groupMode,
workspaceSort,
workspaceSortSupported: list.workspaceSortSupported,
pinnedCollapsed,
collapsedProjectKeys,
collapsedWorkspaceGroupKeys,
@@ -172,8 +169,6 @@ export function SidebarModelProvider({
collapsedProjectKeys,
collapsedWorkspaceGroupKeys,
groupMode,
workspaceSort,
list.workspaceSortSupported,
list.projectNamesByViewKey,
filteredProjects,
pinnedCollapsed,
@@ -21,8 +21,6 @@ function workspace(workspaceId: string, projectViewKey: string): SidebarWorkspac
currentBranch: "main",
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -6,7 +6,6 @@ import type {
SidebarWorkspacePlacement,
} from "@/hooks/use-sidebar-workspaces-list";
import { buildSidebarProjection } from "./sidebar-projection";
import type { SidebarSort } from "./sidebar-sort";
function makeWorkspace(
id: string,
@@ -32,8 +31,6 @@ function makeWorkspace(
currentBranch: null,
statusBucket,
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -68,8 +65,7 @@ function makeProject(
}
function projectionInput(options?: {
groupMode?: "project" | "status" | "none";
workspaceSort?: SidebarSort;
groupMode?: "project" | "status";
pinnedCollapsed?: boolean;
}) {
const pinned = makeWorkspace("pinned", "running");
@@ -87,8 +83,6 @@ function projectionInput(options?: {
]),
projectNamesByViewKey: new Map([["project", "Project"]]),
groupMode: options?.groupMode ?? ("project" as const),
workspaceSort: options?.workspaceSort ?? ("created" as const),
workspaceSortSupported: true,
pinnedCollapsed: options?.pinnedCollapsed ?? false,
collapsedProjectKeys: new Set<string>(),
collapsedWorkspaceGroupKeys: new Set<string>(),
@@ -100,7 +94,7 @@ function projectionInput(options?: {
* Two projects, one workspace each, both labelled — so every grouping mode puts rows from more
* than one project on screen, and a mode that asked for fewer icons than it renders would show it.
*/
function twoProjectInput(groupMode: "project" | "status" | "none") {
function twoProjectInput(groupMode: "project" | "status") {
const first = makeWorkspace("first", "running", ["Urgent"], "project");
const second = makeWorkspace("second", "needs_input", ["Backend"], "other-project");
return {
@@ -118,14 +112,10 @@ function twoProjectInput(groupMode: "project" | "status" | "none") {
};
}
function rowIds(rows: readonly { workspaceId: string }[] | undefined): string[] {
return (rows ?? []).map((entry) => entry.workspaceId);
}
describe("buildSidebarProjection", () => {
// The rule that outlived the bug it was written for: a project icon is fetched per project, so
// whatever a mode groups by, the rows it produces can only reference projects already covered.
for (const groupMode of ["project", "status", "none"] as const) {
for (const groupMode of ["project", "status"] as const) {
it(`covers every row ${groupMode} grouping renders with a project icon target`, () => {
const projection = buildSidebarProjection(twoProjectInput(groupMode));
const covered = new Set(projection.projectIconTargets.map((target) => target.projectViewKey));
@@ -167,7 +157,9 @@ describe("buildSidebarProjection", () => {
const projection = buildSidebarProjection(projectionInput({ groupMode: "status" }));
expect(projection.workspaceGroups.map((group) => group.key)).toEqual(["needs_input"]);
expect(rowIds(projection.workspaceGroups[0]?.rows)).toEqual(["unpinned"]);
expect(projection.workspaceGroups[0]?.rows.map((entry) => entry.workspaceId)).toEqual([
"unpinned",
]);
expect(projection.shortcutModel.shortcutTargets).toEqual([
{ serverId: "srv", workspaceId: "pinned" },
{ serverId: "srv", workspaceId: "unpinned" },
@@ -183,63 +175,4 @@ describe("buildSidebarProjection", () => {
{ serverId: "srv", workspaceId: "unpinned" },
]);
});
describe("ungrouped", () => {
function ungroupedInput(workspaceSort: SidebarSort) {
const pinned = makeWorkspace("pinned", "running");
const old = makeWorkspace("old", "done");
const recent = makeWorkspace("recent", "done");
old.entry.name = "alpha";
recent.entry.name = "zulu";
old.entry.createdAt = new Date("2026-01-01T00:00:00Z");
old.entry.statusEnteredAt = new Date("2026-03-02T00:00:00Z");
recent.entry.createdAt = new Date("2026-02-01T00:00:00Z");
recent.entry.statusEnteredAt = new Date("2026-03-01T00:00:00Z");
return {
...projectionInput({ groupMode: "none", workspaceSort }),
projects: [makeProject([pinned.placement, old.placement, recent.placement])],
pinnedKeys: {
pinnedWorkspaceKeys: [pinned.placement.workspaceKey],
pinnedAtByKey: { [pinned.placement.workspaceKey]: "2026-07-12T12:00:00.000Z" },
},
workspaceEntriesByKey: new Map(
[pinned, old, recent].map(({ entry }) => [entry.workspaceKey, entry]),
),
};
}
it("is one headerless list of the unpinned workspaces, with pinned chats above it", () => {
const projection = buildSidebarProjection(ungroupedInput("created"));
expect(projection.workspaceGroups).toHaveLength(1);
expect(projection.workspaceGroups[0]?.leading).toBeNull();
expect(rowIds(projection.workspaceGroups[0]?.rows)).toEqual(["recent", "old"]);
expect(rowIds(projection.pinnedGroups.pinnedChats)).toEqual(["pinned"]);
expect(projection.shortcutModel.shortcutTargets).toEqual([
{ serverId: "srv", workspaceId: "pinned" },
{ serverId: "srv", workspaceId: "recent" },
{ serverId: "srv", workspaceId: "old" },
]);
});
it("orders the list by the stored sort", () => {
const byStatusChange = buildSidebarProjection(ungroupedInput("statusChange"));
expect(rowIds(byStatusChange.workspaceGroups[0]?.rows)).toEqual(["old", "recent"]);
});
it("orders by name when a host cannot supply the sort times", () => {
const projection = buildSidebarProjection({
...ungroupedInput("created"),
workspaceSortSupported: false,
});
expect(rowIds(projection.workspaceGroups[0]?.rows)).toEqual(["old", "recent"]);
});
it("reads a stored sort this grouping does not offer as Created", () => {
const projection = buildSidebarProjection(ungroupedInput("manual"));
expect(rowIds(projection.workspaceGroups[0]?.rows)).toEqual(["recent", "old"]);
});
});
});
@@ -1,6 +1,5 @@
import type { TFunction } from "i18next";
import { buildStatusGroups } from "@/hooks/sidebar-status-view-model";
import { sortUngroupedWorkspaces } from "@/hooks/sidebar-ungrouped-view-model";
import {
splitPinnedSidebarGroups,
type PinnedSidebarGroups,
@@ -21,9 +20,6 @@ import {
type SidebarShortcutSection,
} from "@/utils/sidebar-shortcuts";
import { statusWorkspaceGroups, type SidebarWorkspaceGroup } from "./sidebar-labels";
import { resolveUngroupedSortForHosts, type SidebarSort } from "./sidebar-sort";
const UNGROUPED_GROUP_KEY = "all";
export interface SidebarProjection {
pinnedGroups: PinnedSidebarGroups;
@@ -47,9 +43,6 @@ export interface SidebarProjectionInput {
workspaceEntriesByKey: ReadonlyMap<string, SidebarWorkspaceEntry>;
projectNamesByViewKey: Map<string, string>;
groupMode: SidebarGroupMode;
workspaceSort: SidebarSort;
/** False when a host predates the Created and Last prompt times. */
workspaceSortSupported: boolean;
pinnedCollapsed: boolean;
collapsedProjectKeys: ReadonlySet<string>;
collapsedWorkspaceGroupKeys: ReadonlySet<string>;
@@ -86,8 +79,7 @@ export function buildSidebarProjection(input: SidebarProjectionInput): SidebarPr
sections.push(
...workspaceGroups.map((group) => ({
workspaces: group.rows,
// A headerless group has no control to collapse it.
collapsed: group.leading !== null && input.collapsedWorkspaceGroupKeys.has(group.key),
collapsed: input.collapsedWorkspaceGroupKeys.has(group.key),
})),
);
}
@@ -100,10 +92,7 @@ export function buildSidebarProjection(input: SidebarProjectionInput): SidebarPr
};
}
/**
* Project mode keeps its project headers and groups nothing; status mode groups the rows; no
* grouping puts every row in one group that has no header.
*/
/** Project mode keeps its project headers and groups nothing; status mode groups the rows. */
function buildWorkspaceGroups(
input: SidebarProjectionInput,
unpinnedWorkspaces: SidebarWorkspaceEntry[],
@@ -115,20 +104,5 @@ function buildWorkspaceGroups(
return statusWorkspaceGroups(
buildStatusGroups(unpinnedWorkspaces, input.projectNamesByViewKey, input.t),
);
case "none":
return unpinnedWorkspaces.length === 0
? []
: [
{
key: UNGROUPED_GROUP_KEY,
label: "",
rows: sortUngroupedWorkspaces(
unpinnedWorkspaces,
resolveUngroupedSortForHosts(input.workspaceSort, input.workspaceSortSupported),
input.projectNamesByViewKey,
),
leading: null,
},
];
}
}
@@ -1,42 +0,0 @@
import { describe, expect, it } from "vitest";
import {
offeredSidebarSorts,
resolveProjectSort,
resolveSidebarSort,
resolveUngroupedSortForHosts,
resolveUngroupedSort,
} from "./sidebar-sort";
describe("sidebar sort", () => {
it("offers each grouping its own sorts", () => {
expect(offeredSidebarSorts("project")).toEqual(["manual", "created", "lastPrompt"]);
expect(offeredSidebarSorts("status")).toEqual([]);
expect(offeredSidebarSorts("none")).toEqual(["created", "lastPrompt", "statusChange"]);
});
it("shows Created for a stored sort the grouping does not offer", () => {
expect(resolveProjectSort("statusChange")).toBe("created");
expect(resolveUngroupedSort("manual")).toBe("created");
});
it("keeps a stored sort the grouping offers", () => {
expect(resolveProjectSort("manual")).toBe("manual");
expect(resolveProjectSort("lastPrompt")).toBe("lastPrompt");
expect(resolveUngroupedSort("statusChange")).toBe("statusChange");
expect(resolveUngroupedSort("lastPrompt")).toBe("lastPrompt");
});
it("resolves no sort for status grouping", () => {
expect(resolveSidebarSort("status", "lastPrompt")).toBeNull();
expect(resolveSidebarSort("none", "manual")).toBe("created");
expect(resolveSidebarSort("project", "statusChange")).toBe("created");
});
it("gives the flat list no sort when its time sort needs times the hosts do not send", () => {
expect(resolveUngroupedSortForHosts("created", false)).toBeUndefined();
expect(resolveUngroupedSortForHosts("manual", false)).toBeUndefined();
expect(resolveUngroupedSortForHosts("lastPrompt", false)).toBeUndefined();
expect(resolveUngroupedSortForHosts("statusChange", false)).toBe("statusChange");
expect(resolveUngroupedSortForHosts("created", true)).toBe("created");
});
});
@@ -1,75 +0,0 @@
import type { WorkspaceSort } from "@/projects/workspace-structure";
import type { SidebarGroupMode } from "@/stores/sidebar-view-store";
/**
* The stored Sort value. One field serves every grouping, and each grouping offers some of its
* values: Manual only makes sense under project headers, Status change only without them.
*/
export type SidebarSort = WorkspaceSort | "statusChange";
export type UngroupedSort = Exclude<SidebarSort, "manual">;
const PROJECT_SORTS = [
"manual",
"created",
"lastPrompt",
] as const satisfies readonly WorkspaceSort[];
const UNGROUPED_SORTS = [
"created",
"lastPrompt",
"statusChange",
] as const satisfies readonly UngroupedSort[];
const OFFERED_SORTS: Record<SidebarGroupMode, readonly SidebarSort[]> = {
project: PROJECT_SORTS,
// Status grouping has one fixed order, so it offers no choice.
status: [],
none: UNGROUPED_SORTS,
};
export function offeredSidebarSorts(mode: SidebarGroupMode): readonly SidebarSort[] {
return OFFERED_SORTS[mode];
}
/**
* What a grouping displays for the stored sort. A value the grouping does not offer reads as
* Created, and the stored value is left alone so switching back restores it.
*/
export function resolveProjectSort(stored: SidebarSort): WorkspaceSort {
return PROJECT_SORTS.find((sort) => sort === stored) ?? "created";
}
export function resolveUngroupedSort(stored: SidebarSort): UngroupedSort {
return UNGROUPED_SORTS.find((sort) => sort === stored) ?? "created";
}
/** What the Sort row shows for a grouping, or null when the grouping offers no choice. */
export function resolveSidebarSort(
mode: SidebarGroupMode,
stored: SidebarSort,
): SidebarSort | null {
if (mode === "project") return resolveProjectSort(stored);
if (mode === "none") return resolveUngroupedSort(stored);
return null;
}
/**
* Created and Last prompt read times that only hosts from v0.13.0 send, so they cannot order a
* list on an older host. Manual and Status change need nothing newer.
*/
export function sortNeedsHostSortTimes(sort: SidebarSort): boolean {
return sort === "created" || sort === "lastPrompt";
}
/**
* The sort the flat list orders by, or undefined when it has none to apply: a time sort needs
* times the host sends, and a host that predates them has none to order by. Project grouping falls
* back to name order the same way, and the menu offers no matching choice either.
*/
export function resolveUngroupedSortForHosts(
stored: SidebarSort,
hostSortTimesSupported: boolean,
): UngroupedSort | undefined {
const sort = resolveUngroupedSort(stored);
return sortNeedsHostSortTimes(sort) && !hostSortTimesSupported ? undefined : sort;
}
@@ -34,7 +34,6 @@ import ChevronDown from "lucide-react-native/icons/chevron-down";
import ChevronRight from "lucide-react-native/icons/chevron-right";
import CircleAlert from "lucide-react-native/icons/circle-alert";
import CircleCheck from "lucide-react-native/icons/circle-check";
import CircleDashed from "lucide-react-native/icons/circle-dashed";
import CircleDot from "lucide-react-native/icons/circle-dot";
import CircleX from "lucide-react-native/icons/circle-x";
import { useToast } from "@/contexts/toast-context";
@@ -104,15 +103,11 @@ const attentionGroupIconProps = densityIconProps("sm", (theme) => ({
const runningGroupIconProps = densityIconProps("sm", (theme) => ({
color: getStatusDotColor({ theme, bucket: "running" }) ?? undefined,
}));
const waitingGroupIconProps = densityIconProps("sm", (theme) => ({
color: getStatusDotColor({ theme, bucket: "waiting" }) ?? undefined,
}));
const ThemedChevronDown = withUnistyles(ChevronDown);
const ThemedChevronRight = withUnistyles(ChevronRight);
const ThemedCircleAlert = withUnistyles(CircleAlert);
const ThemedCircleCheck = withUnistyles(CircleCheck);
const ThemedCircleDashed = withUnistyles(CircleDashed);
const ThemedCircleDot = withUnistyles(CircleDot);
const ThemedCircleX = withUnistyles(CircleX);
const EMPTY_SHORTCUT_INDEX = new Map<string, number>();
@@ -219,9 +214,7 @@ export function SidebarStatusWorkspaceList({
}
}
for (const group of current.groups) {
const collapsed =
group.leading !== null && current.collapsedWorkspaceGroupKeys.has(group.key);
if (collapsed || group.rows.length === 0) {
if (current.collapsedWorkspaceGroupKeys.has(group.key) || group.rows.length === 0) {
continue;
}
const { leadingItem, visibleItems } = selectSidebarGroupVisibility({
@@ -431,7 +424,7 @@ const STATUS_GROUP_VISIBILITY = {
function StatusGroupRows({
group,
collapsed: collapsedByHeader,
collapsed,
workspacesExpanded,
onToggleWorkspacesExpanded,
projectIconByProjectViewKey,
@@ -455,9 +448,6 @@ function StatusGroupRows({
onToggleWorkspacePin: ToggleSidebarWorkspacePin;
}) {
const activeWorkspaceSelection = useActiveWorkspaceSelection();
// A group with no header has nothing to collapse it with.
const hasHeader = group.leading !== null;
const collapsed = hasHeader && collapsedByHeader;
const toggleWorkspacesExpanded = useCallback(
() => onToggleWorkspacesExpanded(group.key),
[group.key, onToggleWorkspacesExpanded],
@@ -494,9 +484,7 @@ function StatusGroupRows({
return (
<View style={collapsed ? undefined : styles.statusGroupBlockExpanded}>
{group.leading ? (
<StatusGroupHeader group={group} leading={group.leading} collapsed={collapsed} />
) : null}
<StatusGroupHeader group={group} collapsed={collapsed} />
{!collapsed ? (
<View
style={styles.statusWorkspaceListContainer}
@@ -542,11 +530,9 @@ function buildStatusRowProjectPresentation({
function StatusGroupHeader({
group,
leading,
collapsed,
}: {
group: SidebarWorkspaceGroup;
leading: NonNullable<SidebarWorkspaceGroup["leading"]>;
collapsed: boolean;
}) {
const { t } = useTranslation();
@@ -579,7 +565,7 @@ function StatusGroupHeader({
<View style={styles.statusGroupRowLeft}>
<View style={styles.statusGroupLeadingVisualSlot}>
<StatusGroupLeadingVisual
leading={leading}
leading={group.leading}
collapsed={collapsed}
showChevron={isHovered}
/>
@@ -600,7 +586,7 @@ function StatusGroupLeadingVisual({
collapsed,
showChevron,
}: {
leading: NonNullable<SidebarWorkspaceGroup["leading"]>;
leading: SidebarWorkspaceGroup["leading"];
collapsed: boolean;
showChevron: boolean;
}) {
@@ -623,9 +609,6 @@ function StatusGroupIcon({ bucket }: { bucket: StatusBucket }) {
return <ThemedCircleCheck uniProps={attentionGroupIconProps} />;
case "running":
return <ThemedCircleDot uniProps={runningGroupIconProps} />;
case "waiting":
// The dashed circle teaches what the dashed ring on a waiting row means.
return <ThemedCircleDashed uniProps={waitingGroupIconProps} />;
case "done":
return <ThemedCircleCheck uniProps={mutedGroupIconProps} />;
}
@@ -34,7 +34,6 @@ import {
} from "@/utils/status-indicator-geometry";
import { shouldRenderSyncedStatusLoader } from "@/utils/status-loader";
import { StatusRing } from "@/components/status-ring";
import { StatusWaitingRing } from "@/components/status-ring/waiting";
import { resolveSidebarWorkspacePrimaryLabel } from "@/components/sidebar/sidebar-workspace-title";
import { DensityIcon } from "@/components/ui/density-icon";
import { SCRIM_WIDTH, TrailingActionScrim } from "@/components/ui/trailing-action-scrim";
@@ -297,14 +296,6 @@ function WorkspaceStatusIndicator({
);
}
if (bucket === "waiting") {
return (
<View style={styles.workspaceStatusDot} testID="workspace-status-indicator-waiting">
<StatusWaitingRing />
</View>
);
}
if (bucket === "needs_input") {
return (
<View style={styles.workspaceStatusDot} testID="workspace-status-indicator-needs_input">
@@ -358,7 +349,6 @@ function getStatusDotColorStyle(bucket: SidebarStateBucket) {
case "failed":
return styles.statusDotFailed;
case "running":
case "waiting":
return styles.statusDotRunning;
case "attention":
return styles.statusDotAttention;
+43 -38
View File
@@ -39,7 +39,7 @@ import {
resolveChildWindowChromeCorners,
type WindowChromeCorners,
} from "@/utils/desktop-window";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { type TabDropPreview } from "@/components/split-container-tab-drop-preview";
import { SplitDropZone, type SplitDropZoneHover } from "@/components/split-drop-zone";
import { deriveWorkspacePaneState } from "@/screens/workspace/workspace-pane-state";
@@ -816,43 +816,44 @@ const SplitPaneView = memo(function SplitPaneView({
<AdaptiveWorkspaceChrome compactHeader={compactHeader}>
{ownsWorkspaceHeader ? renderMainHeader?.() : null}
<WindowChromeRegion corners={focusModeEnabled ? "both" : "none"}>
<WindowChromeSafeArea placement="inline" style={styles.paneTabs}>
<TitlebarDragRegion />
<WorkspaceDesktopTabsRow
paneId={pane.id}
isFocused={isFocused && isWorkspaceFocused}
tabs={desktopTabRowItems}
normalizedServerId={normalizedServerId}
normalizedWorkspaceId={normalizedWorkspaceId}
setHoveredCloseTabKey={setHoveredCloseTabKey}
onNavigateTab={onNavigateTab}
onCloseTab={onCloseTab}
onCopyResumeCommand={onCopyResumeCommand}
onCopyAgentId={onCopyAgentId}
onCopyTerminalId={onCopyTerminalId}
onReloadAgent={onReloadAgent}
onRenameTab={onRenameTab}
onCloseTabsToLeft={handleCloseTabsToLeft}
onCloseTabsToRight={handleCloseTabsToRight}
onCloseOtherTabs={handleCloseOtherTabs}
onCreateNewTab={onCreateNewTab}
onReorderTabs={handleReorderTabs}
ownsKeyboardShortcuts={false}
externalDndContext
activeDragTabId={activeDragTabId}
tabDropPreviewIndex={
tabDropPreview?.paneId === pane.id ? tabDropPreview.indicatorIndex : null
}
showPaneSplitActions={!focusModeEnabled}
showPaneMaximizeAction={workspaceHasMultiplePanes && !focusModeEnabled}
paneMaximized={paneId === maximizedPaneId}
onTogglePaneMaximized={handleTogglePaneMaximized}
onSplitRight={handleSplitRight}
onSplitDown={handleSplitDown}
focusModeEnabled={Boolean(focusModeEnabled)}
onExitFocusMode={onExitFocusMode}
/>
</WindowChromeSafeArea>
<TitlebarDragSurface style={styles.paneTabsDragSurface}>
<WindowChromeSafeArea placement="inline" style={styles.paneTabs}>
<WorkspaceDesktopTabsRow
paneId={pane.id}
isFocused={isFocused && isWorkspaceFocused}
tabs={desktopTabRowItems}
normalizedServerId={normalizedServerId}
normalizedWorkspaceId={normalizedWorkspaceId}
setHoveredCloseTabKey={setHoveredCloseTabKey}
onNavigateTab={onNavigateTab}
onCloseTab={onCloseTab}
onCopyResumeCommand={onCopyResumeCommand}
onCopyAgentId={onCopyAgentId}
onCopyTerminalId={onCopyTerminalId}
onReloadAgent={onReloadAgent}
onRenameTab={onRenameTab}
onCloseTabsToLeft={handleCloseTabsToLeft}
onCloseTabsToRight={handleCloseTabsToRight}
onCloseOtherTabs={handleCloseOtherTabs}
onCreateNewTab={onCreateNewTab}
onReorderTabs={handleReorderTabs}
ownsKeyboardShortcuts={false}
externalDndContext
activeDragTabId={activeDragTabId}
tabDropPreviewIndex={
tabDropPreview?.paneId === pane.id ? tabDropPreview.indicatorIndex : null
}
showPaneSplitActions={!focusModeEnabled}
showPaneMaximizeAction={workspaceHasMultiplePanes && !focusModeEnabled}
paneMaximized={paneId === maximizedPaneId}
onTogglePaneMaximized={handleTogglePaneMaximized}
onSplitRight={handleSplitRight}
onSplitDown={handleSplitDown}
focusModeEnabled={Boolean(focusModeEnabled)}
onExitFocusMode={onExitFocusMode}
/>
</WindowChromeSafeArea>
</TitlebarDragSurface>
</WindowChromeRegion>
</AdaptiveWorkspaceChrome>
@@ -935,6 +936,10 @@ const styles = StyleSheet.create((theme) => ({
backgroundColor: theme.colors.surface0,
overflow: "hidden",
},
paneTabsDragSurface: {
position: "relative",
minWidth: 0,
},
paneTabs: {
position: "relative",
minWidth: 0,
@@ -6,7 +6,6 @@ import type { SidebarStateBucket } from "@/utils/sidebar-agent-state";
import type { SurfaceBackdrop } from "@/styles/surface-backdrop";
import { getStatusDotColor } from "@/utils/status-dot-color";
import { StatusRing } from "@/components/status-ring";
import { StatusWaitingRing } from "@/components/status-ring/waiting";
import { getStatusRingOffset } from "@/components/status-ring/geometry";
import {
STATUS_INDICATOR_ALERT_SIZE,
@@ -38,7 +37,6 @@ export function StatusIcon({
}: StatusIconProps): ReactElement {
const bucket = statusBucket;
const isRunning = bucket === "running";
const isWaiting = bucket === "waiting";
let statusDotColor: string | undefined;
if (bucket === "failed") statusDotColor = styles.statusDotFailed.color;
else if (bucket === "attention") statusDotColor = styles.statusDotAttention.color;
@@ -70,11 +68,6 @@ export function StatusIcon({
<StatusRing backdrop={backdrop} />
</View>
) : null}
{isWaiting ? (
<View style={styles.statusRing} accessibilityLabel="Agent waiting">
<StatusWaitingRing backdrop={backdrop} />
</View>
) : null}
{statusDotColor ? <View style={statusDotStyle} /> : null}
{showNeedsInputAlert ? (
<View style={styles.statusAlertOverlay}>
@@ -32,23 +32,10 @@ export interface StatusRingProps {
*/
export function StatusRingFrame({ backdrop, children }: StatusRingProps & { children: ReactNode }) {
return (
<StatusMarkFrame backdrop={backdrop} testID="status-ring">
<View style={[styles.frame, getBackdropStyle(backdrop)]} testID="status-ring">
<View style={styles.track} />
{children}
<View style={styles.centerDot} />
</StatusMarkFrame>
);
}
/** The box and knockout every busy mark is drawn in, so running and waiting fill the same space. */
export function StatusMarkFrame({
backdrop,
children,
testID,
}: StatusRingProps & { children: ReactNode; testID: string }) {
return (
<View style={[styles.frame, getBackdropStyle(backdrop)]} testID={testID}>
{children}
</View>
);
}
@@ -27,24 +27,6 @@ export const STATUS_RING_FRAME_SIZE = STATUS_RING_SIZE + STATUS_RING_HALO_INSET
export const STATUS_RING_TRACK_OPACITY = 0.3;
export const STATUS_RING_HEAD_OPACITY = 0.9;
// The waiting mark keeps the running ring's stroke and colour but drops the dot and the motion:
// one circle stroked with a dash pattern, so each dash is a short arc with its ends cut along the
// radius. Nothing is in flight, so nothing turns.
//
// It is drawn smaller than the running ring and centred in the same frame. The frame and its
// knockout stay the size the running ring needs, so nothing around the mark moves; the difference
// is negative space between the ring and the icon art the knockout sits on.
export const STATUS_WAITING_DASH_COUNT = 8;
export const STATUS_WAITING_RING_SIZE = 10;
export const STATUS_WAITING_RING_RADIUS = (STATUS_WAITING_RING_SIZE - STATUS_RING_STROKE) / 2;
// A dash and the gap after it are the same length, so the 8 dashes and 8 gaps close the circle
// with nothing left over at the start point.
export const STATUS_WAITING_DASH_LENGTH =
(2 * Math.PI * STATUS_WAITING_RING_RADIUS) / STATUS_WAITING_DASH_COUNT / 2;
// A stroked circle starts at three o'clock. Half a dash short of twelve puts a dash, not a gap,
// across the top, so the mark is symmetric about both axes.
export const STATUS_WAITING_START_ANGLE = -90 - 360 / STATUS_WAITING_DASH_COUNT / 4;
// One period for every ring in the app. Each platform runs the rings off one clock that does not
// depend on when a ring mounted, so a row that appears mid-flight lands in step with the rings
// already turning.
@@ -1,59 +0,0 @@
import { memo } from "react";
import Svg, { Circle } from "react-native-svg";
import { withUnistyles } from "react-native-unistyles";
import { StatusMarkFrame, type StatusRingProps } from "@/components/status-ring/frame";
import {
STATUS_RING_STROKE,
STATUS_WAITING_DASH_LENGTH,
STATUS_WAITING_RING_RADIUS,
STATUS_WAITING_RING_SIZE,
STATUS_WAITING_START_ANGLE,
} from "@/components/status-ring/geometry";
import { isNative } from "@/constants/platform";
import type { Theme } from "@/styles/theme";
import { getStatusDotColor } from "@/utils/status-dot-color";
const CENTER = STATUS_WAITING_RING_SIZE / 2;
// Wrap the whole SVG: withUnistyles adds a div on web, which cannot sit inside an SVG.
const WaitingRingDashes = withUnistyles(function WaitingRingDashes({ color }: { color?: string }) {
return (
<Svg
width={STATUS_WAITING_RING_SIZE}
height={STATUS_WAITING_RING_SIZE}
viewBox={`0 0 ${STATUS_WAITING_RING_SIZE} ${STATUS_WAITING_RING_SIZE}`}
{...(isNative
? { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants" }
: { "aria-hidden": true })}
>
<Circle
cx={CENTER}
cy={CENTER}
r={STATUS_WAITING_RING_RADIUS}
fill="none"
stroke={color}
strokeWidth={STATUS_RING_STROKE}
strokeLinecap="butt"
strokeDasharray={`${STATUS_WAITING_DASH_LENGTH} ${STATUS_WAITING_DASH_LENGTH}`}
transform={`rotate(${STATUS_WAITING_START_ANGLE} ${CENTER} ${CENTER})`}
/>
</Svg>
);
});
const waitingColorMapping = (theme: Theme) => ({
color: getStatusDotColor({ theme, bucket: "waiting" }) ?? undefined,
});
/**
* The indicator for an agent that has no turn running and is waiting on something it started:
* the running ring's frame, stroke and colour, drawn as a dashed circle (a ring of short arcs)
* with no centre dot and no motion.
*/
export const StatusWaitingRing = memo(function StatusWaitingRing({ backdrop }: StatusRingProps) {
return (
<StatusMarkFrame backdrop={backdrop} testID="status-waiting-ring">
<WaitingRingDashes uniProps={waitingColorMapping} />
</StatusMarkFrame>
);
});
+2 -10
View File
@@ -22,7 +22,6 @@ import {
type MenuTriggerState,
} from "@/components/ui/menu";
import { StatusRing } from "@/components/status-ring";
import { StatusWaitingRing } from "@/components/status-ring/waiting";
import { bySizing } from "@/components/ui/control-geometry";
import {
HorizontalScrollBoundaryShades,
@@ -363,17 +362,10 @@ export function ComposerTrackMark({
</View>
);
}
if (bucket === "waiting") {
return (
<View style={styles.ringMark}>
<StatusWaitingRing />
</View>
);
}
return <View style={dotColorStyle(bucket)} />;
}
function dotColorStyle(bucket: Exclude<SidebarStateBucket, "running" | "waiting">) {
function dotColorStyle(bucket: Exclude<SidebarStateBucket, "running">) {
switch (bucket) {
case "needs_input":
return styles.dotNeedsInput;
@@ -389,7 +381,7 @@ function dotColorStyle(bucket: Exclude<SidebarStateBucket, "running" | "waiting"
const styles = StyleSheet.create((theme) => {
// Colours come from the one bucket-to-colour map so the pill cannot drift from the status dots
// everywhere else, and are baked into each variant so the style prop stays a stable object.
const statusDot = (bucket: Exclude<SidebarStateBucket, "running" | "waiting">) => ({
const statusDot = (bucket: Exclude<SidebarStateBucket, "running">) => ({
width: STATUS_INDICATOR_FILLED_DOT_SIZE,
height: STATUS_INDICATOR_FILLED_DOT_SIZE,
borderRadius: theme.borderRadius.full,
+1 -42
View File
@@ -1,8 +1,4 @@
import {
getDesktopHost,
type DesktopWindowBridge,
type DesktopWindowChromeUpdate,
} from "@/desktop/host";
import { getDesktopHost, type DesktopWindowBridge } from "@/desktop/host";
export function getDesktopWindow(): DesktopWindowBridge | null {
const getter = getDesktopHost()?.window?.getCurrentWindow;
@@ -15,40 +11,3 @@ export function getDesktopWindow(): DesktopWindowBridge | null {
return null;
}
}
export async function minimizeDesktopWindow(): Promise<void> {
await getDesktopWindow()?.minimize?.();
}
export async function closeDesktopWindow(): Promise<void> {
await getDesktopWindow()?.close?.();
}
export async function toggleDesktopMaximize(): Promise<void> {
const win = getDesktopWindow();
if (!win || typeof win.toggleMaximize !== "function") {
return;
}
await win.toggleMaximize();
}
export async function isDesktopMaximized(): Promise<boolean> {
return (await getDesktopWindow()?.isMaximized?.()) ?? false;
}
export async function isDesktopFullscreen(): Promise<boolean> {
const win = getDesktopWindow();
if (!win || typeof win.isFullscreen !== "function") {
return false;
}
return await win.isFullscreen();
}
export async function updateDesktopWindowChrome(update: DesktopWindowChromeUpdate): Promise<void> {
const win = getDesktopWindow();
if (!win || typeof win.updateChrome !== "function") {
return;
}
await win.updateChrome(update);
}
@@ -0,0 +1,260 @@
import { DeviceEventEmitter, Platform, processColor, TurboModuleRegistry } from "react-native";
import type { DesktopWindowChromeMode } from "@/desktop/host";
import type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
DesktopWindowChromeUpdate,
} from "./window-chrome-host.types";
export type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
DesktopWindowChromeUpdate,
} from "./window-chrome-host.types";
const MAIN_WINDOW_ID = 1;
export interface GpuiWindowStateResult {
windowId?: number;
isFullscreen?: boolean;
isMaximized?: boolean;
}
export interface GpuiWindowsModule {
windowGetStateSync?(windowId: number): GpuiWindowStateResult | null | undefined;
windowMinimize?(windowId: number): Promise<void>;
windowToggleMaximize?(windowId: number): Promise<void>;
windowClose?(windowId: number, force: boolean): Promise<void>;
windowSetFullscreen?(windowId: number, fullscreen: boolean): Promise<void>;
windowSetBackgroundColor?(windowId: number, color: number): Promise<void>;
windowSetChromeAppearance?(windowId: number, appearance: string): Promise<void>;
}
export interface GpuiDesktopModule {
capabilities?(): { clientDecorations?: boolean; menuBarInWindow?: boolean } | null | undefined;
}
export interface GpuiAppMenuModule {
menuSetMenuBarVisible?(visible: boolean, windowId?: number): Promise<void>;
}
export interface GpuiEventSubscription {
remove(): void;
}
export interface GpuiWindowChromeDeps {
getPlatformOS: () => string;
getWindowsModule: () => GpuiWindowsModule | null;
getDesktopModule: () => GpuiDesktopModule | null;
getAppMenuModule?: () => GpuiAppMenuModule | null;
addEventListener: (
eventName: string,
handler: (payload: unknown) => void,
) => GpuiEventSubscription;
resolveColor: (color: string) => number | null | undefined;
}
const DEFAULT_GPUI_DEPS: GpuiWindowChromeDeps = {
getPlatformOS: () => Platform.OS,
getWindowsModule: () => TurboModuleRegistry.get("GpuiWindows") as GpuiWindowsModule | null,
getDesktopModule: () => TurboModuleRegistry.get("GpuiDesktop") as GpuiDesktopModule | null,
getAppMenuModule: () => TurboModuleRegistry.get("GpuiAppMenu") as GpuiAppMenuModule | null,
addEventListener: (eventName, handler) => DeviceEventEmitter.addListener(eventName, handler),
resolveColor: (color) => {
const resolved = processColor(color);
return typeof resolved === "number" ? resolved : null;
},
};
function resolveChromeMode(deps: GpuiWindowChromeDeps): DesktopWindowChromeMode | null {
const os = deps.getPlatformOS();
if (os === "macos") return "native-mac";
if (os === "windows") return "custom-windows";
if (os === "linux") {
return deps.getDesktopModule()?.capabilities?.()?.clientDecorations ? "custom-linux" : null;
}
return null;
}
function readWindowFlags(deps: GpuiWindowChromeDeps): {
isFullscreen: boolean;
isMaximized: boolean;
} {
try {
const state = deps.getWindowsModule()?.windowGetStateSync?.(MAIN_WINDOW_ID);
return {
isFullscreen: Boolean(state?.isFullscreen),
isMaximized: Boolean(state?.isMaximized),
};
} catch {
return { isFullscreen: false, isMaximized: false };
}
}
function isUnsupportedError(error: unknown): boolean {
if (typeof error !== "object" || error === null) {
return false;
}
const code = (error as { code?: unknown }).code;
if (code === "unsupported") {
return true;
}
const message = (error as { message?: unknown }).message;
return typeof message === "string" && /not supported/i.test(message);
}
function ignoreUnsupported(promise: Promise<void> | undefined): Promise<void> {
if (!promise) return Promise.resolve();
return promise.catch((error: unknown) => {
if (!isUnsupportedError(error)) {
throw error;
}
});
}
export function createGpuiWindowChromeHost(
deps: GpuiWindowChromeDeps = DEFAULT_GPUI_DEPS,
): DesktopWindowChromeHost {
const listeners = new Set<() => void>();
let snapshot: DesktopWindowChromeSnapshot | null = null;
let stateSub: GpuiEventSubscription | undefined;
let decorationsSub: GpuiEventSubscription | undefined;
function readSnapshot(): DesktopWindowChromeSnapshot {
const { isFullscreen, isMaximized } = readWindowFlags(deps);
return {
mode: resolveChromeMode(deps),
isFullscreen,
isMaximized,
};
}
function ensureSnapshot(): DesktopWindowChromeSnapshot {
if (snapshot === null) {
snapshot = readSnapshot();
}
return snapshot;
}
function setSnapshot(next: DesktopWindowChromeSnapshot): void {
const current = ensureSnapshot();
if (
current.mode === next.mode &&
current.isFullscreen === next.isFullscreen &&
current.isMaximized === next.isMaximized
) {
return;
}
snapshot = next;
for (const listener of listeners) {
listener();
}
}
function startListening(): void {
if (deps.getDesktopModule()?.capabilities?.()?.menuBarInWindow) {
// Re-sync hidden menu bar so rn-gpui reclaims the 26pt strip reserved before bootstrap hid it.
void deps
.getAppMenuModule?.()
?.menuSetMenuBarVisible?.(false, MAIN_WINDOW_ID)
?.catch(() => {});
}
stateSub = deps.addEventListener("gpuiDesktop:windowStateChange", (payload: unknown) => {
if (!payload || typeof payload !== "object") return;
const event = payload as {
windowId?: unknown;
isFullscreen?: unknown;
isMaximized?: unknown;
};
if (event.windowId !== MAIN_WINDOW_ID) return;
const current = ensureSnapshot();
setSnapshot({
mode: resolveChromeMode(deps),
isFullscreen:
typeof event.isFullscreen === "boolean" ? event.isFullscreen : current.isFullscreen,
isMaximized:
typeof event.isMaximized === "boolean" ? event.isMaximized : current.isMaximized,
});
});
decorationsSub = deps.addEventListener("gpuiDesktop:windowDecorations", () => {
const current = ensureSnapshot();
setSnapshot({
mode: resolveChromeMode(deps),
isFullscreen: current.isFullscreen,
isMaximized: current.isMaximized,
});
});
setSnapshot(readSnapshot());
}
function stopListening(): void {
stateSub?.remove();
stateSub = undefined;
decorationsSub?.remove();
decorationsSub = undefined;
}
return {
getSnapshot() {
const current = ensureSnapshot();
if (!stateSub) {
const next = readSnapshot();
if (
current.mode !== next.mode ||
current.isFullscreen !== next.isFullscreen ||
current.isMaximized !== next.isMaximized
) {
snapshot = next;
}
}
return ensureSnapshot();
},
subscribe(listener) {
listeners.add(listener);
if (listeners.size === 1) {
startListening();
}
return () => {
listeners.delete(listener);
if (listeners.size === 0) {
stopListening();
}
};
},
async minimize() {
await deps.getWindowsModule()?.windowMinimize?.(MAIN_WINDOW_ID);
},
async toggleMaximize() {
await deps.getWindowsModule()?.windowToggleMaximize?.(MAIN_WINDOW_ID);
},
async close() {
await deps.getWindowsModule()?.windowClose?.(MAIN_WINDOW_ID, false);
},
async setFullscreen(fullscreen: boolean) {
await deps.getWindowsModule()?.windowSetFullscreen?.(MAIN_WINDOW_ID, fullscreen);
},
async updateChrome(update: DesktopWindowChromeUpdate) {
if (deps.getPlatformOS() !== "macos") return;
const win = deps.getWindowsModule();
if (!win) return;
const tasks: Promise<void>[] = [];
if (update.backgroundColor !== undefined) {
const argb = deps.resolveColor(update.backgroundColor);
if (typeof argb === "number") {
tasks.push(ignoreUnsupported(win.windowSetBackgroundColor?.(MAIN_WINDOW_ID, argb)));
}
}
if (update.appearance !== undefined) {
tasks.push(
ignoreUnsupported(win.windowSetChromeAppearance?.(MAIN_WINDOW_ID, update.appearance)),
);
}
await Promise.all(tasks);
},
};
}
export const desktopWindowChromeHost: DesktopWindowChromeHost = createGpuiWindowChromeHost();
@@ -0,0 +1,23 @@
import type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
} from "./window-chrome-host.types";
const NOOP_SNAPSHOT: DesktopWindowChromeSnapshot = {
mode: null,
isFullscreen: false,
isMaximized: false,
};
const noopAsync = async (): Promise<void> => {};
const noopUnsubscribe = (): void => {};
export const desktopWindowChromeHost: DesktopWindowChromeHost = {
getSnapshot: () => NOOP_SNAPSHOT,
subscribe: () => noopUnsubscribe,
minimize: noopAsync,
toggleMaximize: noopAsync,
close: noopAsync,
setFullscreen: noopAsync,
updateChrome: noopAsync,
};
@@ -0,0 +1,389 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { DesktopWindowBridge, DesktopWindowChromeMode } from "@/desktop/host";
import { desktopWindowChromeHost as defaultWindowChromeHost } from "@/desktop/window-chrome-host.noop";
import {
createElectronWindowChromeHost,
type ElectronWindowChromeDeps,
} from "@/desktop/window-chrome-host.web";
import {
createGpuiWindowChromeHost,
type GpuiDesktopModule,
type GpuiWindowChromeDeps,
type GpuiWindowsModule,
} from "@/desktop/window-chrome-host.gpui";
interface FakeElectronBridgeOptions {
mode: DesktopWindowChromeMode;
ready?: boolean;
isFullscreen?: boolean;
isMaximized?: boolean;
}
function createFakeElectronDeps(options: FakeElectronBridgeOptions) {
let ready = options.ready ?? true;
let isFullscreen = options.isFullscreen ?? false;
let isMaximized = options.isMaximized ?? false;
let resizeHandler: (() => void) | null = null;
const calls: Array<{ method: string; arg?: unknown }> = [];
const bridge: DesktopWindowBridge = {
minimize: async () => {
calls.push({ method: "minimize" });
},
toggleMaximize: async () => {
calls.push({ method: "toggleMaximize" });
},
close: async () => {
calls.push({ method: "close" });
},
setFullscreen: async (fullscreen: boolean) => {
calls.push({ method: "setFullscreen", arg: fullscreen });
},
updateChrome: async (update) => {
calls.push({ method: "updateChrome", arg: update });
},
isFullscreen: async () => isFullscreen,
isMaximized: async () => isMaximized,
onResized: <TEvent = unknown>(handler: (event: TEvent) => void) => {
const invoke = () => handler({} as TEvent);
resizeHandler = invoke;
return () => {
if (resizeHandler === invoke) {
resizeHandler = null;
}
};
},
};
const deps: ElectronWindowChromeDeps = {
isElectronRuntime: () => ready,
getChromeMode: () => (ready ? options.mode : null),
getWindow: () => (ready ? bridge : null),
};
return {
deps,
calls,
hasResizeListener: () => resizeHandler !== null,
setReady(nextReady: boolean) {
ready = nextReady;
},
emitResize(next: { isFullscreen?: boolean; isMaximized?: boolean }) {
if (next.isFullscreen !== undefined) isFullscreen = next.isFullscreen;
if (next.isMaximized !== undefined) isMaximized = next.isMaximized;
resizeHandler?.();
},
};
}
async function flushAsyncWork() {
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
}
describe("window-chrome-host", () => {
afterEach(() => {
vi.useRealTimers();
});
it("provides a null-mode no-op host through the default module", async () => {
expect(defaultWindowChromeHost.getSnapshot()).toEqual({
mode: null,
isFullscreen: false,
isMaximized: false,
});
const listener = vi.fn();
const unsubscribe = defaultWindowChromeHost.subscribe(listener);
await expect(defaultWindowChromeHost.minimize()).resolves.toBeUndefined();
await expect(defaultWindowChromeHost.toggleMaximize()).resolves.toBeUndefined();
await expect(defaultWindowChromeHost.close()).resolves.toBeUndefined();
await expect(defaultWindowChromeHost.setFullscreen(true)).resolves.toBeUndefined();
await expect(
defaultWindowChromeHost.updateChrome({ backgroundColor: "#181b1a", appearance: "dark" }),
).resolves.toBeUndefined();
unsubscribe();
expect(listener).not.toHaveBeenCalled();
});
it("syncs Electron window state, forwards commands, and strips GPUI-only chrome fields", async () => {
const fake = createFakeElectronDeps({
mode: "custom-linux",
isFullscreen: false,
isMaximized: false,
});
const host = createElectronWindowChromeHost(fake.deps);
expect(host.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: false,
isMaximized: false,
});
const onChange = vi.fn();
const unsubscribe = host.subscribe(onChange);
await flushAsyncWork();
expect(fake.hasResizeListener()).toBe(true);
fake.emitResize({ isMaximized: true });
await flushAsyncWork();
expect(host.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: false,
isMaximized: true,
});
expect(onChange).toHaveBeenCalled();
fake.emitResize({ isFullscreen: true });
await flushAsyncWork();
expect(host.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: true,
isMaximized: true,
});
await host.minimize();
await host.toggleMaximize();
await host.close();
await host.setFullscreen(false);
await host.updateChrome({
backgroundColor: "#181B1A",
appearance: "dark",
trafficLightOffsetY: -4,
});
expect(fake.calls).toEqual([
{ method: "minimize" },
{ method: "toggleMaximize" },
{ method: "close" },
{ method: "setFullscreen", arg: false },
{
method: "updateChrome",
arg: { backgroundColor: "#181B1A", trafficLightOffsetY: -4 },
},
]);
unsubscribe();
expect(fake.hasResizeListener()).toBe(false);
});
it("retries until the Electron preload bridge becomes available", async () => {
vi.useFakeTimers();
const fake = createFakeElectronDeps({
mode: "native-mac",
ready: false,
isFullscreen: false,
isMaximized: false,
});
const host = createElectronWindowChromeHost(fake.deps);
expect(host.getSnapshot()).toEqual({
mode: null,
isFullscreen: false,
isMaximized: false,
});
const onChange = vi.fn();
const unsubscribe = host.subscribe(onChange);
expect(onChange).not.toHaveBeenCalled();
fake.setReady(true);
await vi.advanceTimersByTimeAsync(250);
await flushAsyncWork();
expect(fake.hasResizeListener()).toBe(true);
expect(host.getSnapshot()).toEqual({
mode: "native-mac",
isFullscreen: false,
isMaximized: false,
});
expect(onChange).toHaveBeenCalled();
unsubscribe();
});
it("reads GPUI sync window state, maps OS/CSD chrome modes, subscribes to main-window events, and forwards commands", async () => {
let platformOS = "macos";
let clientDecorations = true;
let isFullscreen = false;
let isMaximized = true;
const listeners = new Map<string, Set<(payload: unknown) => void>>();
const calls: Array<{ method: string; args: unknown[] }> = [];
const windowsModule: GpuiWindowsModule = {
windowGetStateSync: (windowId) => ({
windowId,
isFullscreen,
isMaximized,
}),
windowMinimize: async (windowId) => {
calls.push({ method: "windowMinimize", args: [windowId] });
},
windowToggleMaximize: async (windowId) => {
calls.push({ method: "windowToggleMaximize", args: [windowId] });
},
windowClose: async (windowId, force) => {
calls.push({ method: "windowClose", args: [windowId, force] });
},
windowSetFullscreen: async (windowId, fullscreen) => {
calls.push({ method: "windowSetFullscreen", args: [windowId, fullscreen] });
},
windowSetBackgroundColor: async (windowId, color) => {
calls.push({ method: "windowSetBackgroundColor", args: [windowId, color] });
},
windowSetChromeAppearance: async (windowId, appearance) => {
calls.push({ method: "windowSetChromeAppearance", args: [windowId, appearance] });
},
};
const desktopModule: GpuiDesktopModule = {
capabilities: () => ({ clientDecorations, menuBarInWindow: platformOS !== "macos" }),
};
const deps: GpuiWindowChromeDeps = {
getPlatformOS: () => platformOS,
getWindowsModule: () => windowsModule,
getDesktopModule: () => desktopModule,
getAppMenuModule: () => ({
menuSetMenuBarVisible: async (visible, windowId) => {
calls.push({ method: "menuSetMenuBarVisible", args: [visible, windowId] });
},
}),
addEventListener: (eventName, handler) => {
let bucket = listeners.get(eventName);
if (!bucket) {
bucket = new Set();
listeners.set(eventName, bucket);
}
bucket.add(handler);
return {
remove: () => {
bucket.delete(handler);
},
};
},
resolveColor: () => 0xff181b1a,
};
const emit = (eventName: string, payload: unknown) => {
for (const handler of listeners.get(eventName) ?? []) {
handler(payload);
}
};
// macOS -> native-mac with initial sync state
const macHost = createGpuiWindowChromeHost(deps);
expect(macHost.getSnapshot()).toEqual({
mode: "native-mac",
isFullscreen: false,
isMaximized: true,
});
// Windows -> custom-windows
platformOS = "windows";
expect(createGpuiWindowChromeHost(deps).getSnapshot().mode).toBe("custom-windows");
// Linux -> custom-linux when CSD is active, null when SSD
platformOS = "linux";
isMaximized = false;
const linuxHost = createGpuiWindowChromeHost(deps);
expect(linuxHost.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: false,
isMaximized: false,
});
const onChange = vi.fn();
const unsubscribe = linuxHost.subscribe(onChange);
expect(listeners.get("gpuiDesktop:windowStateChange")?.size).toBe(1);
expect(listeners.get("gpuiDesktop:windowDecorations")?.size).toBe(1);
// Secondary window state changes must not affect main window snapshot
emit("gpuiDesktop:windowStateChange", {
windowId: 2,
isFullscreen: true,
isMaximized: true,
});
expect(linuxHost.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: false,
isMaximized: false,
});
// Main window state changes update snapshot
emit("gpuiDesktop:windowStateChange", {
windowId: 1,
isFullscreen: true,
isMaximized: true,
});
expect(linuxHost.getSnapshot()).toEqual({
mode: "custom-linux",
isFullscreen: true,
isMaximized: true,
});
// Wayland decorations settling to SSD switches mode to null
clientDecorations = false;
emit("gpuiDesktop:windowDecorations", {});
expect(linuxHost.getSnapshot()).toEqual({
mode: null,
isFullscreen: true,
isMaximized: true,
});
expect(onChange).toHaveBeenCalledTimes(2);
await linuxHost.minimize();
await linuxHost.toggleMaximize();
await linuxHost.close();
await linuxHost.setFullscreen(false);
// Non-macOS updateChrome skips unsupported macOS-only calls; macOS forwards them.
await linuxHost.updateChrome({
backgroundColor: "#181B1A",
appearance: "dark",
trafficLightOffsetY: -4,
});
platformOS = "macos";
await linuxHost.updateChrome({
backgroundColor: "#181B1A",
appearance: "dark",
trafficLightOffsetY: -4,
});
expect(calls).toEqual([
{ method: "menuSetMenuBarVisible", args: [false, 1] },
{ method: "windowMinimize", args: [1] },
{ method: "windowToggleMaximize", args: [1] },
{ method: "windowClose", args: [1, false] },
{ method: "windowSetFullscreen", args: [1, false] },
{ method: "windowSetBackgroundColor", args: [1, 0xff181b1a] },
{ method: "windowSetChromeAppearance", args: [1, "dark"] },
]);
unsubscribe();
expect(listeners.get("gpuiDesktop:windowStateChange")?.size).toBe(0);
expect(listeners.get("gpuiDesktop:windowDecorations")?.size).toBe(0);
});
it("ignores unsupported rejections in GPUI updateChrome", async () => {
const unsupported = Object.assign(
new Error("window background colors are not supported on this platform"),
{
code: "",
},
);
const host = createGpuiWindowChromeHost({
getPlatformOS: () => "macos",
getWindowsModule: () => ({
windowSetBackgroundColor: async () => {
throw unsupported;
},
windowSetChromeAppearance: async () => {
throw Object.assign(new Error("unsupported"), { code: "unsupported" });
},
}),
getDesktopModule: () => ({ capabilities: () => ({ clientDecorations: true }) }),
addEventListener: () => ({ remove: () => {} }),
resolveColor: () => 0xff181b1a,
});
await expect(
host.updateChrome({ backgroundColor: "#181B1A", appearance: "dark" }),
).resolves.toBeUndefined();
});
});
@@ -0,0 +1,7 @@
export type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
DesktopWindowChromeUpdate,
} from "./window-chrome-host.types";
export { desktopWindowChromeHost } from "./window-chrome-host.noop";
@@ -0,0 +1,23 @@
import type { DesktopWindowChromeMode } from "@/desktop/host";
export interface DesktopWindowChromeSnapshot {
mode: DesktopWindowChromeMode | null;
isFullscreen: boolean;
isMaximized: boolean;
}
export interface DesktopWindowChromeUpdate {
backgroundColor?: string;
appearance?: "light" | "dark" | "system";
trafficLightOffsetY?: number;
}
export interface DesktopWindowChromeHost {
getSnapshot(): DesktopWindowChromeSnapshot;
subscribe(listener: () => void): () => void;
minimize(): Promise<void>;
toggleMaximize(): Promise<void>;
close(): Promise<void>;
setFullscreen(fullscreen: boolean): Promise<void>;
updateChrome(update: DesktopWindowChromeUpdate): Promise<void>;
}
@@ -0,0 +1,253 @@
import { getDesktopWindow } from "@/desktop/electron/window";
import {
getDesktopWindowChromeMode,
isElectronRuntime,
type DesktopWindowBridge,
type DesktopWindowChromeMode,
} from "@/desktop/host";
import type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
DesktopWindowChromeUpdate,
} from "./window-chrome-host.types";
export type {
DesktopWindowChromeHost,
DesktopWindowChromeSnapshot,
DesktopWindowChromeUpdate,
} from "./window-chrome-host.types";
export interface ElectronWindowChromeDeps {
isElectronRuntime: () => boolean;
getChromeMode: () => DesktopWindowChromeMode | null;
getWindow: () => DesktopWindowBridge | null;
}
const DEFAULT_ELECTRON_DEPS: ElectronWindowChromeDeps = {
isElectronRuntime,
getChromeMode: getDesktopWindowChromeMode,
getWindow: getDesktopWindow,
};
const MAX_PRELOAD_RETRIES = 40;
const PRELOAD_RETRY_DELAY_MS = 250;
export function createElectronWindowChromeHost(
deps: ElectronWindowChromeDeps = DEFAULT_ELECTRON_DEPS,
): DesktopWindowChromeHost {
const listeners = new Set<() => void>();
const readCurrentMode = () => (deps.isElectronRuntime() ? deps.getChromeMode() : null);
let snapshot: DesktopWindowChromeSnapshot | null = null;
let connectionGeneration = 0;
let connecting = false;
let disposeResize: (() => void) | undefined;
let retryCount = 0;
let retryTimer: ReturnType<typeof setTimeout> | undefined;
function ensureSnapshot(): DesktopWindowChromeSnapshot {
if (snapshot === null) {
snapshot = {
mode: readCurrentMode(),
isFullscreen: false,
isMaximized: false,
};
}
return snapshot;
}
function setSnapshot(next: DesktopWindowChromeSnapshot): void {
const current = ensureSnapshot();
if (
current.mode === next.mode &&
current.isFullscreen === next.isFullscreen &&
current.isMaximized === next.isMaximized
) {
return;
}
snapshot = next;
for (const listener of listeners) {
listener();
}
}
function stopConnection(): void {
connectionGeneration += 1;
connecting = false;
retryCount = 0;
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = undefined;
}
const dispose = disposeResize;
disposeResize = undefined;
dispose?.();
}
function scheduleRetry(generation: number, warnOnExhaustion = false): void {
if (
generation !== connectionGeneration ||
listeners.size === 0 ||
disposeResize ||
retryTimer
) {
return;
}
if (retryCount >= MAX_PRELOAD_RETRIES) {
if (warnOnExhaustion) {
console.warn("[DesktopWindow] Chrome bridge unavailable; window controls may overlap UI");
}
return;
}
retryCount += 1;
retryTimer = setTimeout(() => {
retryTimer = undefined;
connect(generation);
}, PRELOAD_RETRY_DELAY_MS);
}
function connect(generation: number): void {
if (
generation !== connectionGeneration ||
listeners.size === 0 ||
disposeResize ||
connecting
) {
return;
}
if (!deps.isElectronRuntime()) {
scheduleRetry(generation);
return;
}
const desktopWindow = deps.getWindow();
if (
!desktopWindow ||
typeof desktopWindow.isFullscreen !== "function" ||
typeof desktopWindow.onResized !== "function"
) {
scheduleRetry(generation, true);
return;
}
const readFullscreen = desktopWindow.isFullscreen;
const readMaximized = desktopWindow.isMaximized;
const subscribeToResized = desktopWindow.onResized;
connecting = true;
void (async () => {
async function syncWindowState(): Promise<void> {
if (generation !== connectionGeneration || listeners.size === 0) return;
try {
const [isFullscreen, isMaximized] = await Promise.all([
readFullscreen(),
readMaximized?.() ?? false,
]);
if (generation !== connectionGeneration || listeners.size === 0) return;
setSnapshot({
mode: readCurrentMode(),
isFullscreen,
isMaximized,
});
} catch (error) {
if (generation === connectionGeneration && listeners.size > 0) {
console.warn("[DesktopWindow] Failed to read window state", error);
}
}
}
try {
const nextDispose = await subscribeToResized(() => {
void syncWindowState();
});
if (generation !== connectionGeneration || listeners.size === 0) {
nextDispose();
return;
}
disposeResize = nextDispose;
const current = ensureSnapshot();
setSnapshot({
mode: readCurrentMode(),
isFullscreen: current.isFullscreen,
isMaximized: current.isMaximized,
});
await syncWindowState();
} catch (error) {
if (generation === connectionGeneration && listeners.size > 0) {
console.warn("[DesktopWindow] Failed to subscribe to resize", error);
}
} finally {
if (generation === connectionGeneration) {
connecting = false;
if (!disposeResize) {
scheduleRetry(generation);
}
}
}
})();
}
return {
getSnapshot() {
const current = ensureSnapshot();
if (!disposeResize) {
const mode = readCurrentMode();
if (mode !== current.mode) {
snapshot = {
mode,
isFullscreen: false,
isMaximized: false,
};
}
}
return ensureSnapshot();
},
subscribe(listener) {
listeners.add(listener);
if (listeners.size === 1) {
connect(connectionGeneration);
}
return () => {
listeners.delete(listener);
if (listeners.size === 0) {
stopConnection();
}
};
},
async minimize() {
await deps.getWindow()?.minimize?.();
},
async toggleMaximize() {
const win = deps.getWindow();
if (typeof win?.toggleMaximize === "function") {
await win.toggleMaximize();
}
},
async close() {
await deps.getWindow()?.close?.();
},
async setFullscreen(fullscreen: boolean) {
await deps.getWindow()?.setFullscreen?.(fullscreen);
},
async updateChrome(update: DesktopWindowChromeUpdate) {
const win = deps.getWindow();
if (typeof win?.updateChrome !== "function") {
return;
}
const electronUpdate = {
...(update.backgroundColor !== undefined
? { backgroundColor: update.backgroundColor }
: {}),
...(update.trafficLightOffsetY !== undefined
? { trafficLightOffsetY: update.trafficLightOffsetY }
: {}),
};
if (
electronUpdate.backgroundColor === undefined &&
electronUpdate.trafficLightOffsetY === undefined
) {
return;
}
await win.updateChrome(electronUpdate);
},
};
}
export const desktopWindowChromeHost: DesktopWindowChromeHost = createElectronWindowChromeHost();
@@ -27,8 +27,6 @@ function ws(
currentBranch: input.currentBranch ?? null,
statusBucket: input.statusBucket ?? "done",
statusEnteredAt: input.statusEnteredAt ?? null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -66,42 +64,6 @@ describe("buildStatusGroups", () => {
expect(groups[2]?.label).toBe("Done");
});
it("gives waiting workspaces their own Waiting group between Working and Done", () => {
const workspaces = [
ws({ workspaceKey: "srv:done-ws", statusBucket: "done", name: "done-ws" }),
ws({ workspaceKey: "srv:waiting-ws", statusBucket: "waiting", name: "waiting-ws" }),
ws({ workspaceKey: "srv:running-ws", statusBucket: "running", name: "running-ws" }),
];
const groups = buildStatusGroups(workspaces, emptyProjectNames, i18n.t);
expect(groups.map((g) => g.bucket)).toEqual(["running", "waiting", "done"]);
expect(groups.map((g) => g.label)).toEqual(["Working", "Waiting", "Done"]);
expect(groups[0]?.rows.map((w) => w.name)).toEqual(["running-ws"]);
expect(groups[1]?.rows.map((w) => w.name)).toEqual(["waiting-ws"]);
});
it("orders waiting rows like every other group, newest entry first", () => {
const workspaces = [
ws({
workspaceKey: "srv:older",
statusBucket: "waiting",
name: "older",
statusEnteredAt: d("2026-01-01T10:00:00Z"),
}),
ws({
workspaceKey: "srv:newer",
statusBucket: "waiting",
name: "newer",
statusEnteredAt: d("2026-01-01T11:00:00Z"),
}),
];
const groups = buildStatusGroups(workspaces, emptyProjectNames, i18n.t);
expect(groups[0]?.rows.map((w) => w.name)).toEqual(["newer", "older"]);
});
it("omits empty buckets", () => {
const workspaces = [
ws({ workspaceKey: "srv:a", statusBucket: "done" }),
@@ -216,11 +178,6 @@ describe("buildStatusGroups", () => {
statusBucket: "running",
statusEnteredAt: d("2026-01-01T00:00:00Z"),
}),
ws({
workspaceKey: "srv:wait",
statusBucket: "waiting",
statusEnteredAt: d("2026-01-01T00:00:00Z"),
}),
ws({ workspaceKey: "srv:dn", statusBucket: "done", statusEnteredAt: null }),
];
@@ -284,7 +241,6 @@ describe("getStatusBucketLabel", () => {
"Échec",
"À relire",
"En cours",
"En attente",
"Terminé",
]);
} finally {
@@ -2,7 +2,6 @@ import type { TFunction } from "i18next";
import { STATUS_BUCKET_ORDER } from "@/utils/sidebar-agent-state";
import type { SidebarWorkspaceEntry } from "@/hooks/sidebar-workspaces-view-model";
/** A group in status grouping. A row is in the group named by its own status, and no other. */
export type StatusBucket = SidebarWorkspaceEntry["statusBucket"];
export { STATUS_BUCKET_ORDER };
@@ -12,14 +11,10 @@ const STATUS_BUCKET_LABEL_KEYS = {
failed: "sidebar.statusBucket.failed",
attention: "sidebar.statusBucket.readyToReview",
running: "sidebar.statusBucket.working",
waiting: "sidebar.statusBucket.waiting",
done: "sidebar.statusBucket.done",
} as const satisfies Record<SidebarWorkspaceEntry["statusBucket"], string>;
} as const satisfies Record<StatusBucket, string>;
export function getStatusBucketLabel(
bucket: SidebarWorkspaceEntry["statusBucket"],
t: TFunction,
): string {
export function getStatusBucketLabel(bucket: StatusBucket, t: TFunction): string {
return t(STATUS_BUCKET_LABEL_KEYS[bucket]);
}
@@ -37,7 +32,7 @@ export function buildStatusGroups(
const bucketRows = new Map<StatusBucket, SidebarWorkspaceEntry[]>();
for (const ws of workspaces) {
const bucket = ws.statusBucket;
const bucket: StatusBucket = ws.statusBucket;
let rows = bucketRows.get(bucket);
if (!rows) {
rows = [];
@@ -59,7 +54,7 @@ export function buildStatusGroups(
return groups;
}
export function compareStatusRows(
function compareStatusRows(
a: SidebarWorkspaceEntry,
b: SidebarWorkspaceEntry,
projectNamesByViewKey: Map<string, string>,
@@ -1,199 +0,0 @@
import { describe, expect, it } from "vitest";
import type { SidebarWorkspaceEntry } from "./sidebar-workspaces-view-model";
import { sortUngroupedWorkspaces } from "./sidebar-ungrouped-view-model";
function ws(
input: Partial<SidebarWorkspaceEntry> & { workspaceKey: string },
): SidebarWorkspaceEntry {
return {
serverId: "srv",
workspaceId: input.workspaceKey.split(":")[1] ?? "ws",
projectViewKey: "proj",
projectName: "Project",
workspaceDirectory: "",
workspaceDirectoryLabel: "",
projectKind: "git",
workspaceKind: "worktree",
name: input.workspaceKey,
title: null,
currentBranch: null,
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
archiveHasUncommittedChanges: null,
archiveUnpushedCommitCount: null,
scripts: [],
hasRunningScripts: false,
...input,
};
}
function d(iso: string): Date {
return new Date(iso);
}
function keys(rows: SidebarWorkspaceEntry[]): string[] {
return rows.map((row) => row.workspaceKey);
}
const projectNames = new Map<string, string>();
describe("sortUngroupedWorkspaces", () => {
it("orders the whole list by created time, newest first, across projects", () => {
const rows = [
ws({ workspaceKey: "srv:old", projectViewKey: "a", createdAt: d("2026-01-01T00:00:00Z") }),
ws({ workspaceKey: "srv:new", projectViewKey: "b", createdAt: d("2026-03-01T00:00:00Z") }),
ws({ workspaceKey: "srv:mid", projectViewKey: "a", createdAt: d("2026-02-01T00:00:00Z") }),
];
expect(keys(sortUngroupedWorkspaces(rows, "created", projectNames))).toEqual([
"srv:new",
"srv:mid",
"srv:old",
]);
});
it("orders by the last prompt, falling back to created time", () => {
const rows = [
ws({
workspaceKey: "srv:prompted-early",
createdAt: d("2026-03-01T00:00:00Z"),
lastUserMessageAt: d("2026-03-02T00:00:00Z"),
}),
ws({ workspaceKey: "srv:never-prompted", createdAt: d("2026-03-05T00:00:00Z") }),
ws({
workspaceKey: "srv:prompted-late",
createdAt: d("2026-01-01T00:00:00Z"),
lastUserMessageAt: d("2026-03-09T00:00:00Z"),
}),
];
expect(keys(sortUngroupedWorkspaces(rows, "lastPrompt", projectNames))).toEqual([
"srv:prompted-late",
"srv:never-prompted",
"srv:prompted-early",
]);
});
it("orders by the time the status last changed, whatever the status is", () => {
const rows = [
ws({
workspaceKey: "srv:done-recently",
statusBucket: "done",
statusEnteredAt: d("2026-03-03T00:00:00Z"),
}),
ws({
workspaceKey: "srv:needs-input-long-ago",
statusBucket: "needs_input",
statusEnteredAt: d("2026-03-01T00:00:00Z"),
}),
ws({
workspaceKey: "srv:running-now",
statusBucket: "running",
statusEnteredAt: d("2026-03-04T00:00:00Z"),
}),
ws({ workspaceKey: "srv:no-status-time", statusBucket: "done" }),
];
expect(keys(sortUngroupedWorkspaces(rows, "statusChange", projectNames))).toEqual([
"srv:running-now",
"srv:done-recently",
"srv:needs-input-long-ago",
"srv:no-status-time",
]);
});
it("sorts a waiting workspace by its status time like any other status", () => {
const rows = [
ws({
workspaceKey: "srv:running",
statusBucket: "running",
statusEnteredAt: d("2026-03-01T00:00:00Z"),
}),
ws({
workspaceKey: "srv:waiting",
statusBucket: "waiting",
statusEnteredAt: d("2026-03-02T00:00:00Z"),
}),
];
expect(keys(sortUngroupedWorkspaces(rows, "statusChange", projectNames))).toEqual([
"srv:waiting",
"srv:running",
]);
});
it("moves a workspace to the top when its status changes, and leaves it when only other fields change", () => {
const before = [
ws({
workspaceKey: "srv:a",
statusBucket: "done",
statusEnteredAt: d("2026-03-02T00:00:00Z"),
}),
ws({
workspaceKey: "srv:b",
statusBucket: "done",
statusEnteredAt: d("2026-03-01T00:00:00Z"),
}),
];
expect(keys(sortUngroupedWorkspaces(before, "statusChange", projectNames))).toEqual([
"srv:a",
"srv:b",
]);
const changedFields = [before[0]!, ws({ ...before[1]!, title: "renamed", name: "renamed" })];
expect(keys(sortUngroupedWorkspaces(changedFields, "statusChange", projectNames))).toEqual([
"srv:a",
"srv:b",
]);
const statusChanged = [
before[0]!,
ws({ ...before[1]!, statusBucket: "running", statusEnteredAt: d("2026-03-03T00:00:00Z") }),
];
expect(keys(sortUngroupedWorkspaces(statusChanged, "statusChange", projectNames))).toEqual([
"srv:b",
"srv:a",
]);
});
it("breaks ties by workspace key so the order is stable", () => {
const same = d("2026-03-01T00:00:00Z");
const rows = [
ws({ workspaceKey: "srv:b", createdAt: same }),
ws({ workspaceKey: "srv:a", createdAt: same }),
];
expect(keys(sortUngroupedWorkspaces(rows, "created", projectNames))).toEqual([
"srv:a",
"srv:b",
]);
});
it("orders by name when the hosts cannot supply the sort times", () => {
const rows = [
ws({ workspaceKey: "srv:2", name: "Zulu", createdAt: d("2026-03-01T00:00:00Z") }),
ws({ workspaceKey: "srv:1", name: "Alpha", createdAt: d("2026-01-01T00:00:00Z") }),
];
expect(keys(sortUngroupedWorkspaces(rows, undefined, projectNames))).toEqual([
"srv:1",
"srv:2",
]);
});
it("does not reorder the input", () => {
const rows = [
ws({ workspaceKey: "srv:old", createdAt: d("2026-01-01T00:00:00Z") }),
ws({ workspaceKey: "srv:new", createdAt: d("2026-02-01T00:00:00Z") }),
];
sortUngroupedWorkspaces(rows, "created", projectNames);
expect(keys(rows)).toEqual(["srv:old", "srv:new"]);
});
});
@@ -1,33 +0,0 @@
import type { UngroupedSort } from "@/components/sidebar/sidebar-sort";
import { compareNames, compareText } from "@/utils/collation";
import { workspaceSortTime } from "@/projects/workspace-structure";
import { compareStatusRows } from "./sidebar-status-view-model";
import type { SidebarWorkspaceEntry } from "./sidebar-workspaces-view-model";
/**
* Orders every unpinned workspace as one list, newest first by the chosen time.
*
* Created and Last prompt use the same times, with the same fallback, as the per-project sort in
* `buildWorkspaceStructureProjects`. With no sort, rows go by name. Status change uses the time status grouping orders rows by
* inside a group, so the row's right-hand time and the order never disagree.
*/
export function sortUngroupedWorkspaces(
workspaces: readonly SidebarWorkspaceEntry[],
sort: UngroupedSort | undefined,
projectNamesByViewKey: Map<string, string>,
): SidebarWorkspaceEntry[] {
const rows = [...workspaces];
if (sort === undefined) {
return rows.sort(
(a, b) => compareNames(a.name, b.name) || compareText(a.workspaceKey, b.workspaceKey),
);
}
if (sort === "statusChange") {
return rows.sort((a, b) => compareStatusRows(a, b, projectNamesByViewKey));
}
return rows.sort(
(a, b) =>
workspaceSortTime(b, sort) - workspaceSortTime(a, sort) ||
a.workspaceKey.localeCompare(b.workspaceKey),
);
}
@@ -39,9 +39,6 @@ export interface SidebarStatusWorkspacePlacement extends SidebarWorkspacePlaceme
}
export interface SidebarWorkspaceEntry extends SidebarStatusWorkspacePlacement {
// The times the Created and Last prompt sorts order by. Null from a host that predates them.
createdAt: Date | null;
lastUserMessageAt: Date | null;
workspaceDirectory: string;
workspaceDirectoryLabel: string;
// Raw user-set title (null when the name is derived from branch/directory).
@@ -173,8 +170,6 @@ export function createSidebarWorkspaceEntry(input: {
currentBranch: normalizeCurrentBranch(input.workspace.gitRuntime?.currentBranch),
statusBucket: effectiveStatus.status,
statusEnteredAt: effectiveStatus.enteredAt,
createdAt: input.workspace.createdAt,
lastUserMessageAt: input.workspace.lastUserMessageAt,
archivingAt: input.workspace.archivingAt,
diffStat: input.workspace.diffStat,
prHint: selectPrHintFromStatus(
@@ -29,8 +29,6 @@ function workspace(projectKey: string, workspaceId: string): SidebarWorkspaceEnt
currentBranch: null,
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -7,7 +7,6 @@ import { useWorkspaceDirectoryServerIds } from "@/stores/session-store-hooks";
import { workspaceEqualityFns } from "@/stores/session-store-hooks/selectors";
import { useWorkspaceStructure } from "@/stores/session-store-hooks";
import { getHostRuntimeStore, useHostRegistryLoaded, useHosts } from "@/runtime/host-runtime";
import { resolveProjectSort } from "@/components/sidebar/sidebar-sort";
import { useSidebarOrderStore } from "@/stores/sidebar-order-store";
import { useSidebarViewStore } from "@/stores/sidebar-view-store";
import {
@@ -146,10 +145,9 @@ export function useSidebarWorkspacesList(options?: {
const sortSupport = useHostFeatureAvailabilityMap(directoryServerIds, "workspaceSortTimes");
// Cached workspaces are visible before their host sends server info.
const workspaceSortSupported = ![...sortSupport.values()].includes(false);
const projectSort = resolveProjectSort(workspaceSort);
const sort =
groupMode === "project" && (projectSort === "manual" || workspaceSortSupported)
? projectSort
groupMode === "project" && (workspaceSort === "manual" || workspaceSortSupported)
? workspaceSort
: undefined;
const { projects: hostProjects } = useWorkspaceStructure(directoryServerIds, sort);
-4
View File
@@ -1334,7 +1334,6 @@ export const ar: TranslationResources = {
failed: "فشل",
readyToReview: "جاهزة للمراجعة",
working: "قيد العمل",
waiting: "في الانتظار",
done: "تم",
},
display: {
@@ -1346,14 +1345,12 @@ export const ar: TranslationResources = {
created: "تاريخ الإنشاء",
manual: "يدوي",
lastPrompt: "آخر طلب",
statusChange: "تغيّر الحالة",
updateHost: "حدّث المضيفين لترتيب مساحات العمل",
},
grouping: {
label: "التجميع",
project: "المشروع",
status: "الحالة",
none: "بلا",
labels: "التسميات",
},
titleSource: {
@@ -2430,7 +2427,6 @@ export const ar: TranslationResources = {
pillLabelOne: "وكيل فرعي واحد",
pillLabelMany: "{{count}} وكلاء فرعيين",
pillLabelWorking: "{{count}} قيد التشغيل",
pillLabelWaiting: "{{count}} في الانتظار",
pillLabelFailed: "{{count}} فشلت",
pillLabelNeedsInputOne: "واحد يحتاج إدخالاً",
pillLabelNeedsInputMany: "{{count}} تحتاج إدخالاً",
-4
View File
@@ -1345,7 +1345,6 @@ export const en = {
failed: "Failed",
readyToReview: "Ready to review",
working: "Working",
waiting: "Waiting",
done: "Done",
},
display: {
@@ -1357,14 +1356,12 @@ export const en = {
created: "Created",
manual: "Manual",
lastPrompt: "Last prompt",
statusChange: "Status change",
updateHost: "Update hosts to sort workspaces",
},
grouping: {
label: "Grouping",
project: "Project",
status: "Status",
none: "None",
labels: "Labels",
},
titleSource: {
@@ -2462,7 +2459,6 @@ export const en = {
pillLabelOne: "1 subagent",
pillLabelMany: "{{count}} subagents",
pillLabelWorking: "{{count}} working",
pillLabelWaiting: "{{count}} waiting",
pillLabelFailed: "{{count}} failed",
pillLabelNeedsInputOne: "1 needs input",
pillLabelNeedsInputMany: "{{count}} need input",
-4
View File
@@ -1371,7 +1371,6 @@ export const es: TranslationResources = {
failed: "Con error",
readyToReview: "Para revisar",
working: "En ejecución",
waiting: "En espera",
done: "Terminado",
},
display: {
@@ -1383,14 +1382,12 @@ export const es: TranslationResources = {
created: "Creación",
manual: "Manual",
lastPrompt: "Último prompt",
statusChange: "Cambio de estado",
updateHost: "Actualiza los hosts para ordenar los espacios de trabajo",
},
grouping: {
label: "Agrupación",
project: "Proyecto",
status: "Estado",
none: "Ninguno",
labels: "Etiquetas",
},
titleSource: {
@@ -2490,7 +2487,6 @@ export const es: TranslationResources = {
pillLabelOne: "1 subagente",
pillLabelMany: "{{count}} subagentes",
pillLabelWorking: "{{count}} en ejecución",
pillLabelWaiting: "{{count}} en espera",
pillLabelFailed: "{{count}} con error",
pillLabelNeedsInputOne: "1 necesita datos",
pillLabelNeedsInputMany: "{{count}} necesitan datos",
-4
View File
@@ -1363,7 +1363,6 @@ export const fr: TranslationResources = {
failed: "Échec",
readyToReview: "À relire",
working: "En cours",
waiting: "En attente",
done: "Terminé",
},
display: {
@@ -1375,14 +1374,12 @@ export const fr: TranslationResources = {
created: "Création",
manual: "Manuel",
lastPrompt: "Dernier prompt",
statusChange: "Changement de statut",
updateHost: "Mettez les hôtes à jour pour trier les espaces de travail",
},
grouping: {
label: "Regroupement",
project: "Projet",
status: "Statut",
none: "Aucun",
labels: "Libellés",
},
titleSource: {
@@ -2486,7 +2483,6 @@ export const fr: TranslationResources = {
pillLabelOne: "1 sous-agent",
pillLabelMany: "{{count}} sous-agents",
pillLabelWorking: "{{count}} en cours",
pillLabelWaiting: "{{count}} en attente",
pillLabelFailed: "{{count}} en échec",
pillLabelNeedsInputOne: "1 attend une réponse",
pillLabelNeedsInputMany: "{{count}} attendent une réponse",
-4
View File
@@ -1348,7 +1348,6 @@ export const ja: TranslationResources = {
failed: "失敗",
readyToReview: "レビュー待ち",
working: "実行中",
waiting: "待機中",
done: "完了",
},
display: {
@@ -1360,14 +1359,12 @@ export const ja: TranslationResources = {
created: "作成日時",
manual: "手動",
lastPrompt: "最後のプロンプト",
statusChange: "ステータス変更",
updateHost: "ワークスペースを並べ替えるにはホストを更新してください",
},
grouping: {
label: "グループ化",
project: "プロジェクト",
status: "ステータス",
none: "なし",
labels: "ラベル",
},
titleSource: {
@@ -2456,7 +2453,6 @@ export const ja: TranslationResources = {
pillLabelOne: "サブエージェント 1 件",
pillLabelMany: "サブエージェント {{count}} 件",
pillLabelWorking: "{{count}} 件実行中",
pillLabelWaiting: "{{count}} 件待機中",
pillLabelFailed: "{{count}} 件失敗",
pillLabelNeedsInputOne: "1 件が入力待ち",
pillLabelNeedsInputMany: "{{count}} 件が入力待ち",
-4
View File
@@ -1341,7 +1341,6 @@ export const ko: TranslationResources = {
failed: "실패",
readyToReview: "검토 대기",
working: "실행 중",
waiting: "대기 중",
done: "완료",
},
display: {
@@ -1353,14 +1352,12 @@ export const ko: TranslationResources = {
created: "생성일",
manual: "수동",
lastPrompt: "마지막 프롬프트",
statusChange: "상태 변경",
updateHost: "작업 공간을 정렬하려면 호스트를 업데이트하세요",
},
grouping: {
label: "그룹화",
project: "프로젝트",
status: "상태",
none: "없음",
labels: "레이블",
},
titleSource: {
@@ -2447,7 +2444,6 @@ export const ko: TranslationResources = {
pillLabelOne: "하위 에이전트 1개",
pillLabelMany: "하위 에이전트 {{count}}개",
pillLabelWorking: "{{count}}개 실행 중",
pillLabelWaiting: "{{count}}개 대기 중",
pillLabelFailed: "{{count}}개 실패",
pillLabelNeedsInputOne: "1개 입력 필요",
pillLabelNeedsInputMany: "{{count}}개 입력 필요",
-4
View File
@@ -1361,7 +1361,6 @@ export const ptBR: TranslationResources = {
failed: "Com falha",
readyToReview: "Para revisar",
working: "Em execução",
waiting: "Aguardando",
done: "Concluído",
},
display: {
@@ -1373,14 +1372,12 @@ export const ptBR: TranslationResources = {
created: "Criação",
manual: "Manual",
lastPrompt: "Último prompt",
statusChange: "Mudança de status",
updateHost: "Atualize os hosts para ordenar os espaços de trabalho",
},
grouping: {
label: "Agrupamento",
project: "Projeto",
status: "Status",
none: "Nenhum",
labels: "Etiquetas",
},
titleSource: {
@@ -2472,7 +2469,6 @@ export const ptBR: TranslationResources = {
pillLabelOne: "1 subagente",
pillLabelMany: "{{count}} subagentes",
pillLabelWorking: "{{count}} em execução",
pillLabelWaiting: "{{count}} aguardando",
pillLabelFailed: "{{count}} com falha",
pillLabelNeedsInputOne: "1 precisa de resposta",
pillLabelNeedsInputMany: "{{count}} precisam de resposta",
-4
View File
@@ -1353,7 +1353,6 @@ export const ru: TranslationResources = {
failed: "Ошибка",
readyToReview: "На проверку",
working: "В работе",
waiting: "Ожидание",
done: "Готово",
},
display: {
@@ -1365,14 +1364,12 @@ export const ru: TranslationResources = {
created: "Дата создания",
manual: "Вручную",
lastPrompt: "Последний запрос",
statusChange: "Смена статуса",
updateHost: "Обновите хосты для сортировки рабочих пространств",
},
grouping: {
label: "Группировка",
project: "Проект",
status: "Статус",
none: "Без группировки",
labels: "Метки",
},
titleSource: {
@@ -2472,7 +2469,6 @@ export const ru: TranslationResources = {
pillLabelOne: "1 субагент",
pillLabelMany: "Субагентов: {{count}}",
pillLabelWorking: "{{count}} в работе",
pillLabelWaiting: "{{count}} в ожидании",
pillLabelFailed: "{{count}} с ошибкой",
pillLabelNeedsInputOne: "1 ожидает ввода",
pillLabelNeedsInputMany: "{{count}} ожидают ввода",
-4
View File
@@ -1326,7 +1326,6 @@ export const zhCN: TranslationResources = {
failed: "失败",
readyToReview: "待查看",
working: "运行中",
waiting: "等待中",
done: "已完成",
},
display: {
@@ -1338,14 +1337,12 @@ export const zhCN: TranslationResources = {
created: "创建时间",
manual: "手动",
lastPrompt: "最近提示词",
statusChange: "状态变更",
updateHost: "请更新主机以排序工作区",
},
grouping: {
label: "分组",
project: "项目",
status: "状态",
none: "不分组",
labels: "标签",
},
titleSource: {
@@ -2403,7 +2400,6 @@ export const zhCN: TranslationResources = {
pillLabelOne: "1 个 subagent",
pillLabelMany: "{{count}} 个 subagent",
pillLabelWorking: "{{count}} 个运行中",
pillLabelWaiting: "{{count}} 个等待中",
pillLabelFailed: "{{count}} 个失败",
pillLabelNeedsInputOne: "1 个需要输入",
pillLabelNeedsInputMany: "{{count}} 个需要输入",
@@ -105,9 +105,9 @@ describe("shared agent descriptor", () => {
expect(describeAgent({ isTurnActive: true }).statusBucket).toBe("running");
});
it("shows background work as waiting without making the turn active", () => {
it("shows background work as running without making the turn active", () => {
expect(describeAgent({ backgroundWork: { count: 1 } })).toMatchObject({
statusBucket: "waiting",
statusBucket: "running",
subtitle: "Background work running",
});
expect(
@@ -118,9 +118,6 @@ describe("shared agent descriptor", () => {
}).statusBucket,
).toBe("failed");
expect(describeAgent({ backgroundWork: { count: 1 }, status: "error" }).statusBucket).toBe(
"waiting",
);
expect(describeAgent({ backgroundWork: { count: 1 }, isTurnActive: true }).statusBucket).toBe(
"running",
);
});
+2 -16
View File
@@ -1,5 +1,4 @@
import type { AgentAddress } from "@getpaseo/protocol/addresses";
import { isAgentBusy, isAgentTurnRunning } from "@getpaseo/protocol/agent-state-bucket";
import { memo, useCallback, useMemo, useRef, type ReactElement } from "react";
import type { View } from "react-native";
import { BackgroundWorkTrack, createHostBackgroundWorkModel } from "@/background-work";
@@ -10,7 +9,7 @@ import { useIsCompactFormFactor } from "@/constants/layout";
import { usePaneContext } from "@/panels/pane-context";
import { useSettings } from "@/hooks/use-settings";
import { PluginComposerPillItems, PluginComposerPills } from "@/plugins";
import { selectAgentTurnPresentation, useSessionStore } from "@/stores/session-store";
import { useSessionStore } from "@/stores/session-store";
import {
useArchiveFinishedSubagents,
useArchiveSubagent,
@@ -59,15 +58,6 @@ export const AgentTracks = memo(function AgentTracks({
const agent = session?.agents.get(agentId) ?? session?.agentDetails.get(agentId);
return agent?.backgroundWork?.count ?? 0;
});
// The same turn state the tab reads, so a follow-up being sent turns both marks to running.
const backgroundWorkBucket = useSessionStore((state) => {
const session = state.sessions[serverId];
const agent = session?.agents.get(agentId) ?? session?.agentDetails.get(agentId);
const turnRunning =
selectAgentTurnPresentation(session, agentId).isActive ||
isAgentTurnRunning({ status: agent?.status });
return !turnRunning && agent && isAgentBusy(agent) ? "waiting" : "running";
});
const backgroundModel = useMemo(
() => createHostBackgroundWorkModel(serverId, agentId),
[serverId, agentId],
@@ -133,11 +123,7 @@ export const AgentTracks = memo(function AgentTracks({
return (
<ComposerTrackBar trackViewportRef={trackViewportRef}>
<BackgroundWorkTrack
model={backgroundModel}
count={backgroundWorkCount}
bucket={backgroundWorkBucket}
/>
<BackgroundWorkTrack model={backgroundModel} count={backgroundWorkCount} />
{parentAgentId ? <ParentAgentPill serverId={serverId} parentAgentId={parentAgentId} /> : null}
<AgentTaskList tasks={tasks} />
<SubagentsTrack
@@ -177,12 +177,6 @@ describe("sidebar entity snapshots", () => {
expect(Object.isFrozen(snapshot.metadata.issues)).toBe(true);
});
it("reports a waiting workspace to plugins as waiting, labelled Working", () => {
const snapshot = createPluginWorkspaceSnapshot({ ...workspace, status: "waiting" }, "host-1");
expect(snapshot.indicator).toBe("waiting");
expect(snapshot.indicatorLabel).toBe("Working");
});
it("reads projects without requiring a workspace", () => {
const project = {
projectId: "empty",
@@ -116,7 +116,6 @@ const indicatorLabelKeys = {
needs_input: "sidebar.statusBucket.needsInput",
failed: "sidebar.statusBucket.failed",
running: "sidebar.statusBucket.working",
waiting: "sidebar.statusBucket.working",
attention: "sidebar.statusBucket.readyToReview",
done: "sidebar.statusBucket.done",
} as const;
@@ -211,8 +211,8 @@ function compareWorkspaceStructureItems(left: WorkspaceSortItem, right: Workspac
);
}
export function workspaceSortTime(
workspace: Pick<WorkspaceDescriptor, "createdAt" | "lastUserMessageAt">,
function workspaceSortTime(
workspace: WorkspaceDescriptor,
sort: WorkspaceSort | undefined,
): number {
if (!sort) return 0;
@@ -398,20 +398,6 @@ describe("ReplicaCache", () => {
expect(restored.workspaces.get(workspace.id)?.forgeWeb).toEqual(forgeWeb);
});
it("preserves a waiting workspace status across cache reopen", async () => {
const storage = new MemoryStorage();
const writer = createCache(storage);
const baseline = directory();
const workspace = normalizeWorkspaceDescriptor({ ...workspacePayload(), status: "waiting" });
baseline.workspaces.set(workspace.id, workspace);
commitDirectory(writer, SERVER_ID, baseline);
await writer.flush();
const reader = createCache(storage);
expect((await reader.readDirectory(SERVER_ID)).workspaces.get(workspace.id)?.status).toBe(
"waiting",
);
});
it("preserves workspace sorting timestamps across cache reopen", async () => {
const storage = new MemoryStorage();
const writer = createCache(storage);
@@ -364,7 +364,7 @@ const StoredWorkspaceSchema = z.strictObject({
labels: z.array(z.string()).optional(),
// Require metadata so older rows written before metadata was cached invalidate the workspace cursor.
metadata: z.record(z.string(), z.unknown() as z.ZodType<JsonValue>),
status: z.enum(["needs_input", "failed", "running", "waiting", "attention", "done"]),
status: z.enum(["needs_input", "failed", "running", "attention", "done"]),
statusEnteredAt: IsoDateSchema.nullable(),
activityAt: z.null(),
archivingAt: z.string().nullable(),
+3 -4
View File
@@ -59,7 +59,7 @@ import {
resolveActiveHostServerId,
type HostProfile,
} from "@/types/host-connection";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { WindowChromeRegion, WindowChromeSafeArea } from "@/utils/desktop-window";
import { confirmDialog } from "@/utils/confirm-dialog";
import { BackHeader } from "@/components/headers/back-header";
@@ -1223,8 +1223,7 @@ function SettingsSidebar({
>
{isDesktop ? (
<View style={innerContainerStyle}>
<View style={sidebarStyles.sidebarDragArea}>
<TitlebarDragRegion />
<TitlebarDragSurface style={sidebarStyles.sidebarDragArea}>
<WindowChromeSafeArea placement="below" />
<SidebarHeaderRow
icon={ArrowLeft}
@@ -1232,7 +1231,7 @@ function SettingsSidebar({
onPress={onBackToWorkspace}
testID="settings-back-to-workspace"
/>
</View>
</TitlebarDragSurface>
<ScrollView
style={sidebarStyles.scrollBody}
showsVerticalScrollIndicator={false}
@@ -21,7 +21,7 @@ import { StyleSheet, useUnistyles } from "react-native-unistyles";
import { PaseoLogo } from "@/components/icons/paseo-logo";
import { Button } from "@/components/ui/button";
import { getDesktopDaemonLogs, type DesktopDaemonLogs } from "@/desktop/daemon/desktop-daemon";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { isNative, isWeb } from "@/constants/platform";
import { useNativeSplashHold } from "@/native-splash";
import { CODE_SURFACE_DATASET } from "@/styles/code-surface";
@@ -394,18 +394,16 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
if (!isError) {
return (
<View testID="startup-splash" style={styles.container}>
<TitlebarDragRegion />
<TitlebarDragSurface testID="startup-splash" style={styles.container}>
<View style={styles.logo}>
<LogoShimmer />
</View>
</View>
</TitlebarDragSurface>
);
}
return (
<View style={styles.errorScreen}>
<TitlebarDragRegion />
<TitlebarDragSurface style={styles.errorScreen}>
<ScrollView
style={styles.errorScrollView}
contentContainerStyle={styles.errorScrollContent}
@@ -453,6 +451,6 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
</View>
</View>
</ScrollView>
</View>
</TitlebarDragSurface>
);
}
@@ -3,7 +3,7 @@ import { View } from "react-native";
import { useWorkspaceTabDrag } from "@/components/workspace-tab-drag-context";
import { StyleSheet } from "react-native-unistyles";
import { RetainedPanel } from "@/components/retained-panel";
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
import { WorkspacePanelHost } from "@/screens/workspace/workspace-panel-host";
import { deriveWorkspacePaneState } from "@/screens/workspace/workspace-pane-state";
import {
@@ -121,43 +121,44 @@ export function ExplorerSidebarDock({
<RetainedPanel active>
<WindowChromeRegion corners="top-right">
<View style={styles.dock} testID="workspace-explorer-sidebar">
<WindowChromeSafeArea placement="inline" style={styles.tabRail}>
<TitlebarDragRegion />
<View style={styles.tabRow}>
<WorkspaceDesktopTabsRow
host="explorer"
launchPurpose="supporting"
isFocused={isWorkspaceFocused}
ownsKeyboardShortcuts={false}
setHoveredCloseTabKey={setHoveredCloseTabKey}
onCopyResumeCommand={onCopyResumeCommand}
onCopyAgentId={onCopyAgentId}
onCopyTerminalId={onCopyTerminalId}
onReloadAgent={onReloadAgent}
onRenameTab={onRenameTab}
onCloseTabsToLeft={handleCloseTabsToLeft}
onCloseTabsToRight={handleCloseTabsToRight}
onCloseOtherTabs={handleCloseOtherTabs}
focusModeEnabled={false}
onExitFocusMode={onExitFocusMode}
externalDndContext={externalDndContext}
paneId={pane.id}
tabs={tabItems}
normalizedServerId={normalizedServerId}
normalizedWorkspaceId={normalizedWorkspaceId}
activeDragTabId={activeDragTabId}
tabDropPreviewIndex={
tabDropPreview?.paneId === pane.id ? tabDropPreview.indicatorIndex : null
}
onNavigateTab={handleSelectTab}
onCloseTab={onCloseTab}
onCreateNewTab={onCreateNewTab}
onReorderTabs={handleReorderTabs}
/>
</View>
{headerAction ? <View style={styles.headerAction}>{headerAction}</View> : null}
<View pointerEvents="none" style={styles.tabRailDivider} />
</WindowChromeSafeArea>
<TitlebarDragSurface style={styles.tabRailDragSurface}>
<WindowChromeSafeArea placement="inline" style={styles.tabRail}>
<View style={styles.tabRow}>
<WorkspaceDesktopTabsRow
host="explorer"
launchPurpose="supporting"
isFocused={isWorkspaceFocused}
ownsKeyboardShortcuts={false}
setHoveredCloseTabKey={setHoveredCloseTabKey}
onCopyResumeCommand={onCopyResumeCommand}
onCopyAgentId={onCopyAgentId}
onCopyTerminalId={onCopyTerminalId}
onReloadAgent={onReloadAgent}
onRenameTab={onRenameTab}
onCloseTabsToLeft={handleCloseTabsToLeft}
onCloseTabsToRight={handleCloseTabsToRight}
onCloseOtherTabs={handleCloseOtherTabs}
focusModeEnabled={false}
onExitFocusMode={onExitFocusMode}
externalDndContext={externalDndContext}
paneId={pane.id}
tabs={tabItems}
normalizedServerId={normalizedServerId}
normalizedWorkspaceId={normalizedWorkspaceId}
activeDragTabId={activeDragTabId}
tabDropPreviewIndex={
tabDropPreview?.paneId === pane.id ? tabDropPreview.indicatorIndex : null
}
onNavigateTab={handleSelectTab}
onCloseTab={onCloseTab}
onCreateNewTab={onCreateNewTab}
onReorderTabs={handleReorderTabs}
/>
</View>
{headerAction ? <View style={styles.headerAction}>{headerAction}</View> : null}
<View pointerEvents="none" style={styles.tabRailDivider} />
</WindowChromeSafeArea>
</TitlebarDragSurface>
<View style={styles.content}>
<WorkspacePanelHost
paneId={pane.id}
@@ -183,6 +184,10 @@ const styles = StyleSheet.create((theme) => ({
minHeight: 0,
backgroundColor: theme.colors.surfaceSidebar,
},
tabRailDragSurface: {
position: "relative",
flexShrink: 0,
},
tabRail: {
position: "relative",
flexDirection: "row",
@@ -1666,9 +1666,12 @@ const styles = StyleSheet.create((theme) => ({
minWidth: 0,
flex: 1,
alignSelf: "stretch",
flexDirection: "row",
alignItems: "stretch",
},
tabsScrollFitContent: {
flex: 1,
flexGrow: 0,
flexShrink: 1,
},
tabsScrollOverflow: {
flex: 1,
@@ -25,8 +25,6 @@ function makeEntry(
currentBranch: overrides.workspaceId,
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -50,8 +50,6 @@ function makeEntry(id: string): SidebarWorkspaceEntry {
currentBranch: id,
statusBucket: "done",
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
archivingAt: null,
diffStat: null,
prHint: null,
@@ -250,25 +250,6 @@ describe("sidebar view store", () => {
});
});
it("carries the ungrouped arrangement and its sort through the version migration", () => {
expect(
migrateSidebarViewState({ groupMode: "none", workspaceSort: "statusChange" }),
).toMatchObject({ groupMode: "none", workspaceSort: "statusChange" });
});
it("keeps the stored sort when the grouping changes", () => {
const store = useSidebarViewStore.getState();
store.setWorkspaceSort("manual");
store.setGroupMode("none");
store.setGroupMode("project");
expect(useSidebarViewStore.getState()).toMatchObject({
groupMode: "project",
workspaceSort: "manual",
});
});
it("falls back to the legacy storage key when the new key is empty", async () => {
const storage = createMemoryStorage({
"sidebar-view": null,
+8 -14
View File
@@ -1,4 +1,4 @@
import type { SidebarSort } from "@/components/sidebar/sidebar-sort";
import type { WorkspaceSort } from "@/projects/workspace-structure";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { create } from "zustand";
import { persist, type StateStorage } from "zustand/middleware";
@@ -6,8 +6,7 @@ import { z } from "zod";
import { workspaceLabelKey } from "@getpaseo/protocol/workspace-labels";
import { createValidatedPersistStorage } from "@/storage/validated-persist-storage";
/** "none" is one flat list with no group headers. */
export type SidebarGroupMode = "project" | "status" | "none";
export type SidebarGroupMode = "project" | "status";
const SIDEBAR_VIEW_STORAGE_KEY = "sidebar-view";
const LEGACY_SIDEBAR_GROUP_MODE_STORAGE_KEY = "sidebar-group-mode";
@@ -49,7 +48,7 @@ function toggleFilterEntry(list: readonly string[], key: string): string[] {
interface SidebarViewStoreState {
groupMode: SidebarGroupMode;
workspaceSort: SidebarSort;
workspaceSort: WorkspaceSort;
showBackground: boolean;
// Empty means "all hosts". A non-empty list pins the sidebar to those hosts.
hostFilters: string[];
@@ -67,7 +66,7 @@ interface SidebarViewStoreState {
labelFilter: SidebarLabelFilter;
toggleBackground: () => void;
setGroupMode: (mode: SidebarGroupMode) => void;
setWorkspaceSort: (sort: SidebarSort) => void;
setWorkspaceSort: (sort: WorkspaceSort) => void;
toggleHostFilter: (serverId: string) => void;
clearHostFilters: () => void;
focusHost: (serverId: string) => void;
@@ -81,19 +80,19 @@ interface SidebarViewStoreState {
interface SidebarViewPersistedState {
groupMode: SidebarGroupMode;
workspaceSort: SidebarSort;
workspaceSort: WorkspaceSort;
showBackground: boolean;
hostFilters: string[];
projectFilters: string[];
labelFilter: SidebarLabelFilter;
}
const PersistedSidebarGroupModeSchema = z.enum(["project", "status", "none", "label"]);
const PersistedSidebarGroupModeSchema = z.enum(["project", "status", "label"]);
const SidebarLabelFilterSchema = z.object({
labels: z.array(z.string()),
});
const SidebarViewPersistedStateSchema = z.strictObject({
workspaceSort: z.enum(["manual", "created", "lastPrompt", "statusChange"]).optional(),
workspaceSort: z.enum(["manual", "created", "lastPrompt"]).optional(),
showBackground: z.boolean().optional(),
groupMode: PersistedSidebarGroupModeSchema.optional(),
hostFilters: z.array(z.string()).optional(),
@@ -116,11 +115,6 @@ function readLegacyGroupMode(persistedState: SidebarViewStorageState): SidebarGr
return modes.includes("status") ? "status" : "project";
}
// A persisted legacy `"label"` value folds to project.
function readGroupMode(groupMode: SidebarViewStorageState["groupMode"]): SidebarGroupMode {
return groupMode === "status" || groupMode === "none" ? groupMode : "project";
}
// Reads the host filter from any persisted shape: the current `hostFilters` array, or the
// pre-v2 single `hostFilter` string (null/absent meant "all hosts").
function readHostFilters(persistedState: SidebarViewStorageState): string[] {
@@ -162,7 +156,7 @@ export function migrateSidebarViewState(persistedState: unknown): SidebarViewPer
return {
showBackground: state.showBackground ?? false,
groupMode: readGroupMode(state.groupMode),
groupMode: state.groupMode === "status" ? "status" : "project",
workspaceSort: state.workspaceSort ?? "created",
hostFilters: readHostFilters(state),
projectFilters: state.projectFilters ?? [],
@@ -1,4 +1,4 @@
import { isAgentBusy } from "@getpaseo/protocol/agent-state-bucket";
import { isAgentRunning } from "@getpaseo/protocol/agent-state-bucket";
import type { Agent } from "@/stores/session-store";
import type { ConfirmDialogInput } from "@/utils/confirm-dialog";
@@ -26,7 +26,7 @@ export function resolveArchiveSubagentDialog(
input: ResolveArchiveSubagentDialogInput,
): ConfirmDialogInput {
const subagentLabel = resolveSubagentLabel(input.title) ?? "this subagent";
const isRunning = isAgentBusy(input);
const isRunning = isAgentRunning(input);
let message = `Remove ${subagentLabel} from the track. The subagent will be archived.`;
if (isRunning) {
@@ -49,22 +49,6 @@ describe("buildSubagentPillPresentation", () => {
});
});
it("counts a child that only waits on background work in its own segment after working", () => {
expect(
pill([
row({ id: "waits", status: "idle", backgroundWork: { count: 1 } }),
row({ id: "works", status: "running" }),
row({ id: "waits-too", status: "idle", backgroundWork: { count: 2 } }),
]),
).toEqual({
segments: [
{ bucket: "running", text: "1 working" },
{ bucket: "waiting", text: "2 waiting" },
],
accessibilityLabel: "1 working, 2 waiting",
});
});
it("counts every child in the state it reports", () => {
expect(
pill([
@@ -210,19 +194,11 @@ describe("buildSubagentRowPresentationData", () => {
);
});
it("shows a child with background work as waiting after its foreground turn ends", () => {
it("shows a child with background work as running after its foreground turn ends", () => {
expect(
buildSubagentRowPresentationData(
row({ id: "a", status: "idle", backgroundWork: { count: 1 } }),
).statusBucket,
).toBe("waiting");
});
it("keeps a child that is running a turn as running while it has background work", () => {
expect(
buildSubagentRowPresentationData(
row({ id: "a", status: "running", backgroundWork: { count: 1 } }),
).statusBucket,
).toBe("running");
});
@@ -1,7 +1,7 @@
import type { TFunction } from "i18next";
import type { ComposerTrackPillSegment } from "@/composer/tracks";
import type { SidebarStateBucket } from "@/utils/sidebar-agent-state";
import { deriveAgentStateBucket } from "@getpaseo/protocol/agent-state-bucket";
import { isAgentRunning } from "@getpaseo/protocol/agent-state-bucket";
import type { AgentBackgroundWorkSummary } from "@getpaseo/protocol/messages";
import type { AgentLifecycleStatus } from "@getpaseo/protocol/agent-lifecycle";
import { STATUS_BUCKET_ORDER } from "@/utils/sidebar-agent-state";
@@ -26,9 +26,8 @@ export function deriveSubagentStatusBucket(
backgroundWork?: AgentBackgroundWorkSummary | null,
): SidebarStateBucket {
if (status === "error") return "failed";
// Running, waiting and done come from the shared rule, so the track cannot disagree with the
// sidebar about a child that has ended its turn with background work still alive.
return deriveAgentStateBucket({ status, backgroundWork });
if (isAgentRunning({ status, backgroundWork })) return "running";
return "done";
}
export interface SubagentRowPresentationData {
@@ -89,8 +88,8 @@ export interface SubagentPillPresentation {
* "1 failed" over a child that is still working says the fan-out has stopped. Every state present
* gets its own mark and its own count, in the order the sidebar's status groups list them.
*
* It stays one line because subagent rows only ever reach four states — see
* `buildSubagentRowPresentationData`, which reports no attention of its own — so the pill is three
* It stays one line because subagent rows only ever reach three states — see
* `buildSubagentRowPresentationData`, which reports no attention of its own — so the pill is two
* segments at worst, and falls back to naming what it opens once nothing is happening.
*/
export function buildSubagentPillPresentation(
@@ -115,8 +114,6 @@ function statusLabel(t: TFunction, bucket: ActiveStatusBucket, count: number): s
switch (bucket) {
case "running":
return t("subagents.pillLabelWorking", { count });
case "waiting":
return t("subagents.pillLabelWaiting", { count });
case "failed":
return t("subagents.pillLabelFailed", { count });
case "needs_input":
+13 -96
View File
@@ -1,17 +1,12 @@
import { createContext, useContext, useEffect, useMemo, useState, type ReactNode } from "react";
import { createContext, useContext, useMemo, useSyncExternalStore, type ReactNode } from "react";
import { View, type ViewProps } from "react-native";
import {
DESKTOP_TRAFFIC_LIGHT_HEIGHT,
DESKTOP_TRAFFIC_LIGHT_WIDTH,
getIsElectronRuntime,
} from "@/constants/layout";
import { getDesktopWindow } from "@/desktop/electron/window";
import { getDesktopWindowChromeMode, type DesktopWindowChromeMode } from "@/desktop/host";
import { DESKTOP_TRAFFIC_LIGHT_HEIGHT, DESKTOP_TRAFFIC_LIGHT_WIDTH } from "@/constants/layout";
import type { DesktopWindowChromeMode } from "@/desktop/host";
import { desktopWindowChromeHost } from "@/desktop/window-chrome-host";
import {
getDesktopWindowControlsPresentation,
getDesktopWindowControlsWidth,
} from "@/desktop/window-chrome-presentation";
import { isNative } from "@/constants/platform";
import { useTopBand, type TopBand } from "@/window-layout";
export type WindowChromeCorners = "none" | "top-left" | "top-right" | "both";
@@ -148,101 +143,23 @@ export function resolveWindowChromeSafeArea(input: {
}
export function WindowChromeProvider({ children }: { children: ReactNode }) {
const [isElectronReady, setIsElectronReady] = useState(getIsElectronRuntime);
const [windowState, setWindowState] = useState({ isFullscreen: false, isMaximized: false });
useEffect(() => {
let active = true;
let dispose: (() => void) | undefined;
let connecting = false;
let retryCount = 0;
let retryTimer: ReturnType<typeof setTimeout> | undefined;
function scheduleRetry(warnOnExhaustion = false) {
if (!active || dispose || retryTimer) return;
if (retryCount >= 40) {
if (warnOnExhaustion) {
console.warn("[DesktopWindow] Chrome bridge unavailable; window controls may overlap UI");
}
return;
}
retryCount += 1;
retryTimer = setTimeout(() => {
retryTimer = undefined;
connect();
}, 250);
}
function connect() {
if (!active || dispose || connecting) return;
if (!getIsElectronRuntime()) return scheduleRetry();
const desktopWindow = getDesktopWindow();
if (
!desktopWindow ||
typeof desktopWindow.isFullscreen !== "function" ||
typeof desktopWindow.onResized !== "function"
)
return scheduleRetry(true);
const readFullscreen = desktopWindow.isFullscreen;
const readMaximized = desktopWindow.isMaximized;
const subscribeToResized = desktopWindow.onResized;
connecting = true;
void (async () => {
async function syncWindowState() {
try {
const [isFullscreen, isMaximized] = await Promise.all([
readFullscreen(),
readMaximized?.() ?? false,
]);
if (active) setWindowState({ isFullscreen, isMaximized });
} catch (error) {
if (active) console.warn("[DesktopWindow] Failed to read window state", error);
}
}
try {
const nextDispose = await subscribeToResized(syncWindowState);
if (!active) return nextDispose();
dispose = nextDispose;
setIsElectronReady(true);
await syncWindowState();
} catch (error) {
if (active) console.warn("[DesktopWindow] Failed to subscribe to resize", error);
} finally {
connecting = false;
if (!dispose) scheduleRetry();
}
})();
}
if (!isNative) connect();
return () => {
active = false;
if (retryTimer) clearTimeout(retryTimer);
dispose?.();
};
}, []);
const chrome = useSyncExternalStore(
desktopWindowChromeHost.subscribe,
desktopWindowChromeHost.getSnapshot,
desktopWindowChromeHost.getSnapshot,
);
const topBand = useTopBand();
const obstruction = useMemo(
() =>
resolveWindowChromeObstruction({
mode: isElectronReady ? getDesktopWindowChromeMode() : null,
isFullscreen: windowState.isFullscreen,
mode: chrome.mode,
isFullscreen: chrome.isFullscreen,
topBand,
}),
[isElectronReady, windowState.isFullscreen, topBand],
);
const desktopWindowChrome = useMemo(
() => ({
mode: isElectronReady ? getDesktopWindowChromeMode() : null,
isFullscreen: windowState.isFullscreen,
isMaximized: windowState.isMaximized,
}),
[isElectronReady, windowState],
[chrome.mode, chrome.isFullscreen, topBand],
);
return (
<DesktopWindowChromeContext.Provider value={desktopWindowChrome}>
<DesktopWindowChromeContext.Provider value={chrome}>
<WindowChromeContext.Provider value={obstruction}>
<WindowChromeCornersContext.Provider value="both">
{children}
@@ -43,20 +43,6 @@ describe("deriveFaviconStatus", () => {
).toBe("running");
});
it("stays quiet for an idle agent that only has background work", () => {
expect(
deriveFaviconStatus(
stateWith(
agent({
id: "a",
status: "idle",
backgroundWork: { count: 1, runningCount: 1 },
} as Partial<Agent> & { id: string }),
),
),
).toBe("none");
});
it("needs attention for attention or pending permissions", () => {
expect(deriveFaviconStatus(stateWith(agent({ id: "a", requiresAttention: true })))).toBe(
"attention",
@@ -6,10 +6,6 @@ describe("getProjectStatusBadgeContent", () => {
expect(getProjectStatusBadgeContent("running")).toEqual({ kind: "dot", bucket: "running" });
});
it("shows a waiting dot while only background work is alive", () => {
expect(getProjectStatusBadgeContent("waiting")).toEqual({ kind: "dot", bucket: "waiting" });
});
it("shows the alert when input is needed", () => {
expect(getProjectStatusBadgeContent("needs_input")).toEqual({ kind: "alert" });
});
@@ -1,6 +1,6 @@
import type { SidebarStateBucket } from "@/utils/sidebar-agent-state";
export type ProjectStatusBadgeDotBucket = "failed" | "attention" | "running" | "waiting";
export type ProjectStatusBadgeDotBucket = "failed" | "attention" | "running";
export type ProjectStatusBadgeContent =
| { kind: "alert" }
@@ -22,12 +22,7 @@ export function getProjectStatusBadgeContent(
if (statusBucket === "needs_input") {
return { kind: "alert" };
}
if (
statusBucket === "failed" ||
statusBucket === "attention" ||
statusBucket === "running" ||
statusBucket === "waiting"
) {
if (statusBucket === "failed" || statusBucket === "attention" || statusBucket === "running") {
return { kind: "dot", bucket: statusBucket };
}
return null;
@@ -78,12 +78,6 @@ describe("aggregateSidebarStateBuckets", () => {
expect(aggregateSidebarStateBuckets(["attention", "running"])).toBe("running");
});
it("ranks waiting below running and above ready-to-review", () => {
expect(aggregateSidebarStateBuckets(["waiting", "running"])).toBe("running");
expect(aggregateSidebarStateBuckets(["attention", "waiting"])).toBe("waiting");
expect(aggregateSidebarStateBuckets(["done", "waiting"])).toBe("waiting");
});
it("prefers ready-to-review over done", () => {
expect(aggregateSidebarStateBuckets(["done", "attention", "done"])).toBe("attention");
});
+4 -13
View File
@@ -4,13 +4,7 @@ import {
type AgentStateBucketInput,
} from "@getpaseo/protocol/agent-state-bucket";
export type SidebarStateBucket =
| "needs_input"
| "failed"
| "running"
| "waiting"
| "attention"
| "done";
export type SidebarStateBucket = "needs_input" | "failed" | "running" | "attention" | "done";
export type SidebarAttentionReason = AgentAttentionReason;
export function deriveSidebarStateBucket(input: AgentStateBucketInput): SidebarStateBucket {
@@ -24,13 +18,12 @@ export function isSidebarActiveAgent(input: AgentStateBucketInput): boolean {
// Most urgent first, for collapsing a project's workspaces into one badge. This is
// deliberately NOT STATUS_BUCKET_ORDER below, which ranks "attention" above "running": on a
// collapsed project row we want an actively-working project to keep showing the loader,
// so "running" and "waiting" outrank "attention" here. needs_input and failed still win over
// them; done stays last.
// so "running" outranks "attention" here. needs_input and failed still win over both;
// done stays last.
const STATUS_BUCKET_PRIORITY: readonly SidebarStateBucket[] = [
"needs_input",
"failed",
"running",
"waiting",
"attention",
"done",
];
@@ -38,15 +31,13 @@ const STATUS_BUCKET_PRIORITY: readonly SidebarStateBucket[] = [
/**
* The order states are listed in when all of them are shown side by side rather than collapsed
* into one — the sidebar's status groups, and the subagent pill's segments. Anything the user has
* to act on comes before anything that is still moving on its own, and a turn that is running
* comes before one that is only waiting on background work.
* to act on comes before anything that is still moving on its own.
*/
export const STATUS_BUCKET_ORDER: readonly SidebarStateBucket[] = [
"needs_input",
"failed",
"attention",
"running",
"waiting",
"done",
] as const;
@@ -32,8 +32,6 @@ function workspace(overrides: Partial<SidebarWorkspaceEntry> = {}): SidebarWorks
scripts: [],
hasRunningScripts: false,
statusEnteredAt: null,
createdAt: null,
lastUserMessageAt: null,
...overrides,
archivingAt: overrides.archivingAt ?? null,
};
@@ -37,8 +37,6 @@ function workspace(input: {
statusBucket: input.statusBucket ?? "done",
archivingAt: null,
statusEnteredAt: input.statusEnteredAt ?? null,
createdAt: null,
lastUserMessageAt: null,
diffStat: null,
prHint: null,
archiveHasUncommittedChanges: null,
+1 -1
View File
@@ -21,7 +21,7 @@ export function getStatusDotColor(input: {
if (bucket === "failed") {
return theme.colors.statusDotDanger;
}
if (bucket === "running" || bucket === "waiting") {
if (bucket === "running") {
return theme.colors.statusDotRunning;
}
if (bucket === "attention") {

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