Skip to content

fix(server): resolve section-style step image names (Recipe.S.N.ext) - #388

Merged
dubadub merged 1 commit into
mainfrom
fix/section-step-images
Aug 6, 2026
Merged

dubadub merged 1 commit into
mainfrom
fix/section-step-images

Conversation

@dubadub

@dubadub dubadub commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the step-image naming discrepancy between the CLI server and the iOS app (#374).

cooklang-find's StepImageCollection already indexes both conventions — Recipe.N.ext (step N counted continuously across sections) at section bucket 0, and Recipe.S.N.ext (section S, step N within it, as used by the iOS app) at bucket S-1. But the web builder only ever queried get(0, continuous_step), so section-style names never resolved.

The builder now tries the section-specific lookup first and falls back to the continuous one:

entry.step_images()
    .get(section_index + 1, step_count + 1)
    .or_else(|| entry.step_images().get(0, total_steps + step_count + 1))

Both conventions now work in cook server and cook build web (they share this builder), and the section-specific image wins when both exist for the same step. Backward compatible — existing linear-named collections resolve exactly as before (for section 1 the two lookups are identical, since cooklang-find stores section 1 and linear names in the same bucket).

Fixes #374

Testing

New integration test tests/step_images_test.rs covering a two-section recipe (written first, confirmed red):

  • linear names Linear.1.jpg/Linear.2.jpg resolve across sections (passed before the fix)
  • section names Sectioned.1.1.jpg/Sectioned.2.1.jpg resolve per section (failed before, passes now)
  • when both exist, the section-specific image wins

cargo fmt, cargo clippy, and the full cargo test suite pass cleanly.

Step images were only looked up as Recipe.N.ext with N counting steps
continuously across sections, so images named with the section
convention used by the iOS app (Recipe.S.N.ext) never appeared.
cooklang-find already indexes both conventions; try the
section-specific name first and fall back to the continuous one, so
recipe collections written for either app render step images in both.

Fixes #374
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.

image title scheme discrepancy between cli server and ios app

1 participant