Skip to content

Commit 58a4224

Browse files
Merge branch 'main' into t3code/forward-compatible-array-holes
2 parents 188a136 + 8ddf200 commit 58a4224

211 files changed

Lines changed: 15944 additions & 6005 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.coderabbit.config.ts‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
1-
import { defineConfig } from "@coderabbitai/config";
1+
import { defineConfig, type CodeRabbitContext } from "@coderabbitai/config";
22

3-
export default defineConfig({
3+
const approvability = `Fail when a maintainer should read this pull request before CodeRabbit approves it, and name the rule and file. Fail if it:
4+
5+
- Changes a product default: a setting's default value, or what users get without opting in. Making a feature do what it already promises is a bug fix, not a default change.
6+
- Adds or broadens a directive that disables or suppresses a lint, type-checker, LSP, or other static-analysis diagnostic, including file-level, line-level, and configuration-level overrides.
7+
- Adds a subsystem or user workflow, or is a large refactor across apps or packages.
8+
- Changes packages/contracts or persisted data in a way that existing clients or stored data might not accept.
9+
- Changes authentication, pairing, credentials, secrets, or remote connection trust.
10+
- Adds or changes an external side effect, such as acting on GitHub, publishing a release, or calling a webhook.
11+
- Adds, upgrades, or patches a dependency.
12+
- Changes CI or release configuration, agent or contributor instructions, or any review tool's configuration, including .github/, AGENTS.md, CONTRIBUTING.md, .agents/, and .coderabbit.config.ts.
13+
14+
Otherwise pass. A focused bug fix, copy or layout fix, revert, or docs-only or test-only change passes unless a rule above applies. If you cannot decide, fail rather than report inconclusive. When failing, say that the pull request needs a maintainer's review.
15+
`;
16+
17+
// Org members and collaborators merge their own pull requests. On anyone else's, CodeRabbit
18+
// requests changes until its comments are resolved and its checks pass, then approves.
19+
const UNGATED_AUTHORS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
20+
const isGated = ({ pr }: CodeRabbitContext) => !UNGATED_AUTHORS.has(pr?.authorAssociation ?? "");
21+
22+
export default defineConfig((ctx) => ({
423
reviews: {
524
high_level_summary: false,
625
review_status: false,
26+
request_changes_workflow: isGated(ctx),
27+
allow_author_approval: !isGated(ctx),
728
auto_review: {
829
enabled: true,
930
},
1031
pre_merge_checks: {
1132
docstrings: { mode: "off" },
33+
override_requested_reviewers_only: isGated(ctx),
34+
custom_checks: [
35+
{
36+
name: "Approvability",
37+
mode: isGated(ctx) ? "error" : "off",
38+
instructions: approvability,
39+
},
40+
],
1241
},
1342
path_filters: [
1443
// Vendored read-only reference checkouts of upstream Effect and Alchemy
@@ -34,4 +63,4 @@ export default defineConfig({
3463
],
3564
},
3665
},
37-
});
66+
}));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<component type="desktop-application">
3+
<id>com.t3tools.t3code</id>
4+
<metadata_license>CC0-1.0</metadata_license>
5+
<project_license>MIT</project_license>
6+
<name>T3 Code</name>
7+
<summary>Desktop GUI for coding agents</summary>
8+
<developer id="com.t3tools">
9+
<name>T3 Tools Inc.</name>
10+
</developer>
11+
<description>
12+
<p>
13+
T3 Code is an open-source desktop app for coding agents. Work with your
14+
existing agent subscriptions, review code changes, and run commands in
15+
your projects.
16+
</p>
17+
<p>
18+
Connect from desktop, web, or mobile to continue working remotely.
19+
</p>
20+
</description>
21+
<launchable type="desktop-id">t3code.desktop</launchable>
22+
<icon type="stock">t3code</icon>
23+
<provides>
24+
<binary>t3code</binary>
25+
</provides>
26+
<categories>
27+
<category>Development</category>
28+
</categories>
29+
<url type="homepage">https://t3.codes</url>
30+
<url type="bugtracker">https://github.com/pingdotgg/t3code/issues</url>
31+
<url type="vcs-browser">https://github.com/pingdotgg/t3code</url>
32+
</component>

‎apps/desktop/src/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,16 +979,20 @@ describe("DesktopBackendConfiguration", () => {
979979

980980
const previousWslEnv = process.env.WSLENV;
981981
const previousDisabled = process.env.OTEL_SDK_DISABLED;
982+
const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED;
982983
try {
983984
delete process.env.WSLENV;
984985
process.env.OTEL_SDK_DISABLED = "true";
986+
process.env.T3CODE_TELEMETRY_ENABLED = "false";
985987

986988
yield* Effect.gen(function* () {
987989
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
988990
const config = yield* configuration.resolveWsl({ port: 5050, distro: null });
989991

990992
assert.equal(config.env.OTEL_SDK_DISABLED, "true");
991993
assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED");
994+
assert.equal(config.env.T3CODE_TELEMETRY_ENABLED, "false");
995+
assert.include((config.env.WSLENV ?? "").split(":"), "T3CODE_TELEMETRY_ENABLED");
992996
}).pipe(
993997
Effect.provide(
994998
DesktopBackendConfiguration.layer.pipe(
@@ -1009,6 +1013,7 @@ describe("DesktopBackendConfiguration", () => {
10091013
} finally {
10101014
restoreEnv("WSLENV", previousWslEnv);
10111015
restoreEnv("OTEL_SDK_DISABLED", previousDisabled);
1016+
restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry);
10121017
}
10131018
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
10141019
);

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [
101101
const WSL_FORWARDED_ENV_NAMES = [
102102
"OPENAI_API_KEY",
103103
"ANTHROPIC_API_KEY",
104+
"T3CODE_TELEMETRY_ENABLED",
104105
// Otherwise the WSL server keeps exporting to endpoints from the bootstrap.
105106
"T3CODE_OTEL_SDK_DISABLED",
106107
"OTEL_SDK_DISABLED",

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const SET_WSL_BACKEND_ENABLED_CHANNEL = "desktop:set-wsl-backend-enabled"
6868
export const SET_WSL_DISTRO_CHANNEL = "desktop:set-wsl-distro";
6969
export const SET_WSL_ONLY_CHANNEL = "desktop:set-wsl-only";
7070
export const SSH_PASSWORD_PROMPT_CANCELLED_RESULT = "ssh-password-prompt-cancelled";
71+
export const PREVIEW_SET_FORWARDED_SHORTCUTS_CHANNEL = "desktop:preview-set-forwarded-shortcuts";
7172
export const PREVIEW_CREATE_TAB_CHANNEL = "desktop:preview-create-tab";
7273
export const PREVIEW_CLOSE_TAB_CHANNEL = "desktop:preview-close-tab";
7374
export const PREVIEW_REGISTER_WEBVIEW_CHANNEL = "desktop:preview-register-webview";

‎apps/desktop/src/ipc/methods/preview.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
PreviewAnnotationSubmissionResultSchema,
2121
DEFAULT_BROWSER_PROFILE_ID,
2222
INCOGNITO_BROWSER_PROFILE_ID,
23+
PreviewForwardedShortcut,
24+
MAX_KEYBINDINGS_COUNT,
2325
} from "@t3tools/contracts";
2426
import * as Effect from "effect/Effect";
2527
import * as Schema from "effect/Schema";
@@ -53,6 +55,16 @@ export const installPreviewEventForwarding = Effect.fn(
5355
);
5456
});
5557

58+
export const setForwardedShortcuts = DesktopIpc.makeIpcMethod({
59+
channel: IpcChannels.PREVIEW_SET_FORWARDED_SHORTCUTS_CHANNEL,
60+
payload: Schema.Array(PreviewForwardedShortcut).check(Schema.isMaxLength(MAX_KEYBINDINGS_COUNT)),
61+
result: Schema.Void,
62+
handler: Effect.fn("desktop.ipc.preview.setForwardedShortcuts")(function* (shortcuts) {
63+
const manager = yield* PreviewManager.PreviewManager;
64+
yield* manager.setForwardedShortcuts(shortcuts);
65+
}),
66+
});
67+
5668
export const createTab = DesktopIpc.makeIpcMethod({
5769
channel: IpcChannels.PREVIEW_CREATE_TAB_CHANNEL,
5870
payload: DesktopPreviewCreateTabInputSchema,
@@ -406,6 +418,7 @@ export const saveRecording = DesktopIpc.makeIpcMethod({
406418
});
407419

408420
export const methods = [
421+
setForwardedShortcuts,
409422
createTab,
410423
closeTab,
411424
registerWebview,

‎apps/desktop/src/preload.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ contextBridge.exposeInMainWorld("desktopBridge", {
299299
},
300300
},
301301
preview: {
302+
setForwardedShortcuts: (shortcuts) =>
303+
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_FORWARDED_SHORTCUTS_CHANNEL, shortcuts),
302304
createTab: (tabId, defaults) =>
303305
ipcRenderer.invoke(IpcChannels.PREVIEW_CREATE_TAB_CHANNEL, {
304306
tabId,

‎apps/desktop/src/preview/Manager.test.ts‎

Lines changed: 124 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
DesktopPreviewRecordingInputEvent,
77
} from "@t3tools/contracts";
88
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
9+
import { parseKeybindingShortcut } from "@t3tools/shared/keybindings";
910
import * as Cause from "effect/Cause";
1011
import * as Deferred from "effect/Deferred";
1112
import * as Effect from "effect/Effect";
@@ -269,32 +270,34 @@ const layerFileSystem = FileSystem.layerNoop({
269270
}),
270271
});
271272

272-
const layer = PreviewManager.layer.pipe(
273-
Layer.provideMerge(
274-
Layer.succeed(DesktopRendererHistory.DesktopRendererHistory, {
275-
register: () => Effect.void,
276-
recordMetrics: () => Effect.void,
277-
shutdown: Effect.void,
278-
}),
279-
),
280-
Layer.provideMerge(DesktopBrowserHost.layer),
281-
Layer.provideMerge(layerBrowserSession),
282-
Layer.provideMerge(layerEnvironment),
283-
Layer.provideMerge(layerFileSystem),
284-
Layer.provideMerge(Path.layer),
285-
Layer.provideMerge(NodeCrypto.layer),
286-
Layer.provideMerge(Layer.succeed(HostProcessPlatform, "darwin")),
287-
);
273+
const managerLayer = (platform: NodeJS.Platform = "darwin") =>
274+
PreviewManager.layer.pipe(
275+
Layer.provideMerge(
276+
Layer.succeed(DesktopRendererHistory.DesktopRendererHistory, {
277+
register: () => Effect.void,
278+
recordMetrics: () => Effect.void,
279+
shutdown: Effect.void,
280+
}),
281+
),
282+
Layer.provideMerge(DesktopBrowserHost.layer),
283+
Layer.provideMerge(layerBrowserSession),
284+
Layer.provideMerge(layerEnvironment),
285+
Layer.provideMerge(layerFileSystem),
286+
Layer.provideMerge(Path.layer),
287+
Layer.provideMerge(NodeCrypto.layer),
288+
Layer.provideMerge(Layer.succeed(HostProcessPlatform, platform)),
289+
);
288290

289291
const withManager = <A>(
290292
use: (
291293
manager: PreviewManager.PreviewManager["Service"],
292294
) => Effect.Effect<A, PreviewManager.PreviewManagerError, Scope.Scope>,
295+
platform: NodeJS.Platform = "darwin",
293296
) =>
294297
Effect.gen(function* () {
295298
const manager = yield* PreviewManager.PreviewManager;
296299
return yield* use(manager);
297-
}).pipe(Effect.provide(layer), Effect.scoped);
300+
}).pipe(Effect.provide(managerLayer(platform)), Effect.scoped);
298301

299302
interface TestCapturedPreviewImage {
300303
readonly toJPEG: () => Buffer;
@@ -574,7 +577,7 @@ describe("PreviewManager", () => {
574577
Effect.gen(function* () {
575578
const preview = makeFaviconWebContents();
576579
const sendInputEvent = vi.fn();
577-
const hostWebContents = { sendInputEvent };
580+
const hostWebContents = { sendInputEvent, isDestroyed: () => false };
578581
Object.assign(preview.webContents, { hostWebContents });
579582
fromId.mockReturnValue(preview.webContents);
580583
getFocusedWebContents.mockReturnValue(preview.webContents as never);
@@ -628,6 +631,108 @@ describe("PreviewManager", () => {
628631
),
629632
);
630633

634+
effectIt.effect.each([
635+
["mod+shift+t", "view.reopenClosed"],
636+
["ctrl+alt+u", "sidebar.toggle"],
637+
] as const)(
638+
"forwards only the configured command from the focused guest: %s",
639+
([chord, command]) =>
640+
withManager((manager) =>
641+
Effect.gen(function* () {
642+
const preview = makeFaviconWebContents();
643+
const send = vi.fn();
644+
Object.assign(preview.webContents, {
645+
hostWebContents: { isDestroyed: () => false, send },
646+
});
647+
fromId.mockReturnValue(preview.webContents);
648+
getFocusedWebContents.mockReturnValue(preview.webContents as never);
649+
yield* manager.createTab("tab_reopen");
650+
yield* manager.registerWebview("tab_reopen", 42);
651+
const shortcut = parseKeybindingShortcut(chord)!;
652+
yield* manager.setForwardedShortcuts([{ command, shortcut }]);
653+
const beforeInput = preview.listeners.get("before-input-event")!;
654+
const input = {
655+
type: "keyDown",
656+
key: shortcut.key.toUpperCase(),
657+
meta: shortcut.metaKey || shortcut.modKey,
658+
control: shortcut.ctrlKey,
659+
shift: shortcut.shiftKey,
660+
alt: shortcut.altKey,
661+
};
662+
const preventDefault = vi.fn();
663+
beforeInput({ preventDefault } as never, input as never);
664+
expect(preventDefault).toHaveBeenCalledOnce();
665+
expect(send).toHaveBeenCalledExactlyOnceWith("desktop:menu-action", command);
666+
for (const overrides of [
667+
{ isAutoRepeat: true },
668+
{ type: "keyUp" },
669+
{ shift: !input.shift },
670+
{ key: "x" },
671+
]) {
672+
preventDefault.mockClear();
673+
beforeInput({ preventDefault } as never, { ...input, ...overrides } as never);
674+
expect(preventDefault).toHaveBeenCalledTimes("isAutoRepeat" in overrides ? 1 : 0);
675+
expect(send).toHaveBeenCalledOnce();
676+
}
677+
getFocusedWebContents.mockReturnValue(null);
678+
preventDefault.mockClear();
679+
beforeInput({ preventDefault } as never, input as never);
680+
expect(preventDefault).not.toHaveBeenCalled();
681+
expect(send).toHaveBeenCalledOnce();
682+
getFocusedWebContents.mockReturnValue(preview.webContents as never);
683+
yield* manager.setForwardedShortcuts([]);
684+
beforeInput({ preventDefault } as never, input as never);
685+
expect(preventDefault).not.toHaveBeenCalled();
686+
expect(send).toHaveBeenCalledOnce();
687+
}),
688+
),
689+
);
690+
691+
effectIt.effect.each([
692+
["linux", "ctrl+alt+[", "[", "BracketLeft", false],
693+
["win32", "ctrl+alt+8", "[", "Digit8", false],
694+
["win32", "ctrl+alt+k", "K", "KeyK", false],
695+
["linux", "ctrl+alt+`", "Dead", "Backquote", false],
696+
["darwin", "ctrl+alt+[", "[", "BracketLeft", true],
697+
["linux", "ctrl+alt+f7", "F7", "F7", true],
698+
] as const)(
699+
"handles ambiguous preview chords on %s: %s",
700+
([platform, chord, key, code, expected]) =>
701+
withManager(
702+
(manager) =>
703+
Effect.gen(function* () {
704+
const preview = makeFaviconWebContents();
705+
const send = vi.fn();
706+
Object.assign(preview.webContents, {
707+
hostWebContents: { isDestroyed: () => false, send },
708+
});
709+
fromId.mockReturnValue(preview.webContents);
710+
getFocusedWebContents.mockReturnValue(preview.webContents as never);
711+
yield* manager.createTab("tab_alt_graph");
712+
yield* manager.registerWebview("tab_alt_graph", 42);
713+
yield* manager.setForwardedShortcuts([
714+
{ command: "view.reopenClosed", shortcut: parseKeybindingShortcut(chord)! },
715+
]);
716+
const preventDefault = vi.fn();
717+
preview.listeners.get("before-input-event")!(
718+
{ preventDefault } as never,
719+
{
720+
type: "keyDown",
721+
key,
722+
code,
723+
meta: false,
724+
control: true,
725+
shift: false,
726+
alt: true,
727+
} as never,
728+
);
729+
expect(preventDefault).toHaveBeenCalledTimes(expected ? 1 : 0);
730+
expect(send).toHaveBeenCalledTimes(expected ? 1 : 0);
731+
}),
732+
platform,
733+
),
734+
);
735+
631736
effectIt.effect("preserves focused browser editing in tabs and sign-in popups", () =>
632737
withManager((manager) =>
633738
Effect.gen(function* () {
@@ -2716,7 +2821,7 @@ describe("PreviewManager", () => {
27162821
expect(yield* nextType).toBe("attached");
27172822
yield* manager.closeTab("tab_1");
27182823
expect(yield* nextType).toBe("detached");
2719-
}).pipe(Effect.provide(layer), Effect.scoped),
2824+
}).pipe(Effect.provide(managerLayer()), Effect.scoped),
27202825
);
27212826

27222827
effectIt.effect("stops capture retries when the tab swaps during the retry delay", () =>

0 commit comments

Comments
 (0)