mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 21:20:44 +00:00
Merge pull request #2268 from QwenLM/fix/export-current-session
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
fix: export command should use current session ID instead of loadLastSession
This commit is contained in:
commit
2a8366390d
2 changed files with 21 additions and 16 deletions
|
|
@ -19,14 +19,14 @@ import {
|
||||||
} from '../utils/export/index.js';
|
} from '../utils/export/index.js';
|
||||||
|
|
||||||
const mockSessionServiceMocks = vi.hoisted(() => ({
|
const mockSessionServiceMocks = vi.hoisted(() => ({
|
||||||
loadLastSession: vi.fn(),
|
loadSession: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('@qwen-code/qwen-code-core', () => {
|
vi.mock('@qwen-code/qwen-code-core', () => {
|
||||||
class SessionService {
|
class SessionService {
|
||||||
constructor(_cwd: string) {}
|
constructor(_cwd: string) {}
|
||||||
async loadLastSession() {
|
async loadSession(_sessionId: string) {
|
||||||
return mockSessionServiceMocks.loadLastSession();
|
return mockSessionServiceMocks.loadSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,13 +68,14 @@ describe('exportCommand', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
||||||
mockSessionServiceMocks.loadLastSession.mockResolvedValue(mockSessionData);
|
mockSessionServiceMocks.loadSession.mockResolvedValue(mockSessionData);
|
||||||
|
|
||||||
mockContext = createMockCommandContext({
|
mockContext = createMockCommandContext({
|
||||||
services: {
|
services: {
|
||||||
config: {
|
config: {
|
||||||
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
||||||
getProjectRoot: vi.fn().mockReturnValue('/test/project'),
|
getProjectRoot: vi.fn().mockReturnValue('/test/project'),
|
||||||
|
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -132,7 +133,7 @@ describe('exportCommand', () => {
|
||||||
content: expect.stringContaining('export-2025-01-01T00-00-00-000Z.md'),
|
content: expect.stringContaining('export-2025-01-01T00-00-00-000Z.md'),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockSessionServiceMocks.loadLastSession).toHaveBeenCalled();
|
expect(mockSessionServiceMocks.loadSession).toHaveBeenCalled();
|
||||||
expect(collectSessionData).toHaveBeenCalledWith(
|
expect(collectSessionData).toHaveBeenCalledWith(
|
||||||
mockSessionData.conversation,
|
mockSessionData.conversation,
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
|
|
@ -191,7 +192,7 @@ describe('exportCommand', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return error when no session is found', async () => {
|
it('should return error when no session is found', async () => {
|
||||||
mockSessionServiceMocks.loadLastSession.mockResolvedValue(undefined);
|
mockSessionServiceMocks.loadSession.mockResolvedValue(undefined);
|
||||||
|
|
||||||
const mdCommand = exportCommand.subCommands?.find((c) => c.name === 'md');
|
const mdCommand = exportCommand.subCommands?.find((c) => c.name === 'md');
|
||||||
if (!mdCommand?.action) {
|
if (!mdCommand?.action) {
|
||||||
|
|
@ -260,7 +261,7 @@ describe('exportCommand', () => {
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockSessionServiceMocks.loadLastSession).toHaveBeenCalled();
|
expect(mockSessionServiceMocks.loadSession).toHaveBeenCalled();
|
||||||
expect(collectSessionData).toHaveBeenCalledWith(
|
expect(collectSessionData).toHaveBeenCalledWith(
|
||||||
mockSessionData.conversation,
|
mockSessionData.conversation,
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
|
|
@ -323,7 +324,7 @@ describe('exportCommand', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return error when no session is found', async () => {
|
it('should return error when no session is found', async () => {
|
||||||
mockSessionServiceMocks.loadLastSession.mockResolvedValue(undefined);
|
mockSessionServiceMocks.loadSession.mockResolvedValue(undefined);
|
||||||
|
|
||||||
const htmlCommand = exportCommand.subCommands?.find(
|
const htmlCommand = exportCommand.subCommands?.find(
|
||||||
(c) => c.name === 'html',
|
(c) => c.name === 'html',
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ async function exportMarkdownAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load the current session
|
// Load the current session using the current session ID
|
||||||
const sessionService = new SessionService(cwd);
|
const sessionService = new SessionService(cwd);
|
||||||
const sessionData = await sessionService.loadLastSession();
|
const sessionId = config.getSessionId();
|
||||||
|
const sessionData = await sessionService.loadSession(sessionId);
|
||||||
|
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -122,9 +123,10 @@ async function exportHtmlAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load the current session
|
// Load the current session using the current session ID
|
||||||
const sessionService = new SessionService(cwd);
|
const sessionService = new SessionService(cwd);
|
||||||
const sessionData = await sessionService.loadLastSession();
|
const sessionId = config.getSessionId();
|
||||||
|
const sessionData = await sessionService.loadSession(sessionId);
|
||||||
|
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -194,9 +196,10 @@ async function exportJsonAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load the current session
|
// Load the current session using the current session ID
|
||||||
const sessionService = new SessionService(cwd);
|
const sessionService = new SessionService(cwd);
|
||||||
const sessionData = await sessionService.loadLastSession();
|
const sessionId = config.getSessionId();
|
||||||
|
const sessionData = await sessionService.loadSession(sessionId);
|
||||||
|
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -266,9 +269,10 @@ async function exportJsonlAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load the current session
|
// Load the current session using the current session ID
|
||||||
const sessionService = new SessionService(cwd);
|
const sessionService = new SessionService(cwd);
|
||||||
const sessionData = await sessionService.loadLastSession();
|
const sessionId = config.getSessionId();
|
||||||
|
const sessionData = await sessionService.loadSession(sessionId);
|
||||||
|
|
||||||
if (!sessionData) {
|
if (!sessionData) {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue