Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
379a98a
fix(server): t3 pair skips Windows VirtualBox and VMware host-only ad…
juliusmarminge Nov 22, 2026
418e1ac
fix(server): Word text boxes keep their paragraph breaks for agents (…
KyrosHendrix Nov 22, 2026
356dff3
fix(web): RTF previews respect hidden character formatting (#40783)
geezoria Nov 22, 2026
5fc2eb2
fix(mobile): the iOS composer keeps its keyboard and caret after dict…
arun279 Nov 22, 2026
997103b
fix(shared): find file links whose labels contain brackets (#40781)
Abhiram-745 Nov 22, 2026
1acfd37
fix(web): restore effort picker keyboard typeahead (#40798)
juliusmarminge Nov 22, 2026
0ae3154
fix(server): migration 75 no longer fails on an unreadable subagent p…
juliusmarminge Nov 22, 2026
671e05b
fix(issues): an Activity cross-reference opens the issue or pull requ…
juliusmarminge Nov 22, 2026
8435a8c
fix(server): tell a stopped parent which delegated tasks its Stop int…
juliusmarminge Nov 22, 2026
f931f03
fix(server): worktree thread lookups match any spelling of the path (…
juliusmarminge Nov 22, 2026
c585a58
fix(mobile): prevent clipped percentages in usage limit cards (#40778)
peterxiemin Nov 22, 2026
9892474
test(web): browser tests no longer fail when a stale optimizer cache …
Brechard Nov 22, 2026
62a7108
fix(github): superseded runs' cancelled checks no longer block PR wat…
juliusmarminge Nov 22, 2026
a8363da
fix(web): keybindings using '+' show a plus keycap instead of empty p…
AymanKhan9 Nov 22, 2026
d27d29f
fix(web): lineage show-more no longer clips the last row or drops foc…
justsrc Nov 22, 2026
4868aeb
fix(mobile): pulling to Load earlier activity no longer snaps the fee…
juliusmarminge Nov 22, 2026
aa0a851
perf(dev): incremental, cached server typecheck like web and desktop …
Pyseph Nov 22, 2026
a35b3ca
fix(contracts): delegate_task options example says ids differ by prov…
juliusmarminge Nov 22, 2026
d834a4e
fix(web): preserve reply-only edits when a queued message leaves the …
iiijiashu Nov 22, 2026
3c68308
fix(server): t3 start ignores a stale runtime record whose PID was re…
juliusmarminge Nov 22, 2026
9f19a6d
fix(server): runtime prune removes the runtime a committed update rep…
juliusmarminge Nov 22, 2026
f2d0217
fix(server): preserve cancellations during checkpoint capture (#31349)
voltcrash Nov 22, 2026
91d2d90
fix(web): a failed main chunk load reloads once instead of showing th…
juliusmarminge Nov 22, 2026
ecdd8e2
fix(server): slash commands reach the provider verbatim when context …
juliusmarminge Nov 22, 2026
c80f41f
fix(opencode): a command that never calls the model no longer leaves …
juliusmarminge Nov 22, 2026
3d7bb17
fix(mobile): model search finds legacy models (#27587)
juliusmarminge Nov 22, 2026
5799b8a
fix(acp): follow a mode the agent leaves on its own so picking it aga…
juliusmarminge Nov 22, 2026
bcb9217
fix(web): settling a thread no longer jolts the sidebar list (#26661)
flamboh Nov 22, 2026
4136ab6
fix(server): Word files whose main part is not word/document.xml reac…
Marve10s Nov 22, 2026
03920ad
fix(server): wake the agent when Claude exits while it awaits backgro…
juliusmarminge Nov 22, 2026
3571f28
fix(web): Usage Limits no longer shows a stale scrollbar (#40816)
inanimran Nov 22, 2026
77d299c
fix(web): closing the last open pull request clears it from the list …
MyDigitalLife Nov 22, 2026
31790d8
fix(mobile): account badge on the provider icon is readable without a…
juliusmarminge Nov 22, 2026
66ca7cd
fix(server): Claude turns no longer stall on empty or partial stream …
lln556 Nov 22, 2026
ac62463
fix(server): filesystem browse lists symlinks pointing to directories…
lln556 Nov 22, 2026
d5497d6
fix(client-runtime): a resumed thread renders its catch-up once inste…
ahalekelly Nov 22, 2026
501e39d
fix(web): clicking the Tab hint inserts short prompt suggestions agai…
floklein Nov 22, 2026
1e78f37
fix(web): keep script-only drafts reachable in the sidebar (#25272)
juliusmarminge Nov 22, 2026
b23f1e8
fix(server): retire unresponsive shared Codex app-servers (#25123)
juliusmarminge Nov 22, 2026
a985332
fix(shared): Windows command discovery no longer blocks the event loo…
maria-rcks Nov 22, 2026
b479ce2
fix(client-runtime): stop sessions on incompatible server configurati…
juliusmarminge Nov 22, 2026
620cf47
fix(web): browser page translation no longer crashes the app when a t…
juliusmarminge Nov 22, 2026
30372d0
perf(mobile): keep image bytes outside draft JSON (#9727)
t3dotgg Nov 22, 2026
ad2bdc7
fix(server): watch_pull_request says when checks already passed (#40866)
juliusmarminge Nov 22, 2026
a445025
fix(codex): Open diff shows every file of a multi-file patch (#40874)
Abhiram-745 Nov 22, 2026
2f19cec
fix(server): ACP startup gives up when the agent never answers the ha…
juliusmarminge Nov 22, 2026
1d02824
fix(server): a branch prefixed with another remote's name publishes u…
Abhiram-745 Nov 22, 2026
f10e1eb
fix(server): list open delegated tasks when task_status or task_cance…
Project516 Nov 22, 2026
2251de4
fix(gitlab): find merge requests opened from a fork (#40894)
Abhiram-745 Nov 22, 2026
2c4310e
fix(web): pasting a chat message with text and a picture keeps both (…
juliusmarminge Nov 22, 2026
344de5f
fix(antigravity): bound silent post-settle background command holds (…
Lokkuchakreshkumar Nov 22, 2026
5ddcc25
fix(desktop): WSL is not offered or started when only the Windows ins…
juliusmarminge Nov 22, 2026
ad44645
fix(server): idle /ws connections behind a reverse proxy no longer dr…
juliusmarminge Nov 22, 2026
cc4bb17
fix(server): thread reads no longer attribute T3 Code's compact-befor…
juliusmarminge Nov 22, 2026
9de4ec1
fix(web,mobile): @-file mentions show by name in message previews, no…
tiliakoos Nov 22, 2026
7ddc81d
fix(web): tool calls stay grouped after a usage-limit pause again (#4…
matthew-waters Nov 22, 2026
ec35ad6
fix(server): t3 doctor no longer reports a database just under 1 GiB …
tiliakoos Nov 22, 2026
6972026
fix(web): show clone failure after progress is dismissed (#40951)
StiensWout Nov 22, 2026
bc13afa
Invalidate pending theme imports when a replacement is too large (#40…
StiensWout Nov 22, 2026
4e1c1fe
fix(mobile): show linked thread history page errors (#40973)
StiensWout Nov 22, 2026
3806763
fix(client-runtime): skip waiting for lower-priority linked addresses…
StiensWout Nov 22, 2026
25440f5
fix(web): navigate Excel sheets from the focused tab (#41008)
StiensWout Nov 22, 2026
9b7f5eb
fix(mobile): bound app-owned composer attachment filenames (#40991)
StiensWout Nov 22, 2026
0179401
fix(web): prioritize visible saved notebook outputs (#40998)
StiensWout Nov 22, 2026
87554a7
fix(web): editing a queued message keeps its attachment chips resolve…
smirea Nov 22, 2026
28706ac
fix(server): unlinking an environment ends its session on the other m…
juliusmarminge Nov 22, 2026
7ed41b7
fix(mobile): scope Git result banners to their originating thread (#4…
StiensWout Nov 22, 2026
000ba18
fix(web): keep the conversation when a pairing tab closes (#41025)
StiensWout Nov 22, 2026
5bd0616
fix: restart linked thread reads when trying again (#41020)
StiensWout Nov 22, 2026
55880c4
fix(client-runtime): count ambiguous projects in chat file links (#40…
StiensWout Nov 22, 2026
2e62a71
fix(mobile): keep media actions on each sent image page (#41018)
StiensWout Nov 22, 2026
024dba2
perf(server): a run's provider turn lookup is linear, not quadratic (…
navidnadali Nov 22, 2026
c7df700
fix(web): a photo picked on a phone attaches even when the composer c…
juliusmarminge Nov 22, 2026
02a4c18
fix(mobile): cancel pending media actions when swiping gallery pages …
StiensWout Nov 22, 2026
c00f117
fix(mobile): TalkBack can reach the status pill above the composer (#…
Lenoridev Nov 22, 2026
67f1752
fix(web): snooze labels follow the app language (#39494)
SoroushRF Nov 22, 2026
dbb5bdb
feat(web): sidebar folder button picks or adds a project (#33057)
tenyoru Nov 22, 2026
fff245a
feat(mobile): favorites only is its own model filter, not a provider …
RVZO6 Nov 22, 2026
f9fbb00
feat(devices): double-tap Home opens the app switcher (#29459)
JoshuaRileyDev Nov 22, 2026
735c1e7
test(desktop): AppImage shim test's fake server ignores a second stop…
juliusmarminge Nov 22, 2026
7e3a9ba
fix(server): a task folder creation that loses a branch race no longe…
juliusmarminge Nov 22, 2026
e213da2
fix(client-runtime): refresh stale server clock offset after host sle…
Zangetsu101 Nov 22, 2026
68e81cd
fix(server): settled-subagent check reads run status from runs_run_st…
juliusmarminge Nov 22, 2026
324ac49
fix(server): fresh-session scheduled runs release every idle Codex th…
juliusmarminge Nov 22, 2026
fe9c98c
feat: agents can report T3 Code problems when you turn feedback on (#…
gabrielelpidio Nov 22, 2026
c89ca0a
fix(server): a worktree thread moved to the project checkout no longe…
tiliakoos Nov 22, 2026
a3323d4
perf(web): new thread opens its draft without waiting on t3.json (#41…
juliusmarminge Nov 22, 2026
dd19bce
fix(server): a dropped dictation client frees the speech engine withi…
juliusmarminge Nov 22, 2026
0938476
fix(web): Thinking row no longer shows below a streaming reply (#41060)
juliusmarminge Nov 22, 2026
7103527
fix(web): PR description file links resolve in the PR's repository fr…
juliusmarminge Nov 22, 2026
44979a5
fix(mcp): keep deleted schedules from returning on edit (#41084)
SSHdotCodes Nov 22, 2026
a09738f
fix(claude): start the updated Claude Code CLI when a thread changes …
SSHdotCodes Nov 22, 2026
fb4558d
fix(web,mobile,server): large files load in full without freezing the…
juliusmarminge Nov 22, 2026
ba947e3
fix(desktop): show ampersands in native context menu labels (#41097)
brunobola Nov 22, 2026
0ee3a92
fix(forgejo): follow Markdown pull request templates (#41095)
steven-salinas Nov 22, 2026
6ba17d9
fix(claude): show steer replies and progress lines written as thinkin…
SSHdotCodes Nov 22, 2026
fb23f12
feat(server): outside agents poll and stream milestones as MCP events…
juliusmarminge Nov 22, 2026
9d35540
fix(mobile): pasted iOS photos keep their encoding and repeats are dr…
juliusmarminge Nov 22, 2026
7b47a21
fix(server): a Claude resume runs one turn, not a phantom wake after …
juliusmarminge Nov 23, 2026
0591d32
feat(issues): connect more than one Linear account (#39179)
Bil0000 Nov 23, 2026
43af49b
fix(server): keep inactive threads whose branch has an open PR (#41116)
only21mil Nov 23, 2026
1b59af0
fix(mobile): enlarge PR file Viewed tap target (#39950)
Ernest0-Production Nov 23, 2026
05c100f
fix(server): skip queued checkpoint restores after thread deletion (#…
only21mil Nov 23, 2026
65b2e6d
fix(web): stop telemetry refresh spinning after data arrives (#41122)
SSHdotCodes Nov 23, 2026
def64e3
fix(web): clicking the selected file in a Files folder view opens it …
mikeozornin Nov 23, 2026
6b38ec9
fix(desktop): remote servers behind origin-checking proxies no longer…
tyler-bruno-lovable Nov 23, 2026
83119ae
fix(server): stopping a delegated child with a queued message no long…
juliusmarminge Nov 23, 2026
e414cfd
feat(server): durable workflows (#38882)
juliusmarminge Nov 23, 2026
65d2b4f
fix(web): center the Connections map zoom controls (#41081)
shivamhwp Nov 23, 2026
8ff66fc
fix(server): Antigravity usage reads the default instance's T3 profil…
juliusmarminge Nov 23, 2026
69c1d53
feat: workflows on web and mobile (#38884)
juliusmarminge Nov 23, 2026
f29c824
fix(server): Full access Codex no longer asks before dangerous comman…
juliusmarminge Nov 23, 2026
2808e87
fix(usage): skipped-record warnings only count the selected dates (#4…
Yash-Singh1 Nov 23, 2026
8cc8bcb
feat(server): outside agents receive milestones by MCP Events webhook…
juliusmarminge Nov 23, 2026
29a33f8
fix(antigravity): recognize attachments with MIME parameters (#39097)
Lucenx9 Nov 23, 2026
27ab8d4
fix(antigravity): keep shortened question text valid Unicode (#39478)
Lucenx9 Nov 23, 2026
b9c3109
fix(cursor): preserve ended turns when connection retries exhaust (#4…
Yash-Singh1 Nov 23, 2026
074a0d3
fix(server): startup PR backfill looks up each repository branch once…
juliusmarminge Nov 23, 2026
8a17857
perf(mobile): avoid re-rendering on shell updates in useSidebarRowThr…
Isaac-b-ux Nov 23, 2026
1a4932e
perf(client): skip child indexing when no child needs input (#25537)
saphid Nov 23, 2026
8634955
fix(server): app links no longer leave the preview stuck loading (#41…
niieani Nov 23, 2026
047a86f
fix(server): open Claude sessions on macOS share one process-table po…
juliusmarminge Nov 23, 2026
18850a5
fix(mobile): screen readers hear when a terminal Ctrl, Alt or Cmd key…
tiliakoos Nov 23, 2026
372fbab
fix(server): renaming a provider instance no longer stops its session…
juliusmarminge Nov 23, 2026
1d61429
perf(server): idle agent sessions free their memory after 2 minutes (…
juliusmarminge Nov 23, 2026
8708a29
perf(server): checkpoint capture no longer walks every reflog in the …
juliusmarminge Nov 23, 2026
a679987
test(server): replay scenarios no longer run checkpoints against the …
juliusmarminge Nov 23, 2026
9a87dbb
fix(web): chat file tooltips open beside the link instead of sliding …
juliusmarminge Nov 23, 2026
c18f82c
fix(server): RTF attachments leave hidden text out of what agents rea…
only21mil Nov 23, 2026
1d4d9be
fix(server): Antigravity 502s fail the turn with the real error (#33596)
juliusmarminge Nov 23, 2026
9dc3616
fix(web,mobile): translate remaining untranslated workflow, git, and …
SeniorZhai Nov 23, 2026
e6ae581
fix(web): preserve reading position when side panels resize (#41184)
juliusmarminge Nov 23, 2026
192ef9b
fix(web): preserve alpha channel when previewing WhiteIsZero TIFF ima…
only21mil Nov 23, 2026
b50e769
fix(server): workflow event types appear only while Workflows is on (…
juliusmarminge Nov 23, 2026
dc2f73a
fix(server): worktree launches name their branch while the worktree i…
juliusmarminge Nov 23, 2026
9d3054a
fix(cli): expand ~ paths passed to t3 project add --track (#41199)
only21mil Nov 23, 2026
4aed119
fix(server): html_preview as root names the sandbox opt-out (#41206)
juliusmarminge Nov 23, 2026
d775f66
chore: vouch jschachter (#41215)
t3dotgg Nov 23, 2026
7e5a439
fix(server): parse unordered HTML favicon rel tokens (#41203)
only21mil Nov 23, 2026
71d1830
fix(server): token analytics label new models from Codex and Claude c…
t3dotgg Nov 23, 2026
887e3a5
fix(web): file picker highlights stay on the typed letters after İ (#…
only21mil Nov 23, 2026
58aa80d
fix(server): T3's own git commands no longer start Git's auto mainten…
mkantenko Nov 23, 2026
73bb8ec
fix(web): accept TIFF files containing standard IFD tag type 13 (SubI…
only21mil Nov 23, 2026
6cfc3bf
fix(shared): reject keybindings with a dangling or extra '+' (#41231)
juliusmarminge Nov 23, 2026
12f19b8
fix(github): a remote host URL rejects no longer breaks GitHub resolu…
juliusmarminge Nov 23, 2026
21e7fc1
feat(scripts): a server metrics run catches CPU, memory and first-req…
juliusmarminge Nov 23, 2026
3c84f4b
fix(ssh): accept Node versions with build metadata (#41171)
Pulsar-Programmer Nov 23, 2026
ad621cc
fix(server): merge-back refuses an archived or deleted parent (#41229)
juliusmarminge Nov 23, 2026
df93cab
fix(contracts): ForwardCompatibleOptional drops the key for values it…
juliusmarminge Nov 23, 2026
91c6ecc
fix(acp): agent terminals keep 1.25 MiB of output, not 16 MiB (#41243)
juliusmarminge Nov 23, 2026
6114106
feat(cursor): show which step Cursor is in while a turn starts (#41242)
Yash-Singh1 Nov 23, 2026
3e3bb76
fix(server): Claude turns no longer stay in memory for 10 minutes aft…
juliusmarminge Nov 23, 2026
0356d68
fix(server): Claude plan ids live with the turn, not the session (#41…
juliusmarminge Nov 23, 2026
c061593
fix(server): pass explicit null payloads to workflows (#41245)
only21mil Nov 23, 2026
1f13db5
fix(server): accept unquoted HTML favicon attributes (#41239)
only21mil Nov 23, 2026
b1ce608
docs(user): explain how settling differs from archiving a thread (#41…
juliusmarminge Nov 23, 2026
f1c1317
fix(web): spreadsheet text and fills no longer vanish when their cell…
Yash-Singh1 Nov 23, 2026
c5095e7
fix(provider): leave MacPorts-owned agent updates to MacPorts (#25208)
maria-rcks Nov 23, 2026
9c571f3
fix(acp): sessions no longer keep a record of every turn they ran (#4…
juliusmarminge Nov 23, 2026
cbf4ea7
fix(web): shift-scroll and horizontal scrollers no longer navigate hi…
Yash-Singh1 Nov 23, 2026
597c8de
fix(web): hidden preview tabs larger than the window capture whole (#…
jason5545 Nov 23, 2026
5812320
fix(web): quick clicks on different sidebar threads open each one (#4…
juliusmarminge Nov 23, 2026
ba588ef
fix(web): match macOS Option shortcuts to the active keyboard layout …
nateEc Nov 23, 2026
658ba99
Merge upstream/main (ba588ef663) into the fork
radys-s Nov 23, 2026
3d2ef17
fix(server): Auto failover leaves workflow steps to their workflow
radys-s Nov 23, 2026
51a1b29
test(mobile): the sidebar row key test delegates from a linked enviro…
radys-s Nov 23, 2026
eb8806b
docs(progress): fork synced with upstream ba588ef663
radys-s Nov 23, 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
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/VOUCHED.td
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ github:jamesx0416
github:jappyjan
github:jasonLaster
github:JoeEverest
github:jschachter
github:justsomelegs
github:kridaydave
github:lgwacker
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/src/app/DesktopCliShim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ const fakeAppImage = (canMount = true, app = REPORTER) => {
return { root, image, appImage, shim };
};

// Stays up after a signal until the test lets it finish, like a server shutting down.
// Stays up after a signal until the test lets it finish, like a server shutting down. A group
// signal and the launcher's forwarded one can both arrive; a re-run trap would read stdin's EOF.
const SLOW_SERVER = [
"#!/bin/sh",
"trap 'echo stopping >&3; read go; echo \"stopped $go\" >&3; exit 7' TERM HUP",
'trap \'trap "" TERM HUP; echo stopping >&3; read go; echo "stopped $go" >&3; exit 7\' TERM HUP',
"echo ready",
"while :; do sleep 0.05; done",
"",
Expand Down
45 changes: 45 additions & 0 deletions apps/desktop/src/electron/ElectronMenu.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { assert, describe, it } from "@effect/vitest";
import * as HostProcess from "@t3tools/shared/HostProcess";
import type * as Electron from "electron";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import { vi } from "vite-plus/test";

const { menu } = vi.hoisted(() => ({
menu: { template: [] as Electron.MenuItemConstructorOptions[] },
}));

vi.mock("electron", () => ({
Menu: {
buildFromTemplate: (template: Electron.MenuItemConstructorOptions[]) => {
menu.template = template;
return { popup: (options: Electron.PopupOptions) => options.callback?.() };
},
},
}));

import * as ElectronMenu from "./ElectronMenu.ts";

describe("ElectronMenu", () => {
it.effect("shows ampersands in labels instead of reading them as mnemonics", () =>
Effect.gen(function* () {
const electronMenu = yield* ElectronMenu.make;
yield* electronMenu.showContextMenu({
window: { webContents: { getZoomFactor: () => 1 } } as Electron.BrowserWindow,
items: [
{ id: "filter", label: "Filter by R&D" },
{ id: "more", label: "A&B", children: [{ id: "child", label: "C && D" }] },
],
position: Option.none(),
source: Option.none(),
});

assert.deepEqual(
menu.template.map((item) => item.label),
["Filter by R&&D", "A&&B"],
);
const submenu = menu.template[1]!.submenu as Electron.MenuItemConstructorOptions[];
assert.equal(submenu[0]!.label, "C &&&& D");
}).pipe(Effect.provideService(HostProcess.Platform, "win32")),
);
});
3 changes: 2 additions & 1 deletion apps/desktop/src/electron/ElectronMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export const make = Effect.gen(function* () {
}

const itemOption: Electron.MenuItemConstructorOptions = {
label: item.label,
// Electron reads a single & as a mnemonic marker and drops it.
label: item.label.replaceAll("&", "&&"),
enabled: !item.disabled,
...(typeof item.checked === "boolean" ? { type: "checkbox", checked: item.checked } : {}),
};
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/electron/ElectronProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getDesktopScheme(isDevelopment: boolean): string {
return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
}

function getDesktopOrigin(isDevelopment: boolean): string {
export function getDesktopOrigin(isDevelopment: boolean): string {
return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;
}

Expand Down
6 changes: 6 additions & 0 deletions apps/desktop/src/window/DesktopWindow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ function makeFakeBrowserWindow() {
const webContentsListeners = new Map<string, (...args: readonly unknown[]) => void>();
let zoomLevel = 0;
const webContents = {
id: 1,
session: {
webRequest: {
onBeforeSendHeaders: vi.fn(),
},
},
copyImageAt: vi.fn(),
focus: vi.fn(),
isDestroyed: vi.fn(() => false),
Expand Down
22 changes: 21 additions & 1 deletion apps/desktop/src/window/DesktopWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import { msg } from "gt-i18n";
import { type DesktopSnapShotEvent, DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts";

import * as DesktopAssets from "../app/DesktopAssets.ts";
import * as DesktopClerk from "../app/DesktopClerk.ts";
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
import * as DesktopPrimaryPaste from "../app/DesktopPrimaryPaste.ts";
import { makeComponentLogger } from "../app/DesktopObservability.ts";
import * as DesktopState from "../app/DesktopState.ts";
import * as ElectronMenu from "../electron/ElectronMenu.ts";
import { getDesktopUrl } from "../electron/ElectronProtocol.ts";
import { getDesktopOrigin, getDesktopUrl } from "../electron/ElectronProtocol.ts";
import * as ElectronShell from "../electron/ElectronShell.ts";
import * as ElectronTheme from "../electron/ElectronTheme.ts";
import * as ElectronWindow from "../electron/ElectronWindow.ts";
Expand All @@ -44,6 +45,7 @@ import { m } from "../i18n/messages.ts";
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
import { makeQuitShortcutHandler } from "./QuitHold.ts";
import { copyContextMenuImage } from "./ContextMenuImage.ts";
import { installMainWindowRemoteRequestHeaderPolicy } from "./RemoteRequestHeaders.ts";

const TITLEBAR_HEIGHT = 40;

Expand Down Expand Up @@ -408,6 +410,7 @@ export const make = Effect.gen(function* () {
Effect.suspend(() => pendingMainReveals.get(window) ?? electronWindow.reveal(window)),
);
let flushMainWindowBounds: Effect.Effect<void> = Effect.void;
let remoteRequestHeaderOwner: Electron.BrowserWindow | null = null;

const dismissConnectingSplash = Effect.gen(function* () {
const splash = yield* Ref.getAndSet(splashWindowRef, Option.none());
Expand Down Expand Up @@ -1036,6 +1039,19 @@ export const make = Effect.gen(function* () {

// Desktop IPC only answers the main window, so register it before its renderer can call in.
yield* electronWindow.setMain(window);
remoteRequestHeaderOwner = window;
const detachRemoteRequestHeaders = installMainWindowRemoteRequestHeaderPolicy(
window.webContents.session,
{
desktopOrigin: getDesktopOrigin(environment.isDevelopment),
mainWebContentsId: window.webContents.id,
clerkFrontendApiHostname: DesktopClerk.desktopClerkFrontendApiHostname,
devServerOrigin: Option.getOrUndefined(
Option.map(environment.devServerUrl, (url) => url.origin),
),
isDevelopment: environment.isDevelopment,
},
);
loadApplication();
if (environment.isDevelopment) {
window.webContents.openDevTools({ mode: "detach" });
Expand All @@ -1045,6 +1061,10 @@ export const make = Effect.gen(function* () {
if (!backendHasStarted) mainClosedDuringStartup = true;
clearDevelopmentLoadRetry();
clearBoundsPersist();
if (remoteRequestHeaderOwner === window) {
remoteRequestHeaderOwner = null;
detachRemoteRequestHeaders();
}
void runPromise(electronWindow.clearMain(Option.some(window)));
});

Expand Down
186 changes: 186 additions & 0 deletions apps/desktop/src/window/RemoteRequestHeaders.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import { assert, describe, it } from "@effect/vitest";

import {
stripDesktopOriginHeaders,
type MainWindowRequestHeaderPolicy,
} from "./RemoteRequestHeaders.ts";

const packagedPolicy: MainWindowRequestHeaderPolicy = {
desktopOrigin: "t3code://app",
mainWebContentsId: 42,
clerkFrontendApiHostname: "clerk.t3.codes",
isDevelopment: false,
};

const devPolicy: MainWindowRequestHeaderPolicy = {
desktopOrigin: "t3code-dev://app",
mainWebContentsId: 42,
clerkFrontendApiHostname: "clerk.t3.codes",
devServerOrigin: "http://devbox.internal:5733",
isDevelopment: true,
};

describe("RemoteRequestHeaders", () => {
it.each([
"https://remote.example.com/.well-known/t3/environment",
"http://127.0.0.1:8080/api/auth/bootstrap",
"ws://127.0.0.1:8080/ws?ticket=abc",
"wss://remote.example.com/ws?ticket=abc",
])("strips Origin and Sec-Fetch-* on outbound main-window %s requests", (url) => {
const headers = stripDesktopOriginHeaders(packagedPolicy, {
url,
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
Origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"sec-fetch-user": "?1",
Authorization: "Bearer secret",
DPoP: "proof-jwt",
},
});

assert.deepEqual(headers, {
Authorization: "Bearer secret",
DPoP: "proof-jwt",
});
});

it("strips lowercase origin headers and allows null frames (WebSocket upgrades and workers)", () => {
const headers = stripDesktopOriginHeaders(packagedPolicy, {
url: "wss://remote.example.com/ws",
webContentsId: 42,
frame: null,
requestHeaders: {
origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
Upgrade: "websocket",
},
});

assert.deepEqual(headers, {
Upgrade: "websocket",
});
});

it("preserves headers for Clerk frontend API requests", () => {
for (const url of ["https://clerk.t3.codes/v1/client", "https://CLERK.T3.CODES./v1/client"]) {
const headers = stripDesktopOriginHeaders(packagedPolicy, {
url,
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
Origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
},
});
assert.isUndefined(headers);
}
});

it("preserves headers for dev loopback and exact devServerOrigin, while stripping other ports and remote hosts", () => {
for (const url of [
"http://localhost:3773/api/health",
"http://app.localhost:3773/api/health",
"http://127.0.0.1:3773/api/health",
"http://[::1]:3773/api/health",
"ws://127.0.0.1:3773/ws",
"http://devbox.internal:5733/api/health",
"ws://devbox.internal:5733/ws",
]) {
assert.isUndefined(
stripDesktopOriginHeaders(devPolicy, {
url,
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
Origin: "t3code-dev://app",
"Sec-Fetch-Site": "cross-site",
},
}),
);
}

for (const url of [
"http://devbox.internal:8080/api/auth/bootstrap",
"https://remote.example.com/api/auth/bootstrap",
]) {
assert.deepEqual(
stripDesktopOriginHeaders(devPolicy, {
url,
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
Origin: "t3code-dev://app",
"Sec-Fetch-Site": "cross-site",
"Content-Type": "application/json",
},
}),
{ "Content-Type": "application/json" },
);
}
});

it("never touches sandboxed iframes (Origin: null), subframes, or other webContents", () => {
assert.isUndefined(
stripDesktopOriginHeaders(packagedPolicy, {
url: "https://remote.example.com/api/test",
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
Origin: "null",
"Sec-Fetch-Site": "cross-site",
},
}),
);

assert.isUndefined(
stripDesktopOriginHeaders(packagedPolicy, {
url: "https://remote.example.com/api/test",
webContentsId: 42,
frame: { parent: {} },
requestHeaders: {
Origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
},
}),
);

assert.isUndefined(
stripDesktopOriginHeaders(packagedPolicy, {
url: "https://remote.example.com/api/test",
webContentsId: 99,
frame: { parent: null },
requestHeaders: {
Origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
},
}),
);

assert.isUndefined(
stripDesktopOriginHeaders(packagedPolicy, {
url: "https://remote.example.com/api/test",
webContentsId: undefined,
frame: null,
requestHeaders: {
Origin: "t3code://app",
"Sec-Fetch-Site": "cross-site",
},
}),
);

assert.isUndefined(
stripDesktopOriginHeaders(packagedPolicy, {
url: "https://remote.example.com/api/test",
webContentsId: 42,
frame: { parent: null },
requestHeaders: {
"Sec-Fetch-Site": "cross-site",
},
}),
);
});
});
Loading
Loading