Skip to content

feat(sections): allow row image style selection - #338

Closed
raiden202 wants to merge 3 commits into
Silo-Server:mainfrom
raiden202:pr/sections-card-image-style
Closed

raiden202 wants to merge 3 commits into
Silo-Server:mainfrom
raiden202:pr/sections-card-image-style

Conversation

@raiden202

@raiden202 raiden202 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

feat(sections): allow row image style selection

Problem

Section rows on the web client have always rendered portrait posters. Some sources (network row, "Trending" row, editorially curated backdrops) look better as 16:9 landscape cards, but there was no way to choose per-row and no plumbing between the server section descriptor and the client card component.

Approach

Introduce a small enum abstraction and thread it through the section pipeline without changing existing behavior:

  • Add a CardImageStyle type (Auto | Portrait | Landscape) in the existing internal/sections package, with Parse/String helpers. Auto is the default and preserves current portrait rendering, so any section that omits the new field is unchanged.
  • SectionDescriptor API responses gain an optional card_image_style field (omitempty) so old clients keep working.
  • Web SectionRow picks the variant per row via a new sectionCardImageStyle.ts helper; SectionItemCard renders aspect-video when landscape is requested, otherwise the existing 2:3 poster path.
  • Admin UI: the section editor drawer gains a "Card style" selector so the choice is persisted alongside the row definition.

Verification

  • go test ./internal/sections/... ./internal/api/handlers/ -run 'CardImage|Section' — passes.
  • Manual: existing sections with no card_image_style continue to render as portrait posters; new rows configured landscape render 16:9 without card component regressions.

Risks & follow-up

  • Portrait behavior is preserved because the zero value maps to Auto and Auto falls through to the previous portrait path.
  • No storage migration or backfill: the new field is API-only and derived per-request from the section definition.
  • Follow-up (PR B) stores rendered landscape card artwork to avoid depending on unbranded backdrops at render time.

AI-use disclosure

Implemented with a combination of Claude Code and Codex assistance, with human oversight.

Summary by CodeRabbit

  • New Features
    • Added configurable section “Row Images” with Automatic, Portrait, and Landscape options.
    • Updated section layout responses to expose card_image_style and drive row/card rendering accordingly.
  • Bug Fixes
    • Home and library layout refresh/reset now correctly react when card_image_style changes.
    • Row rendering respects cardImageStyle overrides (e.g., portrait vs landscape).
  • Tests
    • Added unit/integration coverage for parsing, validation, response payloads, and landscape/portrait row rendering.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5be268d6-8c93-4e31-9f55-fb81e43660f3

📥 Commits

Reviewing files that changed from the base of the PR and between 8bed58f and f709faf.

📒 Files selected for processing (15)
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_test.go
  • internal/sections/card_image_style.go
  • internal/sections/card_image_style_test.go
  • web/src/api/types.ts
  • web/src/components/SectionItemCard.test.tsx
  • web/src/components/SectionItemCard.tsx
  • web/src/components/SectionRow.test.tsx
  • web/src/components/SectionRow.tsx
  • web/src/components/sections/EditableSectionRows.tsx
  • web/src/components/sections/SectionEditorDrawer.test.ts
  • web/src/components/sections/SectionEditorDrawer.tsx
  • web/src/lib/sectionCardImageStyle.ts
  • web/src/pages/Home.tsx
  • web/src/pages/LibraryRecommended.tsx
🚧 Files skipped from review as they are similar to previous changes (15)
  • internal/sections/card_image_style_test.go
  • web/src/components/sections/SectionEditorDrawer.test.ts
  • web/src/components/sections/EditableSectionRows.tsx
  • web/src/pages/LibraryRecommended.tsx
  • web/src/components/SectionItemCard.test.tsx
  • web/src/pages/Home.tsx
  • web/src/lib/sectionCardImageStyle.ts
  • internal/sections/card_image_style.go
  • web/src/api/types.ts
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_test.go
  • web/src/components/SectionItemCard.tsx
  • web/src/components/SectionRow.test.tsx
  • web/src/components/SectionRow.tsx
  • web/src/components/sections/SectionEditorDrawer.tsx

📝 Walkthrough

Walkthrough

Adds a card_image_style configuration option with auto, portrait, and landscape handling across backend validation, API responses, frontend card rendering, page wiring, and section editing.

Changes

Card Image Style Feature

Layer / File(s) Summary
Backend style contract and parsing
internal/sections/card_image_style.go, internal/sections/card_image_style_test.go
Defines supported styles, normalization, defaults, invalid-value handling, and parser tests.
API validation and response propagation
internal/api/handlers/sections.go, internal/api/handlers/sections_test.go
Validates section configuration and exposes card_image_style in layout and resolved-section responses.
Frontend style contract and utilities
web/src/api/types.ts, web/src/lib/sectionCardImageStyle.ts
Adds response types and helpers for reading, applying, and labeling image styles.
Portrait and landscape card rendering
web/src/components/SectionRow.tsx, web/src/components/SectionItemCard.tsx, web/src/components/*test.tsx
Resolves styles, selects assets and aspect ratios, renders landscape overlays, and updates card variants.
Layout style propagation
web/src/pages/Home.tsx, web/src/pages/LibraryRecommended.tsx
Passes layout styles to rows and includes them in layout reset keys.
Section editor persistence and badges
web/src/components/sections/SectionEditorDrawer.tsx, web/src/components/sections/SectionEditorDrawer.test.ts, web/src/components/sections/EditableSectionRows.tsx
Adds the Row Images selector, save-payload persistence, and configured-style badges.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SectionEditorDrawer
  participant SaveHelpers
  participant SectionHandler
  participant HomeOrLibrary
  participant SectionRow
  participant SectionItemCard

  SectionEditorDrawer->>SaveHelpers: save selected cardImageStyle
  SaveHelpers->>SectionHandler: submit config with card_image_style
  SectionHandler->>SectionHandler: validate with ParseCardImageStyle
  SectionHandler-->>HomeOrLibrary: return layout card_image_style
  HomeOrLibrary->>SectionRow: pass cardImageStyle
  SectionRow->>SectionItemCard: pass imageStyle
  SectionItemCard->>SectionItemCard: render portrait or landscape card
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding row image style selection for sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@raiden202
raiden202 force-pushed the pr/sections-card-image-style branch 3 times, most recently from dba04ba to 691125d Compare July 9, 2026 19:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/components/SectionItemCard.tsx`:
- Around line 83-99: The landscape overlay in SectionItemCard is decorative and
should be hidden from assistive tech to avoid duplicate announcements. Update
the conditional overlay container used for the logo/title fallback so it is
marked aria-hidden="true" for both branches, keeping the existing image and
title display behavior intact while preventing screen readers from reading the
overlay copy twice.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d5f9672-7cd0-4229-b428-46907ea7854c

📥 Commits

Reviewing files that changed from the base of the PR and between 2b243ab and 691125d.

📒 Files selected for processing (15)
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_test.go
  • internal/sections/card_image_style.go
  • internal/sections/card_image_style_test.go
  • web/src/api/types.ts
  • web/src/components/SectionItemCard.test.tsx
  • web/src/components/SectionItemCard.tsx
  • web/src/components/SectionRow.test.tsx
  • web/src/components/SectionRow.tsx
  • web/src/components/sections/EditableSectionRows.tsx
  • web/src/components/sections/SectionEditorDrawer.test.ts
  • web/src/components/sections/SectionEditorDrawer.tsx
  • web/src/lib/sectionCardImageStyle.ts
  • web/src/pages/Home.tsx
  • web/src/pages/LibraryRecommended.tsx

Comment thread web/src/components/SectionItemCard.tsx Resolved
@raiden202
raiden202 force-pushed the pr/sections-card-image-style branch 2 times, most recently from 86c7b47 to ca617c1 Compare July 16, 2026 08:23
@raiden202
raiden202 force-pushed the pr/sections-card-image-style branch from ca617c1 to 8bed58f Compare July 23, 2026 11:46
@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 23, 2026
Silo Contributor and others added 3 commits July 23, 2026 19:27
(cherry picked from commit 0e893c7782a34dae1733740a2bc01cf8397548d6)
(cherry picked from commit 36f5f6a664c88aebb323d1a637a6f6a4dbeab41f)
@raiden202
raiden202 force-pushed the pr/sections-card-image-style branch from 8bed58f to f709faf Compare July 23, 2026 23:28
@coderabbitai coderabbitai Bot removed the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 23, 2026
@raiden202

Copy link
Copy Markdown
Contributor Author

Closing because we are dropping the server-controlled section portrait/landscape feature rather than maintaining it downstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant