Skip to content

Commit d7b77d4

Browse files
donjorrsi-pr-agent
authored andcommitted
fix(upstream-fixes): replayed fork hooks follow upstream renames, moves, and permission splits
Squashes: - e3a3952 fix(upstream-fixes): replayed fork hooks follow upstream renames, moves, and permission splits - db7631f fixup! fix(upstream-fixes): replayed fork hooks follow upstream renames, moves, and permission splits Fork-Domain: upstream-fixes Fork-Tier: bugfix Fork-Upstreamable: no
1 parent 7ce794d commit d7b77d4

10 files changed

Lines changed: 77 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const createTab = DesktopIpc.makeIpcMethod({
9292
payload: DesktopPreviewCreateTabInputSchema,
9393
result: Schema.Void,
9494
handler: Effect.fn("desktop.ipc.preview.createTab")(function* (
95-
{ tabId, zoomFactor, colorScheme },
95+
{ tabId, zoomFactor, colorScheme, serverTab }, // fork-hook: multi-window/preview-server-tab
9696
event,
9797
) {
9898
const { windowManager: manager } = yield* previewForSender(event);

‎apps/server/src/persistence/Sqlite.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as Path from "effect/Path";
55
import * as SqlClient from "effect/sql/SqlClient";
66
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
77

8+
import { repairStaleForkMigrationRow, ensureForkSchema } from "./ForkSchema.ts"; // fork-hook: zmux-estate/fork-schema
89
import { runMigrations } from "./Migrations.ts";
910
import { initializeV2Database } from "./initializeV2Database.ts";
1011
import * as ServerConfig from "../config.ts";
@@ -30,7 +31,9 @@ const layerSetup = Layer.effectDiscard(
3031
yield* sql`PRAGMA checkpoint_fullfsync = ON;`;
3132
// PASSIVE checkpoints retain peak WAL size until the last connection closes.
3233
yield* sql.unsafe(`PRAGMA journal_size_limit = ${WAL_SIZE_LIMIT_BYTES};`);
34+
yield* repairStaleForkMigrationRow(); // fork-hook: zmux-estate/fork-schema
3335
yield* runMigrations();
36+
yield* ensureForkSchema(); // fork-hook: zmux-estate/fork-schema
3437
// Collecting stats scans every page, and stale small-table stats cause scans after growth; use indexes by default.
3538
// Connections cache stats; reload after deleting them.
3639
const statTables = yield* sql`SELECT 1 FROM sqlite_schema WHERE name = 'sqlite_stat1'`;

‎apps/server/src/project/RepositoryIdentityResolver.fork.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
3232
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
3333
);
3434

35+
forkSupersedes({
36+
upstream:
37+
"apps/server/src/project/RepositoryIdentityResolver.test.ts > reports a fork's own remote as origin next to the upstream identity",
38+
reason:
39+
"the fork keeps origin as the primary remote, so a fork's origin is the identity and no separate origin is reported",
40+
commit: "d089901e993",
41+
});
42+
it.effect("reports a fork's own remote as the identity next to an upstream remote", () =>
43+
Effect.gen(function* () {
44+
const fileSystem = yield* FileSystem.FileSystem;
45+
const cwd = yield* fileSystem.makeTempDirectoryScoped({
46+
prefix: "t3-repository-identity-fork-test-",
47+
});
48+
49+
yield* git(cwd, ["init"]);
50+
yield* git(cwd, ["remote", "add", "origin", "[email protected]:julius/t3code-fork.git"]);
51+
yield* git(cwd, ["remote", "add", "upstream", "[email protected]:T3Tools/t3code.git"]);
52+
53+
const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
54+
const identity = yield* resolver.resolve(cwd);
55+
56+
expect(identity?.locator.remoteName).toBe("origin");
57+
expect(identity?.canonicalKey).toBe("github.com/julius/t3code-fork");
58+
expect(identity?.displayName).toBe("julius/t3code-fork");
59+
expect(identity?.origin).toBeUndefined();
60+
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
61+
);
62+
3563
forkSupersedes({
3664
upstream:
3765
"apps/server/src/project/RepositoryIdentityResolver.test.ts > refreshes the primary upstream after %s before cache expiry",

‎apps/server/src/provider/ClaudeProvider.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { createModelCapabilities } from "@t3tools/shared/model";
1818
import { resolveSpawnCommand } from "@t3tools/shared/shell";
1919
import {
2020
query as claudeQuery,
21+
type AgentInfo as ClaudeAgentInfo, // fork-hook: custom-agents/claude-agent-info-type
2122
type Options as ClaudeQueryOptions,
2223
type SlashCommand as ClaudeSlashCommand,
2324
type SDKControlGetUsageResponse,
@@ -52,6 +53,10 @@ import {
5253
resolveClaudeModelsForVersion,
5354
resolveClaudeUpdateRequiredModels,
5455
} from "./ClaudeModelCatalog.ts";
56+
import {
57+
claudeInitializationAgentsField, // fork-hook: custom-agents/claude-probe-agents-parse
58+
withClaudeAgentOptions,
59+
} from "./ClaudeAgentOptions.fork.ts"; // fork-hook: custom-agents/claude-agent-options-import
5560

5661
const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
5762
optionDescriptors: [],
@@ -242,6 +247,7 @@ export type ClaudeCapabilitiesProbe = {
242247
readonly apiKeySource: string | undefined;
243248
/** OAuth applies only to firstParty; Bedrock uses external AWS credentials and omits subscription/token fields. */
244249
readonly apiProvider: string | undefined;
250+
readonly agents?: ReadonlyArray<ClaudeAgentInfo>; // fork-hook: custom-agents/claude-probe-agents-field
245251
readonly slashCommands: ReadonlyArray<ServerProviderSlashCommand>;
246252
/** Undefined means get_usage failed; absent windows on success mean no subscription windows, as with API keys. */
247253
readonly usage?: Pick<SDKControlGetUsageResponse, "rate_limits_available" | "rate_limits">;
@@ -387,6 +393,7 @@ const probeClaudeCapabilities = (
387393
tokenSource: account?.tokenSource,
388394
apiKeySource: account?.apiKeySource,
389395
apiProvider: account?.apiProvider,
396+
...claudeInitializationAgentsField(init.agents), // fork-hook: custom-agents/claude-probe-agents-parse
390397
slashCommands: parseClaudeInitializationCommands(init.commands),
391398
...(usage ? { usage, usageCheckedAt } : {}),
392399
} satisfies ClaudeCapabilitiesProbe;
@@ -559,11 +566,11 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
559566
});
560567
}
561568

562-
const models = providerModelsFromSettings(
569+
const baseModels = providerModelsFromSettings(
563570
resolveClaudeModelsForVersion(modelCatalog, parsedVersion),
564571
claudeSettings.customModels,
565572
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
566-
);
573+
); // fork-hook: custom-agents/claude-base-models
567574
const updateRequiredModels = resolveClaudeUpdateRequiredModels(modelCatalog, parsedVersion);
568575
const versionUpgradeMessage = formatClaudeVersionUpgradeMessage(modelCatalog, parsedVersion);
569576

@@ -574,6 +581,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
574581
probeResult && Result.isSuccess(probeResult) ? probeResult.success : undefined;
575582
const probeFailure =
576583
probeResult && Result.isFailure(probeResult) ? probeResult.failure : undefined;
584+
const models = withClaudeAgentOptions(baseModels, capabilities?.agents ?? []); // fork-hook: custom-agents/claude-model-agent-options
577585
const skills = yield* discoverClaudeSkills(claudeSettings, cwd, resolvedEnvironment);
578586
const slashCommands = [COMPACT_SLASH_COMMAND, ...(capabilities?.slashCommands ?? [])];
579587
const dedupedSlashCommands = dedupeSlashCommands(slashCommands);

‎apps/server/src/provider/CodexProvider.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import type {
2828
} from "@t3tools/contracts";
2929
import { PREFERRED_DEFAULT_CODEX_MODELS, ServerSettingsError } from "@t3tools/contracts";
3030

31+
import { stripForeignHarnessIdentityEnv, stripInheritedTmuxEnv } from "@t3tools/shared/env"; // fork-hook: upstream-fixes/codex-provider-env
3132
import {
3233
codexModelFamily,
3334
createModelCapabilities,
@@ -51,6 +52,8 @@ import {
5152
} from "./codexUsageLimits.ts";
5253
import * as HostProcess from "@t3tools/shared/HostProcess";
5354
import packageJson from "../../package.json" with { type: "json" };
55+
56+
const CODEX_DRIVER_KIND = "codex"; // fork-hook: upstream-fixes/codex-provider-env
5457
const isCodexAppServerSpawnError = Schema.is(CodexErrors.CodexAppServerSpawnError);
5558
const RATE_LIMITS_PROBE_TIMEOUT_MS = 3_000;
5659

@@ -471,20 +474,20 @@ export const withCodexAppServerClient = Effect.fn("withCodexAppServerClient")(fu
471474
: undefined;
472475
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
473476
const environment = {
477+
...stripForeignHarnessIdentityEnv(stripInheritedTmuxEnv(process.env), CODEX_DRIVER_KIND), // fork-hook: upstream-fixes/codex-provider-env
474478
...codexAppServerEnvironment(input.environment),
475479
...(resolvedHomePath ? { CODEX_HOME: resolvedHomePath } : {}),
476480
};
477481
const spawnCommand = yield* resolveSpawnCommand(
478482
input.binaryPath,
479483
codexAppServerArgs(input.launchArgs),
480-
{ env: environment, extendEnv: true },
484+
{ env: environment }, // fork-hook: upstream-fixes/codex-provider-env
481485
);
482486
const child = yield* spawner
483487
.spawn(
484488
ChildProcess.make(spawnCommand.command, spawnCommand.args, {
485489
cwd: input.cwd,
486490
env: environment,
487-
extendEnv: true,
488491
forceKillAfter: CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER,
489492
shell: spawnCommand.shell,
490493
}),

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,7 +4329,11 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
43294329
// Snapshot listeners run under that lock and must not block.
43304330
const streamSession = (
43314331
input: TerminalObserveInput,
4332-
initial: Effect.Effect<TerminalSessionSnapshot | null, TerminalError>,
4332+
initial:
4333+
| Effect.Effect<TerminalSessionSnapshot | null, TerminalError>
4334+
| ((
4335+
onAttachmentAcquired: () => void,
4336+
) => Effect.Effect<TerminalSessionSnapshot | null, TerminalError>), // fork-hook: zmux-estate/stream-attachment-initial
43334337
listener: (event: TerminalAttachStreamEvent) => Effect.Effect<void>,
43344338
registerCleanup?: (stop: () => void) => void,
43354339
) => {
@@ -4389,7 +4393,11 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
43894393
},
43904394
);
43914395

4392-
const initialSnapshot = yield* initial;
4396+
const initialSnapshot = yield* Effect.isEffect(initial)
4397+
? initial
4398+
: initial(() => {
4399+
attachmentAcquired = true;
4400+
}); // fork-hook: zmux-estate/stream-attachment-acquired
43934401

43944402
yield* listener(
43954403
initialSnapshot === null
@@ -4436,7 +4444,13 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
44364444
input,
44374445
listener,
44384446
registerCleanup,
4439-
) => streamSession(input, openOrAttachForStream(input), listener, registerCleanup);
4447+
) =>
4448+
streamSession(
4449+
input,
4450+
(onAttachmentAcquired) => openOrAttachForStream(input, onAttachmentAcquired),
4451+
listener,
4452+
registerCleanup,
4453+
); // fork-hook: zmux-estate/stream-attachment-open
44404454

44414455
const observeStream: TerminalManager["Service"]["observeStream"] = (
44424456
input,

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import {
1818
AuthOrchestrationOperateScope,
1919
AuthSourceControlWriteScope,
20+
type CommandId, // fork-hook: zmux-estate/checkout-move-lock
2021
type ContextMenuItem,
2122
type EnvironmentId,
2223
type VcsRef,
@@ -257,6 +258,7 @@ export function BranchToolbarBranchSelector({
257258
if (
258259
!activeThreadId ||
259260
!activeProject ||
261+
checkoutMoveControlsLocked || // fork-hook: zmux-estate/checkout-move-lock
260262
(hasServerThread && !readEnvironmentScope(environmentId, AuthOrchestrationOperateScope))
261263
)
262264
return;
@@ -485,7 +487,14 @@ export function BranchToolbarBranchSelector({
485487
};
486488

487489
const selectBranch = (refName: VcsRef) => {
488-
if (!canUpdateThreadBranch || !branchCwd || !activeProjectCwd || isBranchActionPending) return;
490+
if (
491+
!canUpdateThreadBranch ||
492+
!branchCwd ||
493+
!activeProjectCwd ||
494+
isBranchActionPending ||
495+
checkoutMoveControlsLocked
496+
)
497+
return; // fork-hook: zmux-estate/checkout-move-lock
489498

490499
if (isSelectingWorktreeBase) {
491500
setThreadBranch(refName.name, null);

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
25932593
currentGroupId: currentGroup?.id ?? null,
25942594
});
25952595
const threadActionItems = buildThreadActionMenuItems({
2596+
canOperate: readEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope), // fork-hook: thread-ordering/thread-action-operate
25962597
branch: thread.branch ?? null,
25972598
projectFilter: threadProjectGroup
25982599
? {

‎apps/web/src/components/files/projectFilesQueryState.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export function useProjectEntriesQuery(
207207
const fileAccess = useFilesystemReadAccess(environmentId);
208208
const { canReadFiles } = fileAccess;
209209
const atom = canReadFiles
210-
? getProjectEntriesQueryAtom(environmentId, cwd, directoryPath)
210+
? getProjectEntriesQueryAtom(environmentId, cwd, directoryPath, includeIgnored) // fork-hook: workspace-files/include-ignored-entries
211211
: EMPTY_PROJECT_ENTRIES_QUERY_ATOM;
212212
const result = useAtomValue(revisionedQuery(atom, canReadFiles ? revision : undefined));
213213
const refreshAtom = useAtomRefresh(atom);

‎packages/client-runtime/src/state/auth.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
} from "@t3tools/contracts";
88
import { WS_METHODS } from "@t3tools/contracts";
99
import * as Stream from "effect/Stream";
10-
import type { HttpClient } from "effect/unstable/http";
10+
import type { HttpClient } from "effect/http"; // fork-hook: backend-attach/http-client-import
1111
import { Atom } from "effect/reactivity";
1212

1313
import type { EnvironmentRegistry } from "../connection/registry.ts";

0 commit comments

Comments
 (0)