feat(resources): render annotations on ResourceListItem#1249
Conversation
Half-finished Phase 5 spec target: ResourceListItem already used title ?? name but ignored resource.annotations entirely. Now renders audience and priority via the existing AnnotationBadge element, matching how ResourcePreviewPanel surfaces the same fields. Layout: a wrapping Group keeps the title + badges on a single line when the row is wide, and lets badges drop below when narrow. When neither annotation is present, the row renders the bare Text (no Group, no leaked spacing). Adds stories for audience-only, priority-only, both, and a ResourceTemplate with annotations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@claude review |
|
Claude finished @cliffhall's task in 2m 40s —— View job Code Review
Overall this is a clean, focused change that correctly follows the existing TypeScript Narrowing Issue
With const hasAudience = audience !== undefined && audience.length > 0; // boolean
// ...
{hasAudience && (
<AnnotationBadge facet="audience" value={audience} /> // audience is still Role[] | undefined here
)}
Compare with how {annotations?.audience && (
<AnnotationBadge facet="audience" value={annotations.audience} />
)}The simplest fix, matching {audience !== undefined && audience.length > 0 && (
<AnnotationBadge facet="audience" value={audience} />
)}
{priority !== undefined && (
<AnnotationBadge facet="priority" value={priority} />
)}This lets TypeScript narrow What's Well Done
Minor Nit
|
- Inline the audience/priority narrowing checks instead of routing through aliased booleans, matching ResourcePreviewPanel's pattern and avoiding reliance on TS aliased-condition narrowing for the inner badges. - Use a distinct resource name (settings.json) for WithAudience so the Storybook canvas reads more clearly across the four annotation stories. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the review. Pushed 3cc726a0 addressing both points. TypeScript narrowing — Applied. Aliased booleans removed; the audience and priority checks are now inline in the JSX, matching Worth noting: the original code did compile under Cosmetic nit — Applied. Validate and the 8 ResourceListItem stories still pass. |
|
@claude review |
|
Claude finished @cliffhall's task in 1m 18s —— View job Code Review
Both points from the previous review have been cleanly addressed. The PR is in good shape. TypeScript Narrowing — Resolved ✓The aliased boolean variables ( {audience !== undefined && audience.length > 0 && (
<AnnotationBadge facet="audience" value={audience} />
)}
{priority !== undefined && (
<AnnotationBadge facet="priority" value={priority} />
)}The one remaining boolean The Cosmetic Nit — Resolved ✓All four new stories use distinct resource names, making the Storybook canvas unambiguous:
Overall AssessmentThe implementation is clean and follows all project conventions:
LGTM. Ready to merge. |
* docs(agents): require version label on new issues and PRs (#1256) Recent v2 PRs (#1247, #1249, #1250, #1252, #1255) all landed without a v2 label, making version-filtered queries unreliable. Codify the expectation directly in the issue-driven workflow: each branch / board gets a fixed label, and the label is set at create time via the gh create flag rather than backfilled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Also fix stale "PR against main" line The PR-target line still said "Open a PR against main", which is correct only for v1 work. Mirror the version-label mapping above so the PR base matches the board. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes #1238.
Summary
ResourceListItemnow rendersaudienceandpriorityannotations viaAnnotationBadge, matching the pattern already used inResourcePreviewPanel. Closes the second half of the Phase 5 spec target (thetitle ?? namehalf had already landed).Groupkeeps the title and badges on one line when the row is wide and lets badges drop below the title when the container narrows. When the resource has no annotations (or only empty/undefined fields), the row renders the bareTextexactly as before — no extra elements, no leaked spacing.ResourceTemplatewith annotations.Test plan
npm run validate(format:check, lint, build) passes.npx vitest run --project=storybook src/components/groups/ResourceListItem— 8/8 stories pass.ResourcesScreen.stories.tsx > WithResourcesin dev — the sidebar list should now show badges onconfig.json(audience + priority) andpackage.json(audience), with unannotated rows unchanged.🤖 Generated with Claude Code