-
Notifications
You must be signed in to change notification settings - Fork 326
feat(companion): native claim + link/create for unclaimed QR codes #2753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
458ecf2
feat(companion): native claim + link/create for unclaimed QR codes
2fd61c1
fix(companion): harden scanner claim and picker against async races
657550f
docs(rules): cross-app mirrors need provenance
e8f40aa
Merge branch 'main' into feat/companion-unclaimed-qr-claim
DonKoko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| description: Hand-copied webapp logic in the companion (or any second app) must be marked as a mirror, point at its source, and prefer extraction to packages/* | ||
| globs: apps/companion/** | ||
| --- | ||
|
|
||
| # Cross-App Mirrors Need Provenance | ||
|
|
||
| The companion cannot import from `apps/webapp/app/**` (Remix-internal paths, | ||
| server-adjacent imports — Metro can't consume them). When it needs webapp | ||
| truth (permission matrices, enums, business constants), a hand-copied mirror | ||
| is sometimes the pragmatic choice — but every mirror MUST: | ||
|
|
||
| 1. **Declare itself a mirror, never a source** — file-level JSDoc stating the | ||
| canonical file it mirrors and that the server enforces the real rules. | ||
| 2. **Mirror the EFFECTIVE behavior, not the raw data** — e.g. the server's | ||
| `hasPermission()` short-circuits ADMIN/OWNER to allow-all; a copy of the | ||
| raw `Role2PermissionMap` alone is wrong. Say so in a comment at the spot. | ||
| 3. **Be UI-cosmetic only** — if a client copy ever gates anything the server | ||
| does not independently enforce, that is a bug, not a mirror. | ||
| 4. **Carry an extraction path** — when the mirrored thing is behavioral | ||
| (matrix + resolution logic), the durable fix is a shared workspace package | ||
| (`packages/*`, like `@shelf/database`). Note the intended package in the | ||
| JSDoc so reviewers see the debt is tracked, not accidental. | ||
|
|
||
| ```ts | ||
| // ❌ Bad — silent copy; reviewer can't tell drift from design | ||
| const ROLE_PERMISSIONS = { OWNER: { qr: ["read", "update"] } }; | ||
|
|
||
| // ✅ Good — provenance + effective-behavior note + extraction path | ||
| /** | ||
| * MIRROR of apps/webapp .../permission.data.ts — cosmetic UI gating only; | ||
| * server enforces via requireMobilePermission. Encodes the EFFECTIVE result | ||
| * (matrix + ADMIN/OWNER allow-all short-circuit). Extraction target: | ||
| * @shelf/permissions (see PR #2753 discussion). | ||
| */ | ||
| ``` | ||
|
|
||
| Existing mirrors: `apps/companion/lib/permissions.ts`. When you touch one, | ||
| diff it against its canonical source before shipping. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.