Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aadd5f0327 | ||
|
|
df78cda8bf | ||
|
|
605c2bb734 | ||
|
|
cb11a71d63 | ||
|
|
41124c7260 | ||
|
|
b0b275227b | ||
|
|
cb293fe790 | ||
|
|
1d694dcbd8 | ||
|
|
32407df9c5 | ||
|
|
162e774294 | ||
|
|
063ed7120a | ||
|
|
34b15a9ace | ||
|
|
fbecb7365e | ||
|
|
4029b858ea | ||
|
|
5b2577f6a9 | ||
|
|
bc142f84a2 | ||
|
|
e4829603ff | ||
|
|
1d77cec991 |
No files matched your search
@@ -66,7 +66,7 @@ Use these client origins:
|
||||
- Android Emulator: `http://10.0.2.2:<server-port>`
|
||||
- Physical device: bind the backend to `0.0.0.0` and use the host's reachable LAN origin
|
||||
|
||||
Always enter the complete `http://` origin; the mobile host field otherwise assumes HTTPS. When testing web and mobile together, run `vp run dev --home-dir <base-dir> --host 127.0.0.1` instead and do not launch a second backend over the same base directory.
|
||||
Enter the complete `http://` origin to make the test transport explicit. Bare IP addresses default to HTTP, while bare hostnames default to HTTPS. When testing web and mobile together, run `vp run dev --home-dir <base-dir> --host 127.0.0.1` instead and do not launch a second backend over the same base directory.
|
||||
|
||||
## Start or reuse Metro safely
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ body:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- apps/mobile
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
|
||||
@@ -30,6 +30,7 @@ body:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- apps/mobile
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
|
||||
@@ -6,6 +6,10 @@ on:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.event.pull_request.number || github.sha }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
@@ -14,6 +18,11 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -55,6 +64,11 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -77,18 +91,25 @@ jobs:
|
||||
|
||||
mobile_native_static_analysis:
|
||||
name: Mobile Native Static Analysis
|
||||
runs-on: blacksmith-12vcpu-macos-26
|
||||
runs-on: blacksmith-6vcpu-macos-26
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Install mobile native static analysis tools
|
||||
run: brew bundle install --file apps/mobile/Brewfile
|
||||
@@ -103,13 +124,20 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Exercise release-only workflow steps
|
||||
run: node scripts/release-smoke.ts
|
||||
@@ -38,13 +38,20 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=t3code-relay...
|
||||
|
||||
- name: Deploy production relay stage
|
||||
id: deploy
|
||||
|
||||
@@ -2,13 +2,18 @@ name: Mobile EAS Preview
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize, labeled, unlabeled]
|
||||
types: [opened, reopened, synchronize, labeled]
|
||||
|
||||
jobs:
|
||||
preview:
|
||||
name: EAS Preview
|
||||
if: contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment')
|
||||
if: |
|
||||
contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') &&
|
||||
(github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment')
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
concurrency:
|
||||
group: mobile-eas-preview-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
@@ -34,6 +39,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# No sparse-checkout here: it makes actions/checkout fetch with
|
||||
# --filter=blob:none, and eas-cli archives the project via
|
||||
# `git clone --depth 1 file://<workspace>`, which fails (exit 128)
|
||||
# when the partial clone can't serve the unfetched blobs.
|
||||
|
||||
- name: Setup Vite+
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
@@ -41,7 +50,9 @@ jobs:
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
|
||||
- name: Expose pnpm
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
|
||||
@@ -57,6 +57,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# No sparse-checkout here: it makes actions/checkout fetch with
|
||||
# --filter=blob:none, and eas-cli archives the project via
|
||||
# `git clone --depth 1 file://<workspace>`, which fails (exit 128)
|
||||
# when the partial clone can't serve the unfetched blobs.
|
||||
|
||||
- name: Setup Vite+
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
@@ -64,7 +68,9 @@ jobs:
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
|
||||
- name: Expose pnpm
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
|
||||
@@ -37,13 +37,21 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
@@ -77,13 +85,21 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
|
||||
@@ -38,6 +38,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- id: check
|
||||
name: Compare HEAD to last nightly tag
|
||||
@@ -84,6 +88,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -192,6 +200,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -269,14 +281,19 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=t3...
|
||||
|
||||
- name: Build node-pty linux-x64 prebuild
|
||||
shell: bash
|
||||
@@ -359,14 +376,21 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/desktop...
|
||||
- --filter=t3...
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
@@ -657,6 +681,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -732,6 +760,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -853,6 +885,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -967,6 +1003,10 @@ jobs:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app_token.outputs.token }}
|
||||
persist-credentials: true
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- id: app_bot
|
||||
name: Resolve GitHub App bot identity
|
||||
@@ -1037,6 +1077,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
## What Changed
|
||||
|
||||
- subscribe mounted workspace file previews to debounced filesystem change events from the connected T3 server
|
||||
- re-read text previews when files change and perform a fresh read after remounting
|
||||
- refresh open image previews with revisioned URLs and require revalidation for mutable workspace assets
|
||||
- keep immutable attachment caching unchanged
|
||||
|
||||
This supersedes #4379, preserves Alex's original commits, rebases them onto current `main`, and adds the missing image-preview behavior.
|
||||
|
||||
## Why
|
||||
|
||||
Agent edits happen directly on disk, bypassing the file-write RPC that could invalidate client state. Text previews therefore kept cached query data, while image previews reused a mutable signed URL served with a one-hour cache lifetime. Watching the file on the connected server fixes both local and T3 connection flows without polling.
|
||||
|
||||
## Testing
|
||||
|
||||
- `vp test run apps/server/src/workspace/WorkspaceFileSystem.test.ts apps/server/src/assets/AssetAccess.test.ts apps/server/src/auth/RpcAuthorization.test.ts packages/client-runtime/src/state/runtime.test.ts apps/web/src/components/files/projectFilesQueryState.test.ts apps/web/src/components/files/workspaceImagePreview.test.ts`
|
||||
- contracts, client-runtime, server, web, and mobile typechecks
|
||||
- targeted lint and formatting checks
|
||||
|
||||
## Checklist
|
||||
|
||||
- [x] This PR is small and focused
|
||||
- [x] I explained what changed and why
|
||||
- [x] Screenshots are not applicable because this fixes stale data without changing the UI
|
||||
- [x] Video is not applicable because no animation or interaction design changed
|
||||
@@ -54,7 +54,6 @@ const makeElectronAppLayer = (calls: ElectronAppCalls) =>
|
||||
calls.setAboutPanelOptions.push(options);
|
||||
}),
|
||||
setAppUserModelId: () => Effect.void,
|
||||
requestSingleInstanceLock: Effect.succeed(true),
|
||||
getAppMetrics: Effect.succeed([]),
|
||||
isDefaultProtocolClient: () => Effect.succeed(false),
|
||||
setAsDefaultProtocolClient: () => Effect.succeed(true),
|
||||
|
||||
@@ -45,6 +45,27 @@ const normalizeCommitHash = (value: string): Option.Option<string> => {
|
||||
: Option.none();
|
||||
};
|
||||
|
||||
export const resolveUserDataPath = Effect.gen(function* () {
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const legacyPath = environment.path.join(
|
||||
environment.appDataDirectory,
|
||||
environment.legacyUserDataDirName,
|
||||
);
|
||||
const legacyPathExists = yield* fileSystem.exists(legacyPath).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new DesktopUserDataPathResolutionError({
|
||||
legacyPath,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return legacyPathExists
|
||||
? legacyPath
|
||||
: environment.path.join(environment.appDataDirectory, environment.userDataDirName);
|
||||
}).pipe(Effect.withSpan("desktop.appIdentity.resolveUserDataPath"));
|
||||
|
||||
export const make = Effect.gen(function* () {
|
||||
const assets = yield* DesktopAssets.DesktopAssets;
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
@@ -90,24 +111,11 @@ export const make = Effect.gen(function* () {
|
||||
return commitHash;
|
||||
});
|
||||
|
||||
const resolveUserDataPath = Effect.gen(function* () {
|
||||
const legacyPath = environment.path.join(
|
||||
environment.appDataDirectory,
|
||||
environment.legacyUserDataDirName,
|
||||
);
|
||||
const legacyPathExists = yield* fileSystem.exists(legacyPath).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new DesktopUserDataPathResolutionError({
|
||||
legacyPath,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return legacyPathExists
|
||||
? legacyPath
|
||||
: environment.path.join(environment.appDataDirectory, environment.userDataDirName);
|
||||
}).pipe(Effect.withSpan("desktop.appIdentity.resolveUserDataPath"));
|
||||
const userDataPath = resolveUserDataPath.pipe(
|
||||
Effect.provide(
|
||||
yield* Effect.context<DesktopEnvironment.DesktopEnvironment | FileSystem.FileSystem>(),
|
||||
),
|
||||
);
|
||||
|
||||
const configure = Effect.gen(function* () {
|
||||
const commitHash = yield* resolveAboutCommitHash;
|
||||
@@ -136,7 +144,7 @@ export const make = Effect.gen(function* () {
|
||||
}).pipe(Effect.withSpan("desktop.appIdentity.configure"));
|
||||
|
||||
return DesktopAppIdentity.of({
|
||||
resolveUserDataPath,
|
||||
resolveUserDataPath: userDataPath,
|
||||
configure,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,17 +22,38 @@ vi.mock("@clerk/electron/storage", () => ({
|
||||
storage: storageMock,
|
||||
}));
|
||||
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as ElectronApp from "../electron/ElectronApp.ts";
|
||||
import * as ElectronWindow from "../electron/ElectronWindow.ts";
|
||||
import * as DesktopClerk from "./DesktopClerk.ts";
|
||||
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
|
||||
|
||||
const makeDesktopClerkLayer = (isDevelopment = true) => {
|
||||
const makeDesktopClerkLayer = (isDevelopment = true, events: string[] = []) => {
|
||||
const environment = DesktopEnvironment.DesktopEnvironment.of({
|
||||
stateDir: "/tmp/t3-state",
|
||||
isDevelopment,
|
||||
appDataDirectory: "/tmp/app-data",
|
||||
userDataDirName: isDevelopment ? "t3code-dev" : "t3code",
|
||||
legacyUserDataDirName: isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)",
|
||||
path: { join: (...parts: ReadonlyArray<string>) => parts.join("/") },
|
||||
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]);
|
||||
|
||||
const electronApp = {
|
||||
setPath: (name: string, value: string) =>
|
||||
Effect.sync(() => {
|
||||
events.push(`setPath:${name}:${value}`);
|
||||
}),
|
||||
} as unknown as ElectronApp.ElectronApp["Service"];
|
||||
|
||||
return DesktopClerk.layer.pipe(
|
||||
Layer.provide(Layer.succeed(DesktopEnvironment.DesktopEnvironment, environment)),
|
||||
Layer.provide(
|
||||
Layer.mergeAll(
|
||||
Layer.succeed(DesktopEnvironment.DesktopEnvironment, environment),
|
||||
Layer.succeed(ElectronApp.ElectronApp, electronApp),
|
||||
FileSystem.layerNoop({ exists: () => Effect.succeed(false) }),
|
||||
),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -55,11 +76,15 @@ describe("DesktopClerk", () => {
|
||||
|
||||
it.effect("acquires and releases the SDK bridge with the layer", () => {
|
||||
const cleanup = vi.fn();
|
||||
const events: string[] = [];
|
||||
storageMock.mockReturnValue(storageAdapter);
|
||||
createClerkBridgeMock.mockReturnValue({ cleanup });
|
||||
createClerkBridgeMock.mockImplementation(() => {
|
||||
events.push("createClerkBridge");
|
||||
return { cleanup, isPrimaryInstance: true };
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
yield* Effect.scoped(Layer.build(makeDesktopClerkLayer()));
|
||||
yield* Effect.scoped(Layer.build(makeDesktopClerkLayer(true, events)));
|
||||
|
||||
assert.deepEqual(createClerkBridgeMock.mock.calls, [
|
||||
[
|
||||
@@ -71,6 +96,10 @@ describe("DesktopClerk", () => {
|
||||
],
|
||||
]);
|
||||
assert.equal(cleanup.mock.calls.length, 1);
|
||||
// The bridge acquires Electron's single-instance lock at creation, and
|
||||
// the lock both lives in and creates the userData directory — so the
|
||||
// real path must be set before the bridge exists.
|
||||
assert.deepEqual(events, ["setPath:userData:/tmp/app-data/t3code-dev", "createClerkBridge"]);
|
||||
storageMock.mockClear();
|
||||
createClerkBridgeMock.mockClear();
|
||||
});
|
||||
@@ -124,11 +153,67 @@ describe("DesktopClerk", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("registers the second-instance handler in the primary instance", () => {
|
||||
storageMock.mockReturnValue(storageAdapter);
|
||||
createClerkBridgeMock.mockReturnValue({ cleanup: vi.fn(), isPrimaryInstance: true });
|
||||
const quit = vi.fn();
|
||||
const registeredEvents: string[] = [];
|
||||
const electronApp = {
|
||||
quit: Effect.sync(quit),
|
||||
on: (eventName: string) =>
|
||||
Effect.sync(() => {
|
||||
registeredEvents.push(eventName);
|
||||
}),
|
||||
} as unknown as ElectronApp.ElectronApp["Service"];
|
||||
const electronWindow = {} as ElectronWindow.ElectronWindow["Service"];
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const clerk = yield* DesktopClerk.DesktopClerk;
|
||||
const exit = yield* Effect.exit(Effect.scoped(clerk.configure));
|
||||
|
||||
assert.isTrue(Exit.isSuccess(exit));
|
||||
assert.equal(quit.mock.calls.length, 0);
|
||||
assert.deepEqual(registeredEvents, ["second-instance"]);
|
||||
}).pipe(
|
||||
Effect.provide(makeDesktopClerkLayer()),
|
||||
Effect.provideService(ElectronApp.ElectronApp, electronApp),
|
||||
Effect.provideService(ElectronWindow.ElectronWindow, electronWindow),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("quits and interrupts startup in a secondary instance", () => {
|
||||
storageMock.mockReturnValue(storageAdapter);
|
||||
createClerkBridgeMock.mockReturnValue({ cleanup: vi.fn(), isPrimaryInstance: false });
|
||||
const quit = vi.fn();
|
||||
const registeredEvents: string[] = [];
|
||||
const electronApp = {
|
||||
quit: Effect.sync(quit),
|
||||
on: (eventName: string) =>
|
||||
Effect.sync(() => {
|
||||
registeredEvents.push(eventName);
|
||||
}),
|
||||
} as unknown as ElectronApp.ElectronApp["Service"];
|
||||
const electronWindow = {} as ElectronWindow.ElectronWindow["Service"];
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const clerk = yield* DesktopClerk.DesktopClerk;
|
||||
const exit = yield* Effect.exit(Effect.scoped(clerk.configure));
|
||||
|
||||
assert.isTrue(Exit.hasInterrupts(exit));
|
||||
assert.equal(quit.mock.calls.length, 1);
|
||||
assert.deepEqual(registeredEvents, []);
|
||||
}).pipe(
|
||||
Effect.provide(makeDesktopClerkLayer()),
|
||||
Effect.provideService(ElectronApp.ElectronApp, electronApp),
|
||||
Effect.provideService(ElectronWindow.ElectronWindow, electronWindow),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ isDevelopment: true, scheme: "t3code-dev" },
|
||||
{ isDevelopment: false, scheme: "t3code" },
|
||||
])("configures the SDK with the $scheme renderer origin", ({ isDevelopment, scheme }) => {
|
||||
const bridge = { cleanup: vi.fn() };
|
||||
const bridge = { cleanup: vi.fn(), isPrimaryInstance: true };
|
||||
storageMock.mockReturnValue(storageAdapter);
|
||||
createClerkBridgeMock.mockReturnValue(bridge);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { clerkFrontendApiHostnameFromPublishableKey } from "@t3tools/shared/rela
|
||||
import * as ElectronApp from "../electron/ElectronApp.ts";
|
||||
import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
|
||||
import * as ElectronWindow from "../electron/ElectronWindow.ts";
|
||||
import * as DesktopAppIdentity from "./DesktopAppIdentity.ts";
|
||||
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
|
||||
|
||||
declare const __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__: string | undefined;
|
||||
@@ -84,7 +85,18 @@ export function createDesktopClerkBridge(stateDir: string, isDevelopment: boolea
|
||||
|
||||
export const make = Effect.gen(function* () {
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
yield* Effect.acquireRelease(
|
||||
const electronApp = yield* ElectronApp.ElectronApp;
|
||||
|
||||
// Electron scopes the single-instance lock to the userData directory and
|
||||
// creates that directory when the lock is acquired. The SDK bridge takes
|
||||
// the lock at creation, so userData must already point at the real
|
||||
// directory here — under the default productName-derived path, acquiring
|
||||
// the lock would create "T3 Code (Alpha)" and make the legacy-install
|
||||
// detection in resolveUserDataPath match on fresh installs.
|
||||
const userDataPath = yield* DesktopAppIdentity.resolveUserDataPath;
|
||||
yield* electronApp.setPath("userData", userDataPath);
|
||||
|
||||
const bridge = yield* Effect.acquireRelease(
|
||||
Effect.try({
|
||||
try: () => createDesktopClerkBridge(environment.stateDir, environment.isDevelopment),
|
||||
catch: (cause) =>
|
||||
@@ -113,7 +125,12 @@ export const make = Effect.gen(function* () {
|
||||
const context = yield* Effect.context<ElectronWindow.ElectronWindow>();
|
||||
const runPromise = Effect.runPromiseWith(context);
|
||||
|
||||
if (!(yield* electronApp.requestSingleInstanceLock)) {
|
||||
// The SDK bridge holds Electron's single-instance lock (acquired at
|
||||
// bridge creation) so OAuth deep-link callbacks on Windows/Linux are
|
||||
// forwarded to the running app. In a secondary instance the bridge has
|
||||
// already begun quitting the app; app.quit() is asynchronous, so stop
|
||||
// bootstrap here before whenReady can fire.
|
||||
if (!bridge.isPrimaryInstance) {
|
||||
yield* electronApp.quit;
|
||||
return yield* Effect.interrupt;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ describe("DesktopLifecycle", () => {
|
||||
setName: () => Effect.void,
|
||||
setAboutPanelOptions: () => Effect.void,
|
||||
setAppUserModelId: () => Effect.void,
|
||||
requestSingleInstanceLock: Effect.succeed(true),
|
||||
getAppMetrics: Effect.succeed([]),
|
||||
isDefaultProtocolClient: () => Effect.succeed(false),
|
||||
setAsDefaultProtocolClient: () => Effect.succeed(true),
|
||||
|
||||
@@ -14,7 +14,6 @@ const {
|
||||
quitMock,
|
||||
relaunchMock,
|
||||
removeListenerMock,
|
||||
requestSingleInstanceLockMock,
|
||||
setAboutPanelOptionsMock,
|
||||
setAppUserModelIdMock,
|
||||
setAsDefaultProtocolClientMock,
|
||||
@@ -35,7 +34,6 @@ const {
|
||||
quitMock: vi.fn(),
|
||||
relaunchMock: vi.fn(),
|
||||
removeListenerMock: vi.fn(),
|
||||
requestSingleInstanceLockMock: vi.fn(() => true),
|
||||
setAboutPanelOptionsMock: vi.fn(),
|
||||
setAppUserModelIdMock: vi.fn(),
|
||||
setAsDefaultProtocolClientMock: vi.fn(() => true),
|
||||
@@ -67,7 +65,6 @@ vi.mock("electron", () => ({
|
||||
quit: quitMock,
|
||||
relaunch: relaunchMock,
|
||||
removeListener: removeListenerMock,
|
||||
requestSingleInstanceLock: requestSingleInstanceLockMock,
|
||||
runningUnderARM64Translation: false,
|
||||
setAboutPanelOptions: setAboutPanelOptionsMock,
|
||||
setAsDefaultProtocolClient: setAsDefaultProtocolClientMock,
|
||||
|
||||
@@ -56,7 +56,6 @@ export class ElectronApp extends Context.Service<
|
||||
options: Electron.AboutPanelOptionsOptions,
|
||||
) => Effect.Effect<void>;
|
||||
readonly setAppUserModelId: (id: string) => Effect.Effect<void>;
|
||||
readonly requestSingleInstanceLock: Effect.Effect<boolean>;
|
||||
readonly getAppMetrics: Effect.Effect<ReadonlyArray<Electron.ProcessMetric>>;
|
||||
readonly isDefaultProtocolClient: (protocol: string) => Effect.Effect<boolean>;
|
||||
readonly setAsDefaultProtocolClient: (
|
||||
@@ -153,7 +152,6 @@ export const make = ElectronApp.of({
|
||||
Effect.sync(() => {
|
||||
Electron.app.setAppUserModelId(id);
|
||||
}),
|
||||
requestSingleInstanceLock: Effect.sync(() => Electron.app.requestSingleInstanceLock()),
|
||||
getAppMetrics: Effect.sync(() => Electron.app.getAppMetrics()),
|
||||
isDefaultProtocolClient: (protocol) =>
|
||||
Effect.sync(() => Electron.app.isDefaultProtocolClient(protocol)),
|
||||
|
||||
@@ -34,7 +34,6 @@ function makeElectronAppLayer(
|
||||
setName: () => Effect.void,
|
||||
setAboutPanelOptions: () => Effect.void,
|
||||
setAppUserModelId: () => Effect.void,
|
||||
requestSingleInstanceLock: Effect.succeed(true),
|
||||
getAppMetrics: Effect.sync(() => {
|
||||
onMetricsRead();
|
||||
return metrics;
|
||||
|
||||
@@ -39,7 +39,6 @@ const electronAppLayer = Layer.succeed(ElectronApp.ElectronApp, {
|
||||
setName: () => Effect.void,
|
||||
setAboutPanelOptions: () => Effect.void,
|
||||
setAppUserModelId: () => Effect.void,
|
||||
requestSingleInstanceLock: Effect.succeed(true),
|
||||
getAppMetrics: Effect.succeed([]),
|
||||
isDefaultProtocolClient: () => Effect.succeed(false),
|
||||
setAsDefaultProtocolClient: () => Effect.succeed(true),
|
||||
|
||||
@@ -161,7 +161,7 @@ const config: ExpoConfig = {
|
||||
slug: "t3-code",
|
||||
platforms: ["ios", "android"],
|
||||
scheme: variant.scheme,
|
||||
version: "0.1.0",
|
||||
version: "1.0.1",
|
||||
runtimeVersion: {
|
||||
// Fingerprint (not appVersion) so an OTA only reaches binaries whose native
|
||||
// project — native deps, config plugins, AND patches/ — matches the update.
|
||||
@@ -275,10 +275,12 @@ const config: ExpoConfig = {
|
||||
"expo-camera",
|
||||
{
|
||||
cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
|
||||
microphonePermission: false,
|
||||
barcodeScannerEnabled: true,
|
||||
recordAudioAndroid: false,
|
||||
},
|
||||
],
|
||||
["expo-image-picker", { photosPermission: false, microphonePermission: false }],
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"start:dev": "APP_VARIANT=development expo start",
|
||||
"start:preview": "APP_VARIANT=preview expo start",
|
||||
"start:prod": "APP_VARIANT=production expo start",
|
||||
"showcase": "APP_VARIANT=development EXPO_PUBLIC_SHOWCASE=1 expo start --dev-client --scheme t3code-dev --clear",
|
||||
"showcase": "APP_VARIANT=production EXPO_PUBLIC_SHOWCASE=1 expo start --dev-client --scheme t3code --clear",
|
||||
"screenshots": "node ../../scripts/mobile-showcase.ts",
|
||||
"android": "EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
"android:dev": "APP_VARIANT=development EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && REACT_NATIVE_PACKAGER_HOSTNAME=localhost expo run:android",
|
||||
|
||||
@@ -15,6 +15,7 @@ import { DynamicColorIOS, Platform, Pressable, ScrollView, StyleSheet } from "re
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { AppText as Text } from "./components/AppText";
|
||||
import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
|
||||
import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
|
||||
import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
|
||||
import { ClerkSettingsSheetDetentProvider } from "./features/cloud/ClerkSettingsSheetDetent";
|
||||
@@ -392,7 +393,7 @@ export const RootStack = createNativeStackNavigator({
|
||||
...GLASS_HEADER_OPTIONS,
|
||||
contentStyle: { backgroundColor: "transparent" },
|
||||
headerBackVisible: false,
|
||||
title: "Threads",
|
||||
...getCompactBrandHeaderOptions(),
|
||||
},
|
||||
}),
|
||||
Thread: createNativeStackScreen({
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import Constants from "expo-constants";
|
||||
import type {
|
||||
NativeStackHeaderItem,
|
||||
NativeStackNavigationOptions,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { Platform, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
import { T3Wordmark } from "./T3Wordmark";
|
||||
import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
|
||||
import { resolveMobileStageLabel } from "../lib/mobileBranding";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass";
|
||||
|
||||
// Native leading items inherit different UIKit margins than title views.
|
||||
const IOS_NATIVE_LEADING_TITLE_OFFSET = -6;
|
||||
const IPAD_NATIVE_LEADING_TITLE_OFFSET = 7;
|
||||
|
||||
/**
|
||||
* Compact brand lockup sized for native navigation bars.
|
||||
*/
|
||||
export function CompactBrandTitle(
|
||||
props: {
|
||||
readonly nativeLeadingItem?: boolean;
|
||||
} = {},
|
||||
) {
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const mutedColor = useThemeColor("--color-foreground-muted");
|
||||
const subtleColor = useThemeColor("--color-subtle");
|
||||
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
|
||||
const titleOffset =
|
||||
Platform.OS !== "ios"
|
||||
? 0
|
||||
: props.nativeLeadingItem
|
||||
? Platform.isPad
|
||||
? IPAD_NATIVE_LEADING_TITLE_OFFSET
|
||||
: IOS_NATIVE_LEADING_TITLE_OFFSET
|
||||
: Platform.isPad
|
||||
? IPAD_HOME_TITLE_OFFSET
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<View
|
||||
aria-level={1}
|
||||
accessibilityLabel="T3 Code, Threads"
|
||||
accessible
|
||||
role="heading"
|
||||
style={{
|
||||
alignItems: "center",
|
||||
flexDirection: "row",
|
||||
gap: 6,
|
||||
marginLeft: titleOffset,
|
||||
}}
|
||||
>
|
||||
<T3Wordmark color={iconColor} height={15} />
|
||||
<Text
|
||||
style={{
|
||||
color: mutedColor,
|
||||
fontFamily: "DMSans-Medium",
|
||||
fontSize: 21,
|
||||
letterSpacing: -0.5,
|
||||
}}
|
||||
>
|
||||
Code
|
||||
</Text>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: subtleColor,
|
||||
borderRadius: 999,
|
||||
paddingHorizontal: 6,
|
||||
paddingVertical: 2,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: mutedColor,
|
||||
fontFamily: "DMSans-Bold",
|
||||
fontSize: 9,
|
||||
letterSpacing: 0.9,
|
||||
textTransform: "uppercase",
|
||||
}}
|
||||
>
|
||||
{stageLabel}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function renderCompactBrandTitle() {
|
||||
return <CompactBrandTitle />;
|
||||
}
|
||||
|
||||
export function renderCompactBrandHeaderItems(): NativeStackHeaderItem[] {
|
||||
return [
|
||||
{
|
||||
element: <CompactBrandTitle nativeLeadingItem />,
|
||||
hidesSharedBackground: true,
|
||||
type: "custom",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function getCompactBrandHeaderOptions(
|
||||
fallbackTitleStyle?: NativeStackNavigationOptions["headerTitleStyle"],
|
||||
): NativeStackNavigationOptions {
|
||||
if (Platform.OS === "ios" && NATIVE_LIQUID_GLASS_SUPPORTED) {
|
||||
return {
|
||||
headerTitle: "Threads",
|
||||
headerTitleStyle: { color: "transparent", fontSize: 18, fontWeight: "800" },
|
||||
title: "Threads",
|
||||
unstable_headerLeftItems: renderCompactBrandHeaderItems,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
headerTitle: renderCompactBrandTitle,
|
||||
headerTitleStyle: fallbackTitleStyle,
|
||||
title: "Threads",
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,21 @@
|
||||
import { SymbolView } from "./AppSymbol";
|
||||
import { Image } from "expo-image";
|
||||
import { useState } from "react";
|
||||
import { useLayoutEffect, useMemo, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import { isProjectFaviconFallbackUrl } from "@t3tools/shared/projectFavicon";
|
||||
import {
|
||||
getProjectFaviconCacheKey,
|
||||
isProjectFaviconFallbackUrl,
|
||||
} from "@t3tools/shared/projectFavicon";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
import { useAssetUrl } from "../state/assets";
|
||||
|
||||
/* ─── Favicon cache (matches web pattern) ────────────────────────────── */
|
||||
const loadedFaviconUrls = new Set<string>();
|
||||
import {
|
||||
beginProjectFaviconRequest,
|
||||
createProjectFaviconRequest,
|
||||
hasLoadedProjectFavicon,
|
||||
markProjectFaviconFailed,
|
||||
markProjectFaviconLoaded,
|
||||
} from "./projectFaviconCache";
|
||||
|
||||
/* ─── Component ──────────────────────────────────────────────────────── */
|
||||
export function ProjectFavicon(props: {
|
||||
@@ -26,10 +33,15 @@ export function ProjectFavicon(props: {
|
||||
: { _tag: "project-favicon", cwd: props.workspaceRoot },
|
||||
);
|
||||
const renderableFaviconUrl = isProjectFaviconFallbackUrl(faviconUrl) ? null : faviconUrl;
|
||||
const cacheKey =
|
||||
renderableFaviconUrl && props.workspaceRoot
|
||||
? getProjectFaviconCacheKey(props.environmentId, props.workspaceRoot, renderableFaviconUrl)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<ProjectFaviconImage
|
||||
key={faviconUrl}
|
||||
key={cacheKey}
|
||||
cacheKey={cacheKey}
|
||||
faviconUrl={renderableFaviconUrl}
|
||||
open={props.open}
|
||||
projectTitle={props.projectTitle}
|
||||
@@ -39,18 +51,32 @@ export function ProjectFavicon(props: {
|
||||
}
|
||||
|
||||
function ProjectFaviconImage(props: {
|
||||
readonly cacheKey: string | null;
|
||||
readonly faviconUrl: string | null;
|
||||
readonly open?: boolean;
|
||||
readonly projectTitle: string;
|
||||
readonly size: number;
|
||||
}) {
|
||||
const iconMuted = useThemeColor("--color-icon-subtle");
|
||||
const faviconRequest = useMemo(
|
||||
() => createProjectFaviconRequest(props.cacheKey, props.faviconUrl),
|
||||
[props.cacheKey, props.faviconUrl],
|
||||
);
|
||||
const [activeFaviconRequest, setActiveFaviconRequest] = useState<typeof faviconRequest>(null);
|
||||
useLayoutEffect(() => {
|
||||
if (faviconRequest === null) return;
|
||||
|
||||
const endRequest = beginProjectFaviconRequest(faviconRequest);
|
||||
setActiveFaviconRequest(faviconRequest);
|
||||
return endRequest;
|
||||
}, [faviconRequest]);
|
||||
|
||||
const [status, setStatus] = useState<"loading" | "loaded" | "error">(() =>
|
||||
props.faviconUrl && loadedFaviconUrls.has(props.faviconUrl) ? "loaded" : "loading",
|
||||
hasLoadedProjectFavicon(props.cacheKey) ? "loaded" : "loading",
|
||||
);
|
||||
|
||||
const showImage = props.faviconUrl !== null && status === "loaded";
|
||||
const requestIsActive = faviconRequest !== null && activeFaviconRequest === faviconRequest;
|
||||
const showImage = requestIsActive && status === "loaded";
|
||||
|
||||
return (
|
||||
<View
|
||||
@@ -72,11 +98,15 @@ function ProjectFaviconImage(props: {
|
||||
) : null}
|
||||
|
||||
{/* Favicon image (hidden until loaded) */}
|
||||
{props.faviconUrl ? (
|
||||
{requestIsActive ? (
|
||||
<Image
|
||||
key={faviconRequest.faviconUrl}
|
||||
source={{
|
||||
uri: props.faviconUrl,
|
||||
uri: faviconRequest.faviconUrl,
|
||||
cacheKey: faviconRequest.cacheKey,
|
||||
}}
|
||||
cachePolicy="memory-disk"
|
||||
recyclingKey={faviconRequest.cacheKey}
|
||||
accessibilityLabel={`${props.projectTitle} favicon`}
|
||||
style={{
|
||||
width: props.size,
|
||||
@@ -86,10 +116,13 @@ function ProjectFaviconImage(props: {
|
||||
}}
|
||||
contentFit="contain"
|
||||
onLoad={() => {
|
||||
if (props.faviconUrl) loadedFaviconUrls.add(props.faviconUrl);
|
||||
if (!markProjectFaviconLoaded(faviconRequest)) return;
|
||||
setStatus("loaded");
|
||||
}}
|
||||
onError={() => setStatus("error")}
|
||||
onError={() => {
|
||||
if (!markProjectFaviconFailed(faviconRequest)) return;
|
||||
setStatus("error");
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
beginProjectFaviconRequest,
|
||||
createProjectFaviconRequest,
|
||||
hasLoadedProjectFavicon,
|
||||
markProjectFaviconFailed,
|
||||
markProjectFaviconLoaded,
|
||||
} from "./projectFaviconCache";
|
||||
|
||||
describe("project favicon cache", () => {
|
||||
it("ignores callbacks from a superseded URL", () => {
|
||||
const cacheKey = "environment-1:/workspace:v1-favicon.svg";
|
||||
const expiredUrl = "https://environment.example/api/assets/expired/v1-favicon.svg";
|
||||
const refreshedUrl = "https://environment.example/api/assets/refreshed/v1-favicon.svg";
|
||||
|
||||
const expiredRequest = createProjectFaviconRequest(cacheKey, expiredUrl);
|
||||
const endExpiredRequest = beginProjectFaviconRequest(expiredRequest);
|
||||
markProjectFaviconLoaded(expiredRequest);
|
||||
const refreshedRequest = createProjectFaviconRequest(cacheKey, refreshedUrl);
|
||||
const endRefreshedRequest = beginProjectFaviconRequest(refreshedRequest);
|
||||
|
||||
expect(markProjectFaviconLoaded(expiredRequest)).toBe(false);
|
||||
expect(markProjectFaviconFailed(expiredRequest)).toBe(false);
|
||||
expect(hasLoadedProjectFavicon(cacheKey)).toBe(true);
|
||||
expect(markProjectFaviconFailed(refreshedRequest)).toBe(true);
|
||||
expect(hasLoadedProjectFavicon(cacheKey)).toBe(false);
|
||||
|
||||
endRefreshedRequest();
|
||||
endExpiredRequest();
|
||||
});
|
||||
|
||||
it("evicts the URL that actually failed", () => {
|
||||
const cacheKey = "environment-1:/workspace:v2-favicon.svg";
|
||||
const faviconUrl = "https://environment.example/api/assets/current/v2-favicon.svg";
|
||||
const request = createProjectFaviconRequest(cacheKey, faviconUrl);
|
||||
const endRequest = beginProjectFaviconRequest(request);
|
||||
|
||||
markProjectFaviconLoaded(request);
|
||||
|
||||
expect(markProjectFaviconFailed(request)).toBe(true);
|
||||
expect(hasLoadedProjectFavicon(cacheKey)).toBe(false);
|
||||
|
||||
endRequest();
|
||||
});
|
||||
|
||||
it("does not supersede a request until the next request begins", () => {
|
||||
const cacheKey = "environment-1:/workspace:v3-favicon.svg";
|
||||
const committedUrl = "https://environment.example/api/assets/current/v3-favicon.svg";
|
||||
const abandonedUrl = "https://environment.example/api/assets/abandoned/v3-favicon.svg";
|
||||
const committedRequest = createProjectFaviconRequest(cacheKey, committedUrl);
|
||||
const endCommittedRequest = beginProjectFaviconRequest(committedRequest);
|
||||
|
||||
createProjectFaviconRequest(cacheKey, abandonedUrl);
|
||||
|
||||
expect(markProjectFaviconLoaded(committedRequest)).toBe(true);
|
||||
expect(hasLoadedProjectFavicon(cacheKey)).toBe(true);
|
||||
|
||||
endCommittedRequest();
|
||||
});
|
||||
|
||||
it("requires a cache key before creating a URL-bearing request", () => {
|
||||
const firstUrl = "https://environment.example/api/assets/first/favicon.svg";
|
||||
const secondUrl = "https://environment.example/api/assets/second/favicon.svg";
|
||||
|
||||
expect(createProjectFaviconRequest(null, firstUrl)).toBeNull();
|
||||
expect(createProjectFaviconRequest(null, secondUrl)).toBeNull();
|
||||
});
|
||||
|
||||
it("restores the remaining active URL when a newer request ends", () => {
|
||||
const cacheKey = "environment-1:/workspace:v4-favicon.svg";
|
||||
const firstRequest = createProjectFaviconRequest(
|
||||
cacheKey,
|
||||
"https://environment.example/api/assets/first/v4-favicon.svg",
|
||||
);
|
||||
const secondRequest = createProjectFaviconRequest(
|
||||
cacheKey,
|
||||
"https://environment.example/api/assets/second/v4-favicon.svg",
|
||||
);
|
||||
const endFirstRequest = beginProjectFaviconRequest(firstRequest);
|
||||
const endSecondRequest = beginProjectFaviconRequest(secondRequest);
|
||||
|
||||
expect(markProjectFaviconLoaded(firstRequest)).toBe(false);
|
||||
endSecondRequest();
|
||||
expect(markProjectFaviconLoaded(firstRequest)).toBe(true);
|
||||
endFirstRequest();
|
||||
expect(markProjectFaviconLoaded(firstRequest)).toBe(false);
|
||||
});
|
||||
|
||||
it("bounds remembered loaded revisions", () => {
|
||||
const firstCacheKey = "environment-1:/workspace:revision-0";
|
||||
let lastCacheKey = firstCacheKey;
|
||||
|
||||
for (let revision = 0; revision < 300; revision++) {
|
||||
lastCacheKey = `environment-1:/workspace:revision-${revision}`;
|
||||
const request = createProjectFaviconRequest(
|
||||
lastCacheKey,
|
||||
`https://environment.example/api/assets/revision-${revision}/favicon.svg`,
|
||||
);
|
||||
const endRequest = beginProjectFaviconRequest(request);
|
||||
markProjectFaviconLoaded(request);
|
||||
endRequest();
|
||||
}
|
||||
|
||||
expect(hasLoadedProjectFavicon(firstCacheKey)).toBe(false);
|
||||
expect(hasLoadedProjectFavicon(lastCacheKey)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
export interface ProjectFaviconRequest {
|
||||
readonly cacheKey: string;
|
||||
readonly faviconUrl: string;
|
||||
}
|
||||
|
||||
interface ActiveFaviconRequests {
|
||||
readonly urls: Map<string, number>;
|
||||
currentUrl: string;
|
||||
}
|
||||
|
||||
const MAX_LOADED_FAVICONS = 256;
|
||||
const activeFaviconRequests = new Map<string, ActiveFaviconRequests>();
|
||||
const loadedFaviconKeys = new Map<string, true>();
|
||||
|
||||
export function createProjectFaviconRequest(
|
||||
cacheKey: string,
|
||||
faviconUrl: string,
|
||||
): ProjectFaviconRequest;
|
||||
export function createProjectFaviconRequest(
|
||||
cacheKey: string | null,
|
||||
faviconUrl: string | null,
|
||||
): ProjectFaviconRequest | null;
|
||||
export function createProjectFaviconRequest(cacheKey: string | null, faviconUrl: string | null) {
|
||||
if (!cacheKey || !faviconUrl) return null;
|
||||
return { cacheKey, faviconUrl };
|
||||
}
|
||||
|
||||
export function beginProjectFaviconRequest(request: ProjectFaviconRequest) {
|
||||
let activeRequests = activeFaviconRequests.get(request.cacheKey);
|
||||
if (!activeRequests) {
|
||||
activeRequests = { currentUrl: request.faviconUrl, urls: new Map() };
|
||||
activeFaviconRequests.set(request.cacheKey, activeRequests);
|
||||
}
|
||||
|
||||
const activeCount = activeRequests.urls.get(request.faviconUrl) ?? 0;
|
||||
activeRequests.urls.delete(request.faviconUrl);
|
||||
activeRequests.urls.set(request.faviconUrl, activeCount + 1);
|
||||
activeRequests.currentUrl = request.faviconUrl;
|
||||
|
||||
let ended = false;
|
||||
return () => {
|
||||
if (ended) return;
|
||||
ended = true;
|
||||
|
||||
const remainingCount = (activeRequests.urls.get(request.faviconUrl) ?? 1) - 1;
|
||||
if (remainingCount > 0) {
|
||||
activeRequests.urls.set(request.faviconUrl, remainingCount);
|
||||
return;
|
||||
}
|
||||
|
||||
activeRequests.urls.delete(request.faviconUrl);
|
||||
if (activeRequests.urls.size === 0) {
|
||||
if (activeFaviconRequests.get(request.cacheKey) === activeRequests) {
|
||||
activeFaviconRequests.delete(request.cacheKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeRequests.currentUrl === request.faviconUrl) {
|
||||
activeRequests.currentUrl = Array.from(activeRequests.urls.keys()).at(-1)!;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function hasLoadedProjectFavicon(cacheKey: string | null) {
|
||||
return cacheKey !== null && loadedFaviconKeys.has(cacheKey);
|
||||
}
|
||||
|
||||
function isCurrentProjectFaviconRequest(request: ProjectFaviconRequest) {
|
||||
return activeFaviconRequests.get(request.cacheKey)?.currentUrl === request.faviconUrl;
|
||||
}
|
||||
|
||||
function rememberLoadedProjectFavicon(cacheKey: string) {
|
||||
loadedFaviconKeys.delete(cacheKey);
|
||||
loadedFaviconKeys.set(cacheKey, true);
|
||||
|
||||
if (loadedFaviconKeys.size > MAX_LOADED_FAVICONS) {
|
||||
loadedFaviconKeys.delete(loadedFaviconKeys.keys().next().value!);
|
||||
}
|
||||
}
|
||||
|
||||
export function markProjectFaviconLoaded(request: ProjectFaviconRequest) {
|
||||
if (!isCurrentProjectFaviconRequest(request)) return false;
|
||||
|
||||
rememberLoadedProjectFavicon(request.cacheKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function markProjectFaviconFailed(request: ProjectFaviconRequest) {
|
||||
if (!isCurrentProjectFaviconRequest(request)) return false;
|
||||
|
||||
loadedFaviconKeys.delete(request.cacheKey);
|
||||
return true;
|
||||
}
|
||||
@@ -1,11 +1,32 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
buildPairingUrl,
|
||||
extractPairingUrlFromQrPayload,
|
||||
PairingQrPayloadEmptyError,
|
||||
parsePairingUrl,
|
||||
} from "./pairing";
|
||||
|
||||
describe("buildPairingUrl", () => {
|
||||
it("uses HTTP for a schemeless IP address", () => {
|
||||
expect(buildPairingUrl("192.168.1.100:3773", "pairing-token")).toBe(
|
||||
"http://192.168.1.100:3773/#token=pairing-token",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps HTTPS as the default for a schemeless hostname", () => {
|
||||
expect(buildPairingUrl("remote.example.com", "pairing-token")).toBe(
|
||||
"https://remote.example.com/#token=pairing-token",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves an explicit scheme for an IP address", () => {
|
||||
expect(buildPairingUrl("https://192.168.1.100:3773", "pairing-token")).toBe(
|
||||
"https://192.168.1.100:3773/#token=pairing-token",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractPairingUrlFromQrPayload", () => {
|
||||
it("trims raw pairing urls from qr payloads", () => {
|
||||
expect(
|
||||
|
||||
@@ -3,6 +3,21 @@ import * as Schema from "effect/Schema";
|
||||
|
||||
const MOBILE_PAIRING_URL_PARAM = "pairingUrl";
|
||||
|
||||
function isIpLiteral(host: string): boolean {
|
||||
try {
|
||||
const hostname = new URL(`http://${host}`).hostname.replace(/^\[|\]$/g, "");
|
||||
if (hostname.includes(":")) return true;
|
||||
|
||||
const octets = hostname.split(".");
|
||||
return (
|
||||
octets.length === 4 &&
|
||||
octets.every((octet) => /^\d{1,3}$/.test(octet) && Number(octet) <= 255)
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class PairingQrPayloadEmptyError extends Schema.TaggedErrorClass<PairingQrPayloadEmptyError>()(
|
||||
"PairingQrPayloadEmptyError",
|
||||
{},
|
||||
@@ -19,7 +34,7 @@ export function buildPairingUrl(host: string, code: string): string {
|
||||
if (!c) return h;
|
||||
|
||||
try {
|
||||
const url = new URL(h.includes("://") ? h : `https://${h}`);
|
||||
const url = new URL(h.includes("://") ? h : `${isIpLiteral(h) ? "http" : "https"}://${h}`);
|
||||
url.hash = new URLSearchParams([["token", c]]).toString();
|
||||
return url.toString();
|
||||
} catch {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { executeAtomQuery } from "@t3tools/client-runtime/state/runtime";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import { Atom } from "effect/unstable/reactivity";
|
||||
|
||||
import { appAtomRegistry } from "../../state/atom-registry";
|
||||
import { projectEnvironment } from "../../state/projects";
|
||||
@@ -11,7 +10,6 @@ import type { ReviewDiffTheme } from "../review/shikiReviewHighlighter";
|
||||
|
||||
const inFlightPreloads = new Map<string, Promise<void>>();
|
||||
const MAX_HIGHLIGHT_PRELOAD_CHARACTERS = 256 * 1024;
|
||||
const WORKSPACE_FILE_PRELOAD_RETAIN_MS = 1_000;
|
||||
|
||||
function preloadKey(input: {
|
||||
readonly cwd: string;
|
||||
@@ -38,12 +36,10 @@ export function preloadWorkspaceFileContents(input: {
|
||||
|
||||
const preload = executeAtomQuery(
|
||||
appAtomRegistry,
|
||||
projectEnvironment
|
||||
.readFile({
|
||||
environmentId: input.environmentId,
|
||||
input: { cwd: input.cwd, relativePath: input.relativePath },
|
||||
})
|
||||
.pipe(Atom.setIdleTTL(WORKSPACE_FILE_PRELOAD_RETAIN_MS)),
|
||||
projectEnvironment.readFile({
|
||||
environmentId: input.environmentId,
|
||||
input: { cwd: input.cwd, relativePath: input.relativePath },
|
||||
}),
|
||||
{
|
||||
label: "workspace file preload",
|
||||
reportDefect: false,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { EnvironmentId, SidebarThreadSortOrder } from "@t3tools/contracts";
|
||||
import type { MenuAction } from "@react-native-menu/menu";
|
||||
import Constants from "expo-constants";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useCallback, useMemo, useRef } from "react";
|
||||
import { Platform, Pressable, Text as RNText, TextInput, View } from "react-native";
|
||||
@@ -9,6 +10,8 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { T3Wordmark } from "../../components/T3Wordmark";
|
||||
import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
|
||||
import { resolveMobileStageLabel } from "../../lib/mobileBranding";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
|
||||
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
|
||||
@@ -64,6 +67,7 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const mutedColor = useThemeColor("--color-foreground-muted");
|
||||
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
|
||||
// Thread List v2 lays the list out in fixed creation order, so the
|
||||
// sort/group filter controls would be silently ignored — hide them and
|
||||
// key the "customized" icon state off the environment filter alone.
|
||||
@@ -195,8 +199,9 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<View
|
||||
className="border-b border-header-border bg-header px-4 pb-3"
|
||||
className="border-b border-header-border bg-header pb-3"
|
||||
style={{
|
||||
paddingHorizontal: HOME_HORIZONTAL_INSET,
|
||||
paddingTop: Math.max(insets.top, 12),
|
||||
}}
|
||||
>
|
||||
@@ -210,7 +215,7 @@ function AndroidHomeHeader(props: HomeHeaderProps) {
|
||||
</RNText>
|
||||
<View className="rounded-full bg-subtle px-2 py-0.75">
|
||||
<RNText className="text-[11px] font-t3-bold tracking-[1.1px] text-foreground-muted uppercase">
|
||||
Alpha
|
||||
{stageLabel}
|
||||
</RNText>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as Order from "effect/Order";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useProjects, useThreadShells } from "../../state/entities";
|
||||
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
|
||||
@@ -93,7 +94,9 @@ export function HomeRouteScreen() {
|
||||
if (layout.usesSplitView) {
|
||||
return (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ title: "", headerTitle: "" }} />
|
||||
<NativeStackScreenOptions
|
||||
options={{ title: "", headerTitle: "", unstable_headerLeftItems: () => [] }}
|
||||
/>
|
||||
<WorkspaceSidebarToolbar
|
||||
afterSidebarButton={
|
||||
<NativeHeaderToolbar.Button
|
||||
@@ -115,8 +118,8 @@ export function HomeRouteScreen() {
|
||||
onStartNewTask={() => navigation.navigate("NewTaskSheet", { screen: "NewTask" })}
|
||||
>
|
||||
<>
|
||||
{/* Restore the compact title in case the split branch blanked it. */}
|
||||
<NativeStackScreenOptions options={{ title: "Threads", headerTitle: "Threads" }} />
|
||||
{/* Restore the compact title after the split branch blanks the detail header. */}
|
||||
<NativeStackScreenOptions options={getCompactBrandHeaderOptions()} />
|
||||
<HomeHeader
|
||||
environments={environments}
|
||||
projects={projectFilterOptions}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import type { ReactNode } from "react";
|
||||
import { Platform, useColorScheme } from "react-native";
|
||||
|
||||
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
|
||||
|
||||
@@ -35,10 +36,9 @@ const SIDEBAR_SCREEN_OPTIONS: SidebarScreenOptions = {
|
||||
headerShadowVisible: false,
|
||||
headerShown: true,
|
||||
headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,
|
||||
headerTitleStyle: { fontSize: 18, fontWeight: "800" },
|
||||
...getCompactBrandHeaderOptions({ fontSize: 18, fontWeight: "800" }),
|
||||
headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
|
||||
scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? SCROLL_EDGE_EFFECTS : undefined,
|
||||
title: "Threads",
|
||||
unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
|
||||
};
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { AppText as Text } from "../../components/AppText";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { ProjectFavicon } from "../../components/ProjectFavicon";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
|
||||
import { relativeTime } from "../../lib/time";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
|
||||
@@ -33,7 +34,7 @@ import { ThreadSearchMatchExcerpt } from "./thread-search-match";
|
||||
export type ThreadListVariant = "compact" | "sidebar";
|
||||
|
||||
/** Left inset that aligns compact secondary rows with the title column. */
|
||||
export const THREAD_LIST_COMPACT_INSET = 20;
|
||||
export const THREAD_LIST_COMPACT_INSET = HOME_HORIZONTAL_INSET;
|
||||
const SIDEBAR_ROW_RADIUS = 12;
|
||||
|
||||
function pullRequestTintColor(
|
||||
|
||||
@@ -65,14 +65,6 @@ export async function pickComposerImages(input: { readonly existingCount: number
|
||||
};
|
||||
}
|
||||
|
||||
const permission = await imagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (!permission.granted) {
|
||||
return {
|
||||
images: [],
|
||||
error: "Allow photo library access to attach images.",
|
||||
};
|
||||
}
|
||||
|
||||
const result = await imagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ["images"],
|
||||
allowsMultipleSelection: true,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/** Horizontal inset shared by the home header and compact thread list. */
|
||||
export const HOME_HORIZONTAL_INSET = 20;
|
||||
|
||||
/** Compensates for the tighter native sidebar title margin on iPad. */
|
||||
export const IPAD_HOME_TITLE_OFFSET = 10;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { resolveMobileStageLabel } from "./mobileBranding";
|
||||
|
||||
describe("resolveMobileStageLabel", () => {
|
||||
it.each([
|
||||
["development", "Dev"],
|
||||
["preview", "Nightly"],
|
||||
["production", "Alpha"],
|
||||
[undefined, "Alpha"],
|
||||
])("maps %s builds to %s", (appVariant, expected) => {
|
||||
expect(resolveMobileStageLabel(appVariant)).toBe(expected);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
export type MobileStageLabel = "Alpha" | "Dev" | "Nightly";
|
||||
|
||||
export function resolveMobileStageLabel(appVariant: unknown): MobileStageLabel {
|
||||
if (appVariant === "development") return "Dev";
|
||||
if (appVariant === "preview") return "Nightly";
|
||||
return "Alpha";
|
||||
}
|
||||
@@ -370,7 +370,8 @@ function NativeHeaderToolbarRoot(props: {
|
||||
const navigation = useNativeStackNavigation();
|
||||
const items = useMemo(() => collectToolbarItems(props.children), [props.children]);
|
||||
|
||||
useEffect(() => {
|
||||
// Swap toolbar owners before paint so split and compact headers cannot clear each other.
|
||||
useLayoutEffect(() => {
|
||||
if (!navigation) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
|
||||
import { requireNativeView } from "expo";
|
||||
import { TextInputWrapper } from "expo-paste-input";
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
@@ -9,12 +10,13 @@ import {
|
||||
useState,
|
||||
type Ref,
|
||||
} from "react";
|
||||
import type { NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from "react-native";
|
||||
import type { NativeSyntheticEvent, ViewProps } from "react-native";
|
||||
import { Image, StyleSheet } from "react-native";
|
||||
|
||||
import { markdownFileIconSource } from "@t3tools/mobile-markdown-text/file-icons";
|
||||
import { resolveMarkdownFileIcon } from "@t3tools/mobile-markdown-text/links";
|
||||
import { MOBILE_TYPOGRAPHY } from "../lib/typography";
|
||||
import { useNativePaste } from "../lib/useNativePaste";
|
||||
import { useFontFamily } from "../lib/useFontFamily";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
import {
|
||||
@@ -117,6 +119,7 @@ export function ComposerEditor({
|
||||
const skillBorder = useThemeColor("--color-inline-skill-border");
|
||||
const skillText = useThemeColor("--color-inline-skill-foreground");
|
||||
const fileTint = useThemeColor("--color-icon-muted");
|
||||
const handlePaste = useNativePaste((uris) => onPasteImages?.(uris));
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
@@ -221,61 +224,63 @@ export function ComposerEditor({
|
||||
const resolvedTextStyle = StyleSheet.flatten(textStyle) ?? {};
|
||||
const regularFontFamily = useFontFamily("regular");
|
||||
return (
|
||||
<NativeView
|
||||
ref={nativeRef}
|
||||
controlledDocumentJson={controlledDocumentJson}
|
||||
themeJson={themeJson}
|
||||
placeholder={props.placeholder ?? ""}
|
||||
fontFamily={
|
||||
typeof resolvedTextStyle.fontFamily === "string"
|
||||
? resolvedTextStyle.fontFamily
|
||||
: regularFontFamily
|
||||
}
|
||||
fontSize={
|
||||
typeof resolvedTextStyle.fontSize === "number"
|
||||
? resolvedTextStyle.fontSize
|
||||
: MOBILE_TYPOGRAPHY.body.fontSize
|
||||
}
|
||||
lineHeight={
|
||||
typeof resolvedTextStyle.lineHeight === "number"
|
||||
? resolvedTextStyle.lineHeight
|
||||
: MOBILE_TYPOGRAPHY.body.lineHeight
|
||||
}
|
||||
contentInsetVertical={contentInsetVertical}
|
||||
singleLineCentered={props.singleLineCentered ?? false}
|
||||
editable={props.editable ?? true}
|
||||
scrollEnabled={props.scrollEnabled ?? true}
|
||||
autoFocus={props.autoFocus ?? false}
|
||||
autoCorrect={props.autoCorrect ?? true}
|
||||
spellCheck={props.spellCheck ?? true}
|
||||
style={style as StyleProp<ViewStyle>}
|
||||
onComposerChange={(event) => {
|
||||
const acknowledgedEventCount = acceptNativeEvent(
|
||||
event.nativeEvent.eventCount,
|
||||
event.nativeEvent.value,
|
||||
event.nativeEvent.selection,
|
||||
);
|
||||
if (acknowledgedEventCount === false) return;
|
||||
onChangeText(event.nativeEvent.value);
|
||||
onSelectionChange?.(event.nativeEvent.selection);
|
||||
setMostRecentEventCount(acknowledgedEventCount);
|
||||
setNativeEventSequence((sequence) => sequence + 1);
|
||||
}}
|
||||
onComposerSelectionChange={(event) => {
|
||||
const acknowledgedEventCount = acceptNativeEvent(
|
||||
event.nativeEvent.eventCount,
|
||||
event.nativeEvent.value,
|
||||
event.nativeEvent.selection,
|
||||
);
|
||||
if (acknowledgedEventCount === false) return;
|
||||
onSelectionChange?.(event.nativeEvent.selection);
|
||||
setMostRecentEventCount(acknowledgedEventCount);
|
||||
setNativeEventSequence((sequence) => sequence + 1);
|
||||
}}
|
||||
onComposerPasteImages={(event) => onPasteImages?.(event.nativeEvent.uris)}
|
||||
onComposerFocus={onFocus}
|
||||
onComposerBlur={onBlur}
|
||||
/>
|
||||
<TextInputWrapper onPaste={handlePaste} style={[{ minHeight: 0 }, style]}>
|
||||
<NativeView
|
||||
ref={nativeRef}
|
||||
controlledDocumentJson={controlledDocumentJson}
|
||||
themeJson={themeJson}
|
||||
placeholder={props.placeholder ?? ""}
|
||||
fontFamily={
|
||||
typeof resolvedTextStyle.fontFamily === "string"
|
||||
? resolvedTextStyle.fontFamily
|
||||
: regularFontFamily
|
||||
}
|
||||
fontSize={
|
||||
typeof resolvedTextStyle.fontSize === "number"
|
||||
? resolvedTextStyle.fontSize
|
||||
: MOBILE_TYPOGRAPHY.body.fontSize
|
||||
}
|
||||
lineHeight={
|
||||
typeof resolvedTextStyle.lineHeight === "number"
|
||||
? resolvedTextStyle.lineHeight
|
||||
: MOBILE_TYPOGRAPHY.body.lineHeight
|
||||
}
|
||||
contentInsetVertical={contentInsetVertical}
|
||||
singleLineCentered={props.singleLineCentered ?? false}
|
||||
editable={props.editable ?? true}
|
||||
scrollEnabled={props.scrollEnabled ?? true}
|
||||
autoFocus={props.autoFocus ?? false}
|
||||
autoCorrect={props.autoCorrect ?? true}
|
||||
spellCheck={props.spellCheck ?? true}
|
||||
style={{ flex: 1, minHeight: 0 }}
|
||||
onComposerChange={(event) => {
|
||||
const acknowledgedEventCount = acceptNativeEvent(
|
||||
event.nativeEvent.eventCount,
|
||||
event.nativeEvent.value,
|
||||
event.nativeEvent.selection,
|
||||
);
|
||||
if (acknowledgedEventCount === false) return;
|
||||
onChangeText(event.nativeEvent.value);
|
||||
onSelectionChange?.(event.nativeEvent.selection);
|
||||
setMostRecentEventCount(acknowledgedEventCount);
|
||||
setNativeEventSequence((sequence) => sequence + 1);
|
||||
}}
|
||||
onComposerSelectionChange={(event) => {
|
||||
const acknowledgedEventCount = acceptNativeEvent(
|
||||
event.nativeEvent.eventCount,
|
||||
event.nativeEvent.value,
|
||||
event.nativeEvent.selection,
|
||||
);
|
||||
if (acknowledgedEventCount === false) return;
|
||||
onSelectionChange?.(event.nativeEvent.selection);
|
||||
setMostRecentEventCount(acknowledgedEventCount);
|
||||
setNativeEventSequence((sequence) => sequence + 1);
|
||||
}}
|
||||
onComposerPasteImages={(event) => onPasteImages?.(event.nativeEvent.uris)}
|
||||
onComposerFocus={onFocus}
|
||||
onComposerBlur={onBlur}
|
||||
/>
|
||||
</TextInputWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { PROJECT_FAVICON_FALLBACK_MARKER } from "@t3tools/shared/projectFavicon";
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as TestClock from "effect/testing/TestClock";
|
||||
|
||||
import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
|
||||
import * as ServerConfig from "../config.ts";
|
||||
@@ -59,12 +61,10 @@ describe("AssetAccess", () => {
|
||||
expect(yield* resolveAsset(token, "report.html")).toEqual({
|
||||
kind: "file",
|
||||
path: canonicalHtmlPath,
|
||||
cacheControl: "private, no-cache",
|
||||
});
|
||||
expect(yield* resolveAsset(token, "report.css")).toEqual({
|
||||
kind: "file",
|
||||
path: canonicalCssPath,
|
||||
cacheControl: "private, no-cache",
|
||||
});
|
||||
expect(yield* resolveAsset(token, "../secret.txt")).toBeNull();
|
||||
expect(yield* resolveAsset(token, ".env")).toBeNull();
|
||||
@@ -178,7 +178,6 @@ describe("AssetAccess", () => {
|
||||
expect(yield* resolveAsset(token, "icon.png")).toEqual({
|
||||
kind: "file",
|
||||
path: canonicalImagePath,
|
||||
cacheControl: "private, no-cache",
|
||||
});
|
||||
expect(yield* resolveAsset(token, "other.png")).toBeNull();
|
||||
expect(yield* resolveAsset(token, "../icon.png")).toBeNull();
|
||||
@@ -205,7 +204,6 @@ describe("AssetAccess", () => {
|
||||
expect(yield* resolveAsset(token, "ignored.png")).toEqual({
|
||||
kind: "file",
|
||||
path: attachmentPath,
|
||||
cacheControl: "private, max-age=3600",
|
||||
});
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
);
|
||||
@@ -218,12 +216,21 @@ describe("AssetAccess", () => {
|
||||
prefix: "t3-asset-favicon-",
|
||||
});
|
||||
const faviconPath = path.join(root, "favicon.svg");
|
||||
yield* fileSystem.writeFileString(faviconPath, "<svg />");
|
||||
const initialFavicon = "<svg>a</svg>";
|
||||
const updatedFavicon = "<svg>b</svg>";
|
||||
expect(updatedFavicon).toHaveLength(initialFavicon.length);
|
||||
yield* fileSystem.writeFileString(faviconPath, initialFavicon);
|
||||
const canonicalFaviconPath = yield* fileSystem.realPath(faviconPath);
|
||||
|
||||
const faviconResult = yield* issueAssetUrl({
|
||||
resource: { _tag: "project-favicon", cwd: root },
|
||||
});
|
||||
expect(faviconResult.relativeUrl).toMatch(/\/v[0-9a-f]{64}-favicon\.svg$/);
|
||||
expect(
|
||||
yield* issueAssetUrl({
|
||||
resource: { _tag: "project-favicon", cwd: root },
|
||||
}),
|
||||
).toEqual(faviconResult);
|
||||
const faviconSuffix = faviconResult.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);
|
||||
const faviconSeparatorIndex = faviconSuffix.indexOf("/");
|
||||
expect(
|
||||
@@ -231,11 +238,15 @@ describe("AssetAccess", () => {
|
||||
faviconSuffix.slice(0, faviconSeparatorIndex),
|
||||
faviconSuffix.slice(faviconSeparatorIndex + 1),
|
||||
),
|
||||
).toEqual({
|
||||
kind: "file",
|
||||
path: canonicalFaviconPath,
|
||||
cacheControl: "private, no-cache",
|
||||
).toEqual({ kind: "file", path: canonicalFaviconPath });
|
||||
|
||||
yield* fileSystem.writeFileString(faviconPath, updatedFavicon);
|
||||
const updatedFaviconResult = yield* issueAssetUrl({
|
||||
resource: { _tag: "project-favicon", cwd: root },
|
||||
});
|
||||
expect(
|
||||
updatedFaviconResult.relativeUrl.slice(updatedFaviconResult.relativeUrl.lastIndexOf("/")),
|
||||
).not.toBe(faviconResult.relativeUrl.slice(faviconResult.relativeUrl.lastIndexOf("/")));
|
||||
|
||||
yield* fileSystem.remove(faviconPath);
|
||||
const fallbackResult = yield* issueAssetUrl({
|
||||
@@ -253,6 +264,31 @@ describe("AssetAccess", () => {
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
);
|
||||
|
||||
it.effect("buckets project favicon expiry after content hashing", () =>
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const root = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-asset-favicon-expiry-",
|
||||
});
|
||||
yield* fileSystem.writeFileString(path.join(root, "favicon.svg"), "<svg />");
|
||||
|
||||
const bucketMs = 30 * 60 * 1000;
|
||||
yield* TestClock.setTime(bucketMs - 1);
|
||||
const crossingCrypto = Crypto.make({
|
||||
randomBytes: (size) => new Uint8Array(size),
|
||||
digest: (algorithm, data) =>
|
||||
TestClock.adjust("2 millis").pipe(Effect.andThen(crypto.digest(algorithm, data))),
|
||||
});
|
||||
const result = yield* issueAssetUrl({
|
||||
resource: { _tag: "project-favicon", cwd: root },
|
||||
}).pipe(Effect.provideService(Crypto.Crypto, crossingCrypto));
|
||||
|
||||
expect(result.expiresAt).toBe(3 * bucketMs);
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
);
|
||||
|
||||
it.effect("preserves structured project favicon resolution causes", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
} from "@t3tools/shared/filePreview";
|
||||
import { PROJECT_FAVICON_FALLBACK_MARKER } from "@t3tools/shared/projectFavicon";
|
||||
import * as Clock from "effect/Clock";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -44,6 +46,8 @@ export const ASSET_ROUTE_PREFIX = "/api/assets";
|
||||
|
||||
const SIGNING_SECRET_NAME = "asset-access-signing-key";
|
||||
const ASSET_TOKEN_TTL_MS = 60 * 60 * 1000;
|
||||
const PROJECT_FAVICON_TOKEN_BUCKET_MS = 30 * 60 * 1000;
|
||||
const PROJECT_FAVICON_VERSION_PREFIX = "v";
|
||||
const PREVIEW_ASSET_EXTENSIONS = new Set([
|
||||
...WORKSPACE_BROWSER_PREVIEW_EXTENSIONS,
|
||||
...WORKSPACE_IMAGE_PREVIEW_EXTENSIONS,
|
||||
@@ -91,11 +95,7 @@ const AssetClaimsJson = Schema.fromJsonString(AssetClaimsSchema);
|
||||
const decodeAssetClaims = Schema.decodeUnknownOption(AssetClaimsJson);
|
||||
const encodeAssetClaims = Schema.encodeSync(AssetClaimsJson);
|
||||
|
||||
export type ResolvedAsset = {
|
||||
readonly kind: "file";
|
||||
readonly path: string;
|
||||
readonly cacheControl: "private, max-age=3600" | "private, no-cache";
|
||||
};
|
||||
export type ResolvedAsset = { readonly kind: "file"; readonly path: string };
|
||||
|
||||
function decodeClaims(encodedPayload: string): AssetClaims | null {
|
||||
try {
|
||||
@@ -173,7 +173,7 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const workspacePaths = yield* WorkspacePaths.WorkspacePaths;
|
||||
const expiresAt = (yield* Clock.currentTimeMillis) + ASSET_TOKEN_TTL_MS;
|
||||
let expiresAt = (yield* Clock.currentTimeMillis) + ASSET_TOKEN_TTL_MS;
|
||||
let claims: AssetClaims;
|
||||
let fileName: string;
|
||||
|
||||
@@ -297,18 +297,18 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
|
||||
),
|
||||
);
|
||||
const relativePath = faviconPath ? path.relative(workspaceRoot, faviconPath) : null;
|
||||
if (
|
||||
relativePath &&
|
||||
!(yield* resolveCanonicalWorkspaceFile({ workspaceRoot, relativePath }).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new AssetProjectFaviconInspectionError({
|
||||
resource: input.resource,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
))
|
||||
) {
|
||||
const canonicalFaviconPath = relativePath
|
||||
? yield* resolveCanonicalWorkspaceFile({ workspaceRoot, relativePath }).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new AssetProjectFaviconInspectionError({
|
||||
resource: input.resource,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
if (relativePath && !canonicalFaviconPath) {
|
||||
return yield* new AssetProjectFaviconNotFoundError({
|
||||
resource: input.resource,
|
||||
});
|
||||
@@ -328,7 +328,31 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
|
||||
relativePath,
|
||||
expiresAt,
|
||||
};
|
||||
fileName = relativePath ? path.basename(relativePath) : PROJECT_FAVICON_FALLBACK_MARKER;
|
||||
if (relativePath && canonicalFaviconPath) {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const faviconBytes = yield* fileSystem.readFile(canonicalFaviconPath).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new AssetProjectFaviconInspectionError({
|
||||
resource: input.resource,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const revision = yield* crypto.digest("SHA-256", faviconBytes).pipe(
|
||||
Effect.map(Encoding.encodeHex),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new AssetProjectFaviconInspectionError({
|
||||
resource: input.resource,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
fileName = `${PROJECT_FAVICON_VERSION_PREFIX}${revision}-${path.basename(relativePath)}`;
|
||||
} else {
|
||||
fileName = PROJECT_FAVICON_FALLBACK_MARKER;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -343,6 +367,13 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
|
||||
}),
|
||||
),
|
||||
);
|
||||
if (claims.kind === "project-favicon") {
|
||||
const issuedAt = yield* Clock.currentTimeMillis;
|
||||
expiresAt =
|
||||
(Math.floor(issuedAt / PROJECT_FAVICON_TOKEN_BUCKET_MS) + 2) *
|
||||
PROJECT_FAVICON_TOKEN_BUCKET_MS;
|
||||
claims = { ...claims, expiresAt };
|
||||
}
|
||||
const encodedPayload = base64UrlEncode(encodeAssetClaims(claims));
|
||||
const token = `${encodedPayload}.${signPayload(encodedPayload, signingSecret)}`;
|
||||
return {
|
||||
@@ -388,11 +419,7 @@ export const resolveAsset = Effect.fn("AssetAccess.resolveAsset")(function* (
|
||||
Effect.orElseSucceed(() => Option.none()),
|
||||
);
|
||||
return Option.isSome(info) && info.value.type === "File"
|
||||
? ({
|
||||
kind: "file",
|
||||
path: attachmentPath,
|
||||
cacheControl: "private, max-age=3600",
|
||||
} satisfies ResolvedAsset)
|
||||
? ({ kind: "file", path: attachmentPath } satisfies ResolvedAsset)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -402,13 +429,7 @@ export const resolveAsset = Effect.fn("AssetAccess.resolveAsset")(function* (
|
||||
workspaceRoot: claims.workspaceRoot,
|
||||
relativePath: claims.relativePath,
|
||||
});
|
||||
return faviconPath
|
||||
? ({
|
||||
kind: "file",
|
||||
path: faviconPath,
|
||||
cacheControl: "private, no-cache",
|
||||
} satisfies ResolvedAsset)
|
||||
: null;
|
||||
return faviconPath ? ({ kind: "file", path: faviconPath } satisfies ResolvedAsset) : null;
|
||||
}
|
||||
|
||||
const decodedPath = decodeRelativePath(relativePath);
|
||||
@@ -421,11 +442,7 @@ export const resolveAsset = Effect.fn("AssetAccess.resolveAsset")(function* (
|
||||
relativePath: claims.relativePath,
|
||||
});
|
||||
return exactWorkspaceFile
|
||||
? ({
|
||||
kind: "file",
|
||||
path: exactWorkspaceFile,
|
||||
cacheControl: "private, no-cache",
|
||||
} satisfies ResolvedAsset)
|
||||
? ({ kind: "file", path: exactWorkspaceFile } satisfies ResolvedAsset)
|
||||
: null;
|
||||
}
|
||||
const segments = decodedPath.split(/[\\/]/);
|
||||
@@ -443,11 +460,5 @@ export const resolveAsset = Effect.fn("AssetAccess.resolveAsset")(function* (
|
||||
workspaceRoot: claims.workspaceRoot,
|
||||
relativePath: joinedRelativePath,
|
||||
});
|
||||
return workspaceFile
|
||||
? ({
|
||||
kind: "file",
|
||||
path: workspaceFile,
|
||||
cacheControl: "private, no-cache",
|
||||
} satisfies ResolvedAsset)
|
||||
: null;
|
||||
return workspaceFile ? ({ kind: "file", path: workspaceFile } satisfies ResolvedAsset) : null;
|
||||
});
|
||||
@@ -55,7 +55,6 @@ export const RPC_REQUIRED_SCOPES = {
|
||||
[WS_METHODS.sourceControlPublishRepository]: AuthOrchestrationOperateScope,
|
||||
[WS_METHODS.projectsListEntries]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsReadFile]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsWatchFile]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsSearchContents]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsSearchEntries]: AuthOrchestrationReadScope,
|
||||
[WS_METHODS.projectsWriteFile]: AuthOrchestrationOperateScope,
|
||||
|
||||
@@ -273,7 +273,7 @@ export const assetRouteLayer = HttpRouter.add(
|
||||
return yield* HttpServerResponse.file(asset.path, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Cache-Control": asset.cacheControl,
|
||||
"Cache-Control": "private, max-age=3600",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
}).pipe(
|
||||
|
||||
@@ -137,6 +137,34 @@ function normalizeDeleteEvent(event: PlannedEvent | ReadonlyArray<PlannedEvent>)
|
||||
}
|
||||
|
||||
it.layer(NodeServices.layer)("decider deletion flows", (it) => {
|
||||
it.effect("emits a deletion tombstone for a missing thread", () =>
|
||||
Effect.gen(function* () {
|
||||
const threadId = asThreadId("ghost-thread");
|
||||
const commandId = asCommandId("cmd-delete-ghost-thread");
|
||||
const readModel = yield* seedReadModel;
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.delete",
|
||||
commandId,
|
||||
threadId,
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
|
||||
expect(normalizeDeleteEvent(result)).toEqual([
|
||||
{
|
||||
type: "thread.deleted",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: threadId,
|
||||
commandId,
|
||||
correlationId: commandId,
|
||||
payload: { threadId },
|
||||
},
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects deleting a non-empty project without force", () =>
|
||||
Effect.gen(function* () {
|
||||
const readModel = yield* seedReadModel;
|
||||
|
||||
@@ -379,11 +379,8 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
}
|
||||
|
||||
case "thread.delete": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
// Keep deletion idempotent for clients holding a stale shell entry. The
|
||||
// tombstone advances the stream and lets every client remove that ghost.
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
|
||||
@@ -153,6 +153,51 @@ it.effect("uses stable diagnostics for every parsed non-repository command", ()
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("invalidates origin remote cache when a driver mutation adds origin", () =>
|
||||
Effect.gen(function* () {
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
const cwd = yield* makeTmpDir();
|
||||
const remote = yield* makeTmpDir("git-vcs-driver-remote-");
|
||||
yield* initRepoWithCommit(cwd);
|
||||
yield* git(remote, ["init", "--bare"]);
|
||||
|
||||
const before = yield* driver.statusDetailsLocal(cwd);
|
||||
assert.equal(before.hasOriginRemote, false);
|
||||
|
||||
yield* driver.ensureRemote({ cwd, preferredName: "origin", url: remote });
|
||||
|
||||
const after = yield* driver.statusDetailsLocal(cwd);
|
||||
assert.equal(after.hasOriginRemote, true);
|
||||
}).pipe(Effect.provide(TestLayer)),
|
||||
);
|
||||
|
||||
it.effect("re-reads origin remote status after cache TTL expiry and bypassed invalidation", () =>
|
||||
Effect.gen(function* () {
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
const cwd = yield* makeTmpDir();
|
||||
const remote = yield* makeTmpDir("git-vcs-driver-remote-");
|
||||
yield* initRepoWithCommit(cwd);
|
||||
yield* git(remote, ["init", "--bare"]);
|
||||
|
||||
// First call caches hasOriginRemote = false (5-min TTL)
|
||||
assert.equal((yield* driver.statusDetailsLocal(cwd)).hasOriginRemote, false);
|
||||
|
||||
// Add origin via raw git (bypasses invalidation hook)
|
||||
yield* git(cwd, ["remote", "add", "origin", remote]);
|
||||
|
||||
// Cache still has the stale false (TTL not yet expired)
|
||||
const stillCached = yield* driver.statusDetailsLocal(cwd);
|
||||
assert.equal(stillCached.hasOriginRemote, false);
|
||||
|
||||
// Advance past the 5-minute TTL so the cache entry expires
|
||||
yield* TestClock.adjust("6 minutes");
|
||||
|
||||
// After expiry, the next call re-executes and picks up the remote
|
||||
const afterExpiry = yield* driver.statusDetailsLocal(cwd);
|
||||
assert.equal(afterExpiry.hasOriginRemote, true);
|
||||
}).pipe(Effect.provide(TestLayer)),
|
||||
);
|
||||
|
||||
it.effect("coalesces concurrent ref pages into one repository snapshot", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -61,6 +61,8 @@ const LIST_REFS_SNAPSHOT_CACHE_CAPACITY = 64;
|
||||
const LIST_REFS_SNAPSHOT_CACHE_TTL = Duration.minutes(2);
|
||||
const LIST_REFS_REFRESH_COALESCE_TTL = Duration.seconds(5);
|
||||
const LIST_REFS_REFRESH_FAILURE_COOLDOWN = Duration.seconds(30);
|
||||
const STATUS_DEFAULT_BRANCH_CACHE_TTL = Duration.minutes(5);
|
||||
const STATUS_ORIGIN_EXISTS_CACHE_TTL = Duration.minutes(5);
|
||||
const STATUS_UPSTREAM_REFRESH_ENV = Object.freeze({
|
||||
GCM_INTERACTIVE: "never",
|
||||
GIT_ASKPASS: "",
|
||||
@@ -1119,6 +1121,63 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
return Cache.get(refresh ? repositoryPathsRefreshCache : repositoryPathsCache, cacheKey);
|
||||
};
|
||||
|
||||
const defaultBranchCache = yield* Cache.makeWith(
|
||||
(gitCommonDir: string) =>
|
||||
Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const fetchCwd =
|
||||
path.basename(gitCommonDir) === ".git" ? path.dirname(gitCommonDir) : gitCommonDir;
|
||||
return yield* executeGit(
|
||||
"GitVcsDriver.statusDetails.defaultBranch",
|
||||
fetchCwd,
|
||||
["--git-dir", gitCommonDir, "symbolic-ref", "refs/remotes/origin/HEAD"],
|
||||
{ allowNonZeroExit: true },
|
||||
).pipe(
|
||||
Effect.map((result) => {
|
||||
if (result.exitCode !== 0) return null;
|
||||
return parseDefaultBranchFromRemoteHeadRef(result.stdout, "origin");
|
||||
}),
|
||||
);
|
||||
}),
|
||||
{
|
||||
capacity: 2_048,
|
||||
timeToLive: Exit.match({
|
||||
onSuccess: () => STATUS_DEFAULT_BRANCH_CACHE_TTL,
|
||||
onFailure: () => Duration.zero,
|
||||
}),
|
||||
},
|
||||
);
|
||||
const originExistsCache = yield* Cache.makeWith(
|
||||
(gitCommonDir: string) =>
|
||||
Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const fetchCwd =
|
||||
path.basename(gitCommonDir) === ".git" ? path.dirname(gitCommonDir) : gitCommonDir;
|
||||
return yield* executeGit(
|
||||
"GitVcsDriver.statusDetails.originExists",
|
||||
fetchCwd,
|
||||
["--git-dir", gitCommonDir, "remote", "get-url", "origin"],
|
||||
{ allowNonZeroExit: true },
|
||||
).pipe(Effect.map((result) => result.exitCode === 0));
|
||||
}),
|
||||
{
|
||||
capacity: 2_048,
|
||||
timeToLive: Exit.match({
|
||||
onSuccess: () => STATUS_ORIGIN_EXISTS_CACHE_TTL,
|
||||
onFailure: () => Duration.zero,
|
||||
}),
|
||||
},
|
||||
);
|
||||
const invalidateStatusStaticCaches = (cwd: string) =>
|
||||
Effect.gen(function* () {
|
||||
const repositoryPaths = yield* resolveRepositoryPaths(cwd).pipe(
|
||||
Effect.catchTags({ GitCommandError: () => Effect.succeed(null) }),
|
||||
);
|
||||
const cacheKey = repositoryPaths?.gitCommonDir ?? normalizeRepositoryPathsCacheKey(cwd);
|
||||
yield* Cache.invalidate(defaultBranchCache, cacheKey);
|
||||
yield* Cache.invalidate(originExistsCache, cacheKey);
|
||||
});
|
||||
|
||||
const resolveGitCommonDir = Effect.fn("resolveGitCommonDir")(function* (cwd: string) {
|
||||
const repositoryPaths = yield* resolveRepositoryPaths(cwd);
|
||||
if (repositoryPaths !== null) {
|
||||
@@ -1517,7 +1576,11 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
});
|
||||
}
|
||||
|
||||
const [numstatStdout, defaultRefResult, hasPrimaryRemote] = yield* Effect.all(
|
||||
const repositoryPaths = yield* resolveRepositoryPaths(cwd).pipe(
|
||||
Effect.catchTags({ GitCommandError: () => Effect.succeed(null) }),
|
||||
);
|
||||
const statusCacheKey = repositoryPaths?.gitCommonDir;
|
||||
const [numstatStdout, defaultBranch, hasPrimaryRemote] = yield* Effect.all(
|
||||
[
|
||||
executeGitWithStableDiagnostics(
|
||||
"GitVcsDriver.statusDetails.numstat",
|
||||
@@ -1574,21 +1637,16 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
);
|
||||
}),
|
||||
),
|
||||
executeGit(
|
||||
"GitVcsDriver.statusDetails.defaultRef",
|
||||
cwd,
|
||||
["symbolic-ref", "refs/remotes/origin/HEAD"],
|
||||
{ allowNonZeroExit: true },
|
||||
),
|
||||
originRemoteExists(cwd).pipe(Effect.orElseSucceed(() => false)),
|
||||
statusCacheKey
|
||||
? Cache.get(defaultBranchCache, statusCacheKey).pipe(Effect.orElseSucceed(() => null))
|
||||
: resolveDefaultBranchName(cwd, "origin").pipe(Effect.orElseSucceed(() => null)),
|
||||
statusCacheKey
|
||||
? Cache.get(originExistsCache, statusCacheKey).pipe(Effect.orElseSucceed(() => false))
|
||||
: originRemoteExists(cwd).pipe(Effect.orElseSucceed(() => false)),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
const statusStdout = statusResult.stdout;
|
||||
const defaultBranch =
|
||||
defaultRefResult.exitCode === 0
|
||||
? defaultRefResult.stdout.trim().replace(/^refs\/remotes\/origin\//, "")
|
||||
: null;
|
||||
|
||||
let refName: string | null = null;
|
||||
let upstreamRef: string | null = null;
|
||||
@@ -2809,7 +2867,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
cwd: string,
|
||||
effect: Effect.Effect<A, E>,
|
||||
): Effect.Effect<A, E> =>
|
||||
effect.pipe(Effect.ensuring(invalidateListRefsSnapshot(cwd).pipe(Effect.ignore)));
|
||||
effect.pipe(
|
||||
Effect.ensuring(
|
||||
Effect.all([
|
||||
invalidateListRefsSnapshot(cwd).pipe(Effect.ignore),
|
||||
invalidateStatusStaticCaches(cwd).pipe(Effect.ignore),
|
||||
]),
|
||||
),
|
||||
);
|
||||
const initRepoWithListRefsInvalidation: GitVcsDriver.GitVcsDriver["Service"]["initRepo"] = (
|
||||
input,
|
||||
) =>
|
||||
|
||||
@@ -2,11 +2,8 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it, describe, expect } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Stream from "effect/Stream";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
@@ -268,42 +265,4 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("watchFile", () => {
|
||||
it.effect("emits when a missing workspace file is created", () =>
|
||||
Effect.gen(function* () {
|
||||
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
|
||||
const cwd = yield* makeTempDir;
|
||||
const eventFiber = yield* workspaceFileSystem
|
||||
.watchFile({ cwd, relativePath: "t3.json" })
|
||||
.pipe(Stream.runHead, Effect.timeout("5 seconds"), Effect.forkChild);
|
||||
|
||||
yield* Effect.sleep("100 millis");
|
||||
yield* writeTextFile(cwd, "t3.json", '{"scripts":[]}');
|
||||
|
||||
const event = yield* Fiber.join(eventFiber);
|
||||
expect(Option.getOrUndefined(event)).toEqual({ relativePath: "t3.json" });
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("emits when an in-workspace symlink target changes", () =>
|
||||
Effect.gen(function* () {
|
||||
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const cwd = yield* makeTempDir;
|
||||
yield* writeTextFile(cwd, "src/target.txt", "initial");
|
||||
yield* fileSystem.symlink(path.join(cwd, "src/target.txt"), path.join(cwd, "linked.txt"));
|
||||
const eventFiber = yield* workspaceFileSystem
|
||||
.watchFile({ cwd, relativePath: "linked.txt" })
|
||||
.pipe(Stream.runHead, Effect.timeout("5 seconds"), Effect.forkChild);
|
||||
|
||||
yield* Effect.sleep("100 millis");
|
||||
yield* writeTextFile(cwd, "src/target.txt", "updated");
|
||||
|
||||
const event = yield* Fiber.join(eventFiber);
|
||||
expect(Option.getOrUndefined(event)).toEqual({ relativePath: "linked.txt" });
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -10,20 +10,17 @@
|
||||
import * as NodeFSP from "node:fs/promises";
|
||||
|
||||
import type {
|
||||
ProjectFileChangeEvent,
|
||||
ProjectReadFileInput,
|
||||
ProjectReadFileResult,
|
||||
ProjectWriteFileInput,
|
||||
ProjectWriteFileResult,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Stream from "effect/Stream";
|
||||
|
||||
import * as WorkspaceEntries from "./WorkspaceEntries.ts";
|
||||
import * as WorkspacePaths from "./WorkspacePaths.ts";
|
||||
@@ -40,12 +37,10 @@ export class WorkspaceFileSystemOperationError extends Schema.TaggedErrorClass<W
|
||||
operation: Schema.Literals([
|
||||
"realpath-workspace-root",
|
||||
"realpath-target",
|
||||
"realpath-watch-directory",
|
||||
"open",
|
||||
"stat",
|
||||
"read",
|
||||
"close",
|
||||
"watch",
|
||||
"make-directory",
|
||||
"write-file",
|
||||
]),
|
||||
@@ -116,13 +111,6 @@ export class WorkspaceFileSystem extends Context.Service<
|
||||
ProjectReadFileResult,
|
||||
WorkspaceFileSystemError | WorkspacePaths.WorkspacePathOutsideRootError
|
||||
>;
|
||||
/** Watch a workspace-relative file and emit after its directory entry changes. */
|
||||
readonly watchFile: (
|
||||
input: ProjectReadFileInput,
|
||||
) => Stream.Stream<
|
||||
ProjectFileChangeEvent,
|
||||
WorkspaceFileSystemError | WorkspacePaths.WorkspacePathOutsideRootError
|
||||
>;
|
||||
/**
|
||||
* Write a file relative to the workspace root.
|
||||
*
|
||||
@@ -271,126 +259,6 @@ export const make = Effect.gen(function* () {
|
||||
);
|
||||
});
|
||||
|
||||
const watchFile: WorkspaceFileSystem["Service"]["watchFile"] = (input) =>
|
||||
Stream.unwrap(
|
||||
Effect.gen(function* () {
|
||||
const target = yield* workspacePaths.resolveRelativePathWithinRoot({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
});
|
||||
const watchDirectory = path.dirname(target.absolutePath);
|
||||
const realWorkspaceRoot = yield* Effect.tryPromise({
|
||||
try: () => NodeFSP.realpath(input.cwd),
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: input.cwd,
|
||||
operation: "realpath-workspace-root",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
const realWatchDirectory = yield* Effect.tryPromise({
|
||||
try: () => NodeFSP.realpath(watchDirectory),
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: watchDirectory,
|
||||
operation: "realpath-watch-directory",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
const relativeRealDirectory = path.relative(realWorkspaceRoot, realWatchDirectory);
|
||||
if (
|
||||
relativeRealDirectory.startsWith(`..${path.sep}`) ||
|
||||
relativeRealDirectory === ".." ||
|
||||
path.isAbsolute(relativeRealDirectory)
|
||||
) {
|
||||
return yield* new WorkspaceFilePathEscapeError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedWorkspaceRoot: realWorkspaceRoot,
|
||||
resolvedPath: realWatchDirectory,
|
||||
});
|
||||
}
|
||||
|
||||
const realTargetPath = yield* Effect.tryPromise({
|
||||
try: async () => {
|
||||
try {
|
||||
return await NodeFSP.realpath(target.absolutePath);
|
||||
} catch (cause) {
|
||||
if ((cause as NodeJS.ErrnoException).code === "ENOENT") {
|
||||
return null;
|
||||
}
|
||||
throw cause;
|
||||
}
|
||||
},
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: target.absolutePath,
|
||||
operation: "realpath-target",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
if (realTargetPath !== null) {
|
||||
const relativeRealTarget = path.relative(realWorkspaceRoot, realTargetPath);
|
||||
if (
|
||||
relativeRealTarget.startsWith(`..${path.sep}`) ||
|
||||
relativeRealTarget === ".." ||
|
||||
path.isAbsolute(relativeRealTarget)
|
||||
) {
|
||||
return yield* new WorkspaceFilePathEscapeError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedWorkspaceRoot: realWorkspaceRoot,
|
||||
resolvedPath: realTargetPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const watchEntry = (watchPath: string, fileName: string) => {
|
||||
const watchedAbsolutePath = path.join(watchPath, fileName);
|
||||
return fileSystem.watch(watchPath).pipe(
|
||||
Stream.filter((event) => {
|
||||
return (
|
||||
event.path === fileName ||
|
||||
event.path === watchedAbsolutePath ||
|
||||
path.resolve(watchPath, event.path) === watchedAbsolutePath
|
||||
);
|
||||
}),
|
||||
Stream.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: watchPath,
|
||||
operation: "watch",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const lexicalTargetPath = path.join(realWatchDirectory, path.basename(target.absolutePath));
|
||||
const lexicalEvents = watchEntry(realWatchDirectory, path.basename(target.absolutePath));
|
||||
const resolvedTargetEvents =
|
||||
realTargetPath !== null && realTargetPath !== lexicalTargetPath
|
||||
? watchEntry(path.dirname(realTargetPath), path.basename(realTargetPath))
|
||||
: Stream.empty;
|
||||
return Stream.merge(lexicalEvents, resolvedTargetEvents).pipe(
|
||||
Stream.debounce(Duration.millis(100)),
|
||||
Stream.map(() => ({ relativePath: target.relativePath })),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
const writeFile: WorkspaceFileSystem["Service"]["writeFile"] = Effect.fn(
|
||||
"WorkspaceFileSystem.writeFile",
|
||||
)(function* (input) {
|
||||
@@ -429,7 +297,7 @@ export const make = Effect.gen(function* () {
|
||||
return { relativePath: target.relativePath };
|
||||
});
|
||||
|
||||
return WorkspaceFileSystem.of({ readFile, watchFile, writeFile });
|
||||
return WorkspaceFileSystem.of({ readFile, writeFile });
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(WorkspaceFileSystem, make);
|
||||
@@ -1645,21 +1645,6 @@ const makeWsRpcLayer = (
|
||||
),
|
||||
{ "rpc.aggregate": "workspace" },
|
||||
),
|
||||
[WS_METHODS.projectsWatchFile]: (input) =>
|
||||
observeRpcStream(
|
||||
WS_METHODS.projectsWatchFile,
|
||||
workspaceFileSystem.watchFile(input).pipe(
|
||||
Stream.mapError(
|
||||
(cause) =>
|
||||
new ProjectReadFileError({
|
||||
...input,
|
||||
...projectFileFailureContext(cause),
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
),
|
||||
{ "rpc.aggregate": "workspace" },
|
||||
),
|
||||
[WS_METHODS.projectsWriteFile]: (input) =>
|
||||
observeRpcEffect(
|
||||
WS_METHODS.projectsWriteFile,
|
||||
|
||||
@@ -5829,7 +5829,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
aria-label="Scroll to end"
|
||||
title="Scroll to end"
|
||||
onClick={() => scrollToEnd(true)}
|
||||
className="pointer-events-auto flex items-center gap-1.5 rounded-full border border-border/60 bg-card px-3 py-1 text-muted-foreground text-xs shadow-sm transition-colors hover:border-border hover:text-foreground hover:cursor-pointer"
|
||||
className="chat-composer-glass pointer-events-auto flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1 text-muted-foreground text-xs shadow-sm transition-colors hover:border-border hover:text-foreground hover:cursor-pointer"
|
||||
>
|
||||
<ChevronDownIcon className="size-3.5" />
|
||||
Scroll to end
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import type { ComponentType, Dispatch, ReactElement, SetStateAction } from "react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
|
||||
const testState = vi.hoisted(() => ({
|
||||
faviconUrl: "https://environment.test/api/assets/token-a/v1-20-favicon.svg",
|
||||
}));
|
||||
|
||||
const hooks = vi.hoisted(() => {
|
||||
let cursor = 0;
|
||||
let slots: unknown[] = [];
|
||||
const nextIndex = () => cursor++;
|
||||
|
||||
return {
|
||||
beginRender() {
|
||||
cursor = 0;
|
||||
},
|
||||
reset() {
|
||||
cursor = 0;
|
||||
slots = [];
|
||||
},
|
||||
useMemoCache(size: number): unknown[] {
|
||||
const index = nextIndex();
|
||||
if (!slots[index]) {
|
||||
slots[index] = Array.from({ length: size }, () => Symbol.for("react.memo_cache_sentinel"));
|
||||
}
|
||||
return slots[index] as unknown[];
|
||||
},
|
||||
useState<T>(initialValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>] {
|
||||
const index = nextIndex();
|
||||
if (index >= slots.length) {
|
||||
slots[index] =
|
||||
typeof initialValue === "function" ? (initialValue as () => T)() : initialValue;
|
||||
}
|
||||
const setValue: Dispatch<SetStateAction<T>> = (nextValue) => {
|
||||
const previous = slots[index] as T;
|
||||
slots[index] =
|
||||
typeof nextValue === "function" ? (nextValue as (value: T) => T)(previous) : nextValue;
|
||||
};
|
||||
return [slots[index] as T, setValue];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("react", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("react")>();
|
||||
return {
|
||||
...actual,
|
||||
useState: hooks.useState,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("react/compiler-runtime", () => ({ c: hooks.useMemoCache }));
|
||||
vi.mock("../assets/assetUrls", () => ({
|
||||
useAssetUrl: () => testState.faviconUrl,
|
||||
}));
|
||||
|
||||
import { ProjectFavicon } from "./ProjectFavicon";
|
||||
|
||||
type ProjectFaviconImageProps = {
|
||||
readonly cacheKey: string;
|
||||
readonly src: string;
|
||||
readonly className?: string | undefined;
|
||||
readonly fallbackIcon: ComponentType<{ className?: string }>;
|
||||
};
|
||||
|
||||
type ImageElement = ReactElement<{
|
||||
readonly src: string;
|
||||
readonly onLoad?: () => void;
|
||||
readonly onError?: () => void;
|
||||
}>;
|
||||
|
||||
type ProjectFaviconImageElement = ReactElement<{
|
||||
readonly children: [ReactElement | null, ImageElement | null, ImageElement | null];
|
||||
}>;
|
||||
|
||||
function resolveImageComponent(): {
|
||||
readonly Component: (props: ProjectFaviconImageProps) => ProjectFaviconImageElement;
|
||||
readonly props: ProjectFaviconImageProps;
|
||||
} {
|
||||
hooks.beginRender();
|
||||
const element = ProjectFavicon({
|
||||
environmentId: "environment-test" as EnvironmentId,
|
||||
cwd: "/workspace-test",
|
||||
}) as ReactElement<ProjectFaviconImageProps>;
|
||||
hooks.reset();
|
||||
|
||||
return {
|
||||
Component: element.type as (props: ProjectFaviconImageProps) => ProjectFaviconImageElement,
|
||||
props: element.props,
|
||||
};
|
||||
}
|
||||
|
||||
function renderImage(
|
||||
Component: (props: ProjectFaviconImageProps) => ProjectFaviconImageElement,
|
||||
props: ProjectFaviconImageProps,
|
||||
): ProjectFaviconImageElement {
|
||||
hooks.beginRender();
|
||||
return Component(props);
|
||||
}
|
||||
|
||||
describe("ProjectFavicon", () => {
|
||||
beforeEach(() => {
|
||||
hooks.reset();
|
||||
});
|
||||
|
||||
it("falls back when the displayed favicon fails without discarding a valid older image early", () => {
|
||||
const { Component, props } = resolveImageComponent();
|
||||
const initialLoadingImage = renderImage(Component, props).props.children[2];
|
||||
initialLoadingImage?.props.onLoad?.();
|
||||
|
||||
const refreshedProps = {
|
||||
...props,
|
||||
src: "https://environment.test/api/assets/token-b/v1-20-favicon.svg",
|
||||
};
|
||||
const refreshing = renderImage(Component, refreshedProps).props.children;
|
||||
expect(refreshing[1]?.props.src).toBe(props.src);
|
||||
refreshing[2]?.props.onError?.();
|
||||
|
||||
const afterRefreshError = renderImage(Component, refreshedProps).props.children;
|
||||
expect(afterRefreshError[1]?.props.src).toBe(props.src);
|
||||
afterRefreshError[1]?.props.onError?.();
|
||||
|
||||
const afterDisplayedError = renderImage(Component, refreshedProps).props.children;
|
||||
expect(afterDisplayedError[0]).not.toBeNull();
|
||||
expect(afterDisplayedError[1]).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,15 @@
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import { isProjectFaviconFallbackUrl } from "@t3tools/shared/projectFavicon";
|
||||
import {
|
||||
getProjectFaviconCacheKey,
|
||||
isProjectFaviconFallbackUrl,
|
||||
} from "@t3tools/shared/projectFavicon";
|
||||
import { FolderIcon } from "lucide-react";
|
||||
import type { ComponentType } from "react";
|
||||
import { useState } from "react";
|
||||
import { useAssetUrl } from "../assets/assetUrls";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
const loadedProjectFaviconSrcs = new Set<string>();
|
||||
const loadedProjectFaviconSrcs = new Map<string, string>();
|
||||
|
||||
export function ProjectFavicon(input: {
|
||||
environmentId: EnvironmentId;
|
||||
@@ -24,9 +27,12 @@ export function ProjectFavicon(input: {
|
||||
return <ProjectFaviconFallback className={input.className} icon={FallbackIcon} />;
|
||||
}
|
||||
|
||||
const cacheKey = getProjectFaviconCacheKey(input.environmentId, input.cwd, src);
|
||||
|
||||
return (
|
||||
<ProjectFaviconImage
|
||||
key={src}
|
||||
key={cacheKey}
|
||||
cacheKey={cacheKey}
|
||||
src={src}
|
||||
className={input.className}
|
||||
fallbackIcon={FallbackIcon}
|
||||
@@ -45,37 +51,52 @@ function ProjectFaviconFallback({
|
||||
}
|
||||
|
||||
function ProjectFaviconImage({
|
||||
cacheKey,
|
||||
src,
|
||||
className,
|
||||
fallbackIcon: FallbackIcon,
|
||||
}: {
|
||||
readonly cacheKey: string;
|
||||
readonly src: string;
|
||||
readonly className?: string | undefined;
|
||||
readonly fallbackIcon: ComponentType<{ className?: string }>;
|
||||
}) {
|
||||
const [status, setStatus] = useState<"loading" | "loaded" | "error">(() =>
|
||||
loadedProjectFaviconSrcs.has(src) ? "loaded" : "loading",
|
||||
const [displayedSrc, setDisplayedSrc] = useState<string | null>(
|
||||
() => loadedProjectFaviconSrcs.get(cacheKey) ?? null,
|
||||
);
|
||||
const isLoading = displayedSrc !== src;
|
||||
const handleLoadError = (failedSrc: string) => {
|
||||
if (loadedProjectFaviconSrcs.get(cacheKey) === failedSrc) {
|
||||
loadedProjectFaviconSrcs.delete(cacheKey);
|
||||
}
|
||||
setDisplayedSrc((currentSrc) => (currentSrc === failedSrc ? null : currentSrc));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{status !== "loaded" ? (
|
||||
{displayedSrc === null ? (
|
||||
<ProjectFaviconFallback className={className} icon={FallbackIcon} />
|
||||
) : null}
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
className={cn(
|
||||
"size-3.5 shrink-0 rounded-sm object-contain",
|
||||
status !== "loaded" && "hidden",
|
||||
className,
|
||||
)}
|
||||
onLoad={() => {
|
||||
loadedProjectFaviconSrcs.add(src);
|
||||
setStatus("loaded");
|
||||
}}
|
||||
onError={() => setStatus("error")}
|
||||
/>
|
||||
{displayedSrc ? (
|
||||
<img
|
||||
src={displayedSrc}
|
||||
alt=""
|
||||
className={cn("size-3.5 shrink-0 rounded-sm object-contain", className)}
|
||||
onError={() => handleLoadError(displayedSrc)}
|
||||
/>
|
||||
) : null}
|
||||
{isLoading ? (
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
className="hidden"
|
||||
onLoad={() => {
|
||||
loadedProjectFaviconSrcs.set(cacheKey, src);
|
||||
setDisplayedSrc(src);
|
||||
}}
|
||||
onError={() => handleLoadError(src)}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -133,6 +133,7 @@ import {
|
||||
shouldShowArm64IntelBuildWarning,
|
||||
shouldToastDesktopUpdateActionResult,
|
||||
} from "./desktopUpdate.logic";
|
||||
import { showDesktopUpdateDownloadedToast } from "./desktopUpdate.toast";
|
||||
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
|
||||
import { Button } from "./ui/button";
|
||||
import {
|
||||
@@ -3509,11 +3510,7 @@ export default function Sidebar() {
|
||||
.downloadUpdate()
|
||||
.then((result) => {
|
||||
if (result.completed) {
|
||||
toastManager.add({
|
||||
type: "success",
|
||||
title: "Update downloaded",
|
||||
description: "Restart the app from the update button to install it.",
|
||||
});
|
||||
showDesktopUpdateDownloadedToast(bridge, result.state);
|
||||
}
|
||||
if (!shouldToastDesktopUpdateActionResult(result)) return;
|
||||
const actionError = getDesktopUpdateActionError(result);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
getDesktopUpdateActionError,
|
||||
getDesktopUpdateButtonTooltip,
|
||||
getDesktopUpdateInstallConfirmationMessage,
|
||||
getDesktopUpdateReleaseUrl,
|
||||
isDesktopUpdateButtonDisabled,
|
||||
resolveDesktopUpdateButtonAction,
|
||||
shouldShowArm64IntelBuildWarning,
|
||||
@@ -158,6 +159,23 @@ describe("getDesktopUpdateActionError", () => {
|
||||
});
|
||||
|
||||
describe("desktop update UI helpers", () => {
|
||||
it("builds the stable release URL for a downloaded version", () => {
|
||||
expect(getDesktopUpdateReleaseUrl("0.0.30")).toBe(
|
||||
"https://github.com/pingdotgg/t3code/releases/tag/v0.0.30",
|
||||
);
|
||||
});
|
||||
|
||||
it("builds the nightly release URL without dropping its version suffix", () => {
|
||||
expect(getDesktopUpdateReleaseUrl("0.0.30-nightly.20260728.931")).toBe(
|
||||
"https://github.com/pingdotgg/t3code/releases/tag/v0.0.30-nightly.20260728.931",
|
||||
);
|
||||
});
|
||||
|
||||
it("omits the release URL when the updater does not report a version", () => {
|
||||
expect(getDesktopUpdateReleaseUrl(null)).toBeNull();
|
||||
expect(getDesktopUpdateReleaseUrl(" ")).toBeNull();
|
||||
});
|
||||
|
||||
it("toasts only for actionable updater errors", () => {
|
||||
expect(
|
||||
shouldToastDesktopUpdateActionResult({
|
||||
|
||||
@@ -3,6 +3,24 @@ import { isWindowsPlatform } from "../lib/utils";
|
||||
|
||||
export type DesktopUpdateButtonAction = "download" | "install" | "none";
|
||||
|
||||
const DESKTOP_RELEASE_TAG_URL = "https://github.com/pingdotgg/t3code/releases/tag";
|
||||
|
||||
/**
|
||||
* The main process fills `downloadedVersion` from the updater's `update-downloaded`
|
||||
* event, which is dispatched on its own fiber. A download RPC can therefore resolve
|
||||
* before that write lands, so fall back to the version the download was started for.
|
||||
*/
|
||||
export function getDesktopUpdateDownloadedVersion(state: DesktopUpdateState): string | null {
|
||||
return state.downloadedVersion ?? state.availableVersion;
|
||||
}
|
||||
|
||||
/** Release notes for an exact downloaded build; nightly suffixes are part of the tag. */
|
||||
export function getDesktopUpdateReleaseUrl(version: string | null): string | null {
|
||||
const normalizedVersion = version?.trim();
|
||||
if (!normalizedVersion) return null;
|
||||
return `${DESKTOP_RELEASE_TAG_URL}/v${encodeURIComponent(normalizedVersion)}`;
|
||||
}
|
||||
|
||||
export function resolveDesktopUpdateButtonAction(
|
||||
state: DesktopUpdateState,
|
||||
): DesktopUpdateButtonAction {
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import { isValidElement, type ReactElement, type ReactNode } from "react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
import type { DesktopUpdateState } from "@t3tools/contracts";
|
||||
|
||||
const testState = vi.hoisted(() => ({
|
||||
addToast: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("./ui/toast", () => ({
|
||||
toastManager: { add: testState.addToast },
|
||||
}));
|
||||
|
||||
import { showDesktopUpdateDownloadedToast } from "./desktopUpdate.toast";
|
||||
|
||||
type ClickableElement = ReactElement<{ readonly onClick?: () => void }>;
|
||||
|
||||
/** Walks the rendered description, invoking function components, to find the link button. */
|
||||
function findReleaseNotesLink(node: ReactNode): ClickableElement | null {
|
||||
if (Array.isArray(node)) {
|
||||
for (const child of node) {
|
||||
const found = findReleaseNotesLink(child);
|
||||
if (found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (!isValidElement(node)) return null;
|
||||
const element = node as ReactElement<{ readonly children?: ReactNode }>;
|
||||
if (element.type === "button") return element as ClickableElement;
|
||||
if (typeof element.type === "function") {
|
||||
const render = element.type as (props: unknown) => ReactNode;
|
||||
return findReleaseNotesLink(render(element.props));
|
||||
}
|
||||
return findReleaseNotesLink(element.props.children);
|
||||
}
|
||||
|
||||
function getDescription(): ReactNode {
|
||||
const toast = testState.addToast.mock.calls[0]?.[0] as { description?: ReactNode } | undefined;
|
||||
return toast?.description ?? null;
|
||||
}
|
||||
|
||||
function downloadedState(overrides: Partial<DesktopUpdateState> = {}): DesktopUpdateState {
|
||||
return {
|
||||
enabled: true,
|
||||
status: "downloaded",
|
||||
channel: "latest",
|
||||
currentVersion: "0.0.29",
|
||||
hostArch: "arm64",
|
||||
appArch: "arm64",
|
||||
runningUnderArm64Translation: false,
|
||||
availableVersion: "0.0.30",
|
||||
downloadedVersion: "0.0.30",
|
||||
releaseNotes: [],
|
||||
downloadPercent: 100,
|
||||
checkedAt: null,
|
||||
message: null,
|
||||
errorContext: null,
|
||||
canRetry: true,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("showDesktopUpdateDownloadedToast", () => {
|
||||
beforeEach(() => {
|
||||
testState.addToast.mockReset();
|
||||
});
|
||||
|
||||
it("opens the downloaded version's release notes", async () => {
|
||||
const openExternal = vi.fn().mockResolvedValue(true);
|
||||
|
||||
showDesktopUpdateDownloadedToast({ openExternal }, downloadedState());
|
||||
const link = findReleaseNotesLink(getDescription());
|
||||
link?.props.onClick?.();
|
||||
await vi.waitFor(() => {
|
||||
expect(openExternal).toHaveBeenCalledWith(
|
||||
"https://github.com/pingdotgg/t3code/releases/tag/v0.0.30",
|
||||
);
|
||||
});
|
||||
expect(testState.addToast).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("falls back to the version the download was started for", async () => {
|
||||
const openExternal = vi.fn().mockResolvedValue(true);
|
||||
|
||||
// The `update-downloaded` event can land after the download RPC resolves.
|
||||
showDesktopUpdateDownloadedToast(
|
||||
{ openExternal },
|
||||
downloadedState({ downloadedVersion: null }),
|
||||
);
|
||||
findReleaseNotesLink(getDescription())?.props.onClick?.();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(openExternal).toHaveBeenCalledWith(
|
||||
"https://github.com/pingdotgg/t3code/releases/tag/v0.0.30",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("omits the link when the updater reports no version at all", () => {
|
||||
showDesktopUpdateDownloadedToast(
|
||||
{ openExternal: vi.fn() },
|
||||
downloadedState({ availableVersion: null, downloadedVersion: null }),
|
||||
);
|
||||
|
||||
expect(findReleaseNotesLink(getDescription())).toBeNull();
|
||||
});
|
||||
|
||||
it.each([
|
||||
["returns false", vi.fn().mockResolvedValue(false)],
|
||||
["rejects", vi.fn().mockRejectedValue(new Error("open failed"))],
|
||||
])("shows an error when opening release notes %s", async (_description, openExternal) => {
|
||||
showDesktopUpdateDownloadedToast({ openExternal }, downloadedState());
|
||||
findReleaseNotesLink(getDescription())?.props.onClick?.();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(testState.addToast).toHaveBeenLastCalledWith({
|
||||
type: "error",
|
||||
title: "Unable to open release notes",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { DesktopBridge, DesktopUpdateState } from "@t3tools/contracts";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
getDesktopUpdateDownloadedVersion,
|
||||
getDesktopUpdateReleaseUrl,
|
||||
} from "./desktopUpdate.logic";
|
||||
import { toastManager } from "./ui/toast";
|
||||
|
||||
type DesktopUpdateShell = Pick<DesktopBridge, "openExternal">;
|
||||
|
||||
function ReleaseNotesLink({
|
||||
shell,
|
||||
releaseUrl,
|
||||
}: {
|
||||
shell: DesktopUpdateShell;
|
||||
releaseUrl: string;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
className="ml-2 inline-flex cursor-pointer items-center gap-1 align-baseline text-muted-foreground underline decoration-dotted underline-offset-4 transition-colors hover:text-foreground"
|
||||
onClick={() => {
|
||||
void (async () => {
|
||||
try {
|
||||
if (await shell.openExternal(releaseUrl)) return;
|
||||
} catch {
|
||||
// Surface rejected IPC calls through the same user-visible fallback.
|
||||
}
|
||||
toastManager.add({ type: "error", title: "Unable to open release notes" });
|
||||
})();
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
Read more
|
||||
<ArrowRightIcon aria-hidden className="size-3 -rotate-45" strokeWidth={2.25} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function showDesktopUpdateDownloadedToast(
|
||||
shell: DesktopUpdateShell,
|
||||
state: DesktopUpdateState,
|
||||
): void {
|
||||
const releaseUrl = getDesktopUpdateReleaseUrl(getDesktopUpdateDownloadedVersion(state));
|
||||
toastManager.add({
|
||||
type: "success",
|
||||
title: "Update downloaded",
|
||||
description: (
|
||||
<>
|
||||
Restart the app from the update button to install it.
|
||||
{releaseUrl ? <ReleaseNotesLink releaseUrl={releaseUrl} shell={shell} /> : null}
|
||||
</>
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import { useAtomCommand } from "~/state/use-atom-command";
|
||||
import { useAtomQueryRunner } from "~/state/use-atom-query-runner";
|
||||
|
||||
import FileBrowserPanel from "./FileBrowserPanel";
|
||||
import { workspaceImagePreviewUrl } from "./workspaceImagePreview";
|
||||
import {
|
||||
type FileCommentAnnotationEntry,
|
||||
type FileCommentAnnotationGroup,
|
||||
@@ -62,7 +61,6 @@ import {
|
||||
confirmProjectFileQueryData,
|
||||
getOptimisticProjectFileQueryData,
|
||||
setProjectFileQueryData,
|
||||
useProjectFileChangeRevision,
|
||||
useProjectFileQuery,
|
||||
} from "./projectFilesQueryState";
|
||||
|
||||
@@ -122,8 +120,6 @@ type FilePostRender = NonNullable<FileOptions<unknown>["onPostRender"]>;
|
||||
function WorkspaceImagePreview(props: {
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly threadRef: ScopedThreadRef;
|
||||
readonly cwd: string;
|
||||
readonly relativePath: string;
|
||||
readonly absolutePath: string;
|
||||
readonly alt: string;
|
||||
}) {
|
||||
@@ -132,12 +128,9 @@ function WorkspaceImagePreview(props: {
|
||||
threadId: props.threadRef.threadId,
|
||||
path: props.absolutePath,
|
||||
});
|
||||
const revision = useProjectFileChangeRevision(props.environmentId, props.cwd, props.relativePath);
|
||||
const resolvedUrl =
|
||||
assetUrl._tag === "Success" ? workspaceImagePreviewUrl(assetUrl.url, revision) : null;
|
||||
const [failedUrl, setFailedUrl] = useState<string | null>(null);
|
||||
|
||||
if (assetUrl._tag === "Failure" || (resolvedUrl !== null && failedUrl === resolvedUrl)) {
|
||||
if (assetUrl._tag === "Failure" || (assetUrl._tag === "Success" && failedUrl === assetUrl.url)) {
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive">
|
||||
Unable to load workspace image.
|
||||
@@ -149,9 +142,9 @@ function WorkspaceImagePreview(props: {
|
||||
<div className="flex min-h-0 flex-1 items-center justify-center overflow-auto p-4">
|
||||
<img
|
||||
className="max-h-full max-w-full object-contain"
|
||||
src={resolvedUrl ?? undefined}
|
||||
src={assetUrl.url}
|
||||
alt={props.alt}
|
||||
onError={() => setFailedUrl(resolvedUrl)}
|
||||
onError={() => setFailedUrl(assetUrl.url)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
@@ -982,8 +975,6 @@ export default function FilePreviewPanel({
|
||||
key={absolutePath}
|
||||
environmentId={environmentId}
|
||||
threadRef={threadRef}
|
||||
cwd={cwd}
|
||||
relativePath={relativePath}
|
||||
absolutePath={absolutePath}
|
||||
alt={relativePath}
|
||||
/>
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
import { useAtomRefresh, useAtomValue } from "@effect/atom-react";
|
||||
import type {
|
||||
EnvironmentId,
|
||||
ProjectFileChangeEvent,
|
||||
ProjectListEntriesResult,
|
||||
ProjectReadFileResult,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Option from "effect/Option";
|
||||
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { appAtomRegistry } from "~/rpc/atomRegistry";
|
||||
import { projectEnvironment } from "~/state/projects";
|
||||
import { executeAtomQuery } from "@t3tools/client-runtime/state/runtime";
|
||||
import { useProjectPathSearch } from "~/state/queries";
|
||||
import { executeAtomQuery } from "@t3tools/client-runtime/state/runtime";
|
||||
|
||||
const EMPTY_PROJECT_FILE_PATH = "";
|
||||
const EMPTY_PROJECT_FILE_QUERY_ATOM = Atom.make(
|
||||
AsyncResult.initial<ProjectReadFileResult, never>(false),
|
||||
).pipe(Atom.withLabel("project-file-query:empty"));
|
||||
const EMPTY_PROJECT_FILE_CHANGE_ATOM = Atom.make(
|
||||
AsyncResult.initial<ProjectFileChangeEvent, never>(false),
|
||||
).pipe(Atom.withLabel("project-file-change:empty"));
|
||||
function optimisticFileAtom(environmentId: EnvironmentId, cwd: string, relativePath: string) {
|
||||
return projectEnvironment.optimisticFile({ environmentId, cwd, relativePath });
|
||||
}
|
||||
@@ -167,39 +163,15 @@ export function useProjectFilePickerQuery(
|
||||
};
|
||||
}
|
||||
|
||||
export function useProjectFileChangeRevision(
|
||||
environmentId: EnvironmentId,
|
||||
cwd: string,
|
||||
relativePath: string | null,
|
||||
): number {
|
||||
const atom = relativePath
|
||||
? projectEnvironment.watchFile({ environmentId, input: { cwd, relativePath } })
|
||||
: EMPTY_PROJECT_FILE_CHANGE_ATOM;
|
||||
const result = useAtomValue(atom);
|
||||
const previousResultRef = useRef(result);
|
||||
const [revision, setRevision] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (previousResultRef.current === result) return;
|
||||
previousResultRef.current = result;
|
||||
if (AsyncResult.isSuccess(result)) {
|
||||
setRevision((current) => current + 1);
|
||||
}
|
||||
}, [result]);
|
||||
|
||||
return revision;
|
||||
}
|
||||
|
||||
export function useProjectFileQuery(
|
||||
environmentId: EnvironmentId,
|
||||
cwd: string,
|
||||
relativePath: string | null,
|
||||
enabled = true,
|
||||
): ProjectQueryState<ProjectReadFileResult> {
|
||||
const atom =
|
||||
enabled && relativePath !== null
|
||||
? getProjectFileQueryAtom(environmentId, cwd, relativePath)
|
||||
: EMPTY_PROJECT_FILE_QUERY_ATOM;
|
||||
const atom = enabled
|
||||
? getProjectFileQueryAtom(environmentId, cwd, relativePath)
|
||||
: EMPTY_PROJECT_FILE_QUERY_ATOM;
|
||||
const result = useAtomValue(atom);
|
||||
const refreshAtom = useAtomRefresh(atom);
|
||||
const refresh = useCallback(() => refreshAtom(), [refreshAtom]);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { workspaceImagePreviewUrl } from "./workspaceImagePreview";
|
||||
|
||||
describe("workspaceImagePreviewUrl", () => {
|
||||
it("changes the image URL for every filesystem revision", () => {
|
||||
expect(workspaceImagePreviewUrl("https://example.test/image.png", 0)).toBe(
|
||||
"https://example.test/image.png?t3-file-revision=0",
|
||||
);
|
||||
expect(workspaceImagePreviewUrl("https://example.test/image.png", 2)).toBe(
|
||||
"https://example.test/image.png?t3-file-revision=2",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves existing query parameters", () => {
|
||||
expect(workspaceImagePreviewUrl("https://example.test/image.png?token=abc", 1)).toBe(
|
||||
"https://example.test/image.png?token=abc&t3-file-revision=1",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
export function workspaceImagePreviewUrl(assetUrl: string, revision: number): string {
|
||||
const separator = assetUrl.includes("?") ? "&" : "?";
|
||||
return `${assetUrl}${separator}t3-file-revision=${revision}`;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
shouldShowDesktopUpdateButton,
|
||||
shouldToastDesktopUpdateActionResult,
|
||||
} from "../desktopUpdate.logic";
|
||||
import { showDesktopUpdateDownloadedToast } from "../desktopUpdate.toast";
|
||||
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
||||
import { Separator } from "../ui/separator";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
@@ -80,11 +81,7 @@ export function SidebarUpdatePill() {
|
||||
.downloadUpdate()
|
||||
.then((result) => {
|
||||
if (result.completed) {
|
||||
toastManager.add({
|
||||
type: "success",
|
||||
title: "Update downloaded",
|
||||
description: "Restart the app from the update button to install it.",
|
||||
});
|
||||
showDesktopUpdateDownloadedToast(bridge, result.state);
|
||||
}
|
||||
if (!shouldToastDesktopUpdateActionResult(result)) return;
|
||||
const actionError = getDesktopUpdateActionError(result);
|
||||
|
||||
@@ -43,7 +43,7 @@ Captures wait for the real environment snapshot to hydrate and for the requested
|
||||
active. Both platforms record readiness in the simulator/emulator app container. A final settle
|
||||
delay allows native terminal and Git review data to finish rendering.
|
||||
|
||||
A full capture regenerates the selected native project with Expo's clean development prebuild before
|
||||
A full capture regenerates the selected native project with Expo's clean production prebuild before
|
||||
building it. Use --skip-build for repeated captures after the first build.
|
||||
|
||||
The harness uses fixed Metro port `8199`, which separates it from Expo's normal default port but is
|
||||
|
||||
@@ -38,6 +38,8 @@ available. You can set another endpoint as the default from the expanded endpoin
|
||||
|
||||
If the copied link points directly at `http://192.168.x.y:3773`, open it from a client that can reach that LAN address. If it points at `https://app.t3.codes/pair?...`, the hosted web app will save the environment and connect directly to the backend URL in the link.
|
||||
|
||||
In the mobile app's **Add Environment** form, a numeric IP address without a scheme uses HTTP. Include `https://` explicitly when the backend is served over HTTPS.
|
||||
|
||||
### Tailscale Endpoints
|
||||
|
||||
When the desktop app can detect Tailscale, it adds Tailnet endpoints to the reachable endpoint list.
|
||||
|
||||
@@ -49,7 +49,6 @@ export type EnvironmentSubscriptionRpcTag =
|
||||
| typeof WS_METHODS.subscribeTerminalMetadata
|
||||
| typeof WS_METHODS.subscribePreviewEvents
|
||||
| typeof WS_METHODS.subscribeDiscoveredLocalServers
|
||||
| typeof WS_METHODS.projectsWatchFile
|
||||
| typeof WS_METHODS.subscribeResourceTelemetry
|
||||
| typeof WS_METHODS.previewAutomationConnect
|
||||
| typeof WS_METHODS.subscribeVcsStatus
|
||||
|
||||
@@ -287,6 +287,40 @@ describe("RpcSessionFactory", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("reaches ready when a newer server sends unknown config members", () =>
|
||||
Effect.gen(function* () {
|
||||
const { factory, sockets } = yield* makeFactory();
|
||||
const session = yield* factory.connect(PREPARED);
|
||||
const readyFiber = yield* Effect.forkChild(session.ready);
|
||||
const socket = yield* awaitSocket(sockets);
|
||||
socket.open();
|
||||
|
||||
const shortcut = {
|
||||
key: "p",
|
||||
metaKey: false,
|
||||
ctrlKey: false,
|
||||
shiftKey: false,
|
||||
altKey: false,
|
||||
modKey: true,
|
||||
};
|
||||
yield* completeInitialConfig(socket, {
|
||||
...ENCODED_SERVER_CONFIG,
|
||||
keybindings: [
|
||||
{ command: "someFuture.toggle", shortcut },
|
||||
{ command: "terminal.toggle", shortcut },
|
||||
],
|
||||
issues: [{ kind: "keybindings.future-issue", message: "From a newer server" }],
|
||||
availableEditors: ["some-future-editor", "zed"],
|
||||
});
|
||||
yield* Fiber.join(readyFiber);
|
||||
|
||||
const config = yield* session.initialConfig;
|
||||
expect(config.keybindings).toEqual([{ command: "terminal.toggle", shortcut }]);
|
||||
expect(config.issues).toEqual([]);
|
||||
expect(config.availableEditors).toEqual(["zed"]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("uses the legacy config RPC for probes when the server lacks the capability", () =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -7,8 +7,6 @@ import {
|
||||
createEnvironmentCommand,
|
||||
createEnvironmentRpcCommand,
|
||||
createEnvironmentRpcQueryAtomFamily,
|
||||
createEnvironmentRpcSubscriptionAtomFamily,
|
||||
refreshQueryOnSuccess,
|
||||
} from "./runtime.ts";
|
||||
import {
|
||||
type CreateProjectInput,
|
||||
@@ -56,32 +54,6 @@ export function createProjectEnvironmentAtoms<R, E>(
|
||||
key: ({ environmentId, input }: { environmentId: string; input: { projectId: string } }) =>
|
||||
JSON.stringify([environmentId, input.projectId]),
|
||||
};
|
||||
const readFileQuery = createEnvironmentRpcQueryAtomFamily(runtime, {
|
||||
label: "environment-data:projects:read-file-query",
|
||||
tag: WS_METHODS.projectsReadFile,
|
||||
// Workspace files can change outside T3 Code, so always revalidate cached reads on mount.
|
||||
staleTimeMs: 0,
|
||||
idleTtlMs: 0,
|
||||
});
|
||||
const fileChanges = createEnvironmentRpcSubscriptionAtomFamily(runtime, {
|
||||
label: "environment-data:projects:file-changes",
|
||||
tag: WS_METHODS.projectsWatchFile,
|
||||
idleTtlMs: 0,
|
||||
});
|
||||
type ReadFileAtom = ReturnType<typeof readFileQuery>;
|
||||
const liveReadFileAtoms = new WeakMap<ReadFileAtom, ReadFileAtom>();
|
||||
const readFile = (target: Parameters<typeof readFileQuery>[0]): ReadFileAtom => {
|
||||
const queryAtom = readFileQuery(target);
|
||||
const cached = liveReadFileAtoms.get(queryAtom);
|
||||
if (cached) return cached;
|
||||
|
||||
const changesAtom = fileChanges(target);
|
||||
const liveAtom = refreshQueryOnSuccess(queryAtom, changesAtom).pipe(
|
||||
Atom.withLabel(`environment-data:projects:read-file:${target.input.relativePath}`),
|
||||
);
|
||||
liveReadFileAtoms.set(queryAtom, liveAtom);
|
||||
return liveAtom;
|
||||
};
|
||||
return {
|
||||
searchEntries: createEnvironmentRpcQueryAtomFamily(runtime, {
|
||||
label: "environment-data:projects:search-entries",
|
||||
@@ -94,8 +66,12 @@ export function createProjectEnvironmentAtoms<R, E>(
|
||||
staleTimeMs: 30_000,
|
||||
idleTtlMs: 5 * 60_000,
|
||||
}),
|
||||
readFile,
|
||||
watchFile: fileChanges,
|
||||
readFile: createEnvironmentRpcQueryAtomFamily(runtime, {
|
||||
label: "environment-data:projects:read-file",
|
||||
tag: WS_METHODS.projectsReadFile,
|
||||
staleTimeMs: 30_000,
|
||||
idleTtlMs: 5 * 60_000,
|
||||
}),
|
||||
optimisticFile: (target: OptimisticProjectFileTarget) =>
|
||||
optimisticFileFamily(optimisticProjectFileKey(target)),
|
||||
create: createEnvironmentCommand(runtime, {
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
executeAtomQuery,
|
||||
isAtomCommandInterrupted,
|
||||
mapAtomCommandResult,
|
||||
refreshQueryOnSuccess,
|
||||
runAtomCommand,
|
||||
settleAsyncResult,
|
||||
settlePromise,
|
||||
@@ -63,135 +62,6 @@ describe("settleAsyncResult", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("refreshQueryOnSuccess", () => {
|
||||
it.effect("refreshes the query for new success signals without replaying a cached signal", () =>
|
||||
Effect.gen(function* () {
|
||||
let reads = 0;
|
||||
const query = Atom.make(
|
||||
Effect.sync(() => {
|
||||
reads += 1;
|
||||
return reads;
|
||||
}),
|
||||
);
|
||||
const signal = Atom.make<AsyncResult.AsyncResult<string, never>>(
|
||||
AsyncResult.initial<string, never>(false),
|
||||
);
|
||||
const liveQuery = refreshQueryOnSuccess(query, signal);
|
||||
const registry = AtomRegistry.make();
|
||||
const unmount = registry.mount(liveQuery);
|
||||
|
||||
expect(
|
||||
yield* AtomRegistry.getResult(registry, liveQuery, {
|
||||
suspendOnWaiting: true,
|
||||
}),
|
||||
).toBe(1);
|
||||
expect(reads).toBe(1);
|
||||
|
||||
registry.set(signal, AsyncResult.success("changed"));
|
||||
expect(
|
||||
yield* AtomRegistry.getResult(registry, liveQuery, {
|
||||
suspendOnWaiting: true,
|
||||
}),
|
||||
).toBe(2);
|
||||
|
||||
unmount();
|
||||
registry.dispose();
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("keeps a preloaded zero-TTL query warm through the consumer handoff", () =>
|
||||
Effect.gen(function* () {
|
||||
let reads = 0;
|
||||
const query = Atom.make(
|
||||
Effect.sync(() => {
|
||||
reads += 1;
|
||||
return reads;
|
||||
}),
|
||||
).pipe(Atom.setIdleTTL(0));
|
||||
const signal = Atom.make<AsyncResult.AsyncResult<string, never>>(
|
||||
AsyncResult.initial<string, never>(false),
|
||||
).pipe(Atom.setIdleTTL(0));
|
||||
const liveQuery = refreshQueryOnSuccess(query, signal);
|
||||
const preloadedQuery = liveQuery.pipe(Atom.setIdleTTL(1_000));
|
||||
const registry = AtomRegistry.make();
|
||||
|
||||
const preload = yield* Effect.promise(() =>
|
||||
executeAtomQuery(registry, preloadedQuery, {
|
||||
label: "preload",
|
||||
}),
|
||||
);
|
||||
expect(AsyncResult.isSuccess(preload)).toBe(true);
|
||||
expect(reads).toBe(1);
|
||||
|
||||
const unmountConsumer = registry.mount(liveQuery);
|
||||
expect(
|
||||
yield* AtomRegistry.getResult(registry, liveQuery, {
|
||||
suspendOnWaiting: true,
|
||||
}),
|
||||
).toBe(1);
|
||||
expect(reads).toBe(1);
|
||||
|
||||
unmountConsumer();
|
||||
registry.dispose();
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("revalidates a stale cached query after the live query remounts", () =>
|
||||
Effect.gen(function* () {
|
||||
let contents = "initial";
|
||||
let reads = 0;
|
||||
const query = Atom.make(
|
||||
Effect.sync(() => {
|
||||
reads += 1;
|
||||
return contents;
|
||||
}),
|
||||
).pipe(Atom.swr({ staleTime: 0, revalidateOnMount: true }), Atom.setIdleTTL(0));
|
||||
const signal = Atom.make<AsyncResult.AsyncResult<string, never>>(
|
||||
AsyncResult.initial<string, never>(false),
|
||||
);
|
||||
const liveQuery = refreshQueryOnSuccess(query, signal);
|
||||
const scheduledTasks: Array<() => void> = [];
|
||||
const registry = AtomRegistry.make({
|
||||
defaultIdleTTL: 5 * 60_000,
|
||||
scheduleTask: (task) => {
|
||||
let active = true;
|
||||
scheduledTasks.push(() => {
|
||||
if (active) task();
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
},
|
||||
});
|
||||
const unmountInitial = registry.mount(liveQuery);
|
||||
|
||||
expect(
|
||||
yield* AtomRegistry.getResult(registry, liveQuery, {
|
||||
suspendOnWaiting: true,
|
||||
}),
|
||||
).toBe("initial");
|
||||
const readsAfterInitialMount = reads;
|
||||
|
||||
unmountInitial();
|
||||
contents = "updated";
|
||||
while (scheduledTasks.length > 0) {
|
||||
scheduledTasks.shift()?.();
|
||||
}
|
||||
|
||||
const unmountUpdated = registry.mount(liveQuery);
|
||||
expect(
|
||||
yield* AtomRegistry.getResult(registry, liveQuery, {
|
||||
suspendOnWaiting: true,
|
||||
}),
|
||||
).toBe("updated");
|
||||
expect(reads).toBe(readsAfterInitialMount + 1);
|
||||
|
||||
unmountUpdated();
|
||||
registry.dispose();
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("atom command result helpers", () => {
|
||||
it("maps successful command values", () => {
|
||||
const result = mapAtomCommandResult(AsyncResult.success(2), (value) => value * 3);
|
||||
|
||||
@@ -79,29 +79,6 @@ export interface AtomCommandReporter {
|
||||
readonly error: (message: string, cause: Cause.Cause<unknown>) => void;
|
||||
}
|
||||
|
||||
export function refreshQueryOnSuccess<A, E, B, E2>(
|
||||
queryAtom: Atom.Atom<AsyncResult.AsyncResult<A, E>>,
|
||||
signalAtom: Atom.Atom<AsyncResult.AsyncResult<B, E2>>,
|
||||
): Atom.Atom<AsyncResult.AsyncResult<A, E>> {
|
||||
return Atom.transform(
|
||||
queryAtom,
|
||||
(get) => {
|
||||
const current = get.once(queryAtom);
|
||||
get.once(signalAtom);
|
||||
get.subscribe(queryAtom, (result) => {
|
||||
get.setSelf(result);
|
||||
});
|
||||
get.subscribe(signalAtom, (result) => {
|
||||
if (AsyncResult.isSuccess(result)) {
|
||||
get.refresh(queryAtom);
|
||||
}
|
||||
});
|
||||
return current;
|
||||
},
|
||||
{ initialValueTarget: queryAtom },
|
||||
).pipe(Atom.setIdleTTL(0));
|
||||
}
|
||||
|
||||
export interface AtomCommand<W, A, E> {
|
||||
readonly label: string;
|
||||
readonly run: (registry: AtomRegistry.AtomRegistry, input: W) => Promise<AtomCommandResult<A, E>>;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as SchemaTransformation from "effect/SchemaTransformation";
|
||||
|
||||
@@ -20,6 +21,30 @@ export const PortSchema = Schema.Int.check(Schema.isBetween({ minimum: 1, maximu
|
||||
export const IsoDateTime = Schema.String;
|
||||
export type IsoDateTime = typeof IsoDateTime.Type;
|
||||
|
||||
/**
|
||||
* Wire codec for server→client arrays whose element unions grow over time
|
||||
* (new literal members, new struct variants). Decoding drops elements the
|
||||
* current build cannot decode instead of failing the whole payload — a client
|
||||
* has to keep decoding configs sent by servers newer than itself, and
|
||||
* rejecting the payload would take down the connection over data the client
|
||||
* couldn't act on anyway. Encoding is the plain array encoding.
|
||||
*/
|
||||
export const ForwardCompatibleArray = <Element extends Schema.Top>(element: Element) => {
|
||||
const decodeElement = Schema.decodeUnknownOption(element as never);
|
||||
return Schema.Array(Schema.Unknown).pipe(
|
||||
Schema.decodeTo(
|
||||
Schema.Array(element),
|
||||
SchemaTransformation.transform<ReadonlyArray<Element["Encoded"]>, ReadonlyArray<unknown>>({
|
||||
decode: (values) =>
|
||||
values.filter((value) => Option.isSome(decodeElement(value))) as ReadonlyArray<
|
||||
Element["Encoded"]
|
||||
>,
|
||||
encode: (values) => values,
|
||||
}),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a branded identifier. Enforces non-empty trimmed strings
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ const decode = <S extends Schema.Top>(
|
||||
>;
|
||||
|
||||
const decodeResolvedRule = Schema.decodeUnknownEffect(ResolvedKeybindingRule as never);
|
||||
const encodeResolvedKeybindings = Schema.encodeEffect(ResolvedKeybindingsConfig);
|
||||
|
||||
it.effect("parses keybinding rules", () =>
|
||||
Effect.gen(function* () {
|
||||
@@ -185,6 +186,70 @@ it.effect("parses resolved keybindings arrays", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
const shortcut = {
|
||||
key: "p",
|
||||
metaKey: false,
|
||||
ctrlKey: false,
|
||||
shiftKey: false,
|
||||
altKey: false,
|
||||
modKey: true,
|
||||
};
|
||||
|
||||
it.effect("drops resolved rules with commands this build does not know", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decode(ResolvedKeybindingsConfig, [
|
||||
{ command: "terminal.toggle", shortcut },
|
||||
{ command: "someFuture.toggle", shortcut },
|
||||
{ command: "filePicker.toggle", shortcut },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
parsed.map((rule) => rule.command),
|
||||
["terminal.toggle", "filePicker.toggle"],
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("drops resolved rules with unknown when-node types", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decode(ResolvedKeybindingsConfig, [
|
||||
{
|
||||
command: "terminal.toggle",
|
||||
shortcut,
|
||||
whenAst: { type: "xor", left: 1, right: 2 },
|
||||
},
|
||||
{ command: "terminal.split", shortcut },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
parsed.map((rule) => rule.command),
|
||||
["terminal.split"],
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("drops malformed resolved rule entries", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decode(ResolvedKeybindingsConfig, [
|
||||
"garbage",
|
||||
{ command: "terminal.toggle", shortcut },
|
||||
null,
|
||||
]);
|
||||
assert.deepEqual(
|
||||
parsed.map((rule) => rule.command),
|
||||
["terminal.toggle"],
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("encodes resolved keybindings to the plain wire shape", () =>
|
||||
Effect.gen(function* () {
|
||||
const rules = [{ command: "terminal.toggle" as const, shortcut }];
|
||||
const encoded = yield* encodeResolvedKeybindings(rules);
|
||||
assert.deepEqual(encoded, rules);
|
||||
const roundTripped = yield* decode(ResolvedKeybindingsConfig, encoded);
|
||||
assert.deepEqual(roundTripped, rules);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("drops unknown fields in resolved keybinding rules", () =>
|
||||
decodeResolvedRule({
|
||||
command: "terminal.toggle",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Schema from "effect/Schema";
|
||||
import { TrimmedString } from "./baseSchemas.ts";
|
||||
import { ForwardCompatibleArray, TrimmedString } from "./baseSchemas.ts";
|
||||
|
||||
export const MAX_KEYBINDING_VALUE_LENGTH = 64;
|
||||
export const MAX_KEYBINDING_WHEN_LENGTH = 256;
|
||||
@@ -155,7 +155,14 @@ export const ResolvedKeybindingRule = Schema.Struct({
|
||||
}).annotate({ parseOptions: { onExcessProperty: "ignore" } });
|
||||
export type ResolvedKeybindingRule = typeof ResolvedKeybindingRule.Type;
|
||||
|
||||
export const ResolvedKeybindingsConfig = Schema.Array(ResolvedKeybindingRule).check(
|
||||
/**
|
||||
* The command set grows over time, so a client may receive rules it cannot
|
||||
* represent (a command or `when` node added after that client shipped).
|
||||
* Decoding drops those rules instead of failing the whole payload —
|
||||
* rejecting the config would take down the connection over a shortcut the
|
||||
* client couldn't dispatch anyway.
|
||||
*/
|
||||
export const ResolvedKeybindingsConfig = ForwardCompatibleArray(ResolvedKeybindingRule).check(
|
||||
Schema.isMaxLength(MAX_KEYBINDINGS_COUNT),
|
||||
);
|
||||
export type ResolvedKeybindingsConfig = typeof ResolvedKeybindingsConfig.Type;
|
||||
|
||||
@@ -204,11 +204,6 @@ export const ProjectReadFileResult = Schema.Struct({
|
||||
});
|
||||
export type ProjectReadFileResult = typeof ProjectReadFileResult.Type;
|
||||
|
||||
export const ProjectFileChangeEvent = Schema.Struct({
|
||||
relativePath: TrimmedNonEmptyString,
|
||||
});
|
||||
export type ProjectFileChangeEvent = typeof ProjectFileChangeEvent.Type;
|
||||
|
||||
export const ProjectFileFailure = Schema.Literals([
|
||||
"workspace_path_outside_root",
|
||||
"resolved_path_outside_root",
|
||||
@@ -221,12 +216,10 @@ export type ProjectFileFailure = typeof ProjectFileFailure.Type;
|
||||
export const ProjectFileOperation = Schema.Literals([
|
||||
"realpath-workspace-root",
|
||||
"realpath-target",
|
||||
"realpath-watch-directory",
|
||||
"open",
|
||||
"stat",
|
||||
"read",
|
||||
"close",
|
||||
"watch",
|
||||
"make-directory",
|
||||
"write-file",
|
||||
]);
|
||||
|
||||
@@ -73,7 +73,6 @@ import {
|
||||
ProjectListEntriesError,
|
||||
ProjectListEntriesInput,
|
||||
ProjectListEntriesResult,
|
||||
ProjectFileChangeEvent,
|
||||
ProjectReadFileError,
|
||||
ProjectReadFileInput,
|
||||
ProjectReadFileResult,
|
||||
@@ -171,7 +170,6 @@ export const WS_METHODS = {
|
||||
projectsListEntries: "projects.listEntries",
|
||||
projectsReadFile: "projects.readFile",
|
||||
projectsSearchContents: "projects.searchContents",
|
||||
projectsWatchFile: "projects.watchFile",
|
||||
projectsSearchEntries: "projects.searchEntries",
|
||||
projectsWriteFile: "projects.writeFile",
|
||||
|
||||
@@ -462,13 +460,6 @@ export const WsProjectsReadFileRpc = Rpc.make(WS_METHODS.projectsReadFile, {
|
||||
error: Schema.Union([ProjectReadFileError, EnvironmentAuthorizationError]),
|
||||
});
|
||||
|
||||
export const WsProjectsWatchFileRpc = Rpc.make(WS_METHODS.projectsWatchFile, {
|
||||
payload: ProjectReadFileInput,
|
||||
success: ProjectFileChangeEvent,
|
||||
error: Schema.Union([ProjectReadFileError, EnvironmentAuthorizationError]),
|
||||
stream: true,
|
||||
});
|
||||
|
||||
export const WsProjectsWriteFileRpc = Rpc.make(WS_METHODS.projectsWriteFile, {
|
||||
payload: ProjectWriteFileInput,
|
||||
success: ProjectWriteFileResult,
|
||||
@@ -821,7 +812,6 @@ export const WsRpcGroup = RpcGroup.make(
|
||||
WsProjectsListEntriesRpc,
|
||||
WsProjectsReadFileRpc,
|
||||
WsProjectsSearchContentsRpc,
|
||||
WsProjectsWatchFileRpc,
|
||||
WsProjectsSearchEntriesRpc,
|
||||
WsProjectsWriteFileRpc,
|
||||
WsShellOpenInEditorRpc,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import * as Schema from "effect/Schema";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ServerProvider } from "./server.ts";
|
||||
import { ServerConfig, ServerProvider, ServerUpsertKeybindingResult } from "./server.ts";
|
||||
|
||||
const decodeServerProvider = Schema.decodeUnknownSync(ServerProvider);
|
||||
const decodeUpsertKeybindingResult = Schema.decodeUnknownSync(ServerUpsertKeybindingResult);
|
||||
const decodeAvailableEditors = Schema.decodeUnknownSync(ServerConfig.fields.availableEditors);
|
||||
|
||||
describe("ServerProvider", () => {
|
||||
it("defaults capability arrays when decoding provider snapshots", () => {
|
||||
@@ -72,3 +74,25 @@ describe("ServerProvider", () => {
|
||||
expect(parsed.continuation?.groupKey).toBe("codex:home:/Users/julius/.codex");
|
||||
});
|
||||
});
|
||||
|
||||
describe("server config forward compatibility", () => {
|
||||
it("drops config issues with kinds this build does not know", () => {
|
||||
const parsed = decodeUpsertKeybindingResult({
|
||||
keybindings: [],
|
||||
issues: [
|
||||
{ kind: "keybindings.invalid-entry", message: "Bad entry", index: 2 },
|
||||
{ kind: "keybindings.future-issue", message: "From a newer server" },
|
||||
],
|
||||
});
|
||||
|
||||
expect(parsed.issues).toEqual([
|
||||
{ kind: "keybindings.invalid-entry", message: "Bad entry", index: 2 },
|
||||
]);
|
||||
});
|
||||
|
||||
it("drops editor ids this build does not know", () => {
|
||||
const parsed = decodeAvailableEditors(["zed", "some-future-editor", "vscode"]);
|
||||
|
||||
expect(parsed).toEqual(["zed", "vscode"]);
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import * as Schema from "effect/Schema";
|
||||
import { ExecutionEnvironmentDescriptor, ServerSelfUpdateMethod } from "./environment.ts";
|
||||
import { ServerAuthDescriptor } from "./auth.ts";
|
||||
import {
|
||||
ForwardCompatibleArray,
|
||||
IsoDateTime,
|
||||
NonNegativeInt,
|
||||
PositiveInt,
|
||||
@@ -38,7 +39,9 @@ export const ServerConfigIssue = Schema.Union([
|
||||
]);
|
||||
export type ServerConfigIssue = typeof ServerConfigIssue.Type;
|
||||
|
||||
const ServerConfigIssues = Schema.Array(ServerConfigIssue);
|
||||
// Issue kinds grow over time; older clients must not fail the whole config
|
||||
// decode over a kind they cannot render.
|
||||
const ServerConfigIssues = ForwardCompatibleArray(ServerConfigIssue);
|
||||
|
||||
export const ServerProviderState = Schema.Literals(["ready", "warning", "error", "disabled"]);
|
||||
export type ServerProviderState = typeof ServerProviderState.Type;
|
||||
@@ -417,7 +420,9 @@ export const ServerConfig = Schema.Struct({
|
||||
keybindings: ResolvedKeybindingsConfig,
|
||||
issues: ServerConfigIssues,
|
||||
providers: ServerProviders,
|
||||
availableEditors: Schema.Array(EditorId),
|
||||
// Editor ids grow over time; drop ones this build does not know rather than
|
||||
// failing the whole config decode.
|
||||
availableEditors: ForwardCompatibleArray(EditorId),
|
||||
observability: ServerObservability,
|
||||
settings: ServerSettings,
|
||||
/** Whether shell subscriptions can emit an opt-in catch-up completion marker. */
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { isProjectFaviconFallbackUrl, PROJECT_FAVICON_FALLBACK_MARKER } from "./projectFavicon.ts";
|
||||
import {
|
||||
getProjectFaviconCacheKey,
|
||||
isProjectFaviconFallbackUrl,
|
||||
PROJECT_FAVICON_FALLBACK_MARKER,
|
||||
} from "./projectFavicon.ts";
|
||||
|
||||
describe("project favicon", () => {
|
||||
it("uses the project and versioned filename as the cache identity", () => {
|
||||
const firstUrl = "https://environment.example/api/assets/first-signed-token/v1-20-favicon.svg";
|
||||
const refreshedUrl =
|
||||
"https://environment.example/api/assets/refreshed-signed-token/v1-20-favicon.svg";
|
||||
|
||||
expect(getProjectFaviconCacheKey("environment-1", "/workspace", firstUrl)).toBe(
|
||||
getProjectFaviconCacheKey("environment-1", "/workspace", refreshedUrl),
|
||||
);
|
||||
expect(getProjectFaviconCacheKey("environment-1", "/workspace", firstUrl)).not.toBe(
|
||||
getProjectFaviconCacheKey(
|
||||
"environment-1",
|
||||
"/workspace",
|
||||
"https://environment.example/api/assets/refreshed-signed-token/v2-20-favicon.svg",
|
||||
),
|
||||
);
|
||||
expect(getProjectFaviconCacheKey("environment-1", "/workspace", firstUrl)).not.toBe(
|
||||
getProjectFaviconCacheKey("environment-2", "/workspace", firstUrl),
|
||||
);
|
||||
});
|
||||
|
||||
it("identifies fallback asset URLs by their dedicated filename", () => {
|
||||
expect(
|
||||
isProjectFaviconFallbackUrl(
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
export const PROJECT_FAVICON_FALLBACK_MARKER = "project-favicon-missing";
|
||||
|
||||
export function getProjectFaviconCacheKey(
|
||||
environmentId: string,
|
||||
workspaceRoot: string,
|
||||
url: string,
|
||||
) {
|
||||
let revision = url;
|
||||
|
||||
try {
|
||||
const pathname = new URL(url, "https://t3.invalid").pathname;
|
||||
revision = pathname.slice(pathname.lastIndexOf("/") + 1);
|
||||
} catch {
|
||||
// Keep the full value as a safe fallback for malformed URLs.
|
||||
}
|
||||
|
||||
return JSON.stringify([environmentId, workspaceRoot, revision]);
|
||||
}
|
||||
|
||||
export function isProjectFaviconFallbackUrl(url: string | null | undefined): boolean {
|
||||
if (!url) return false;
|
||||
|
||||
|
||||
@@ -57,6 +57,15 @@ Done.`),
|
||||
expect(() => decodeLenientJson('{ "enabled": true,, }')).toThrow();
|
||||
});
|
||||
|
||||
it("preserves commas before brackets inside string values", () => {
|
||||
// A comma inside a string value that happens to precede `}`/`]` must not
|
||||
// be stripped as if it were a trailing comma.
|
||||
expect(decodeLenientJson('{"note":"a,]"}')).toEqual({ note: "a,]" });
|
||||
expect(decodeLenientJson('{"list":["x,}"]}')).toEqual({ list: ["x,}"] });
|
||||
// Genuine trailing commas are still removed.
|
||||
expect(decodeLenientJson('{"values":[1, 2,],}')).toEqual({ values: [1, 2] });
|
||||
});
|
||||
|
||||
it("formats schema failures with paths without exposing invalid values", () => {
|
||||
const decodeCredential = decodeJsonResult(Schema.Struct({ token: Schema.Number }));
|
||||
const decoded = decodeCredential('{"token":"credential=secret-value"}');
|
||||
|
||||
@@ -190,8 +190,14 @@ const parseLenientJsonGetter = SchemaGetter.onSome((input: string) => {
|
||||
(match, stringLiteral: string | undefined) => (stringLiteral ? match : ""),
|
||||
);
|
||||
|
||||
// Strip trailing commas before `}` or `]`.
|
||||
stripped = stripped.replace(/,(\s*[}\]])/g, "$1");
|
||||
// Strip trailing commas before `}` or `]`. The alternation preserves quoted
|
||||
// strings so a comma inside a string value (e.g. `{"note":"a,]"}`) is not
|
||||
// mistaken for a trailing comma and removed.
|
||||
stripped = stripped.replace(
|
||||
/("(?:[^"\\]|\\.)*")|,(\s*[}\]])/g,
|
||||
(match, stringLiteral: string | undefined, bracket: string | undefined) =>
|
||||
stringLiteral ? match : (bracket ?? ""),
|
||||
);
|
||||
|
||||
return decodeJsonString(stripped).pipe(
|
||||
Effect.map(Option.some),
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { compareSemverVersions, normalizeSemverVersion, satisfiesSemverRange } from "./semver.ts";
|
||||
import {
|
||||
compareSemverVersions,
|
||||
normalizeSemverVersion,
|
||||
parseSemver,
|
||||
satisfiesSemverRange,
|
||||
} from "./semver.ts";
|
||||
|
||||
describe("semver helpers", () => {
|
||||
it("matches supported range groups", () => {
|
||||
@@ -18,6 +23,25 @@ describe("semver helpers", () => {
|
||||
expect(normalizeSemverVersion("2.1")).toBe("2.1.0");
|
||||
});
|
||||
|
||||
it("normalizes and parses shorthand major-only versions", () => {
|
||||
expect(normalizeSemverVersion("20")).toBe("20.0.0");
|
||||
expect(normalizeSemverVersion("v18")).toBe("v18.0.0");
|
||||
expect(normalizeSemverVersion("20-rc.1")).toBe("20.0.0-rc.1");
|
||||
expect(parseSemver("20")).toEqual({ major: 20, minor: 0, patch: 0, prerelease: [] });
|
||||
});
|
||||
|
||||
it("compares shorthand versions numerically instead of lexically", () => {
|
||||
// Regression: "20" vs "9" previously fell back to string comparison, which
|
||||
// ordered "20" before "9" ("2" < "9").
|
||||
expect(compareSemverVersions("20", "9")).toBeGreaterThan(0);
|
||||
expect(compareSemverVersions("18", "18.0.0")).toBe(0);
|
||||
});
|
||||
|
||||
it("still rejects non-numeric shorthand and keeps empty input empty", () => {
|
||||
expect(parseSemver("abc")).toBeNull();
|
||||
expect(normalizeSemverVersion("")).toBe("");
|
||||
});
|
||||
|
||||
it("compares prerelease versions before stable versions", () => {
|
||||
expect(compareSemverVersions("2.1.111-beta.1", "2.1.111")).toBeLessThan(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,12 @@ export function normalizeSemverVersion(version: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
if (segments.length === 2) {
|
||||
// Pad shorthand versions ("20" or "20.1") up to three segments so major-only
|
||||
// and minor-only inputs parse and compare numerically. This matches
|
||||
// satisfiesSemverRange, which already treats a missing minor/patch as 0. The
|
||||
// length > 0 guard keeps empty/garbage input empty (parseSemver still
|
||||
// rejects it), and inputs with more than three segments are left untouched.
|
||||
while (segments.length > 0 && segments.length < 3) {
|
||||
segments.push("0");
|
||||
}
|
||||
|
||||
|
||||
Generated
+48
-48
@@ -35,19 +35,19 @@ catalogs:
|
||||
version: 0.2.2
|
||||
|
||||
overrides:
|
||||
'@clerk/backend': 3.13.0
|
||||
'@clerk/clerk-js': 6.25.7
|
||||
'@clerk/backend': 3.14.0
|
||||
'@clerk/clerk-js': 6.25.12
|
||||
'@clerk/clerk-js>@base-org/account': '-'
|
||||
'@clerk/clerk-js>@coinbase/wallet-sdk': '-'
|
||||
'@clerk/clerk-js>@solana/wallet-adapter-base': '-'
|
||||
'@clerk/clerk-js>@solana/wallet-adapter-react': '-'
|
||||
'@clerk/clerk-js>@solana/wallet-standard': '-'
|
||||
'@clerk/clerk-js>@wallet-standard/core': '-'
|
||||
'@clerk/electron': 0.0.18
|
||||
'@clerk/electron': 0.0.24
|
||||
'@clerk/electron-passkeys': 0.0.3
|
||||
'@clerk/expo': 4.0.2
|
||||
'@clerk/react': 6.12.7
|
||||
'@clerk/shared': 4.25.7
|
||||
'@clerk/expo': 4.1.2
|
||||
'@clerk/react': 6.12.9
|
||||
'@clerk/shared': 4.25.9
|
||||
'@effect/atom-react': 4.0.0-beta.102
|
||||
'@effect/platform-bun': 4.0.0-beta.102
|
||||
'@effect/platform-node': 4.0.0-beta.102
|
||||
@@ -111,8 +111,8 @@ importers:
|
||||
apps/desktop:
|
||||
dependencies:
|
||||
'@clerk/electron':
|
||||
specifier: 0.0.18
|
||||
version: 0.0.18(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])
|
||||
specifier: 0.0.24
|
||||
version: 0.0.24(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])
|
||||
'@clerk/electron-passkeys':
|
||||
specifier: 0.0.3
|
||||
version: 0.0.3
|
||||
@@ -197,8 +197,8 @@ importers:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
'@clerk/expo':
|
||||
specifier: 4.0.2
|
||||
version: 4.0.2([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])([email protected])
|
||||
specifier: 4.1.2
|
||||
version: 4.1.2([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])([email protected])
|
||||
'@effect/atom-react':
|
||||
specifier: 4.0.0-beta.102
|
||||
version: 4.0.0-beta.102([email protected](patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488))([email protected])([email protected])
|
||||
@@ -514,11 +514,11 @@ importers:
|
||||
specifier: ^1.4.1
|
||||
version: 1.5.0(@types/[email protected])([email protected]([email protected]))([email protected])
|
||||
'@clerk/electron':
|
||||
specifier: 0.0.18
|
||||
version: 0.0.18(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])
|
||||
specifier: 0.0.24
|
||||
version: 0.0.24(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])
|
||||
'@clerk/react':
|
||||
specifier: 6.12.7
|
||||
version: 6.12.7([email protected]([email protected]))([email protected])
|
||||
specifier: 6.12.9
|
||||
version: 6.12.9([email protected]([email protected]))([email protected])
|
||||
'@dnd-kit/core':
|
||||
specifier: ^6.3.1
|
||||
version: 6.3.1([email protected]([email protected]))([email protected])
|
||||
@@ -668,8 +668,8 @@ importers:
|
||||
infra/relay:
|
||||
dependencies:
|
||||
'@clerk/backend':
|
||||
specifier: 3.13.0
|
||||
version: 3.13.0([email protected]([email protected]))([email protected])
|
||||
specifier: 3.14.0
|
||||
version: 3.14.0([email protected]([email protected]))([email protected])
|
||||
'@effect/sql-pg':
|
||||
specifier: 4.0.0-beta.102
|
||||
version: 4.0.0-beta.102([email protected](patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488))
|
||||
@@ -1695,12 +1695,12 @@ packages:
|
||||
resolution: {integrity: sha512-EYlRokl8szrP9Z25qT5aepMdBjzBvHF9ZEhzIiUBc9guz/T31EqRgvD0QSgZcpE93xiwrr+OkB4nz0BZyF6fSA==}
|
||||
engines: {node: '>= 20.12.0'}
|
||||
|
||||
'@clerk/[email protected]3.0':
|
||||
resolution: {integrity: sha512-kYOgeR48iXYypudpYITE0L2yxi4TeFXU+ISAOULlVgOcurw8qnm1/JEuK6Mr2IFUbRS9hcHk1HVO0Ceo0XmL8Q==}
|
||||
'@clerk/[email protected]4.0':
|
||||
resolution: {integrity: sha512-WsphTvDFHDuQilKI7dyVE5qmt7USu8qSrujAq6SqpEHbVFfNBfINDNuzxlF9M2skOTfHFfgiTE8Jjb1egIBGLg==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
|
||||
'@clerk/[email protected].7':
|
||||
resolution: {integrity: sha512-GOnbEUzPKAdsdCodZsHhku2YloBBuwLGx5UP0VeezUj73wKLwlSYMlVPuntsJoY7c8+lVrMCY9LQWYVZ7VMLBw==}
|
||||
'@clerk/[email protected].12':
|
||||
resolution: {integrity: sha512-N91mFKenMF5e+LRQ0NsqFb8bw+icbwnF8MzjzS4cux72xG4Gekh772tiLIetbURe44Srgjw5lj8jkWbt+yH/FA==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
|
||||
'@clerk/[email protected]':
|
||||
@@ -1727,8 +1727,8 @@ packages:
|
||||
resolution: {integrity: sha512-OHhIe88qDL+FxyBalXdXNHAS5eEramr6Rerp+6iNkfkjqT8rx4hHNmfpmjg5/T1/am8QfknbOBZkqoXZlCrjPg==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
|
||||
'@clerk/[email protected].18':
|
||||
resolution: {integrity: sha512-0lWiITlTxCviglPfPSu+uhERnQyXroiWrSMRpZcEO3FgBt3bnrpfgZUrXW8iaLoUYJrFP2byF7bHJPRwEPVXEw==}
|
||||
'@clerk/[email protected].24':
|
||||
resolution: {integrity: sha512-xORO51KLzCqmRQ4IVsa+Amp1M5NjG28QnvsaRBq1v4CUEjH8vAXDKCPiPBKAE+HuQB6HUhzYmzUkyTw2FcDonw==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
peerDependencies:
|
||||
'@clerk/electron-passkeys': 0.0.3
|
||||
@@ -1744,8 +1744,8 @@ packages:
|
||||
react-dom:
|
||||
optional: true
|
||||
|
||||
'@clerk/expo@4.0.2':
|
||||
resolution: {integrity: sha512-afBdV2bLRM55p5L7FoAGV/wCamLxXusjIBPmNo+TwAYabU0oUokMsm+0++xWDA0nxzMt/O08Oj+xAGEtE+Qvxg==}
|
||||
'@clerk/expo@4.1.2':
|
||||
resolution: {integrity: sha512-ZyGozbbizcGwEyK0CEXsPHnHnQoaa2CbTsXAqWBygzKEZyFjLjCHwQsQBKj6WgjAgn8mtw2ByIP9qLpItZffgw==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
peerDependencies:
|
||||
'@clerk/expo-google-signin': '>=0.1.0'
|
||||
@@ -1783,15 +1783,15 @@ packages:
|
||||
react-dom:
|
||||
optional: true
|
||||
|
||||
'@clerk/[email protected].7':
|
||||
resolution: {integrity: sha512-K8CK0tS7My/3RT5sAIJTjYgnH0xU+K4Jdnhi76xQdAY4agD/M07BbrBMWXEE0xUEDst2PqPfX660V1LRLOsxOQ==}
|
||||
'@clerk/[email protected].9':
|
||||
resolution: {integrity: sha512-lQ1UOJhHGDweLCDf4IgT5r3rgkch1Gx21hNqK2/kOohJrJd/XM89fq2F7VK9Kg/Byc14TsfCh64Dm8ej2MyRWw==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
peerDependencies:
|
||||
react: ^18.0.0 || ~19.0.3 || ~19.1.4 || ~19.2.3 || ~19.3.0-0
|
||||
react-dom: ^18.0.0 || ~19.0.3 || ~19.1.4 || ~19.2.3 || ~19.3.0-0
|
||||
|
||||
'@clerk/[email protected].7':
|
||||
resolution: {integrity: sha512-FfBbDeFkxwDuz/2YcVs4DhyZ0VxnqNtdbO0Tn/lkLAiDvFFspWw+PDYqo7LQiBymEQaOQkb094dX21WWnZbmlA==}
|
||||
'@clerk/[email protected].9':
|
||||
resolution: {integrity: sha512-nw3maGzqPrwmUKjGffOM9Zvw24IyOllq0TkQGzsTfQX312WLu2u5CNvjKntMb6Ok6kXa1Zdc77zmPLn1/EAIFA==}
|
||||
engines: {node: '>=20.9.0'}
|
||||
peerDependencies:
|
||||
react: ^18.0.0 || ~19.0.3 || ~19.1.4 || ~19.2.3 || ~19.3.0-0
|
||||
@@ -11512,18 +11512,18 @@ snapshots:
|
||||
fast-wrap-ansi: 0.2.2
|
||||
sisteransi: 1.0.5
|
||||
|
||||
'@clerk/[email protected]3.0([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected]4.0([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
standardwebhooks: 1.0.0
|
||||
tslib: 2.8.1
|
||||
transitivePeerDependencies:
|
||||
- react
|
||||
- react-dom
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].12([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
'@stripe/stripe-js': 5.6.0
|
||||
'@swc/helpers': 0.5.21
|
||||
'@tanstack/query-core': 5.100.14
|
||||
@@ -11538,9 +11538,9 @@ snapshots:
|
||||
- react
|
||||
- react-dom
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].12([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
'@stripe/stripe-js': 5.6.0
|
||||
'@swc/helpers': 0.5.21
|
||||
'@tanstack/query-core': 5.100.14
|
||||
@@ -11574,11 +11574,11 @@ snapshots:
|
||||
'@clerk/electron-passkeys-win32-arm64-msvc': 0.0.3
|
||||
'@clerk/electron-passkeys-win32-x64-msvc': 0.0.3
|
||||
|
||||
'@clerk/[email protected].18(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].24(@clerk/[email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/clerk-js': 6.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/react': 6.12.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/clerk-js': 6.25.12([email protected]([email protected]))([email protected])
|
||||
'@clerk/react': 6.12.9([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
electron: 41.5.0
|
||||
react: 19.2.6
|
||||
tslib: 2.8.1
|
||||
@@ -11587,11 +11587,11 @@ snapshots:
|
||||
electron-store: 8.2.0
|
||||
react-dom: 19.2.6([email protected])
|
||||
|
||||
'@clerk/expo@4.0.2([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])([email protected])':
|
||||
'@clerk/expo@4.1.2([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected])([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])))([email protected])([email protected]([email protected]))([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@clerk/clerk-js': 6.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/react': 6.12.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/clerk-js': 6.25.12([email protected]([email protected]))([email protected])
|
||||
'@clerk/react': 6.12.9([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
'@expo/config-plugins': 56.0.9([email protected])
|
||||
base-64: 1.0.0
|
||||
expo: 56.0.12(8895228379997a2a064f9644cda56ed0)
|
||||
@@ -11610,21 +11610,21 @@ snapshots:
|
||||
- supports-color
|
||||
- typescript
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].9([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
react: 19.2.3
|
||||
react-dom: 19.2.3([email protected])
|
||||
tslib: 2.8.1
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].9([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@clerk/shared': 4.25.7([email protected]([email protected]))([email protected])
|
||||
'@clerk/shared': 4.25.9([email protected]([email protected]))([email protected])
|
||||
react: 19.2.6
|
||||
react-dom: 19.2.6([email protected])
|
||||
tslib: 2.8.1
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].9([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@tanstack/query-core': 5.100.14
|
||||
dequal: 2.0.3
|
||||
@@ -11634,7 +11634,7 @@ snapshots:
|
||||
react: 19.2.3
|
||||
react-dom: 19.2.3([email protected])
|
||||
|
||||
'@clerk/[email protected].7([email protected]([email protected]))([email protected])':
|
||||
'@clerk/[email protected].9([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
'@tanstack/query-core': 5.100.14
|
||||
dequal: 2.0.3
|
||||
|
||||
+12
-12
@@ -23,13 +23,13 @@ allowBuilds:
|
||||
workerd: false
|
||||
|
||||
catalog:
|
||||
"@clerk/backend": 3.13.0
|
||||
"@clerk/clerk-js": 6.25.7
|
||||
"@clerk/electron": 0.0.18
|
||||
"@clerk/backend": 3.14.0
|
||||
"@clerk/clerk-js": 6.25.12
|
||||
"@clerk/electron": 0.0.24
|
||||
"@clerk/electron-passkeys": 0.0.3
|
||||
"@clerk/expo": 4.0.2
|
||||
"@clerk/react": 6.12.7
|
||||
"@clerk/shared": 4.25.7
|
||||
"@clerk/expo": 4.1.2
|
||||
"@clerk/react": 6.12.9
|
||||
"@clerk/shared": 4.25.9
|
||||
"@effect/atom-react": 4.0.0-beta.102
|
||||
"@effect/openapi-generator": 4.0.0-beta.102
|
||||
"@effect/platform-bun": 4.0.0-beta.102
|
||||
@@ -52,12 +52,12 @@ catalog:
|
||||
yaml: ^2.9.0
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- "@clerk/[email protected]3.0"
|
||||
- "@clerk/[email protected].7"
|
||||
- "@clerk/[email protected].18"
|
||||
- "@clerk/expo@4.0.2"
|
||||
- "@clerk/[email protected].7"
|
||||
- "@clerk/[email protected].7"
|
||||
- "@clerk/[email protected]4.0"
|
||||
- "@clerk/[email protected].12"
|
||||
- "@clerk/[email protected].24"
|
||||
- "@clerk/expo@4.1.2"
|
||||
- "@clerk/[email protected].9"
|
||||
- "@clerk/[email protected].9"
|
||||
- "@distilled.cloud/[email protected]"
|
||||
- "@distilled.cloud/[email protected]"
|
||||
- "@distilled.cloud/[email protected]"
|
||||
|
||||
@@ -349,6 +349,11 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
assert.notProperty(mac, "asarUnpack");
|
||||
assert.notProperty(linux, "asarUnpack");
|
||||
assert.deepStrictEqual(win.asarUnpack, WINDOWS_ASAR_UNPACK);
|
||||
// Linux must register the renderer schemes so the generated .desktop
|
||||
// entry advertises MimeType=x-scheme-handler/t3code; for OAuth deep links.
|
||||
assert.deepStrictEqual((linux.linux as Record<string, unknown>).protocols, [
|
||||
{ name: "T3 Code", schemes: ["t3code", "t3code-dev"] },
|
||||
]);
|
||||
for (const config of [mac, linux, win]) {
|
||||
assert.deepStrictEqual(config.electronLanguages, DESKTOP_ELECTRON_LANGUAGES);
|
||||
assert.deepStrictEqual(config.files, DESKTOP_FILE_EXCLUSIONS);
|
||||
|
||||
@@ -1589,6 +1589,15 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
executableName: "t3code",
|
||||
icon: "icons",
|
||||
category: "Development",
|
||||
// electron-builder turns these into MimeType=x-scheme-handler/<scheme>;
|
||||
// in the .desktop entry (Exec already gets %U), so browsers can hand
|
||||
// t3code:// OAuth callbacks to the app.
|
||||
protocols: [
|
||||
{
|
||||
name: "T3 Code",
|
||||
schemes: ["t3code", "t3code-dev"],
|
||||
},
|
||||
],
|
||||
desktop: {
|
||||
entry: {
|
||||
StartupWMClass: "t3code",
|
||||
|
||||
@@ -244,22 +244,19 @@ it("selects a reachable LAN IPv4 address", () => {
|
||||
});
|
||||
|
||||
it("maps capture scenes to the real application routes", () => {
|
||||
assert.equal(showcaseSceneUrl("threads", "environment-1"), "t3code-dev://");
|
||||
assert.equal(
|
||||
showcaseSceneUrl("environments", "environment-1"),
|
||||
"t3code-dev://settings/environments",
|
||||
);
|
||||
assert.equal(showcaseSceneUrl("threads", "environment-1"), "t3code://");
|
||||
assert.equal(showcaseSceneUrl("environments", "environment-1"), "t3code://settings/environments");
|
||||
assert.equal(
|
||||
showcaseSceneUrl("thread", "environment-1"),
|
||||
"t3code-dev://threads/environment-1/remote-command-center",
|
||||
"t3code://threads/environment-1/remote-command-center",
|
||||
);
|
||||
assert.equal(
|
||||
showcaseSceneUrl("terminal", "environment-1"),
|
||||
"t3code-dev://threads/environment-1/remote-command-center/terminal?terminalId=term-1",
|
||||
"t3code://threads/environment-1/remote-command-center/terminal?terminalId=term-1",
|
||||
);
|
||||
assert.equal(
|
||||
showcaseSceneUrl("review", "environment-1"),
|
||||
"t3code-dev://threads/environment-1/remote-command-center/review",
|
||||
"t3code://threads/environment-1/remote-command-center/review",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -31,14 +31,14 @@ import {
|
||||
|
||||
const REPO_ROOT = NodePath.resolve(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), "..");
|
||||
const MOBILE_ROOT = NodePath.join(REPO_ROOT, "apps/mobile");
|
||||
const ANDROID_PACKAGE = "com.t3tools.t3code.dev";
|
||||
const APP_SCHEME = "t3code-dev";
|
||||
const ANDROID_PACKAGE = "com.t3tools.t3code";
|
||||
const APP_SCHEME = "t3code";
|
||||
const IOS_READY_FILENAME = "T3ShowcaseReadyScene";
|
||||
const SERVER_HOST = "0.0.0.0";
|
||||
const IOS_SIMULATOR_ARCH = NodeProcess.arch === "arm64" ? "arm64" : "x86_64";
|
||||
const IOS_APP_PATH = NodePath.join(
|
||||
MOBILE_ROOT,
|
||||
".showcase/ios-derived-data/Build/Products/Debug-iphonesimulator/T3CodeDev.app",
|
||||
".showcase/ios-derived-data/Build/Products/Debug-iphonesimulator/T3Code.app",
|
||||
);
|
||||
const ANDROID_APK_PATH = NodePath.join(
|
||||
MOBILE_ROOT,
|
||||
@@ -58,7 +58,7 @@ const ANDROID_SDK_ROOT = resolveAndroidSdkRoot(NodeProcess.env);
|
||||
const MOBILE_BUILD_ENV = {
|
||||
...NodeProcess.env,
|
||||
ANDROID_HOME: ANDROID_SDK_ROOT,
|
||||
APP_VARIANT: "development",
|
||||
APP_VARIANT: "production",
|
||||
EXPO_NO_GIT_STATUS: "1",
|
||||
JAVA_HOME:
|
||||
NodeProcess.env.JAVA_HOME ??
|
||||
@@ -664,9 +664,9 @@ async function buildIos(): Promise<string> {
|
||||
"xcodebuild",
|
||||
[
|
||||
"-workspace",
|
||||
NodePath.join(MOBILE_ROOT, "ios/T3CodeDev.xcworkspace"),
|
||||
NodePath.join(MOBILE_ROOT, "ios/T3Code.xcworkspace"),
|
||||
"-scheme",
|
||||
"T3CodeDev",
|
||||
"T3Code",
|
||||
"-configuration",
|
||||
"Debug",
|
||||
"-sdk",
|
||||
|
||||
Reference in new issue
Block a user