Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea7294bea7 | ||
|
|
51f3403bc5 |
No files matched your search
@@ -1,134 +0,0 @@
|
||||
name: Mobile Showcase Screenshots
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
platform:
|
||||
description: Device platforms to capture
|
||||
required: true
|
||||
default: all
|
||||
type: choice
|
||||
options:
|
||||
- all
|
||||
- ios
|
||||
- android
|
||||
appearance:
|
||||
description: System appearances to capture
|
||||
required: true
|
||||
default: both
|
||||
type: choice
|
||||
options:
|
||||
- both
|
||||
- dark
|
||||
- light
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=8192
|
||||
|
||||
jobs:
|
||||
ios:
|
||||
name: iPhone 6.9, iPhone 6.5, and iPad 13
|
||||
if: inputs.platform == 'all' || inputs.platform == 'ios'
|
||||
runs-on: blacksmith-12vcpu-macos-26
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
|
||||
vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
|
||||
echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
|
||||
"$vp_pnpm_bin/pnpm" --version
|
||||
|
||||
- name: Capture iOS showcase
|
||||
run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}"
|
||||
|
||||
- name: Validate App Store Connect assets
|
||||
run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --validate-only
|
||||
|
||||
- name: Upload iOS screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: app-store-connect-screenshots
|
||||
path: artifacts/app-store/screenshots/apple/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
android:
|
||||
name: Android phone, 7-inch tablet, and 10-inch tablet
|
||||
if: inputs.platform == 'all' || inputs.platform == 'android'
|
||||
runs-on: blacksmith-16vcpu-ubuntu-2404
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
T3_SHOWCASE_ANDROID_ABI: x86_64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
|
||||
vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
|
||||
echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
|
||||
"$vp_pnpm_bin/pnpm" --version
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- name: Setup Gradle cache
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
|
||||
- name: Enable KVM
|
||||
run: |
|
||||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS="static_node=kvm"' \
|
||||
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger --name-match=kvm
|
||||
|
||||
- name: Capture Android showcase
|
||||
uses: reactivecircus/android-emulator-runner@v2
|
||||
with:
|
||||
api-level: 36
|
||||
target: google_apis
|
||||
arch: x86_64
|
||||
profile: pixel_7_pro
|
||||
avd-name: Pixel_10_Pro
|
||||
cores: 8
|
||||
ram-size: 4096M
|
||||
disable-animations: false
|
||||
script: pnpm screenshots:mobile --platform android --appearance "${{ inputs.appearance }}"
|
||||
|
||||
- name: Validate Google Play assets
|
||||
run: pnpm screenshots:mobile --platform android --appearance "${{ inputs.appearance }}" --validate-only
|
||||
|
||||
- name: Upload Android screenshots
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: google-play-screenshots
|
||||
path: artifacts/app-store/screenshots/google-play/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
@@ -27,9 +27,6 @@ squashfs-root/
|
||||
.gstack/
|
||||
dist-electron/
|
||||
.electron-runtime/
|
||||
.showcase/
|
||||
apps/mobile/.showcase/
|
||||
artifacts/app-store/screenshots/
|
||||
node_modules/
|
||||
.alchemy/
|
||||
*.log
|
||||
|
||||
@@ -20,7 +20,7 @@ export const APP_BUNDLE_ID = isDevelopment
|
||||
? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
|
||||
: "com.t3tools.t3code";
|
||||
const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
|
||||
const LAUNCHER_VERSION = 14;
|
||||
const LAUNCHER_VERSION = 12;
|
||||
const defaultIconPath = NodePath.join(desktopDir, "resources", "icon.icns");
|
||||
const developmentMacIconPngPath = NodePath.join(
|
||||
repoRoot,
|
||||
@@ -220,12 +220,11 @@ function ensureDevelopmentIconIcns(runtimeDir) {
|
||||
}
|
||||
}
|
||||
|
||||
function patchMainBundleInfoPlist(appBundlePath, iconPath, executableName) {
|
||||
function patchMainBundleInfoPlist(appBundlePath, iconPath) {
|
||||
const infoPlistPath = NodePath.join(appBundlePath, "Contents", "Info.plist");
|
||||
setPlistString(infoPlistPath, "CFBundleDisplayName", APP_DISPLAY_NAME);
|
||||
setPlistString(infoPlistPath, "CFBundleName", APP_DISPLAY_NAME);
|
||||
setPlistString(infoPlistPath, "CFBundleIdentifier", APP_BUNDLE_ID);
|
||||
setPlistString(infoPlistPath, "CFBundleExecutable", executableName);
|
||||
setPlistString(infoPlistPath, "CFBundleIconFile", "icon.icns");
|
||||
setPlistJson(infoPlistPath, "CFBundleURLTypes", [
|
||||
{
|
||||
@@ -278,25 +277,11 @@ function readJson(path) {
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveMacLauncherPaths(appBundlePath, displayName = APP_DISPLAY_NAME) {
|
||||
const executableDir = NodePath.join(appBundlePath, "Contents", "MacOS");
|
||||
const launcherExecutableName = `${displayName} Launcher`;
|
||||
return {
|
||||
launcherExecutableName,
|
||||
launcherBinaryPath: NodePath.join(executableDir, launcherExecutableName),
|
||||
runtimeElectronBinaryPath: NodePath.join(executableDir, "Electron"),
|
||||
};
|
||||
}
|
||||
|
||||
function buildMacLauncher(electronBinaryPath) {
|
||||
const sourceAppBundlePath = NodePath.resolve(NodePath.dirname(electronBinaryPath), "../..");
|
||||
const runtimeDir = NodePath.join(desktopDir, ".electron-runtime");
|
||||
const targetAppBundlePath = NodePath.join(runtimeDir, `${APP_DISPLAY_NAME}.app`);
|
||||
const developmentPaths = resolveMacLauncherPaths(targetAppBundlePath);
|
||||
const runtimeElectronBinaryPath = developmentPaths.runtimeElectronBinaryPath;
|
||||
const launcherBinaryPath = isDevelopment
|
||||
? developmentPaths.launcherBinaryPath
|
||||
: runtimeElectronBinaryPath;
|
||||
const targetBinaryPath = NodePath.join(targetAppBundlePath, "Contents", "MacOS", "Electron");
|
||||
const iconPath = isDevelopment ? ensureDevelopmentIconIcns(runtimeDir) : defaultIconPath;
|
||||
const metadataPath = NodePath.join(runtimeDir, "metadata.json");
|
||||
|
||||
@@ -313,8 +298,7 @@ function buildMacLauncher(electronBinaryPath) {
|
||||
|
||||
const currentMetadata = readJson(metadataPath);
|
||||
if (
|
||||
NodeFS.existsSync(launcherBinaryPath) &&
|
||||
(!isDevelopment || NodeFS.existsSync(runtimeElectronBinaryPath)) &&
|
||||
NodeFS.existsSync(targetBinaryPath) &&
|
||||
currentMetadata &&
|
||||
JSON.stringify(currentMetadata) === JSON.stringify(expectedMetadata)
|
||||
) {
|
||||
@@ -322,10 +306,10 @@ function buildMacLauncher(electronBinaryPath) {
|
||||
// The launcher also handles protocol activations outside the dev runner,
|
||||
// so refresh its fallback environment on every launch. Never let a value
|
||||
// captured by an older parent app override the live dev-runner environment.
|
||||
writeDevelopmentLauncherScript(launcherBinaryPath, runtimeElectronBinaryPath);
|
||||
writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath);
|
||||
}
|
||||
registerMacLauncherBundle(targetAppBundlePath);
|
||||
return launcherBinaryPath;
|
||||
return targetBinaryPath;
|
||||
}
|
||||
|
||||
NodeFS.rmSync(targetAppBundlePath, { recursive: true, force: true });
|
||||
@@ -337,24 +321,15 @@ function buildMacLauncher(electronBinaryPath) {
|
||||
recursive: true,
|
||||
verbatimSymlinks: true,
|
||||
});
|
||||
patchMainBundleInfoPlist(
|
||||
targetAppBundlePath,
|
||||
iconPath,
|
||||
isDevelopment ? developmentPaths.launcherExecutableName : "Electron",
|
||||
);
|
||||
patchMainBundleInfoPlist(targetAppBundlePath, iconPath);
|
||||
patchHelperBundleInfoPlists(targetAppBundlePath);
|
||||
if (isDevelopment) {
|
||||
// Keep Electron's native executable inside the branded bundle. Launching the
|
||||
// node_modules copy makes macOS associate the process (and Dock label) with
|
||||
// Electron.app even though this bundle's Info.plist has the T3 Code name.
|
||||
// Its conventional executable name also keeps Electron's default-app runtime
|
||||
// in development mode instead of making app.isPackaged report true.
|
||||
writeDevelopmentLauncherScript(launcherBinaryPath, runtimeElectronBinaryPath);
|
||||
writeDevelopmentLauncherScript(targetBinaryPath, electronBinaryPath);
|
||||
}
|
||||
NodeFS.writeFileSync(metadataPath, `${JSON.stringify(expectedMetadata, null, 2)}\n`);
|
||||
registerMacLauncherBundle(targetAppBundlePath);
|
||||
|
||||
return launcherBinaryPath;
|
||||
return targetBinaryPath;
|
||||
}
|
||||
|
||||
function isLinuxSetuidSandboxConfigured(electronBinaryPath) {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { assert, describe, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
makeDevelopmentLauncherScript,
|
||||
resolveElectronBinaryPath,
|
||||
resolveMacLauncherPaths,
|
||||
} from "./electron-launcher.mjs";
|
||||
import { makeDevelopmentLauncherScript, resolveElectronBinaryPath } from "./electron-launcher.mjs";
|
||||
|
||||
describe("electron development launcher", () => {
|
||||
it("uses captured values only as fallbacks for a live runner environment", () => {
|
||||
@@ -49,33 +45,4 @@ describe("electron development launcher", () => {
|
||||
);
|
||||
assert.deepEqual(calls, ["ensure", "require:electron"]);
|
||||
});
|
||||
|
||||
it("keeps the native Electron executable name inside the branded macOS bundle", () => {
|
||||
const paths = resolveMacLauncherPaths(
|
||||
"/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app",
|
||||
"T3 Code (Dev)",
|
||||
);
|
||||
|
||||
assert.equal(paths.launcherExecutableName, "T3 Code (Dev) Launcher");
|
||||
assert.equal(
|
||||
paths.launcherBinaryPath,
|
||||
"/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/T3 Code (Dev) Launcher",
|
||||
);
|
||||
assert.equal(
|
||||
paths.runtimeElectronBinaryPath,
|
||||
"/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/Electron",
|
||||
);
|
||||
|
||||
const script = makeDevelopmentLauncherScript({
|
||||
electronBinaryPath: paths.runtimeElectronBinaryPath,
|
||||
mainEntryPath: "/repo/apps/desktop/dist-electron/main.cjs",
|
||||
desktopRoot: "/repo/apps/desktop",
|
||||
environment: {},
|
||||
});
|
||||
assert.include(
|
||||
script,
|
||||
"exec '/repo/apps/desktop/.electron-runtime/T3 Code (Dev).app/Contents/MacOS/Electron'",
|
||||
);
|
||||
assert.notInclude(script, "node_modules/electron");
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,6 @@ const { autoUpdaterMock } = vi.hoisted(() => ({
|
||||
autoInstallOnAppQuit: true,
|
||||
channel: "latest",
|
||||
disableDifferentialDownload: false,
|
||||
fullChangelog: false,
|
||||
checkForUpdates: vi.fn(() => Promise.resolve(null)),
|
||||
downloadUpdate: vi.fn(() => Promise.resolve([])),
|
||||
on: vi.fn(),
|
||||
@@ -34,7 +33,6 @@ describe("ElectronUpdater", () => {
|
||||
autoUpdaterMock.autoInstallOnAppQuit = true;
|
||||
autoUpdaterMock.channel = "latest";
|
||||
autoUpdaterMock.disableDifferentialDownload = false;
|
||||
autoUpdaterMock.fullChangelog = false;
|
||||
autoUpdaterMock.checkForUpdates.mockClear();
|
||||
autoUpdaterMock.checkForUpdates.mockImplementation(() => Promise.resolve(null));
|
||||
autoUpdaterMock.downloadUpdate.mockClear();
|
||||
@@ -100,18 +98,6 @@ describe("ElectronUpdater", () => {
|
||||
}).pipe(Effect.provide(ElectronUpdater.layer)),
|
||||
);
|
||||
|
||||
it.effect("sets full changelog mode", () =>
|
||||
Effect.gen(function* () {
|
||||
const updater = yield* ElectronUpdater.ElectronUpdater;
|
||||
|
||||
yield* updater.setFullChangelog(true);
|
||||
assert.equal(autoUpdaterMock.fullChangelog, true);
|
||||
|
||||
yield* updater.setFullChangelog(false);
|
||||
assert.equal(autoUpdaterMock.fullChangelog, false);
|
||||
}).pipe(Effect.provide(ElectronUpdater.layer)),
|
||||
);
|
||||
|
||||
it.effect("preserves quit-and-install flags and the execution-time channel", () =>
|
||||
Effect.gen(function* () {
|
||||
const cause = new Error("quit and install failed");
|
||||
|
||||
@@ -66,7 +66,6 @@ export class ElectronUpdater extends Context.Service<
|
||||
readonly setAllowPrerelease: (value: boolean) => Effect.Effect<void>;
|
||||
readonly allowDowngrade: Effect.Effect<boolean>;
|
||||
readonly setAllowDowngrade: (value: boolean) => Effect.Effect<void>;
|
||||
readonly setFullChangelog: (value: boolean) => Effect.Effect<void>;
|
||||
readonly setDisableDifferentialDownload: (value: boolean) => Effect.Effect<void>;
|
||||
readonly checkForUpdates: Effect.Effect<void, ElectronUpdaterCheckForUpdatesError>;
|
||||
readonly downloadUpdate: Effect.Effect<void, ElectronUpdaterDownloadUpdateError>;
|
||||
@@ -113,11 +112,6 @@ export const make = ElectronUpdater.of({
|
||||
autoUpdater.allowDowngrade = value;
|
||||
return Effect.void;
|
||||
}),
|
||||
setFullChangelog: (value) =>
|
||||
Effect.suspend(() => {
|
||||
autoUpdater.fullChangelog = value;
|
||||
return Effect.void;
|
||||
}),
|
||||
setDisableDifferentialDownload: (value) =>
|
||||
Effect.suspend(() => {
|
||||
autoUpdater.disableDifferentialDownload = value;
|
||||
|
||||
@@ -38,7 +38,6 @@ const flushCallbacks = Effect.yieldNow;
|
||||
function makeHarness(options: UpdatesHarnessOptions = {}) {
|
||||
let checkCount = 0;
|
||||
let allowDowngrade = false;
|
||||
let fullChangelog = false;
|
||||
const feedUrls: ElectronUpdater.ElectronUpdaterFeedUrl[] = [];
|
||||
const listeners = new Map<string, Set<(...args: readonly unknown[]) => void>>();
|
||||
const sentStates: DesktopUpdateState[] = [];
|
||||
@@ -74,10 +73,6 @@ function makeHarness(options: UpdatesHarnessOptions = {}) {
|
||||
Effect.sync(() => {
|
||||
allowDowngrade = value;
|
||||
}),
|
||||
setFullChangelog: (value) =>
|
||||
Effect.sync(() => {
|
||||
fullChangelog = value;
|
||||
}),
|
||||
setDisableDifferentialDownload: () => options.setDisableDifferentialDownload ?? Effect.void,
|
||||
checkForUpdates: Effect.sync(() => {
|
||||
checkCount += 1;
|
||||
@@ -191,7 +186,6 @@ function makeHarness(options: UpdatesHarnessOptions = {}) {
|
||||
layer,
|
||||
checkCount: () => checkCount,
|
||||
feedUrls: () => feedUrls,
|
||||
fullChangelog: () => fullChangelog,
|
||||
listenerCount: () =>
|
||||
Array.from(listeners.values()).reduce(
|
||||
(total, eventListeners) => total + eventListeners.size,
|
||||
@@ -293,49 +287,6 @@ describe("DesktopUpdates", () => {
|
||||
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
|
||||
});
|
||||
|
||||
it.effect("enables nightly full changelog release notes and broadcasts summaries", () => {
|
||||
const harness = makeHarness();
|
||||
|
||||
return Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const updates = yield* DesktopUpdates.DesktopUpdates;
|
||||
yield* updates.configure;
|
||||
|
||||
yield* updates.setChannel("nightly");
|
||||
assert.equal(harness.fullChangelog(), true);
|
||||
|
||||
harness.emit("update-available", {
|
||||
version: "1.2.4-nightly.20260709.766",
|
||||
releaseNotes: [
|
||||
{
|
||||
version: "1.2.4-nightly.20260709.766",
|
||||
note: `<h2>What's Changed</h2><ul><li>feat(client): persist offline environment data by <a>@juliusmarminge</a> in <a>#3795</a></li></ul><h2>Full Changelog</h2>`,
|
||||
},
|
||||
{
|
||||
version: "1.2.4-nightly.20260709.765",
|
||||
note: "- [codex] Upgrade Clerk stack by @juliusmarminge in #3821",
|
||||
},
|
||||
],
|
||||
});
|
||||
yield* flushCallbacks;
|
||||
|
||||
const state = yield* updates.getState;
|
||||
assert.equal(state.status, "available");
|
||||
assert.deepEqual(state.releaseNotes, [
|
||||
{
|
||||
version: "1.2.4-nightly.20260709.766",
|
||||
items: ["feat(client): persist offline environment data by @juliusmarminge in #3795"],
|
||||
},
|
||||
{
|
||||
version: "1.2.4-nightly.20260709.765",
|
||||
items: ["[codex] Upgrade Clerk stack by @juliusmarminge in #3821"],
|
||||
},
|
||||
]);
|
||||
assert.deepEqual(harness.sentStates.at(-1)?.releaseNotes, state.releaseNotes);
|
||||
}),
|
||||
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
|
||||
});
|
||||
|
||||
it.effect("keeps raw updater event failures out of update state", () => {
|
||||
const harness = makeHarness();
|
||||
const cause = new Error(
|
||||
|
||||
@@ -27,7 +27,6 @@ import * as ElectronUpdater from "../electron/ElectronUpdater.ts";
|
||||
import * as ElectronWindow from "../electron/ElectronWindow.ts";
|
||||
import * as IpcChannels from "../ipc/channels.ts";
|
||||
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
|
||||
import { normalizeDesktopUpdateReleaseNotes } from "./releaseNotes.ts";
|
||||
import { resolveDefaultDesktopUpdateChannel } from "./updateChannels.ts";
|
||||
import {
|
||||
createInitialDesktopUpdateState,
|
||||
@@ -50,10 +49,6 @@ type AppUpdateYmlConfig = typeof AppUpdateYmlConfig.Type;
|
||||
|
||||
const UpdateInfo = Schema.Struct({
|
||||
version: Schema.String,
|
||||
// Left unvalidated on purpose: a malformed release-notes payload must never
|
||||
// fail the decode and block the update state transition. The shape is
|
||||
// validated defensively in normalizeDesktopUpdateReleaseNotes.
|
||||
releaseNotes: Schema.optional(Schema.Unknown),
|
||||
});
|
||||
|
||||
const DownloadProgressInfo = Schema.Struct({
|
||||
@@ -335,12 +330,10 @@ export const make = Effect.gen(function* () {
|
||||
yield* electronUpdater.setChannel(channel);
|
||||
yield* electronUpdater.setAllowPrerelease(allowsPrerelease);
|
||||
yield* electronUpdater.setAllowDowngrade(allowsPrerelease);
|
||||
yield* electronUpdater.setFullChangelog(allowsPrerelease);
|
||||
yield* logUpdaterInfo("using update channel", {
|
||||
channel,
|
||||
allowPrerelease: allowsPrerelease,
|
||||
allowDowngrade: allowsPrerelease,
|
||||
fullChangelog: allowsPrerelease,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -574,15 +567,11 @@ export const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
const checkedAt = yield* currentIsoTimestamp;
|
||||
const releaseNotes = normalizeDesktopUpdateReleaseNotes(info.releaseNotes, info.version);
|
||||
yield* setState(
|
||||
reduceDesktopUpdateStateOnUpdateAvailable(state, info.version, checkedAt, releaseNotes),
|
||||
reduceDesktopUpdateStateOnUpdateAvailable(state, info.version, checkedAt),
|
||||
);
|
||||
yield* Ref.set(lastLoggedDownloadMilestoneRef, -1);
|
||||
yield* logUpdaterInfo("update available", {
|
||||
version: info.version,
|
||||
releaseNoteGroups: releaseNotes.length,
|
||||
});
|
||||
yield* logUpdaterInfo("update available", { version: info.version });
|
||||
}),
|
||||
),
|
||||
Effect.catchCause((cause) => {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { normalizeDesktopUpdateReleaseNotes } from "./releaseNotes.ts";
|
||||
|
||||
describe("normalizeDesktopUpdateReleaseNotes", () => {
|
||||
it("splits a plain string note into items under the fallback version", () => {
|
||||
const notes = normalizeDesktopUpdateReleaseNotes(
|
||||
"## What's changed\n- First fix\n- Second fix",
|
||||
"1.2.3",
|
||||
);
|
||||
expect(notes).toEqual([{ version: "1.2.3", items: ["First fix", "Second fix"] }]);
|
||||
});
|
||||
|
||||
it("keeps per-version groups and drops empty ones", () => {
|
||||
const notes = normalizeDesktopUpdateReleaseNotes(
|
||||
[
|
||||
{ version: "1.2.3", note: "- Newer change" },
|
||||
{ version: "1.2.2", note: "Full changelog: https://example.com/compare/x...y" },
|
||||
{ version: "1.2.1", note: "- Older change" },
|
||||
],
|
||||
"1.2.3",
|
||||
);
|
||||
expect(notes).toEqual([
|
||||
{ version: "1.2.3", items: ["Newer change"] },
|
||||
{ version: "1.2.1", items: ["Older change"] },
|
||||
]);
|
||||
});
|
||||
|
||||
it("decodes valid HTML entities", () => {
|
||||
const notes = normalizeDesktopUpdateReleaseNotes("- Fix & polish 😀", "1.0.0");
|
||||
expect(notes).toEqual([{ version: "1.0.0", items: ["Fix & polish 😀"] }]);
|
||||
});
|
||||
|
||||
it("ignores malformed entries instead of throwing", () => {
|
||||
const notes = normalizeDesktopUpdateReleaseNotes(
|
||||
[
|
||||
{ version: "1.2.3", note: "- Valid change" },
|
||||
{ version: 42, note: "- Bad version type" },
|
||||
{ version: "1.2.1", note: { html: "<p>object note</p>" } },
|
||||
"not an object",
|
||||
null,
|
||||
],
|
||||
"1.2.3",
|
||||
);
|
||||
expect(notes).toEqual([{ version: "1.2.3", items: ["Valid change"] }]);
|
||||
});
|
||||
|
||||
it("returns non-empty groups even when preceded by many boilerplate-only groups", () => {
|
||||
const boilerplate = Array.from({ length: 7 }, (_, index) => ({
|
||||
version: `1.3.${9 - index}`,
|
||||
note: "Full changelog: https://example.com/compare/x...y",
|
||||
}));
|
||||
const notes = normalizeDesktopUpdateReleaseNotes(
|
||||
[...boilerplate, { version: "1.3.2", note: "- Older but real change" }],
|
||||
"1.3.9",
|
||||
);
|
||||
expect(notes).toEqual([{ version: "1.3.2", items: ["Older but real change"] }]);
|
||||
});
|
||||
|
||||
it("does not throw on out-of-range numeric entities and keeps the literal", () => {
|
||||
expect(() =>
|
||||
normalizeDesktopUpdateReleaseNotes("- Broken entity �", "1.0.0"),
|
||||
).not.toThrow();
|
||||
const notes = normalizeDesktopUpdateReleaseNotes("- Broken entity �", "1.0.0");
|
||||
expect(notes).toEqual([{ version: "1.0.0", items: ["Broken entity �"] }]);
|
||||
});
|
||||
});
|
||||
@@ -1,125 +0,0 @@
|
||||
import type { DesktopUpdateReleaseNote } from "@t3tools/contracts";
|
||||
|
||||
interface ElectronReleaseNoteInfo {
|
||||
readonly version: string;
|
||||
readonly note: string | null | undefined;
|
||||
}
|
||||
|
||||
function isElectronReleaseNoteInfo(value: unknown): value is ElectronReleaseNoteInfo {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const candidate = value as { readonly version?: unknown; readonly note?: unknown };
|
||||
return (
|
||||
typeof candidate.version === "string" &&
|
||||
(typeof candidate.note === "string" || candidate.note === null || candidate.note === undefined)
|
||||
);
|
||||
}
|
||||
|
||||
const MAX_RELEASE_NOTE_GROUPS = 6;
|
||||
const MAX_RELEASE_NOTE_ITEMS_PER_GROUP = 8;
|
||||
const MAX_RELEASE_NOTE_ITEM_LENGTH = 220;
|
||||
|
||||
const HTML_ENTITY_REPLACEMENTS: Readonly<Record<string, string>> = {
|
||||
amp: "&",
|
||||
apos: "'",
|
||||
gt: ">",
|
||||
lt: "<",
|
||||
nbsp: " ",
|
||||
quot: '"',
|
||||
};
|
||||
|
||||
function decodeCodePoint(codePoint: number, entity: string): string {
|
||||
// String.fromCodePoint throws RangeError outside the valid Unicode range, and
|
||||
// Number.isFinite alone lets oversized values (e.g. �) through.
|
||||
if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) {
|
||||
return `&${entity};`;
|
||||
}
|
||||
return String.fromCodePoint(codePoint);
|
||||
}
|
||||
|
||||
function decodeHtmlEntity(entity: string): string {
|
||||
const named = HTML_ENTITY_REPLACEMENTS[entity];
|
||||
if (named) return named;
|
||||
if (entity.startsWith("#x")) {
|
||||
return decodeCodePoint(Number.parseInt(entity.slice(2), 16), entity);
|
||||
}
|
||||
if (entity.startsWith("#")) {
|
||||
return decodeCodePoint(Number.parseInt(entity.slice(1), 10), entity);
|
||||
}
|
||||
return `&${entity};`;
|
||||
}
|
||||
|
||||
function decodeHtmlEntities(input: string): string {
|
||||
return input.replace(/&([a-zA-Z]+|#\d+|#x[0-9a-fA-F]+);/g, (_, entity: string) =>
|
||||
decodeHtmlEntity(entity),
|
||||
);
|
||||
}
|
||||
|
||||
function stripMarkup(input: string): string {
|
||||
return decodeHtmlEntities(
|
||||
input
|
||||
.replace(/<br\s*\/?>/gi, "\n")
|
||||
.replace(/<li\b[^>]*>/gi, "\n- ")
|
||||
.replace(/<\/(?:p|div|li|h[1-6]|ul|ol|blockquote)>/gi, "\n")
|
||||
.replace(/<[^>]*>/g, "")
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
|
||||
.replace(/\*\*([^*]+)\*\*/g, "$1"),
|
||||
);
|
||||
}
|
||||
|
||||
function truncateReleaseNoteItem(item: string): string {
|
||||
if (item.length <= MAX_RELEASE_NOTE_ITEM_LENGTH) return item;
|
||||
return `${item.slice(0, MAX_RELEASE_NOTE_ITEM_LENGTH - 3).trimEnd()}...`;
|
||||
}
|
||||
|
||||
function isIgnoredReleaseNoteLine(line: string): boolean {
|
||||
const normalized = line
|
||||
.toLowerCase()
|
||||
.replace(/[*_`#]/g, "")
|
||||
.trim();
|
||||
return (
|
||||
normalized === "" ||
|
||||
normalized === "what's changed" ||
|
||||
normalized === "whats changed" ||
|
||||
normalized === "full changelog" ||
|
||||
normalized === "new contributors" ||
|
||||
normalized.startsWith("compare: ") ||
|
||||
normalized.includes("/compare/")
|
||||
);
|
||||
}
|
||||
|
||||
function extractReleaseNoteItems(note: string | null | undefined): ReadonlyArray<string> {
|
||||
if (!note) return [];
|
||||
|
||||
const items: string[] = [];
|
||||
for (const rawLine of stripMarkup(note).split("\n")) {
|
||||
const item = rawLine
|
||||
.trim()
|
||||
.replace(/^[-*]\s+/, "")
|
||||
.replace(/^\d+[.)]\s+/, "")
|
||||
.replace(/\s+/g, " ");
|
||||
if (isIgnoredReleaseNoteLine(item)) continue;
|
||||
items.push(truncateReleaseNoteItem(item));
|
||||
if (items.length >= MAX_RELEASE_NOTE_ITEMS_PER_GROUP) break;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
export function normalizeDesktopUpdateReleaseNotes(
|
||||
releaseNotes: unknown,
|
||||
fallbackVersion: string,
|
||||
): ReadonlyArray<DesktopUpdateReleaseNote> {
|
||||
const rawNotes =
|
||||
typeof releaseNotes === "string"
|
||||
? [{ version: fallbackVersion, note: releaseNotes }]
|
||||
: Array.isArray(releaseNotes)
|
||||
? releaseNotes.filter(isElectronReleaseNoteInfo)
|
||||
: [];
|
||||
|
||||
return rawNotes
|
||||
.map((entry) => ({
|
||||
version: entry.version,
|
||||
items: extractReleaseNoteItems(entry.note),
|
||||
}))
|
||||
.filter((entry) => entry.items.length > 0)
|
||||
.slice(0, MAX_RELEASE_NOTE_GROUPS);
|
||||
}
|
||||
@@ -118,12 +118,6 @@ describe("updateMachine", () => {
|
||||
});
|
||||
|
||||
it("tracks available, download start, and progress cleanly", () => {
|
||||
const releaseNotes = [
|
||||
{
|
||||
version: "1.1.0",
|
||||
items: ["feat: add update release notes"],
|
||||
},
|
||||
];
|
||||
const available = reduceDesktopUpdateStateOnUpdateAvailable(
|
||||
{
|
||||
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
|
||||
@@ -132,33 +126,15 @@ describe("updateMachine", () => {
|
||||
},
|
||||
"1.1.0",
|
||||
"2026-03-04T00:00:00.000Z",
|
||||
releaseNotes,
|
||||
);
|
||||
const downloading = reduceDesktopUpdateStateOnDownloadStart(available);
|
||||
const progress = reduceDesktopUpdateStateOnDownloadProgress(downloading, 55.5);
|
||||
|
||||
expect(available.status).toBe("available");
|
||||
expect(available.channel).toBe("latest");
|
||||
expect(available.releaseNotes).toBe(releaseNotes);
|
||||
expect(downloading.releaseNotes).toBe(releaseNotes);
|
||||
expect(downloading.status).toBe("downloading");
|
||||
expect(downloading.downloadPercent).toBe(0);
|
||||
expect(progress.downloadPercent).toBe(55.5);
|
||||
expect(progress.errorContext).toBeNull();
|
||||
});
|
||||
|
||||
it("clears release notes when checking again", () => {
|
||||
const state = reduceDesktopUpdateStateOnCheckStart(
|
||||
{
|
||||
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "nightly"),
|
||||
enabled: true,
|
||||
status: "available",
|
||||
availableVersion: "1.1.0-nightly.1",
|
||||
releaseNotes: [{ version: "1.1.0-nightly.1", items: ["feat: old note"] }],
|
||||
},
|
||||
"2026-03-04T00:00:00.000Z",
|
||||
);
|
||||
|
||||
expect(state.releaseNotes).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import type {
|
||||
DesktopRuntimeInfo,
|
||||
DesktopUpdateChannel,
|
||||
DesktopUpdateReleaseNote,
|
||||
DesktopUpdateState,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
@@ -30,7 +29,6 @@ export function createInitialDesktopUpdateState(
|
||||
runningUnderArm64Translation: runtimeInfo.runningUnderArm64Translation,
|
||||
availableVersion: null,
|
||||
downloadedVersion: null,
|
||||
releaseNotes: [],
|
||||
downloadPercent: null,
|
||||
checkedAt: null,
|
||||
message: null,
|
||||
@@ -47,7 +45,6 @@ export function reduceDesktopUpdateStateOnCheckStart(
|
||||
...state,
|
||||
status: "checking",
|
||||
checkedAt,
|
||||
releaseNotes: [],
|
||||
message: null,
|
||||
downloadPercent: null,
|
||||
errorContext: null,
|
||||
@@ -75,14 +72,12 @@ export function reduceDesktopUpdateStateOnUpdateAvailable(
|
||||
state: DesktopUpdateState,
|
||||
version: string,
|
||||
checkedAt: string,
|
||||
releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote> = [],
|
||||
): DesktopUpdateState {
|
||||
return {
|
||||
...state,
|
||||
status: "available",
|
||||
availableVersion: version,
|
||||
downloadedVersion: null,
|
||||
releaseNotes,
|
||||
downloadPercent: null,
|
||||
checkedAt,
|
||||
message: null,
|
||||
@@ -100,7 +95,6 @@ export function reduceDesktopUpdateStateOnNoUpdate(
|
||||
status: "up-to-date",
|
||||
availableVersion: null,
|
||||
downloadedVersion: null,
|
||||
releaseNotes: [],
|
||||
downloadPercent: null,
|
||||
checkedAt,
|
||||
message: null,
|
||||
|
||||
@@ -1 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="cursor_light__Ebene_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 466.73 532.09"><defs></defs><path class="cursor_light__st0" fill="#EDECEC" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"></path></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg id="cursor_light__Ebene_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 466.73 532.09"><defs></defs><path class="cursor_light__st0" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 665 B After Width: | Height: | Size: 649 B |
@@ -1,6 +1,6 @@
|
||||
export const GITHUB_REPOSITORY_URL = "https://github.com/pingdotgg/t3code";
|
||||
|
||||
export const MARKETING_STATS = {
|
||||
githubStars: "14k+",
|
||||
githubStars: "12k+",
|
||||
users: "100,000",
|
||||
} as const;
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ExpoConfig } from "expo/config";
|
||||
|
||||
import { BRAND_ASSET_PATHS } from "../../scripts/lib/brand-assets.ts";
|
||||
import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
|
||||
|
||||
type AppVariant = "development" | "preview" | "production";
|
||||
@@ -14,8 +13,6 @@ const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
|
||||
const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
|
||||
const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
|
||||
|
||||
const fromRepoRoot = (relativePath: string) => `../../${relativePath}`;
|
||||
|
||||
if (
|
||||
isIosPersonalTeamBuild &&
|
||||
(!personalTeamBundleIdentifier ||
|
||||
@@ -27,31 +24,20 @@ if (
|
||||
}
|
||||
|
||||
const DEVELOPMENT_ASSETS = {
|
||||
appIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
|
||||
iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIconComposerProject),
|
||||
splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
|
||||
androidAdaptiveForeground: fromRepoRoot(BRAND_ASSET_PATHS.developmentUniversalIconPng),
|
||||
appIcon: "./assets/splash-icon-dev.png",
|
||||
iosIcon: "./assets/icon-composer-dev.icon",
|
||||
splashIcon: "./assets/splash-icon-dev.png",
|
||||
androidAdaptiveForeground: "./assets/android-icon-dev-foreground.png",
|
||||
androidAdaptiveBackgroundColor: "#00639B",
|
||||
androidMonochromeIcon: "./assets/android-icon-mark.png",
|
||||
androidNotificationIcon: "./assets/android-notification-icon.png",
|
||||
androidNotificationColor: "#00639B",
|
||||
} as const;
|
||||
|
||||
const PREVIEW_ASSETS = {
|
||||
appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
|
||||
iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
|
||||
splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
|
||||
androidAdaptiveForeground: fromRepoRoot(BRAND_ASSET_PATHS.nightlyLinuxIconPng),
|
||||
androidAdaptiveBackgroundColor: "#111533",
|
||||
androidMonochromeIcon: "./assets/android-icon-mark.png",
|
||||
androidNotificationIcon: "./assets/android-notification-icon.png",
|
||||
androidNotificationColor: "#7565C7",
|
||||
} as const;
|
||||
|
||||
const RELEASE_ASSETS = {
|
||||
appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
|
||||
iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
|
||||
splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
|
||||
appIcon: "./assets/splash-icon-prod.png",
|
||||
iosIcon: "./assets/icon-composer-prod.icon",
|
||||
splashIcon: "./assets/splash-icon-prod.png",
|
||||
androidAdaptiveForeground: "./assets/android-icon-mark.png",
|
||||
androidAdaptiveBackgroundColor: "#000000",
|
||||
androidMonochromeIcon: "./assets/android-icon-mark.png",
|
||||
@@ -74,7 +60,7 @@ const VARIANT_CONFIG = {
|
||||
iosBundleIdentifier: "com.t3tools.t3code.preview",
|
||||
androidPackage: "com.t3tools.t3code.preview",
|
||||
relyingParty: "clerk.t3.codes",
|
||||
assets: PREVIEW_ASSETS,
|
||||
assets: RELEASE_ASSETS,
|
||||
},
|
||||
production: {
|
||||
appName: "T3 Code",
|
||||
|
||||
|
After Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 920 B |
|
After Width: | Height: | Size: 10 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
@@ -6,40 +6,35 @@
|
||||
{
|
||||
"layers": [
|
||||
{
|
||||
"glass": true,
|
||||
"image-name": "text.svg",
|
||||
"name": "Text",
|
||||
"hidden": false,
|
||||
"image-name": "gpt-image-1.5-jd70szmrd03p36z4zv48ycsbax81egvr.png",
|
||||
"name": "gpt-image-1.5-jd70szmrd03p36z4zv48ycsbax81egvr",
|
||||
"position": {
|
||||
"scale": 8.5,
|
||||
"scale": 1.1,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"glass": false,
|
||||
"image-name": "annotations.svg",
|
||||
"name": "Annotations",
|
||||
"image-name": "T3.svg",
|
||||
"name": "T3",
|
||||
"position": {
|
||||
"scale": 8.5,
|
||||
"scale": 10,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"glass": true,
|
||||
"image-name": "background.svg",
|
||||
"name": "Background",
|
||||
"position": {
|
||||
"scale": 8.1,
|
||||
"translation-in-points": [0, 0]
|
||||
}
|
||||
"hidden": true,
|
||||
"image-name": "Texturelabs_Paper_381XL.jpg",
|
||||
"name": "Texturelabs_Paper_381XL"
|
||||
}
|
||||
],
|
||||
"shadow": {
|
||||
"kind": "neutral",
|
||||
"opacity": 0.6
|
||||
"opacity": 0.5
|
||||
},
|
||||
"translucency": {
|
||||
"enabled": true,
|
||||
"value": 0.2
|
||||
"value": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="77" height="47" viewBox="0 0 77 47" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M14.56 45.5V8.58H1.69082e-06V-3.09944e-06H39.65V8.58H25.09V45.5H14.56ZM57.8454 46.28C54.6821 46.28 51.5404 45.8683 48.4204 45.045C45.3004 44.1783 42.6571 42.965 40.4904 41.405L44.5854 33.345C46.3188 34.6017 48.3338 35.5983 50.6304 36.335C52.9271 37.0717 55.2454 37.44 57.5854 37.44C60.2288 37.44 62.3088 36.92 63.8254 35.88C65.3421 34.84 66.1004 33.41 66.1004 31.59C66.1004 29.8567 65.4288 28.4917 64.0854 27.495C62.7421 26.4983 60.5754 26 57.5854 26H52.7754V19.045L65.4504 4.68L66.6204 8.45H42.7654V-3.09944e-06H74.6154V6.825L62.0054 21.19L56.6754 18.135H59.7304C65.3204 18.135 69.5454 19.3917 72.4054 21.905C75.2654 24.4183 76.6954 27.6467 76.6954 31.59C76.6954 34.1467 76.0238 36.5517 74.6804 38.805C73.3371 41.015 71.2788 42.8133 68.5054 44.2C65.7321 45.5867 62.1788 46.28 57.8454 46.28Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 920 B |
@@ -6,8 +6,8 @@
|
||||
{
|
||||
"layers": [
|
||||
{
|
||||
"image-name": "text.svg",
|
||||
"name": "Text",
|
||||
"image-name": "T3.svg",
|
||||
"name": "T3",
|
||||
"position": {
|
||||
"scale": 10,
|
||||
"translation-in-points": [0, 0]
|
||||
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 302 KiB |
@@ -1,6 +1,5 @@
|
||||
import { registerRootComponent } from "expo";
|
||||
import "react-native-gesture-handler";
|
||||
import { LogBox } from "react-native";
|
||||
import { featureFlags } from "react-native-screens";
|
||||
|
||||
import App from "./src/App";
|
||||
@@ -9,8 +8,4 @@ import App from "./src/App";
|
||||
// native stack is rendered inside a non-fitToContents formSheet.
|
||||
featureFlags.experiment.synchronousScreenUpdatesEnabled = true;
|
||||
|
||||
if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
|
||||
LogBox.ignoreAllLogs();
|
||||
}
|
||||
|
||||
registerRootComponent(App);
|
||||
@@ -7,32 +7,6 @@ class T3NativeControlsModule : Module() {
|
||||
override fun definition() = ModuleDefinition {
|
||||
Name("T3NativeControls")
|
||||
|
||||
Function("getShowcasePairingUrl") {
|
||||
appContext.currentActivity?.intent?.getStringExtra("showcasePairingUrl")
|
||||
}
|
||||
|
||||
Function("getShowcaseScene") {
|
||||
val storedScene = appContext.reactContext
|
||||
?.filesDir
|
||||
?.resolve("t3-showcase-scene")
|
||||
?.takeIf { it.isFile }
|
||||
?.readText()
|
||||
?.trim()
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
storedScene ?: appContext.currentActivity?.intent?.getStringExtra("showcaseScene")
|
||||
}
|
||||
|
||||
Function("prepareShowcaseCapture") {
|
||||
// Android app data is cleared by the host runner before launch.
|
||||
}
|
||||
|
||||
Function("markShowcaseReady") { scene: String ->
|
||||
appContext.reactContext
|
||||
?.filesDir
|
||||
?.resolve("t3-showcase-ready")
|
||||
?.writeText(scene)
|
||||
}
|
||||
|
||||
View(T3HeaderButtonView::class) {
|
||||
Prop("label") { view: T3HeaderButtonView, label: String ->
|
||||
view.setLabel(label)
|
||||
|
||||
@@ -1,48 +1,9 @@
|
||||
import ExpoModulesCore
|
||||
import Security
|
||||
|
||||
public final class T3NativeControlsModule: Module {
|
||||
public func definition() -> ModuleDefinition {
|
||||
Name("T3NativeControls")
|
||||
|
||||
Function("getShowcasePairingUrl") {
|
||||
let arguments = ProcessInfo.processInfo.arguments
|
||||
guard
|
||||
let flagIndex = arguments.firstIndex(of: "--showcasePairingUrl"),
|
||||
arguments.indices.contains(flagIndex + 1)
|
||||
else {
|
||||
return nil as String?
|
||||
}
|
||||
return arguments[flagIndex + 1]
|
||||
}
|
||||
|
||||
Function("getShowcaseScene") { () -> String? in
|
||||
let scenePath = NSHomeDirectory() + "/Library/Caches/T3ShowcaseScene"
|
||||
if let storedScene = try? String(contentsOfFile: scenePath, encoding: .utf8)
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines), !storedScene.isEmpty {
|
||||
return storedScene
|
||||
}
|
||||
let arguments = ProcessInfo.processInfo.arguments
|
||||
guard
|
||||
let flagIndex = arguments.firstIndex(of: "--showcaseScene"),
|
||||
arguments.indices.contains(flagIndex + 1)
|
||||
else {
|
||||
return nil as String?
|
||||
}
|
||||
return arguments[flagIndex + 1]
|
||||
}
|
||||
|
||||
Function("prepareShowcaseCapture") {
|
||||
for itemClass in [kSecClassGenericPassword, kSecClassInternetPassword] {
|
||||
SecItemDelete([kSecClass as String: itemClass] as CFDictionary)
|
||||
}
|
||||
}
|
||||
|
||||
Function("markShowcaseReady") { (scene: String) in
|
||||
let readyPath = NSHomeDirectory() + "/Library/Caches/T3ShowcaseReadyScene"
|
||||
try? scene.write(toFile: readyPath, atomically: true, encoding: .utf8)
|
||||
}
|
||||
|
||||
View(T3HeaderButtonView.self) {
|
||||
Prop("label") { (view: T3HeaderButtonView, label: String) in
|
||||
view.setLabel(label)
|
||||
|
||||
@@ -30,10 +30,6 @@ class T3TerminalModule : Module() {
|
||||
view.focusRequest = focusRequest
|
||||
}
|
||||
|
||||
Prop("autoFocus") { view: T3TerminalView, autoFocus: Boolean ->
|
||||
view.autoFocus = autoFocus
|
||||
}
|
||||
|
||||
Prop("appearanceScheme") { view: T3TerminalView, appearanceScheme: String ->
|
||||
view.appearanceScheme = appearanceScheme
|
||||
}
|
||||
|
||||
@@ -76,17 +76,6 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
|
||||
}
|
||||
}
|
||||
|
||||
var autoFocus: Boolean = true
|
||||
set(value) {
|
||||
field = value
|
||||
if (value) {
|
||||
requestKeyboardFocus()
|
||||
} else {
|
||||
inputView.clearFocus()
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
var backgroundColorHex: String = "#24292E"
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -379,13 +368,6 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
|
||||
inputMethodManager?.showSoftInput(inputView, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
|
||||
private fun hideKeyboard() {
|
||||
val inputMethodManager = context.getSystemService(
|
||||
Context.INPUT_METHOD_SERVICE
|
||||
) as? InputMethodManager
|
||||
inputMethodManager?.hideSoftInputFromWindow(windowToken, 0)
|
||||
}
|
||||
|
||||
private fun applyTheme() {
|
||||
setBackgroundColor(backgroundColorValue)
|
||||
container.setBackgroundColor(backgroundColorValue)
|
||||
|
||||
@@ -27,10 +27,6 @@ public class T3TerminalModule: Module {
|
||||
view.focusRequest = focusRequest
|
||||
}
|
||||
|
||||
Prop("autoFocus") { (view: T3TerminalView, autoFocus: Bool) in
|
||||
view.autoFocus = autoFocus
|
||||
}
|
||||
|
||||
Prop("appearanceScheme") { (view: T3TerminalView, appearanceScheme: String) in
|
||||
view.appearanceScheme = appearanceScheme
|
||||
}
|
||||
|
||||
@@ -248,17 +248,6 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
var autoFocus = true {
|
||||
didSet {
|
||||
guard oldValue != autoFocus else { return }
|
||||
if autoFocus {
|
||||
requestKeyboardFocus()
|
||||
} else {
|
||||
inputField.resignFirstResponder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var appearanceScheme: String = TerminalAppearanceScheme.dark.rawValue {
|
||||
didSet {
|
||||
guard oldValue != appearanceScheme else { return }
|
||||
@@ -370,7 +359,7 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate {
|
||||
public override func didMoveToWindow() {
|
||||
super.didMoveToWindow()
|
||||
|
||||
guard window != nil, autoFocus else { return }
|
||||
guard window != nil else { return }
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.requestKeyboardFocus()
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
"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",
|
||||
"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",
|
||||
"android:preview": "APP_VARIANT=preview EXPO_NO_GIT_STATUS=1 expo prebuild --clean --platform android && expo run:android",
|
||||
|
||||
@@ -11,7 +11,6 @@ import { createStaticNavigation, DarkTheme, DefaultTheme } from "@react-navigati
|
||||
import { RegistryContext } from "@effect/atom-react";
|
||||
import { ConfirmDialogHost } from "./components/ConfirmDialogHost";
|
||||
import { CloudAuthProvider } from "./features/cloud/CloudAuthProvider";
|
||||
import { prepareNativeShowcaseCapture } from "./features/showcase/nativeShowcaseScene";
|
||||
import { IncomingShareProvider } from "./features/sharing/IncomingShareProvider";
|
||||
import { AppearancePreferencesProvider } from "./features/settings/appearance/AppearancePreferencesProvider";
|
||||
import { RootStack } from "./Stack";
|
||||
@@ -22,10 +21,6 @@ import { useThemeColor } from "./lib/useThemeColor";
|
||||
|
||||
import "../global.css";
|
||||
|
||||
if (process.env.EXPO_PUBLIC_SHOWCASE === "1") {
|
||||
prepareNativeShowcaseCapture();
|
||||
}
|
||||
|
||||
const appLinking = {
|
||||
prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
|
||||
// The Expo dev client launches the app via
|
||||
|
||||
@@ -48,7 +48,6 @@ import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnv
|
||||
import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
|
||||
import { SettingsRouteScreen } from "./features/settings/SettingsRouteScreen";
|
||||
import { SettingsWaitlistRouteScreen } from "./features/settings/SettingsWaitlistRouteScreen";
|
||||
import { ShowcaseCaptureCoordinator } from "./features/showcase/ShowcaseCaptureCoordinator";
|
||||
import {
|
||||
SettingsLegalDocumentCloseHeaderButton,
|
||||
SettingsLegalDocumentExternalHeaderButton,
|
||||
@@ -314,7 +313,6 @@ function RootStackLayout(props: {
|
||||
|
||||
return (
|
||||
<HardwareKeyboardCommandProvider pathname={pathname}>
|
||||
<ShowcaseCaptureCoordinator pathname={pathname} />
|
||||
<ClerkSettingsSheetDetentProvider initiallyExpanded={false}>
|
||||
<AdaptiveWorkspaceLayout pathname={workspacePathname}>
|
||||
{props.children}
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
import Constants from "expo-constants";
|
||||
import { Image } from "expo-image";
|
||||
import { View } from "react-native";
|
||||
import { Image, View } from "react-native";
|
||||
|
||||
import { AppText as Text } from "./AppText";
|
||||
|
||||
const appVariant = Constants.expoConfig?.extra?.appVariant;
|
||||
const BRAND_MARK_SOURCE =
|
||||
appVariant === "development"
|
||||
? require("../../../../assets/dev/blueprint-ios-1024.png")
|
||||
: appVariant === "preview"
|
||||
? require("../../../../assets/nightly/nightly-ios-1024.png")
|
||||
: require("../../../../assets/prod/black-ios-1024.png");
|
||||
const DEFAULT_STAGE_LABEL =
|
||||
appVariant === "development" ? "Dev" : appVariant === "preview" ? "Preview" : "Alpha";
|
||||
const BRAND_MARK_SOURCE = require("../../../../assets/dev/blueprint-ios-1024.png");
|
||||
|
||||
export function BrandMark(props: { readonly compact?: boolean; readonly stageLabel?: string }) {
|
||||
const compact = props.compact ?? false;
|
||||
const iconSize = compact ? 32 : 44;
|
||||
const stageLabel = props.stageLabel ?? DEFAULT_STAGE_LABEL;
|
||||
const stageLabel = props.stageLabel ?? "Alpha";
|
||||
|
||||
return (
|
||||
<View className="flex-row items-center gap-3">
|
||||
|
||||
@@ -33,8 +33,6 @@ import { type RelayEnvironmentView, useConnectionController } from "./useConnect
|
||||
export function CloudEnvironmentRows(props: {
|
||||
readonly connectedCloudEnvironments: ReadonlyArray<ConnectedEnvironmentSummary>;
|
||||
readonly onReconnectEnvironment: (environmentId: EnvironmentId) => void;
|
||||
readonly showcaseAvailableEnvironments?: ReadonlyArray<RelayEnvironmentView>;
|
||||
readonly showcaseSignedIn?: boolean;
|
||||
/**
|
||||
* Hide the "T3 Connect" section title + refresh button for hosts that
|
||||
* provide their own chrome (the onboarding sheet's native header and
|
||||
@@ -45,8 +43,7 @@ export function CloudEnvironmentRows(props: {
|
||||
const { isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
|
||||
const controller = useConnectionController();
|
||||
const iconColor = useThemeColor("--color-icon");
|
||||
const availableCloudEnvironments =
|
||||
props.showcaseAvailableEnvironments ?? controller.availableRelayEnvironments;
|
||||
const availableCloudEnvironments = controller.availableRelayEnvironments;
|
||||
const [expandedErrorId, setExpandedErrorId] = useState<string | null>(null);
|
||||
const hasCloudRows =
|
||||
props.connectedCloudEnvironments.length > 0 || availableCloudEnvironments.length > 0;
|
||||
@@ -67,7 +64,7 @@ export function CloudEnvironmentRows(props: {
|
||||
|
||||
const showHeader = props.showHeader ?? true;
|
||||
|
||||
if (!(props.showcaseSignedIn ?? isSignedIn)) return null;
|
||||
if (!isSignedIn) return null;
|
||||
|
||||
return (
|
||||
<View collapsable={false} className={cn("gap-3", showHeader && "mt-5")}>
|
||||
|
||||
@@ -96,22 +96,5 @@ describe("isPendingNativeViewRegistration", () => {
|
||||
new Error("Unable to find the 'T3ReviewDiffView' view for this native tag"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isPendingNativeViewRegistration(
|
||||
new Error(
|
||||
"Unable to find the class expo.modules.t3reviewdiff.T3ReviewDiffView view with tag 1150",
|
||||
),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isNativeReviewDiffDrawEvent", () => {
|
||||
it("accepts only native events emitted after diff rows draw", async () => {
|
||||
const { isNativeReviewDiffDrawEvent } = await import("./nativeReviewDiffSurface");
|
||||
|
||||
expect(isNativeReviewDiffDrawEvent({ message: "draw-metrics" })).toBe(true);
|
||||
expect(isNativeReviewDiffDrawEvent({ message: "visible-range" })).toBe(true);
|
||||
expect(isNativeReviewDiffDrawEvent({ message: "rows-decoded" })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -149,10 +149,6 @@ export interface NativeReviewDiffViewHandle {
|
||||
readonly scrollToTop: (animated?: boolean) => Promise<void>;
|
||||
}
|
||||
|
||||
export function isNativeReviewDiffDrawEvent(payload: Readonly<Record<string, unknown>>): boolean {
|
||||
return payload.message === "draw-metrics" || payload.message === "visible-range";
|
||||
}
|
||||
|
||||
interface NativeReviewDiffViewRef {
|
||||
readonly setRowsJson: (rowsJson: string) => Promise<void>;
|
||||
readonly setTokensJson: (tokensJson: string) => Promise<void>;
|
||||
@@ -174,11 +170,9 @@ let nativeReviewDiffViewResolutionFailed = false;
|
||||
type NativeReviewDiffPayloadMethod = "setRowsJson" | "setTokensJson" | "setTokensPatchJson";
|
||||
|
||||
export function isPendingNativeViewRegistration(error: unknown): boolean {
|
||||
if (!(error instanceof Error)) return false;
|
||||
return (
|
||||
error.message.includes(`Unable to find the '${NATIVE_REVIEW_DIFF_MODULE_NAME}' view`) ||
|
||||
(error.message.includes("Unable to find the class") &&
|
||||
error.message.includes("T3ReviewDiffView view with tag"))
|
||||
error instanceof Error &&
|
||||
error.message.includes(`Unable to find the '${NATIVE_REVIEW_DIFF_MODULE_NAME}' view`)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
const listRef = useRef<LegendListRef | null>(null);
|
||||
const insets = useSafeAreaInsets();
|
||||
const accentColor = useThemeColor("--color-icon-muted");
|
||||
|
||||
const effectiveGroupDisplayStates = useMemo(() => {
|
||||
const next = new Map(groupDisplayStates);
|
||||
if (!AsyncResult.isSuccess(preferencesResult)) {
|
||||
|
||||
@@ -56,7 +56,6 @@ import { WorkspaceSidebarToolbar } from "../layout/workspace-sidebar-toolbar";
|
||||
import { ThreadGitMenu } from "../threads/ThreadGitControls";
|
||||
import { useReviewCacheForThread } from "./reviewState";
|
||||
import {
|
||||
isNativeReviewDiffDrawEvent,
|
||||
type NativeReviewDiffViewHandle,
|
||||
resolveNativeReviewDiffView,
|
||||
} from "../diffs/nativeReviewDiffSurface";
|
||||
@@ -72,10 +71,8 @@ import { resolveReviewAvailability } from "./reviewAvailability";
|
||||
import { resolveSelectedReviewFileId } from "./reviewPaneSelection";
|
||||
import { buildReviewSectionMenu } from "./review-section-menu";
|
||||
import type { ReviewSectionItem } from "./reviewModel";
|
||||
import { markNativeShowcaseReady } from "../showcase/nativeShowcaseScene";
|
||||
|
||||
const REVIEW_HEADER_SPACING = 0;
|
||||
const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
|
||||
|
||||
const ReviewNotice = memo(function ReviewNotice(props: { readonly notice: string }) {
|
||||
return (
|
||||
@@ -397,7 +394,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
|
||||
});
|
||||
const NativeReviewDiffView = resolveNativeReviewDiffView()!;
|
||||
const nativeReviewDiffViewRef = useRef<NativeReviewDiffViewHandle>(null);
|
||||
const showcasedReviewDrawRef = useRef<string | null>(null);
|
||||
// Native pull-to-refresh on the diff surface (replaces the old Refresh menu item).
|
||||
const [isPullRefreshing, setIsPullRefreshing] = useState(false);
|
||||
const handlePullToRefresh = useCallback(async () => {
|
||||
@@ -439,25 +435,6 @@ export function ReviewSheet(props: ReviewSheetProps) {
|
||||
selectedRowIds: commentSelection.selectedRowIds,
|
||||
canHighlight: parsedDiff.kind === "files",
|
||||
});
|
||||
const showcaseReviewKey =
|
||||
SHOWCASE_ENABLED && parsedDiff.kind === "files" && selectedSection
|
||||
? `${reviewCache.threadKey}:${selectedSection.id}:${nativeBridge.tokensResetKey}`
|
||||
: null;
|
||||
const handleNativeDebug = useCallback(
|
||||
(event: NativeSyntheticEvent<Record<string, unknown>>) => {
|
||||
nativeBridge.onDebug(event);
|
||||
if (
|
||||
showcaseReviewKey === null ||
|
||||
showcasedReviewDrawRef.current === showcaseReviewKey ||
|
||||
!isNativeReviewDiffDrawEvent(event.nativeEvent)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
showcasedReviewDrawRef.current = showcaseReviewKey;
|
||||
markNativeShowcaseReady("review");
|
||||
},
|
||||
[nativeBridge.onDebug, showcaseReviewKey],
|
||||
);
|
||||
|
||||
const handleSelectFile = useCallback(
|
||||
(fileId: string | null) => {
|
||||
@@ -811,7 +788,7 @@ export function ReviewSheet(props: ReviewSheetProps) {
|
||||
tokensPatchJson={nativeBridge.tokensPatchJson}
|
||||
tokensResetKey={nativeBridge.tokensResetKey}
|
||||
viewedFileIdsJson={nativeBridge.viewedFileIdsJson}
|
||||
onDebug={handleNativeDebug}
|
||||
onDebug={nativeBridge.onDebug}
|
||||
onPressLine={commentSelection.onPressLine}
|
||||
onVisibleFileChange={handleVisibleFileChange}
|
||||
onToggleComment={nativeBridge.onToggleComment}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/Stac
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { Platform, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
@@ -15,15 +15,6 @@ import { splitEnvironmentSections } from "../connection/environmentSections";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import {
|
||||
applyShowcaseLocalEnvironmentDisplayUrls,
|
||||
resolveShowcaseEnvironmentUpdateDisplayUrl,
|
||||
SHOWCASE_AVAILABLE_CLOUD_ENVIRONMENTS,
|
||||
SHOWCASE_CONNECTED_CLOUD_ENVIRONMENTS,
|
||||
} from "../showcase/showcaseEnvironmentRows";
|
||||
import { markNativeShowcaseReady } from "../showcase/nativeShowcaseScene";
|
||||
|
||||
const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
|
||||
|
||||
export function SettingsEnvironmentsRouteScreen() {
|
||||
const {
|
||||
@@ -34,56 +25,18 @@ export function SettingsEnvironmentsRouteScreen() {
|
||||
} = useRemoteConnections();
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const environmentSections = splitEnvironmentSections({
|
||||
const { localEnvironments, connectedCloudEnvironments } = splitEnvironmentSections({
|
||||
connectedEnvironments,
|
||||
cloudEnvironments: null,
|
||||
});
|
||||
const localEnvironments = SHOWCASE_ENABLED
|
||||
? applyShowcaseLocalEnvironmentDisplayUrls(environmentSections.localEnvironments)
|
||||
: environmentSections.localEnvironments;
|
||||
const connectedCloudEnvironments = SHOWCASE_ENABLED
|
||||
? SHOWCASE_CONNECTED_CLOUD_ENVIRONMENTS
|
||||
: environmentSections.connectedCloudEnvironments;
|
||||
const hasLocalEnvironments = localEnvironments.length > 0;
|
||||
const [expandedId, setExpandedId] = useState<EnvironmentId | null>(null);
|
||||
const accentColor = useThemeColor("--color-icon-muted");
|
||||
const headerIconColor = useThemeColor("--color-icon");
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED) return;
|
||||
const timer = setTimeout(() => markNativeShowcaseReady("environments"), 500);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const handleToggle = useCallback((environmentId: EnvironmentId) => {
|
||||
setExpandedId((prev) => (prev === environmentId ? null : environmentId));
|
||||
}, []);
|
||||
const handleUpdateEnvironment = useCallback(
|
||||
(
|
||||
environmentId: EnvironmentId,
|
||||
updates: { readonly label: string; readonly displayUrl: string },
|
||||
) => {
|
||||
if (!SHOWCASE_ENABLED) return onUpdateEnvironment(environmentId, updates);
|
||||
const actualEnvironment = environmentSections.localEnvironments.find(
|
||||
(environment) => environment.environmentId === environmentId,
|
||||
);
|
||||
const presentedEnvironment = localEnvironments.find(
|
||||
(environment) => environment.environmentId === environmentId,
|
||||
);
|
||||
return onUpdateEnvironment(environmentId, {
|
||||
...updates,
|
||||
displayUrl:
|
||||
actualEnvironment && presentedEnvironment
|
||||
? resolveShowcaseEnvironmentUpdateDisplayUrl({
|
||||
actualDisplayUrl: actualEnvironment.displayUrl,
|
||||
presentedDisplayUrl: presentedEnvironment.displayUrl,
|
||||
submittedDisplayUrl: updates.displayUrl,
|
||||
})
|
||||
: updates.displayUrl,
|
||||
});
|
||||
},
|
||||
[environmentSections.localEnvironments, localEnvironments, onUpdateEnvironment],
|
||||
);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
@@ -139,7 +92,7 @@ export function SettingsEnvironmentsRouteScreen() {
|
||||
onToggle={() => handleToggle(environment.environmentId)}
|
||||
onReconnect={onReconnectEnvironment}
|
||||
onRemove={onRemoveEnvironmentPress}
|
||||
onUpdate={handleUpdateEnvironment}
|
||||
onUpdate={onUpdateEnvironment}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
@@ -161,16 +114,10 @@ export function SettingsEnvironmentsRouteScreen() {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{hasCloudPublicConfig() || SHOWCASE_ENABLED ? (
|
||||
{hasCloudPublicConfig() ? (
|
||||
<CloudEnvironmentRows
|
||||
connectedCloudEnvironments={connectedCloudEnvironments}
|
||||
onReconnectEnvironment={onReconnectEnvironment}
|
||||
{...(SHOWCASE_ENABLED
|
||||
? {
|
||||
showcaseAvailableEnvironments: SHOWCASE_AVAILABLE_CLOUD_ENVIRONMENTS,
|
||||
showcaseSignedIn: true,
|
||||
}
|
||||
: {})}
|
||||
/>
|
||||
) : null}
|
||||
</ScrollView>
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Keyboard, View } from "react-native";
|
||||
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
|
||||
import { useConnectionController } from "../connection/useConnectionController";
|
||||
import { useProjects, useThreadShells } from "../../state/entities";
|
||||
import { enqueueThreadOutboxMessage } from "../../state/thread-outbox";
|
||||
import { holdEditingQueuedMessage } from "../../state/use-thread-outbox";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import {
|
||||
getNativeShowcasePairingUrls,
|
||||
getNativeShowcaseScene,
|
||||
markNativeShowcaseReady,
|
||||
type ShowcaseScene,
|
||||
} from "./nativeShowcaseScene";
|
||||
import {
|
||||
buildShowcasePendingTasks,
|
||||
SHOWCASE_PENDING_TASK_DEFINITIONS,
|
||||
} from "./showcasePendingTasks";
|
||||
import { retryShowcaseOperation } from "./showcaseRetry";
|
||||
|
||||
const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
|
||||
const SHOWCASE_THREAD_ID = "remote-command-center";
|
||||
|
||||
function sceneFromPathname(pathname: string): ShowcaseScene | null {
|
||||
const routePath = pathname.split(/[?#]/u, 1)[0] ?? pathname;
|
||||
if (routePath === "/settings" || routePath.endsWith("/settings/environments")) {
|
||||
return "environments";
|
||||
}
|
||||
if (routePath.endsWith("/terminal")) return "terminal";
|
||||
if (routePath.endsWith("/review")) return "review";
|
||||
if (routePath.startsWith("/threads/")) return "thread";
|
||||
if (routePath === "/") return "threads";
|
||||
return null;
|
||||
}
|
||||
|
||||
export function ShowcaseCaptureCoordinator(props: { readonly pathname: string }) {
|
||||
const navigation = useNavigation();
|
||||
const { connectPairingUrl } = useConnectionController();
|
||||
const workspace = useWorkspaceState();
|
||||
const projects = useProjects();
|
||||
const threads = useThreadShells();
|
||||
const attemptedPairingRef = useRef(new Set<string>());
|
||||
const seededPendingTaskIdsRef = useRef(new Set<string>());
|
||||
const [pairingUrls, setPairingUrls] = useState<ReadonlyArray<string>>([]);
|
||||
const [pendingTasksReady, setPendingTasksReady] = useState(false);
|
||||
const [requestedScene, setRequestedScene] = useState<ShowcaseScene | null>(null);
|
||||
const [readyScene, setReadyScene] = useState<ShowcaseScene | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED || pairingUrls.length > 0) return;
|
||||
|
||||
const readPairingUrls = () => {
|
||||
const values = getNativeShowcasePairingUrls();
|
||||
if (values.length > 0) setPairingUrls(values);
|
||||
};
|
||||
readPairingUrls();
|
||||
const interval = setInterval(readPairingUrls, 250);
|
||||
return () => clearInterval(interval);
|
||||
}, [pairingUrls.length]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED) return;
|
||||
|
||||
const readRequestedScene = () => {
|
||||
const value = getNativeShowcaseScene();
|
||||
if (value) setRequestedScene(value);
|
||||
};
|
||||
readRequestedScene();
|
||||
const interval = setInterval(readRequestedScene, 250);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED || pairingUrls.length === 0) return;
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
await Promise.all(
|
||||
pairingUrls.map(async (pairingUrl) => {
|
||||
if (cancelled || attemptedPairingRef.current.has(pairingUrl)) return;
|
||||
const paired = await retryShowcaseOperation(
|
||||
async () => AsyncResult.isSuccess(await connectPairingUrl(pairingUrl)),
|
||||
{ isCancelled: () => cancelled },
|
||||
);
|
||||
if (paired) attemptedPairingRef.current.add(pairingUrl);
|
||||
}),
|
||||
);
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [connectPairingUrl, pairingUrls]);
|
||||
|
||||
const scene = sceneFromPathname(props.pathname);
|
||||
const hasServerFixture =
|
||||
workspace.state.hasReadyEnvironment &&
|
||||
workspace.environments.length >= 3 &&
|
||||
projects.length >= 3 &&
|
||||
threads.some((thread) => String(thread.id) === SHOWCASE_THREAD_ID);
|
||||
const hasFixture = hasServerFixture && pendingTasksReady;
|
||||
const showcaseThread = threads.find((thread) => String(thread.id) === SHOWCASE_THREAD_ID);
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED || !hasServerFixture || pendingTasksReady) return;
|
||||
|
||||
const pendingTasks = buildShowcasePendingTasks(projects, Date.now());
|
||||
if (pendingTasks.length !== SHOWCASE_PENDING_TASK_DEFINITIONS.length) return;
|
||||
|
||||
let cancelled = false;
|
||||
for (const task of pendingTasks) holdEditingQueuedMessage(task.messageId);
|
||||
void (async () => {
|
||||
const results = await Promise.all(
|
||||
pendingTasks.map(async (task) => {
|
||||
const messageId = String(task.messageId);
|
||||
if (seededPendingTaskIdsRef.current.has(messageId)) return true;
|
||||
const seeded = await retryShowcaseOperation(
|
||||
async () => {
|
||||
await enqueueThreadOutboxMessage(task);
|
||||
return true;
|
||||
},
|
||||
{ isCancelled: () => cancelled },
|
||||
);
|
||||
if (seeded) seededPendingTaskIdsRef.current.add(messageId);
|
||||
return seeded;
|
||||
}),
|
||||
);
|
||||
if (!cancelled && results.every(Boolean)) setPendingTasksReady(true);
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [hasServerFixture, pendingTasksReady, projects]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!SHOWCASE_ENABLED || requestedScene === null || !hasFixture || !showcaseThread) return;
|
||||
if (scene === requestedScene) return;
|
||||
|
||||
const params = {
|
||||
environmentId: String(showcaseThread.environmentId),
|
||||
threadId: SHOWCASE_THREAD_ID,
|
||||
};
|
||||
if (requestedScene === "threads") {
|
||||
navigation.dispatch(StackActions.popToTop());
|
||||
return;
|
||||
}
|
||||
const routes: Array<{
|
||||
name: string;
|
||||
params?: Record<string, unknown>;
|
||||
state?: { index: number; routes: Array<{ name: string }> };
|
||||
}> = [{ name: "Home" }];
|
||||
if (requestedScene === "environments") {
|
||||
routes.push({
|
||||
name: "SettingsSheet",
|
||||
state: {
|
||||
index: 1,
|
||||
routes: [{ name: "Settings" }, { name: "SettingsEnvironments" }],
|
||||
},
|
||||
});
|
||||
} else {
|
||||
routes.push({ name: "Thread", params });
|
||||
if (requestedScene === "terminal") {
|
||||
routes.push({
|
||||
name: "ThreadTerminal",
|
||||
params: { ...params, terminalId: "term-1" },
|
||||
});
|
||||
} else if (requestedScene === "review") {
|
||||
routes.push({ name: "ThreadReview", params });
|
||||
}
|
||||
}
|
||||
navigation.dispatch(
|
||||
CommonActions.reset({
|
||||
index: routes.length - 1,
|
||||
routes,
|
||||
}),
|
||||
);
|
||||
}, [hasFixture, navigation, requestedScene, scene, showcaseThread]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!SHOWCASE_ENABLED ||
|
||||
scene === null ||
|
||||
requestedScene === null ||
|
||||
scene !== requestedScene ||
|
||||
!hasFixture
|
||||
) {
|
||||
setReadyScene(null);
|
||||
return;
|
||||
}
|
||||
// Review owns its readiness marker because route activation happens before
|
||||
// the VCS request is parsed and the native diff surface is mounted.
|
||||
if (scene === "review") {
|
||||
setReadyScene(null);
|
||||
return;
|
||||
}
|
||||
if (scene === "terminal") Keyboard.dismiss();
|
||||
|
||||
let renderFrame: number | null = null;
|
||||
let readyFrame: number | null = null;
|
||||
const settleTimer = setTimeout(() => {
|
||||
renderFrame = requestAnimationFrame(() => {
|
||||
readyFrame = requestAnimationFrame(() => {
|
||||
markNativeShowcaseReady(scene);
|
||||
setReadyScene(scene);
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
return () => {
|
||||
clearTimeout(settleTimer);
|
||||
if (renderFrame !== null) cancelAnimationFrame(renderFrame);
|
||||
if (readyFrame !== null) cancelAnimationFrame(readyFrame);
|
||||
};
|
||||
}, [hasFixture, requestedScene, scene]);
|
||||
|
||||
if (!SHOWCASE_ENABLED || readyScene === null) return null;
|
||||
|
||||
return (
|
||||
<View
|
||||
pointerEvents="none"
|
||||
testID={`showcase-ready-${readyScene}`}
|
||||
style={{ position: "absolute", width: 1, height: 1, opacity: 0.01 }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import { requireOptionalNativeModule } from "expo";
|
||||
|
||||
export const SHOWCASE_SCENES = ["threads", "thread", "terminal", "review", "environments"] as const;
|
||||
export type ShowcaseScene = (typeof SHOWCASE_SCENES)[number];
|
||||
|
||||
interface NativeShowcaseControls {
|
||||
readonly getShowcasePairingUrl?: () => string | null;
|
||||
readonly getShowcaseScene?: () => string | null;
|
||||
readonly prepareShowcaseCapture?: () => void;
|
||||
readonly markShowcaseReady?: (scene: ShowcaseScene) => void;
|
||||
}
|
||||
|
||||
function nativeShowcaseControls(): NativeShowcaseControls | null {
|
||||
return requireOptionalNativeModule<NativeShowcaseControls>("T3NativeControls");
|
||||
}
|
||||
|
||||
export function getNativeShowcasePairingUrls(): ReadonlyArray<string> {
|
||||
try {
|
||||
let raw = nativeShowcaseControls()?.getShowcasePairingUrl?.()?.trim();
|
||||
if (!raw) return [];
|
||||
if (raw.startsWith("json-uri:")) {
|
||||
try {
|
||||
raw = decodeURIComponent(raw.slice("json-uri:".length));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(raw);
|
||||
if (Array.isArray(parsed)) {
|
||||
return parsed.filter(
|
||||
(candidate): candidate is string =>
|
||||
typeof candidate === "string" && candidate.trim().length > 0,
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
// Older runners pass a single URL rather than a JSON array.
|
||||
}
|
||||
return [raw];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function getNativeShowcaseScene(): ShowcaseScene | null {
|
||||
try {
|
||||
const scene = nativeShowcaseControls()?.getShowcaseScene?.()?.trim();
|
||||
return SHOWCASE_SCENES.find((candidate) => candidate === scene) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function prepareNativeShowcaseCapture(): void {
|
||||
try {
|
||||
nativeShowcaseControls()?.prepareShowcaseCapture?.();
|
||||
} catch {
|
||||
// The harness still works when a development build predates this helper.
|
||||
}
|
||||
}
|
||||
|
||||
export function markNativeShowcaseReady(scene: ShowcaseScene): void {
|
||||
try {
|
||||
nativeShowcaseControls()?.markShowcaseReady?.(scene);
|
||||
} catch {
|
||||
// The readiness marker is capture-runner metadata, never app functionality.
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
import { EnvironmentId } from "@t3tools/contracts";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
|
||||
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
|
||||
import {
|
||||
applyShowcaseLocalEnvironmentDisplayUrls,
|
||||
resolveShowcaseEnvironmentUpdateDisplayUrl,
|
||||
} from "./showcaseEnvironmentRows";
|
||||
|
||||
function environment(
|
||||
environmentId: string,
|
||||
environmentLabel: string,
|
||||
displayUrl = "http://127.0.0.1:3773/",
|
||||
): ConnectedEnvironmentSummary {
|
||||
return {
|
||||
environmentId: EnvironmentId.make(environmentId),
|
||||
environmentLabel,
|
||||
displayUrl,
|
||||
isRelayManaged: false,
|
||||
connectionState: "connected",
|
||||
connectionError: null,
|
||||
connectionErrorTraceId: null,
|
||||
};
|
||||
}
|
||||
|
||||
it("presents showcase transports as remote endpoints", () => {
|
||||
const environments = applyShowcaseLocalEnvironmentDisplayUrls([
|
||||
environment("runtime-id-1", "Moonbase Terminal"),
|
||||
environment("runtime-id-2", "Suspense Station"),
|
||||
environment("runtime-id-3", "Kernel Cabin"),
|
||||
]);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
environments.map(({ displayUrl }) => displayUrl),
|
||||
[
|
||||
"https://moonbase.tail9f3a.ts.net/",
|
||||
"https://suspense-vps.hel1.t3.sh/",
|
||||
"http://100.82.16.5:3773/",
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves environments outside the showcase fixture unchanged", () => {
|
||||
const original = environment(
|
||||
"runtime-id-4",
|
||||
"My Workstation",
|
||||
"https://workstation.example.test/",
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(applyShowcaseLocalEnvironmentDisplayUrls([original]), [original]);
|
||||
});
|
||||
|
||||
it("does not persist a cosmetic showcase URL when only the label is saved", () => {
|
||||
assert.equal(
|
||||
resolveShowcaseEnvironmentUpdateDisplayUrl({
|
||||
actualDisplayUrl: "http://127.0.0.1:3773/",
|
||||
presentedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
|
||||
submittedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
|
||||
}),
|
||||
"http://127.0.0.1:3773/",
|
||||
);
|
||||
assert.equal(
|
||||
resolveShowcaseEnvironmentUpdateDisplayUrl({
|
||||
actualDisplayUrl: "http://127.0.0.1:3773/",
|
||||
presentedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
|
||||
submittedDisplayUrl: "https://new-host.example.com/",
|
||||
}),
|
||||
"https://new-host.example.com/",
|
||||
);
|
||||
});
|
||||
@@ -1,70 +0,0 @@
|
||||
import { EnvironmentId } from "@t3tools/contracts";
|
||||
|
||||
import type { RelayEnvironmentView } from "../connection/useConnectionController";
|
||||
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
|
||||
|
||||
const SHOWCASE_LOCAL_ENVIRONMENT_DISPLAY_URLS: Readonly<Record<string, string>> = {
|
||||
"Moonbase Terminal": "https://moonbase.tail9f3a.ts.net/",
|
||||
"Suspense Station": "https://suspense-vps.hel1.t3.sh/",
|
||||
"Kernel Cabin": "http://100.82.16.5:3773/",
|
||||
};
|
||||
|
||||
export function applyShowcaseLocalEnvironmentDisplayUrls(
|
||||
environments: ReadonlyArray<ConnectedEnvironmentSummary>,
|
||||
): ReadonlyArray<ConnectedEnvironmentSummary> {
|
||||
return environments.map((environment) => ({
|
||||
...environment,
|
||||
displayUrl:
|
||||
SHOWCASE_LOCAL_ENVIRONMENT_DISPLAY_URLS[environment.environmentLabel] ??
|
||||
environment.displayUrl,
|
||||
}));
|
||||
}
|
||||
|
||||
export function resolveShowcaseEnvironmentUpdateDisplayUrl(input: {
|
||||
readonly actualDisplayUrl: string;
|
||||
readonly presentedDisplayUrl: string;
|
||||
readonly submittedDisplayUrl: string;
|
||||
}): string {
|
||||
return input.submittedDisplayUrl === input.presentedDisplayUrl
|
||||
? input.actualDisplayUrl
|
||||
: input.submittedDisplayUrl;
|
||||
}
|
||||
|
||||
const pocketPiId = EnvironmentId.make("showcase-pocket-pi");
|
||||
const pocketPiEndpoint = {
|
||||
httpBaseUrl: "https://pocket-pi.t3.sh",
|
||||
wsBaseUrl: "wss://pocket-pi.t3.sh",
|
||||
providerKind: "t3_relay" as const,
|
||||
};
|
||||
|
||||
export const SHOWCASE_CONNECTED_CLOUD_ENVIRONMENTS: ReadonlyArray<ConnectedEnvironmentSummary> = [
|
||||
{
|
||||
environmentId: EnvironmentId.make("showcase-aurora-gpu"),
|
||||
environmentLabel: "Aurora GPU Pod",
|
||||
displayUrl: "https://aurora-gpu.t3.sh",
|
||||
isRelayManaged: true,
|
||||
connectionState: "connected",
|
||||
connectionError: null,
|
||||
connectionErrorTraceId: null,
|
||||
},
|
||||
];
|
||||
|
||||
export const SHOWCASE_AVAILABLE_CLOUD_ENVIRONMENTS: ReadonlyArray<RelayEnvironmentView> = [
|
||||
{
|
||||
environment: {
|
||||
environmentId: pocketPiId,
|
||||
label: "Pocket Pi",
|
||||
endpoint: pocketPiEndpoint,
|
||||
linkedAt: "2026-07-16T08:00:00.000Z",
|
||||
},
|
||||
availability: "online",
|
||||
status: {
|
||||
environmentId: pocketPiId,
|
||||
endpoint: pocketPiEndpoint,
|
||||
status: "online",
|
||||
checkedAt: "2026-07-16T08:41:00.000Z",
|
||||
},
|
||||
error: null,
|
||||
traceId: null,
|
||||
},
|
||||
];
|
||||
@@ -1,72 +0,0 @@
|
||||
import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
|
||||
import { EnvironmentId, ProjectId, ProviderInstanceId } from "@t3tools/contracts";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
|
||||
import {
|
||||
buildShowcasePendingTasks,
|
||||
SHOWCASE_PENDING_TASK_DEFINITIONS,
|
||||
} from "./showcasePendingTasks";
|
||||
|
||||
const projects: ReadonlyArray<EnvironmentProject> = [
|
||||
{
|
||||
environmentId: EnvironmentId.make("moonbase-terminal"),
|
||||
id: ProjectId.make("t3code"),
|
||||
title: "T3 Code",
|
||||
workspaceRoot: "/workspace/t3code",
|
||||
repositoryIdentity: null,
|
||||
defaultModelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
|
||||
scripts: [],
|
||||
createdAt: "2026-07-16T08:00:00.000Z",
|
||||
updatedAt: "2026-07-16T08:00:00.000Z",
|
||||
},
|
||||
{
|
||||
environmentId: EnvironmentId.make("suspense-station"),
|
||||
id: ProjectId.make("react"),
|
||||
title: "React",
|
||||
workspaceRoot: "/workspace/react",
|
||||
repositoryIdentity: null,
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-07-16T08:00:00.000Z",
|
||||
updatedAt: "2026-07-16T08:00:00.000Z",
|
||||
},
|
||||
];
|
||||
|
||||
it("builds sendable-looking pending tasks against real showcase projects", () => {
|
||||
const tasks = buildShowcasePendingTasks(projects, Date.parse("2026-07-16T09:00:00.000Z"));
|
||||
|
||||
assert.equal(tasks.length, SHOWCASE_PENDING_TASK_DEFINITIONS.length);
|
||||
assert.deepStrictEqual(
|
||||
tasks.map((task) => ({
|
||||
environmentId: String(task.environmentId),
|
||||
projectId: task.creation ? String(task.creation.projectId) : undefined,
|
||||
title: task.creation?.projectTitle,
|
||||
branch: task.creation?.branch,
|
||||
createdAt: task.createdAt,
|
||||
})),
|
||||
[
|
||||
{
|
||||
environmentId: "moonbase-terminal",
|
||||
projectId: "t3code",
|
||||
title: "T3 Code",
|
||||
branch: "feat/offline-launchpad",
|
||||
createdAt: "2026-07-16T08:52:00.000Z",
|
||||
},
|
||||
{
|
||||
environmentId: "suspense-station",
|
||||
projectId: "react",
|
||||
title: "React",
|
||||
branch: "perf/tunnel-handoff",
|
||||
createdAt: "2026-07-16T08:33:00.000Z",
|
||||
},
|
||||
],
|
||||
);
|
||||
assert.equal(
|
||||
tasks.every((task) => task.modelSelection !== undefined),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("waits until every referenced project has hydrated", () => {
|
||||
assert.equal(buildShowcasePendingTasks(projects.slice(0, 1), Date.now()).length, 1);
|
||||
});
|
||||
@@ -1,66 +0,0 @@
|
||||
import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
|
||||
import {
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
MessageId,
|
||||
ProviderInstanceId,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import type { QueuedThreadMessage } from "../../state/thread-outbox-model";
|
||||
|
||||
export const SHOWCASE_PENDING_TASK_DEFINITIONS = [
|
||||
{
|
||||
projectId: "t3code",
|
||||
id: "offline-launch-checklist",
|
||||
text: "Ship the offline launch checklist before touchdown ✈️",
|
||||
branch: "feat/offline-launchpad",
|
||||
minutesAgo: 8,
|
||||
},
|
||||
{
|
||||
projectId: "react",
|
||||
id: "train-tunnel-suspense",
|
||||
text: "Polish the Suspense handoff for the train tunnel 🚇",
|
||||
branch: "perf/tunnel-handoff",
|
||||
minutesAgo: 27,
|
||||
},
|
||||
] as const;
|
||||
|
||||
const FALLBACK_MODEL_SELECTION = {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5.4",
|
||||
} as const;
|
||||
|
||||
export function buildShowcasePendingTasks(
|
||||
projects: ReadonlyArray<EnvironmentProject>,
|
||||
now: number,
|
||||
): ReadonlyArray<QueuedThreadMessage> {
|
||||
return SHOWCASE_PENDING_TASK_DEFINITIONS.flatMap((definition) => {
|
||||
const project = projects.find((candidate) => String(candidate.id) === definition.projectId);
|
||||
if (!project) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
environmentId: project.environmentId,
|
||||
threadId: ThreadId.make(`showcase-pending-${definition.id}`),
|
||||
messageId: MessageId.make(`showcase-pending-message-${definition.id}`),
|
||||
commandId: CommandId.make(`showcase-pending-command-${definition.id}`),
|
||||
text: definition.text,
|
||||
attachments: [],
|
||||
modelSelection: project.defaultModelSelection ?? FALLBACK_MODEL_SELECTION,
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
creation: {
|
||||
projectId: project.id,
|
||||
projectTitle: project.title,
|
||||
projectCwd: project.workspaceRoot,
|
||||
workspaceMode: "local" as const,
|
||||
branch: definition.branch,
|
||||
worktreePath: project.workspaceRoot,
|
||||
},
|
||||
createdAt: new Date(now - definition.minutesAgo * 60_000).toISOString(),
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import { assert, it } from "@effect/vitest";
|
||||
|
||||
import { retryShowcaseOperation } from "./showcaseRetry";
|
||||
|
||||
it("retries a failed showcase operation until it succeeds", async () => {
|
||||
let attempts = 0;
|
||||
const succeeded = await retryShowcaseOperation(
|
||||
async () => {
|
||||
attempts += 1;
|
||||
return attempts === 3;
|
||||
},
|
||||
{ isCancelled: () => false, retryDelayMs: 0 },
|
||||
);
|
||||
|
||||
assert.equal(succeeded, true);
|
||||
assert.equal(attempts, 3);
|
||||
});
|
||||
|
||||
it("recovers when a showcase operation attempt hangs", async () => {
|
||||
let attempts = 0;
|
||||
const succeeded = await retryShowcaseOperation(
|
||||
() => {
|
||||
attempts += 1;
|
||||
return attempts === 1 ? new Promise<boolean>(() => undefined) : Promise.resolve(true);
|
||||
},
|
||||
{ isCancelled: () => false, attemptTimeoutMs: 1, retryDelayMs: 0 },
|
||||
);
|
||||
|
||||
assert.equal(succeeded, true);
|
||||
assert.equal(attempts, 2);
|
||||
});
|
||||
|
||||
it("stops retrying when the owning showcase effect is cancelled", async () => {
|
||||
let cancelled = false;
|
||||
const succeeded = await retryShowcaseOperation(
|
||||
async () => {
|
||||
cancelled = true;
|
||||
return false;
|
||||
},
|
||||
{ isCancelled: () => cancelled, retryDelayMs: 0 },
|
||||
);
|
||||
|
||||
assert.equal(succeeded, false);
|
||||
});
|
||||
@@ -1,46 +0,0 @@
|
||||
export interface ShowcaseRetryOptions {
|
||||
readonly isCancelled: () => boolean;
|
||||
readonly attemptTimeoutMs?: number;
|
||||
readonly retryDelayMs?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_ATTEMPT_TIMEOUT_MS = 10_000;
|
||||
const DEFAULT_RETRY_DELAY_MS = 500;
|
||||
|
||||
function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function runAttemptWithTimeout(
|
||||
operation: () => Promise<boolean>,
|
||||
timeoutMs: number,
|
||||
): Promise<boolean> {
|
||||
let timeout: ReturnType<typeof setTimeout> | null = null;
|
||||
try {
|
||||
return await Promise.race([
|
||||
operation(),
|
||||
new Promise<boolean>((resolve) => {
|
||||
timeout = setTimeout(() => resolve(false), timeoutMs);
|
||||
}),
|
||||
]);
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
if (timeout !== null) clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
/** Retry transient showcase setup work until it succeeds or the owning effect unmounts. */
|
||||
export async function retryShowcaseOperation(
|
||||
operation: () => Promise<boolean>,
|
||||
options: ShowcaseRetryOptions,
|
||||
): Promise<boolean> {
|
||||
const attemptTimeoutMs = options.attemptTimeoutMs ?? DEFAULT_ATTEMPT_TIMEOUT_MS;
|
||||
const retryDelayMs = options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS;
|
||||
|
||||
while (!options.isCancelled()) {
|
||||
if (await runAttemptWithTimeout(operation, attemptTimeoutMs)) return true;
|
||||
if (!options.isCancelled()) await delay(retryDelayMs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -37,7 +37,6 @@ interface TerminalSurfaceProps extends ViewProps {
|
||||
readonly buffer: string;
|
||||
readonly fontSize?: number;
|
||||
readonly isRunning: boolean;
|
||||
readonly autoFocus?: boolean;
|
||||
readonly keyboardFocusRequest?: number;
|
||||
readonly theme?: TerminalTheme;
|
||||
readonly onInput: (data: string) => void;
|
||||
@@ -216,7 +215,6 @@ export const TerminalSurface = memo(function TerminalSurface(props: TerminalSurf
|
||||
<View style={props.style}>
|
||||
<NativeTerminalSurfaceView
|
||||
appearanceScheme={appearanceScheme}
|
||||
autoFocus={props.autoFocus ?? true}
|
||||
backgroundColor={theme.background}
|
||||
focusRequest={props.isRunning ? (props.keyboardFocusRequest ?? 0) : 0}
|
||||
foregroundColor={theme.foreground}
|
||||
|
||||
@@ -70,7 +70,6 @@ import { cacheTerminalGridSize, getCachedTerminalGridSize } from "./terminalUiSt
|
||||
const DEFAULT_TERMINAL_COLS = 80;
|
||||
const DEFAULT_TERMINAL_ROWS = 24;
|
||||
const TERMINAL_ACCESSORY_HEIGHT = 52;
|
||||
const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
|
||||
|
||||
type PendingModifier = "ctrl" | "meta";
|
||||
type HostPlatform = "mac" | "linux" | "windows" | "unknown";
|
||||
@@ -1219,7 +1218,6 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
|
||||
<>
|
||||
<View className="flex-1" style={{ paddingBottom: terminalBottomInset }}>
|
||||
<TerminalSurface
|
||||
autoFocus={!SHOWCASE_ENABLED}
|
||||
buffer={terminalSurfaceBuffer}
|
||||
fontSize={fontSize}
|
||||
isRunning={isRunning}
|
||||
|
||||
@@ -23,7 +23,6 @@ interface TerminalResizeEvent {
|
||||
|
||||
export interface NativeTerminalSurfaceProps extends ViewProps {
|
||||
readonly appearanceScheme?: "light" | "dark";
|
||||
readonly autoFocus?: boolean;
|
||||
readonly focusRequest?: number;
|
||||
readonly themeConfig?: string;
|
||||
readonly backgroundColor?: string;
|
||||
|
||||
@@ -101,10 +101,7 @@ export function createThreadOutboxManager(options: ThreadOutboxManagerOptions) {
|
||||
cause,
|
||||
});
|
||||
}
|
||||
setMessages([
|
||||
...currentMessages().filter((candidate) => candidate.messageId !== message.messageId),
|
||||
message,
|
||||
]);
|
||||
setMessages([...currentMessages(), message]);
|
||||
});
|
||||
|
||||
// Rewrites an already-queued message. A no-op when the message has been
|
||||
|
||||
@@ -294,31 +294,6 @@ describe("thread outbox", () => {
|
||||
registry.dispose();
|
||||
});
|
||||
|
||||
it("replaces an existing message when an enqueue retry uses the same id", async () => {
|
||||
const registry = AtomRegistry.make();
|
||||
const manager = createThreadOutboxManager({
|
||||
registry,
|
||||
storage: {
|
||||
load: async () => [],
|
||||
write: async () => undefined,
|
||||
remove: async () => undefined,
|
||||
},
|
||||
});
|
||||
const message = queuedMessage({
|
||||
messageId: "message-1",
|
||||
createdAt: "2026-06-08T10:00:01.000Z",
|
||||
});
|
||||
const retried = { ...message, text: "retried" };
|
||||
|
||||
await manager.enqueue(message);
|
||||
await manager.enqueue(retried);
|
||||
|
||||
expect(registry.get(manager.queuedMessagesByThreadKeyAtom)).toEqual({
|
||||
"environment-1:thread-1": [retried],
|
||||
});
|
||||
registry.dispose();
|
||||
});
|
||||
|
||||
it("updates a queued message in place but never resurrects a removed one", async () => {
|
||||
const registry = AtomRegistry.make();
|
||||
const stored = new Map<MessageId, QueuedThreadMessage>();
|
||||
|
||||
@@ -62,7 +62,7 @@ const promptText = NodeProcess.argv[4] ?? "helo";
|
||||
const targetReasoning = NodeProcess.env.CURSOR_REASONING ?? "";
|
||||
const targetContext = NodeProcess.env.CURSOR_CONTEXT ?? "";
|
||||
const targetFast = NodeProcess.env.CURSOR_FAST ?? "";
|
||||
const agentBin = NodeProcess.env.CURSOR_AGENT_BIN ?? "cursor-agent";
|
||||
const agentBin = NodeProcess.env.CURSOR_AGENT_BIN ?? "agent";
|
||||
const promptWaitMs = Number(NodeProcess.env.CURSOR_PROMPT_WAIT_MS ?? "4000");
|
||||
const requestTimeoutMs = Number(NodeProcess.env.CURSOR_REQUEST_TIMEOUT_MS ?? "20000");
|
||||
|
||||
|
||||
@@ -32,63 +32,6 @@ describe("imageMime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects payload with characters outside the base64 alphabet", () => {
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVs!bG8=")).toBeNull();
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVs,bG8=")).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects structurally malformed base64", () => {
|
||||
// '=' before the trailing padding position
|
||||
expect(parseBase64DataUrl("data:image/png;base64,AB=CD===")).toBeNull();
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGV=bG8=")).toBeNull();
|
||||
// more than two padding characters
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVsbG8=====AAA")).toBeNull();
|
||||
// length not a multiple of 4
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVsbG8")).toBeNull();
|
||||
});
|
||||
|
||||
it("accepts base64 with one or two trailing padding characters", () => {
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVsbA==")).toEqual({
|
||||
mimeType: "image/png",
|
||||
base64: "SGVsbA==",
|
||||
});
|
||||
expect(parseBase64DataUrl("data:image/png;base64,SGVsbG8h")).toEqual({
|
||||
mimeType: "image/png",
|
||||
base64: "SGVsbG8h",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects empty and whitespace-only payloads", () => {
|
||||
expect(parseBase64DataUrl("data:image/png;base64,")).toBeNull();
|
||||
expect(parseBase64DataUrl("data:image/png;base64, \r\n")).toBeNull();
|
||||
});
|
||||
|
||||
it("parses a case-insensitive scheme and mime type", () => {
|
||||
expect(parseBase64DataUrl("DATA:IMAGE/PNG;BASE64,SGVsbG8=")).toEqual({
|
||||
mimeType: "image/png",
|
||||
base64: "SGVsbG8=",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses a multi-megabyte payload from a deep call stack", () => {
|
||||
// Regression: matching the payload with a regex borrowed the JS call
|
||||
// stack, so a ~10 MB image parsed inside fiber execution threw
|
||||
// "RangeError: Maximum call stack size exceeded".
|
||||
const dataUrl = `data:image/png;base64,${"A".repeat(14_000_000)}`;
|
||||
const atDepth = (depth: number): ReturnType<typeof parseBase64DataUrl> =>
|
||||
depth === 0 ? parseBase64DataUrl(dataUrl) : atDepth(depth - 1);
|
||||
const findMaxDepth = (depth: number): number => {
|
||||
try {
|
||||
return findMaxDepth(depth + 1);
|
||||
} catch {
|
||||
return depth;
|
||||
}
|
||||
};
|
||||
const result = atDepth(Math.floor(findMaxDepth(0) * 0.85));
|
||||
expect(result?.mimeType).toBe("image/png");
|
||||
expect(result?.base64.length).toBe(14_000_000);
|
||||
});
|
||||
|
||||
it("does not read inherited keys from mime extension map", () => {
|
||||
expect(inferImageExtension({ mimeType: "constructor" })).toBe(".bin");
|
||||
});
|
||||
|
||||
@@ -29,43 +29,17 @@ export const SAFE_IMAGE_FILE_EXTENSIONS = new Set([
|
||||
".webp",
|
||||
]);
|
||||
|
||||
// Whether `code` is a character the base64 payload may contain, aside from
|
||||
// the whitespace handled separately below.
|
||||
function isBase64Char(code: number): boolean {
|
||||
return (
|
||||
(code >= 0x61 && code <= 0x7a) || // a-z
|
||||
(code >= 0x41 && code <= 0x5a) || // A-Z
|
||||
(code >= 0x30 && code <= 0x39) || // 0-9
|
||||
code === 0x2b || // +
|
||||
code === 0x2f || // /
|
||||
code === 0x3d // =
|
||||
);
|
||||
}
|
||||
|
||||
function isBase64Whitespace(code: number): boolean {
|
||||
return code === 0x0d || code === 0x0a || code === 0x20; // \r \n space
|
||||
}
|
||||
|
||||
// Data URLs carry the full image payload, so this parser must never run a
|
||||
// regex across the payload: V8's regex engine borrows the JS call stack, and
|
||||
// matching a multi-megabyte string from a deep call stack (e.g. inside fiber
|
||||
// execution) throws "Maximum call stack size exceeded".
|
||||
export function parseBase64DataUrl(
|
||||
dataUrl: string,
|
||||
): { readonly mimeType: string; readonly base64: string } | null {
|
||||
const trimmed = dataUrl.trim();
|
||||
if (trimmed.slice(0, 5).toLowerCase() !== "data:") return null;
|
||||
|
||||
const commaIndex = trimmed.indexOf(",");
|
||||
if (commaIndex === -1) return null;
|
||||
const header = trimmed.slice(5, commaIndex);
|
||||
if (header.length === 0) return null;
|
||||
const match = /^data:([^,]+),([a-z0-9+/=\r\n ]+)$/i.exec(dataUrl.trim());
|
||||
if (!match) return null;
|
||||
|
||||
const headerParts: Array<string> = [];
|
||||
for (const part of header.split(";")) {
|
||||
const partTrimmed = part.trim();
|
||||
if (partTrimmed.length > 0) {
|
||||
headerParts.push(partTrimmed);
|
||||
for (const part of (match[1] ?? "").split(";")) {
|
||||
const trimmed = part.trim();
|
||||
if (trimmed.length > 0) {
|
||||
headerParts.push(trimmed);
|
||||
}
|
||||
}
|
||||
if (headerParts.length < 2) {
|
||||
@@ -77,37 +51,8 @@ export function parseBase64DataUrl(
|
||||
}
|
||||
|
||||
const mimeType = headerParts[0]?.toLowerCase();
|
||||
if (!mimeType) return null;
|
||||
|
||||
const payload = trimmed.slice(commaIndex + 1);
|
||||
const runs: Array<string> = [];
|
||||
let runStart = -1;
|
||||
for (let index = 0; index < payload.length; index += 1) {
|
||||
const code = payload.charCodeAt(index);
|
||||
if (isBase64Char(code)) {
|
||||
if (runStart === -1) runStart = index;
|
||||
continue;
|
||||
}
|
||||
if (!isBase64Whitespace(code)) return null;
|
||||
if (runStart !== -1) {
|
||||
runs.push(payload.slice(runStart, index));
|
||||
runStart = -1;
|
||||
}
|
||||
}
|
||||
if (runStart !== -1) {
|
||||
runs.push(payload.slice(runStart));
|
||||
}
|
||||
const base64 = runs.length === 1 ? runs[0]! : runs.join("");
|
||||
if (base64.length === 0 || base64.length % 4 !== 0) return null;
|
||||
const firstPad = base64.indexOf("=");
|
||||
if (firstPad !== -1) {
|
||||
// '=' is only valid as one or two trailing padding characters; Node's
|
||||
// decoder would otherwise silently truncate at the first '='.
|
||||
if (base64.length - firstPad > 2) return null;
|
||||
for (let index = firstPad; index < base64.length; index += 1) {
|
||||
if (base64.charCodeAt(index) !== 0x3d) return null;
|
||||
}
|
||||
}
|
||||
const base64 = match[2]?.replace(/\s+/g, "");
|
||||
if (!mimeType || !base64) return null;
|
||||
|
||||
return { mimeType, base64 };
|
||||
}
|
||||
|
||||
@@ -411,28 +411,6 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
|
||||
}).pipe(Effect.provide(makeKeybindingsLayer())),
|
||||
);
|
||||
|
||||
it.effect("replacing with a rule that already exists elsewhere does not duplicate it", () =>
|
||||
Effect.gen(function* () {
|
||||
const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
|
||||
yield* writeKeybindingsConfig(keybindingsConfigPath, [
|
||||
{ key: "mod+r", command: "script.run-tests.run" },
|
||||
{ key: "mod+alt+r", command: "script.run-tests.run" },
|
||||
]);
|
||||
yield* Effect.gen(function* () {
|
||||
const keybindings = yield* Keybindings.Keybindings;
|
||||
return yield* keybindings.upsertKeybindingRule({
|
||||
key: "mod+alt+r",
|
||||
command: "script.run-tests.run",
|
||||
replace: { key: "mod+r", command: "script.run-tests.run" },
|
||||
});
|
||||
});
|
||||
|
||||
const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
|
||||
const persistedView = persisted.map(({ key, command }) => ({ key, command }));
|
||||
assert.deepEqual(persistedView, [{ key: "mod+alt+r", command: "script.run-tests.run" }]);
|
||||
}).pipe(Effect.provide(makeKeybindingsLayer())),
|
||||
);
|
||||
|
||||
it.effect("removes only the targeted custom keybinding", () =>
|
||||
Effect.gen(function* () {
|
||||
const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
|
||||
|
||||
@@ -644,9 +644,7 @@ const make = Effect.gen(function* () {
|
||||
const nextConfig = [
|
||||
...customConfig.filter((entry) => {
|
||||
if (replaceTarget) {
|
||||
return (
|
||||
!isSameKeybindingRule(entry, replaceTarget) && !isSameKeybindingRule(entry, rule)
|
||||
);
|
||||
return !isSameKeybindingRule(entry, replaceTarget);
|
||||
}
|
||||
return !isSameKeybindingRule(entry, rule);
|
||||
}),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import * as Arr from "effect/Array";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Struct from "effect/Struct";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
@@ -282,30 +280,18 @@ export const make = Effect.gen(function* () {
|
||||
),
|
||||
),
|
||||
Effect.flatMap((rows) =>
|
||||
// Skip rows that no longer decode (e.g. written by an older build)
|
||||
// instead of failing the whole list — one stale row must not disable
|
||||
// every consumer that enumerates sessions, such as the reaper.
|
||||
Effect.forEach(rows, (row) =>
|
||||
decodeRuntimeRow(row).pipe(
|
||||
Effect.map(Option.some),
|
||||
Effect.catch((cause) =>
|
||||
Effect.logWarning("provider.session.runtime.row-skipped", {
|
||||
threadId: row.threadId,
|
||||
error: PersistenceDecodeError.fromSchemaError(
|
||||
"ProviderSessionRuntimeRepository.list:decodeRows",
|
||||
cause,
|
||||
{ threadId: row.threadId },
|
||||
).message,
|
||||
}).pipe(Effect.as(Option.none<ProviderSessionRuntime>())),
|
||||
Effect.mapError((cause) =>
|
||||
PersistenceDecodeError.fromSchemaError(
|
||||
"ProviderSessionRuntimeRepository.list:decodeRows",
|
||||
cause,
|
||||
{ threadId: row.threadId },
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Effect.map((decoded) =>
|
||||
Arr.filterMap(decoded, (row) =>
|
||||
Option.isSome(row) ? Result.succeed(row.value) : Result.failVoid,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const deleteByThreadId: ProviderSessionRuntimeRepository["Service"]["deleteByThreadId"] = (
|
||||
|
||||
@@ -182,7 +182,7 @@ describe("persistence error correlation", () => {
|
||||
}).pipe(Effect.provide(authPairingLinkLayer)),
|
||||
);
|
||||
|
||||
it.effect("skips undecodable provider runtime rows and correlates SQL failures by thread", () =>
|
||||
it.effect("correlates provider runtime SQL and per-row decode failures by thread", () =>
|
||||
Effect.gen(function* () {
|
||||
const runtimes = yield* ProviderSessionRuntime.ProviderSessionRuntimeRepository;
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
@@ -215,24 +215,16 @@ describe("persistence error correlation", () => {
|
||||
)
|
||||
`;
|
||||
|
||||
const validThreadId = ThreadId.make("thread-valid");
|
||||
yield* runtimes.upsert({
|
||||
threadId: validThreadId,
|
||||
providerName: "codex",
|
||||
providerInstanceId: null,
|
||||
adapterKey: "codex",
|
||||
runtimeMode: "full-access",
|
||||
status: "running",
|
||||
lastSeenAt,
|
||||
resumeCursor: null,
|
||||
runtimePayload: null,
|
||||
});
|
||||
|
||||
const listed = yield* runtimes.list();
|
||||
assert.deepStrictEqual(
|
||||
listed.map((runtime) => runtime.threadId),
|
||||
[validThreadId],
|
||||
const decodeError = yield* Effect.flip(runtimes.list());
|
||||
assert.instanceOf(decodeError, PersistenceErrors.PersistenceDecodeError);
|
||||
assert.deepStrictEqual(decodeError.correlation, { threadId });
|
||||
assert.equal(
|
||||
decodeError.message,
|
||||
`Decode error in ProviderSessionRuntimeRepository.list:decodeRows: ${decodeError.issue}`,
|
||||
);
|
||||
assert.notInclude(decodeError.issue, runtimePayload);
|
||||
assert.notInclude(decodeError.message, runtimePayload);
|
||||
assert.notInclude(decodeError.message, lastSeenAt);
|
||||
|
||||
yield* sql`DROP TABLE provider_session_runtime`;
|
||||
const sqlFailure = yield* Effect.flip(
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { ProviderInteractionMode } from "@t3tools/contracts";
|
||||
|
||||
const T3_CODE_BROWSER_TOOL_INSTRUCTIONS = `
|
||||
|
||||
## T3 Code collaborative browser
|
||||
@@ -147,26 +145,3 @@ The \`request_user_input\` tool is unavailable in Default mode. If you call it w
|
||||
In Default mode, strongly prefer making reasonable assumptions and executing the user's request rather than stopping to ask questions. If you absolutely must ask a question because the answer cannot be discovered from local context and a reasonable assumption would be risky, ask the user directly with a concise plain-text question. Never write a multiple choice question as a textual assistant message.
|
||||
${T3_CODE_BROWSER_TOOL_INSTRUCTIONS}
|
||||
</collaboration_mode>`;
|
||||
|
||||
export interface CodexRuntimeInfo {
|
||||
readonly model: string;
|
||||
readonly reasoningEffort: string;
|
||||
}
|
||||
|
||||
// Values come from trusted config, but keep the block single-line regardless.
|
||||
function toSingleLine(value: string): string {
|
||||
return value.replaceAll(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
export function buildCodexDeveloperInstructions(
|
||||
interactionMode: ProviderInteractionMode,
|
||||
runtime: CodexRuntimeInfo,
|
||||
): string {
|
||||
const base =
|
||||
interactionMode === "plan"
|
||||
? CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS
|
||||
: CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS;
|
||||
return `${base}
|
||||
|
||||
<runtime_info>In case you're asked: you are running in T3 Code through the Codex harness, as ${toSingleLine(runtime.model)} with ${toSingleLine(runtime.reasoningEffort)} reasoning effort. No need to mention this otherwise.</runtime_info>`;
|
||||
}
|
||||
@@ -119,7 +119,6 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
|
||||
Effect.gen(function* () {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const path = yield* Path.Path;
|
||||
const { cwd } = yield* ServerConfig;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const eventLoggers = yield* ProviderEventLoggers;
|
||||
@@ -155,11 +154,11 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
|
||||
capacity: 1,
|
||||
timeToLive: CAPABILITIES_PROBE_TTL,
|
||||
lookup: () =>
|
||||
probeClaudeCapabilities(effectiveConfig, processEnv, cwd).pipe(
|
||||
probeClaudeCapabilities(effectiveConfig, processEnv).pipe(
|
||||
Effect.provideService(Path.Path, path),
|
||||
),
|
||||
});
|
||||
const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig, cwd);
|
||||
const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig);
|
||||
|
||||
const checkProvider = checkClaudeProviderStatus(
|
||||
effectiveConfig,
|
||||
|
||||
@@ -31,23 +31,14 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => {
|
||||
const resolved = path.resolve(NodeOS.homedir(), ".claude-work");
|
||||
|
||||
expect(yield* resolveClaudeHomePath({ homePath })).toBe(resolved);
|
||||
expect((yield* makeClaudeEnvironment({ homePath })).CLAUDE_CONFIG_DIR).toBe(resolved);
|
||||
expect((yield* makeClaudeEnvironment({ homePath })).HOME).toBe(resolved);
|
||||
expect(yield* makeClaudeContinuationGroupKey({ homePath })).toBe(`claude:home:${resolved}`);
|
||||
expect(yield* makeClaudeCapabilitiesCacheKey({ binaryPath: "claude", homePath })).toBe(
|
||||
`claude\0${resolved}\0`,
|
||||
`claude\0${resolved}`,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("separates capability probes by cwd", () =>
|
||||
Effect.gen(function* () {
|
||||
const config = { binaryPath: "claude", homePath: "" };
|
||||
const first = yield* makeClaudeCapabilitiesCacheKey(config, "/repo-a");
|
||||
const second = yield* makeClaudeCapabilitiesCacheKey(config, "/repo-b");
|
||||
expect(first).not.toBe(second);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("keeps continuation compatible across instances with the same Claude HOME", () =>
|
||||
Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
|
||||
@@ -24,13 +24,7 @@ export const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function
|
||||
const resolvedHomePath = yield* resolveClaudeHomePath(config);
|
||||
return {
|
||||
...resolvedBaseEnv,
|
||||
// Isolate this instance's config via CLAUDE_CONFIG_DIR rather than HOME.
|
||||
// Overriding HOME also relocates the macOS login keychain lookup
|
||||
// ($HOME/Library/Keychains), so the spawned CLI can't find its stored
|
||||
// OAuth credentials and reports "Not logged in". CLAUDE_CONFIG_DIR points
|
||||
// Claude Code at its config dir directly while leaving HOME (and the
|
||||
// keychain) intact.
|
||||
CLAUDE_CONFIG_DIR: resolvedHomePath,
|
||||
HOME: resolvedHomePath,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -44,9 +38,8 @@ export const makeClaudeContinuationGroupKey = Effect.fn("makeClaudeContinuationG
|
||||
export const makeClaudeCapabilitiesCacheKey = Effect.fn("makeClaudeCapabilitiesCacheKey")(
|
||||
function* (
|
||||
config: Pick<ClaudeSettings, "binaryPath" | "homePath">,
|
||||
cwd?: string,
|
||||
): Effect.fn.Return<string, never, Path.Path> {
|
||||
const resolvedHomePath = yield* resolveClaudeHomePath(config);
|
||||
return `${config.binaryPath}\0${resolvedHomePath}\0${cwd ?? ""}`;
|
||||
return `${config.binaryPath}\0${resolvedHomePath}`;
|
||||
},
|
||||
);
|
||||
@@ -114,9 +114,6 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
|
||||
|
||||
const sessionsTarget = yield* fileSystem.readLink(path.join(shadowHome, "sessions"));
|
||||
const configTarget = yield* fileSystem.readLink(path.join(shadowHome, "config.toml"));
|
||||
const mcpOauthLocksTarget = yield* fileSystem.readLink(
|
||||
path.join(shadowHome, "mcp-oauth-locks"),
|
||||
);
|
||||
const modelsCacheExists = yield* fileSystem.exists(
|
||||
path.join(shadowHome, "models_cache.json"),
|
||||
);
|
||||
@@ -127,45 +124,12 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
|
||||
|
||||
expect(sessionsTarget).toBe(path.join(sharedHome, "sessions"));
|
||||
expect(configTarget).toBe(path.join(sharedHome, "config.toml"));
|
||||
expect(mcpOauthLocksTarget).toBe(path.join(sharedHome, "mcp-oauth-locks"));
|
||||
expect(modelsCacheExists).toBe(false);
|
||||
expect(authLinkResult._tag).toBe("Failure");
|
||||
expect(authContents).toContain("shadow");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("replaces Codex-created local MCP OAuth locks with the shared lock directory", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const sharedHome = yield* makeTempDir("t3code-codex-shared-");
|
||||
const shadowRoot = yield* makeTempDir("t3code-codex-shadow-root-");
|
||||
const shadowHome = path.join(shadowRoot, "shadow");
|
||||
const sharedLocks = path.join(sharedHome, "mcp-oauth-locks");
|
||||
const shadowLocks = path.join(shadowHome, "mcp-oauth-locks");
|
||||
|
||||
yield* writeTextFile(path.join(sharedLocks, "file-store.lock"), "");
|
||||
yield* writeTextFile(path.join(shadowLocks, "file-store.lock"), "");
|
||||
|
||||
const layout = yield* resolveCodexHomeLayout(
|
||||
decodeCodexSettings({
|
||||
homePath: sharedHome,
|
||||
shadowHomePath: shadowHome,
|
||||
}),
|
||||
);
|
||||
|
||||
yield* materializeCodexShadowHome(layout);
|
||||
|
||||
const locksTarget = yield* fileSystem.readLink(shadowLocks);
|
||||
const sharedLockExists = yield* fileSystem.exists(
|
||||
path.join(sharedLocks, "file-store.lock"),
|
||||
);
|
||||
|
||||
expect(locksTarget).toBe(sharedLocks);
|
||||
expect(sharedLockExists).toBe(true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("accepts Codex-created shadow-local runtime directories", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -26,12 +26,10 @@ const KNOWN_SHARED_DIRECTORIES = [
|
||||
"plugins",
|
||||
"cache",
|
||||
"logs",
|
||||
"mcp-oauth-locks",
|
||||
] as const;
|
||||
|
||||
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
|
||||
const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp"]);
|
||||
const REPLACEABLE_SHARED_RUNTIME_DIRECTORIES = new Set(["mcp-oauth-locks"]);
|
||||
|
||||
function resolveHomePath(path: Path.Path, value: string | undefined): string {
|
||||
const expanded =
|
||||
@@ -227,6 +225,16 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
|
||||
linkPath: link,
|
||||
});
|
||||
|
||||
if (state._tag === "NotSymlink") {
|
||||
return yield* new CodexShadowHomeEntryConflictError({
|
||||
sharedHomePath: input.sharedHomePath,
|
||||
effectiveHomePath: input.effectiveHomePath,
|
||||
entryName: input.entryName,
|
||||
linkPath: link,
|
||||
targetPath: target,
|
||||
});
|
||||
}
|
||||
|
||||
const createLink = input.fileSystem.symlink(target, link).pipe(
|
||||
Effect.catchTags({
|
||||
PlatformError: (cause) =>
|
||||
@@ -242,33 +250,6 @@ const ensureSymlink = Effect.fn("CodexHomeLayout.ensureSymlink")(function* (inpu
|
||||
}),
|
||||
);
|
||||
|
||||
if (state._tag === "NotSymlink") {
|
||||
if (!REPLACEABLE_SHARED_RUNTIME_DIRECTORIES.has(input.entryName)) {
|
||||
return yield* new CodexShadowHomeEntryConflictError({
|
||||
sharedHomePath: input.sharedHomePath,
|
||||
effectiveHomePath: input.effectiveHomePath,
|
||||
entryName: input.entryName,
|
||||
linkPath: link,
|
||||
targetPath: target,
|
||||
});
|
||||
}
|
||||
|
||||
yield* input.fileSystem.remove(link, { recursive: true }).pipe(
|
||||
Effect.catchTags({
|
||||
PlatformError: (cause) =>
|
||||
new CodexShadowHomeFileSystemError({
|
||||
sharedHomePath: input.sharedHomePath,
|
||||
effectiveHomePath: input.effectiveHomePath,
|
||||
operation: "remove",
|
||||
path: link,
|
||||
entryName: input.entryName,
|
||||
cause,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
return yield* createLink;
|
||||
}
|
||||
|
||||
if (state._tag === "Missing") {
|
||||
return yield* createLink;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* CursorDriver — `ProviderDriver` for the Cursor Agent (`cursor-agent`) runtime.
|
||||
* CursorDriver — `ProviderDriver` for the Cursor Agent (`agent`) runtime.
|
||||
*
|
||||
* Cursor exposes an ACP-based CLI. Model catalog and capability refreshes
|
||||
* happen during the managed provider status check via Cursor's
|
||||
@@ -42,7 +42,7 @@ import type { ServerProviderDraft } from "../providerSnapshot.ts";
|
||||
import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";
|
||||
import {
|
||||
makeProviderMaintenanceCapabilities,
|
||||
type ProviderMaintenanceCapabilitiesResolver,
|
||||
makeStaticProviderMaintenanceResolver,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import {
|
||||
@@ -54,16 +54,15 @@ const decodeCursorSettings = Schema.decodeSync(CursorSettings);
|
||||
|
||||
const DRIVER_KIND = ProviderDriverKind.make("cursor");
|
||||
const SNAPSHOT_REFRESH_INTERVAL = Duration.minutes(5);
|
||||
const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
|
||||
resolve: (options) =>
|
||||
makeProviderMaintenanceCapabilities({
|
||||
provider: DRIVER_KIND,
|
||||
packageName: null,
|
||||
updateExecutable: options?.binaryPath?.trim() || "cursor-agent",
|
||||
updateArgs: ["update"],
|
||||
updateLockKey: "cursor-agent",
|
||||
}),
|
||||
};
|
||||
const UPDATE = makeStaticProviderMaintenanceResolver(
|
||||
makeProviderMaintenanceCapabilities({
|
||||
provider: DRIVER_KIND,
|
||||
packageName: null,
|
||||
updateExecutable: "agent",
|
||||
updateArgs: ["update"],
|
||||
updateLockKey: "cursor-agent",
|
||||
}),
|
||||
);
|
||||
|
||||
export type CursorDriverEnv =
|
||||
| ChildProcessSpawner.ChildProcessSpawner
|
||||
@@ -101,7 +100,6 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
defaultConfig: (): CursorSettings => decodeCursorSettings({}),
|
||||
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
@@ -134,7 +132,6 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
|
||||
const checkProvider = checkCursorProviderStatus(effectiveConfig, processEnv).pipe(
|
||||
Effect.map(stampIdentity),
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
Effect.provideService(FileSystem.FileSystem, fileSystem),
|
||||
Effect.provideService(Path.Path, path),
|
||||
|
||||
@@ -84,7 +84,6 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = {
|
||||
defaultConfig: (): GrokSettings => decodeGrokSettings({}),
|
||||
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
@@ -115,7 +114,6 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = {
|
||||
|
||||
const checkProvider = checkGrokProviderStatus(effectiveConfig, processEnv).pipe(
|
||||
Effect.map(stampIdentity),
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
);
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("runs Claude SDK sessions with the configured CLAUDE_CONFIG_DIR", () => {
|
||||
it.effect("runs Claude SDK sessions with the configured Claude HOME", () => {
|
||||
const harness = makeHarness({ claudeConfig: { homePath: "~/.claude-work" } });
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* ClaudeAdapter;
|
||||
@@ -433,10 +433,7 @@ describe("ClaudeAdapterLive", () => {
|
||||
});
|
||||
|
||||
const createInput = harness.getLastCreateQueryInput();
|
||||
assert.equal(
|
||||
createInput?.options.env?.CLAUDE_CONFIG_DIR,
|
||||
NodePath.join(NodeOS.homedir(), ".claude-work"),
|
||||
);
|
||||
assert.equal(createInput?.options.env?.HOME, NodePath.join(NodeOS.homedir(), ".claude-work"));
|
||||
}).pipe(
|
||||
Effect.provideService(Random.Random, makeDeterministicRandomService()),
|
||||
Effect.provide(harness.layer),
|
||||
|
||||
@@ -583,7 +583,6 @@ function waitForAbortSignal(signal: AbortSignal): Promise<void> {
|
||||
const probeClaudeCapabilities = (
|
||||
claudeSettings: ClaudeSettings,
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
cwd?: string,
|
||||
) => {
|
||||
const abort = new AbortController();
|
||||
return Effect.gen(function* () {
|
||||
@@ -603,7 +602,6 @@ const probeClaudeCapabilities = (
|
||||
settingSources: ["user", "project", "local"],
|
||||
allowedTools: [],
|
||||
env: claudeEnvironment,
|
||||
...(cwd ? { cwd } : {}),
|
||||
stderr: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,12 +4,11 @@ import { it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { describe } from "vite-plus/test";
|
||||
import { DEFAULT_MODEL, ThreadId } from "@t3tools/contracts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import * as CodexErrors from "effect-codex-app-server/errors";
|
||||
import * as CodexRpc from "effect-codex-app-server/rpc";
|
||||
|
||||
import {
|
||||
buildCodexDeveloperInstructions,
|
||||
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
} from "../CodexDeveloperInstructions.ts";
|
||||
@@ -119,10 +118,7 @@ describe("buildTurnStartParams", () => {
|
||||
settings: {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoning_effort: "medium",
|
||||
developer_instructions: buildCodexDeveloperInstructions("plan", {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoningEffort: "medium",
|
||||
}),
|
||||
developer_instructions: CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -167,31 +163,12 @@ describe("buildTurnStartParams", () => {
|
||||
settings: {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoning_effort: "medium",
|
||||
developer_instructions: buildCodexDeveloperInstructions("default", {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoningEffort: "medium",
|
||||
}),
|
||||
developer_instructions: CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("reports the same fallback model and effort in settings and instructions", () => {
|
||||
const params = Effect.runSync(
|
||||
buildTurnStartParams({
|
||||
threadId: "provider-thread-1",
|
||||
runtimeMode: "full-access",
|
||||
prompt: "Go",
|
||||
interactionMode: "default",
|
||||
}),
|
||||
);
|
||||
|
||||
const settings = params.collaborationMode?.settings;
|
||||
NodeAssert.equal(settings?.model, DEFAULT_MODEL);
|
||||
NodeAssert.equal(settings?.reasoning_effort, "medium");
|
||||
NodeAssert.ok(settings?.developer_instructions?.includes(`as ${DEFAULT_MODEL} with medium`));
|
||||
});
|
||||
|
||||
it("omits collaboration mode when interaction mode is absent", () => {
|
||||
const params = Effect.runSync(
|
||||
buildTurnStartParams({
|
||||
@@ -217,53 +194,6 @@ describe("buildTurnStartParams", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildCodexDeveloperInstructions", () => {
|
||||
it("appends runtime info after the mode instructions", () => {
|
||||
const instructions = buildCodexDeveloperInstructions("default", {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoningEffort: "high",
|
||||
});
|
||||
|
||||
NodeAssert.ok(instructions.startsWith(CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS));
|
||||
NodeAssert.match(instructions, /T3 Code/);
|
||||
NodeAssert.match(instructions, /Codex harness/);
|
||||
NodeAssert.match(instructions, /as gpt-5\.3-codex with high reasoning effort/);
|
||||
});
|
||||
|
||||
it("includes runtime info alongside plan mode instructions", () => {
|
||||
const instructions = buildCodexDeveloperInstructions("plan", {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoningEffort: "medium",
|
||||
});
|
||||
|
||||
NodeAssert.ok(instructions.startsWith(CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS));
|
||||
NodeAssert.match(instructions, /as gpt-5\.3-codex with medium reasoning effort/);
|
||||
});
|
||||
|
||||
it("varies with the model and effort of each turn", () => {
|
||||
const first = buildCodexDeveloperInstructions("default", {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoningEffort: "medium",
|
||||
});
|
||||
const second = buildCodexDeveloperInstructions("default", {
|
||||
model: "gpt-5.4",
|
||||
reasoningEffort: "high",
|
||||
});
|
||||
|
||||
NodeAssert.notEqual(first, second);
|
||||
});
|
||||
|
||||
it("flattens multiline metadata into single-line runtime info", () => {
|
||||
const instructions = buildCodexDeveloperInstructions("default", {
|
||||
model: "gpt\n5.3\ncodex",
|
||||
reasoningEffort: " high\neffort ",
|
||||
});
|
||||
|
||||
NodeAssert.match(instructions, /as gpt 5\.3 codex with high effort reasoning effort/);
|
||||
NodeAssert.doesNotMatch(instructions, /<runtime_info>[^<]*\n/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("T3 browser developer instructions", () => {
|
||||
it("prefers the product-native preview tools in both collaboration modes", () => {
|
||||
for (const instructions of [
|
||||
|
||||
@@ -37,7 +37,10 @@ import * as EffectCodexSchema from "effect-codex-app-server/schema";
|
||||
|
||||
import { buildCodexInitializeParams } from "./CodexProvider.ts";
|
||||
import { expandHomePath } from "../../pathExpansion.ts";
|
||||
import { buildCodexDeveloperInstructions } from "../CodexDeveloperInstructions.ts";
|
||||
import {
|
||||
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
} from "../CodexDeveloperInstructions.ts";
|
||||
const decodeV2TurnStartResponse = Schema.decodeUnknownEffect(EffectCodexSchema.V2TurnStartResponse);
|
||||
|
||||
const PROVIDER = ProviderDriverKind.make("codex");
|
||||
@@ -328,16 +331,15 @@ function buildCodexCollaborationMode(input: {
|
||||
return undefined;
|
||||
}
|
||||
const model = normalizeCodexModelSlug(input.model) ?? DEFAULT_MODEL;
|
||||
const reasoningEffort = input.effort ?? "medium";
|
||||
return {
|
||||
mode: input.interactionMode,
|
||||
settings: {
|
||||
model,
|
||||
reasoning_effort: reasoningEffort,
|
||||
developer_instructions: buildCodexDeveloperInstructions(input.interactionMode, {
|
||||
model,
|
||||
reasoningEffort,
|
||||
}),
|
||||
reasoning_effort: input.effort ?? "medium",
|
||||
developer_instructions:
|
||||
input.interactionMode === "plan"
|
||||
? CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS
|
||||
: CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
assert.isDefined(delta);
|
||||
if (delta?.type === "content.delta") {
|
||||
assert.equal(delta.payload.delta, "hello from mock");
|
||||
assert.match(String(delta.itemId), /^assistant:mock-session-1:runtime:[^:]+:segment:0$/);
|
||||
assert.match(String(delta.itemId), /^assistant:mock-session-1:segment:0$/);
|
||||
}
|
||||
|
||||
const assistantCompleted = runtimeEvents.find(
|
||||
@@ -687,10 +687,7 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
|
||||
if (contentDelta?.type === "content.delta") {
|
||||
assert.equal(String(contentDelta.turnId), String(turn.turnId));
|
||||
assert.equal(contentDelta.payload.delta, "hello from mock");
|
||||
assert.match(
|
||||
String(contentDelta.itemId),
|
||||
/^assistant:mock-session-1:runtime:[^:]+:segment:0$/,
|
||||
);
|
||||
assert.equal(String(contentDelta.itemId), "assistant:mock-session-1:segment:0");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -558,7 +558,6 @@ export function makeCursorAdapter(
|
||||
: {}),
|
||||
...acpNativeLoggers,
|
||||
}).pipe(
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.provideService(Scope.Scope, sessionScope),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as NodeOS from "node:os";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import type * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -29,7 +28,7 @@ const runNode = <A, E>(
|
||||
effect: Effect.Effect<
|
||||
A,
|
||||
E,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | FileSystem.FileSystem | Path.Path
|
||||
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path
|
||||
>,
|
||||
): Promise<A> => Effect.runPromise(effect.pipe(Effect.provide(NodeServices.layer)));
|
||||
|
||||
@@ -295,7 +294,7 @@ const parameterizedClaudeModelOptionConfigOptions = [
|
||||
|
||||
const baseCursorSettings: CursorSettings = {
|
||||
enabled: true,
|
||||
binaryPath: "cursor-agent",
|
||||
binaryPath: "agent",
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ import type {
|
||||
import { ProviderDriverKind } from "@t3tools/contracts";
|
||||
import type * as EffectAcpSchema from "effect-acp/schema";
|
||||
import { causeErrorTag } from "@t3tools/shared/observability";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
@@ -993,7 +992,7 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
|
||||
): Effect.fn.Return<
|
||||
ServerProviderDraft,
|
||||
never,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | FileSystem.FileSystem | Path.Path
|
||||
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path
|
||||
> {
|
||||
const checkedAt = DateTime.formatIso(yield* DateTime.now);
|
||||
const fallbackModels = getCursorFallbackModels(cursorSettings);
|
||||
|
||||
@@ -596,7 +596,6 @@ export function makeGrokAdapter(grokSettings: GrokSettings, options?: GrokAdapte
|
||||
: {}),
|
||||
...acpNativeLoggers,
|
||||
}).pipe(
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.provideService(Scope.Scope, sessionScope),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import type * as EffectAcpSchema from "effect-acp/schema";
|
||||
import { causeErrorTag } from "@t3tools/shared/observability";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
@@ -168,11 +167,7 @@ const runGrokVersionCommand = (
|
||||
export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(function* (
|
||||
grokSettings: GrokSettings,
|
||||
environment: NodeJS.ProcessEnv = process.env,
|
||||
): Effect.fn.Return<
|
||||
ServerProviderDraft,
|
||||
never,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto
|
||||
> {
|
||||
): Effect.fn.Return<ServerProviderDraft, never, ChildProcessSpawner.ChildProcessSpawner> {
|
||||
const checkedAt = DateTime.formatIso(yield* DateTime.now);
|
||||
const fallbackModels = grokModelsFromSettings(grokSettings.customModels);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ const makeClaudeConfig = (overrides: Partial<ClaudeSettings>): ClaudeSettings =>
|
||||
|
||||
const makeCursorConfig = (overrides: Partial<CursorSettings>): CursorSettings => ({
|
||||
enabled: false,
|
||||
binaryPath: "cursor-agent",
|
||||
binaryPath: "agent",
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
...overrides,
|
||||
|
||||
@@ -1396,7 +1396,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
Layer.provideMerge(OpenCodeRuntime.OpenCodeRuntimeLive),
|
||||
Layer.provideMerge(
|
||||
mockCommandSpawnerLayer((command, args) => {
|
||||
if (command === "cursor-agent") {
|
||||
if (command === "agent") {
|
||||
cursorSpawned = true;
|
||||
}
|
||||
const joined = args.join(" ");
|
||||
@@ -1719,8 +1719,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("runs Claude status probes with the configured CLAUDE_CONFIG_DIR", () => {
|
||||
const claudeConfigDir = "/tmp/t3code-claude-home";
|
||||
it.effect("runs Claude status probes with the configured Claude HOME", () => {
|
||||
const claudeHome = "/tmp/t3code-claude-home";
|
||||
const recorded = recordingMockSpawnerLayer((args) => {
|
||||
const joined = args.join(" ");
|
||||
if (joined === "--version") return { stdout: "1.0.0\n", stderr: "", code: 0 };
|
||||
@@ -1737,14 +1737,14 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
|
||||
const status = yield* checkClaudeProviderStatus(
|
||||
{
|
||||
...defaultClaudeSettings,
|
||||
homePath: claudeConfigDir,
|
||||
homePath: claudeHome,
|
||||
},
|
||||
claudeCapabilities(),
|
||||
);
|
||||
assert.strictEqual(status.status, "ready");
|
||||
assert.deepStrictEqual(
|
||||
recorded.commands.map((command) => command.env?.CLAUDE_CONFIG_DIR),
|
||||
[claudeConfigDir],
|
||||
recorded.commands.map((command) => command.env?.HOME),
|
||||
[claudeHome],
|
||||
);
|
||||
}).pipe(Effect.provide(recorded.layer));
|
||||
});
|
||||
|
||||
@@ -116,43 +116,6 @@ describe("AcpSessionRuntime", () => {
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("keeps assistant item IDs unique when a provider session restarts", () => {
|
||||
const collectFirstAssistantItemId = Effect.gen(function* () {
|
||||
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
|
||||
const started = yield* runtime.start();
|
||||
expect(started.sessionId).toBe("mock-session-1");
|
||||
|
||||
yield* runtime.prompt({
|
||||
prompt: [{ type: "text", text: "hi" }],
|
||||
});
|
||||
|
||||
const events = Array.from(yield* Stream.runCollect(Stream.take(runtime.getEvents(), 4)));
|
||||
const assistantStart = events.find((event) => event._tag === "AssistantItemStarted");
|
||||
expect(assistantStart?._tag).toBe("AssistantItemStarted");
|
||||
return assistantStart?._tag === "AssistantItemStarted" ? assistantStart.itemId : "";
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
AcpSessionRuntime.layer({
|
||||
spawn: {
|
||||
command: mockAgentCommand,
|
||||
args: mockAgentArgs,
|
||||
},
|
||||
cwd: process.cwd(),
|
||||
clientInfo: { name: "t3-test", version: "0.0.0" },
|
||||
authMethodId: "test",
|
||||
}),
|
||||
),
|
||||
Effect.scoped,
|
||||
);
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const beforeRestart = yield* collectFirstAssistantItemId;
|
||||
const afterRestart = yield* collectFirstAssistantItemId;
|
||||
|
||||
expect(afterRestart).not.toBe(beforeRestart);
|
||||
}).pipe(Effect.provide(NodeServices.layer));
|
||||
});
|
||||
|
||||
it.effect("drops session updates emitted for a child ACP session", () =>
|
||||
Effect.gen(function* () {
|
||||
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Clock from "effect/Clock";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -271,24 +270,14 @@ export const make = (
|
||||
): Effect.Effect<
|
||||
AcpSessionRuntime["Service"],
|
||||
EffectAcpErrors.AcpError,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | Scope.Scope
|
||||
ChildProcessSpawner.ChildProcessSpawner | Scope.Scope
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const runtimeScope = yield* Scope.Scope;
|
||||
const eventQueue = yield* Queue.unbounded<AcpSessionRuntimeEvent>();
|
||||
const modeStateRef = yield* Ref.make<AcpSessionModeState | undefined>(undefined);
|
||||
const toolCallsRef = yield* Ref.make(new Map<string, AcpToolCallState>());
|
||||
const assistantItemRuntimeId = yield* crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new EffectAcpErrors.AcpTransportError({
|
||||
detail: "Failed to generate an ACP assistant item runtime identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const assistantSegmentRef = yield* Ref.make<AcpAssistantSegmentState>({ nextSegmentIndex: 0 });
|
||||
const configOptionsRef = yield* Ref.make(sessionConfigOptionsFromSetup(undefined));
|
||||
const startStateRef = yield* Ref.make<AcpStartState>({ _tag: "NotStarted" });
|
||||
@@ -398,7 +387,6 @@ export const make = (
|
||||
modeStateRef,
|
||||
toolCallsRef,
|
||||
assistantSegmentRef,
|
||||
assistantItemRuntimeId,
|
||||
params: notification,
|
||||
});
|
||||
}),
|
||||
@@ -814,7 +802,7 @@ export const layer = (
|
||||
): Layer.Layer<
|
||||
AcpSessionRuntime,
|
||||
EffectAcpErrors.AcpError,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto
|
||||
ChildProcessSpawner.ChildProcessSpawner
|
||||
> => Layer.effect(AcpSessionRuntime, make(options));
|
||||
|
||||
function sessionConfigOptionsFromSetup(
|
||||
@@ -846,14 +834,12 @@ const handleSessionUpdate = ({
|
||||
modeStateRef,
|
||||
toolCallsRef,
|
||||
assistantSegmentRef,
|
||||
assistantItemRuntimeId,
|
||||
params,
|
||||
}: {
|
||||
readonly queue: Queue.Queue<AcpSessionRuntimeEvent>;
|
||||
readonly modeStateRef: Ref.Ref<AcpSessionModeState | undefined>;
|
||||
readonly toolCallsRef: Ref.Ref<Map<string, AcpToolCallState>>;
|
||||
readonly assistantSegmentRef: Ref.Ref<AcpAssistantSegmentState>;
|
||||
readonly assistantItemRuntimeId: string;
|
||||
readonly params: EffectAcpSchema.SessionNotification;
|
||||
}): Effect.Effect<void> =>
|
||||
Effect.gen(function* () {
|
||||
@@ -901,7 +887,6 @@ const handleSessionUpdate = ({
|
||||
queue,
|
||||
assistantSegmentRef,
|
||||
sessionId: params.sessionId,
|
||||
assistantItemRuntimeId,
|
||||
});
|
||||
yield* Queue.offer(queue, {
|
||||
...event,
|
||||
@@ -939,19 +924,17 @@ function shouldEmitToolCallUpdate(
|
||||
return previous === undefined || previous.title !== next.title || previous.detail !== next.detail;
|
||||
}
|
||||
|
||||
const assistantItemId = (sessionId: string, runtimeId: string, segmentIndex: number) =>
|
||||
`assistant:${sessionId}:runtime:${runtimeId}:segment:${segmentIndex}`;
|
||||
const assistantItemId = (sessionId: string, segmentIndex: number) =>
|
||||
`assistant:${sessionId}:segment:${segmentIndex}`;
|
||||
|
||||
const ensureActiveAssistantSegment = ({
|
||||
queue,
|
||||
assistantSegmentRef,
|
||||
sessionId,
|
||||
assistantItemRuntimeId,
|
||||
}: {
|
||||
readonly queue: Queue.Queue<AcpSessionRuntimeEvent>;
|
||||
readonly assistantSegmentRef: Ref.Ref<AcpAssistantSegmentState>;
|
||||
readonly sessionId: string;
|
||||
readonly assistantItemRuntimeId: string;
|
||||
}) =>
|
||||
Ref.modify<AcpAssistantSegmentState, EnsureActiveAssistantSegmentResult>(
|
||||
assistantSegmentRef,
|
||||
@@ -959,7 +942,7 @@ const ensureActiveAssistantSegment = ({
|
||||
if (current.activeItemId) {
|
||||
return [{ itemId: current.activeItemId }, current] as const;
|
||||
}
|
||||
const itemId = assistantItemId(sessionId, assistantItemRuntimeId, current.nextSegmentIndex);
|
||||
const itemId = assistantItemId(sessionId, current.nextSegmentIndex);
|
||||
return [
|
||||
{
|
||||
itemId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Optional integration check against a real `cursor-agent acp` install.
|
||||
* Optional integration check against a real `agent acp` install.
|
||||
* Enable with: T3_CURSOR_ACP_PROBE=1 bun run test --filter CursorAcpCliProbe
|
||||
*/
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
@@ -12,7 +12,7 @@ import type * as EffectAcpSchema from "effect-acp/schema";
|
||||
import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";
|
||||
|
||||
describe.runIf(process.env.T3_CURSOR_ACP_PROBE === "1")("Cursor ACP CLI probe", () => {
|
||||
it.effect("initialize and authenticate against real cursor-agent acp", () =>
|
||||
it.effect("initialize and authenticate against real agent acp", () =>
|
||||
Effect.gen(function* () {
|
||||
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
|
||||
const started = yield* runtime.start();
|
||||
@@ -21,7 +21,7 @@ describe.runIf(process.env.T3_CURSOR_ACP_PROBE === "1")("Cursor ACP CLI probe",
|
||||
Effect.provide(
|
||||
AcpSessionRuntime.layer({
|
||||
spawn: {
|
||||
command: "cursor-agent",
|
||||
command: "agent",
|
||||
args: ["acp"],
|
||||
cwd: process.cwd(),
|
||||
},
|
||||
@@ -77,7 +77,7 @@ describe.runIf(process.env.T3_CURSOR_ACP_PROBE === "1")("Cursor ACP CLI probe",
|
||||
AcpSessionRuntime.layer({
|
||||
authMethodId: "cursor_login",
|
||||
spawn: {
|
||||
command: "cursor-agent",
|
||||
command: "agent",
|
||||
args: ["acp"],
|
||||
cwd: process.cwd(),
|
||||
},
|
||||
@@ -133,7 +133,7 @@ describe.runIf(process.env.T3_CURSOR_ACP_PROBE === "1")("Cursor ACP CLI probe",
|
||||
AcpSessionRuntime.layer({
|
||||
authMethodId: "cursor_login",
|
||||
spawn: {
|
||||
command: "cursor-agent",
|
||||
command: "agent",
|
||||
args: ["acp"],
|
||||
cwd: process.cwd(),
|
||||
},
|
||||
|
||||
@@ -53,7 +53,7 @@ const parameterizedGpt54ConfigOptions: ReadonlyArray<EffectAcpSchema.SessionConf
|
||||
describe("buildCursorAcpSpawnInput", () => {
|
||||
it("builds the default Cursor ACP command", () => {
|
||||
expect(buildCursorAcpSpawnInput(undefined, "/tmp/project")).toEqual({
|
||||
command: "cursor-agent",
|
||||
command: "agent",
|
||||
args: ["acp"],
|
||||
cwd: "/tmp/project",
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { type CursorSettings, type ProviderOptionSelection } from "@t3tools/contracts";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Scope from "effect/Scope";
|
||||
@@ -36,7 +35,7 @@ export function buildCursorAcpSpawnInput(
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
): AcpSessionRuntime.AcpSpawnInput {
|
||||
return {
|
||||
command: cursorSettings?.binaryPath || "cursor-agent",
|
||||
command: cursorSettings?.binaryPath || "agent",
|
||||
args: [
|
||||
...(cursorSettings?.apiEndpoint ? (["-e", cursorSettings.apiEndpoint] as const) : []),
|
||||
"acp",
|
||||
@@ -51,7 +50,7 @@ export const makeCursorAcpRuntime = (
|
||||
): Effect.Effect<
|
||||
AcpSessionRuntime.AcpSessionRuntime["Service"],
|
||||
EffectAcpErrors.AcpError,
|
||||
Crypto.Crypto | Scope.Scope
|
||||
Scope.Scope
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const acpContext = yield* Layer.build(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { type GrokSettings, ProviderDriverKind } from "@t3tools/contracts";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Scope from "effect/Scope";
|
||||
@@ -56,7 +55,7 @@ export const makeGrokAcpRuntime = (
|
||||
): Effect.Effect<
|
||||
AcpSessionRuntime.AcpSessionRuntime["Service"],
|
||||
EffectAcpErrors.AcpError,
|
||||
Crypto.Crypto | Scope.Scope
|
||||
Scope.Scope
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const acpContext = yield* Layer.build(
|
||||
|
||||
@@ -48,7 +48,7 @@ function lifecycleFor(provider: ProviderDriverKind): ProviderMaintenanceCapabili
|
||||
return makeProviderMaintenanceCapabilities({
|
||||
provider,
|
||||
packageName: null,
|
||||
updateExecutable: "cursor-agent",
|
||||
updateExecutable: "agent",
|
||||
updateArgs: ["update"],
|
||||
updateLockKey: "cursor-agent",
|
||||
});
|
||||
@@ -226,7 +226,7 @@ describe("providerMaintenanceRunner", () => {
|
||||
const result = yield* updater.updateProvider(CURSOR_DRIVER);
|
||||
assert.deepStrictEqual(calls, [
|
||||
{
|
||||
command: "cursor-agent",
|
||||
command: "agent",
|
||||
args: ["update"],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -5607,64 +5607,6 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||
);
|
||||
|
||||
it.effect("buffers thread events published while the initial snapshot loads", () =>
|
||||
Effect.gen(function* () {
|
||||
const thread = makeDefaultOrchestrationReadModel().threads[0]!;
|
||||
const liveEvents = yield* PubSub.unbounded<OrchestrationEvent>();
|
||||
const messageEvent = {
|
||||
sequence: 2,
|
||||
eventId: EventId.make("event-message"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: defaultThreadId,
|
||||
occurredAt: "2026-01-01T00:00:01.000Z",
|
||||
commandId: null,
|
||||
causationEventId: null,
|
||||
correlationId: null,
|
||||
metadata: {},
|
||||
type: "thread.message-sent",
|
||||
payload: {
|
||||
threadId: defaultThreadId,
|
||||
messageId: MessageId.make("message-1"),
|
||||
role: "user",
|
||||
text: "First message",
|
||||
turnId: null,
|
||||
streaming: false,
|
||||
createdAt: "2026-01-01T00:00:01.000Z",
|
||||
updatedAt: "2026-01-01T00:00:01.000Z",
|
||||
},
|
||||
} satisfies Extract<OrchestrationEvent, { type: "thread.message-sent" }>;
|
||||
|
||||
yield* buildAppUnderTest({
|
||||
layers: {
|
||||
orchestrationEngine: {
|
||||
streamDomainEvents: Stream.fromPubSub(liveEvents),
|
||||
},
|
||||
projectionSnapshotQuery: {
|
||||
getThreadDetailSnapshot: () =>
|
||||
Effect.gen(function* () {
|
||||
yield* Effect.sleep("25 millis");
|
||||
yield* PubSub.publish(liveEvents, messageEvent);
|
||||
return Option.some({ snapshotSequence: 1, thread });
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const wsUrl = yield* getWsServerUrl("/ws");
|
||||
const items = yield* Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
client[ORCHESTRATION_WS_METHODS.subscribeThread]({
|
||||
threadId: defaultThreadId,
|
||||
}).pipe(Stream.take(2), Stream.runCollect),
|
||||
),
|
||||
).pipe(Effect.timeout("2 seconds"));
|
||||
|
||||
assert.equal(items[0]?.kind, "snapshot");
|
||||
assert.equal(items[1]?.kind, "event");
|
||||
assert.equal(items[1]?.kind === "event" ? items[1].event.sequence : null, 2);
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest), TestClock.withLive),
|
||||
);
|
||||
|
||||
it.effect("enriches replayed project events with repository identity metadata", () =>
|
||||
Effect.gen(function* () {
|
||||
const repositoryIdentity = {
|
||||
|
||||
@@ -1334,63 +1334,6 @@ it.layer(
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("strips AppImage runtime env from terminal sessions", () =>
|
||||
Effect.gen(function* () {
|
||||
const appDir = "/tmp/.mount_T3Codeabc123";
|
||||
const { manager, ptyAdapter } = yield* createManager(5, {
|
||||
env: {
|
||||
APPIMAGE: "/home/user/T3-Code.AppImage",
|
||||
APPDIR: appDir,
|
||||
ARGV0: "/home/user/T3-Code.AppImage",
|
||||
OWD: "/home/user/project",
|
||||
PATH: `${appDir}/usr/bin:${appDir}:/usr/local/bin:/usr/bin:/bin`,
|
||||
LD_LIBRARY_PATH: `${appDir}/usr/lib:/home/user/.local/lib`,
|
||||
TEST_TERMINAL_KEEP: "keep-me",
|
||||
},
|
||||
});
|
||||
yield* manager.open(openInput());
|
||||
const spawnInput = ptyAdapter.spawnInputs[0];
|
||||
expect(spawnInput).toBeDefined();
|
||||
if (!spawnInput) return;
|
||||
|
||||
// AppImage runtime markers must never reach the PTY — tools inside the
|
||||
// terminal otherwise resolve against the AppImage mount (e.g. PHP_BINARY
|
||||
// reporting the AppImage path instead of the real binary).
|
||||
expect(spawnInput.env.APPIMAGE).toBeUndefined();
|
||||
expect(spawnInput.env.APPDIR).toBeUndefined();
|
||||
expect(spawnInput.env.ARGV0).toBeUndefined();
|
||||
expect(spawnInput.env.OWD).toBeUndefined();
|
||||
// PATH/LD_LIBRARY_PATH keep the user's real entries but drop the AppImage
|
||||
// mount segments that the runtime prepended.
|
||||
expect(spawnInput.env.PATH).toBe("/usr/local/bin:/usr/bin:/bin");
|
||||
expect(spawnInput.env.LD_LIBRARY_PATH).toBe("/home/user/.local/lib");
|
||||
// Unrelated host vars still pass through untouched.
|
||||
expect(spawnInput.env.TEST_TERMINAL_KEEP).toBe("keep-me");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("leaves the environment untouched when not launched from an AppImage", () =>
|
||||
Effect.gen(function* () {
|
||||
const { manager, ptyAdapter } = yield* createManager(5, {
|
||||
env: {
|
||||
PATH: "/usr/local/bin:/usr/bin:/bin",
|
||||
LD_LIBRARY_PATH: "/home/user/.local/lib",
|
||||
// Without APPIMAGE/APPDIR set, OWD is an ordinary variable and must
|
||||
// not be stripped — only an AppImage launch gives it special meaning.
|
||||
OWD: "/home/user/keep-this",
|
||||
},
|
||||
});
|
||||
yield* manager.open(openInput());
|
||||
const spawnInput = ptyAdapter.spawnInputs[0];
|
||||
expect(spawnInput).toBeDefined();
|
||||
if (!spawnInput) return;
|
||||
|
||||
expect(spawnInput.env.PATH).toBe("/usr/local/bin:/usr/bin:/bin");
|
||||
expect(spawnInput.env.LD_LIBRARY_PATH).toBe("/home/user/.local/lib");
|
||||
expect(spawnInput.env.OWD).toBe("/home/user/keep-this");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("injects runtime env overrides into spawned terminals", () =>
|
||||
Effect.gen(function* () {
|
||||
const { manager, ptyAdapter } = yield* createManager();
|
||||
|
||||
@@ -1065,53 +1065,6 @@ function shouldExcludeTerminalEnvKey(key: string): boolean {
|
||||
return TERMINAL_ENV_BLOCKLIST.has(normalizedKey);
|
||||
}
|
||||
|
||||
// Marker variables the AppImage runtime injects into the process it launches.
|
||||
// They describe the AppImage itself, not the user's session, so terminals must
|
||||
// not inherit them.
|
||||
const APPIMAGE_RUNTIME_ENV_KEYS = ["APPIMAGE", "APPDIR", "ARGV0", "OWD"] as const;
|
||||
// PATH-style variables the AppImage runtime prepends with its temporary mount
|
||||
// (e.g. /tmp/.mount_T3-XXXX/usr/bin). Only the mount segments are dropped; the
|
||||
// user's real entries are preserved.
|
||||
const APPIMAGE_PATH_LIKE_ENV_KEYS = ["PATH", "LD_LIBRARY_PATH"] as const;
|
||||
|
||||
function isPathSegmentUnderAppDir(segment: string, appDir: string): boolean {
|
||||
return segment === appDir || segment.startsWith(`${appDir}/`);
|
||||
}
|
||||
|
||||
// On Linux AppImage builds the runtime mounts the app under a temporary dir and
|
||||
// injects APPIMAGE/APPDIR/ARGV0/OWD plus mount entries on PATH/LD_LIBRARY_PATH.
|
||||
// The integrated terminal inherits the server process environment, so without
|
||||
// this scrub those leak into the PTY and tools resolve against the AppImage
|
||||
// mount instead of the user's real environment (e.g. `php` reporting
|
||||
// PHP_BINARY as the AppImage path). See issue #1699. The scrub is gated on an
|
||||
// actual AppImage launch so non-AppImage environments are left untouched.
|
||||
function stripAppImageRuntimeEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
||||
if (env.APPIMAGE === undefined && env.APPDIR === undefined) return env;
|
||||
|
||||
const scrubbed: NodeJS.ProcessEnv = { ...env };
|
||||
for (const key of APPIMAGE_RUNTIME_ENV_KEYS) {
|
||||
delete scrubbed[key];
|
||||
}
|
||||
|
||||
const appDir = env.APPDIR?.replace(/\/+$/, "");
|
||||
if (appDir) {
|
||||
for (const key of APPIMAGE_PATH_LIKE_ENV_KEYS) {
|
||||
const value = scrubbed[key];
|
||||
if (value === undefined) continue;
|
||||
const kept = value
|
||||
.split(":")
|
||||
.filter((segment) => segment.length > 0 && !isPathSegmentUnderAppDir(segment, appDir));
|
||||
if (kept.length > 0) {
|
||||
scrubbed[key] = kept.join(":");
|
||||
} else {
|
||||
delete scrubbed[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scrubbed;
|
||||
}
|
||||
|
||||
function createTerminalSpawnEnv(
|
||||
baseEnv: NodeJS.ProcessEnv,
|
||||
runtimeEnv?: Record<string, string> | null,
|
||||
@@ -1127,7 +1080,7 @@ function createTerminalSpawnEnv(
|
||||
spawnEnv[key] = value;
|
||||
}
|
||||
}
|
||||
return stripAppImageRuntimeEnv(spawnEnv);
|
||||
return spawnEnv;
|
||||
}
|
||||
|
||||
function normalizedRuntimeEnv(
|
||||
|
||||
@@ -51,8 +51,8 @@ function makeFakeClaudeBinary(dir: string) {
|
||||
" exit 4",
|
||||
" }",
|
||||
"fi",
|
||||
'if [ -n "$T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE" ] && [ "$CLAUDE_CONFIG_DIR" != "$T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE" ]; then',
|
||||
' printf "%s\\n" "CLAUDE_CONFIG_DIR was $CLAUDE_CONFIG_DIR" >&2',
|
||||
'if [ -n "$T3_FAKE_CLAUDE_HOME_MUST_BE" ] && [ "$HOME" != "$T3_FAKE_CLAUDE_HOME_MUST_BE" ]; then',
|
||||
' printf "%s\\n" "HOME was $HOME" >&2',
|
||||
" exit 5",
|
||||
"fi",
|
||||
'if [ -n "$T3_FAKE_CLAUDE_STDERR" ]; then',
|
||||
@@ -76,7 +76,7 @@ function withFakeClaudeEnv<A, E, R>(
|
||||
argsMustContain?: string;
|
||||
argsMustNotContain?: string;
|
||||
stdinMustContain?: string;
|
||||
configDirMustBe?: string;
|
||||
homeMustBe?: string;
|
||||
claudeConfig?: Partial<ClaudeSettings>;
|
||||
},
|
||||
effectFn: (textGeneration: TextGeneration.TextGeneration["Service"]) => Effect.Effect<A, E, R>,
|
||||
@@ -92,7 +92,7 @@ function withFakeClaudeEnv<A, E, R>(
|
||||
const previousArgsMustContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN;
|
||||
const previousArgsMustNotContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN;
|
||||
const previousStdinMustContain = process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
|
||||
const previousConfigDirMustBe = process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
|
||||
const previousHomeMustBe = process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
|
||||
|
||||
yield* Effect.acquireRelease(
|
||||
Effect.sync(() => {
|
||||
@@ -129,10 +129,10 @@ function withFakeClaudeEnv<A, E, R>(
|
||||
delete process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
|
||||
}
|
||||
|
||||
if (input.configDirMustBe !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE = input.configDirMustBe;
|
||||
if (input.homeMustBe !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_HOME_MUST_BE = input.homeMustBe;
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
|
||||
delete process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
|
||||
}
|
||||
}),
|
||||
() =>
|
||||
@@ -175,10 +175,10 @@ function withFakeClaudeEnv<A, E, R>(
|
||||
process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN = previousStdinMustContain;
|
||||
}
|
||||
|
||||
if (previousConfigDirMustBe === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
|
||||
if (previousHomeMustBe === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE = previousConfigDirMustBe;
|
||||
process.env.T3_FAKE_CLAUDE_HOME_MUST_BE = previousHomeMustBe;
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -286,10 +286,10 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("runs Claude text generation with the configured CLAUDE_CONFIG_DIR", () =>
|
||||
it.effect("runs Claude text generation with the configured Claude HOME", () =>
|
||||
Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const claudeConfigDir = path.join(process.cwd(), ".claude-work-test");
|
||||
const claudeHome = path.join(process.cwd(), ".claude-work-test");
|
||||
return yield* withFakeClaudeEnv(
|
||||
{
|
||||
// @effect-diagnostics-next-line preferSchemaOverJson:off
|
||||
@@ -298,8 +298,8 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
|
||||
title: "Use Claude home",
|
||||
},
|
||||
}),
|
||||
configDirMustBe: claudeConfigDir,
|
||||
claudeConfig: { homePath: claudeConfigDir },
|
||||
homeMustBe: claudeHome,
|
||||
claudeConfig: { homePath: claudeHome },
|
||||
},
|
||||
(textGeneration) =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Ref from "effect/Ref";
|
||||
@@ -39,7 +38,6 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu
|
||||
cursorSettings: CursorSettings,
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
) {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const resolvedEnvironment = environment ?? process.env;
|
||||
|
||||
@@ -68,7 +66,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu
|
||||
childProcessSpawner: commandSpawner,
|
||||
cwd,
|
||||
clientInfo: { name: "t3-code-git-text", version: "0.0.0" },
|
||||
}).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
||||
});
|
||||
|
||||
yield* runtime.handleSessionUpdate((notification) => {
|
||||
const update = notification.update;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Ref from "effect/Ref";
|
||||
@@ -38,7 +37,6 @@ export const makeGrokTextGeneration = Effect.fn("makeGrokTextGeneration")(functi
|
||||
grokSettings: GrokSettings,
|
||||
environment: NodeJS.ProcessEnv = process.env,
|
||||
) {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
|
||||
const runGrokJson = <S extends Schema.Top>({
|
||||
@@ -67,7 +65,7 @@ export const makeGrokTextGeneration = Effect.fn("makeGrokTextGeneration")(functi
|
||||
childProcessSpawner: commandSpawner,
|
||||
cwd,
|
||||
clientInfo: { name: "t3-code-git-text", version: "0.0.0" },
|
||||
}).pipe(Effect.provideService(Crypto.Crypto, crypto));
|
||||
});
|
||||
|
||||
yield* runtime.handleSessionUpdate((notification) => {
|
||||
const update = notification.update;
|
||||
|
||||
@@ -6,9 +6,6 @@ import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Sink from "effect/Sink";
|
||||
import * as Stream from "effect/Stream";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import { GitCommandError } from "@t3tools/contracts";
|
||||
import { ServerConfig } from "../config.ts";
|
||||
@@ -23,21 +20,6 @@ const TestLayer = GitVcsDriver.layer.pipe(
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const makeNonRepositoryHandle = () =>
|
||||
ChildProcessSpawner.makeHandle({
|
||||
pid: ChildProcessSpawner.ProcessId(1),
|
||||
exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(128)),
|
||||
isRunning: Effect.succeed(false),
|
||||
kill: () => Effect.void,
|
||||
unref: Effect.succeed(Effect.void),
|
||||
stdin: Sink.drain,
|
||||
stdout: Stream.empty,
|
||||
stderr: Stream.encodeText(Stream.make("fatal: not a git repository")),
|
||||
all: Stream.empty,
|
||||
getInputFd: () => Sink.drain,
|
||||
getOutputFd: () => Stream.empty,
|
||||
});
|
||||
|
||||
const makeTmpDir = (
|
||||
prefix = "git-vcs-driver-test-",
|
||||
): Effect.Effect<string, PlatformError.PlatformError, FileSystem.FileSystem | Scope.Scope> =>
|
||||
@@ -95,62 +77,7 @@ const initRepoWithCommit = (
|
||||
return { initialBranch };
|
||||
});
|
||||
|
||||
it.effect("uses stable diagnostics for every parsed non-repository command", () => {
|
||||
const commands: Array<{ readonly args: ReadonlyArray<string>; readonly lcAll?: string }> = [];
|
||||
const spawner = ChildProcessSpawner.make((command) =>
|
||||
Effect.sync(() => {
|
||||
if (!ChildProcess.isStandardCommand(command)) {
|
||||
return assert.fail("expected a standard Git command");
|
||||
}
|
||||
commands.push({
|
||||
args: command.args,
|
||||
...(command.options.env?.LC_ALL ? { lcAll: command.options.env.LC_ALL } : {}),
|
||||
});
|
||||
return makeNonRepositoryHandle();
|
||||
}),
|
||||
);
|
||||
const nodeServicesLayer = Layer.merge(
|
||||
NodeServices.layer,
|
||||
Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
);
|
||||
const layer = GitVcsDriver.layer.pipe(
|
||||
Layer.provide(ServerConfigLayer),
|
||||
Layer.provideMerge(nodeServicesLayer),
|
||||
);
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
const cwd = "/repo";
|
||||
|
||||
yield* driver.statusDetailsLocal(cwd);
|
||||
yield* driver.statusDetailsRemote(cwd, { refreshUpstream: false });
|
||||
yield* driver.listRefs({ cwd });
|
||||
|
||||
assert.deepStrictEqual(commands, [
|
||||
{ args: ["status", "--porcelain=2", "--branch"], lcAll: "C" },
|
||||
{ args: ["rev-parse", "--abbrev-ref", "HEAD"], lcAll: "C" },
|
||||
{ args: ["branch", "--no-color", "--no-column"], lcAll: "C" },
|
||||
]);
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
describe("process environment", () => {
|
||||
it.effect("preserves the caller locale for general Git subprocesses", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
|
||||
const locale = yield* git(
|
||||
cwd,
|
||||
["-c", 'alias.print-locale=!printf "%s" "$LC_ALL"', "print-locale"],
|
||||
{ LC_ALL: "zh_CN.UTF-8" },
|
||||
);
|
||||
|
||||
assert.equal(locale, "zh_CN.UTF-8");
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("structured errors", () => {
|
||||
it.effect("preserves structured spawn context and the platform cause", () =>
|
||||
Effect.gen(function* () {
|
||||
@@ -693,24 +620,6 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
assert.notInclude(status, "a.txt");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("treats selected file paths literally", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
yield* initRepoWithCommit(cwd);
|
||||
const driver = yield* GitVcsDriver.GitVcsDriver;
|
||||
|
||||
yield* writeTextFile(cwd, "selected[1].txt", "literal\n");
|
||||
yield* writeTextFile(cwd, "selected1.txt", "pattern match\n");
|
||||
|
||||
yield* driver.prepareCommitContext(cwd, ["selected[1].txt"]);
|
||||
|
||||
assert.equal(yield* git(cwd, ["diff", "--cached", "--name-only"]), "selected[1].txt");
|
||||
|
||||
const status = yield* git(cwd, ["status", "--porcelain"]);
|
||||
assert.include(status, "?? selected1.txt");
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("remote operations", () => {
|
||||
|
||||
@@ -830,20 +830,6 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
}),
|
||||
);
|
||||
|
||||
const executeGitWithStableDiagnostics = (
|
||||
operation: string,
|
||||
cwd: string,
|
||||
args: readonly string[],
|
||||
options: ExecuteGitOptions = {},
|
||||
): Effect.Effect<GitVcsDriver.ExecuteGitResult, GitCommandError> =>
|
||||
executeGit(operation, cwd, args, {
|
||||
...options,
|
||||
env: {
|
||||
...options.env,
|
||||
LC_ALL: "C",
|
||||
},
|
||||
});
|
||||
|
||||
const runGit = (
|
||||
operation: string,
|
||||
cwd: string,
|
||||
@@ -1198,7 +1184,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
});
|
||||
|
||||
const readStatusDetailsRemote = Effect.fn("readStatusDetailsRemote")(function* (cwd: string) {
|
||||
const branchResult = yield* executeGitWithStableDiagnostics(
|
||||
const branchResult = yield* executeGit(
|
||||
"GitVcsDriver.statusDetailsRemote.branch",
|
||||
cwd,
|
||||
["rev-parse", "--abbrev-ref", "HEAD"],
|
||||
@@ -1318,7 +1304,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
});
|
||||
|
||||
const readStatusDetailsLocal = Effect.fn("readStatusDetailsLocal")(function* (cwd: string) {
|
||||
const statusResult = yield* executeGitWithStableDiagnostics(
|
||||
const statusResult = yield* executeGit(
|
||||
"GitVcsDriver.statusDetails.status",
|
||||
cwd,
|
||||
["status", "--porcelain=2", "--branch"],
|
||||
@@ -1538,7 +1524,6 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
}),
|
||||
);
|
||||
yield* runGit("GitVcsDriver.prepareCommitContext.addSelected", cwd, [
|
||||
"--literal-pathspecs",
|
||||
"add",
|
||||
"-A",
|
||||
"--",
|
||||
@@ -2000,7 +1985,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
const branchRecencyPromise = readBranchRecency(input.cwd).pipe(
|
||||
Effect.orElseSucceed(() => new Map<string, number>()),
|
||||
);
|
||||
const localBranchResult = yield* executeGitWithStableDiagnostics(
|
||||
const localBranchResult = yield* executeGit(
|
||||
"GitVcsDriver.listRefs.branchNoColor",
|
||||
input.cwd,
|
||||
["branch", "--no-color", "--no-column"],
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it, describe, expect } from "@effect/vitest";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
@@ -64,7 +66,7 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
relativePath: "src/index.ts",
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
assert.deepStrictEqual(result, {
|
||||
relativePath: "src/index.ts",
|
||||
contents: "export const answer = 42;\n",
|
||||
byteLength: 26,
|
||||
@@ -82,7 +84,8 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
.readFile({ cwd, relativePath: "../escape.md" })
|
||||
.pipe(Effect.flip);
|
||||
|
||||
expect(error.message).toContain(
|
||||
assert.include(
|
||||
error.message,
|
||||
"Workspace file path must be relative to the project root: ../escape.md",
|
||||
);
|
||||
}),
|
||||
@@ -107,14 +110,14 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
const resolvedWorkspaceRoot = yield* fileSystem.realPath(cwd);
|
||||
const resolvedPath = yield* fileSystem.realPath(path.join(outsideDir, "secret.txt"));
|
||||
|
||||
expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspaceFilePathEscapeError);
|
||||
expect(error).toMatchObject({
|
||||
assert.strictEqual(error._tag, "WorkspaceFilePathEscapeError");
|
||||
assert.deepInclude(error, {
|
||||
workspaceRoot: cwd,
|
||||
relativePath: "linked-secret.txt",
|
||||
resolvedWorkspaceRoot,
|
||||
resolvedPath,
|
||||
});
|
||||
expect("cause" in error).toBe(false);
|
||||
assert.notProperty(error, "cause");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -131,13 +134,13 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
.pipe(Effect.flip);
|
||||
const resolvedPath = yield* fileSystem.realPath(path.join(cwd, "src"));
|
||||
|
||||
expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);
|
||||
expect(error).toMatchObject({
|
||||
assert.strictEqual(error._tag, "WorkspacePathNotFileError");
|
||||
assert.deepInclude(error, {
|
||||
workspaceRoot: cwd,
|
||||
relativePath: "src",
|
||||
resolvedPath,
|
||||
});
|
||||
expect("cause" in error).toBe(false);
|
||||
assert.notProperty(error, "cause");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -155,14 +158,31 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
.pipe(Effect.flip);
|
||||
const resolvedPath = yield* fileSystem.realPath(absolutePath);
|
||||
|
||||
expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspaceBinaryFileError);
|
||||
expect(error).toMatchObject({
|
||||
assert.strictEqual(error._tag, "WorkspaceBinaryFileError");
|
||||
assert.deepInclude(error, {
|
||||
workspaceRoot: cwd,
|
||||
relativePath: "asset.bin",
|
||||
resolvedPath,
|
||||
});
|
||||
expect("cause" in error).toBe(false);
|
||||
expect("contents" in error).toBe(false);
|
||||
assert.notProperty(error, "cause");
|
||||
assert.notProperty(error, "contents");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("reads at most the preview limit", () =>
|
||||
Effect.gen(function* () {
|
||||
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
|
||||
const cwd = yield* makeTempDir;
|
||||
yield* writeTextFile(cwd, "large.txt", "a".repeat(1024 * 1024 + 1));
|
||||
|
||||
const result = yield* workspaceFileSystem.readFile({
|
||||
cwd,
|
||||
relativePath: "large.txt",
|
||||
});
|
||||
|
||||
assert.strictEqual(result.contents.length, 1024 * 1024);
|
||||
assert.strictEqual(result.byteLength, 1024 * 1024 + 1);
|
||||
assert.isTrue(result.truncated);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -177,16 +197,16 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
.readFile({ cwd, relativePath: "missing.txt" })
|
||||
.pipe(Effect.flip);
|
||||
|
||||
expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspaceFileSystemOperationError);
|
||||
expect(error).toMatchObject({
|
||||
assert.strictEqual(error._tag, "WorkspaceFileSystemOperationError");
|
||||
assert.deepInclude(error, {
|
||||
workspaceRoot: cwd,
|
||||
relativePath: "missing.txt",
|
||||
resolvedPath,
|
||||
operationPath: resolvedPath,
|
||||
operation: "realpath-target",
|
||||
});
|
||||
expect(error.cause).toBeInstanceOf(Error);
|
||||
expect((error.cause as NodeJS.ErrnoException).code).toBe("ENOENT");
|
||||
assert.instanceOf(error.cause, PlatformError.PlatformError);
|
||||
assert.strictEqual((error.cause as PlatformError.PlatformError).reason._tag, "NotFound");
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -207,8 +227,8 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
.readFileString(path.join(cwd, "plans/effect-rpc.md"))
|
||||
.pipe(Effect.orDie);
|
||||
|
||||
expect(result).toEqual({ relativePath: "plans/effect-rpc.md" });
|
||||
expect(saved).toBe("# Plan\n");
|
||||
assert.deepStrictEqual(result, { relativePath: "plans/effect-rpc.md" });
|
||||
assert.strictEqual(saved, "# Plan\n");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -220,9 +240,7 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
yield* writeTextFile(cwd, "src/existing.ts", "export {};\n");
|
||||
|
||||
const beforeWrite = yield* workspaceEntries.list({ cwd });
|
||||
expect(beforeWrite.entries.some((entry) => entry.path === "plans/effect-rpc.md")).toBe(
|
||||
false,
|
||||
);
|
||||
assert.isFalse(beforeWrite.entries.some((entry) => entry.path === "plans/effect-rpc.md"));
|
||||
|
||||
yield* workspaceFileSystem.writeFile({
|
||||
cwd,
|
||||
@@ -231,10 +249,8 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
});
|
||||
|
||||
const afterWrite = yield* workspaceEntries.list({ cwd });
|
||||
expect(afterWrite.entries).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ path: "plans/effect-rpc.md" })]),
|
||||
);
|
||||
expect(afterWrite.truncated).toBe(false);
|
||||
assert.isTrue(afterWrite.entries.some((entry) => entry.path === "plans/effect-rpc.md"));
|
||||
assert.isFalse(afterWrite.truncated);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -253,15 +269,14 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
|
||||
})
|
||||
.pipe(Effect.flip);
|
||||
|
||||
expect(error.message).toContain(
|
||||
assert.include(
|
||||
error.message,
|
||||
"Workspace file path must be relative to the project root: ../escape.md",
|
||||
);
|
||||
|
||||
const escapedPath = path.resolve(cwd, "..", "escape.md");
|
||||
const escapedStat = yield* fileSystem
|
||||
.stat(escapedPath)
|
||||
.pipe(Effect.orElseSucceed(() => null));
|
||||
expect(escapedStat).toBeNull();
|
||||
const escapedStat = yield* fileSystem.stat(escapedPath).pipe(Effect.option);
|
||||
assert.isTrue(Option.isNone(escapedStat));
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
/**
|
||||
* WorkspaceFileSystem - Effect service contract for workspace file mutations.
|
||||
*
|
||||
@@ -7,7 +6,6 @@
|
||||
*
|
||||
* @module WorkspaceFileSystem
|
||||
*/
|
||||
import * as NodeFSP from "node:fs/promises";
|
||||
|
||||
import type {
|
||||
ProjectReadFileInput,
|
||||
@@ -19,6 +17,7 @@ import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
@@ -140,30 +139,32 @@ export const make = Effect.gen(function* () {
|
||||
relativePath: input.relativePath,
|
||||
});
|
||||
|
||||
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 realTargetPath = yield* Effect.tryPromise({
|
||||
try: () => NodeFSP.realpath(target.absolutePath),
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: target.absolutePath,
|
||||
operation: "realpath-target",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
const realWorkspaceRoot = yield* fileSystem.realPath(input.cwd).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: input.cwd,
|
||||
operation: "realpath-workspace-root",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const realTargetPath = yield* fileSystem.realPath(target.absolutePath).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: target.absolutePath,
|
||||
operationPath: target.absolutePath,
|
||||
operation: "realpath-target",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const relativeRealPath = path.relative(realWorkspaceRoot, realTargetPath);
|
||||
if (
|
||||
relativeRealPath.startsWith(`..${path.sep}`) ||
|
||||
@@ -178,24 +179,24 @@ export const make = Effect.gen(function* () {
|
||||
});
|
||||
}
|
||||
|
||||
return yield* Effect.acquireUseRelease(
|
||||
Effect.tryPromise({
|
||||
try: () => NodeFSP.open(realTargetPath, "r"),
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
operationPath: realTargetPath,
|
||||
operation: "open",
|
||||
cause,
|
||||
}),
|
||||
}),
|
||||
(handle) =>
|
||||
Effect.gen(function* () {
|
||||
const stat = yield* Effect.tryPromise({
|
||||
try: () => handle.stat(),
|
||||
catch: (cause) =>
|
||||
return yield* Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const handle = yield* fileSystem.open(realTargetPath, { flag: "r" }).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
operationPath: realTargetPath,
|
||||
operation: "open",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const stat = yield* handle.stat.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
@@ -204,20 +205,21 @@ export const make = Effect.gen(function* () {
|
||||
operation: "stat",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
if (stat.type !== "File") {
|
||||
return yield* new WorkspacePathNotFileError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
});
|
||||
if (!stat.isFile()) {
|
||||
return yield* new WorkspacePathNotFileError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const bytesToRead = Math.min(stat.size, PROJECT_READ_FILE_MAX_BYTES);
|
||||
const buffer = Buffer.alloc(bytesToRead);
|
||||
const { bytesRead } = yield* Effect.tryPromise({
|
||||
try: () => handle.read(buffer, 0, bytesToRead, 0),
|
||||
catch: (cause) =>
|
||||
const byteLength = Number(stat.size);
|
||||
const bytesToRead = Math.min(byteLength, PROJECT_READ_FILE_MAX_BYTES);
|
||||
const maybeFileBytes = yield* handle.readAlloc(bytesToRead).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
@@ -226,36 +228,24 @@ export const make = Effect.gen(function* () {
|
||||
operation: "read",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const fileBytes = Option.getOrElse(maybeFileBytes, () => new Uint8Array());
|
||||
if (fileBytes.includes(0)) {
|
||||
return yield* new WorkspaceBinaryFileError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
});
|
||||
const fileBytes = buffer.subarray(0, bytesRead);
|
||||
if (fileBytes.includes(0)) {
|
||||
return yield* new WorkspaceBinaryFileError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
relativePath: target.relativePath,
|
||||
contents: new TextDecoder("utf-8").decode(fileBytes),
|
||||
byteLength: stat.size,
|
||||
truncated: stat.size > PROJECT_READ_FILE_MAX_BYTES,
|
||||
};
|
||||
}),
|
||||
(handle) =>
|
||||
Effect.tryPromise({
|
||||
try: () => handle.close(),
|
||||
catch: (cause) =>
|
||||
new WorkspaceFileSystemOperationError({
|
||||
workspaceRoot: input.cwd,
|
||||
relativePath: input.relativePath,
|
||||
resolvedPath: realTargetPath,
|
||||
operationPath: realTargetPath,
|
||||
operation: "close",
|
||||
cause,
|
||||
}),
|
||||
}),
|
||||
return {
|
||||
relativePath: target.relativePath,
|
||||
contents: new TextDecoder("utf-8").decode(fileBytes),
|
||||
byteLength,
|
||||
truncated: byteLength > PROJECT_READ_FILE_MAX_BYTES,
|
||||
};
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1166,14 +1166,6 @@ const makeWsRpcLayer = (
|
||||
})),
|
||||
);
|
||||
|
||||
// Attach live delivery before reading either replay or snapshot state.
|
||||
// Otherwise an event published while the snapshot is loading is lost.
|
||||
const liveBuffer = yield* Queue.unbounded<OrchestrationThreadStreamItem>();
|
||||
yield* Effect.forkScoped(
|
||||
liveStream.pipe(Stream.runForEach((item) => Queue.offer(liveBuffer, item))),
|
||||
);
|
||||
const bufferedLiveStream = Stream.fromQueue(liveBuffer);
|
||||
|
||||
// When the client already loaded the snapshot over HTTP it passes
|
||||
// that snapshot's sequence, and we resume the live subscription by
|
||||
// replaying persisted events after it instead of re-sending the
|
||||
@@ -1193,20 +1185,28 @@ const makeWsRpcLayer = (
|
||||
// so a global cap could otherwise omit this thread's events.
|
||||
if (input.afterSequence !== undefined) {
|
||||
const afterSequence = input.afterSequence;
|
||||
const catchUpStream = orchestrationEngine
|
||||
.readEvents(afterSequence, Number.MAX_SAFE_INTEGER)
|
||||
.pipe(
|
||||
Stream.filter(isThisThreadDetailEvent),
|
||||
Stream.map((event) => ({ kind: "event" as const, event })),
|
||||
Stream.mapError(
|
||||
(cause) =>
|
||||
new OrchestrationGetSnapshotError({
|
||||
message: `Failed to replay thread ${input.threadId} events`,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return Stream.concat(catchUpStream, bufferedLiveStream);
|
||||
return Stream.unwrap(
|
||||
Effect.gen(function* () {
|
||||
const liveBuffer = yield* Queue.unbounded<OrchestrationThreadStreamItem>();
|
||||
yield* Effect.forkScoped(
|
||||
liveStream.pipe(Stream.runForEach((item) => Queue.offer(liveBuffer, item))),
|
||||
);
|
||||
const catchUpStream = orchestrationEngine
|
||||
.readEvents(afterSequence, Number.MAX_SAFE_INTEGER)
|
||||
.pipe(
|
||||
Stream.filter(isThisThreadDetailEvent),
|
||||
Stream.map((event) => ({ kind: "event" as const, event })),
|
||||
Stream.mapError(
|
||||
(cause) =>
|
||||
new OrchestrationGetSnapshotError({
|
||||
message: `Failed to replay thread ${input.threadId} events`,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return Stream.concat(catchUpStream, Stream.fromQueue(liveBuffer));
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const snapshot = yield* projectionSnapshotQuery
|
||||
@@ -1233,7 +1233,7 @@ const makeWsRpcLayer = (
|
||||
kind: "snapshot" as const,
|
||||
snapshot: snapshot.value,
|
||||
}),
|
||||
bufferedLiveStream,
|
||||
liveStream,
|
||||
);
|
||||
}),
|
||||
{ "rpc.aggregate": "orchestration" },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useEffect, useState, type CSSProperties, type ReactNode } from "react";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { isElectron } from "../env";
|
||||
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
|
||||
@@ -55,7 +55,6 @@ function SidebarControl() {
|
||||
|
||||
export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
const navigate = useNavigate();
|
||||
const pathname = useLocation({ select: (location) => location.pathname });
|
||||
const isMacosDesktop = isElectron && isMacPlatform(navigator.platform);
|
||||
const [isWindowFullscreen, setIsWindowFullscreen] = useState(() => {
|
||||
const getWindowFullscreenState = window.desktopBridge?.getWindowFullscreenState;
|
||||
@@ -93,17 +92,14 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
|
||||
const unsubscribe = onMenuAction((action) => {
|
||||
if (action === "open-settings") {
|
||||
const isSettingsRoute = /^\/settings(\/|$)/.test(pathname);
|
||||
if (!isSettingsRoute) {
|
||||
void navigate({ to: "/settings" });
|
||||
}
|
||||
void navigate({ to: "/settings" });
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
unsubscribe?.();
|
||||
};
|
||||
}, [navigate, pathname]);
|
||||
}, [navigate]);
|
||||
|
||||
return (
|
||||
<SidebarProvider className="h-dvh! min-h-0!" defaultOpen style={macosWindowControlsStyle}>
|
||||
|
||||