Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/mobile-fingerprint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ concurrency:
jobs:
fingerprint:
name: Native fingerprint diff
<<<<<<< origin/main
runs-on: ubuntu-24.04
=======
if: github.event.action != 'edited' || github.event.changes.base
runs-on: blacksmith-8vcpu-ubuntu-2404
>>>>>>> upstream/main
runs-on: ubuntu-24.04
permissions:
contents: read
env:
Expand Down
5 changes: 1 addition & 4 deletions apps/mobile/src/features/threads/ThreadFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2252,12 +2252,9 @@ function renderFeedEntry(
: resolveUserMessageIntentBadge(
message.inputIntent,
message.projectedItem?.item.status === "pending",
<<<<<<< origin/main
props.m,
message.projectedItem?.item,
props.fyiRuns,
=======
props.m,
>>>>>>> upstream/main
);
const referenceIds = new Set(
collectComposerContextReferences(message.text).map((reference) => reference.contextId),
Expand Down
11 changes: 2 additions & 9 deletions apps/mobile/src/features/threads/userMessageIntentBadge.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { OrchestrationV2UserMessageInputIntent } from "@t3tools/contracts";
<<<<<<< origin/main
import type { OrchestrationV2TurnItem, RunId } from "@t3tools/contracts";
import type { FyiCarrierRun } from "@t3tools/client-runtime/fork/fyi-marker";
import { msg } from "gt-react-native";

import type { AppSymbolName } from "../../components/ui/AppSymbol";
import { resolveFyiIntentBadge } from "../../fork/fyi/fyiIntentBadge";
=======
import { msg } from "gt-react-native";

import { m, type MessageResolver } from "../../i18n/messages";
>>>>>>> upstream/main

export interface UserMessageIntentBadgePresentation {
readonly label: string;
Expand All @@ -20,12 +16,9 @@ export interface UserMessageIntentBadgePresentation {
export function resolveUserMessageIntentBadge(
intent: OrchestrationV2UserMessageInputIntent | undefined,
unread = false,
<<<<<<< origin/main
resolve: MessageResolver = m,
item?: OrchestrationV2TurnItem,
fyiRuns?: ReadonlyMap<RunId, FyiCarrierRun>,
=======
resolve: MessageResolver = m,
>>>>>>> upstream/main
): UserMessageIntentBadgePresentation | null {
const fyi = resolveFyiIntentBadge(item, fyiRuns);
if (fyi !== null) return fyi;
Expand Down
5 changes: 3 additions & 2 deletions apps/mobile/src/widgets/subscriptionUsageSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ describe("subscription widget snapshots", () => {
deepLink,
);
const session = snapshot.providers[0]?.windows.find((w) => w.kind === "session");
// The fork orders a pool by weekly reset first, so relay's weekly window leads.
expect(session?.accounts).toStrictEqual([
{ name: "RE", remaining: 60, refill: 0 },
{ name: "RE" },
{ name: "RE2", remaining: 60, refill: 0 },
{
name: "smol",
color: "#4c6ef5",
Expand All @@ -110,7 +112,6 @@ describe("subscription widget snapshots", () => {
reset: expect.any(String),
durationMs: 300 * 60_000,
},
{ name: "RE2" },
]);
expect(JSON.stringify(snapshot)).not.toContain("example.com");
});
Expand Down
34 changes: 30 additions & 4 deletions apps/server/src/fork/fyi/FyiMcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ const layerOrchestratorService = (
it("readThread reports each FYI's state from its run in the thread the row comes from", async () => {
const sourceThreadId = ThreadId.make("thread-mcp-fyi-source");
const node = NodeId.make("node-mcp-fyi");
const run = (id: RunId, threadId: ThreadId, status: "running" | "completed") => ({
const run = (id: RunId, threadId: ThreadId, status: "running" | "completed", ordinal = 2) => ({
id,
threadId,
ordinal: 1,
ordinal,
status,
modelSelection: { instanceId, model: "gpt-5.4" },
providerInstanceId: instanceId,
Expand Down Expand Up @@ -100,9 +100,16 @@ it("readThread reports each FYI's state from its run in the thread the row comes
fyiRow("se", parentThreadId, activeRunId),
fyiRow("inh", sourceThreadId, RunId.make("run-mcp-fyi-source")),
fyiRow("lost", parentThreadId, RunId.make("run-mcp-fyi-missing")),
fyiRow("older", parentThreadId, RunId.make("run-mcp-fyi-old")),
];
const runsByThread = new Map([
[parentThreadId, [run(activeRunId, parentThreadId, "running")]],
[
parentThreadId,
[
run(RunId.make("run-mcp-fyi-old"), parentThreadId, "completed", 1),
run(activeRunId, parentThreadId, "running"),
],
],
[sourceThreadId, [run(RunId.make("run-mcp-fyi-source"), sourceThreadId, "completed")]],
]);
const projection = {
Expand Down Expand Up @@ -151,14 +158,21 @@ it("readThread reports each FYI's state from its run in the thread the row comes
const result = yield* service.readThread(scope, {
threadId: parentThreadId,
afterPosition: -1,
runLimit: 1,
});
// The read loads only the latest run; the old FYI's run is looked up by its id.
assert.deepEqual(
result.recentRuns.map((recent) => recent.runId),
[activeRunId],
);
assert.deepEqual(
result.items.map((item) => [item.text, item.fyi]),
[
["w", "waiting"],
["se", "sent"],
["inh", "delivered"],
["lost", "unknown"],
["older", "delivered"],
],
);
}).pipe(
Expand All @@ -178,7 +192,19 @@ it("readThread reports each FYI's state from its run in the thread the row comes
(run) => filter?.runIds === undefined || filter.runIds.includes(run.id),
),
} as unknown as OrchestrationV2ThreadProjection),
getProjectThreadRecords: () => Effect.succeed(projection),
getProjectThreadRecords: (_input, _fields, filter) =>
Effect.succeed({
...projection,
runs: projection.runs
.toSorted((left, right) => right.ordinal - left.ordinal)
.filter(
(run, index) =>
filter?.latestRunLimit === undefined ||
index < filter.latestRunLimit ||
filter.runStatuses?.includes(run.status) === true,
),
} as unknown as OrchestrationV2ThreadProjection),
getRunCount: () => Effect.succeed(projection.runs.length),
getThreadShell: () =>
Effect.succeed(projection.thread as unknown as OrchestrationV2ThreadShell),
}),
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/fork/generalRoleParity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { UserView } from "./userView/UserView.ts";
import { ServerEnvironment } from "../environment/ServerEnvironment.ts";
import * as EnvironmentTheme from "../environmentTheme.ts";
import { GitWorkflowService } from "../git/GitWorkflowService.ts";
import { IssueService } from "../issue/IssueService.ts";
import * as McpHttpServer from "../mcp/McpHttpServer.ts";
import type { McpThreadInvocationScope } from "../mcp/McpInvocationContext.ts";
import * as McpSessionRegistry from "../mcp/McpSessionRegistry.ts";
Expand All @@ -59,6 +60,7 @@ import * as CommandReceiptStore from "../orchestration-v2/CommandReceiptStore.ts
import * as EffectWorker from "../orchestration-v2/EffectWorker.ts";
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
import { ThreadIssueService } from "../orchestration-v2/ThreadIssueService.ts";
import * as ThreadLaunchService from "../orchestration-v2/ThreadLaunchService.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
import * as ProjectionStore from "../orchestration-v2/ProjectionStore.ts";
Expand Down Expand Up @@ -668,6 +670,7 @@ const toolHandlerServices = Layer.mergeAll(
Layer.mock(EnvironmentTheme.EnvironmentThemeService)({}),
Layer.mock(GitVcsDriver.GitVcsDriver)({}),
Layer.mock(GitWorkflowService)({}),
Layer.mock(IssueService)({}),
Layer.mock(ManagedProjectFolders)({ namedProjectsRoot: "" }),
Layer.mock(McpProviderSessions.McpProviderSessions)({}),
Layer.mock(Orchestrator.OrchestratorV2)({}),
Expand All @@ -693,6 +696,7 @@ const toolHandlerServices = Layer.mergeAll(
Layer.mock(ServerSecretStore)({}),
ServerSettings.layerTest(),
Layer.mock(SourceControlRepositoryService)({}),
Layer.mock(ThreadIssueService)({}),
Layer.mock(ThreadLaunchService.ThreadLaunchService)({}),
McpToolAccessTestkit.liveThreadsLayer,
Layer.mock(ThreadSearch)({}),
Expand Down
131 changes: 6 additions & 125 deletions apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1464,130 +1464,6 @@ export const layerQueryRunner: Layer.Layer<
return { refresh: refresh(true).pipe(Effect.asVoid), stop };
};

<<<<<<< origin/main
return ClaudeAgentSdkQueryRunner.of({
allocateSessionId: random.uuidV4(),
open: Effect.fn("ClaudeAgentSdkQueryRunner.open")(
function* (input: ClaudeAgentSdkQueryOpenInput) {
const protocolLogger = makeClaudeAgentSdkProtocolLogger({
nativeEventLogger,
threadId: input.threadId,
providerSessionId: input.providerSessionId,
});
const logProtocolEvent = (event: ClaudeAgentSdkProtocolLogEvent) =>
protocolLogger === undefined ? Effect.void : protocolLogger(event);
// A failed open shuts down its queue before retrying, so the old CLI cannot take the prompt.
const promptQueue = yield* Queue.unbounded<SDKUserMessage>();
const prompt = Stream.fromQueue(promptQueue).pipe(
Stream.catchCause((cause) =>
Cause.hasInterruptsOnly(cause) ? Stream.empty : Stream.failCause(cause),
),
Stream.toAsyncIterable,
);
// Send MCP credentials over stdin to keep them out of SDK argv and inherited command environments.
const { mcpServers, ...sdkOptions } = input.options;
// Jobs the agent starts inherit the thread, so port discovery can attribute their servers.
let resumeSessionAt = sdkOptions.resumeSessionAt;
if (input.resume && sdkOptions.resume !== undefined) {
const messages = yield* runClaudeWorker({
method: "getSessionMessages",
sessionId: sdkOptions.resume,
options: sdkOptions.cwd === undefined ? {} : { dir: sdkOptions.cwd },
environment: sdkOptions.env ?? hostEnvironment,
}).pipe(
Effect.flatMap(decodeClaudeHistoryMessages),
Effect.mapError((cause) => queryRunnerError(cause, "getSessionMessages")),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.provideService(Path.Path, path),
);
const boundary =
resumeSessionAt === undefined
? messages.length
: messages.findIndex((message) => message.uuid === resumeSessionAt) + 1;
resumeSessionAt = claudeResumeSessionAt(messages.slice(0, boundary)) ?? resumeSessionAt;
}
const queryOptions = {
...sdkOptions,
disallowedTools: [
...DELEGATE_ONLY_PROVIDERS.claudeAgent.hide.disallowedTools,
...(sdkOptions.disallowedTools ?? []),
],
...(resumeSessionAt === undefined ? {} : { resumeSessionAt }),
env: {
...(sdkOptions.env ?? hostEnvironment),
...claudeTerminalToolEnvironment,
...DELEGATE_ONLY_PROVIDERS.claudeAgent.hide.environment,
...(input.resume
? {
CLAUDE_CODE_RESUME_INTERRUPTED_TURN: "1",
CLAUDE_CODE_RESUME_REASON: "user_resume",
}
: {}),
[PortScanner.AGENT_THREAD_ENV]: input.threadId,
},
};
// The SDK can prepend a scope wrapper to native binaries; script entries run through node.
const binaryPath = queryOptions.pathToClaudeCodeExecutable;
const launch =
binaryPath === undefined ||
CLAUDE_SCRIPT_EXTENSIONS.some((ext) => binaryPath.endsWith(ext))
? undefined
: yield* agentScope.wrap({
command: binaryPath,
args: [],
name: "claude",
threadId: input.threadId,
env: queryOptions.env,
});
const options =
launch === undefined || launch.args.length === 0
? queryOptions
: {
...queryOptions,
pathToClaudeCodeExecutable: launch.command,
executableArgs: [...launch.args, ...(queryOptions.executableArgs ?? [])],
};
const unit = launch?.unit;
const stopScope =
unit === undefined ? undefined : () => void runFork(agentScope.stop(unit));
// Only a CLI that fails before its first message explains itself on
// stderr. The known root refusal becomes a curated failure; any other
// stderr can hold private text, so it stays out of turn failures.
let stderrTail = "";
let stderrClosed: Promise<void> = Promise.resolve();
let answered = false;
let conversationMissing = false;
const appendStderr = (text: string) => {
if (answered) return;
stderrTail = (stderrTail + text).slice(-CLAUDE_STDERR_TAIL_LENGTH);
};
let refreshDescendants: Effect.Effect<void> = Effect.void;
const spawnProcess =
options.spawnClaudeCodeProcess ??
((spawnOptions: ClaudeSpawnOptions) => {
if (platform !== "win32") {
// Node can report "exit" before it has read the stderr the CLI wrote.
let stderrDone = () => {};
stderrClosed = new Promise((resolve) => (stderrDone = resolve));
const child = spawnClaudeProcessGroup(
spawnOptions,
stopScope,
appendStderr,
stderrDone,
providerProcesses.register,
);
if (unit === undefined && child.pid !== undefined) {
const tracker = trackDescendants(child.pid);
const polling = runFork(
tracker.refresh.pipe(Effect.repeat(Schedule.spaced(CLAUDE_DESCENDANT_POLL))),
);
child.once("exit", () =>
runFork(Fiber.interrupt(polling).pipe(Effect.andThen(tracker.stop))),
);
refreshDescendants = tracker.refresh;
}
return child;
=======
// The open span below is the tracing boundary for both attempts.
const openQuery = Effect.fnUntraced(function* (input: ClaudeAgentSdkQueryOpenInput) {
const protocolLogger = makeClaudeAgentSdkProtocolLogger({
Expand Down Expand Up @@ -1629,14 +1505,19 @@ export const layerQueryRunner: Layer.Layer<
}
const queryOptions = {
...sdkOptions,
disallowedTools: [
...DELEGATE_ONLY_PROVIDERS.claudeAgent.hide.disallowedTools,
...(sdkOptions.disallowedTools ?? []),
],
...(resumeSessionAt === undefined ? {} : { resumeSessionAt }),
env: {
...(sdkOptions.env ?? hostEnvironment),
...claudeTerminalToolEnvironment,
...DELEGATE_ONLY_PROVIDERS.claudeAgent.hide.environment,
...(input.resume
? {
CLAUDE_CODE_RESUME_INTERRUPTED_TURN: "1",
CLAUDE_CODE_RESUME_REASON: "user_resume",
>>>>>>> upstream/main
}
: {}),
[PortScanner.AGENT_THREAD_ENV]: input.threadId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";

import { resolveAttachmentPath, resolveAttachmentPathById } from "../../attachmentStore.ts";
import * as PortScanner from "../../preview/PortScanner.ts";
import { getCodexServiceTierOptionValue } from "../../codexModelOptions.ts";
import { resolveCodexTurnServiceTier } from "../../fork/codexServiceTier.ts";
import {
codexCompactionNoteItems,
Expand Down
8 changes: 1 addition & 7 deletions apps/server/src/provider/agentContextBudget.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
<<<<<<< origin/main
"claudeSystemAppendBytes": 5630,
"codexAdditionalContextBytes": 7024,
"mcpToolListJsonBytes": 55258
=======
"claudeSystemAppendBytes": 5930,
"codexAdditionalContextBytes": 7324,
"mcpToolListJsonBytes": 52145
>>>>>>> upstream/main
"mcpToolListJsonBytes": 57666
}
9 changes: 2 additions & 7 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5233,17 +5233,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
{ concurrency: "unbounded" },
);
const checkoutWorkers = configuredCheckoutWorkers ?? "0";
<<<<<<< origin/main
// The cache clones a full checkout, so a sparse worktree uses Git's own checkout.
const checkoutCache =
options?.fastCheckout === true
options?.fastCheckout === true && sparsePatterns === null
? yield* checkoutSites.select(options.worktreesDirectory ?? "")
: undefined;
const fastCheckout = checkoutCache !== undefined;
=======
// The cache clones a full checkout, so a sparse worktree uses Git's own checkout.
const fastCheckout =
checkoutCache !== undefined && options?.fastCheckout === true && sparsePatterns === null;
>>>>>>> upstream/main
const cacheGeneration = fastCheckout ? yield* checkoutCache.currentGeneration : 0;
const stockCheckout = executeGitWithStableDiagnostics(
"GitVcsDriver.createWorktree",
Expand Down
4 changes: 0 additions & 4 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ function registerAppShellCommands(router: AnyRouter, shellElement: Element): ()
};
}

<<<<<<< origin/main
function SidebarControl({
boardHidden,
showSidebar,
Expand All @@ -331,10 +330,7 @@ function SidebarControl({
readonly showSidebar: boolean;
readonly sidebarFits: boolean;
}) {
=======
function SidebarControl({ showSidebar }: { readonly showSidebar: boolean }) {
const gt = useGT();
>>>>>>> upstream/main
const router = useRouter();
const usagePageOpen = useLocation({ select: (location) => location.pathname === "/usage" });
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
Expand Down
Loading
Loading