fix: gracefully handle empty prompts in session-init hook
When a user submits an empty or whitespace-only prompt to Claude Code,
the UserPromptSubmit hook would throw "sessionInitHandler requires prompt"
and block the operation.
This change returns early with `{ continue: true }` instead of throwing,
allowing the session to continue gracefully.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Alex Newman
parent
d333c7dc08
commit
9789a1969c
@@ -21,8 +21,9 @@ export const sessionInitHandler: EventHandler = {
|
||||
|
||||
const { sessionId, cwd, prompt } = input;
|
||||
|
||||
if (!prompt) {
|
||||
throw new Error('sessionInitHandler requires prompt');
|
||||
// Gracefully handle empty prompts (user submitted blank input)
|
||||
if (!prompt || !prompt.trim()) {
|
||||
return { continue: true, suppressOutput: true };
|
||||
}
|
||||
|
||||
const project = getProjectName(cwd);
|
||||
|
||||
Reference in New Issue
Block a user