Skip to content

Name assistant-generated images even when the plan omits "alt" - #203

Merged
davior merged 1 commit into
mainfrom
claude/wizardly-dijkstra-5l227x
Oct 7, 2026
Merged

davior merged 1 commit into
mainfrom
claude/wizardly-dijkstra-5l227x

Conversation

@davior

@davior davior commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Problem

Images the assistant generates were showing up in the Assets tab by their UUID filename (022b8a9a-…jpg) instead of a readable name.

Generated files are stored on disk as {uuid}{ext}. The only readable label they get is the image block's name prop, which sync_note_assets copies into NoteAsset.original_name, and the Assets tab shows title or original_name or filename. The executor filled name only from the plan's optional alt field, so any plan without alt left every image named by its UUID.

#202 (per-paragraph placement) added a "Placing blocks" example to the planner prompt that lists section / anchorText / position but no alt, and the image rule only said "Optionally set alt". Batch image plans that follow that example (for example, "an image above every paragraph") come out with no names.

Changes

  • backend/app/assistant/executor.py: new image_name(alt, prompt). It uses alt when the plan gives one. Otherwise it takes the image prompt's first sentence, cut at a word boundary to 60 characters. Every generated image block now carries a name.
  • frontend/src/services/aiPlan.ts: the planner prompt now asks for alt on every image as a 3–8 word title, and the per-paragraph example includes it. The parser still treats alt as optional.
  • Tests: four new executor tests: name from alt, name taken from the prompt, cutting a long prompt, and an end-to-end check that the NoteAsset row gets the name. On the old code, the two fallback tests fail with '' == … and None == ….

Not covered

  • Images already registered without a name keep their UUID label, because the blocks have no name or caption to backfill from. They can be renamed in the Assets tab.
  • The manual "Generate image" modal still inserts images with no name or caption. That has always been the case, so this PR leaves it alone.

Testing

  • pytest tests/test_assistant_executor.py: 62 passed
  • vitest run src/services/aiPlan.test.ts: 26 passed
  • tsc --noEmit: clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01RSFoSnyUt5dnN1eCnBqi6M


Generated by Claude Code

Generated images are stored on disk as {uuid}{ext}; the only human-readable
label they get is the image block's `name`, which sync_note_assets copies into
the asset row the Assets tab lists. The executor filled that name from the
plan's optional "alt" and nothing else, so a plan without it registered every
image under its UUID.

The per-paragraph placement example added to the planner prompt showed
section/anchorText/position but no "alt", and "alt" was only ever "optionally"
asked for, so batch image plans that followed it came out nameless.

- The executor now falls back to the image prompt's first sentence, cut at a
  word boundary to 60 chars, when "alt" is missing or blank.
- The planner prompt asks for "alt" on every image (a 3-8 word title) and the
  per-paragraph example includes it.

Images already registered without a name keep their UUID label; they can be
renamed from the Assets tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RSFoSnyUt5dnN1eCnBqi6M
@davior
davior marked this pull request as ready for review October 7, 2026 01:32
@davior
davior merged commit e8b4ba6 into main Oct 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants