Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
c7a3f02
fix(desktop): Local environment off survives an unreadable value in d…
juliusmarminge Nov 13, 2026
095611d
fix(mobile): a sub-agent opened from its parent on a narrow iPad keep…
juliusmarminge Nov 13, 2026
8610b31
fix(server): Codex usage answering after three seconds is no longer d…
juliusmarminge Nov 13, 2026
9a35ab0
fix(mobile): iOS terminal font and theme changes no longer replay out…
shivamhwp Nov 13, 2026
f313d0a
fix(server): stop device daemon alongside slow hub shutdown (#33566)
shivamhwp Nov 13, 2026
3ac8b1f
fix(acp): bound unread notification retention by size (#23217)
juliusmarminge Nov 13, 2026
00f617d
fix(client-runtime): recover subscriptions that stop on a healthy con…
juliusmarminge Nov 13, 2026
e419417
fix(server): stopping the service during the pre-update backup ends t…
juliusmarminge Nov 13, 2026
928dd04
fix(server): preview browser downloads Chrome 157.0.8103.78 with its …
juliusmarminge Nov 13, 2026
d0957bc
fix(opencode): restarted server stops an orphaned OpenCode server sta…
juliusmarminge Nov 13, 2026
c398b46
fix(server): Codex text generation runs when launch args define an MC…
juliusmarminge Nov 13, 2026
759e649
fix(server): agent recordings keep up with the page instead of the en…
juliusmarminge Nov 13, 2026
9b6dde9
fix(server): session import finds compressed Codex rollouts (#34947)
juliusmarminge Nov 13, 2026
148612e
fix(opencode): usage scans reuse unchanged rows and run off the event…
juliusmarminge Nov 13, 2026
d3ef7e8
fix(cursor): send the catalog's default model parameters on every Cur…
juliusmarminge Nov 13, 2026
0568a63
fix(server): agents point to Settings → Labs when the link tools are …
juliusmarminge Nov 13, 2026
139ec80
fix(server): Claude no longer dispatches skill mentions from handoff …
juliusmarminge Nov 13, 2026
4b316fd
fix(web): clear deleted checkout labels from the sidebar (#25063)
juliusmarminge Nov 13, 2026
4582a3b
fix(server): MacPorts-owned agent CLIs are no longer updated through …
juliusmarminge Nov 13, 2026
286eeea
test(desktop): AppImage shim test no longer writes into its temp dir …
juliusmarminge Nov 13, 2026
f62fa29
fix(web): Add to another machine can find ignored files past the firs…
juliusmarminge Nov 13, 2026
b5c0ee5
fix(mobile): Android Back from Pulls or Usage returns to Threads (#36…
juliusmarminge Nov 13, 2026
d19467a
fix(server): a thread visit stores only its read state (#36233)
juliusmarminge Nov 13, 2026
5cbdf00
fix(web): mostly vertical trackpad scrolls no longer navigate back or…
juliusmarminge Nov 13, 2026
8bf0dc4
fix(opencode): a resumed task subagent's turn no longer collides with…
juliusmarminge Nov 13, 2026
a4a8c61
fix(server): preview click, hover and drag survive a target replaced …
juliusmarminge Nov 13, 2026
0f13d63
fix(browser): Stop cancels loading pages (#29475)
voltcrash Nov 13, 2026
713731f
fix(server): a timed-out preview call no longer evicts the shared ser…
juliusmarminge Nov 13, 2026
5aea99a
fix(server): turns recreate a worktree folder that lost its checkout …
juliusmarminge Nov 13, 2026
beb528c
fix(server): queued scheduled deliveries follow the thread's current …
Ali-Al1 Nov 13, 2026
350753a
fix(usage): Claude accounts with a $0 monthly cap no longer leave a b…
cardoso-neto Nov 13, 2026
93aaad5
fix(web): PR conversation headers wrap instead of overflowing (#36211)
BeLazy167 Nov 13, 2026
c5dfb8f
fix(mobile): new thread starts in the thread list's filtered project …
juliusmarminge Nov 13, 2026
a877d40
fix(opencode): models load once OpenCode 2 finishes activating its pl…
juliusmarminge Nov 13, 2026
497aac2
fix(server): include Cursor team usage in account history (#36237)
Yash-Singh1 Nov 13, 2026
764c047
fix(web): terminal TypeScript links preserve error locations (#36174)
saphitv Nov 13, 2026
79dd6d7
fix(web): terminal TypeScript links preserve error locations (#36174)
saphitv Nov 13, 2026
daed1dd
fix(server): a follow-up delegated task waits for the subagents its c…
juliusmarminge Nov 13, 2026
9b5d997
fix(opencode): native forks no longer multiply usage (#23120)
juliusmarminge Nov 13, 2026
d70bfe6
fix(server): a send to a thread whose worktree can't be recreated now…
juliusmarminge Nov 13, 2026
1ea5236
fix(mobile): HTML file previews play video inline on iPhone (#32343)
juliusmarminge Nov 13, 2026
2953fda
fix(server): Antigravity skill bodies no longer exhaust the skill sca…
juliusmarminge Nov 13, 2026
76d0fff
fix(server): include symlinks in workspace search (#24578)
juliusmarminge Nov 13, 2026
7ab4650
fix(mobile): Work on PR keeps its worktree when switching machines (#…
juliusmarminge Nov 13, 2026
a09e54a
fix(server): proxied usage limits take their reset time from the CLIP…
juliusmarminge Nov 13, 2026
2d5e0ae
fix(server): session import brings in the linked-worktree sessions th…
juliusmarminge Nov 13, 2026
571b319
fix(server): a remote delegated task no longer stays running when its…
juliusmarminge Nov 13, 2026
445d32c
fix(server): preview clicks fail within their timeout and say why (#3…
juliusmarminge Nov 13, 2026
daed91f
fix(shared): batch SQLite worker result transfers (#36067)
Yash-Singh1 Nov 13, 2026
78b654f
fix(server): Stop clears a finished delegated child's row held by a s…
juliusmarminge Nov 13, 2026
ff30b16
fix(desktop): clicking above the Settings or Usage modal closes it ag…
juliusmarminge Nov 13, 2026
065aca4
test(web): code block highlight test waits for the highlighter, not a…
juliusmarminge Nov 13, 2026
be5f805
fix(web): new desktop browser tabs open at the default zoom and appea…
juliusmarminge Nov 13, 2026
8cd8a3c
fix(server): file search no longer freezes the server while fff's wat…
juliusmarminge Nov 13, 2026
8171cd0
fix(desktop): mouse back and forward stay inside the browser tab (#33…
juliusmarminge Nov 13, 2026
fcd0687
fix(web): removing a checkout moves its open draft to a remaining che…
juliusmarminge Nov 13, 2026
9efd960
fix(mobile): a Settings link sent to the running app opens the Settin…
juliusmarminge Nov 13, 2026
c83e78f
fix(web): Shift+Return after closed inline code or bold starts a plai…
juliusmarminge Nov 13, 2026
e94db17
fix(mobile): adding a folder that is already a project opens it (#34942)
juliusmarminge Nov 13, 2026
41e69ff
fix(contracts): agents keep working after starting an async delegate …
juliusmarminge Nov 13, 2026
1a4a299
fix(server): reverting to a checkpoint restores skip-worktree files (…
juliusmarminge Nov 13, 2026
66ec370
fix(shared): hosted thread URLs inside other links stay as written (#…
juliusmarminge Nov 13, 2026
c165587
fix(provider-cursor): Cursor threads report token usage and context f…
juliusmarminge Nov 13, 2026
3521634
fix(server): review diffs no longer read oversized untracked files (#…
juliusmarminge Nov 13, 2026
fa6326b
fix(web): closing a composer menu on a touch tablet no longer opens t…
juliusmarminge Nov 13, 2026
ca6e09c
fix(mobile): Duo feed scroll indicator stays left of the vertical bar…
juliusmarminge Nov 13, 2026
7bd9134
fix(server): turn diffs follow branch switches (#36343)
juliusmarminge Nov 13, 2026
b009582
fix(web): picking the previous branch after an outside checkout switc…
juliusmarminge Nov 13, 2026
0c28045
fix(server): systemd service starts again after its start limit tripp…
juliusmarminge Nov 13, 2026
eb81855
fix(server): branches in a fork checkout no longer show the fork main…
juliusmarminge Nov 13, 2026
f8dc37d
fix(web): floating preview resize holds its shape and ends when inter…
juliusmarminge Nov 13, 2026
250d372
fix(web): images in expanded tool rows page through the group's viewe…
juliusmarminge Nov 13, 2026
6bb9b7b
fix(web): auto-settle days save when the edit is finished, not on eve…
juliusmarminge Nov 13, 2026
e07585e
fix(desktop): AppImage updates keep their filename (#36306)
juliusmarminge Nov 13, 2026
51e1346
fix(relay): an iPad no longer gets a Done alert for every unrelated p…
juliusmarminge Nov 13, 2026
96a4d2f
fix(web): pasted URLs and paths keep their underscores (#36363)
juliusmarminge Nov 13, 2026
af28467
fix(mobile): reference links resolve across folds and artifact cards …
juliusmarminge Nov 13, 2026
4115648
fix(server): a folder that only holds a repository's worktrees is ref…
juliusmarminge Nov 13, 2026
65e4272
fix(server): a hung network mount no longer freezes the server when i…
juliusmarminge Nov 13, 2026
cfc71e1
fix(web): preview annotations in question answers reach the agent wit…
juliusmarminge Nov 13, 2026
1721f18
fix(web): clearing a running terminal keeps its screen and input mode…
juliusmarminge Nov 13, 2026
1da05a8
fix(server): a default branch the remote deleted no longer starts wor…
juliusmarminge Nov 13, 2026
38072bd
fix(desktop): new tabs the agent opens from links no longer steal com…
juliusmarminge Nov 13, 2026
9a455f0
fix(ssh): a renamed SSH connection keeps managing its remote server (…
juliusmarminge Nov 13, 2026
af9b4e4
fix(server): a worktree handoff on Claude or Pi completes its run and…
juliusmarminge Nov 13, 2026
0a6b3eb
fix(forgejo): Gitea branch PR lookups no longer read the whole pull r…
juliusmarminge Nov 13, 2026
9402dc3
fix(checkpoint): fetched upstream commits no longer show as agent cha…
juliusmarminge Nov 13, 2026
d772115
fix(server): terminal history keeps text after a CSI cut off by non-A…
juliusmarminge Nov 13, 2026
7ea6db4
fix(web): a mounted chat view no longer keeps every thread copy it re…
juliusmarminge Nov 13, 2026
b5b4705
fix(server): a Codex Stop that never completes offers Force stop (#36…
juliusmarminge Nov 13, 2026
0517d15
fix(web): provider sign-in links only open web addresses (#36392)
juliusmarminge Nov 13, 2026
aab388d
fix(server): Claude can show the user mid-turn text in full (#36384)
juliusmarminge Nov 13, 2026
9f94a87
fix(cli): tagged source builds report the release version (#36350)
juliusmarminge Nov 13, 2026
0b5f35c
fix(server): storage cleanup prunes idle No project folders under ~/.…
juliusmarminge Nov 13, 2026
93cbca3
fix(terminal): trimmed history no longer replays half of a control se…
juliusmarminge Nov 13, 2026
9ced4f1
fix(usage): a re-emitted Codex snapshot is no longer billed as a coun…
juliusmarminge Nov 13, 2026
931cd3a
fix(server): a Claude Monitor line no longer wakes a delegated child'…
juliusmarminge Nov 13, 2026
b35819c
fix(opencode): a lost subagent report no longer leaves a resumed call…
juliusmarminge Nov 13, 2026
bc7fe11
fix(web): a new worktree thread opened during a clone bases on the re…
juliusmarminge Nov 13, 2026
4ee3b60
fix(server): unauthenticated token requests no longer write DPoP repl…
juliusmarminge Nov 13, 2026
94aa3d7
fix(server): other sites can no longer frame the web app (#36395)
juliusmarminge Nov 13, 2026
5df5b44
fix(server): a server browser tab survives a renderer crash, and a se…
juliusmarminge Nov 13, 2026
1219f62
fix(web): T3 Connect sign-in offers Retry after Clerk fails to load (…
juliusmarminge Nov 13, 2026
dd2678d
fix(ci): macOS PR previews no longer run the PR's bundle next to sign…
juliusmarminge Nov 13, 2026
134ab31
fix(mobile): a new thread's first message no longer returns to the co…
juliusmarminge Nov 13, 2026
48cdefe
fix(web): size markdown media whose width and height carry a px unit …
juliusmarminge Nov 13, 2026
36f011d
fix(web): file links the agent cited from a checkout it cd'd into ope…
juliusmarminge Nov 13, 2026
70b0529
ci(mobile): iOS jobs run on macos-27, store builds require the final …
juliusmarminge Nov 13, 2026
3566a82
Merge remote-tracking branch 'origin/main' into upstream-sync
D3SOX Nov 13, 2026
e6c7fc8
fix: preserve collapsible image rows during upstream sync
D3SOX Nov 13, 2026
fafee89
Merge remote-tracking branch 'origin/main' into upstream-sync
D3SOX Nov 13, 2026
6f2cdea
fix(web): keep viewed image galleries in collapsible rows
D3SOX Nov 13, 2026
33fb183
test: isolate lightweight tags from signing preferences
D3SOX Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ jobs:
name: Mobile Native Static Analysis
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
runs-on: blacksmith-6vcpu-macos-26
runs-on: blacksmith-6vcpu-macos-27
timeout-minutes: 10
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/desktop-macos-preview-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ jobs:
rust_target: aarch64-apple-darwin
resource_key: darwin-arm64
cli_archive: false
untrusted_bundle: true

# Release assets download without a GitHub account, unlike workflow
# artifacts. All preview DMGs live on one rolling prerelease tagged
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mobile-dev-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
ios:
name: iOS simulator
if: github.repository == 'pingdotgg/t3code' && (github.event_name != 'workflow_dispatch' || inputs.platform == 'ios')
runs-on: blacksmith-12vcpu-macos-26
runs-on: blacksmith-12vcpu-macos-27
timeout-minutes: 60
concurrency:
group: mobile-dev-client-ios-${{ github.event_name == 'pull_request' && github.event.pull_request.number || inputs.fingerprint || github.sha }}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/mobile-eas-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ jobs:
echo ":rocket: android: submitted and recorded \`$BUILD_TAG\`" >> "$GITHUB_STEP_SUMMARY"

# Off unless the MOBILE_IOS_LOCAL_BUILDS repository variable is `true`; the
# production job only sets ios_build then. Store binaries need the final
# Xcode 27.1; MOBILE_IOS_ALLOW_XCODE_RC=true accepts the release candidate.
# production job only sets ios_build then. Xcode 27.1 matches the EAS build
# image in eas.json.
# No sticky disk: it mounts ext4 and only works on Linux runners.
ios:
name: iOS store build
Expand All @@ -701,7 +701,6 @@ jobs:
EXPO_TOKEN: ${{ secrets.EXPO_PRODUCTION_TOKEN }}
PROFILE: ${{ needs.production.outputs.ios_profile }}
BUILD_TAG: mobile-ios-build/${{ needs.production.outputs.ios_profile }}/${{ needs.production.outputs.ios_version }}/${{ needs.production.outputs.ios_fingerprint }}
ALLOW_XCODE_RC: ${{ vars.MOBILE_IOS_ALLOW_XCODE_RC == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -739,12 +738,9 @@ jobs:
if: steps.record.outputs.built != 'true'
run: |
xcode=/Applications/Xcode_27.1.app
if [ ! -d "$xcode" ] && [ "$ALLOW_XCODE_RC" = "true" ]; then
xcode=/Applications/Xcode_27.1_Release_Candidate.app
fi
if [ ! -d "$xcode" ]; then
ls -d /Applications/Xcode*.app
echo "::error::Xcode 27.1 (final) is not on this runner. Set the MOBILE_IOS_ALLOW_XCODE_RC repository variable to true to build store binaries with the release candidate."
echo "::error::Xcode 27.1 is not on this runner."
exit 1
fi
sudo xcode-select -s "$xcode/Contents/Developer"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mobile-showcase-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
ios:
name: iPhone, iPhone Duo, and iPad 13
if: inputs.platform == 'all' || inputs.platform == 'ios'
runs-on: blacksmith-12vcpu-macos-26
runs-on: blacksmith-12vcpu-macos-27
# Capturing every palette multiplies the device matrix by six, and only the
# one native build is shared between them.
timeout-minutes: ${{ inputs.theme == 'all' && 300 || 60 }}
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ on:
required: false
default: false
type: boolean
# Whether the JS bundle came from a pull request. This job holds the
# signing secrets, so packaging then skips every step that runs the bundle.
untrusted_bundle:
required: false
default: false
type: boolean
# A runner of the target's own platform and architecture, for a `runner`
# that cannot execute the target. The build job skips everything that
# runs the packaged binaries, and a second job runs it there.
Expand Down Expand Up @@ -134,6 +140,14 @@ jobs:
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ inputs.clerk_cli_oauth_client_id }}
T3CODE_RELAY_URL: ${{ inputs.relay_url }}
steps:
# The launch check and the CLI archive smoke test both run the bundle.
- name: Reject running an untrusted bundle
if: inputs.untrusted_bundle && (inputs.launch_check || inputs.cli_archive)
shell: bash
run: |
echo "::error::untrusted_bundle cannot be combined with launch_check or cli_archive, which run the bundle."
exit 1
# This repository is public, so Git needs no credentials. checkout's
# credential cleanup runs submodule foreach even with submodules disabled,
# which fails on the orphaned gitlinks in our vendored .repos tree.
Expand Down Expand Up @@ -573,6 +587,7 @@ jobs:
pnpm_config_prefer_offline: "true"
T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: true
T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS: ${{ steps.capture_helper_cache.outputs.cache-hit == 'true' }}
T3CODE_DESKTOP_UNTRUSTED_BUNDLE: ${{ inputs.untrusted_bundle }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/app/DesktopCliShim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const fakeAppImage = (canMount = true, app = REPORTER) => {
`echo $$ >'${root}/mounter.pid'`,
canMount ? `echo '${image}'` : 'echo "Cannot mount AppImage"; exit 1',
// Like the FUSE runtime, any of these unmounts. fd 3 reports to the test when it is open.
`trap 'echo unmounted >&3 2>/dev/null; touch "${root}/unmounted"; exit 0' TERM HUP INT`,
"trap 'echo unmounted >&3 2>/dev/null; exit 0' TERM HUP INT",
"trap 'echo mounted >&3 2>/dev/null' WINCH",
"while :; do sleep 0.05; done",
"",
Expand Down
29 changes: 29 additions & 0 deletions apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,35 @@ describe("DesktopLinuxUrlHandler", () => {
assert.include(entry, "Icon=/home/al ice/icons/T3\\\\x.png");
});

it.each([
{ from: "T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: true },
{
from: "T3-Code-0.1.9-nightly.20261110.4449-arm64.AppImage",
to: "T3-Code-Nightly-arm64.AppImage",
restored: true,
},
{ from: "T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-0.1.9-x86_64.AppImage", restored: false },
{ from: "t3code.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
{ from: "T3-Code-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
{ from: "../T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
])("finds the launch path an update from $from to $to removed", ({ from, to, restored }) => {
for (const dir of ["/home/alice/Applications", '/home/al ice/My "100%" $Apps\\x']) {
const previous = dir + "/" + from;
const previousEntry = DesktopLinuxUrlHandler.renderUrlHandlerDesktopEntry({
displayName: "T3 Code (Beta)",
execTarget: previous,
scheme: "t3code",
});
assert.equal(
DesktopLinuxUrlHandler.replacedVersionedAppImagePath({
previousEntry,
appImagePath: dir + "/" + to,
}),
restored ? previous : null,
);
}
});

it.effect(
"writes the handler entry, refreshes the MIME cache, and claims the scheme default",
() => {
Expand Down
32 changes: 32 additions & 0 deletions apps/desktop/src/app/DesktopLinuxUrlHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,38 @@ export function renderUrlHandlerDesktopEntry(input: {
].join("\n");
}

function parseUrlHandlerExecTarget(entry: string): string | null {
const exec = /^Exec=(.*) %U$/mu.exec(entry)?.[1];
if (exec === undefined) return null;
const unescaped = exec.replace(/\\([\\nrt])/gu, (_, char: string) =>
char === "n" ? "\n" : char === "r" ? "\r" : char === "t" ? "\t" : char,
);
const quoted = /^"(.*)"$/su.exec(unescaped)?.[1];
return (
quoted === undefined ? unescaped : quoted.replace(/\\([\\`$"])/gu, (_, char: string) => char)
).replaceAll("%%", "%");
}

const APPIMAGE_NAME_VERSION = /\d+\.\d+\.\d+/u;

// An updater from before version-free AppImage names deletes its own file and installs the update
// beside it under the new name. The previous launch's entry still names the path launchers use.
export function replacedVersionedAppImagePath(input: {
readonly previousEntry: string;
readonly appImagePath: string;
}): string | null {
const previous = parseUrlHandlerExecTarget(input.previousEntry);
if (previous === null) return null;
const previousName = previous.slice(previous.lastIndexOf("/") + 1);
const currentName = input.appImagePath.slice(input.appImagePath.lastIndexOf("/") + 1);
return previous.startsWith("/") &&
previous.slice(0, -previousName.length) === input.appImagePath.slice(0, -currentName.length) &&
APPIMAGE_NAME_VERSION.test(previousName) &&
!APPIMAGE_NAME_VERSION.test(currentName)
? previous
: null;
}

// Docks may look up the Wayland app id without a desktop entry; icon theme lookups are case-sensitive.
const LINUX_THEME_ICON_SIZE = "256x256";

Expand Down
45 changes: 45 additions & 0 deletions apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
copyFileSyncMock,
execFileSyncMock,
readFileSyncMock,
symlinkSyncMock,
} = vi.hoisted(() => ({
appendSwitchMock: vi.fn(),
getSwitchValueMock: vi.fn(),
Expand All @@ -27,6 +28,7 @@ const {
copyFileSyncMock: vi.fn(),
execFileSyncMock: vi.fn(),
readFileSyncMock: vi.fn(),
symlinkSyncMock: vi.fn(),
}));

vi.mock("electron", () => ({
Expand All @@ -51,6 +53,7 @@ vi.mock("node:fs", () => ({
mkdirSync: mkdirSyncMock,
writeFileSync: writeFileSyncMock,
copyFileSync: copyFileSyncMock,
symlinkSync: symlinkSyncMock,
}));

vi.mock("node:child_process", () => ({
Expand All @@ -72,6 +75,7 @@ describe("DesktopPreReadyPlatform", () => {
copyFileSyncMock.mockReset();
execFileSyncMock.mockReset();
readFileSyncMock.mockReset().mockReturnValue("{}");
symlinkSyncMock.mockReset();
});

it.effect("persists Linux scaling synchronously across relaunches and settings rewrites", () => {
Expand Down Expand Up @@ -181,6 +185,47 @@ describe("DesktopPreReadyPlatform", () => {
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
});

it.effect.each([
{ relaunchedByUpdater: "true", restored: true },
{ relaunchedByUpdater: "", restored: false },
])(
"restores the versioned AppImage path an update removed (updater relaunch: $relaunchedByUpdater)",
({ relaunchedByUpdater, restored }) => {
vi.stubEnv("VITE_DEV_SERVER_URL", "");
getSwitchValueMock.mockReturnValue("");
const entryPath = "/xdg/applications/com.t3tools.T3Code.desktop";
const files = new Map([[entryPath, "Exec=/Applications/T3-Code-0.1.8-x86_64.AppImage %U\n"]]);
readFileSyncMock.mockImplementation((path: string) => files.get(path) ?? "{}");
writeFileSyncMock.mockImplementation((path: string, contents: string | Buffer) => {
files.set(path, String(contents));
});

return Effect.scoped(
Effect.gen(function* () {
yield* Layer.build(
DesktopPreReadyPlatform.layer.pipe(
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
Layer.provide(
DesktopConfig.layerTest({
XDG_DATA_HOME: "/xdg",
APPIMAGE: "/Applications/T3-Code-x86_64.AppImage",
APPIMAGE_SILENT_INSTALL: relaunchedByUpdater,
}),
),
),
);
assert.deepEqual(
symlinkSyncMock.mock.calls,
restored
? [["T3-Code-x86_64.AppImage", "/Applications/T3-Code-0.1.8-x86_64.AppImage"]]
: [],
);
assert.include(files.get(entryPath), "Exec=/Applications/T3-Code-x86_64.AppImage %U");
}),
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
},
);

it.effect("points the early portal entry at a configured distribution launcher", () => {
vi.stubEnv("VITE_DEV_SERVER_URL", "");
getSwitchValueMock.mockReturnValue("");
Expand Down
27 changes: 25 additions & 2 deletions apps/desktop/src/app/DesktopPreReadyPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts";
import { trimmedString } from "./DesktopConfig.ts";
import { resolveDesktopAppBranding } from "./DesktopEnvironment.ts";
import { renderUrlHandlerDesktopEntry } from "./DesktopLinuxUrlHandler.ts";
import {
renderUrlHandlerDesktopEntry,
replacedVersionedAppImagePath,
} from "./DesktopLinuxUrlHandler.ts";
import * as ElectronProtocol from "../electron/ElectronProtocol.ts";

export interface DesktopPreReadyCommandLineReader {
Expand Down Expand Up @@ -56,6 +59,8 @@ const LinuxDesktopEntryConfig = Config.all({
xdgDataHome: trimmedString("XDG_DATA_HOME"),
launcherPath: trimmedString("T3CODE_DESKTOP_LAUNCHER_PATH"),
appImagePath: trimmedString("APPIMAGE"),
// electron-updater sets this on the AppImage it relaunches after installing an update.
relaunchedByUpdater: trimmedString("APPIMAGE_SILENT_INSTALL"),
});

/** @public */
Expand Down Expand Up @@ -116,8 +121,26 @@ export const make = Effect.gen(function* () {
);
} catch {}
}
const desktopEntryPath = NodePath.posix.join(applicationsDir, linux.linuxDesktopEntryName);
const { appImagePath } = linuxDesktopEntryConfig;
if (
Option.isSome(appImagePath) &&
Option.isNone(linuxDesktopEntryConfig.launcherPath) &&
Option.contains(linuxDesktopEntryConfig.relaunchedByUpdater, "true")
) {
try {
const replacedPath = replacedVersionedAppImagePath({
previousEntry: NodeFS.readFileSync(desktopEntryPath, "utf8"),
appImagePath: appImagePath.value,
});
// Relative, so the pair survives a moved folder; symlink never overwrites a file.
if (replacedPath !== null) {
NodeFS.symlinkSync(NodePath.posix.basename(appImagePath.value), replacedPath);
}
} catch {}
}
NodeFS.writeFileSync(
NodePath.posix.join(applicationsDir, linux.linuxDesktopEntryName),
desktopEntryPath,
renderUrlHandlerDesktopEntry({
displayName: resolveDesktopAppBranding({
isDevelopment: linux.isDevelopment,
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/ipc/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const PREVIEW_REGISTER_WEBVIEW_CHANNEL = "desktop:preview-register-webvie
export const PREVIEW_NAVIGATE_CHANNEL = "desktop:preview-navigate";
export const PREVIEW_GO_BACK_CHANNEL = "desktop:preview-go-back";
export const PREVIEW_GO_FORWARD_CHANNEL = "desktop:preview-go-forward";
export const PREVIEW_STOP_LOADING_CHANNEL = "desktop:preview-stop-loading";
export const PREVIEW_REFRESH_CHANNEL = "desktop:preview-refresh";
export const PREVIEW_ZOOM_IN_CHANNEL = "desktop:preview-zoom-in";
export const PREVIEW_ZOOM_OUT_CHANNEL = "desktop:preview-zoom-out";
Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/ipc/methods/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ const refresh = tabMethod(
"desktop.ipc.preview.refresh",
(manager, tabId) => manager.refresh(tabId),
);
const stopLoading = tabMethod(
IpcChannels.PREVIEW_STOP_LOADING_CHANNEL,
"desktop.ipc.preview.stopLoading",
(manager, tabId) => manager.stopLoading(tabId),
);
const zoomIn = tabMethod(
IpcChannels.PREVIEW_ZOOM_IN_CHANNEL,
"desktop.ipc.preview.zoomIn",
Expand Down Expand Up @@ -472,6 +477,7 @@ export const methods = [
goBack,
goForward,
refresh,
stopLoading,
zoomIn,
zoomOut,
resetZoom,
Expand Down
11 changes: 11 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
// @effect-diagnostics-next-line nodeBuiltinImport:off - Version output must flush before Electron exits, without acquiring the runtime.
import * as NodeFS from "node:fs";
import * as NodeOS from "node:os";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";

import * as Electron from "electron";
Expand Down Expand Up @@ -123,6 +125,15 @@ const layerDesktopSshEnvironment = Layer.unwrap(
nodeEngineRange: serverPackageJson.engines.node,
}),
),
resolveLauncherId: yield* Effect.cached(
DesktopSshEnvironment.readOrCreateLauncherId(
environment.path.join(environment.stateDir, "ssh-launcher-id"),
).pipe(
Effect.provide(
yield* Effect.context<FileSystem.FileSystem | SecureRandom.SecureRandom>(),
),
),
),
});
}),
);
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ contextBridge.exposeInMainWorld("desktopBridge", {
goBack: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_GO_BACK_CHANNEL, { tabId }),
goForward: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_GO_FORWARD_CHANNEL, { tabId }),
refresh: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_REFRESH_CHANNEL, { tabId }),
stopLoading: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_STOP_LOADING_CHANNEL, { tabId }),
zoomIn: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_ZOOM_IN_CHANNEL, { tabId }),
zoomOut: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_ZOOM_OUT_CHANNEL, { tabId }),
resetZoom: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_RESET_ZOOM_CHANNEL, { tabId }),
Expand Down
Loading
Loading