mirror of
https://github.com/cline/cline.git
synced 2026-09-19 02:05:44 +08:00
Clean up compaction sidecar kill switch review nits
This commit is contained in:
@@ -642,10 +642,7 @@ export function createInteractiveSessionRuntime(input: {
|
||||
}
|
||||
const compactionState = result.compactionState;
|
||||
const updated = await compactionSidecar.update(() =>
|
||||
manager.updateSessionCompactionState(
|
||||
sourceSessionId,
|
||||
compactionState,
|
||||
),
|
||||
manager.updateSessionCompactionState(sourceSessionId, compactionState),
|
||||
);
|
||||
if (!updated.updated && !updated.disabled) {
|
||||
throw new Error("Compaction could not be saved. Try again.");
|
||||
|
||||
@@ -126,10 +126,8 @@ export interface ClineCoreAutomationApi {
|
||||
|
||||
export type ClineCoreListHistoryOptions = SessionHistoryListOptions;
|
||||
|
||||
export interface ClineCoreStartInput extends Omit<
|
||||
StartSessionInput,
|
||||
"config" | "localRuntime"
|
||||
> {
|
||||
export interface ClineCoreStartInput
|
||||
extends Omit<StartSessionInput, "config" | "localRuntime"> {
|
||||
config: CoreSessionConfig;
|
||||
localRuntime?: LocalRuntimeStartOptions;
|
||||
}
|
||||
@@ -223,7 +221,7 @@ export interface ClineCoreOptions {
|
||||
*/
|
||||
featureFlags?: FeatureFlagsService;
|
||||
/**
|
||||
* Gets whether persisted compaction sidecar reads and writes are enabled.
|
||||
* Gets whether persisted compaction sidecar reads and writes are enabled.
|
||||
* @internal
|
||||
*/
|
||||
isCompactionSidecarEnabled?: () => boolean;
|
||||
|
||||
@@ -654,73 +654,73 @@ describe("HubServerTransport boundaries", () => {
|
||||
},
|
||||
});
|
||||
|
||||
await expect(answerPromise).resolves.toBe("Use hub");
|
||||
});
|
||||
await expect(answerPromise).resolves.toBe("Use hub");
|
||||
});
|
||||
|
||||
it("ignores initial compaction sidecar state when the sidecar flag is off", async () => {
|
||||
let capturedStartInput: StartSessionInput | undefined;
|
||||
const startSession = vi.fn(async (input: StartSessionInput) => {
|
||||
capturedStartInput = input;
|
||||
const sessionId = input.config.sessionId?.trim() || "session-1";
|
||||
return {
|
||||
sessionId,
|
||||
manifest: {
|
||||
version: 1,
|
||||
session_id: sessionId,
|
||||
source: "cli",
|
||||
pid: 1,
|
||||
started_at: new Date(0).toISOString(),
|
||||
status: "running",
|
||||
interactive: true,
|
||||
provider: "cline",
|
||||
model: "test-model",
|
||||
cwd: "/tmp/project",
|
||||
workspace_root: "/tmp/project",
|
||||
enable_tools: true,
|
||||
enable_spawn: true,
|
||||
enable_teams: false,
|
||||
},
|
||||
manifestPath: "",
|
||||
messagesPath: "",
|
||||
result: undefined,
|
||||
};
|
||||
});
|
||||
const transport = createTransport({
|
||||
sessionHost: { startSession },
|
||||
isCompactionSidecarEnabled: () => false,
|
||||
});
|
||||
const initialCompactionState = createSessionCompactionState({
|
||||
sourceMessages: [{ role: "user", content: "source" }],
|
||||
compactedMessages: [{ role: "user", content: "summary" }],
|
||||
conversationId: "session-1",
|
||||
});
|
||||
|
||||
const reply = await transport.handleCommand({
|
||||
version: "v1",
|
||||
requestId: "req-create-sidecar-off",
|
||||
command: "session.create",
|
||||
clientId: "client-1",
|
||||
payload: {
|
||||
workspaceRoot: "/tmp/project",
|
||||
it("ignores initial compaction sidecar state when the sidecar flag is off", async () => {
|
||||
let capturedStartInput: StartSessionInput | undefined;
|
||||
const startSession = vi.fn(async (input: StartSessionInput) => {
|
||||
capturedStartInput = input;
|
||||
const sessionId = input.config.sessionId?.trim() || "session-1";
|
||||
return {
|
||||
sessionId,
|
||||
manifest: {
|
||||
version: 1,
|
||||
session_id: sessionId,
|
||||
source: "cli",
|
||||
pid: 1,
|
||||
started_at: new Date(0).toISOString(),
|
||||
status: "running",
|
||||
interactive: true,
|
||||
provider: "cline",
|
||||
model: "test-model",
|
||||
cwd: "/tmp/project",
|
||||
sessionConfig: {
|
||||
sessionId: "session-1",
|
||||
providerId: "cline",
|
||||
modelId: "test-model",
|
||||
cwd: "/tmp/project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
systemPrompt: "system",
|
||||
},
|
||||
initialCompactionState,
|
||||
workspace_root: "/tmp/project",
|
||||
enable_tools: true,
|
||||
enable_spawn: true,
|
||||
enable_teams: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(reply.ok).toBe(true);
|
||||
expect(capturedStartInput?.initialCompactionState).toBeUndefined();
|
||||
manifestPath: "",
|
||||
messagesPath: "",
|
||||
result: undefined,
|
||||
};
|
||||
});
|
||||
const transport = createTransport({
|
||||
sessionHost: { startSession },
|
||||
isCompactionSidecarEnabled: () => false,
|
||||
});
|
||||
const initialCompactionState = createSessionCompactionState({
|
||||
sourceMessages: [{ role: "user", content: "source" }],
|
||||
compactedMessages: [{ role: "user", content: "summary" }],
|
||||
conversationId: "session-1",
|
||||
});
|
||||
|
||||
it("does not transfer capability ownership to attached clients", async () => {
|
||||
let createdSessionId = "";
|
||||
const reply = await transport.handleCommand({
|
||||
version: "v1",
|
||||
requestId: "req-create-sidecar-off",
|
||||
command: "session.create",
|
||||
clientId: "client-1",
|
||||
payload: {
|
||||
workspaceRoot: "/tmp/project",
|
||||
cwd: "/tmp/project",
|
||||
sessionConfig: {
|
||||
sessionId: "session-1",
|
||||
providerId: "cline",
|
||||
modelId: "test-model",
|
||||
cwd: "/tmp/project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
systemPrompt: "system",
|
||||
},
|
||||
initialCompactionState,
|
||||
},
|
||||
});
|
||||
|
||||
expect(reply.ok).toBe(true);
|
||||
expect(capturedStartInput?.initialCompactionState).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not transfer capability ownership to attached clients", async () => {
|
||||
let createdSessionId = "";
|
||||
const startSession = vi.fn(async (input: StartSessionInput) => {
|
||||
createdSessionId = input.config.sessionId?.trim() || "missing-session";
|
||||
return {
|
||||
|
||||
@@ -259,7 +259,7 @@ export class LocalRuntimeHost implements RuntimeHost {
|
||||
new RuntimeOAuthTokenManager({
|
||||
providerSettingsManager: this.providerSettingsManager,
|
||||
telemetry: options.telemetry,
|
||||
});
|
||||
});
|
||||
this.defaultTelemetry = options.telemetry;
|
||||
this.defaultTelemetry?.setDistinctId(distinctId);
|
||||
this.defaultFetch = options.fetch;
|
||||
@@ -531,8 +531,7 @@ export class LocalRuntimeHost implements RuntimeHost {
|
||||
"Skipped stale session compaction state",
|
||||
{
|
||||
sessionId: activeSession.sessionId,
|
||||
sourceMessageCount:
|
||||
stateForSession.source_message_count,
|
||||
sourceMessageCount: stateForSession.source_message_count,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -559,7 +558,7 @@ export class LocalRuntimeHost implements RuntimeHost {
|
||||
});
|
||||
},
|
||||
})
|
||||
: undefined;
|
||||
: undefined;
|
||||
|
||||
const agentConfig = {
|
||||
sessionId,
|
||||
|
||||
Reference in New Issue
Block a user