Skip to content

feat(preview): let the atlas resolve a proposal's relationships without reading user-submissions - #816

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/feat-814-preview-images-region
Sep 18, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/feat-814-preview-images-region

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • previewEvent.images now carries image documents (url, alt) in the editor's order, so the atlas widget no longer re-resolves them by hand.
  • A new-event proposal's preview now names the region Accept will write, instead of showing none.
  • Option 1 from the ticket. Option 2 needs two access relaxations, not one, and reopens feat(api)!: unified intake, phase 1 — the user-submissions schema #723.

Changes

  • src/lib/utilities/eventImages.ts — new. readEventImages plus IMAGE_SELECT, lifted out of the atlas SEO endpoint, which now calls it too. EventImage types the four-field projection, so no caller can read a field the select never asked for.
  • src/collections/UserSubmissions/lifecycle/mergeProposal.ts — submissionRegionId, the one statement of region ?? regionHint.anchorRegion. applyReview now calls it.
  • src/collections/UserSubmissions/hooks/computeReviewFields.ts — the preview resolves images after the merge, and states its contract in the docblock.

Preview

  • Proposal review queue — open a proposal targeting an event that has photographs; the Live Preview panel should render them
  • Events list — to find or give a target event some photos first

Contract impact

previewEvent is the atlas widget's only view of a merged proposal — it holds create-only on user-submissions (#723). SahajAtlasWeb#212 can now delete getImages / imagesQuery and the resolveImages half of src/lib/live-preview/submission.ts. resolveRegion stays: it reads the region tree the widget already holds, and costs no network read. No SahajCloud type or endpoint shape changed, so no types:cms resync is needed.

Test results

  • Lean gate: ✓ lint, tsc --noEmit (src + tests), 2133 unit tests
  • Targeted specs: user-submissions-review-lifecycle 21 passed, user-submissions-access 8 passed, atlas-seo 53 passed (it shares the lifted reader)
  • Build: N/A — Railway builds the preview

Manual verification

  1. Open a proposal targeting an event with photographs and confirm the Live Preview panel renders them.
  2. Open a new-event proposal and confirm the preview names the region screening resolved.
  3. Confirm a reviewer's Proposed Changes table reads exactly as it did — no new Region row, no populated relationship rendered by name.

Notes for reviewer

  • The one judgement call: proposedChanges is deliberately untouched. submissionRegionId sits outside newEventDefaults for that reason — inside the merge it would add a Region line to every new-event diff. So two of the three consumers of the merge now name the region and the diff still does not, and the merge banner records that exception. The adversarial-review pass argued for the deeper version (region in newEventDefaults, applyReview dropping its post-patch override); it needs a resolveRegion load to avoid printing Region: 12, and it trips the ticket's "reads the same for a reviewer" criterion. Worth a follow-up ticket if you want it.
  • The images read is not the SEO read's access. readEventImages takes access explicitly at both call sites: the endpoint reads as its client on the caller's request, the field hook reads committed state on its own connection (a projection that joins the caller's transaction aborts the write it decorates — Event submissions: judge a proposal, don't edit a copy #641).
  • All three new assertions were watched fail with the defects reintroduced. The ordering assertion is the exception and is called out below.
Detail

Why images resolve after the merge. loadTargetEvent is shared with computeProposedChanges through the request memo, so raising its depth would make the diff render relationships by name instead of by row id. The preview resolves its own ids instead, and a spec pins previewEvent.region as a bare number so that stays true.

A missing id drops out. The widget parses each entry against EventImageSchema, and the array has .default([]) — one bare number would fail the whole array, costing the preview every photograph rather than the missing one.

Open question answered. A populated image satisfies EventImageSchema with no further shaping: url is virtual and derived from filename, so IMAGE_SELECT co-selects filename. Without that co-select the preview would ship url: null and the photos would vanish silently. The spec asserts a non-null url on every entry.

The ordering assertion is correct but was not watched fail. Removing the order restore in readEventImages left the spec green — Postgres answered id in (…) in the listed order for that fixture. The ordering contract is pinned bidirectionally in tests/int/atlas-seo.int.spec.ts instead, and the new spec lists the highest id first so a regression would still show. The comment says exactly this rather than claiming a guard it does not have.

Fixture pre-mortem. The spec assumes images on Events is an ordered hasMany upload to the images collection, and that an image created by testData.createImage has a filename. Verified against src/collections/Events/Events.ts:314-321, src/collections/Images/Images.ts:66 (the virtualUrlField), and tests/utils/testData.ts:210-229.

Security review: skipped. No changed path matches securityReview.triggerPattern. The one access-carrying line — the SEO endpoint's overrideAccess: false plus req — is preserved verbatim, and atlas-seo.int.spec.ts covers it.

Not fixed here. docs/rules/endpoints.md:156 states the co-select rule that IMAGE_SELECT exists for; nothing there went stale.

Closes #814

🤖 Generated with Claude Code

https://claude.ai/code/session_013gcsNaBDXJ2RhJeFhhDvaS

The atlas widget holds create-only on `user-submissions` (#723), so it can
never read a merged event's relationships back for itself. `previewEvent` is
the only transport, and it was handing over two things the widget could not
use.

**Photographs.** `images` came through as row ids, so SahajAtlasWeb#212 had to
re-resolve them by hand from the posted message. They are resolved here
instead, after the merge. Not by raising `loadTargetEvent`'s depth:
`computeProposedChanges` shares that load through the request memo, and a
populated relationship renders there by name rather than by row id, which would
change the reviewer's diff. The diff is untouched, and a spec pins `region`
as a bare id so it stays that way. An id that no longer resolves is dropped —
the widget parses each entry against a schema, so one bare number would cost
the preview every photograph rather than the missing one.

**Region.** `newEventDefaults` sets none, while Accept writes
`region ?? regionHint.anchorRegion`. So a new-event proposal previewed without
the region screening had resolved, and then Accept wrote one — the preview
disagreeing with the write, which is the failure `mergeProposal` exists to
prevent. The new-event branch now carries it, by the same fallback order.

A new-event proposal can never show photographs at all: `images` is in
`PRIVILEGED_FIELDS`, so only a target event supplies them. The docblock now
states all three facts, since they are what a consumer may rely on.

All three assertions were verified red with the defects reintroduced.

Closes #814

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013gcsNaBDXJ2RhJeFhhDvaS
Four review lenses over the branch diff. Both findings were the same shape —
a rule written twice, kept in step by a comment.

`resolveImages` was a line-for-line copy of the atlas SEO endpoint's
`readImages`, down to the `byId` map that restores the editor's order. Both now
call `readEventImages` (`src/lib/utilities/eventImages.ts`), which also carries
`IMAGE_SELECT`. That select is the part worth sharing: `url` is virtual and
reads `filename`, so a select naming `url` alone yields `null` and the photo
silently disappears. The preview had no select at all and hydrated every column
for two fields. `access` is spelled out at each call site, because the callers
need opposite things — the endpoint reads as its client on the caller's
request, the projection reads committed state on its own connection.

The region fallback was a verbatim second copy of `applyReview`'s, promising by
comment to stay in step with it. `submissionRegionId` is now the one statement,
in `mergeProposal.ts` beside `newEventDefaults` — deliberately outside the
merge itself, since in the merge it would add a Region line to every new-event
diff and `proposedChanges` is meant to read exactly as it did.

Also from the pass: the preview's image load joins the per-request memo, which
every other load in that file already uses and `applyReview` needs — it reads
the row and then updates it on one request, running the hook twice.
`previewEvent.images` is asserted absent rather than `?? []`, which passed for
three different values.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013gcsNaBDXJ2RhJeFhhDvaS
`src/AGENTS.md` enumerates every helper in `src/lib/utilities/`, and the list
decides where the next reader looks for one.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013gcsNaBDXJ2RhJeFhhDvaS
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-816 September 18, 2026 02:11 Destroyed
@railway-app

railway-app Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-816 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 18, 2026 at 2:39 am UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot

sydevs-bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 02:31Z address-review · attempt 1 · session · done
  • 02:31Z address-review · attempt 1 · session
  • 02:23Z adversarial-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🧐 Adversarial review

The diff is the size of its ticket and no larger. Option 1 is the right call. readEventImages earns its new file: two callers, and the ordering rule now has one home instead of two. The consumer already accepts the shape — SahajAtlasWeb#212 parses images as z.union([z.number(), EventImageSchema]) and passes a non-number entry through, so populated docs land there today and previewImageIds returns nothing.

Findings

  • should-fix — eventImages.ts:39 types a four-field projection as the full Image.
  • consider — the region rule now has two of three consumers; proposedChanges stays silent.

What was checked

Read whole: computeReviewFields.ts, mergeProposal.ts, review.ts, eventImages.ts, requestMemo.ts, the SEO call site, submission.ts plus types/event.ts on SahajAtlasWeb#212. applyReview still spreads region: regionId after the patch, so the new-event preview mirrors the write order. The select and the order restore moved verbatim.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/lib/utilities/eventImages.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 18, 2026
`readEventImages` selects four fields and promised a whole `Image`, so
`image.createdAt` typechecked and was `undefined` at runtime. `EventImage`
names what `IMAGE_SELECT` actually returns, the way `eventCard` types its own
projection as a `Pick<Event, …>`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XVt38gWWy5xKZYsp1k5Sac
The banner says one merge serves three consumers. The region is the one field
two of them name and the diff does not, and the exception was stated only at
`submissionRegionId`, where a reader arrives after the claim.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XVt38gWWy5xKZYsp1k5Sac
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-816 September 18, 2026 02:37 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review. Pushed 760a860.

Lean gate green, plus user-submissions-review-lifecycle (21) and atlas-seo (53).

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 18, 2026 02:46
@sydevs-bot
sydevs-bot requested a review from Ardnived September 18, 2026 02:46
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit 2145405 Sep 18, 2026
33 of 35 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-814-preview-images-region branch September 18, 2026 18:33
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Sep 18, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-816 — 760a860f Deployed Sep 18, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(preview): let the atlas resolve a proposal's relationships without reading user-submissions

3 participants