Skip to content

feat(web): encryption key guard, copy-link buttons, lucide icons, deterministic member ordering - #37

Merged
iskhakovt merged 8 commits into
mainfrom
feat/encryption-key-guard-copy-link
Apr 13, 2026
Merged

iskhakovt merged 8 commits into
mainfrom
feat/encryption-key-guard-copy-link

Conversation

@iskhakovt

@iskhakovt iskhakovt commented Apr 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Missing key error: opening an encrypted group without #key= shows "Encryption key missing" with an actionable message instead of the generic "Something went wrong." Covers both encrypted-data-exists (error boundary via MissingKeyError class with stable code discriminator) and no-data-yet (early guard prevents silent plaintext writes) cases.
  • Copy my link: subtle button on idle screens (/pending, /waiting, /invite, /results) for encrypted groups so users can save their full URL for another device. Uses copy-my-link.tsx with chain-link/check icons from lucide-react.
  • Admin's own link: shown first on the "You're all set" setup screen for all groups, with link icon and "Save this to access your group from another device" hint.
  • lucide-react icons: replaces all 6 hand-drawn inline SVGs with named Lucide components (Link, Check, Pencil, ChevronLeft, ChevronRight) at strokeWidth={1.5}. Convention documented in CLAUDE.md.
  • Deterministic member ordering: sortMembersViewerFirst (now generic) applied once in PersonApp — self first, others alphabetical by name. Fixes non-deterministic ordering caused by UUIDs tying on identical created_at within a transaction.
  • Dockerized visual tests: CI and local visual tests now run inside mcr.microsoft.com/playwright:v1.59.1-noble for deterministic screenshot rendering across machines. Added scripts/visual-docker.sh wrapper and pnpm test:visual:docker commands.
  • buildPersonLink() helper: extracted in crypto.ts, replaces duplicated link-building patterns.
  • useCopy timer 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

  • 4 new unit tests (buildPersonLink x3, sortMembersViewerFirst with plain objects)
  • 6 new E2E tests (e2e/encryption-key.spec.ts): missing key error, key present happy path, copy-link visible/absent, admin link parameterized for encrypted/plaintext
  • Visual baselines regenerated from Playwright Docker container
  • All 339 unit tests pass
  • All 43 E2E tests pass
  • All 16 visual tests pass (in Docker)

🤖 Generated with Claude Code

…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]>
@coderabbitai

coderabbitai Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title partially covers the main changes but is incomplete and misleading about scope. Consider revising the title to focus on the primary objective: something like 'feat(web): encryption key guard and copy-link buttons for encrypted groups' would better reflect the PR's main intent without the vague 'deterministic member ordering' claim that isn't substantiated in the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/encryption-key-guard-copy-link

Comment @coderabbitai help to get the list of available commands and usage tips.

…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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Prevent 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 | 🟡 Minor

Assert the expected partner-link count here.

If the selector stops matching, this helper returns undefined for partnerLink and the spec fails later on goto(), 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.

♻️ Proposed props-type cleanup
+interface CopyMyLinkProps {
+  encrypted: boolean;
+}
+
-export function CopyMyLink({ encrypted }: Readonly<{ encrypted: boolean }>) {
+export function CopyMyLink({ encrypted }: Readonly<CopyMyLinkProps>) {
As per coding guidelines, `**/*.{ts,tsx}` requires “Use interfaces for object shapes” and “Use lowercase-hyphenated filenames (e.g., `category-picker.tsx`)”.
🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between deb3441 and 34cc08b.

⛔ Files ignored due to path filters (3)
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-mobile-linux.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • CLAUDE.md
  • e2e/encryption-key.spec.ts
  • e2e/helpers.ts
  • e2e/multi-tab.spec.ts
  • e2e/self-pick-flow.spec.ts
  • e2e/visual/admin-flow.spec.ts
  • e2e/visual/partner-flow.spec.ts
  • packages/web/package.json
  • packages/web/src/components/CopyMyLink.tsx
  • packages/web/src/components/ErrorFallback.tsx
  • packages/web/src/lib/crypto.test.ts
  • packages/web/src/lib/crypto.ts
  • packages/web/src/screens/Comparison.tsx
  • packages/web/src/screens/GroupSetup.tsx
  • packages/web/src/screens/Invite.tsx
  • packages/web/src/screens/PersonApp.tsx
  • packages/web/src/screens/QuestionCard.tsx
  • todo.md


/** Root-level fallback — shown when the entire app crashes */
export function RootErrorFallback({ resetErrorBoundary }: FallbackProps) {
export function RootErrorFallback({ error, resetErrorBoundary }: FallbackProps) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

iskhakovt and others added 5 commits April 13, 2026 09:11
… 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]>
@iskhakovt iskhakovt changed the title feat(web): clear error for missing encryption key + copy-link buttons feat(web): encryption key guard, copy-link buttons, lucide icons, deterministic member ordering Apr 13, 2026
@iskhakovt
iskhakovt enabled auto-merge (squash) April 13, 2026 09:06
@iskhakovt
iskhakovt merged commit 159efe0 into main Apr 13, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

iskhakovt added a commit that referenced this pull request Apr 13, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant