セッションが見つからない場合に info メッセージを表示

This commit is contained in:
nrslib 2026-02-11 22:46:22 +09:00
parent b4a224c0f0
commit 0d73007c3f
4 changed files with 12 additions and 0 deletions

View File

@ -19,10 +19,17 @@ vi.mock('../shared/prompt/index.js', () => ({
selectOption: (...args: [string, unknown[]]) => mockSelectOption(...args),
}));
const mockInfo = vi.fn<(message: string) => void>();
vi.mock('../shared/ui/index.js', () => ({
info: (...args: [string]) => mockInfo(...args),
}));
vi.mock('../shared/i18n/index.js', () => ({
getLabel: (key: string, _lang: string, params?: Record<string, string>) => {
if (key === 'interactive.sessionSelector.newSession') return 'New session';
if (key === 'interactive.sessionSelector.newSessionDescription') return 'Start a new conversation';
if (key === 'interactive.sessionSelector.noSessions') return 'No sessions found';
if (key === 'interactive.sessionSelector.messages') return `${params?.count} messages`;
if (key === 'interactive.sessionSelector.lastResponse') return `Last: ${params?.response}`;
if (key === 'interactive.sessionSelector.prompt') return 'Select a session';
@ -44,6 +51,7 @@ describe('selectRecentSession', () => {
expect(result).toBeNull();
expect(mockSelectOption).not.toHaveBeenCalled();
expect(mockInfo).toHaveBeenCalledWith('No sessions found');
});
it('should return null when user selects __new__', async () => {

View File

@ -8,6 +8,7 @@
import { loadSessionIndex, extractLastAssistantResponse } from '../../infra/claude/session-reader.js';
import { selectOption, type SelectOptionItem } from '../../shared/prompt/index.js';
import { getLabel } from '../../shared/i18n/index.js';
import { info } from '../../shared/ui/index.js';
/** Maximum number of sessions to display */
const MAX_DISPLAY_SESSIONS = 10;
@ -53,6 +54,7 @@ export async function selectRecentSession(
const sessions = loadSessionIndex(cwd);
if (sessions.length === 0) {
info(getLabel('interactive.sessionSelector.noSessions', lang));
return null;
}

View File

@ -40,6 +40,7 @@ interactive:
prompt: "Resume from a recent session?"
newSession: "New session"
newSessionDescription: "Start a fresh conversation"
noSessions: "No resumable sessions were found. Starting a new session."
lastResponse: "Last: {response}"
messages: "{count} messages"
previousTask:

View File

@ -40,6 +40,7 @@ interactive:
prompt: "直近のセッションを引き継ぎますか?"
newSession: "新しいセッション"
newSessionDescription: "新しい会話を始める"
noSessions: "引き継げるセッションが見つかりませんでした。新しいセッションで開始します。"
lastResponse: "最後: {response}"
messages: "{count}メッセージ"
previousTask: