MAESTRO: Fix image-only prompts skipping session init (PR #928 concept)

Image-only prompts have empty text content, causing session-init handler
to skip session creation entirely. Use '[media prompt]' placeholder so
sessions still get created and tracked in memory.

Closes PR #928 (applied directly due to merge conflicts with outdated base).
Credit: @iammike for identifying the issue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-05 23:47:12 -05:00
parent 3eb0154d58
commit 576d407c00
2 changed files with 6 additions and 6 deletions
+2 -1
View File
@@ -12,7 +12,8 @@ These PRs all touch `src/cli/handlers/session-init.ts` — review together to av
- [x] Review PR #829 (`fix: gracefully handle empty prompts in session-init hook` by @rajivsinclair). File: `src/cli/handlers/session-init.ts`. Steps: (1) `gh pr checkout 829` (2) Review — empty prompt should result in valid exit (not crash) (3) Small change, low risk (4) Run `npm run build` (5) If clean: `gh pr merge 829 --rebase --delete-branch`
- **CLOSED AS REDUNDANT** (2026-02-05): The empty prompt handling fix (`!prompt || !prompt.trim()``return { continue: true, suppressOutput: true }`) was already merged as part of PR #828 (commit 9789a196). Main branch already has this fix at `src/cli/handlers/session-init.ts` lines 24-27. No action needed.
- [ ] Review PR #928 (`Fix: Allow image-only prompts in session-init handler` by @iammike). File: `src/cli/handlers/session-init.ts`. Image-only prompts have no text content, causing the handler to reject them. Steps: (1) `gh pr checkout 928` (2) Review — should check for content blocks (images) not just text (3) Run `npm run build` (4) If clean: `gh pr merge 928 --rebase --delete-branch`
- [x] Review PR #928 (`Fix: Allow image-only prompts in session-init handler` by @iammike). File: `src/cli/handlers/session-init.ts`. Image-only prompts have no text content, causing the handler to reject them. Steps: (1) `gh pr checkout 928` (2) Review — should check for content blocks (images) not just text (3) Run `npm run build` (4) If clean: `gh pr merge 928 --rebase --delete-branch`
- **CLOSED — FIX APPLIED ON MAIN** (2026-02-05): PR was based on outdated code (pre-#828 refactor) and would have merge conflicts. The concept was valid: image-only prompts had empty text causing session init to be skipped entirely, losing memory tracking. Applied the fix directly on main at `src/cli/handlers/session-init.ts` lines 22-26: empty/undefined prompts now use `[media prompt]` placeholder instead of returning early, so sessions are still created and tracked. Build passes. Credit to @iammike for identifying the issue (#927).
- [ ] Review PR #932 (`fix: prevent duplicate generator spawns in handleSessionInit` by @jayvenn21). File: `src/services/worker/http/routes/SessionRoutes.ts`. Steps: (1) `gh pr checkout 932` (2) Review idempotency guard — should check if generator already exists before spawning (3) Run `npm run build` (4) If clean: `gh pr merge 932 --rebase --delete-branch`
+4 -5
View File
@@ -19,12 +19,11 @@ export const sessionInitHandler: EventHandler = {
return { continue: true, suppressOutput: true, exitCode: HOOK_EXIT_CODES.SUCCESS };
}
const { sessionId, cwd, prompt } = input;
const { sessionId, cwd, prompt: rawPrompt } = input;
// Gracefully handle empty prompts (user submitted blank input)
if (!prompt || !prompt.trim()) {
return { continue: true, suppressOutput: true };
}
// Handle image-only prompts (where text prompt is empty/undefined)
// Use placeholder so sessions still get created and tracked for memory
const prompt = (!rawPrompt || !rawPrompt.trim()) ? '[media prompt]' : rawPrompt;
const project = getProjectName(cwd);
const port = getWorkerPort();