mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
Migrate console to coreEvents.emitFeedback or debugLogger (#15219)
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
import {
|
||||
ChatRecordingService,
|
||||
generateSummary,
|
||||
writeToStderr,
|
||||
writeToStdout,
|
||||
type Config,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
@@ -23,11 +25,13 @@ export async function listSessions(config: Config): Promise<void> {
|
||||
const sessions = await sessionSelector.listSessions();
|
||||
|
||||
if (sessions.length === 0) {
|
||||
console.log('No previous sessions found for this project.');
|
||||
writeToStdout('No previous sessions found for this project.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`\nAvailable sessions for this project (${sessions.length}):\n`);
|
||||
writeToStdout(
|
||||
`\nAvailable sessions for this project (${sessions.length}):\n`,
|
||||
);
|
||||
|
||||
sessions
|
||||
.sort(
|
||||
@@ -41,8 +45,8 @@ export async function listSessions(config: Config): Promise<void> {
|
||||
session.displayName.length > 100
|
||||
? session.displayName.slice(0, 97) + '...'
|
||||
: session.displayName;
|
||||
console.log(
|
||||
` ${index + 1}. ${title} (${time}${current}) [${session.id}]`,
|
||||
writeToStdout(
|
||||
` ${index + 1}. ${title} (${time}${current}) [${session.id}]\n`,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -55,7 +59,7 @@ export async function deleteSession(
|
||||
const sessions = await sessionSelector.listSessions();
|
||||
|
||||
if (sessions.length === 0) {
|
||||
console.error('No sessions found for this project.');
|
||||
writeToStderr('No sessions found for this project.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +80,7 @@ export async function deleteSession(
|
||||
// Parse session index
|
||||
const index = parseInt(sessionIndex, 10);
|
||||
if (isNaN(index) || index < 1 || index > sessions.length) {
|
||||
console.error(
|
||||
writeToStderr(
|
||||
`Invalid session identifier "${sessionIndex}". Use --list-sessions to see available sessions.`,
|
||||
);
|
||||
return;
|
||||
@@ -86,7 +90,7 @@ export async function deleteSession(
|
||||
|
||||
// Prevent deleting the current session
|
||||
if (sessionToDelete.isCurrentSession) {
|
||||
console.error('Cannot delete the current active session.');
|
||||
writeToStderr('Cannot delete the current active session.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,11 +100,11 @@ export async function deleteSession(
|
||||
chatRecordingService.deleteSession(sessionToDelete.file);
|
||||
|
||||
const time = formatRelativeTime(sessionToDelete.lastUpdated);
|
||||
console.log(
|
||||
writeToStdout(
|
||||
`Deleted session ${sessionToDelete.index}: ${sessionToDelete.firstUserMessage} (${time})`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
writeToStderr(
|
||||
`Failed to delete session: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user