Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions packages/acp-bridge/src/transcript-replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const GOAL: GoalRecord = {
status: 'active',
evidenceCursor: { recordId: 'record-0' },
turnCount: 4,
tokensUsed: 0,
activeTimeMs: 2000,
createdAt: 100,
updatedAt: 200,
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/acp-integration/acpAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ function goalSnapshot(
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 123,
updatedAt: 123,
...overrides,
Expand Down Expand Up @@ -17363,6 +17364,7 @@ describe('QwenAgent loadSession / unstable_resumeSession', () => {
evidenceCursor: { recordId: 'goal-state' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1,
updatedAt: 1,
},
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/src/acp-integration/session/Session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16894,6 +16894,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -16936,6 +16937,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -16999,6 +17001,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17106,6 +17109,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17312,6 +17316,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
};
Expand Down Expand Up @@ -17397,6 +17402,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
};
Expand Down Expand Up @@ -17431,6 +17437,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17501,6 +17508,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17557,6 +17565,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17688,6 +17697,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17762,6 +17772,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17821,6 +17832,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17862,6 +17874,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17923,6 +17936,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -17970,6 +17984,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18017,6 +18032,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18088,6 +18104,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18158,6 +18175,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18215,6 +18233,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18330,6 +18349,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -18440,6 +18460,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
};
Expand Down Expand Up @@ -18566,6 +18587,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -22030,6 +22052,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down Expand Up @@ -28645,6 +28668,7 @@ describe('Session', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ describe('MessageEmitter', () => {
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 0,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: 1234,
updatedAt: 1234,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const GOAL_STATE: GoalSnapshotV2 = {
evidenceCursor: { recordId: 'goal-state' },
turnCount: 2,
activeTimeMs: 1000,
tokensUsed: 0,
createdAt: 1,
updatedAt: 2,
},
Expand Down Expand Up @@ -645,6 +646,7 @@ describe('history replay page', () => {
evidenceCursor: { recordId: 'goal-state' },
turnCount: 3,
activeTimeMs: 1234,
tokensUsed: 0,
createdAt: 10,
updatedAt: 20,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const hiddenSnapshot: GoalSnapshotV2 = {
evidenceCursor: { recordId: 'hidden-record' },
turnCount: 1,
activeTimeMs: 10,
tokensUsed: 0,
createdAt: 1,
updatedAt: 2,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const goalSnapshot: GoalSnapshotV2 = {
evidenceCursor: { recordId: 'record-1' },
turnCount: 3,
activeTimeMs: 12_000,
tokensUsed: 0,
createdAt: 1,
updatedAt: 2,
lastReason: 'keep going',
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/serve/routes/goals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const activeGoal = (
evidenceCursor: { recordId: 'cursor-1' },
turnCount: active.iterations,
activeTimeMs: 0,
tokensUsed: 0,
createdAt: active.setAt,
updatedAt: active.setAt,
...(active.lastReason ? { lastReason: active.lastReason } : {}),
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/commands/goalCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function goalSnapshot(
evidenceCursor: { recordId: 'cursor-1' },
turnCount: 3,
activeTimeMs: 1_000,
tokensUsed: 0,
createdAt: 10,
updatedAt: 20,
...overrides,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/components/GoalPill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function snapshot(
evidenceCursor: { recordId: null },
turnCount: 3,
activeTimeMs: 2_000,
tokensUsed: 0,
createdAt: 1_000,
updatedAt: 7_000,
...overrides,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/components/HistoryItemDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ describe('<HistoryItemDisplay />', () => {
evidenceCursor: { recordId: 'record-1' },
turnCount: 2,
activeTimeMs: 4_000,
tokensUsed: 0,
createdAt: 1_000,
updatedAt: 5_000,
lastReason: 'waiting for approval',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function snapshot(
evidenceCursor: { recordId: 'record-1' },
turnCount: 4,
activeTimeMs: 12_000,
tokensUsed: 0,
createdAt: 1_000,
updatedAt: 13_000,
...(lastReason ? { lastReason } : {}),
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/src/ui/hooks/useBranchCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ import { renderHook, act } from '@testing-library/react';
import { useBranchCommand } from './useBranchCommand.js';
import type { LoadedSettings } from '../../config/settings.js';

const replayUiTelemetryEventsMock = vi.hoisted(() => vi.fn());

vi.mock('@qwen-code/qwen-code-core', async (importOriginal) => {
const original =
await importOriginal<typeof import('@qwen-code/qwen-code-core')>();
return {
...original,
replayUiTelemetryEventsFromConversation: replayUiTelemetryEventsMock,
};
});

const mockSettings = {
merged: { ui: { history: { collapseOnResume: false } } },
} as unknown as LoadedSettings;
Expand Down Expand Up @@ -80,6 +91,7 @@ describe('useBranchCommand', () => {
});

beforeEach(() => {
replayUiTelemetryEventsMock.mockClear();
forkSession = vi
.fn()
.mockResolvedValue({ filePath: '/tmp/new.jsonl', copiedCount: 2 });
Expand Down Expand Up @@ -283,6 +295,9 @@ describe('useBranchCommand', () => {
await result.current.handleBranch('my-branch');
});
expect(getGoalRuntimeReady).toHaveBeenCalledTimes(1);
expect(
replayUiTelemetryEventsMock.mock.invocationCallOrder[0],
).toBeLessThan(getGoalRuntimeReady.mock.invocationCallOrder[0]!);
});

it('rolls core back when the fork contains malformed Goal state', async () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/ui/hooks/useBranchCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
type ResumedSessionData,
SessionStartSource,
computeUniqueBranchTitle,
replayUiTelemetryEventsFromConversation,
} from '@qwen-code/qwen-code-core';
import {
buildResumedHistoryItems,
Expand Down Expand Up @@ -199,6 +200,10 @@ export function useBranchCommand(
// the parent, silently recording user input into an orphan.
config.startNewSession(newSessionId, resumed);
coreSwapped = true;
replayUiTelemetryEventsFromConversation(
resumed.conversation,
Comment thread
qqqys marked this conversation as resolved.
Resolved
newSessionId,
);
await waitForGoalRuntime(config);
await config.getGeminiClient()?.initialize?.(SessionStartSource.Branch);

Expand Down
Loading
Loading