Skip to content

hide agreements page - #975

Open
jbwilson8 wants to merge 2 commits into
mainfrom
OTTER-727-hide-agreements-page
Open

hide agreements page#975
jbwilson8 wants to merge 2 commits into
mainfrom
OTTER-727-hide-agreements-page

Conversation

@jbwilson8

@jbwilson8 jbwilson8 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Jira: OTTER-727

Approach

Agreements existed in three forms — a reviewer screen (reviewer-agreements, resolved by the rule table), a reviewer route, and a researcher route — all rendering the shared agreements-page.tsx.

There's no central next/prev map: ordering lives in rule-table precedence plus hardcoded previousHref/proceedHref props on each leaf view. So this is a "splice one node out of a linked list" change — delete the reviewer rule entry, then re-point every inbound edge at whatever Agreements' own Previous/Proceed pointed at. Doing it that way preserves the OTTER-643 loop fix (reviewer Previous → /review/proposal, not /review) instead of reintroducing an agreements ⇄ code-review cycle.

Reviewer (Data Partner)

  • Removed the reviewer-agreements entry from REVIEWER_SCREEN_RULES. Its successor ['reviewer-code-review', { when: (s) => s.codeAwaitingDecision }] has the identical predicate minus the ack clause, so it absorbs that state exactly — no other rule moved. /review now resolves straight to the code-review editor.
  • Removed it from REVIEWER_CODE_SCREENS in resolve.ts, so the read-only /review/code walk-back resolves to code review too.

Research Lab (researcher)

  • /submitted's Proceed button now computes the destination Agreements' own Proceed did: /view/code once code is submitted, else /code. (Not plain /view — that would jump an advanced study straight to results.)

Inbound edges re-pointed

Edge Now targets
review/code-review.tsx Previous /review/proposal
reviewer-code-feedback-screen.tsx Previous (read-only step) /review/proposal
code/page.tsx Previous (APPROVED) /submitted
code-post-submission-view.tsx Back /submitted
code-post-decision-view.tsx Previous step /submitted
proposal-submitted.tsx Proceed /code or /view/code

Both /agreements/* routes now redirect

Rather than render, so a stale bookmark, history entry or old email link can't reach the placeholder or write an ack:

  • /agreements/reviewer/review (which runs the shared reviewer guard).
  • /agreements/researcher → the code step. Keeps its study lookup and access check, since the destination depends on code stage and the guard stops the redirect being used to probe studies the user can't see.

Deliberately retained

Per the card's "don't erase it from our code base": reviewer-agreements-screen.tsx, agreements-page.tsx, the reviewer-agreements ScreenId + its SCREEN_COMPONENTS entry, both Routes.*Agreements definitions, ackAgreementsAction, and the two *_agreements_acked_at columns. All commented as intentionally unreachable. Restoring the gate is re-adding one rule entry (plus the back-edges above).

dashboard-rules.ts is untouched — its rule only reads researcherAgreementsAcked and nothing in the AC requires changing it.

Copy change worth a look

The /submitted approved banner read "proceed to Step 3 - Agreements to sign the required legal documents" — it named the hidden page and told users to do something now impossible. Changed to "…then proceed to provide your code."

Step numbers and button labels are untouched per the card, so the button still reads "Proceed to step 3" and lands on a page headed "STEP 4". That gap will be handled in this card.

Testing

  • Added a regression guard in reviewer-screen-rules.test.ts: no rule maps to reviewer-agreements, and no state across the status × decision × ack × code-stage matrix resolves to it. The screen is retained on purpose, so absence-of-a-rule is the only thing hiding it — worth asserting directly.
  • Rewrote both /agreements/* route tests to assert the redirect target instead of the rendered placeholder.
  • Updated the screen-rule, review, code and view tests that asserted the old hrefs or the gate rendering.
  • E2E: navigateToCodeUpload loses the /agreements/researcher hop; openCodeReviewEditor loses its conditional "Proceed to Step 3" branch (removing a conditional-visibility check that could otherwise mask a regression). Noted the now-inert agreementsAcked seed flag.

Docs

docs/study-screens-logic.md: reviewer rule table renumbered (10 rows → 9), precedence notes corrected, and an OTTER-727 section recording what was removed, what was retained, and how to restore the gate.

@jbwilson8
jbwilson8 requested a review from a team August 17, 2026 22:01
@github-actions

Copy link
Copy Markdown
Contributor

👎 Total coverage is lower than the default branch

Lines Branches Functions Statements
96.29% (-0.09%) 76.58% (-0.34%) 92.70% (-0.14%) 95.56% (-0.11%)

Detailed report

8 files with a coverage regression
File Lines Branches Functions Statements
🚫 src/app/[orgSlug]/study/[studyId]/_screens/reviewer-agreements-screen.tsx 55.55% (-44.45%) 100.00% 0.00% (-100.00%) 55.55% (-44.45%)
🚫 src/app/[orgSlug]/study/[studyId]/agreements/agreements-page.tsx 39.13% (-60.87%) 0.00% (-100.00%) 0.00% (-100.00%) 39.13% (-60.87%)
src/app/[orgSlug]/study/[studyId]/agreements/researcher/page.test.tsx 100.00% (+1.13%) 100.00% 100.00% (+6.67%) 100.00% (+1.13%)
🚫 src/app/[orgSlug]/study/[studyId]/agreements/researcher/page.tsx 86.95% (-2.33%) 75.00% 100.00% 86.95% (-2.33%)
src/app/[orgSlug]/study/[studyId]/agreements/reviewer/page.tsx 100.00% (+11.12%) 100.00% (+30.00%) 100.00% 100.00% (+11.12%)
src/app/[orgSlug]/study/[studyId]/review/submitted-code-interactive.tsx 100.00% (+0.79%) 97.22% (+1.39%) 93.33% 98.54% (+0.73%)
🚫 src/app/[orgSlug]/study/[studyId]/submitted/proposal-submitted.tsx 97.67% (+0.17%) 78.26% (-2.69%) 100.00% 95.65% (+0.31%)
🚫 src/components/editable-text/collaborative-editor.tsx 88.18% (-3.94%) 68.33% (-10.00%) 72.41% (-6.90%) 84.28% (-5.72%)
🚫 src/lib/realtime/yjs-websocket-context.test.tsx 100.00% 100.00% 95.50% (-1.12%) 100.00%
🚫 src/lib/routes/definitions.ts 84.37% (-15.63%) 60.00% (-20.00%) 77.27% (-9.09%) 83.33% (-16.67%)
src/lib/study-screen/reviewer-screen-rules.ts 100.00% 100.00% 100.00% (+10.00%) 100.00%
🚫 src/server/actions/editor.actions.ts 100.00% 66.66% (-16.67%) 100.00% 100.00%

@nathanstitt nathanstitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good Jennifer, nothing major, mainly a helper and think we can drop that test

// inheriting the destination agreements' own Proceed computed: once code is submitted, the
// read-only code step — NOT plain /view, which would jump an advanced study to results.
const codeSubmitted = studyHasJobStatus(study, 'CODE-SUBMITTED')
const proceedHref = codeSubmitted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The codeSubmitted ? studyViewCode : studyCode destination (plus its near-identical why-comment) now lives both here and in agreements/researcher/page.tsx. Since both are meant to inherit exactly what the old Agreements Proceed computed, we could extract a tiny helper (e.g. a researcherCodeStepHref(study, { orgSlug, returnTo }) next to studyHasJobStatus in @/lib/studies) so the two can't drift if the code-step routing changes again. It would also be a natural home for documenting the small asymmetry on these lines: the code-submitted branch threads returnTo while the upload branch drops it (Routes.studyCode takes none).

Comment thread tests/study-flow.spec.ts
if (await proceed.isVisible().catch(() => false)) {
await proceed.click()
}
await expect(page.getByTestId('code-review-section')).toBeVisible()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice — dropping the isVisible().catch() conditional here removes exactly the kind of branch that can silently mask a regression. If the gate ever reappeared, this now fails loudly on the missing code-review-section instead of quietly clicking through it.

}
}
})
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is kinda of a crazy test. I don't think we need to test a negative, we just remove it

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.

2 participants