Skip to content

476 extend assignment indicator to reflect current stage assignee - #502

Merged
B3RN153 merged 3 commits into
mainfrom
476-extend-assignment-indicator-to-reflect-current-stage-assignee
Sep 11, 2026
Merged

476 extend assignment indicator to reflect current stage assignee#502
B3RN153 merged 3 commits into
mainfrom
476-extend-assignment-indicator-to-reflect-current-stage-assignee

Conversation

@B3RN153

@B3RN153 B3RN153 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

TLDR

Makes the chapter list's ownership icon stage-aware — it now shows the assignee relevant to the item's current stage (drafter at Drafting, PM-assigned peer checker at Peer Check, nothing at Community Review/Advanced/Complete) instead of always reading Drafting's assigned_user_id. Also fixes a pre-existing bug where the conflict icon and ownership icon could render simultaneously in the same slot.

Reviewer checklist

  • GitHub issue linked in Details (Refs #NNN)
  • How to verify steps completed
  • Acceptance criteria met
  • Scope limited to this issue — see scope-expansion note below (conflict-icon precedence fix)
  • Needs QA? decided

Details

Refs #476

deriveChapterOwnershipState previously took only assigned_user_id, so it always evaluated Drafting's assignee regardless of the item's actual stage. Added resolveStageAssigneeId to pick the correct field (assigned_user_id at Drafting, peer_checker_id at Peer Check, null otherwise) before handing off to the existing three-state derivation. peer_checker_id wasn't previously selected by the two list queries (getProjectChapters, getMyWorkChapters) — only by the single-record getChapterAssignmentById — so it's now added to both.

Peer Check items with no peer_checker_id show no icon. This is consistent with #442's open-Peer-Check model once that ships, but #476 has no functional dependency on #442 — the null-check works correctly against today's data regardless of #442's status.

Scope expansion: While implementing this, found ChapterConflictIndicator (#260) and ChapterOwnershipIndicator rendering as two independent, unconditional elements in both MyWorkRow and ProjectChapterRow — no actual precedence existed, despite this ticket's own NFR assuming conflict "continues to take precedence in the same slot." Since #476 makes the ownership icon appear in more cases (any Peer-Check item with a PM-assigned checker), the collision becomes more likely, so fixed it as part of this PR: conflict and ownership now render as a single ternary per row, conflict wins. This also required updating two existing tests (renders indicators in the shared cloud, conflict, ownership order) that had encoded the old dual-render bug as expected behavior.

Needs QA?

  • No
  • Yes — post-merge nightly QA

Type of change:

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Maintenance / refactor

Technical changes

  • src/utils/chapterOwnershipState.ts — added resolveStageAssigneeId(status, assignedUserId, peerCheckerId); existing deriveChapterOwnershipState unchanged.
  • src/db/queries.ts — added ca.peer_checker_id to getProjectChapters and getMyWorkChapters SELECTs; mapChapterRowCore now calls resolveStageAssigneeId before deriveChapterOwnershipState.
  • src/types/db/types.ts — added peer_checker_id to ProjectChapterRow and MyWorkChapterRow.
  • src/components/ui/MyWorkRow.tsx, src/components/ui/ProjectChapterRow.tsx — conflict/ownership icon precedence fixed to a single ternary (scope expansion, see above).
  • src/utils/chapterOwnershipState.test.ts — coverage for all resolveStageAssigneeId branches (Drafting with/without assignee, Peer Check with/without PM assignment, no-assignee stages, unrecognized/null status).
  • src/components/ui/MyWorkRow.test.tsx, src/components/ui/ProjectChapterRow.test.tsx — replaced the outdated dual-render assertion with precedence-focused tests (conflict wins when both apply; ownership shows when no conflict).

Testing

npm run format:check && npm run lint && npm run typecheck && npm test -- --ci — all passing except a pre-existing, unrelated flaky timeout in usePrepareOfflineDownload.test.ts (not touched by this PR).

How to verify

  1. npm run format:check && npm run lint && npm run typecheck && npm test -- --ci
  2. On device: seed chapters at each stage (Drafting assigned/unassigned, Peer Check with/without PM-assigned checker, Community Review, Complete) and confirm icon presence/state matches the AC table in Extend Assignment Indicator to Reflect Current-Stage Assignee #476.
  3. Seed one chapter with both a stage assignee and has_conflict = true; confirm only the conflict icon renders, not both.

Expected: Icon reflects the current-stage assignee only; no icon past Peer Check; conflict icon always wins when both conditions are true.

Follow-ups

  • Mobile's internal community_check label vs API's community_review status value is a naming-only mismatch in STAGE_BY_STATUS — functionally correct today, no ticket filed yet, tracked verbally with team.
  • getChapterAssignmentsWithBooks / ChapterListItem confirmed dead code (grep shows zero call sites beyond their own definitions) — left untouched here for scope discipline; candidate for a separate cleanup PR.

Summary by CodeRabbit

  • Bug Fixes
    • Conflict indicators now take precedence over ownership indicators, preventing both from appearing simultaneously.
    • Chapter ownership is now assigned to the appropriate person based on workflow stage, including peer check assignments.
    • Ownership indicators now more accurately reflect the chapter’s current workflow status.

Extend Assignment Indicator to Reflect Current-Stage Assignee
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c1fd4cf3-c88c-4891-a976-6967f6e2b4e4

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8fa5f447-6a92-40e2-9ecb-fc51ea3e2973

📥 Commits

Reviewing files that changed from the base of the PR and between c39799d and 6af2f5d.

📒 Files selected for processing (8)
  • src/components/ui/MyWorkRow.test.tsx
  • src/components/ui/MyWorkRow.tsx
  • src/components/ui/ProjectChapterRow.test.tsx
  • src/components/ui/ProjectChapterRow.tsx
  • src/db/queries.ts
  • src/types/db/types.ts
  • src/utils/chapterOwnershipState.test.ts
  • src/utils/chapterOwnershipState.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Chapter ownership now resolves from the workflow stage and the relevant assignee. Project and My Work queries fetch peer-checker data. Chapter rows show either the conflict indicator or the ownership indicator, with tests covering both states.

Changes

Chapter ownership behavior

Layer / File(s) Summary
Stage-specific ownership resolution
src/utils/chapterOwnershipState.ts, src/utils/chapterOwnershipState.test.ts
Adds resolveStageAssigneeId for drafting and Peer Check stages, with coverage for assigned, unassigned, and unsupported states.
Chapter query ownership data
src/db/queries.ts, src/types/db/types.ts
Passes chapter status and peer-checker assignments into ownership resolution. Project and My Work rows now include peer_checker_id.
Conflict and ownership indicators
src/components/ui/MyWorkRow.tsx, src/components/ui/MyWorkRow.test.tsx, src/components/ui/ProjectChapterRow.tsx, src/components/ui/ProjectChapterRow.test.tsx
Renders the conflict indicator when a conflict exists and the ownership indicator otherwise. Tests verify both render states.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 6af2f

Stage-aware ownership and conflict indicator behavior are covered across the updated utility, queries, components, and tests; no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 8 files. 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 summarizes the main change: updating the assignment indicator to reflect the current stage assignee.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 476-extend-assignment-indicator-to-reflect-current-stage-assignee

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.

@B3RN153

B3RN153 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@B3RN153
B3RN153 enabled auto-merge (squash) September 11, 2026 08:36

@JonathanSeehagen JonathanSeehagen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@B3RN153, good job here. Tested on device. AI-assisted review.

Stage-aware icon and conflict-wins-the-slot both work as specified in #476.

@B3RN153
B3RN153 merged commit 0183cfb into main Sep 11, 2026
15 checks passed
@B3RN153
B3RN153 deleted the 476-extend-assignment-indicator-to-reflect-current-stage-assignee branch September 11, 2026 21:53
@B3RN153 B3RN153 linked an issue Sep 13, 2026 that may be closed by this pull request
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.

Extend Assignment Indicator to Reflect Current-Stage Assignee

2 participants