Repository navigation
feat(web): encryption key guard, copy-link buttons, lucide icons, deterministic member ordering - #37
Conversation
…ink buttons Opening an encrypted group without the #key= fragment now shows "Encryption key missing" instead of the generic "Something went wrong." This covers two cases: encrypted data already exists (decryption throws → error boundary catches it) and no data yet (early guard in PersonApp prevents silent plaintext writes). Adds a "Copy my link" button on idle screens (/pending, /waiting, /invite, /results) for encrypted groups so users can save their full URL for another device. The admin's own link is now shown first on the "You're all set" setup completion screen for all groups (encrypted and plaintext). Extracts buildPersonLink() helper in crypto.ts to replace three duplicated link-building patterns. Adds data-testid="partner-link" to distinguish partner link inputs from the admin's own link input in E2E selectors. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…ly no-oping Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Adds lucide-react and replaces all 6 hand-drawn inline SVGs with
named icon components (Link, Check, Pencil, ChevronLeft, ChevronRight).
All icons use strokeWidth={1.5} to match the existing visual weight.
Documents the convention in CLAUDE.md: always use lucide-react for
icons, never write inline <svg> by hand.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/web/src/screens/GroupSetup.tsx (1)
106-155:⚠️ Potential issue | 🟡 MinorPrevent earlier copy timers from clearing newer button feedback.
These buttons share one
useCopy()instance. Right now each click schedules its own reset timer, so copying one link and then another within the 2s window lets the first timer clear the second button’s"Copied!"state early.🛠 Suggested fix in
packages/web/src/lib/use-copy.ts-import { useCallback, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; export function useCopy(resetMs = 2000) { const [copiedIndex, setCopiedIndex] = useState<number | null>(null); + const resetTimeoutRef = useRef<number | null>(null); const copy = useCallback( async (text: string, index = 0) => { await navigator.clipboard.writeText(text); setCopiedIndex(index); - setTimeout(() => setCopiedIndex(null), resetMs); + if (resetTimeoutRef.current !== null) { + window.clearTimeout(resetTimeoutRef.current); + } + resetTimeoutRef.current = window.setTimeout(() => { + setCopiedIndex(null); + resetTimeoutRef.current = null; + }, resetMs); }, [resetMs], ); + + useEffect(() => { + return () => { + if (resetTimeoutRef.current !== null) { + window.clearTimeout(resetTimeoutRef.current); + } + }; + }, []); return { copiedIndex, copy }; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/src/screens/GroupSetup.tsx` around lines 106 - 155, The copy hook (useCopy) currently uses a single timeout so a previous copy's timer can clear a newer button's "Copied!" state; change useCopy to track timers per copy target by storing timeout IDs in a ref Map keyed by the identifier passed to handleCopy (the second arg used in the component), clear any existing timeout for that key before setting a new one, and on cleanup (useEffect return) clear all remaining timeouts; update the hook's handleCopy signature to accept/expect the key (used by the component) and ensure the hook still exposes the copied state logic the component uses.e2e/helpers.ts (1)
133-142:⚠️ Potential issue | 🟡 MinorAssert the expected partner-link count here.
If the selector stops matching, this helper returns
undefinedforpartnerLinkand the spec fails later ongoto(), which makes the root cause much harder to spot. This helper already knows how many partner links should exist, so fail at the boundary.🔍 Suggested tightening
- // Collect partner links only (not the admin's own link on encrypted groups) + // Collect partner links only; the admin's own link uses a different input. const linkInputs = page.locator('[data-testid="partner-link"]'); - const linkCount = await linkInputs.count(); + const expectedLinkCount = 1 + extraPartners.length; + await expect(linkInputs).toHaveCount(expectedLinkCount); + const linkCount = expectedLinkCount; const partnerLinks: string[] = []; for (let i = 0; i < linkCount; i++) { partnerLinks.push(await linkInputs.nth(i).inputValue()); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/helpers.ts` around lines 133 - 142, Add a strict assertion right after computing linkCount to fail fast if the selector doesn't match the expected number of partner links: verify linkCount is the expected value (or at minimum > 0) and throw a clear Error including the selector and the observed linkCount; place this check immediately after computing linkCount (variables: linkInputs, linkCount, partnerLinks, partnerLink) so the helper fails with an explicit message instead of returning undefined for partnerLink.
🧹 Nitpick comments (3)
packages/web/src/components/CopyMyLink.tsx (1)
1-13: Align this new component with TS naming/type-shape conventions.Line 12 uses an inline object type for props, and the new filename is PascalCase. Prefer an interface for props and rename file to lowercase-hyphenated (
copy-my-link.tsx) to match repo conventions.As per coding guidelines, `**/*.{ts,tsx}` requires “Use interfaces for object shapes” and “Use lowercase-hyphenated filenames (e.g., `category-picker.tsx`)”.♻️ Proposed props-type cleanup
+interface CopyMyLinkProps { + encrypted: boolean; +} + -export function CopyMyLink({ encrypted }: Readonly<{ encrypted: boolean }>) { +export function CopyMyLink({ encrypted }: Readonly<CopyMyLinkProps>) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/src/components/CopyMyLink.tsx` around lines 1 - 13, Replace the inline prop type in the CopyMyLink component with a dedicated interface (e.g., interface CopyMyLinkProps { encrypted: boolean }) and update the component signature to use that interface (function CopyMyLink(props: Readonly<CopyMyLinkProps>) or destructure with ({ encrypted }: Readonly<CopyMyLinkProps>)); also rename the file to lowercase-hyphenated copy-my-link.tsx to match repo naming conventions and update any imports that reference the old PascalCase filename.packages/web/src/components/ErrorFallback.tsx (1)
6-8: Avoid brittle exact-message matching for control flow.Line 7 couples behavior to a literal error message. Prefer a stable discriminator (e.g., error
code) with message fallback so minor wording changes don’t silently break this path.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/src/components/ErrorFallback.tsx` around lines 6 - 8, The isMissingKeyError function should not rely on exact error.message matching; update it to first check for a stable discriminator (e.g., error.code === 'MISSING_GROUP_KEY' or similar) and only fall back to a more tolerant message check (e.g., message.includes('decrypt') or contains 'group key') for backward compatibility; locate and modify isMissingKeyError to read the code property from the thrown error (casting as needed) and then fallback to a substring match on error.message so minor wording changes won’t break the control flow.e2e/encryption-key.spec.ts (1)
79-94: Parameterize the admin-link encrypted/non-encrypted variants to reduce duplication.These two tests follow the same flow and differ only in the
#key=assertion. A single looped test will be easier to maintain.♻️ Suggested refactor
-test("shows admin link on non-encrypted group", async ({ page }) => { - await createGroupAndSetup(page); - // The "You're all set" screen should show the admin's own link - await expect(page.getByText("Your link", { exact: true })).toBeVisible(); - await expect(page.getByLabel("Copy your link")).toBeVisible(); -}); - -test("shows admin link with key on encrypted group", async ({ page }) => { - await createGroupAndSetup(page, { encrypted: true }); - await expect(page.getByText("Your link", { exact: true })).toBeVisible(); - // The admin link input should contain `#key`= - const adminLinkInput = page.getByLabel("Your invite link"); - const adminLink = await adminLinkInput.inputValue(); - expect(adminLink).toContain("#key="); -}); +for (const encrypted of [false, true] as const) { + test(`shows admin link on ${encrypted ? "encrypted" : "non-encrypted"} group`, async ({ page }) => { + await createGroupAndSetup(page, encrypted ? { encrypted: true } : undefined); + await expect(page.getByText("Your link", { exact: true })).toBeVisible(); + await expect(page.getByLabel("Copy your link")).toBeVisible(); + if (encrypted) { + const adminLink = await page.getByLabel("Your invite link").inputValue(); + expect(adminLink).toContain("#key="); + } + }); +}Based on learnings: “Applies to **/*.spec.ts : Playwright E2E tests should be parameterized with
for (const encrypted of [false, true])where encryption affects behavior.”🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/encryption-key.spec.ts` around lines 79 - 94, Combine the two tests into one parameterized test that iterates for encrypted = false and true; call createGroupAndSetup(page, { encrypted }) (or without options when encrypted is false), assert the common expectations (page.getByText("Your link") visible and page.getByLabel("Copy your link")/page.getByLabel("Your invite link") exists), then conditionally perform the encryption-specific assertion: read the adminLink via adminLinkInput.inputValue() (adminLinkInput from page.getByLabel("Your invite link")) and expect(adminLink).toContain("#key=") only when encrypted === true, otherwise assert it does not contain "#key=" (or skip that check for false). Ensure the test name reflects parameterization (e.g., "shows admin link (encrypted=%s)").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/src/components/ErrorFallback.tsx`:
- Line 26: Update the component prop types to be immutable by wrapping them with
Readonly<>: change the RootErrorFallback signature to accept props as
Readonly<FallbackProps> and likewise update the other component signature in
this file (the component declared around line 44) to use Readonly<...> for its
props type so both follow the repo prop-immutability convention.
---
Outside diff comments:
In `@e2e/helpers.ts`:
- Around line 133-142: Add a strict assertion right after computing linkCount to
fail fast if the selector doesn't match the expected number of partner links:
verify linkCount is the expected value (or at minimum > 0) and throw a clear
Error including the selector and the observed linkCount; place this check
immediately after computing linkCount (variables: linkInputs, linkCount,
partnerLinks, partnerLink) so the helper fails with an explicit message instead
of returning undefined for partnerLink.
In `@packages/web/src/screens/GroupSetup.tsx`:
- Around line 106-155: The copy hook (useCopy) currently uses a single timeout
so a previous copy's timer can clear a newer button's "Copied!" state; change
useCopy to track timers per copy target by storing timeout IDs in a ref Map
keyed by the identifier passed to handleCopy (the second arg used in the
component), clear any existing timeout for that key before setting a new one,
and on cleanup (useEffect return) clear all remaining timeouts; update the
hook's handleCopy signature to accept/expect the key (used by the component) and
ensure the hook still exposes the copied state logic the component uses.
---
Nitpick comments:
In `@e2e/encryption-key.spec.ts`:
- Around line 79-94: Combine the two tests into one parameterized test that
iterates for encrypted = false and true; call createGroupAndSetup(page, {
encrypted }) (or without options when encrypted is false), assert the common
expectations (page.getByText("Your link") visible and page.getByLabel("Copy your
link")/page.getByLabel("Your invite link") exists), then conditionally perform
the encryption-specific assertion: read the adminLink via
adminLinkInput.inputValue() (adminLinkInput from page.getByLabel("Your invite
link")) and expect(adminLink).toContain("#key=") only when encrypted === true,
otherwise assert it does not contain "#key=" (or skip that check for false).
Ensure the test name reflects parameterization (e.g., "shows admin link
(encrypted=%s)").
In `@packages/web/src/components/CopyMyLink.tsx`:
- Around line 1-13: Replace the inline prop type in the CopyMyLink component
with a dedicated interface (e.g., interface CopyMyLinkProps { encrypted: boolean
}) and update the component signature to use that interface (function
CopyMyLink(props: Readonly<CopyMyLinkProps>) or destructure with ({ encrypted }:
Readonly<CopyMyLinkProps>)); also rename the file to lowercase-hyphenated
copy-my-link.tsx to match repo naming conventions and update any imports that
reference the old PascalCase filename.
In `@packages/web/src/components/ErrorFallback.tsx`:
- Around line 6-8: The isMissingKeyError function should not rely on exact
error.message matching; update it to first check for a stable discriminator
(e.g., error.code === 'MISSING_GROUP_KEY' or similar) and only fall back to a
more tolerant message check (e.g., message.includes('decrypt') or contains
'group key') for backward compatibility; locate and modify isMissingKeyError to
read the code property from the thrown error (casting as needed) and then
fallback to a substring match on error.message so minor wording changes won’t
break the control flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1c048688-178b-470e-8a9e-61917c98cef7
⛔ Files ignored due to path filters (3)
e2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-desktop-linux.pngis excluded by!**/*.pnge2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-mobile-linux.pngis excluded by!**/*.pngpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
CLAUDE.mde2e/encryption-key.spec.tse2e/helpers.tse2e/multi-tab.spec.tse2e/self-pick-flow.spec.tse2e/visual/admin-flow.spec.tse2e/visual/partner-flow.spec.tspackages/web/package.jsonpackages/web/src/components/CopyMyLink.tsxpackages/web/src/components/ErrorFallback.tsxpackages/web/src/lib/crypto.test.tspackages/web/src/lib/crypto.tspackages/web/src/screens/Comparison.tsxpackages/web/src/screens/GroupSetup.tsxpackages/web/src/screens/Invite.tsxpackages/web/src/screens/PersonApp.tsxpackages/web/src/screens/QuestionCard.tsxtodo.md
|
|
||
| /** Root-level fallback — shown when the entire app crashes */ | ||
| export function RootErrorFallback({ resetErrorBoundary }: FallbackProps) { | ||
| export function RootErrorFallback({ error, resetErrorBoundary }: FallbackProps) { |
There was a problem hiding this comment.
Wrap error-boundary props in Readonly<> at the component signature.
Line 26 and Line 44 should follow the repo prop-immutability convention for TSX component props.
♻️ Suggested change
-export function RootErrorFallback({ error, resetErrorBoundary }: FallbackProps) {
+export function RootErrorFallback({ error, resetErrorBoundary }: Readonly<FallbackProps>) {
@@
-export function ScreenErrorFallback({ error, resetErrorBoundary }: FallbackProps) {
+export function ScreenErrorFallback({ error, resetErrorBoundary }: Readonly<FallbackProps>) {As per coding guidelines: **/*.{ts,tsx}: Use Readonly<> wrapper for component props at the function signature.
Also applies to: 44-44
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/web/src/components/ErrorFallback.tsx` at line 26, Update the
component prop types to be immutable by wrapping them with Readonly<>: change
the RootErrorFallback signature to accept props as Readonly<FallbackProps> and
likewise update the other component signature in this file (the component
declared around line 44) to use Readonly<...> for its props type so both follow
the repo prop-immutability convention.
… screenshots The visual CI job and local workflow now run inside mcr.microsoft.com/playwright:v1.59.1-noble so screenshots render identically regardless of the host OS. This fixes the CI-only failure on results-3p-second-tab.png caused by font rendering differences between bare ubuntu-latest and the dev machine. Changes: - Add scripts/visual-docker.sh wrapper (used by both CI and local) - Update CI visual job to use Docker instead of bare ubuntu - Make e2e/global-setup.ts resolve bins from node_modules/.bin when pnpm is not available (inside the container) - Regenerate all 20 affected baselines from inside the container - Document the Docker workflow in CLAUDE.md Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
pnpm may not hoist binaries to the root node_modules/.bin on CI with --frozen-lockfile. Check packages/server and packages/web node_modules before falling back to pnpm exec. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…eens
Makes sortMembersViewerFirst generic (works on any {id, name} object)
and applies it once in PersonApp before passing members to child screens.
This ensures deterministic member ordering on Invite, Pending, and
Waiting screens — previously the order depended on random UUIDs when
persons shared the same created_at timestamp within a transaction.
Results screen (Comparison) already used this sort via journal members.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Follows the repo convention for component prop immutability. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Fix useCopy timer race: clear previous timeout before setting a new one, clean up on unmount - Add MissingKeyError class with stable `code` discriminator instead of brittle exact-message matching in isMissingKeyError - Rename CopyMyLink.tsx → copy-my-link.tsx (lowercase-hyphenated convention) and extract CopyMyLinkProps interface - Assert expected partner-link count in createGroupAndSetup helper to fail fast instead of returning undefined - Parameterize admin-link E2E tests with for (const encrypted of [false, true]) loop Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
🎉 This PR is included in version 1.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Adopt design polish for new elements from #37: gradient copy buttons, consistent border/radius tokens, surface/border opacity on new "Your link" card in GroupSetup. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Summary
#key=shows "Encryption key missing" with an actionable message instead of the generic "Something went wrong." Covers both encrypted-data-exists (error boundary viaMissingKeyErrorclass with stable code discriminator) and no-data-yet (early guard prevents silent plaintext writes) cases./pending,/waiting,/invite,/results) for encrypted groups so users can save their full URL for another device. Usescopy-my-link.tsxwith chain-link/check icons from lucide-react.Link,Check,Pencil,ChevronLeft,ChevronRight) atstrokeWidth={1.5}. Convention documented in CLAUDE.md.sortMembersViewerFirst(now generic) applied once in PersonApp — self first, others alphabetical by name. Fixes non-deterministic ordering caused by UUIDs tying on identicalcreated_atwithin a transaction.mcr.microsoft.com/playwright:v1.59.1-noblefor deterministic screenshot rendering across machines. Addedscripts/visual-docker.shwrapper andpnpm test:visual:dockercommands.buildPersonLink()helper: extracted incrypto.ts, replaces duplicated link-building patterns.useCopytimer fix: clears previous timeout before setting a new one, preventing early reset of "Copied!" state.data-testid="partner-link"on partner link inputs to distinguish from admin's own link in E2E selectors.Test plan
buildPersonLinkx3,sortMembersViewerFirstwith plain objects)e2e/encryption-key.spec.ts): missing key error, key present happy path, copy-link visible/absent, admin link parameterized for encrypted/plaintext🤖 Generated with Claude Code