Skip to content

Commit 7f6ff53

Browse files
juliusmarmingecodex
andcommitted
Merge origin/main into t3code/undeletable-thread-debug
Co-authored-by: codex <[email protected]>
2 parents 0f15b17 + 1bf048e commit 7f6ff53

71 files changed

Lines changed: 4359 additions & 3719 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.

‎apps/desktop/src/backendReadiness.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface WaitForHttpReadyOptions {
88
readonly isReady?: (response: Response) => boolean;
99
}
1010

11-
const DEFAULT_TIMEOUT_MS = 10_000;
11+
const DEFAULT_TIMEOUT_MS = 30_000;
1212
const DEFAULT_INTERVAL_MS = 100;
1313
const DEFAULT_REQUEST_TIMEOUT_MS = 1_000;
1414

‎apps/desktop/src/main.ts‎

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Path from "node:path";
77
import {
88
app,
99
BrowserWindow,
10+
type BrowserWindowConstructorOptions,
1011
clipboard,
1112
dialog,
1213
ipcMain,
@@ -101,7 +102,7 @@ const DESKTOP_SCHEME = "t3";
101102
const ROOT_DIR = Path.resolve(__dirname, "../../..");
102103
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
103104
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
104-
const APP_USER_MODEL_ID = "com.t3tools.t3code";
105+
const APP_USER_MODEL_ID = isDevelopment ? "com.t3tools.t3code.dev" : "com.t3tools.t3code";
105106
const LINUX_DESKTOP_ENTRY_NAME = isDevelopment ? "t3code-dev.desktop" : "t3code.desktop";
106107
const LINUX_WM_CLASS = isDevelopment ? "t3code-dev" : "t3code";
107108
const USER_DATA_DIR_NAME = isDevelopment ? "t3code-dev" : "t3code";
@@ -119,6 +120,15 @@ const DESKTOP_UPDATE_CHANNEL = "latest";
119120
const DESKTOP_UPDATE_ALLOW_PRERELEASE = false;
120121
const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
121122
const DESKTOP_REQUIRED_PORT_PROBE_HOSTS = ["0.0.0.0", "::"] as const;
123+
const TITLEBAR_HEIGHT = 40;
124+
const TITLEBAR_COLOR = "#01000000"; // #00000000 does not work correctly on Linux
125+
const TITLEBAR_LIGHT_SYMBOL_COLOR = "#1f2937";
126+
const TITLEBAR_DARK_SYMBOL_COLOR = "#f8fafc";
127+
128+
type WindowTitleBarOptions = Pick<
129+
BrowserWindowConstructorOptions,
130+
"titleBarOverlay" | "titleBarStyle" | "trafficLightPosition"
131+
>;
122132

123133
type DesktopUpdateErrorContext = DesktopUpdateState["errorContext"];
124134
type LinuxDesktopNamedApp = Electron.App & {
@@ -1756,6 +1766,46 @@ function getInitialWindowBackgroundColor(): string {
17561766
return nativeTheme.shouldUseDarkColors ? "#0a0a0a" : "#ffffff";
17571767
}
17581768

1769+
function getWindowTitleBarOptions(): WindowTitleBarOptions {
1770+
if (process.platform === "darwin") {
1771+
return {
1772+
titleBarStyle: "hiddenInset",
1773+
trafficLightPosition: { x: 16, y: 18 },
1774+
};
1775+
}
1776+
1777+
return {
1778+
titleBarStyle: "hidden",
1779+
titleBarOverlay: {
1780+
color: TITLEBAR_COLOR,
1781+
height: TITLEBAR_HEIGHT,
1782+
symbolColor: nativeTheme.shouldUseDarkColors
1783+
? TITLEBAR_DARK_SYMBOL_COLOR
1784+
: TITLEBAR_LIGHT_SYMBOL_COLOR,
1785+
},
1786+
};
1787+
}
1788+
1789+
function syncWindowAppearance(window: BrowserWindow): void {
1790+
if (window.isDestroyed()) {
1791+
return;
1792+
}
1793+
1794+
window.setBackgroundColor(getInitialWindowBackgroundColor());
1795+
const { titleBarOverlay } = getWindowTitleBarOptions();
1796+
if (typeof titleBarOverlay === "object") {
1797+
window.setTitleBarOverlay(titleBarOverlay);
1798+
}
1799+
}
1800+
1801+
function syncAllWindowAppearance(): void {
1802+
for (const window of BrowserWindow.getAllWindows()) {
1803+
syncWindowAppearance(window);
1804+
}
1805+
}
1806+
1807+
nativeTheme.on("updated", syncAllWindowAppearance);
1808+
17591809
function createWindow(): BrowserWindow {
17601810
const window = new BrowserWindow({
17611811
width: 1100,
@@ -1767,8 +1817,7 @@ function createWindow(): BrowserWindow {
17671817
backgroundColor: getInitialWindowBackgroundColor(),
17681818
...getIconOption(),
17691819
title: APP_DISPLAY_NAME,
1770-
titleBarStyle: "hiddenInset",
1771-
trafficLightPosition: { x: 16, y: 18 },
1820+
...getWindowTitleBarOptions(),
17721821
webPreferences: {
17731822
preload: Path.join(__dirname, "preload.js"),
17741823
contextIsolation: true,

‎apps/server/src/checkpointing/Layers/CheckpointDiffQuery.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ describe("CheckpointDiffQueryLive", () => {
8282
Layer.succeed(ProjectionSnapshotQuery, {
8383
getSnapshot: () =>
8484
Effect.die("CheckpointDiffQuery should not request the full orchestration snapshot"),
85+
getShellSnapshot: () =>
86+
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
8587
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
8688
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
89+
getProjectShellById: () => Effect.succeed(Option.none()),
8790
getFirstActiveThreadIdByProjectId: () => Effect.succeed(Option.none()),
8891
getThreadCheckpointContext: () => Effect.succeed(Option.some(threadCheckpointContext)),
92+
getThreadShellById: () => Effect.succeed(Option.none()),
93+
getThreadDetailById: () => Effect.succeed(Option.none()),
8994
}),
9095
),
9196
);
@@ -136,10 +141,15 @@ describe("CheckpointDiffQueryLive", () => {
136141
Layer.succeed(ProjectionSnapshotQuery, {
137142
getSnapshot: () =>
138143
Effect.die("CheckpointDiffQuery should not request the full orchestration snapshot"),
144+
getShellSnapshot: () =>
145+
Effect.die("CheckpointDiffQuery should not request the orchestration shell snapshot"),
139146
getCounts: () => Effect.succeed({ projectCount: 0, threadCount: 0 }),
140147
getActiveProjectByWorkspaceRoot: () => Effect.succeed(Option.none()),
148+
getProjectShellById: () => Effect.succeed(Option.none()),
141149
getFirstActiveThreadIdByProjectId: () => Effect.succeed(Option.none()),
142150
getThreadCheckpointContext: () => Effect.succeed(Option.none()),
151+
getThreadShellById: () => Effect.succeed(Option.none()),
152+
getThreadDetailById: () => Effect.succeed(Option.none()),
143153
}),
144154
),
145155
);

‎apps/server/src/git/Layers/GitCore.test.ts‎

Lines changed: 82 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ it.layer(TestLayer)("git integration", (it) => {
826826
}),
827827
);
828828

829-
it.effect("shares upstream refreshes across worktrees that use the same git common dir", () =>
829+
it.effect("coalesces upstream refreshes across sibling worktrees on the same remote", () =>
830830
Effect.gen(function* () {
831831
const ok = (stdout = "") =>
832832
Effect.succeed({
@@ -845,7 +845,9 @@ it.layer(TestLayer)("git integration", (it) => {
845845
input.args[2] === "--symbolic-full-name" &&
846846
input.args[3] === "@{upstream}"
847847
) {
848-
return ok("origin/main\n");
848+
return ok(
849+
input.cwd === "/repo/worktrees/pr-123" ? "origin/feature/pr-123\n" : "origin/main\n",
850+
);
849851
}
850852
if (input.args[0] === "remote") {
851853
return ok("origin\n");
@@ -856,10 +858,22 @@ it.layer(TestLayer)("git integration", (it) => {
856858
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
857859
fetchCount += 1;
858860
expect(input.cwd).toBe("/repo");
861+
expect(input.args).toEqual([
862+
"--git-dir",
863+
"/repo/.git",
864+
"fetch",
865+
"--quiet",
866+
"--no-tags",
867+
"origin",
868+
]);
859869
return ok();
860870
}
861871
if (input.operation === "GitCore.statusDetails.status") {
862-
return ok("# branch.head main\n# branch.upstream origin/main\n# branch.ab +0 -0\n");
872+
return ok(
873+
input.cwd === "/repo/worktrees/pr-123"
874+
? "# branch.head feature/pr-123\n# branch.upstream origin/feature/pr-123\n# branch.ab +0 -0\n"
875+
: "# branch.head main\n# branch.upstream origin/main\n# branch.ab +0 -0\n",
876+
);
863877
}
864878
if (
865879
input.operation === "GitCore.statusDetails.unstagedNumstat" ||
@@ -886,70 +900,80 @@ it.layer(TestLayer)("git integration", (it) => {
886900
}),
887901
);
888902

889-
it.effect("briefly backs off failed upstream refreshes across sibling worktrees", () =>
890-
Effect.gen(function* () {
891-
const ok = (stdout = "") =>
892-
Effect.succeed({
893-
code: 0,
894-
stdout,
895-
stderr: "",
896-
stdoutTruncated: false,
897-
stderrTruncated: false,
898-
});
903+
it.effect(
904+
"briefly backs off failed upstream refreshes across sibling worktrees on one remote",
905+
() =>
906+
Effect.gen(function* () {
907+
const ok = (stdout = "") =>
908+
Effect.succeed({
909+
code: 0,
910+
stdout,
911+
stderr: "",
912+
stdoutTruncated: false,
913+
stderrTruncated: false,
914+
});
899915

900-
let fetchCount = 0;
901-
const core = yield* makeIsolatedGitCore((input) => {
902-
if (
903-
input.args[0] === "rev-parse" &&
904-
input.args[1] === "--abbrev-ref" &&
905-
input.args[2] === "--symbolic-full-name" &&
906-
input.args[3] === "@{upstream}"
907-
) {
908-
return ok("origin/main\n");
909-
}
910-
if (input.args[0] === "remote") {
911-
return ok("origin\n");
912-
}
913-
if (input.args[0] === "rev-parse" && input.args[1] === "--git-common-dir") {
914-
return ok("/repo/.git\n");
915-
}
916-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
917-
fetchCount += 1;
916+
let fetchCount = 0;
917+
const core = yield* makeIsolatedGitCore((input) => {
918+
if (
919+
input.args[0] === "rev-parse" &&
920+
input.args[1] === "--abbrev-ref" &&
921+
input.args[2] === "--symbolic-full-name" &&
922+
input.args[3] === "@{upstream}"
923+
) {
924+
return ok(
925+
input.cwd === "/repo/worktrees/pr-123"
926+
? "origin/feature/pr-123\n"
927+
: "origin/main\n",
928+
);
929+
}
930+
if (input.args[0] === "remote") {
931+
return ok("origin\n");
932+
}
933+
if (input.args[0] === "rev-parse" && input.args[1] === "--git-common-dir") {
934+
return ok("/repo/.git\n");
935+
}
936+
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
937+
fetchCount += 1;
938+
return Effect.fail(
939+
new GitCommandError({
940+
operation: input.operation,
941+
command: `git ${input.args.join(" ")}`,
942+
cwd: input.cwd,
943+
detail: "simulated fetch timeout",
944+
}),
945+
);
946+
}
947+
if (input.operation === "GitCore.statusDetails.status") {
948+
return ok(
949+
input.cwd === "/repo/worktrees/pr-123"
950+
? "# branch.head feature/pr-123\n# branch.upstream origin/feature/pr-123\n# branch.ab +0 -0\n"
951+
: "# branch.head main\n# branch.upstream origin/main\n# branch.ab +0 -0\n",
952+
);
953+
}
954+
if (
955+
input.operation === "GitCore.statusDetails.unstagedNumstat" ||
956+
input.operation === "GitCore.statusDetails.stagedNumstat"
957+
) {
958+
return ok();
959+
}
960+
if (input.operation === "GitCore.statusDetails.defaultRef") {
961+
return ok("refs/remotes/origin/main\n");
962+
}
918963
return Effect.fail(
919964
new GitCommandError({
920965
operation: input.operation,
921966
command: `git ${input.args.join(" ")}`,
922967
cwd: input.cwd,
923-
detail: "simulated fetch timeout",
968+
detail: "Unexpected git command in refresh failure cooldown test.",
924969
}),
925970
);
926-
}
927-
if (input.operation === "GitCore.statusDetails.status") {
928-
return ok("# branch.head main\n# branch.upstream origin/main\n# branch.ab +0 -0\n");
929-
}
930-
if (
931-
input.operation === "GitCore.statusDetails.unstagedNumstat" ||
932-
input.operation === "GitCore.statusDetails.stagedNumstat"
933-
) {
934-
return ok();
935-
}
936-
if (input.operation === "GitCore.statusDetails.defaultRef") {
937-
return ok("refs/remotes/origin/main\n");
938-
}
939-
return Effect.fail(
940-
new GitCommandError({
941-
operation: input.operation,
942-
command: `git ${input.args.join(" ")}`,
943-
cwd: input.cwd,
944-
detail: "Unexpected git command in refresh failure cooldown test.",
945-
}),
946-
);
947-
});
971+
});
948972

949-
yield* core.statusDetails("/repo/worktrees/main");
950-
yield* core.statusDetails("/repo/worktrees/pr-123");
951-
expect(fetchCount).toBe(1);
952-
}),
973+
yield* core.statusDetails("/repo/worktrees/main");
974+
yield* core.statusDetails("/repo/worktrees/pr-123");
975+
expect(fetchCount).toBe(1);
976+
}),
953977
);
954978

955979
it.effect("throws when branch does not exist", () =>
@@ -1047,7 +1071,6 @@ it.layer(TestLayer)("git integration", (it) => {
10471071
"--quiet",
10481072
"--no-tags",
10491073
remoteName,
1050-
`+refs/heads/${featureBranch}:refs/remotes/${remoteName}/${featureBranch}`,
10511074
]);
10521075
}),
10531076
);

‎apps/server/src/git/Layers/GitCore.ts‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ type TraceTailState = {
7878
remainder: string;
7979
};
8080

81-
class StatusUpstreamRefreshCacheKey extends Data.Class<{
81+
class StatusRemoteRefreshCacheKey extends Data.Class<{
8282
gitCommonDir: string;
83-
upstreamRef: string;
8483
remoteName: string;
85-
upstreamBranch: string;
8684
}> {}
8785

8886
interface ExecuteGitOptions {
@@ -919,17 +917,16 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
919917
);
920918
});
921919

922-
const fetchUpstreamRefForStatus = (
920+
const fetchRemoteForStatus = (
923921
gitCommonDir: string,
924-
upstream: { upstreamRef: string; remoteName: string; upstreamBranch: string },
922+
remoteName: string,
925923
): Effect.Effect<void, GitCommandError> => {
926-
const refspec = `+refs/heads/${upstream.upstreamBranch}:refs/remotes/${upstream.upstreamRef}`;
927924
const fetchCwd =
928925
path.basename(gitCommonDir) === ".git" ? path.dirname(gitCommonDir) : gitCommonDir;
929926
return executeGit(
930-
"GitCore.fetchUpstreamRefForStatus",
927+
"GitCore.fetchRemoteForStatus",
931928
fetchCwd,
932-
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", upstream.remoteName, refspec],
929+
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", remoteName],
933930
{
934931
allowNonZeroExit: true,
935932
timeoutMs: Duration.toMillis(STATUS_UPSTREAM_REFRESH_TIMEOUT),
@@ -945,18 +942,14 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
945942
return path.isAbsolute(gitCommonDir) ? gitCommonDir : path.resolve(cwd, gitCommonDir);
946943
});
947944

948-
const refreshStatusUpstreamCacheEntry = Effect.fn("refreshStatusUpstreamCacheEntry")(function* (
949-
cacheKey: StatusUpstreamRefreshCacheKey,
945+
const refreshStatusRemoteCacheEntry = Effect.fn("refreshStatusRemoteCacheEntry")(function* (
946+
cacheKey: StatusRemoteRefreshCacheKey,
950947
) {
951-
yield* fetchUpstreamRefForStatus(cacheKey.gitCommonDir, {
952-
upstreamRef: cacheKey.upstreamRef,
953-
remoteName: cacheKey.remoteName,
954-
upstreamBranch: cacheKey.upstreamBranch,
955-
});
948+
yield* fetchRemoteForStatus(cacheKey.gitCommonDir, cacheKey.remoteName);
956949
return true as const;
957950
});
958951

959-
const statusUpstreamRefreshCache = yield* Cache.makeWith(refreshStatusUpstreamCacheEntry, {
952+
const statusRemoteRefreshCache = yield* Cache.makeWith(refreshStatusRemoteCacheEntry, {
960953
capacity: STATUS_UPSTREAM_REFRESH_CACHE_CAPACITY,
961954
// Keep successful refreshes warm and briefly back off failed refreshes to avoid retry storms.
962955
timeToLive: (exit) =>
@@ -972,12 +965,10 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
972965
if (!upstream) return;
973966
const gitCommonDir = yield* resolveGitCommonDir(cwd);
974967
yield* Cache.get(
975-
statusUpstreamRefreshCache,
976-
new StatusUpstreamRefreshCacheKey({
968+
statusRemoteRefreshCache,
969+
new StatusRemoteRefreshCacheKey({
977970
gitCommonDir,
978-
upstreamRef: upstream.upstreamRef,
979971
remoteName: upstream.remoteName,
980-
upstreamBranch: upstream.upstreamBranch,
981972
}),
982973
);
983974
});

0 commit comments

Comments
 (0)