Skip to content

feat(portal): find and manage patches in the browser - #268

Merged
allisonmahmood merged 2 commits into
mainfrom
portal/255-portal-index-card
Sep 16, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
portal/255-portal-index-card

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

People had to find patches through shared links and use the CLI for routine management. The signed-in portal now lists the company's patches and gives members, owners and admins the appropriate card controls.

Description, sharing, rollback and restore forms check for stale state before making changes. Cards include retained versions, lifecycle notices and the shared app shell.

Stacked on portal/254-component-set via #267, not directly on main.

Closes #255.

Retire, Delete, Reassign and off-source Restore links intentionally return app-shell 404s until the follow-on confirmation pages land. This amends the unmerged 0008 migration; existing disposable dev databases need a reset, as documented.

Verification

  • Typecheck and lint pass. Final Portal/Serving tests pass: 46/46.
  • One full pnpm test run had 893 passes and four database timeouts. The three affected files passed serially, 12/12, with unchanged timeouts.
  • Verified the populated index, owner card, description save and two-tab stale refusal in the worktree dev browser. Saved both requested PNGs and checked the narrow layout.

Implemented with GPT-6 Astra in Oh My Pi.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:core Touches the core area area:docs Touches the docs area size:l 501-1,000 changed lines labels Sep 15, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 3dd7bfd5845c7855a68026adf82e8e1e489a4569 with git diff origin/portal/254-component-set...HEAD, against #255 and its referenced stale-action and portal requirements in #247. One pass, no subagents; merge blockers only.

Standards

No merge-blocking method or YAGNI findings. The new Portal package is explicitly requested, the pages use the shared shell and components, and the mutation preconditions are checked under the existing transactional patch lock.

Spec

No merge-blocking intent findings. The deferred Retire, Delete, Reassign and off-source Restore links are explicitly admitted at merge by #255 and disclosed in this PR, so their current 404 responses are not findings.

Verification: pnpm exec vitest run packages/portal/src/PortalPages.test.ts packages/serving/src/Pages.test.ts packages/serving/src/render.test.ts passed all 46 tests across 3 files. No live-instance or browser verification performed during this review.

Summary: Standards 0 blockers; Spec 0 blockers. No blocking issue on either axis.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review of #268 against #255

Issue 255 asked for the signed-in portal at /, the card at /patches/<name>, inline description/scope/rollback/restore, the versions page, and §5 stale-action refusals. The PR does that. The package seam, app-shell 404s, and admitted Retire/Delete/Reassign 404s match the ticket. The method is the small one: a portal router module, string HTML over the shared component set, hidden preconditions, last_changed_action on unmerged 0008.

What follows is a two-axis review (standards vs spec), then the method and YAGNI. The axes are separate on purpose. Passing one does not excuse the other.

Standards

Documented-standard breaches (hard):

  • packages/portal/src/render.ts:173-175. Description is a textarea.field labelled only by h3.section-heading + aria-labelledby. ui-consistency (Component set / Fields) and every other first-party form use <label class="field-label" for="…">. Clicking the heading does not focus the control. Use field-label. Keep the section heading if it names the Manage block.

  • packages/portal/src/render.ts:173-175 with PortalPages.ts:216-221. Invalid description sets aria-invalid but aria-describedby still points at field-hint. The 422 text is a page-level note-refused. Fields and notices are distinct in the component set. Device pages put the validation message in field-error and associate it. Keep note-refused for stale-action refusals.

  • packages/portal/src/render.ts:277-279. "Stop serving" is section.note.note-warn with h3.section-heading. Notices use note-title (ui-consistency, Notices; the same card's off/deleted notes already do). Replace the heading with span.note-title.

Baseline smells (judgement only; not violations):

  • Duplicated Code. PortalPages.ts:89-96 and 141-148 repeat the 32-character / isName 414/404 gate.

  • Primitive Obsession. lastChangedAction is free-form TEXT interpolated into the 409 notice (Patches.ts:1777, 1812, 1900; PortalPages.ts:213). The phrases themselves are required by §5, so a closed label type is optional.

  • Middle Man / door drift. PortalPages.ts:243-263 502/503 pageResponse calls omit Session and sign-out. SessionError has no session to pass. SqlError could.

Effect service conventions: no findings. PortalPages is a router module like AuthPages and ConnectionPages, not a Context.Service. That is the house shape.

Spec

(a) Missing or partial

  • Description field bound. Spec §9: "Description (textarea, 500, …)". The textarea has no maxlength; the hint says "Up to 500 characters". A comment at render.ts:174 explains native maxlength is UTF-16, not the server's code-point bound, and the server still 422s. Intentional, but the field does not encode the bound itself.

  • Member off card is not only state + note. Spec: "A member's off card: the state fact and the note, no Open, no acts." Members still get Owner, Current version, and Used by. Open and acts are correctly omitted. render.ts:263-284.

  • Deactivated-owner notice. Spec §9 includes "Reassign it or retire it." That sentence is dropped on off cards. render.ts:269-271.

  • sources_off 409 is not ticket 9's confirmation. Spec: "an inline restore that meets sources_off answers 409 with that page." The implementation is a warning page with no acknowledgement; "Review restore…" 404s, which the PR admits for GET. PortalPages.ts:231, render.ts:315-328.

(b) Not asked for

  • last_changed_action on unmerged 0008 (admitted; used for the §5 act phrases). packages/patches/src/migrations.ts:111.

  • Same-origin POST gate (RequireSession.sameOrigin). Not in feat(portal): the portal at / and the patch card at /patches/<name> #255. Correct for browser forms. PortalPages.ts:336-337.

  • Index extras: "N patches" count and a "No live patches" placeholder card. Spec asked for the empty live index and toggle. docs/product.md now describes the placeholder. render.ts:105-113,300-302.

  • Deleted past purgeAt: "The recovery window has ended…" instead of Restore. render.ts:220-221.

(c) Present but wrong

  • Off-card scope/rollback POSTs. Spec: "Rollback and scope on an off card are wrong_state". WrongState is mapped to the stale sentence ("This patch changed while you had this page open…") rather than naming the current state. Forms are correctly not drawn. On a page that went off while open, last_changed_action often makes the copy land right (retired by Sam). A crafted POST on an already-off card still gets the stale framing. PortalPages.ts:226-227.

Listed #255 tests (three views, retired/deleted, empty vs off-only, groups/marks, inline success + stale 409, member 403, title, index cut) are in PortalPages.test.ts. Surfaces named in #255 are updated.

Method

Acceptable, with one load-path caveat.

Birthing packages/portal matches the map. GET / lives in the server so registration order cannot steal the root (apps/server/src/Server.ts:199-221). HTML string templates over html.ts classes match Company and Auth pages. Hidden expected fields plus StaleAction is the smallest stale check. Amending unmerged 0008 is the right migration tactic on this stack. Patches.portalCard names the consumer, but the joins are patches data; putting SQL in portal would reverse the arrow.

The load path is larger than it needs to be. render always read({state:"all"}) then portalCard, and portalCard reads that patch again (PortalPages.ts:98-108, Patches.ts:1445). read also loads companyInventories for every selected id (Patches.ts:1261-1264), which the index never shows. Index needs name/state/owner/description. The card needs versions, actors, and off sources. One list query and one card query.

PortalCard.offSources duplicates ReadPatch.reads (Patches.ts:1276-1283,1450-1460). Off sources are reads.filter(r => r.state !== "live"). Drop the extra query.

Tests are focused, not slop. One it.layer + NodeHttpServer.layerTest covers the spec list.

YAGNI

Lean. One renderCard with live / manage / admin flags, not five page copies. firstClause and titleLine are the spec cuts. last_changed_action cannot be derived: sharing has no own stamp, and rolled back to v7 vs published v7 collide. Optional expected* on existing mutations is smaller than a second portal API.

Delete: unused now on renderRestoreConflict (render.ts:315-321), the extra offSources query, and the unused inventory load on index-only renders. Do not extract a page framework.

Surfaces

Hit: wire (session HTML, not HttpApi), dev loop (0008 + pnpm dev reset), vocabulary, product.md, README layout, migrator/dev/vitest spread, reverse states (restore, stale 409), repo layout, ui-consistency skill (routing ownership and first-party page kinds actually changed).

Partial: Portal Component set glossary still omits list-compact / list-link / table / copy-address (packages/portal/CONTEXT.md:43-44) while the skill and html.ts added them.

Summary

Standards: 3 hard (field label, field error association, Stop serving heading), 3 judgements. Worst: description field is not a labelled field in the component set.

Spec: 4 partial, 4 unasked (mostly admitted or harmless), 1 wrong presentation. Worst: member off cards still show Owner / version / Used by, and WrongState is shown as a stale-action sentence.

Method is the right small model. The inventory double-read is the part I would change. Code is lean, not overbuilt.

@allisonmahmood

allisonmahmood commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner Author

Review dispositions

Read both conversation reviews, the Reviews tab and inline comments. The latter two currently have no entries. Fixes are pushed in 573a862.

Fixed

  • Description label: replaced the heading-only association with a native field-label linked to the textarea. Clicking it now focuses the field.
  • Description validation: 422 errors use field-error, role="alert" and the textarea's aria-describedby. Submitted text is preserved. Stale refusals still use the page-level notice.
  • Stop serving: uses note-title, matching the shared notice contract.
  • Member off cards: their facts contain only State, with the existing off note and no Open or management acts. Owner/admin facts remain available.
  • Wrong-state refusals: name the current state while retaining the required actor/action stale notice. This matters when a description edit follows retirement: the latest act alone no longer explains why scope or rollback is refused.
  • Unused argument: removed now from renderRestoreConflict and its caller.
  • Glossary: the Component set definition now includes compact selectable lists, version tables and copyable addresses.

Kept as-is, with reasons

  • Native maxlength: the contract is 500 Unicode code points after whitespace normalization. Native maxlength counts UTF-16 units before normalization and would reject valid input. Server validation and the visible hint remain; the regression accepts 500 astral characters and rejects overlong text.
  • Deactivated-owner copy on off cards: it does not advise retiring an already retired/deleted patch. The notice and admin Reassign link remain; live cards retain the full advice.
  • Off-source confirmation: feat(portal): the portal at / and the patch card at /patches/<name> #255 explicitly admits the deferred confirmation links returning 404. The inline race still returns a separate 409 warning and performs no restore. Adding acknowledgement and forced restore would implement the next ticket, not fix this one.
  • Current-version source query: it is not equivalent to filtering ReadPatch.reads. That list includes every retained version; restore must inspect only the current version, per Portal: finding and managing patches in the deployed stage #247 §3. The existing socket regression verifies an older version's retired source is excluded.
  • Shared read/inventory load: retained the shared read model specified by Portal: finding and managing patches in the deployed stage #247 §13. Its unused inventory work and repeated card read are optimization opportunities, not correctness defects. These fixes do not introduce a separate index query or projection API without evidence that the load warrants it.
  • Repeated name validation: retained the small GET/POST boundary checks rather than introducing an abstraction solely to remove a few lines. Existing socket coverage checks 404/414 behavior.
  • Action label and migration: retained the internal text label in unmerged 0008. Actor/time stamps cannot distinguish sharing, restore, rollback and publication. A closed label type is optional; the emitted notice is escaped.
  • SQL/session error doors: retained the safe outer fallback. Portal: finding and managing patches in the deployed stage #247 §12 explicitly treats error pages as doors, and the handler sits outside the viewer provider. It should not depend on another successful viewer lookup.
  • Same-origin POST guard: retained the existing browser-form security convention. Omitting it because feat(portal): the portal at / and the patch card at /patches/<name> #255 does not repeat it would weaken the mutation boundary.
  • Index count/off-only guidance: retained. They distinguish an empty company from a company whose patches are all off, without adding search, filters or paging.
  • Expired recovery guard: retained. Portal: finding and managing patches in the deployed stage #247 §3 forbids restoring at or after purgeAt, even before the sweep runs.

Verification

  • The description accessibility, member off-card and wrong-state regressions each failed before their fix and pass afterward.
  • Final affected run: 46/46 tests across Portal HTTP, Serving HTTP and rendering. pnpm typecheck and pnpm lint pass.
  • Live worktree browser: native label focus; 501-character submission returns 422; submitted text and error association remain; stored description is unchanged. Updated notice styling checked visually. The dev instance is stopped and its impersonation session revoked.
  • Latest commit 573a862b70a758f8c366bc2d31c5701fb1c2a83d: all eight reported checks pass, including Node 22/24 tests, Postgres concurrency, Clerk live, lint, CLI smoke, dependency review and labels. CI evidence: https://github.com/allisonmahmood/patchy-cloud/actions/runs/34984514276. GitHub reports no required checks configured for this stacked base; all reported checks are green.
  • Final readiness: MERGEABLE / CLEAN against portal/254-component-set. Rechecked conversation comments, review bodies and inline comments after CI; no new findings or unresolved blockers. Not merged.

@allisonmahmood
allisonmahmood force-pushed the portal/254-component-set branch from 719aa8d to d65d618 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/255-portal-index-card branch from 573a862 to cd44643 Compare September 16, 2026 16:00
@allisonmahmood
allisonmahmood force-pushed the portal/254-component-set branch from d65d618 to 1cc2152 Compare September 16, 2026 17:00
Base automatically changed from portal/254-component-set to main September 16, 2026 17:09
Implement #255 with role-aware cards, inline lifecycle forms, stale-action preconditions, and versions pages. Keep deferred action-page 404s on the app shell.
@allisonmahmood
allisonmahmood force-pushed the portal/255-portal-index-card branch from cd44643 to a8e2b71 Compare September 16, 2026 17:09
@allisonmahmood
allisonmahmood merged commit ea4d726 into main Sep 16, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the portal/255-portal-index-card branch September 16, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:core Touches the core area area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(portal): the portal at / and the patch card at /patches/<name>

1 participant