mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-06 15:16:03 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5242c4dbcd | ||
|
|
6b96005868 | ||
|
|
d08bb64020 | ||
|
|
b3906a4cdf | ||
|
|
47f60678a5 | ||
|
|
8e379b17f8 | ||
|
|
4c4fd69c26 | ||
|
|
0cefa98a6a | ||
|
|
67472e3814 |
@@ -1,6 +1,8 @@
|
||||
name: GPUI Experimental
|
||||
name: GPUI Nightly
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 6 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
platform:
|
||||
@@ -13,7 +15,7 @@ on:
|
||||
- macos
|
||||
- linux
|
||||
publish:
|
||||
description: "Publish built artifacts as a timestamped gpui-experimental prerelease."
|
||||
description: "Publish built artifacts to the rolling gpui-nightly prerelease."
|
||||
required: false
|
||||
default: "true"
|
||||
type: choice
|
||||
@@ -22,7 +24,7 @@ on:
|
||||
- "false"
|
||||
|
||||
concurrency:
|
||||
group: gpui-experimental-${{ github.ref }}
|
||||
group: gpui-nightly-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
@@ -36,8 +38,8 @@ env:
|
||||
|
||||
jobs:
|
||||
build-macos:
|
||||
name: gpui-experimental (macos-latest, arm64)
|
||||
if: ${{ inputs.platform == 'all' || inputs.platform == 'macos' }}
|
||||
name: gpui-nightly (macos-latest, arm64)
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'macos' }}
|
||||
runs-on: macos-latest
|
||||
timeout-minutes: 60
|
||||
permissions:
|
||||
@@ -62,13 +64,9 @@ jobs:
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
.artifacts/gpui/macos/target
|
||||
.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') }}
|
||||
key: gpui-nightly-cargo-macos26-arm64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
|
||||
restore-keys: |
|
||||
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
|
||||
gpui-nightly-cargo-macos26-arm64-
|
||||
|
||||
- name: Install macOS build tools
|
||||
run: command -v ninja >/dev/null || brew install ninja
|
||||
@@ -91,11 +89,12 @@ 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 \
|
||||
@@ -187,11 +186,11 @@ jobs:
|
||||
xcrun stapler staple "$app_path"
|
||||
spctl --assess --type execute -v "$app_path"
|
||||
|
||||
out_dir="$RUNNER_TEMP/gpui-experimental-macos-arm64"
|
||||
out_dir="$RUNNER_TEMP/gpui-nightly-macos-arm64"
|
||||
rm -rf "$out_dir"
|
||||
node scripts/gpui.mjs package-macos-dmg "$app_path" "$out_dir"
|
||||
|
||||
dmg_path="$out_dir/Paseo-GPUI-experimental-macos-arm64.dmg"
|
||||
dmg_path="$out_dir/Paseo-GPUI-nightly-macos-arm64.dmg"
|
||||
codesign --force --sign "$sign_identity" --timestamp "$dmg_path"
|
||||
xcrun notarytool submit "$dmg_path" \
|
||||
--apple-id "$APPLE_ID" \
|
||||
@@ -213,7 +212,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-experimental-macos-arm64"
|
||||
out_dir="$RUNNER_TEMP/gpui-nightly-macos-arm64"
|
||||
rm -rf "$out_dir"
|
||||
node scripts/gpui.mjs package-macos-dmg "$app_path" "$out_dir"
|
||||
|
||||
@@ -226,18 +225,18 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Generate macOS checksums
|
||||
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-experimental-macos-arm64" "SHA256SUMS-gpui-experimental-macos-arm64.txt"
|
||||
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-nightly-macos-arm64" "SHA256SUMS-gpui-nightly-macos-arm64.txt"
|
||||
|
||||
- name: Upload macOS experimental artifact
|
||||
- name: Upload macOS nightly artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: gpui-experimental-macos-arm64
|
||||
path: ${{ runner.temp }}/gpui-experimental-macos-arm64
|
||||
name: gpui-nightly-macos-arm64
|
||||
path: ${{ runner.temp }}/gpui-nightly-macos-arm64
|
||||
retention-days: 7
|
||||
|
||||
build-linux:
|
||||
name: gpui-experimental (ubuntu-24.04, x64)
|
||||
if: ${{ inputs.platform == 'all' || inputs.platform == 'linux' }}
|
||||
name: gpui-nightly (ubuntu-24.04, x64)
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.platform == 'all' || github.event.inputs.platform == 'linux' }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
permissions:
|
||||
@@ -262,13 +261,9 @@ jobs:
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
.artifacts/gpui/linux/target
|
||||
.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') }}
|
||||
key: gpui-nightly-cargo-linux-x64-${{ hashFiles('packages/app/gpui/desktop/Cargo.lock', 'packages/app/gpui/package-lock.json') }}
|
||||
restore-keys: |
|
||||
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
|
||||
gpui-nightly-cargo-linux-x64-
|
||||
|
||||
- name: Install Linux GPUI build dependencies
|
||||
run: |
|
||||
@@ -280,8 +275,6 @@ jobs:
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
libfontconfig-dev \
|
||||
libfreetype-dev \
|
||||
libvulkan-dev \
|
||||
libwayland-dev \
|
||||
libx11-xcb-dev \
|
||||
@@ -313,26 +306,25 @@ 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-experimental-linux-x64"
|
||||
run: node scripts/gpui.mjs package-linux --out "${{ runner.temp }}/gpui-nightly-linux-x64"
|
||||
|
||||
- name: Generate Linux checksums
|
||||
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-experimental-linux-x64" "SHA256SUMS-gpui-experimental-linux-x64.txt"
|
||||
run: node scripts/release-checksums.mjs "${{ runner.temp }}/gpui-nightly-linux-x64" "SHA256SUMS-gpui-nightly-linux-x64.txt"
|
||||
|
||||
- name: Upload Linux experimental artifact
|
||||
- name: Upload Linux nightly artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
||||
with:
|
||||
name: gpui-experimental-linux-x64
|
||||
path: ${{ runner.temp }}/gpui-experimental-linux-x64
|
||||
name: gpui-nightly-linux-x64
|
||||
path: ${{ runner.temp }}/gpui-nightly-linux-x64
|
||||
retention-days: 7
|
||||
|
||||
publish:
|
||||
name: Publish gpui-experimental prerelease
|
||||
name: Publish gpui-nightly prerelease
|
||||
needs: [build-macos, build-linux]
|
||||
if: ${{ !cancelled() && inputs.publish != 'false' && needs.build-macos.result == 'success' && needs.build-linux.result == 'success' }}
|
||||
if: ${{ !cancelled() && (github.event_name != 'workflow_dispatch' || github.event.inputs.publish != 'false') && needs.build-macos.result == 'success' && needs.build-linux.result == 'success' }}
|
||||
concurrency:
|
||||
group: gpui-experimental-release
|
||||
group: gpui-nightly-release
|
||||
cancel-in-progress: false
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
@@ -346,124 +338,142 @@ jobs:
|
||||
with:
|
||||
node-version: "22"
|
||||
|
||||
- name: Download built experimental artifacts
|
||||
- name: Download built nightly artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
with:
|
||||
pattern: gpui-experimental-*
|
||||
path: ${{ runner.temp }}/experimental-assets
|
||||
pattern: gpui-nightly-*
|
||||
path: ${{ runner.temp }}/nightly-assets
|
||||
merge-multiple: true
|
||||
|
||||
- name: Publish gpui-experimental prerelease
|
||||
- name: Publish rolling gpui-nightly prerelease
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
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"
|
||||
assets_dir="${RUNNER_TEMP}/nightly-assets"
|
||||
notes_file="${RUNNER_TEMP}/gpui-nightly-notes.md"
|
||||
build_date="$(date -u +"%Y-%m-%d %H:%M UTC")"
|
||||
short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-9)"
|
||||
tag="gpui-experimental-${tag_timestamp}"
|
||||
release_title="Paseo GPUI Experimental ${title_timestamp} UTC"
|
||||
|
||||
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
|
||||
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
|
||||
fi
|
||||
|
||||
{
|
||||
echo "This build is the native desktop app for Paseo. It runs on GPUI instead of Electron."
|
||||
echo "## Paseo GPUI Nightly Preview"
|
||||
echo ""
|
||||
echo "It is under heavy development and is not ready for daily use. It is not a Paseo beta."
|
||||
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 ""
|
||||
echo "If you want to use Paseo normally, download the [latest release](https://github.com/getpaseo/paseo/releases/latest)."
|
||||
echo "### Preview Limitations"
|
||||
echo ""
|
||||
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 "- 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 ""
|
||||
echo "### SHA-256 Checksums"
|
||||
echo ""
|
||||
echo '```'
|
||||
if [[ -f "${assets_dir}/SHA256SUMS-gpui-experimental.txt" ]]; then
|
||||
cat "${assets_dir}/SHA256SUMS-gpui-experimental.txt"
|
||||
if [[ -f "${assets_dir}/SHA256SUMS-gpui-nightly.txt" ]]; then
|
||||
cat "${assets_dir}/SHA256SUMS-gpui-nightly.txt"
|
||||
else
|
||||
echo "(no checksums generated)"
|
||||
fi
|
||||
echo '```'
|
||||
} > "${notes_file}"
|
||||
|
||||
repo="${{ github.repository }}"
|
||||
staging_tag="gpui-experimental-stage-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
tag="gpui-nightly"
|
||||
staging_tag="gpui-nightly-stage-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
staging_id=""
|
||||
created_tag=""
|
||||
old_id=""
|
||||
old_sha=""
|
||||
swapping="false"
|
||||
cleanup_staging() {
|
||||
local ec=$?
|
||||
set +e
|
||||
if [[ -n "$staging_id" ]]; then
|
||||
gh api "repos/${repo}/releases/${staging_id}" -X DELETE > /dev/null 2>&1 || true
|
||||
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
|
||||
fi
|
||||
if [[ -n "$created_tag" ]]; then
|
||||
gh api "repos/${repo}/git/refs/tags/${created_tag}" -X DELETE > /dev/null 2>&1 || true
|
||||
if [[ -n "$staging_id" && "$swapping" != "true" ]]; then
|
||||
gh api "repos/${{ github.repository }}/releases/${staging_id}" -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
|
||||
# publish a half-empty release.
|
||||
# Stage and verify the full asset set on a draft first so upload failures never touch
|
||||
# the public gpui-nightly release or its downloads.
|
||||
gh release create "$staging_tag" \
|
||||
--repo "$repo" \
|
||||
--title "$release_title" \
|
||||
--repo "${{ github.repository }}" \
|
||||
--title "Paseo GPUI Nightly (${short_sha})" \
|
||||
--notes-file "${notes_file}" \
|
||||
--draft \
|
||||
--prerelease \
|
||||
--latest=false \
|
||||
--target "${GITHUB_SHA}"
|
||||
|
||||
staging_id="$(gh release view "$staging_tag" --repo "$repo" --json databaseId --jq '.databaseId')"
|
||||
node scripts/upload-release-assets.mjs "$staging_tag" "${assets_dir}" "$repo"
|
||||
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 }}"
|
||||
|
||||
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
|
||||
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}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
gh api "repos/${repo}/git/refs" \
|
||||
-X POST \
|
||||
-f ref="refs/tags/${tag}" \
|
||||
-f sha="${GITHUB_SHA}"
|
||||
created_tag="$tag"
|
||||
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
|
||||
|
||||
promoted_draft="$(gh api "repos/${repo}/releases/${staging_id}" \
|
||||
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}" \
|
||||
-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" >&2
|
||||
echo "::error::Promoted release is still a draft"
|
||||
exit 1
|
||||
fi
|
||||
swapping="false"
|
||||
staging_id=""
|
||||
created_tag=""
|
||||
|
||||
if [[ -n "$old_id" ]]; then
|
||||
gh api "repos/${{ github.repository }}/releases/${old_id}" -X DELETE > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
+1
-1
@@ -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/caption-button.tsx",
|
||||
"packages/app/src/components/desktop/window-controls.tsx",
|
||||
"packages/app/src/components/dictation-controls.tsx",
|
||||
"packages/app/src/components/download-toast.tsx",
|
||||
"packages/app/src/components/file-explorer-pane.tsx",
|
||||
|
||||
@@ -24,6 +24,18 @@ 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
|
||||
|
||||
@@ -27,7 +27,14 @@ 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";
|
||||
type WorkspaceIndicator =
|
||||
| "attention"
|
||||
| "done"
|
||||
| "failed"
|
||||
| "loading"
|
||||
| "needs_input"
|
||||
| "running"
|
||||
| "waiting";
|
||||
|
||||
interface CreatedAgentAssertion {
|
||||
workspaceId: string;
|
||||
@@ -126,6 +133,7 @@ async function expectWorkspaceRowHasOnlyIndicator(
|
||||
"loading",
|
||||
"needs_input",
|
||||
"running",
|
||||
"waiting",
|
||||
] satisfies WorkspaceIndicator[]) {
|
||||
const locator = row.locator(`[data-testid="workspace-status-indicator-${indicator}"]`);
|
||||
if (indicator === input.indicator) {
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -180,7 +180,7 @@ The following are not feature-parity claims:
|
||||
| Image conversion/image clipboard | Unavailable. The picker accepts PNG/JPEG without conversion. |
|
||||
| Mermaid/HTML/document previews | Mermaid and HTML show source. Document previews report unavailable. No embedded browser backend. |
|
||||
| Terminals | The mobile view expects an Expo `PaseoTerminal` component. No GPUI implementation yet. |
|
||||
| Diffs | `surface.gpui.tsx` lays diff lines out with React Native views and text. No inline review, drag selection, or scroll-to-file yet. |
|
||||
| Diffs | The mobile surface uses React Native Skia. No GPUI drawing backend yet. |
|
||||
| Plugins | The existing loader evaluates JS and injects host React/RN. No end-to-end plugin verification on GPUI yet. |
|
||||
| Other platforms | Linux x86_64 and macOS arm64 have been exercised. Windows remains unverified. |
|
||||
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
{
|
||||
"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,8 +1,5 @@
|
||||
{
|
||||
"icon": "../../../desktop/assets/icon.icns",
|
||||
"window": {
|
||||
"trafficLightPosition": { "x": 16, "y": 10 }
|
||||
},
|
||||
"bundle": {
|
||||
"macos": {
|
||||
"entitlements": "desktop/entitlements.mac.adhoc.plist"
|
||||
|
||||
@@ -17,6 +17,8 @@ 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| {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { readFileSync, realpathSync, statSync } from "node:fs";
|
||||
import { realpathSync, statSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import ts from "typescript";
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
@@ -203,47 +202,6 @@ 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: "diff surface",
|
||||
origin: path.join(APP_DIR, "src/git/diff-document/index.tsx"),
|
||||
specifier: "./surface",
|
||||
gpui: path.join(APP_DIR, "src/git/diff-document/surface.gpui.tsx"),
|
||||
native: path.join(APP_DIR, "src/git/diff-document/surface.native.tsx"),
|
||||
web: path.join(APP_DIR, "src/git/diff-document/surface.web.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(() => {
|
||||
@@ -265,31 +223,6 @@ 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"),
|
||||
@@ -326,46 +259,9 @@ describe("GPUI Metro platform rule", () => {
|
||||
item.specifier,
|
||||
target.platform,
|
||||
).filePath;
|
||||
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, `${target.platform}: ${item.label}`).toBe(item[target.expected]);
|
||||
expect(filePath).not.toContain(".gpui.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("the GPUI diff surface's import graph never reaches React Native Skia", () => {
|
||||
const config = require(path.join(GPUI_DIR, "desktop/metro.config.js")) as MetroConfig;
|
||||
const resolver = require(require.resolve("metro-resolver", { paths: [GPUI_DIR] })) as {
|
||||
resolve: (...args: unknown[]) => unknown;
|
||||
};
|
||||
const entry = path.join(APP_DIR, "src/git/diff-document/surface.gpui.tsx");
|
||||
const sourceRoot = path.join(APP_DIR, "src") + path.sep;
|
||||
const visited = new Set<string>();
|
||||
const bareSpecifiers = new Set<string>();
|
||||
const pending = [entry];
|
||||
while (pending.length > 0) {
|
||||
const file = pending.pop()!;
|
||||
if (visited.has(file)) continue;
|
||||
visited.add(file);
|
||||
const { importedFiles } = ts.preProcessFile(readFileSync(file, "utf8"), true, true);
|
||||
for (const { fileName: specifier } of importedFiles) {
|
||||
if (!specifier.startsWith(".") && !specifier.startsWith("@/")) {
|
||||
bareSpecifiers.add(specifier);
|
||||
continue;
|
||||
}
|
||||
const ctx = createResolutionContext(file, config.resolver.sourceExts, true, resolver);
|
||||
const resolved = config.resolver.resolveRequest(ctx, specifier, "desktop").filePath;
|
||||
if (resolved?.startsWith(sourceRoot) && /\.[cm]?[jt]sx?$/.test(resolved)) {
|
||||
pending.push(resolved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect(visited.size).toBeGreaterThan(1);
|
||||
expect([...bareSpecifiers].filter((name) => name.includes("react-native-skia"))).toEqual([]);
|
||||
expect(
|
||||
[...visited].filter((file) => /diff-document[\\/](text|paint)\.native\./.test(file)),
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Generated
+25
-25
@@ -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-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-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/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-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
|
||||
"@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/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-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-codegen-0.87.0-alpha.2.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-core-0.87.0-alpha.5.tgz",
|
||||
"integrity": "sha512-0rGzTzIJ1/xsxIYxnvx6JNMVrGgu+cW/3MGLtrlJy3/lS0Lkmx6Havv6zjQKnF40FZemFFeV/DfQ/QG32XPK8Q==",
|
||||
"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==",
|
||||
"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-6/react-native-gpui-fs-0.0.1-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-gesture-handler-3.3.0-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-hermes-0.87.0-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-reanimated-4.7.0-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-safe-area-context-5.10.0-alpha.0.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-screens-4.28.0-alpha.2.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-svg-15.15.0-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-v8-0.87.0-alpha.0.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/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-6/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
|
||||
"resolved": "https://github.com/getpaseo/react-native-gpui/releases/download/paseo-5/react-native-gpui-worklets-0.13.0-alpha.1.tgz",
|
||||
"integrity": "sha512-TTN9CFwirHVojJM4s6UHUPU/3qA1zdCcUrokS5gf+G9lmdpKKV3sCr7Cqpdr8MzAAC/4ohpou13JZIbnyP3dSg==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -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-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-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/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-6/react-native-gpui-cli-0.87.0-alpha.5.tgz",
|
||||
"@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/babel-preset": "0.87.1",
|
||||
"@react-native/metro-config": "0.87.1",
|
||||
"typescript": "^5.8.3"
|
||||
|
||||
@@ -72,7 +72,7 @@ export function buildAgentDescriptor(input: {
|
||||
return {
|
||||
label: label ?? "",
|
||||
subtitle:
|
||||
statusBucket === "running" && !input.isTurnActive && input.status !== "running"
|
||||
statusBucket === "waiting"
|
||||
? 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 { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DismissBackdrop } from "@/components/ui/dismiss-backdrop";
|
||||
import {
|
||||
@@ -182,7 +182,8 @@ function DrawerHeader({
|
||||
const showSteppers = mode === "edit" && Boolean(onStepPrev && onStepNext);
|
||||
|
||||
return (
|
||||
<TitlebarDragSurface style={styles.headerChrome}>
|
||||
<View style={styles.headerChrome}>
|
||||
<TitlebarDragRegion />
|
||||
<WindowChromeSafeArea placement="below" />
|
||||
<View style={styles.header}>
|
||||
<View style={styles.headerIdentity}>
|
||||
@@ -245,7 +246,7 @@ function DrawerHeader({
|
||||
</ToolbarButton>
|
||||
</View>
|
||||
</View>
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ 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, useContributedThemes } from "@/appearance/provider";
|
||||
import { resolveWindowChromeAppearance } from "@/appearance/theme-catalog";
|
||||
import { AppearanceProvider } from "@/appearance/provider";
|
||||
import { CommandCenter } from "@/command-center/command-center";
|
||||
import { WorkspaceSwitcherHud } from "@/workspace-switcher";
|
||||
import { CommandCenterRootActions } from "@/command-center/root-registration";
|
||||
@@ -82,7 +81,7 @@ import {
|
||||
resolveSidebarActivity,
|
||||
resolveLeftSidebarPresentation,
|
||||
} from "@/components/desktop-sidebar-layout";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { HorizontalScrollProvider } from "@/contexts/horizontal-scroll-context";
|
||||
import { SessionProvider } from "@/contexts/session-context";
|
||||
import { SidebarCalloutProvider } from "@/contexts/sidebar-callout-context";
|
||||
@@ -107,7 +106,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 { desktopWindowChromeHost } from "@/desktop/window-chrome-host";
|
||||
import { updateDesktopWindowChrome } from "@/desktop/electron/window";
|
||||
import { getDesktopHost } from "@/desktop/host";
|
||||
import { loadDesktopSettings } from "@/desktop/settings/desktop-settings";
|
||||
import { RosettaCalloutSource } from "@/desktop/updates/rosetta-callout-source";
|
||||
@@ -697,28 +696,19 @@ function ProvidersWrapper({ children }: { children: ReactNode }) {
|
||||
}
|
||||
|
||||
function DesktopWindowControlsSync() {
|
||||
const { settings, isLoading } = useAppSettings();
|
||||
const { selected: selectedPluginTheme } = useContributedThemes();
|
||||
const { isLoading } = useAppSettings();
|
||||
const { theme } = useUnistyles();
|
||||
const surface0 = theme.colors.surface0;
|
||||
const appearance = resolveWindowChromeAppearance({
|
||||
theme: settings.theme,
|
||||
hasContributedTheme: selectedPluginTheme !== null,
|
||||
colorScheme: theme.colorScheme,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
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]);
|
||||
if (isLoading || isNative) return;
|
||||
void updateDesktopWindowChrome({
|
||||
backgroundColor: surface0,
|
||||
trafficLightOffsetY: -4,
|
||||
}).catch((error) => {
|
||||
console.warn("[DesktopWindow] Failed to update window controls overlay", error);
|
||||
});
|
||||
}, [isLoading, surface0]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,20 +70,3 @@ 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, resolveWindowChromeAppearance } from "./theme-catalog";
|
||||
import { resolveThemeCatalog } from "./theme-catalog";
|
||||
import type { PluginThemeOption } from "@/plugins/themes";
|
||||
|
||||
const PLUGIN_THEME: PluginThemeOption = {
|
||||
@@ -68,43 +68,4 @@ 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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,9 +18,12 @@ 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(
|
||||
@@ -40,7 +43,7 @@ export function BackgroundWorkTrack({
|
||||
panelTitle={t("message.backgroundWork.title")}
|
||||
segments={[
|
||||
{
|
||||
bucket: "running",
|
||||
bucket,
|
||||
text:
|
||||
visibleCount === 1
|
||||
? t("message.backgroundWork.pillOne")
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
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");
|
||||
@@ -1,42 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
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} />;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
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} />;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
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,17 +1,18 @@
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { View } from "react-native";
|
||||
import { Pressable, 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 {
|
||||
DesktopCaptionButton,
|
||||
type DesktopCaptionButtonProps,
|
||||
} from "@/components/desktop/caption-button";
|
||||
import { WINDOW_NO_DRAG_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
closeDesktopWindow,
|
||||
minimizeDesktopWindow,
|
||||
toggleDesktopMaximize,
|
||||
} from "@/desktop/electron/window";
|
||||
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";
|
||||
|
||||
@@ -80,18 +81,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 (
|
||||
@@ -121,15 +122,23 @@ function WindowControl({
|
||||
[presentation.controlWidth],
|
||||
);
|
||||
return (
|
||||
<DesktopCaptionButton action={action} label={label} style={controlStyle}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={label}
|
||||
onPress={onPress}
|
||||
style={controlStyle}
|
||||
>
|
||||
{glyph}
|
||||
</DesktopCaptionButton>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -140,23 +149,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 { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { HeaderToggleButton } from "@/components/headers/header-toggle-button";
|
||||
import { SidebarMenuToggle } from "@/components/headers/sidebar-menu-toggle";
|
||||
import {
|
||||
@@ -77,31 +77,30 @@ export function CompactHeader({
|
||||
|
||||
return (
|
||||
<IconButtonChromeProvider value="header-island">
|
||||
<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}
|
||||
<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} />}
|
||||
</View>
|
||||
<View style={styles.titleGroup}>
|
||||
<CompactHeaderTitle
|
||||
loading={loading}
|
||||
title={title}
|
||||
titleTestID={titleTestID}
|
||||
subtitle={subtitle}
|
||||
/>
|
||||
</View>
|
||||
{actions ? <View style={styles.island}>{actions}</View> : null}
|
||||
</View>
|
||||
</WindowChromeSafeArea>
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
</WindowChromeSafeArea>
|
||||
</IconButtonChromeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
useIsCompactFormFactor,
|
||||
} from "@/constants/layout";
|
||||
import { WindowChromeSafeArea } from "@/utils/desktop-window";
|
||||
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
|
||||
interface ScreenHeaderProps {
|
||||
left?: ReactNode;
|
||||
@@ -52,17 +52,16 @@ export function ScreenHeader({
|
||||
return (
|
||||
<ComposerDockBackground style={styles.header} testID="composer-dock-header">
|
||||
<View style={innerStyle}>
|
||||
<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>
|
||||
<WindowChromeSafeArea
|
||||
placement="inline"
|
||||
horizontalPadding={baseHorizontalPadding}
|
||||
onLayout={onRowLayout}
|
||||
style={rowStyle}
|
||||
>
|
||||
<TitlebarDragRegion />
|
||||
<View style={leftCombinedStyle}>{left}</View>
|
||||
<View style={rightCombinedStyle}>{right}</View>
|
||||
</WindowChromeSafeArea>
|
||||
</View>
|
||||
</ComposerDockBackground>
|
||||
);
|
||||
@@ -73,9 +72,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
backgroundColor: theme.colors.surface0,
|
||||
},
|
||||
inner: {},
|
||||
dragSurface: {
|
||||
position: "relative",
|
||||
},
|
||||
row: {
|
||||
position: "relative",
|
||||
height: {
|
||||
|
||||
@@ -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 { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { SidebarCloseButton } from "@/components/headers/sidebar-close-button";
|
||||
import {
|
||||
resolveDesktopSidebarInsetLeft,
|
||||
@@ -868,7 +868,8 @@ function DesktopSidebar({
|
||||
<View style={desktopSidebarBorderStyle}>
|
||||
<View style={styles.sidebarDragArea}>
|
||||
{showsChromeRow ? (
|
||||
<TitlebarDragSurface style={styles.desktopChromeRow}>
|
||||
<View style={styles.desktopChromeRow}>
|
||||
<TitlebarDragRegion />
|
||||
{DEV_BUILD_LABEL ? (
|
||||
<View
|
||||
pointerEvents="none"
|
||||
@@ -882,13 +883,12 @@ function DesktopSidebar({
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
) : null}
|
||||
{showsDragStrip ? (
|
||||
<TitlebarDragSurface
|
||||
style={styles.desktopDragStrip}
|
||||
testID="sidebar-nav-drag-strip"
|
||||
/>
|
||||
<View style={styles.desktopDragStrip} testID="sidebar-nav-drag-strip">
|
||||
<TitlebarDragRegion />
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{hasNavRows ? (
|
||||
|
||||
@@ -21,6 +21,7 @@ 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";
|
||||
|
||||
@@ -180,7 +181,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") {
|
||||
if (content.kind === "dot" && (content.bucket === "running" || content.bucket === "waiting")) {
|
||||
return (
|
||||
<View
|
||||
role="status"
|
||||
@@ -188,7 +189,11 @@ function ProjectStatusBadge({
|
||||
style={styles.statusRingAnchor}
|
||||
testID="project-status-badge"
|
||||
>
|
||||
<StatusRing backdrop={backdrop} />
|
||||
{content.bucket === "waiting" ? (
|
||||
<StatusWaitingRing backdrop={backdrop} />
|
||||
) : (
|
||||
<StatusRing backdrop={backdrop} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -257,7 +262,7 @@ function ProjectInlineChevron({ chevron }: { chevron: "expand" | "collapse" | nu
|
||||
|
||||
function getStatusDotColorStyle(bucket: ProjectStatusBadgeDotBucket): ViewStyle {
|
||||
if (bucket === "failed") return styles.statusDotFailed;
|
||||
if (bucket === "running") return styles.statusDotRunning;
|
||||
if (bucket === "running" || bucket === "waiting") return styles.statusDotRunning;
|
||||
return styles.statusDotAttention;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ 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";
|
||||
@@ -103,11 +104,15 @@ 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>();
|
||||
@@ -609,6 +614,9 @@ 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,6 +34,7 @@ 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";
|
||||
@@ -296,6 +297,14 @@ 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">
|
||||
@@ -349,6 +358,7 @@ function getStatusDotColorStyle(bucket: SidebarStateBucket) {
|
||||
case "failed":
|
||||
return styles.statusDotFailed;
|
||||
case "running":
|
||||
case "waiting":
|
||||
return styles.statusDotRunning;
|
||||
case "attention":
|
||||
return styles.statusDotAttention;
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
resolveChildWindowChromeCorners,
|
||||
type WindowChromeCorners,
|
||||
} from "@/utils/desktop-window";
|
||||
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
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,44 +816,43 @@ const SplitPaneView = memo(function SplitPaneView({
|
||||
<AdaptiveWorkspaceChrome compactHeader={compactHeader}>
|
||||
{ownsWorkspaceHeader ? renderMainHeader?.() : null}
|
||||
<WindowChromeRegion corners={focusModeEnabled ? "both" : "none"}>
|
||||
<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>
|
||||
<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>
|
||||
</WindowChromeRegion>
|
||||
</AdaptiveWorkspaceChrome>
|
||||
|
||||
@@ -936,10 +935,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
backgroundColor: theme.colors.surface0,
|
||||
overflow: "hidden",
|
||||
},
|
||||
paneTabsDragSurface: {
|
||||
position: "relative",
|
||||
minWidth: 0,
|
||||
},
|
||||
paneTabs: {
|
||||
position: "relative",
|
||||
minWidth: 0,
|
||||
|
||||
@@ -6,6 +6,7 @@ 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,
|
||||
@@ -37,6 +38,7 @@ 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;
|
||||
@@ -68,6 +70,11 @@ 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,10 +32,23 @@ export interface StatusRingProps {
|
||||
*/
|
||||
export function StatusRingFrame({ backdrop, children }: StatusRingProps & { children: ReactNode }) {
|
||||
return (
|
||||
<View style={[styles.frame, getBackdropStyle(backdrop)]} testID="status-ring">
|
||||
<StatusMarkFrame backdrop={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,6 +27,24 @@ 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.
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
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>
|
||||
);
|
||||
});
|
||||
@@ -22,6 +22,7 @@ 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,
|
||||
@@ -362,10 +363,17 @@ 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">) {
|
||||
function dotColorStyle(bucket: Exclude<SidebarStateBucket, "running" | "waiting">) {
|
||||
switch (bucket) {
|
||||
case "needs_input":
|
||||
return styles.dotNeedsInput;
|
||||
@@ -381,7 +389,7 @@ function dotColorStyle(bucket: Exclude<SidebarStateBucket, "running">) {
|
||||
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">) => ({
|
||||
const statusDot = (bucket: Exclude<SidebarStateBucket, "running" | "waiting">) => ({
|
||||
width: STATUS_INDICATOR_FILLED_DOT_SIZE,
|
||||
height: STATUS_INDICATOR_FILLED_DOT_SIZE,
|
||||
borderRadius: theme.borderRadius.full,
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { getDesktopHost, type DesktopWindowBridge } from "@/desktop/host";
|
||||
import {
|
||||
getDesktopHost,
|
||||
type DesktopWindowBridge,
|
||||
type DesktopWindowChromeUpdate,
|
||||
} from "@/desktop/host";
|
||||
|
||||
export function getDesktopWindow(): DesktopWindowBridge | null {
|
||||
const getter = getDesktopHost()?.window?.getCurrentWindow;
|
||||
@@ -11,3 +15,40 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1,260 +0,0 @@
|
||||
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();
|
||||
@@ -1,23 +0,0 @@
|
||||
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,
|
||||
};
|
||||
@@ -1,389 +0,0 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
export type {
|
||||
DesktopWindowChromeHost,
|
||||
DesktopWindowChromeSnapshot,
|
||||
DesktopWindowChromeUpdate,
|
||||
} from "./window-chrome-host.types";
|
||||
|
||||
export { desktopWindowChromeHost } from "./window-chrome-host.noop";
|
||||
@@ -1,23 +0,0 @@
|
||||
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>;
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
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();
|
||||
@@ -4,7 +4,7 @@ import type { DiffFileSection } from "./types";
|
||||
import type { DiffDocumentProps } from "./types";
|
||||
|
||||
interface DocumentFileHeaderProps {
|
||||
file: Pick<DiffFileSection, "file" | "fileIndex" | "path" | "isCollapsed">;
|
||||
file: DiffFileSection;
|
||||
selectedPath: string | null;
|
||||
mode: DiffDocumentProps["mode"];
|
||||
onToggleFile: (path: string) => void;
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ParsedDiffFile } from "@getpaseo/protocol/messages";
|
||||
import { DiffSurface } from "./surface.gpui";
|
||||
import type { DiffPalette, DiffSurfaceProps } from "./types";
|
||||
|
||||
const PALETTE: DiffPalette = {
|
||||
surface: "rgb(1, 2, 3)",
|
||||
headerSurface: "rgb(1, 2, 3)",
|
||||
border: "rgb(9, 9, 9)",
|
||||
foreground: "rgb(240, 240, 240)",
|
||||
foregroundMuted: "rgb(120, 120, 120)",
|
||||
addition: "rgb(0, 200, 0)",
|
||||
deletion: "rgb(200, 0, 0)",
|
||||
additionBackground: "rgba(0, 128, 0, 0.15)",
|
||||
deletionBackground: "rgba(128, 0, 0, 0.1)",
|
||||
emptyBackground: "rgb(1, 2, 3)",
|
||||
selection: "rgb(0, 0, 255)",
|
||||
headerActiveSurface: "rgb(4, 5, 6)",
|
||||
headerBorder: "rgb(7, 8, 9)",
|
||||
statusSuccess: "rgb(0, 200, 0)",
|
||||
statusDanger: "rgb(200, 0, 0)",
|
||||
statusWarning: "rgb(200, 200, 0)",
|
||||
syntax: { keyword: "rgb(255, 0, 255)" },
|
||||
};
|
||||
|
||||
const GREETING_FILE: ParsedDiffFile = {
|
||||
path: "src/greeting.ts",
|
||||
isNew: false,
|
||||
isDeleted: false,
|
||||
additions: 1,
|
||||
deletions: 1,
|
||||
hunks: [
|
||||
{
|
||||
oldStart: 10,
|
||||
oldCount: 2,
|
||||
newStart: 10,
|
||||
newCount: 2,
|
||||
lines: [
|
||||
{ type: "header", content: "@@ -10,2 +10,2 @@ export function greet()" },
|
||||
{ type: "context", content: "const greeting = prefix;" },
|
||||
{ type: "remove", content: 'return "hello";' },
|
||||
{
|
||||
type: "add",
|
||||
content: "return `hi`;",
|
||||
tokens: [
|
||||
{ text: "return", style: "keyword" },
|
||||
{ text: " `hi`;", style: null },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function renderSurface(overrides: Partial<DiffSurfaceProps> = {}): string {
|
||||
const props = {
|
||||
files: [GREETING_FILE],
|
||||
mode: { kind: "commit" },
|
||||
displayPreferences: {
|
||||
layout: "unified",
|
||||
wrapLines: true,
|
||||
codeFontSize: 13,
|
||||
monoFontFamily: "Menlo",
|
||||
},
|
||||
palette: PALETTE,
|
||||
headerTypography: { family: "Inter", size: 14, statSize: 12 },
|
||||
collapsedFilePaths: new Set<string>(),
|
||||
onToggleFile: () => {},
|
||||
selectedPath: null,
|
||||
onSelectPath: () => {},
|
||||
...overrides,
|
||||
} as DiffSurfaceProps;
|
||||
return renderToStaticMarkup(<DiffSurface {...props} />);
|
||||
}
|
||||
|
||||
describe("GPUI DiffSurface", () => {
|
||||
it("renders hunk headers and added, removed, and context lines with their line numbers", () => {
|
||||
const markup = renderSurface();
|
||||
|
||||
expect(markup).toContain("@@ -10,2 +10,2 @@ export function greet()");
|
||||
expect(markup).toContain("const greeting = prefix;");
|
||||
expect(markup).toContain("hello");
|
||||
expect(markup).toContain("hi");
|
||||
expect(markup).toContain('data-testid="diff-line-context"');
|
||||
expect(markup).toContain('data-testid="diff-line-remove"');
|
||||
expect(markup).toContain('data-testid="diff-line-add"');
|
||||
// context line 10 (old and new), removed old line 11, added new line 11
|
||||
expect(markup).toMatch(/>10</);
|
||||
expect(markup).toMatch(/>11</);
|
||||
});
|
||||
|
||||
it("paints added and removed rows with the palette backgrounds", () => {
|
||||
const markup = renderSurface();
|
||||
|
||||
expect(markup).toContain("rgba(0,128,0,0.15)");
|
||||
expect(markup).toContain("rgba(128,0,0,0.10)");
|
||||
});
|
||||
|
||||
it("colors syntax tokens from the palette and leaves unstyled tokens in the foreground", () => {
|
||||
const markup = renderSurface();
|
||||
|
||||
expect(markup).toMatch(/color:rgba\(255,0,255,1\.00\)[^>]*>return</);
|
||||
});
|
||||
|
||||
it("renders every file in the document", () => {
|
||||
const other: ParsedDiffFile = {
|
||||
...GREETING_FILE,
|
||||
path: "src/other.ts",
|
||||
hunks: [
|
||||
{
|
||||
oldStart: 1,
|
||||
oldCount: 0,
|
||||
newStart: 1,
|
||||
newCount: 1,
|
||||
lines: [
|
||||
{ type: "header", content: "@@ -0,0 +1 @@" },
|
||||
{ type: "add", content: "export const other = 1;" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const markup = renderSurface({ files: [GREETING_FILE, other] });
|
||||
|
||||
expect(markup).toContain("greeting.ts");
|
||||
expect(markup).toContain("other.ts");
|
||||
expect(markup).toContain("export const other = 1;");
|
||||
});
|
||||
|
||||
it("hides the body of a collapsed file", () => {
|
||||
const markup = renderSurface({ collapsedFilePaths: new Set(["src/greeting.ts"]) });
|
||||
|
||||
expect(markup).toContain("greeting.ts");
|
||||
expect(markup).not.toContain("const greeting = prefix;");
|
||||
});
|
||||
|
||||
it("colors line numbers by line type", () => {
|
||||
const markup = renderSurface();
|
||||
|
||||
expect(markup).toMatch(/color:rgba\(0,200,0,1\.00\)[^>]*>11</);
|
||||
expect(markup).toMatch(/color:rgba\(200,0,0,1\.00\)[^>]*>11</);
|
||||
expect(markup).toMatch(/color:rgba\(120,120,120,1\.00\)[^>]*>10</);
|
||||
});
|
||||
|
||||
it("renders no rows for an empty diff", () => {
|
||||
const markup = renderSurface({ files: [] });
|
||||
|
||||
expect(markup).not.toContain("diff-line-");
|
||||
});
|
||||
|
||||
it("explains files whose diff is not shown", () => {
|
||||
const binary: ParsedDiffFile = { ...GREETING_FILE, hunks: [], status: "binary" };
|
||||
const markup = renderSurface({ files: [binary] });
|
||||
|
||||
expect(markup).toContain('data-testid="diff-status"');
|
||||
expect(markup).not.toContain("diff-line-");
|
||||
});
|
||||
|
||||
it("renders split preferences as unified rows", () => {
|
||||
const markup = renderSurface({
|
||||
displayPreferences: {
|
||||
layout: "split",
|
||||
wrapLines: true,
|
||||
codeFontSize: 13,
|
||||
monoFontFamily: "Menlo",
|
||||
},
|
||||
});
|
||||
|
||||
expect(markup).toContain('data-testid="diff-line-remove"');
|
||||
expect(markup).toContain('data-testid="diff-line-add"');
|
||||
});
|
||||
|
||||
it("keeps scrollable space below the last line for floating controls", () => {
|
||||
expect(renderSurface({ contentInsetBottom: 73 })).toContain("padding-bottom:73px");
|
||||
});
|
||||
});
|
||||
@@ -1,273 +0,0 @@
|
||||
import { memo, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ScrollView, StyleSheet, Text, View, type TextStyle, type ViewStyle } from "react-native";
|
||||
import type { ParsedDiffFile } from "@getpaseo/protocol/messages";
|
||||
import { lineNumberGutterWidth } from "@/components/code-insets";
|
||||
import { buildUnifiedDiffLines } from "@/utils/diff-layout";
|
||||
import { compactHighlightTokens, formatDiffContentText } from "@/utils/diff-rendering";
|
||||
import { DocumentFileHeader } from "./document-file-header";
|
||||
import type { DiffPalette, DiffSurfaceProps } from "./types";
|
||||
|
||||
// GPUI has no Skia canvas, so this surface lays each diff line out with plain React Native
|
||||
// views and text. The canvas-only features of the mobile surface (inline review threads,
|
||||
// drag selection, scroll-to-file) are not part of it. It always lays lines out unified: the
|
||||
// split layout is offered only where `isWeb` holds, so callers never pass it on GPUI.
|
||||
|
||||
type LineType = "add" | "remove" | "context" | "header";
|
||||
|
||||
interface CodeStyle {
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
lineHeight: number;
|
||||
}
|
||||
|
||||
interface LineCell {
|
||||
type: LineType;
|
||||
content: string;
|
||||
lineNumber: number | null;
|
||||
tokens?: ParsedDiffFile["hunks"][number]["lines"][number]["tokens"];
|
||||
}
|
||||
|
||||
const MONOSPACE = "monospace";
|
||||
const CODE_PADDING = 8;
|
||||
|
||||
export function DiffSurface(props: DiffSurfaceProps) {
|
||||
const { displayPreferences, palette } = props;
|
||||
const code = useMemo<CodeStyle>(
|
||||
() => ({
|
||||
fontFamily: displayPreferences.monoFontFamily.trim() || MONOSPACE,
|
||||
fontSize: displayPreferences.codeFontSize,
|
||||
lineHeight: Math.round(displayPreferences.codeFontSize * 1.5),
|
||||
}),
|
||||
[displayPreferences.monoFontFamily, displayPreferences.codeFontSize],
|
||||
);
|
||||
const contentStyle = useMemo<ViewStyle>(
|
||||
() => ({ paddingBottom: props.contentInsetBottom ?? 0 }),
|
||||
[props.contentInsetBottom],
|
||||
);
|
||||
return (
|
||||
<ScrollView
|
||||
style={[styles.fill, { backgroundColor: palette.surface }]}
|
||||
contentContainerStyle={contentStyle}
|
||||
>
|
||||
{props.files.map((file, fileIndex) => (
|
||||
<FileSection
|
||||
key={file.path}
|
||||
file={file}
|
||||
fileIndex={fileIndex}
|
||||
surface={props}
|
||||
code={code}
|
||||
/>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
interface FileSectionProps {
|
||||
file: ParsedDiffFile;
|
||||
fileIndex: number;
|
||||
surface: DiffSurfaceProps;
|
||||
code: CodeStyle;
|
||||
}
|
||||
|
||||
function FileSection({ file, fileIndex, surface, code }: FileSectionProps) {
|
||||
const isCollapsed = surface.collapsedFilePaths.has(file.path);
|
||||
const section = useMemo(
|
||||
() => ({ file, fileIndex, path: file.path, isCollapsed }),
|
||||
[file, fileIndex, isCollapsed],
|
||||
);
|
||||
return (
|
||||
<View>
|
||||
<DocumentFileHeader
|
||||
file={section}
|
||||
selectedPath={surface.selectedPath}
|
||||
mode={surface.mode}
|
||||
onToggleFile={surface.onToggleFile}
|
||||
onSelectPath={surface.onSelectPath}
|
||||
/>
|
||||
{isCollapsed ? null : (
|
||||
<FileBody
|
||||
file={file}
|
||||
wrapLines={surface.displayPreferences.wrapLines}
|
||||
palette={surface.palette}
|
||||
code={code}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
interface FileBodyProps {
|
||||
file: ParsedDiffFile;
|
||||
wrapLines: boolean;
|
||||
palette: DiffPalette;
|
||||
code: CodeStyle;
|
||||
}
|
||||
|
||||
const FileBody = memo(function FileBody({ file, wrapLines, palette, code }: FileBodyProps) {
|
||||
const { t } = useTranslation();
|
||||
const bodyStyle = useMemo<ViewStyle>(
|
||||
() => ({ borderTopWidth: StyleSheet.hairlineWidth, borderColor: palette.border }),
|
||||
[palette.border],
|
||||
);
|
||||
const rows = useMemo(
|
||||
() => (file.status === "binary" || file.status === "too_large" ? [] : bodyRows(file)),
|
||||
[file],
|
||||
);
|
||||
const gutterWidth = useMemo(
|
||||
() => lineNumberGutterWidth(maxLineNumber(file), code.fontSize),
|
||||
[file, code.fontSize],
|
||||
);
|
||||
|
||||
if (file.status === "binary" || file.status === "too_large") {
|
||||
const label =
|
||||
file.status === "binary"
|
||||
? t("workspace.git.diff.binaryFile")
|
||||
: t("workspace.git.diff.tooLarge");
|
||||
return (
|
||||
<View style={[bodyStyle, styles.status]} testID="diff-status">
|
||||
<ColoredText color={palette.foregroundMuted} fontFamily={code.fontFamily}>
|
||||
{label}
|
||||
</ColoredText>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const lines = rows.map((row) => (
|
||||
<LineRow
|
||||
key={row.key}
|
||||
cell={row.cell}
|
||||
palette={palette}
|
||||
code={code}
|
||||
gutterWidth={gutterWidth}
|
||||
wrapLines={wrapLines}
|
||||
/>
|
||||
));
|
||||
if (wrapLines) return <View style={bodyStyle}>{lines}</View>;
|
||||
return (
|
||||
<ScrollView horizontal style={bodyStyle} contentContainerStyle={styles.unwrappedContent}>
|
||||
<View style={styles.unwrappedRows}>{lines}</View>
|
||||
</ScrollView>
|
||||
);
|
||||
});
|
||||
|
||||
function bodyRows(file: ParsedDiffFile): Array<{ key: string; cell: LineCell }> {
|
||||
return buildUnifiedDiffLines(file).map((entry) => ({
|
||||
key: entry.key,
|
||||
cell: {
|
||||
type: entry.line.type,
|
||||
content: entry.line.content,
|
||||
lineNumber: entry.lineNumber,
|
||||
tokens: entry.line.tokens,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
function maxLineNumber(file: ParsedDiffFile): number {
|
||||
return file.hunks.reduce(
|
||||
(max, hunk) => Math.max(max, hunk.oldStart + hunk.oldCount, hunk.newStart + hunk.newCount),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
interface CellProps {
|
||||
palette: DiffPalette;
|
||||
code: CodeStyle;
|
||||
gutterWidth: number;
|
||||
wrapLines: boolean;
|
||||
}
|
||||
|
||||
function LineRow({ cell, ...rest }: CellProps & { cell: LineCell }) {
|
||||
return (
|
||||
<View testID={`diff-line-${cell.type}`} style={rowStyle(cell.type, rest.palette)}>
|
||||
<LineCellContent cell={cell} {...rest} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function LineCellContent({
|
||||
cell,
|
||||
palette,
|
||||
code,
|
||||
gutterWidth,
|
||||
wrapLines,
|
||||
}: CellProps & { cell: LineCell }) {
|
||||
const isHeader = cell.type === "header";
|
||||
const textStyle = useMemo<TextStyle>(
|
||||
() => ({
|
||||
...code,
|
||||
color: isHeader ? palette.foregroundMuted : palette.foreground,
|
||||
}),
|
||||
[code, isHeader, palette.foreground, palette.foregroundMuted],
|
||||
);
|
||||
const tokens = isHeader || !cell.tokens ? [] : compactHighlightTokens(cell.tokens);
|
||||
return (
|
||||
<View style={styles.cell}>
|
||||
{isHeader ? null : (
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[
|
||||
textStyle,
|
||||
styles.gutter,
|
||||
{ width: gutterWidth, color: lineNumberColor(cell.type, palette) },
|
||||
]}
|
||||
>
|
||||
{cell.lineNumber == null ? " " : cell.lineNumber}
|
||||
</Text>
|
||||
)}
|
||||
<Text
|
||||
numberOfLines={wrapLines ? undefined : 1}
|
||||
style={[styles.code, textStyle, isHeader ? undefined : styles.codeInset]}
|
||||
>
|
||||
{tokens.length > 0
|
||||
? tokens.map((token, index) => (
|
||||
<ColoredText
|
||||
// Tokens carry no identity beyond their position in the line.
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key={index}
|
||||
color={(token.style && palette.syntax[token.style]) || palette.foreground}
|
||||
>
|
||||
{token.text}
|
||||
</ColoredText>
|
||||
))
|
||||
: formatDiffContentText(cell.content)}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function ColoredText({
|
||||
color,
|
||||
fontFamily,
|
||||
children,
|
||||
}: {
|
||||
color: string;
|
||||
fontFamily?: string;
|
||||
children: string;
|
||||
}) {
|
||||
const style = useMemo<TextStyle>(() => ({ color, fontFamily }), [color, fontFamily]);
|
||||
return <Text style={style}>{children}</Text>;
|
||||
}
|
||||
|
||||
function rowStyle(type: LineType, palette: DiffPalette): ViewStyle {
|
||||
if (type === "add") return { backgroundColor: palette.additionBackground };
|
||||
if (type === "remove") return { backgroundColor: palette.deletionBackground };
|
||||
return {};
|
||||
}
|
||||
|
||||
function lineNumberColor(type: LineType, palette: DiffPalette): string {
|
||||
if (type === "add") return palette.addition;
|
||||
if (type === "remove") return palette.deletion;
|
||||
return palette.foregroundMuted;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
fill: { flex: 1 },
|
||||
status: { paddingHorizontal: 12, paddingVertical: 12 },
|
||||
unwrappedContent: { minWidth: "100%" },
|
||||
unwrappedRows: { minWidth: "100%", alignSelf: "flex-start" },
|
||||
cell: { flexDirection: "row", alignItems: "flex-start" },
|
||||
gutter: { textAlign: "right", paddingRight: 4, flexShrink: 0 },
|
||||
code: { flex: 1, minWidth: 0 },
|
||||
codeInset: { paddingLeft: CODE_PADDING },
|
||||
});
|
||||
@@ -64,6 +64,42 @@ 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" }),
|
||||
@@ -178,6 +214,11 @@ 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 }),
|
||||
];
|
||||
|
||||
@@ -241,6 +282,7 @@ describe("getStatusBucketLabel", () => {
|
||||
"Échec",
|
||||
"À relire",
|
||||
"En cours",
|
||||
"En attente",
|
||||
"Terminé",
|
||||
]);
|
||||
} finally {
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 };
|
||||
@@ -11,10 +12,14 @@ 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<StatusBucket, string>;
|
||||
} as const satisfies Record<SidebarWorkspaceEntry["statusBucket"], string>;
|
||||
|
||||
export function getStatusBucketLabel(bucket: StatusBucket, t: TFunction): string {
|
||||
export function getStatusBucketLabel(
|
||||
bucket: SidebarWorkspaceEntry["statusBucket"],
|
||||
t: TFunction,
|
||||
): string {
|
||||
return t(STATUS_BUCKET_LABEL_KEYS[bucket]);
|
||||
}
|
||||
|
||||
@@ -32,7 +37,7 @@ export function buildStatusGroups(
|
||||
const bucketRows = new Map<StatusBucket, SidebarWorkspaceEntry[]>();
|
||||
|
||||
for (const ws of workspaces) {
|
||||
const bucket: StatusBucket = ws.statusBucket;
|
||||
const bucket = ws.statusBucket;
|
||||
let rows = bucketRows.get(bucket);
|
||||
if (!rows) {
|
||||
rows = [];
|
||||
|
||||
@@ -1334,6 +1334,7 @@ export const ar: TranslationResources = {
|
||||
failed: "فشل",
|
||||
readyToReview: "جاهزة للمراجعة",
|
||||
working: "قيد العمل",
|
||||
waiting: "في الانتظار",
|
||||
done: "تم",
|
||||
},
|
||||
display: {
|
||||
@@ -2427,6 +2428,7 @@ export const ar: TranslationResources = {
|
||||
pillLabelOne: "وكيل فرعي واحد",
|
||||
pillLabelMany: "{{count}} وكلاء فرعيين",
|
||||
pillLabelWorking: "{{count}} قيد التشغيل",
|
||||
pillLabelWaiting: "{{count}} في الانتظار",
|
||||
pillLabelFailed: "{{count}} فشلت",
|
||||
pillLabelNeedsInputOne: "واحد يحتاج إدخالاً",
|
||||
pillLabelNeedsInputMany: "{{count}} تحتاج إدخالاً",
|
||||
|
||||
@@ -1345,6 +1345,7 @@ export const en = {
|
||||
failed: "Failed",
|
||||
readyToReview: "Ready to review",
|
||||
working: "Working",
|
||||
waiting: "Waiting",
|
||||
done: "Done",
|
||||
},
|
||||
display: {
|
||||
@@ -2459,6 +2460,7 @@ 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",
|
||||
|
||||
@@ -1371,6 +1371,7 @@ export const es: TranslationResources = {
|
||||
failed: "Con error",
|
||||
readyToReview: "Para revisar",
|
||||
working: "En ejecución",
|
||||
waiting: "En espera",
|
||||
done: "Terminado",
|
||||
},
|
||||
display: {
|
||||
@@ -2487,6 +2488,7 @@ 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",
|
||||
|
||||
@@ -1363,6 +1363,7 @@ export const fr: TranslationResources = {
|
||||
failed: "Échec",
|
||||
readyToReview: "À relire",
|
||||
working: "En cours",
|
||||
waiting: "En attente",
|
||||
done: "Terminé",
|
||||
},
|
||||
display: {
|
||||
@@ -2483,6 +2484,7 @@ 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",
|
||||
|
||||
@@ -1348,6 +1348,7 @@ export const ja: TranslationResources = {
|
||||
failed: "失敗",
|
||||
readyToReview: "レビュー待ち",
|
||||
working: "実行中",
|
||||
waiting: "待機中",
|
||||
done: "完了",
|
||||
},
|
||||
display: {
|
||||
@@ -2453,6 +2454,7 @@ export const ja: TranslationResources = {
|
||||
pillLabelOne: "サブエージェント 1 件",
|
||||
pillLabelMany: "サブエージェント {{count}} 件",
|
||||
pillLabelWorking: "{{count}} 件実行中",
|
||||
pillLabelWaiting: "{{count}} 件待機中",
|
||||
pillLabelFailed: "{{count}} 件失敗",
|
||||
pillLabelNeedsInputOne: "1 件が入力待ち",
|
||||
pillLabelNeedsInputMany: "{{count}} 件が入力待ち",
|
||||
|
||||
@@ -1341,6 +1341,7 @@ export const ko: TranslationResources = {
|
||||
failed: "실패",
|
||||
readyToReview: "검토 대기",
|
||||
working: "실행 중",
|
||||
waiting: "대기 중",
|
||||
done: "완료",
|
||||
},
|
||||
display: {
|
||||
@@ -2444,6 +2445,7 @@ export const ko: TranslationResources = {
|
||||
pillLabelOne: "하위 에이전트 1개",
|
||||
pillLabelMany: "하위 에이전트 {{count}}개",
|
||||
pillLabelWorking: "{{count}}개 실행 중",
|
||||
pillLabelWaiting: "{{count}}개 대기 중",
|
||||
pillLabelFailed: "{{count}}개 실패",
|
||||
pillLabelNeedsInputOne: "1개 입력 필요",
|
||||
pillLabelNeedsInputMany: "{{count}}개 입력 필요",
|
||||
|
||||
@@ -1361,6 +1361,7 @@ export const ptBR: TranslationResources = {
|
||||
failed: "Com falha",
|
||||
readyToReview: "Para revisar",
|
||||
working: "Em execução",
|
||||
waiting: "Aguardando",
|
||||
done: "Concluído",
|
||||
},
|
||||
display: {
|
||||
@@ -2469,6 +2470,7 @@ 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",
|
||||
|
||||
@@ -1353,6 +1353,7 @@ export const ru: TranslationResources = {
|
||||
failed: "Ошибка",
|
||||
readyToReview: "На проверку",
|
||||
working: "В работе",
|
||||
waiting: "Ожидание",
|
||||
done: "Готово",
|
||||
},
|
||||
display: {
|
||||
@@ -2469,6 +2470,7 @@ export const ru: TranslationResources = {
|
||||
pillLabelOne: "1 субагент",
|
||||
pillLabelMany: "Субагентов: {{count}}",
|
||||
pillLabelWorking: "{{count}} в работе",
|
||||
pillLabelWaiting: "{{count}} в ожидании",
|
||||
pillLabelFailed: "{{count}} с ошибкой",
|
||||
pillLabelNeedsInputOne: "1 ожидает ввода",
|
||||
pillLabelNeedsInputMany: "{{count}} ожидают ввода",
|
||||
|
||||
@@ -1326,6 +1326,7 @@ export const zhCN: TranslationResources = {
|
||||
failed: "失败",
|
||||
readyToReview: "待查看",
|
||||
working: "运行中",
|
||||
waiting: "等待中",
|
||||
done: "已完成",
|
||||
},
|
||||
display: {
|
||||
@@ -2400,6 +2401,7 @@ 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 running without making the turn active", () => {
|
||||
it("shows background work as waiting without making the turn active", () => {
|
||||
expect(describeAgent({ backgroundWork: { count: 1 } })).toMatchObject({
|
||||
statusBucket: "running",
|
||||
statusBucket: "waiting",
|
||||
subtitle: "Background work running",
|
||||
});
|
||||
expect(
|
||||
@@ -118,6 +118,9 @@ 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",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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";
|
||||
@@ -9,7 +10,7 @@ import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { usePaneContext } from "@/panels/pane-context";
|
||||
import { useSettings } from "@/hooks/use-settings";
|
||||
import { PluginComposerPillItems, PluginComposerPills } from "@/plugins";
|
||||
import { useSessionStore } from "@/stores/session-store";
|
||||
import { selectAgentTurnPresentation, useSessionStore } from "@/stores/session-store";
|
||||
import {
|
||||
useArchiveFinishedSubagents,
|
||||
useArchiveSubagent,
|
||||
@@ -58,6 +59,15 @@ 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],
|
||||
@@ -123,7 +133,11 @@ export const AgentTracks = memo(function AgentTracks({
|
||||
|
||||
return (
|
||||
<ComposerTrackBar trackViewportRef={trackViewportRef}>
|
||||
<BackgroundWorkTrack model={backgroundModel} count={backgroundWorkCount} />
|
||||
<BackgroundWorkTrack
|
||||
model={backgroundModel}
|
||||
count={backgroundWorkCount}
|
||||
bucket={backgroundWorkBucket}
|
||||
/>
|
||||
{parentAgentId ? <ParentAgentPill serverId={serverId} parentAgentId={parentAgentId} /> : null}
|
||||
<AgentTaskList tasks={tasks} />
|
||||
<SubagentsTrack
|
||||
|
||||
@@ -177,6 +177,12 @@ 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,6 +116,7 @@ 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;
|
||||
|
||||
@@ -398,6 +398,20 @@ 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", "attention", "done"]),
|
||||
status: z.enum(["needs_input", "failed", "running", "waiting", "attention", "done"]),
|
||||
statusEnteredAt: IsoDateSchema.nullable(),
|
||||
activityAt: z.null(),
|
||||
archivingAt: z.string().nullable(),
|
||||
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
resolveActiveHostServerId,
|
||||
type HostProfile,
|
||||
} from "@/types/host-connection";
|
||||
import { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { WindowChromeRegion, WindowChromeSafeArea } from "@/utils/desktop-window";
|
||||
import { confirmDialog } from "@/utils/confirm-dialog";
|
||||
import { BackHeader } from "@/components/headers/back-header";
|
||||
@@ -1223,7 +1223,8 @@ function SettingsSidebar({
|
||||
>
|
||||
{isDesktop ? (
|
||||
<View style={innerContainerStyle}>
|
||||
<TitlebarDragSurface style={sidebarStyles.sidebarDragArea}>
|
||||
<View style={sidebarStyles.sidebarDragArea}>
|
||||
<TitlebarDragRegion />
|
||||
<WindowChromeSafeArea placement="below" />
|
||||
<SidebarHeaderRow
|
||||
icon={ArrowLeft}
|
||||
@@ -1231,7 +1232,7 @@ function SettingsSidebar({
|
||||
onPress={onBackToWorkspace}
|
||||
testID="settings-back-to-workspace"
|
||||
/>
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
<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 { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { useNativeSplashHold } from "@/native-splash";
|
||||
import { CODE_SURFACE_DATASET } from "@/styles/code-surface";
|
||||
@@ -394,16 +394,18 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
|
||||
|
||||
if (!isError) {
|
||||
return (
|
||||
<TitlebarDragSurface testID="startup-splash" style={styles.container}>
|
||||
<View testID="startup-splash" style={styles.container}>
|
||||
<TitlebarDragRegion />
|
||||
<View style={styles.logo}>
|
||||
<LogoShimmer />
|
||||
</View>
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<TitlebarDragSurface style={styles.errorScreen}>
|
||||
<View style={styles.errorScreen}>
|
||||
<TitlebarDragRegion />
|
||||
<ScrollView
|
||||
style={styles.errorScrollView}
|
||||
contentContainerStyle={styles.errorScrollContent}
|
||||
@@ -451,6 +453,6 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</TitlebarDragSurface>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 { TitlebarDragSurface } from "@/components/desktop/titlebar-drag-surface";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import { WorkspacePanelHost } from "@/screens/workspace/workspace-panel-host";
|
||||
import { deriveWorkspacePaneState } from "@/screens/workspace/workspace-pane-state";
|
||||
import {
|
||||
@@ -121,44 +121,43 @@ export function ExplorerSidebarDock({
|
||||
<RetainedPanel active>
|
||||
<WindowChromeRegion corners="top-right">
|
||||
<View style={styles.dock} testID="workspace-explorer-sidebar">
|
||||
<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>
|
||||
<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>
|
||||
<View style={styles.content}>
|
||||
<WorkspacePanelHost
|
||||
paneId={pane.id}
|
||||
@@ -184,10 +183,6 @@ const styles = StyleSheet.create((theme) => ({
|
||||
minHeight: 0,
|
||||
backgroundColor: theme.colors.surfaceSidebar,
|
||||
},
|
||||
tabRailDragSurface: {
|
||||
position: "relative",
|
||||
flexShrink: 0,
|
||||
},
|
||||
tabRail: {
|
||||
position: "relative",
|
||||
flexDirection: "row",
|
||||
|
||||
@@ -1666,12 +1666,9 @@ const styles = StyleSheet.create((theme) => ({
|
||||
minWidth: 0,
|
||||
flex: 1,
|
||||
alignSelf: "stretch",
|
||||
flexDirection: "row",
|
||||
alignItems: "stretch",
|
||||
},
|
||||
tabsScrollFitContent: {
|
||||
flexGrow: 0,
|
||||
flexShrink: 1,
|
||||
flex: 1,
|
||||
},
|
||||
tabsScrollOverflow: {
|
||||
flex: 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isAgentRunning } from "@getpaseo/protocol/agent-state-bucket";
|
||||
import { isAgentBusy } 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 = isAgentRunning(input);
|
||||
const isRunning = isAgentBusy(input);
|
||||
|
||||
let message = `Remove ${subagentLabel} from the track. The subagent will be archived.`;
|
||||
if (isRunning) {
|
||||
|
||||
@@ -49,6 +49,22 @@ 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([
|
||||
@@ -194,11 +210,19 @@ describe("buildSubagentRowPresentationData", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("shows a child with background work as running after its foreground turn ends", () => {
|
||||
it("shows a child with background work as waiting 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 { isAgentRunning } from "@getpaseo/protocol/agent-state-bucket";
|
||||
import { deriveAgentStateBucket } 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,8 +26,9 @@ export function deriveSubagentStatusBucket(
|
||||
backgroundWork?: AgentBackgroundWorkSummary | null,
|
||||
): SidebarStateBucket {
|
||||
if (status === "error") return "failed";
|
||||
if (isAgentRunning({ status, backgroundWork })) return "running";
|
||||
return "done";
|
||||
// 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 });
|
||||
}
|
||||
|
||||
export interface SubagentRowPresentationData {
|
||||
@@ -88,8 +89,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 three states — see
|
||||
* `buildSubagentRowPresentationData`, which reports no attention of its own — so the pill is two
|
||||
* 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
|
||||
* segments at worst, and falls back to naming what it opens once nothing is happening.
|
||||
*/
|
||||
export function buildSubagentPillPresentation(
|
||||
@@ -114,6 +115,8 @@ 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":
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { createContext, useContext, useMemo, useSyncExternalStore, type ReactNode } from "react";
|
||||
import { createContext, useContext, useEffect, useMemo, useState, type ReactNode } from "react";
|
||||
import { View, type ViewProps } from "react-native";
|
||||
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 {
|
||||
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 {
|
||||
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";
|
||||
@@ -143,23 +148,101 @@ export function resolveWindowChromeSafeArea(input: {
|
||||
}
|
||||
|
||||
export function WindowChromeProvider({ children }: { children: ReactNode }) {
|
||||
const chrome = useSyncExternalStore(
|
||||
desktopWindowChromeHost.subscribe,
|
||||
desktopWindowChromeHost.getSnapshot,
|
||||
desktopWindowChromeHost.getSnapshot,
|
||||
);
|
||||
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 topBand = useTopBand();
|
||||
const obstruction = useMemo(
|
||||
() =>
|
||||
resolveWindowChromeObstruction({
|
||||
mode: chrome.mode,
|
||||
isFullscreen: chrome.isFullscreen,
|
||||
mode: isElectronReady ? getDesktopWindowChromeMode() : null,
|
||||
isFullscreen: windowState.isFullscreen,
|
||||
topBand,
|
||||
}),
|
||||
[chrome.mode, chrome.isFullscreen, topBand],
|
||||
[isElectronReady, windowState.isFullscreen, topBand],
|
||||
);
|
||||
const desktopWindowChrome = useMemo(
|
||||
() => ({
|
||||
mode: isElectronReady ? getDesktopWindowChromeMode() : null,
|
||||
isFullscreen: windowState.isFullscreen,
|
||||
isMaximized: windowState.isMaximized,
|
||||
}),
|
||||
[isElectronReady, windowState],
|
||||
);
|
||||
return (
|
||||
<DesktopWindowChromeContext.Provider value={chrome}>
|
||||
<DesktopWindowChromeContext.Provider value={desktopWindowChrome}>
|
||||
<WindowChromeContext.Provider value={obstruction}>
|
||||
<WindowChromeCornersContext.Provider value="both">
|
||||
{children}
|
||||
|
||||
@@ -43,6 +43,20 @@ 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,6 +6,10 @@ 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";
|
||||
export type ProjectStatusBadgeDotBucket = "failed" | "attention" | "running" | "waiting";
|
||||
|
||||
export type ProjectStatusBadgeContent =
|
||||
| { kind: "alert" }
|
||||
@@ -22,7 +22,12 @@ export function getProjectStatusBadgeContent(
|
||||
if (statusBucket === "needs_input") {
|
||||
return { kind: "alert" };
|
||||
}
|
||||
if (statusBucket === "failed" || statusBucket === "attention" || statusBucket === "running") {
|
||||
if (
|
||||
statusBucket === "failed" ||
|
||||
statusBucket === "attention" ||
|
||||
statusBucket === "running" ||
|
||||
statusBucket === "waiting"
|
||||
) {
|
||||
return { kind: "dot", bucket: statusBucket };
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -78,6 +78,12 @@ 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,7 +4,13 @@ import {
|
||||
type AgentStateBucketInput,
|
||||
} from "@getpaseo/protocol/agent-state-bucket";
|
||||
|
||||
export type SidebarStateBucket = "needs_input" | "failed" | "running" | "attention" | "done";
|
||||
export type SidebarStateBucket =
|
||||
| "needs_input"
|
||||
| "failed"
|
||||
| "running"
|
||||
| "waiting"
|
||||
| "attention"
|
||||
| "done";
|
||||
export type SidebarAttentionReason = AgentAttentionReason;
|
||||
|
||||
export function deriveSidebarStateBucket(input: AgentStateBucketInput): SidebarStateBucket {
|
||||
@@ -18,12 +24,13 @@ 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" outranks "attention" here. needs_input and failed still win over both;
|
||||
// done stays last.
|
||||
// so "running" and "waiting" outrank "attention" here. needs_input and failed still win over
|
||||
// them; done stays last.
|
||||
const STATUS_BUCKET_PRIORITY: readonly SidebarStateBucket[] = [
|
||||
"needs_input",
|
||||
"failed",
|
||||
"running",
|
||||
"waiting",
|
||||
"attention",
|
||||
"done",
|
||||
];
|
||||
@@ -31,13 +38,15 @@ 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.
|
||||
* 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.
|
||||
*/
|
||||
export const STATUS_BUCKET_ORDER: readonly SidebarStateBucket[] = [
|
||||
"needs_input",
|
||||
"failed",
|
||||
"attention",
|
||||
"running",
|
||||
"waiting",
|
||||
"done",
|
||||
] as const;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export function getStatusDotColor(input: {
|
||||
if (bucket === "failed") {
|
||||
return theme.colors.statusDotDanger;
|
||||
}
|
||||
if (bucket === "running") {
|
||||
if (bucket === "running" || bucket === "waiting") {
|
||||
return theme.colors.statusDotRunning;
|
||||
}
|
||||
if (bucket === "attention") {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
export type StatusLoaderBucket = "needs_input" | "failed" | "running" | "attention" | "done";
|
||||
export type StatusLoaderBucket =
|
||||
| "needs_input"
|
||||
| "failed"
|
||||
| "running"
|
||||
| "waiting"
|
||||
| "attention"
|
||||
| "done";
|
||||
|
||||
export function shouldRenderSyncedStatusLoader(input: {
|
||||
bucket: StatusLoaderBucket | null | undefined;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { WindowInsetsContext } from "./context";
|
||||
|
||||
export { useWindowLayout } from "./context";
|
||||
export { WindowLayoutActions, WindowLayoutActionsHost } from "./actions";
|
||||
export { WindowLayoutSurface, WindowLayoutDivisionGap } from "./surface";
|
||||
export { useTopBand } from "./context";
|
||||
export { WindowSafeArea, useWindowSafeAreaInsets } from "./window-safe-area";
|
||||
export {
|
||||
resolveDesktopDivisionLayout,
|
||||
resolveWorkspaceActionPlacement,
|
||||
resolveWorkspaceBarActions,
|
||||
} from "./model";
|
||||
export type { DesktopDivisionLayout, TopBand, WindowLayout, WindowLayoutRect } from "./model";
|
||||
|
||||
export function WindowLayoutProvider({ children }: { children: ReactNode }) {
|
||||
const systemInsets = useSafeAreaInsets();
|
||||
const insets = useMemo(
|
||||
() => (systemInsets.top === 0 ? systemInsets : { ...systemInsets, top: 0 }),
|
||||
[systemInsets],
|
||||
);
|
||||
return (
|
||||
<WindowInsetsContext.Provider value={insets}>
|
||||
<SafeAreaInsetsContext.Provider value={insets}>{children}</SafeAreaInsetsContext.Provider>
|
||||
</WindowInsetsContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { WorkspaceDescriptorPayload } from "@getpaseo/protocol/messages";
|
||||
import { render } from "../../output/render.js";
|
||||
import { toWorkspaceRow, workspaceSchema } from "./shared.js";
|
||||
|
||||
function descriptor(status: WorkspaceDescriptorPayload["status"]): WorkspaceDescriptorPayload {
|
||||
return {
|
||||
id: "ws-1",
|
||||
projectId: "project-1",
|
||||
projectDisplayName: "paseo",
|
||||
projectRootPath: "/repo",
|
||||
workspaceDirectory: "/repo",
|
||||
projectKind: "git",
|
||||
workspaceKind: "local_checkout",
|
||||
name: "main",
|
||||
status,
|
||||
statusEnteredAt: null,
|
||||
activityAt: null,
|
||||
} as WorkspaceDescriptorPayload;
|
||||
}
|
||||
|
||||
describe("workspace ls", () => {
|
||||
it("prints the status of each workspace, including waiting", () => {
|
||||
const output = render(
|
||||
{ type: "list", data: [toWorkspaceRow(descriptor("waiting"))], schema: workspaceSchema },
|
||||
{ format: "table", noColor: true },
|
||||
);
|
||||
expect(output).toMatch(/STATUS/);
|
||||
expect(output).toMatch(/waiting/);
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@ export interface WorkspaceRow {
|
||||
project: string;
|
||||
name: string;
|
||||
isolation: "local" | "worktree";
|
||||
status: WorkspaceDescriptorPayload["status"];
|
||||
cwd: string;
|
||||
background: boolean;
|
||||
}
|
||||
@@ -17,6 +18,7 @@ export const workspaceSchema: OutputSchema<WorkspaceRow> = {
|
||||
{ header: "PROJECT", field: "project", width: 20 },
|
||||
{ header: "NAME", field: "name", width: 22 },
|
||||
{ header: "ISOLATION", field: "isolation", width: 10 },
|
||||
{ header: "STATUS", field: "status", width: 10 },
|
||||
{ header: "CWD", field: "cwd", width: 42 },
|
||||
],
|
||||
};
|
||||
@@ -36,6 +38,7 @@ export function toWorkspaceRow(workspace: WorkspaceDescriptorPayload): Workspace
|
||||
project: workspace.projectDisplayName,
|
||||
name: workspace.name,
|
||||
isolation: workspace.workspaceKind === "worktree" ? "worktree" : "local",
|
||||
status: workspace.status,
|
||||
cwd: workspace.workspaceDirectory,
|
||||
background: workspace.background === true,
|
||||
};
|
||||
|
||||
@@ -157,6 +157,7 @@ export const DEFAULT_CLIENT_CAPABILITIES = {
|
||||
[CLIENT_CAPS.pluginBinaryPayloads]: true,
|
||||
[CLIENT_CAPS.backgroundAgents]: true,
|
||||
[CLIENT_CAPS.explicitEventSubscriptions]: true,
|
||||
[CLIENT_CAPS.workspaceWaitingStatus]: true,
|
||||
} satisfies Record<
|
||||
Exclude<ClientCapability, typeof CLIENT_CAPS.browserHost | typeof CLIENT_CAPS.frameCodecs>,
|
||||
true
|
||||
|
||||
@@ -1339,6 +1339,7 @@ test("advertises client capabilities in hello", async () => {
|
||||
plugin_binary_payloads: true,
|
||||
workspace_setup_blocked: true,
|
||||
workspace_setup_observation: true,
|
||||
workspace_waiting_status: true,
|
||||
hello_rejection: true,
|
||||
evolvable_hello_rejection: true,
|
||||
background_agents: true,
|
||||
|
||||
@@ -20,7 +20,13 @@ export interface PluginTheme {
|
||||
};
|
||||
}
|
||||
|
||||
export type WorkspaceIndicator = "needs_input" | "failed" | "running" | "attention" | "done";
|
||||
export type WorkspaceIndicator =
|
||||
| "needs_input"
|
||||
| "failed"
|
||||
| "running"
|
||||
| "waiting"
|
||||
| "attention"
|
||||
| "done";
|
||||
|
||||
export interface PluginWorkspaceSnapshot {
|
||||
readonly ref: WorkspaceRef;
|
||||
@@ -50,8 +56,12 @@ export interface PluginWorkspaceSnapshot {
|
||||
readonly kind: "directory" | "local_checkout" | "checkout" | "worktree";
|
||||
readonly name: string;
|
||||
readonly title: string | null;
|
||||
/** Raw daemon status; prefer indicator for presentation. */
|
||||
readonly status: "needs_input" | "failed" | "running" | "attention" | "done";
|
||||
/**
|
||||
* Raw daemon status; prefer indicator for presentation. `waiting` means no turn is running and
|
||||
* the workspace is waiting on background work an agent started. Hosts that predate it report
|
||||
* that state as `running`.
|
||||
*/
|
||||
readonly status: WorkspaceIndicator;
|
||||
readonly statusEnteredAt: string | null;
|
||||
readonly archivingAt: string | null;
|
||||
readonly diffStat: { readonly additions: number; readonly deletions: number } | null;
|
||||
|
||||
@@ -3,10 +3,12 @@ import {
|
||||
deriveAgentStateBucket,
|
||||
getAgentStatusPriority,
|
||||
getWorkspaceStateBucketPriority,
|
||||
isAgentBusy,
|
||||
isAgentTurnRunning,
|
||||
} from "./agent-state-bucket.js";
|
||||
|
||||
describe("deriveAgentStateBucket", () => {
|
||||
it("shows idle agents with background work as running while preserving attention precedence", () => {
|
||||
it("shows idle agents with background work as waiting while preserving attention precedence", () => {
|
||||
const backgroundWork = { count: 1 };
|
||||
expect(
|
||||
deriveAgentStateBucket({
|
||||
@@ -15,11 +17,11 @@ describe("deriveAgentStateBucket", () => {
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
}),
|
||||
).toBe("running");
|
||||
).toBe("waiting");
|
||||
expect(
|
||||
deriveAgentStateBucket({ status: "idle", backgroundWork, attentionReason: "permission" }),
|
||||
).toBe("needs_input");
|
||||
expect(deriveAgentStateBucket({ status: "error", backgroundWork })).toBe("running");
|
||||
expect(deriveAgentStateBucket({ status: "error", backgroundWork })).toBe("waiting");
|
||||
expect(
|
||||
deriveAgentStateBucket({
|
||||
status: "error",
|
||||
@@ -38,7 +40,13 @@ describe("deriveAgentStateBucket", () => {
|
||||
expect(getAgentStatusPriority(passive)).toBe(getAgentStatusPriority({ status: "idle" }));
|
||||
expect(
|
||||
deriveAgentStateBucket({ ...passive, backgroundWork: { count: 2, runningCount: 1 } }),
|
||||
).toBe("running");
|
||||
).toBe("waiting");
|
||||
});
|
||||
|
||||
it("keeps a running turn as running while background work is alive", () => {
|
||||
expect(deriveAgentStateBucket({ status: "running", backgroundWork: { count: 1 } })).toBe(
|
||||
"running",
|
||||
);
|
||||
});
|
||||
|
||||
it("prioritizes pending permissions as needs_input", () => {
|
||||
@@ -122,11 +130,25 @@ describe("deriveAgentStateBucket", () => {
|
||||
describe("getWorkspaceStateBucketPriority", () => {
|
||||
it("orders active buckets before done", () => {
|
||||
expect(
|
||||
["done", "attention", "running", "failed", "needs_input"].sort(
|
||||
["done", "attention", "waiting", "running", "failed", "needs_input"].sort(
|
||||
(left, right) =>
|
||||
getWorkspaceStateBucketPriority(left) - getWorkspaceStateBucketPriority(right),
|
||||
),
|
||||
).toEqual(["needs_input", "failed", "running", "attention", "done"]);
|
||||
).toEqual(["needs_input", "failed", "running", "waiting", "attention", "done"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("agent busy predicates", () => {
|
||||
it("separates a running turn from counted background work", () => {
|
||||
const idleWithWork = { status: "idle", backgroundWork: { count: 1 } } as const;
|
||||
expect(isAgentTurnRunning(idleWithWork)).toBe(false);
|
||||
expect(isAgentBusy(idleWithWork)).toBe(true);
|
||||
expect(isAgentTurnRunning({ status: "running" })).toBe(true);
|
||||
expect(isAgentBusy({ status: "running" })).toBe(true);
|
||||
expect(isAgentBusy({ status: "idle", backgroundWork: { count: 1, runningCount: 0 } })).toBe(
|
||||
false,
|
||||
);
|
||||
expect(isAgentBusy({ status: "idle" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,20 +12,33 @@ export interface AgentStateBucketInput {
|
||||
backgroundWork?: AgentBackgroundWorkSummary | null;
|
||||
}
|
||||
|
||||
export function isAgentRunning(input: {
|
||||
interface AgentActivityInput {
|
||||
status: AgentLifecycleStatus | null | undefined;
|
||||
backgroundWork?: AgentBackgroundWorkSummary | null;
|
||||
}): boolean {
|
||||
const { status, backgroundWork } = input;
|
||||
return status === "running" || (backgroundWork?.runningCount ?? backgroundWork?.count ?? 0) > 0;
|
||||
}
|
||||
|
||||
/** A turn is running. Background work alone does not make this true. */
|
||||
export function isAgentTurnRunning(input: Pick<AgentActivityInput, "status">): boolean {
|
||||
return input.status === "running";
|
||||
}
|
||||
|
||||
function hasCountedBackgroundWork(input: Pick<AgentActivityInput, "backgroundWork">): boolean {
|
||||
const { backgroundWork } = input;
|
||||
return (backgroundWork?.runningCount ?? backgroundWork?.count ?? 0) > 0;
|
||||
}
|
||||
|
||||
/** Running a turn, or waiting on counted background work after the turn ended. */
|
||||
export function isAgentBusy(input: AgentActivityInput): boolean {
|
||||
return isAgentTurnRunning(input) || hasCountedBackgroundWork(input);
|
||||
}
|
||||
|
||||
const WORKSPACE_STATE_BUCKET_PRIORITY = {
|
||||
needs_input: 0,
|
||||
failed: 1,
|
||||
running: 2,
|
||||
attention: 3,
|
||||
done: 4,
|
||||
waiting: 3,
|
||||
attention: 4,
|
||||
done: 5,
|
||||
} as const satisfies Record<WorkspaceStateBucket, number>;
|
||||
|
||||
// An error is a notification like a finish: once the user has seen it, the agent stops showing as
|
||||
@@ -41,9 +54,12 @@ export function deriveAgentStateBucket(input: AgentStateBucketInput): WorkspaceS
|
||||
if (hasUnreadError(input)) {
|
||||
return "failed";
|
||||
}
|
||||
if (isAgentRunning(input)) {
|
||||
if (isAgentTurnRunning(input)) {
|
||||
return "running";
|
||||
}
|
||||
if (hasCountedBackgroundWork(input)) {
|
||||
return "waiting";
|
||||
}
|
||||
if (input.requiresAttention) {
|
||||
return "attention";
|
||||
}
|
||||
@@ -61,7 +77,8 @@ export function getAgentStatusPriority(input: AgentStateBucketInput): number {
|
||||
if (hasUnreadError(input)) {
|
||||
return 1;
|
||||
}
|
||||
if (isAgentRunning(input)) {
|
||||
// Lists keep every busy agent together; running versus waiting is a display distinction.
|
||||
if (isAgentBusy(input)) {
|
||||
return 2;
|
||||
}
|
||||
if (input.status === "initializing") {
|
||||
|
||||
@@ -73,6 +73,10 @@ export const CLIENT_CAPS = {
|
||||
// An agent sender's steer means wait-for-turn-end from clients without it, because older
|
||||
// CLIs and connected hosts send an explicit steer for every default agent send.
|
||||
agentActiveTurnBehaviors: "agent_active_turn_behaviors",
|
||||
// COMPAT(workspaceWaitingStatus): added in v0.19.3, remove after 2027-06-06 once client floor >= v0.19.3.
|
||||
// Older clients validate workspace `status` against a closed enum and drop a workspace carrying
|
||||
// "waiting"; the daemon sends them "running", which is what they showed for this state before.
|
||||
workspaceWaitingStatus: "workspace_waiting_status",
|
||||
} as const;
|
||||
|
||||
export type ClientCapability = (typeof CLIENT_CAPS)[keyof typeof CLIENT_CAPS];
|
||||
|
||||
@@ -1550,6 +1550,7 @@ const WorkspaceStateBucketSchema = z.enum([
|
||||
"needs_input",
|
||||
"failed",
|
||||
"running",
|
||||
"waiting",
|
||||
"attention",
|
||||
"done",
|
||||
]);
|
||||
|
||||
@@ -5,7 +5,6 @@ import { afterEach, describe, expect, test } from "vitest";
|
||||
|
||||
import {
|
||||
buildCommandResolutionDiagnosticRows,
|
||||
readCommandVersionOutput,
|
||||
toDiagnosticErrorMessage,
|
||||
} from "./diagnostic-utils.js";
|
||||
|
||||
@@ -128,17 +127,6 @@ describe("buildCommandResolutionDiagnosticRows", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("readCommandVersionOutput", () => {
|
||||
test("returns the version as plain text when the CLI styles it for a terminal", async () => {
|
||||
const output = await readCommandVersionOutput({
|
||||
command: process.execPath,
|
||||
args: ["-e", String.raw`process.stdout.write("\x1b[1m\x1b[32mtool 1.2.3\x1b[0m\n")`],
|
||||
});
|
||||
|
||||
expect(output).toBe("tool 1.2.3");
|
||||
});
|
||||
});
|
||||
|
||||
describe("toDiagnosticErrorMessage", () => {
|
||||
test("returns message for plain Error", () => {
|
||||
expect(toDiagnosticErrorMessage(new Error("boom"))).toBe("boom");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { constants } from "node:fs";
|
||||
import { access, stat } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import stripAnsi from "strip-ansi";
|
||||
|
||||
import {
|
||||
createProviderEnvSpec,
|
||||
@@ -398,8 +397,7 @@ export async function readCommandVersionOutput(
|
||||
timeout: 5_000,
|
||||
signal: invocation.signal,
|
||||
});
|
||||
// Some CLIs style `--version` for a terminal even when piped; callers show the text as is.
|
||||
return stripAnsi(stdout).trim() || stripAnsi(stderr).trim();
|
||||
return stdout.trim() || stderr.trim();
|
||||
}
|
||||
|
||||
async function resolveCommandVersion(invocation: BinaryDiagnosticVersionCommand): Promise<string> {
|
||||
|
||||
@@ -122,6 +122,28 @@ describe("MockLoadTestAgentClient", () => {
|
||||
expect(events.at(-1)).toMatchObject({ type: "turn_completed", provider: "mock" });
|
||||
});
|
||||
|
||||
test("a background shell command outlives the turn that started it", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = new MockLoadTestAgentClient();
|
||||
const session = await client.createSession({ provider: "mock", cwd: process.cwd() });
|
||||
const events: AgentStreamEvent[] = [];
|
||||
session.subscribe((event) => events.push(event));
|
||||
|
||||
const run = session.run("Please start a background shell command for 5000ms.");
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
await run;
|
||||
|
||||
const types = events.map((event) =>
|
||||
event.type === "background_work" ? `background_work:${event.items?.length}` : event.type,
|
||||
);
|
||||
expect(types.indexOf("background_work:1")).toBeGreaterThan(-1);
|
||||
expect(types.indexOf("background_work:1")).toBeLessThan(types.indexOf("turn_completed"));
|
||||
expect(types.at(-1)).toBe("turn_completed");
|
||||
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
expect(events.at(-1)).toMatchObject({ type: "background_work", items: [] });
|
||||
});
|
||||
|
||||
test("can withhold the provider user-message echo until an immediate interrupt", async () => {
|
||||
vi.useFakeTimers();
|
||||
const client = new MockLoadTestAgentClient();
|
||||
|
||||
@@ -288,6 +288,17 @@ function parseHeldToolCallMs(prompt: AgentPromptInput): number | null {
|
||||
return Number.isSafeInteger(holdMs) ? Math.min(holdMs, MAX_HELD_TOOL_CALL_MS) : null;
|
||||
}
|
||||
|
||||
// A turn that starts a shell command in the background and ends. The command stays in the
|
||||
// agent's background work for the given time, so the agent is waiting with no turn running.
|
||||
function parseBackgroundShellMs(prompt: AgentPromptInput): number | null {
|
||||
const match = /start a background shell command for (\d+)ms/i.exec(promptToText(prompt));
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
const durationMs = Number(match[1]);
|
||||
return Number.isSafeInteger(durationMs) ? Math.min(durationMs, MAX_HELD_TOOL_CALL_MS) : null;
|
||||
}
|
||||
|
||||
function parseSettledAssistantImageMarkdown(prompt: AgentPromptInput): string | null {
|
||||
const match = /^emit settled assistant image markdown:\s*(!\[[^\]\r\n]*\]\(.+\))\s*$/i.exec(
|
||||
promptToText(prompt),
|
||||
@@ -960,11 +971,14 @@ export class MockLoadTestAgentSession implements AgentSession {
|
||||
const settledAssistantImageMarkdown = parseSettledAssistantImageMarkdown(prompt);
|
||||
const steeringReplayShape = parseSteeringReplayShape(prompt);
|
||||
const heldToolCallMs = parseHeldToolCallMs(prompt);
|
||||
const backgroundShellMs = parseBackgroundShellMs(prompt);
|
||||
const scheduleTurn = () => {
|
||||
if (shouldEmitTurnFailure(prompt)) {
|
||||
this.scheduleFailedTurn(turn);
|
||||
} else if (heldToolCallMs !== null) {
|
||||
this.scheduleHeldToolCallTurn(turn, heldToolCallMs);
|
||||
} else if (backgroundShellMs !== null) {
|
||||
this.scheduleBackgroundShellTurn(turn, backgroundShellMs);
|
||||
} else if (steeringReplayShape) {
|
||||
this.scheduleSteeringReplayTurn(turn, steeringReplayShape);
|
||||
} else if (this.streamingAssistantResponse !== null) {
|
||||
@@ -1369,6 +1383,32 @@ export class MockLoadTestAgentSession implements AgentSession {
|
||||
turn.timer.unref?.();
|
||||
}
|
||||
|
||||
private scheduleBackgroundShellTurn(turn: ActiveTurn, durationMs: number): void {
|
||||
turn.timer = setTimeout(() => {
|
||||
if (this.activeTurn !== turn) return;
|
||||
this.clearTurnTimer(turn);
|
||||
this.emitTurnStarted(turn);
|
||||
this.emit({
|
||||
type: "background_work",
|
||||
provider: this.provider,
|
||||
items: [
|
||||
{
|
||||
id: `${turn.turnId}:background-shell`,
|
||||
kind: "shell",
|
||||
description: `sleep ${Math.ceil(durationMs / 1000)}`,
|
||||
command: `sleep ${Math.ceil(durationMs / 1000)}`,
|
||||
},
|
||||
],
|
||||
});
|
||||
this.emitSettledAssistantTurn(turn, "Started a background shell command.");
|
||||
const finish = setTimeout(() => {
|
||||
this.emit({ type: "background_work", provider: this.provider, items: [] });
|
||||
}, durationMs);
|
||||
finish.unref?.();
|
||||
}, 0);
|
||||
turn.timer.unref?.();
|
||||
}
|
||||
|
||||
private scheduleSplitClosingFenceTurn(turn: ActiveTurn): void {
|
||||
const chunks = [...SPLIT_CLOSING_FENCE_CHUNKS];
|
||||
const finalText = chunks.map((chunk) => chunk.text).join("");
|
||||
|
||||
@@ -127,6 +127,7 @@ import { toWireDaemonConfig, type DaemonConfigStore } from "./daemon-config-stor
|
||||
import { releaseWorkspaceServicePortPlan } from "./workspace-service-port-registry.js";
|
||||
import { getErrorMessage, getErrorMessageOr } from "@getpaseo/protocol/error-utils";
|
||||
import { getAgentStatusPriority } from "@getpaseo/protocol/agent-state-bucket";
|
||||
import { workspaceStatusForClient } from "./workspace-waiting-status-compat.js";
|
||||
import { getParentAgentIdFromLabels } from "@getpaseo/protocol/agent-labels";
|
||||
import { applyRecordPatch } from "./record-patch.js";
|
||||
import type { WorkspaceGitRuntimeSnapshot, WorkspaceGitService } from "./workspace-git-service.js";
|
||||
@@ -877,7 +878,7 @@ export class Session {
|
||||
return this.onBinaryMessageToSource(source, frame);
|
||||
} else this.emitBinary(frame);
|
||||
},
|
||||
(source, message) => this.workspaceSetupMessageForClient(message, source),
|
||||
(source, message) => this.messageForClient(message, source),
|
||||
(request, message) =>
|
||||
this.sessionLogger.warn(
|
||||
{
|
||||
@@ -10558,7 +10559,7 @@ export class Session {
|
||||
!this.delivery.isModern(source) &&
|
||||
this.wantsEvent(event, source)
|
||||
)
|
||||
this.onMessageToSource(source, this.workspaceSetupMessageForClient(message, source));
|
||||
this.onMessageToSource(source, this.messageForClient(message, source));
|
||||
}
|
||||
} else if (delivered.size === 0 && this.wantsEvent(event)) this.onMessage(message);
|
||||
return true;
|
||||
@@ -10588,13 +10589,26 @@ export class Session {
|
||||
if (msg.type === "workspace_setup_status_response") {
|
||||
if (this.clientSources.size > 0 && this.onMessageToSource) {
|
||||
for (const [source] of this.clientSources) {
|
||||
this.onMessageToSource(source, this.workspaceSetupMessageForClient(msg, source));
|
||||
this.onMessageToSource(source, this.messageForClient(msg, source));
|
||||
}
|
||||
return;
|
||||
}
|
||||
msg = this.workspaceSetupMessageForClient(msg);
|
||||
}
|
||||
this.onMessage(msg);
|
||||
this.onMessage(this.messageForClient(msg));
|
||||
}
|
||||
|
||||
/** Adapts one outbound message to what the receiving client's capabilities can read. */
|
||||
private messageForClient(
|
||||
message: SessionOutboundMessage,
|
||||
source?: object,
|
||||
): SessionOutboundMessage {
|
||||
const supportsWaiting = source
|
||||
? this.supportsForSource(CLIENT_CAPS.workspaceWaitingStatus, source)
|
||||
: this.supports(CLIENT_CAPS.workspaceWaitingStatus);
|
||||
return workspaceStatusForClient(
|
||||
this.workspaceSetupMessageForClient(message, source),
|
||||
supportsWaiting,
|
||||
);
|
||||
}
|
||||
|
||||
// COMPAT(workspaceSetupBlocked): added in v0.8.0, remove after 2027-03-07 once client floor >= v0.8.0.
|
||||
|
||||
@@ -252,6 +252,7 @@ function makeAgent(input: {
|
||||
attentionReason?: AgentSnapshotPayload["attentionReason"];
|
||||
attentionTimestamp?: string | null;
|
||||
labels?: Record<string, string>;
|
||||
backgroundWork?: AgentSnapshotPayload["backgroundWork"];
|
||||
}): AgentSnapshotPayload {
|
||||
const pendingPermissionCount = input.pendingPermissions ?? 0;
|
||||
return {
|
||||
@@ -292,6 +293,7 @@ function makeAgent(input: {
|
||||
requiresAttention: input.requiresAttention ?? false,
|
||||
attentionReason: input.attentionReason ?? null,
|
||||
attentionTimestamp: input.attentionTimestamp ?? null,
|
||||
...(input.backgroundWork ? { backgroundWork: input.backgroundWork } : {}),
|
||||
archivedAt: null,
|
||||
};
|
||||
}
|
||||
@@ -3761,6 +3763,54 @@ test("branch/detached policies and dominant status bucket are deterministic", as
|
||||
expect(result.entries[0]?.status).toBe("needs_input");
|
||||
});
|
||||
|
||||
test("an idle agent with background work makes its workspace waiting only for clients that know the state", async () => {
|
||||
const deliveries = new Map<object, SessionOutboundMessage[]>();
|
||||
const session = createSessionForWorkspaceTests({
|
||||
onMessageToSource: (source, message) => {
|
||||
deliveries.set(source, [...(deliveries.get(source) ?? []), message]);
|
||||
},
|
||||
});
|
||||
session.workspaceRegistry.listAll = session.workspaceRegistry.listActive = async () => [
|
||||
createPersistedWorkspaceRecord({
|
||||
workspaceId: "ws-waiting",
|
||||
projectId: "proj-waiting",
|
||||
cwd: REPO_CWD,
|
||||
kind: "local_checkout",
|
||||
displayName: "repo",
|
||||
createdAt: "2026-03-01T12:00:00.000Z",
|
||||
updatedAt: "2026-03-01T12:00:00.000Z",
|
||||
}),
|
||||
];
|
||||
session.listAgentPayloads = async () => [
|
||||
makeAgent({
|
||||
id: "a1",
|
||||
cwd: REPO_CWD,
|
||||
workspaceId: "ws-waiting",
|
||||
status: "idle",
|
||||
updatedAt: "2026-03-01T12:00:00.000Z",
|
||||
backgroundWork: { count: 1 },
|
||||
}),
|
||||
];
|
||||
|
||||
const olderApp = {};
|
||||
const currentApp = {};
|
||||
session.updateClientCapabilities({}, olderApp);
|
||||
session.updateClientCapabilities({ [CLIENT_CAPS.workspaceWaitingStatus]: true }, currentApp);
|
||||
for (const source of [olderApp, currentApp]) {
|
||||
await session.handleMessage(
|
||||
{ type: "fetch_workspaces_request", requestId: "fetch-waiting" },
|
||||
source,
|
||||
);
|
||||
}
|
||||
|
||||
const statusSeenBy = (source: object) =>
|
||||
filterByType(deliveries.get(source) ?? [], "fetch_workspaces_response").map((message) =>
|
||||
message.payload.entries.map((entry) => entry.status),
|
||||
);
|
||||
expect(statusSeenBy(currentApp)).toEqual([["waiting"]]);
|
||||
expect(statusSeenBy(olderApp)).toEqual([["running"]]);
|
||||
});
|
||||
|
||||
test("subdirectory agents contribute to their owning workspace descriptor", async () => {
|
||||
const session = createSessionForWorkspaceTests();
|
||||
session.workspaceRegistry.listAll = session.workspaceRegistry.listActive = async () => [
|
||||
|
||||
@@ -311,24 +311,6 @@ describe("LocalSpeechWorkerClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
["linux", "daemon.log"],
|
||||
["win32", "daemon.log"],
|
||||
["darwin", "daemon.log and macOS DiagnosticReports"],
|
||||
])("suggests crash logs available on %s when stderr is empty", async (platform, logs) => {
|
||||
const original = process.platform;
|
||||
const { client, workers } = createClient();
|
||||
try {
|
||||
const pending = client.synthesizeSpeech("hello");
|
||||
Object.defineProperty(process, "platform", { value: platform });
|
||||
workers[0].emit("close", null, "SIGKILL");
|
||||
await expect(pending).rejects.toThrow("Check " + logs + " for Paseo Voice crash details.");
|
||||
} finally {
|
||||
Object.defineProperty(process, "platform", { value: original });
|
||||
client.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not log intentional shutdowns as worker crashes", async () => {
|
||||
const { logger, records } = createCapturingLogger();
|
||||
const workers: FakeLocalSpeechWorker[] = [];
|
||||
|
||||
@@ -168,11 +168,9 @@ function buildWorkerExitMessage(params: {
|
||||
.map(formatPendingRequestForMessage)
|
||||
.join(", ")}`
|
||||
: "";
|
||||
const crashLogs =
|
||||
process.platform === "darwin" ? "daemon.log and macOS DiagnosticReports" : "daemon.log";
|
||||
const stderr = params.stderrTail
|
||||
? ` Last stderr: ${truncateStart(params.stderrTail, USER_ERROR_STDERR_MAX_CHARS)}`
|
||||
: ` Check ${crashLogs} for Paseo Voice crash details.`;
|
||||
: " Check daemon.log and macOS DiagnosticReports for Paseo Voice crash details.";
|
||||
return `Local speech worker exited (${formatExitStatus(params.code, params.signal)})${pending}.${stderr}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ function createAgent(
|
||||
}
|
||||
|
||||
describe("WorkspaceDirectory", () => {
|
||||
test("treats background work as running without changing foreground status", async () => {
|
||||
test("treats background work as waiting without changing foreground status", async () => {
|
||||
const workspace = new WorkspaceStatus();
|
||||
workspace.hasRootAgent({
|
||||
id: "root-agent",
|
||||
@@ -350,8 +350,28 @@ describe("WorkspaceDirectory", () => {
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
});
|
||||
await expect(workspace.workspaceStatus()).resolves.toBe("waiting");
|
||||
});
|
||||
|
||||
test("a running turn outranks background work in the same workspace", async () => {
|
||||
const workspace = new WorkspaceStatus();
|
||||
workspace.hasRootAgent({ id: "waiting-root", status: "idle", backgroundWork: { count: 1 } });
|
||||
workspace.hasRootAgent({ id: "running-root", status: "running" });
|
||||
await expect(workspace.workspaceStatus()).resolves.toBe("running");
|
||||
});
|
||||
|
||||
test("same-workspace subagent with background work contributes waiting to its parent workspace", async () => {
|
||||
const workspace = new WorkspaceStatus();
|
||||
|
||||
workspace.hasRootAgent({ id: "parent-agent", status: "idle" });
|
||||
workspace.hasDelegatedAgent({
|
||||
id: "child-agent",
|
||||
status: "idle",
|
||||
backgroundWork: { count: 1 },
|
||||
});
|
||||
|
||||
await expect(workspace.workspaceStatus()).resolves.toBe("waiting");
|
||||
});
|
||||
test("keeps the workspace idle when root and delegated agents only have passive background work", async () => {
|
||||
const workspace = new WorkspaceStatus();
|
||||
const backgroundWork = { count: 1, runningCount: 0 };
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user