Skip to content

Commit 919d6c8

Browse files
test(server): trim duplicate Claude import resume coverage
1 parent 4e2224c commit 919d6c8

1 file changed

Lines changed: 22 additions & 145 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 22 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
ChatImageAttachment,
2929
CheckpointId,
3030
ClaudeSettings,
31-
CommandId,
3231
EnvironmentId,
3332
MessageId,
3433
type ModelSelection,
@@ -94,13 +93,6 @@ import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
9493
import { ClaudeOrchestratorReplayHarness } from "./ClaudeAdapterV2.testkit.ts";
9594
import { provideDeterministicTestRuntime } from "../testkit/DeterministicRuntime.ts";
9695
import { runOrchestratorV2Scenario } from "../testkit/OrchestratorScenario.ts";
97-
import * as AgentSessionImporter from "../../project/AgentSessionImporter.ts";
98-
import * as AgentSessionScanner from "../../project/AgentSessionScanner.ts";
99-
import * as ProjectService from "../../project/ProjectService.ts";
100-
import * as ProviderSessionRuntime from "../../persistence/ProviderSessionRuntime.ts";
101-
import * as Orchestrator from "../Orchestrator.ts";
102-
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
103-
import { layerWithRegistry } from "../testkit/ProviderReplayHarness.ts";
10496
import { layerProviderReplay } from "../testkit/ProviderReplayHarness.ts";
10597
import {
10698
assertBaseProjection,
@@ -2248,16 +2240,11 @@ describe("ClaudeAdapterV2 native session identity", () => {
22482240
),
22492241
);
22502242

2251-
it.effect.each([
2252-
"onboarding import",
2253-
"single-session import",
2254-
"legacy direct continuation",
2255-
] as const)("resumes the first follow-up after %s", (source) =>
2243+
it.effect("resumes the first follow-up after legacy direct continuation", () =>
22562244
Effect.scoped(
22572245
Effect.gen(function* () {
22582246
const harness = yield* makeIdentityHarness();
22592247
const nativeId = "11111111-2222-4333-8444-555555555555";
2260-
const projectId = ProjectId.make("project-imported-claude");
22612248
const threadId = ThreadId.make(`import:claudeAgent:${nativeId}`);
22622249
const projectDir = NodePath.join(harness.configDir, "projects", "-workspace");
22632250
yield* harness.fileSystem.makeDirectory(projectDir, { recursive: true });
@@ -2271,137 +2258,27 @@ describe("ClaudeAdapterV2 native session identity", () => {
22712258
}) + "\n",
22722259
);
22732260
const runtime = yield* harness.openSession(threadId);
2274-
const now = yield* DateTime.now;
2275-
const providerThread = yield* Effect.gen(function* () {
2276-
if (source === "legacy direct continuation") {
2277-
// A persisted pre-fix import is continued without calling either importer.
2278-
const template = yield* runtime.ensureThread({
2279-
threadId,
2280-
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
2281-
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
2282-
});
2283-
return {
2284-
...template,
2285-
id: IdAllocator.deriveProviderThread({
2286-
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
2287-
providerInstanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
2288-
nativeThreadId: nativeId,
2289-
}),
2290-
nativeThreadRef: {
2291-
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
2292-
nativeId,
2293-
strength: "strong" as const,
2294-
},
2295-
nativeConversationHeadRef: null,
2296-
nativeMetadata: null,
2297-
};
2298-
}
2299-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2300-
if (source === "single-session import") {
2301-
yield* orchestrator.dispatch({
2302-
type: "thread.create",
2303-
commandId: CommandId.make("command-import-native-claude"),
2304-
threadId,
2305-
projectId,
2306-
title: "Imported Claude",
2307-
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
2308-
runtimeMode: "full-access",
2309-
interactionMode: "default",
2310-
branch: null,
2311-
worktreePath: null,
2312-
createdBy: "user",
2313-
creationSource: "web",
2314-
importedNativeThread: {
2315-
ref: { driver: ClaudeAdapterV2.CLAUDE_PROVIDER, nativeId, strength: "strong" },
2316-
},
2317-
});
2318-
} else {
2319-
const importer = yield* AgentSessionImporter.AgentSessionImporter;
2320-
assert.deepEqual(yield* importer.importRecentAgentThreads({ projectId }), {
2321-
importedCount: 1,
2322-
skippedCount: 0,
2323-
});
2324-
}
2325-
const projection = yield* orchestrator.getThreadProjection(threadId);
2326-
assert.lengthOf(projection.providerTurns, 0);
2327-
const imported = projection.providerThreads[0];
2328-
assert.isDefined(imported);
2329-
return imported!;
2330-
}).pipe(
2331-
Effect.provide(
2332-
AgentSessionImporter.layer.pipe(
2333-
Layer.provideMerge(
2334-
layerWithRegistry(
2335-
{ name: "claude-import-resume" },
2336-
ProviderAdapterRegistry.layerFromAdapters([harness.adapter]),
2337-
{ runEffectWorker: false },
2338-
),
2339-
),
2340-
Layer.provide(
2341-
Layer.mergeAll(
2342-
Layer.mock(ProjectService.ProjectService)({
2343-
getById: () =>
2344-
Effect.succeed(
2345-
Option.some({
2346-
id: projectId,
2347-
title: "Imported Claude",
2348-
workspaceRoot: "/workspace",
2349-
defaultModelSelection: CLAUDE_TEST_MODEL_SELECTION,
2350-
scripts: [],
2351-
createdAt: DateTime.formatIso(now),
2352-
updatedAt: DateTime.formatIso(now),
2353-
deletedAt: null,
2354-
}),
2355-
),
2356-
}),
2357-
Layer.succeed(
2358-
AgentSessionScanner.AgentSessionScanner,
2359-
AgentSessionScanner.AgentSessionScanner.of({
2360-
scan: Effect.die("unused"),
2361-
recentThreads: () =>
2362-
Stream.succeed({
2363-
_tag: "Importable",
2364-
source: {
2365-
provider: "claudeAgent",
2366-
providerInstanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
2367-
providerSessionId: nativeId,
2368-
filePath: NodePath.join(projectDir, `${nativeId}.jsonl`),
2369-
size: 100,
2370-
mtimeMs: 2,
2371-
device: 3,
2372-
inode: 4,
2373-
birthtimeMs: 1,
2374-
},
2375-
thread: {
2376-
source: "claudeAgent",
2377-
providerInstanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
2378-
providerSessionId: nativeId,
2379-
title: "Imported Claude",
2380-
model: CLAUDE_TEST_MODEL_SELECTION.model,
2381-
createdAt: DateTime.formatIso(now),
2382-
updatedAt: DateTime.formatIso(now),
2383-
messages: [
2384-
{
2385-
role: "user",
2386-
text: "Remember the existing conversation",
2387-
createdAt: DateTime.formatIso(now),
2388-
},
2389-
],
2390-
},
2391-
}),
2392-
}),
2393-
),
2394-
Layer.mock(ProviderSessionRuntime.ProviderSessionRuntimeRepository)({
2395-
list: () => Effect.succeed([]),
2396-
upsert: () => Effect.void,
2397-
recordImportedTranscript: () => Effect.void,
2398-
}),
2399-
IdAllocator.layer,
2400-
),
2401-
),
2402-
),
2403-
),
2404-
);
2261+
// A persisted pre-fix import is continued without calling either importer.
2262+
const template = yield* runtime.ensureThread({
2263+
threadId,
2264+
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
2265+
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
2266+
});
2267+
const providerThread = {
2268+
...template,
2269+
id: IdAllocator.deriveProviderThread({
2270+
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
2271+
providerInstanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
2272+
nativeThreadId: nativeId,
2273+
}),
2274+
nativeThreadRef: {
2275+
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
2276+
nativeId,
2277+
strength: "strong" as const,
2278+
},
2279+
nativeConversationHeadRef: null,
2280+
nativeMetadata: null,
2281+
};
24052282
// Run start binds the provider session before resumeThread reaches the adapter.
24062283
const boundThread = {
24072284
...providerThread,

0 commit comments

Comments
 (0)