@milesroxas/design-hub 0.6.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +16 -6
  2. package/core/review/model.ts +124 -6
  3. package/core/review/policy.test.ts +103 -24
  4. package/core/review/policy.ts +43 -7
  5. package/core/review/service.test.ts +569 -33
  6. package/core/review/service.ts +272 -76
  7. package/core/review/store.ts +24 -4
  8. package/dist/core/review/model.d.ts +59 -4
  9. package/dist/core/review/model.js +98 -4
  10. package/dist/core/review/policy.d.ts +21 -2
  11. package/dist/core/review/policy.js +34 -2
  12. package/dist/core/review/service.d.ts +39 -11
  13. package/dist/core/review/service.js +237 -77
  14. package/dist/core/review/store.d.ts +17 -4
  15. package/dist/core/review/store.js +21 -3
  16. package/dist/scripts/bootstrap.d.ts +16 -14
  17. package/dist/scripts/bootstrap.js +56 -39
  18. package/dist/scripts/comments.d.ts +10 -2
  19. package/dist/scripts/comments.js +18 -7
  20. package/dist/scripts/lib/deploy.d.ts +12 -4
  21. package/dist/scripts/lib/deploy.js +47 -13
  22. package/dist/scripts/lib/vercel.d.ts +8 -2
  23. package/dist/scripts/lib/vercel.js +23 -9
  24. package/dist/scripts/people.d.ts +13 -26
  25. package/dist/scripts/people.js +68 -35
  26. package/dist/scripts/preflight.js +2 -2
  27. package/dist/scripts/share.d.ts +2 -3
  28. package/dist/scripts/share.js +18 -10
  29. package/dist/server/api.d.ts +6 -2
  30. package/dist/server/api.js +65 -24
  31. package/dist/server/fake-upstash.js +3 -2
  32. package/dist/server/local.js +2 -0
  33. package/dist/server/session.d.ts +25 -10
  34. package/dist/server/session.js +69 -52
  35. package/dist/server/upstash.js +4 -3
  36. package/dist/vercel/proxy.d.ts +5 -3
  37. package/dist/vercel/proxy.js +183 -157
  38. package/dist/vite/plugin.js +5 -5
  39. package/kit/prefs.ts +19 -2
  40. package/package.json +2 -2
  41. package/shell/review/Bar.tsx +97 -4
  42. package/shell/review/People.tsx +178 -45
  43. package/shell/review/Pins.tsx +39 -24
  44. package/shell/review/Review.tsx +113 -29
  45. package/shell/review/ThreadCard.tsx +25 -13
  46. package/shell/review/client.ts +64 -23
  47. package/shell/review/review.css +16 -2
  48. package/shell/review/view.test.ts +73 -1
  49. package/shell/review/view.ts +49 -3
  50. package/skills/miles-deploy/SKILL.md +44 -16
  51. package/skills/miles-design-hub/SKILL.md +5 -5
  52. package/skills/miles-new-feature/SKILL.md +1 -1
  53. package/skills/miles-review/SKILL.md +10 -6
  54. package/skills/miles-worktrees/SKILL.md +1 -1
  55. package/templates/conductor/settings.toml +1 -1
  56. package/templates/guide.md +1 -1
@@ -19,10 +19,10 @@ import { lapse } from './lapse.js';
19
19
  import { markdownDocs } from './markdown.js';
20
20
  import { registry } from './registry.js';
21
21
  const require = createRequire(import.meta.url);
22
- // The password page loads before sign-in, so it cannot reach the hashed
23
- // bundle. Its font goes out at the one fixed path the gate lets through.
24
- // `design-hub dev` has no gate, so there /_gate/ previews the page (?failed
25
- // shows the wrong-password state).
22
+ // The gate pages load before sign-in, so they cannot reach the hashed
23
+ // bundle. Their font goes out at the one fixed path the gate lets through.
24
+ // `design-hub dev` has no gate, so there /_gate/ previews the sign-in page,
25
+ // ?page=link a link's page and ?page=used a used or expired link's.
26
26
  const gateFontFile = () => join(dirname(require.resolve('@fontsource-variable/geist')), 'files', 'geist-latin-wght-normal.woff2');
27
27
  function gateFont() {
28
28
  return {
@@ -40,7 +40,7 @@ function gateFont() {
40
40
  }
41
41
  if (url.pathname !== '/_gate/')
42
42
  return nextMiddleware();
43
- const page = await gatePreview(url.searchParams.has('failed'));
43
+ const page = await gatePreview(url.searchParams.get('page'));
44
44
  res.setHeader('content-type', 'text/html; charset=utf-8');
45
45
  res.setHeader('content-security-policy', page.csp);
46
46
  res.end(page.html);
package/kit/prefs.ts CHANGED
@@ -2,8 +2,9 @@ import { useSyncExternalStore } from 'react';
2
2
 
3
3
  // Theme, reduced motion and speed for the page, mirrored onto <html>
4
4
  // (.dark-mode, [data-motion="reduce"]) so CSS and JS read one source.
5
- // Also whether the comments button and pins are hidden: a choice about the
6
- // page a person is looking at, kept the same way as their theme.
5
+ // Also whether the comments button and pins are hidden, and whether Studio
6
+ // is in Client view: choices about the page a person is looking at, kept the
7
+ // same way as their theme.
7
8
 
8
9
  export type Appearance = 'system' | 'light' | 'dark';
9
10
 
@@ -18,9 +19,11 @@ const urlReduce = params.get('motion') === 'reduce';
18
19
  const listeners = new Set<() => void>();
19
20
 
20
21
  const COMMENTS_KEY = 'proto:comments';
22
+ const CLIENT_VIEW_KEY = 'proto:client-view';
21
23
 
22
24
  let appearance: Appearance = readAppearance();
23
25
  let commentsHidden = readStored(COMMENTS_KEY) === 'hidden';
26
+ let clientView = readStored(CLIENT_VIEW_KEY) === 'on';
24
27
  let forceReduce = false;
25
28
  let speed = 1;
26
29
  let lapse: LapseHandle | null = null;
@@ -97,6 +100,20 @@ export function setCommentsHidden(hidden: boolean) {
97
100
  emit();
98
101
  }
99
102
 
103
+ /**
104
+ * Whether Studio is looking as a Client does. Remembered per browser. Only a
105
+ * view: the server decides what each person receives, so for a Client it
106
+ * changes nothing.
107
+ */
108
+ export const isClientView = () => clientView;
109
+
110
+ export function setClientView(on: boolean) {
111
+ if (on === clientView) return;
112
+ clientView = on;
113
+ store(CLIENT_VIEW_KEY, on ? 'on' : 'off');
114
+ emit();
115
+ }
116
+
100
117
  export const isDark = () => root.classList.contains('dark-mode');
101
118
  export const prefersReducedMotion = () => root.dataset.motion === 'reduce';
102
119
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@milesroxas/design-hub",
3
- "version": "0.6.2",
4
- "description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the password gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
3
+ "version": "0.8.0",
4
+ "description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the sign-in gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,10 +1,13 @@
1
1
  // Comment mode's bar: one quiet pill in three groups. What a new comment is
2
2
  // about (Pin or Page), the threads to step through, and the way out.
3
- // Everything rarer sits behind ⋯. Only the chosen half of the toggle is
4
- // filled: the page under the bar is the work.
3
+ // Everything rarer sits behind ⋯: for Studio, that includes which threads
4
+ // to list (all, internal, client-facing) and Client view. Client view, and a
5
+ // filter other than All, each put a plain note over the bar with the way out,
6
+ // so a narrowed list is never mistaken for the whole one. Only the chosen half of the
7
+ // toggle is filled: the page under the bar is the work.
5
8
  import { Icon } from '@kit/Icon';
6
9
  import { Button, type MenuEntry, useMenu } from '@kit/ui';
7
- import type { Scope } from './view';
10
+ import type { Filter, Scope } from './view';
8
11
 
9
12
  const VERB = matchMedia('(pointer: coarse)').matches ? 'Tap' : 'Click';
10
13
 
@@ -18,6 +21,16 @@ type Props = {
18
21
  resolvedCount: number;
19
22
  /** Studio only: the People entry in ⋯. */
20
23
  canManagePeople: boolean;
24
+ /** Studio, not in Client view: the audience filter in ⋯. */
25
+ canFilter: boolean;
26
+ filter: Filter;
27
+ /** "Internal only" while the filter narrows the list; null with All. */
28
+ filterNote: string | null;
29
+ onFilter: (filter: Filter) => void;
30
+ /** Studio: the Client view entry in ⋯, and the note while it is on. */
31
+ canClientView: boolean;
32
+ clientView: boolean;
33
+ onClientView: (on: boolean) => void;
21
34
  error: string | null;
22
35
  onStep: (by: number) => void;
23
36
  onResolved: () => void;
@@ -27,6 +40,45 @@ type Props = {
27
40
  onDismissError: () => void;
28
41
  };
29
42
 
43
+ const FILTERS: { value: Filter; label: string }[] = [
44
+ { value: 'all', label: 'All' },
45
+ { value: 'internal', label: 'Internal' },
46
+ { value: 'client', label: 'Client-facing' },
47
+ ];
48
+
49
+ /** Studio's: which threads to list, then Client view. A Client gets neither. */
50
+ function audienceItems(p: Pick<Props, 'canFilter' | 'filter' | 'canClientView' | 'clientView'>): MenuEntry[] {
51
+ const filter: MenuEntry[] = p.canFilter
52
+ ? [
53
+ { heading: 'Show' },
54
+ ...FILTERS.map((f) => ({
55
+ label: f.label,
56
+ value: `filter:${f.value}`,
57
+ checked: p.filter === f.value,
58
+ })),
59
+ '-',
60
+ ]
61
+ : [];
62
+ const view: MenuEntry[] = p.canClientView
63
+ ? [
64
+ p.clientView
65
+ ? {
66
+ label: 'Leave Client view',
67
+ desc: 'Back to every thread',
68
+ value: 'clientView',
69
+ icon: 'log-out-01',
70
+ }
71
+ : {
72
+ label: 'Client view',
73
+ desc: 'See comments as a client does',
74
+ value: 'clientView',
75
+ icon: 'briefcase-01',
76
+ },
77
+ ]
78
+ : [];
79
+ return [...filter, ...view];
80
+ }
81
+
30
82
  function moreItems(resolved: boolean, resolvedCount: number, canManagePeople: boolean): MenuEntry[] {
31
83
  return [
32
84
  {
@@ -43,6 +95,27 @@ function moreItems(resolved: boolean, resolvedCount: number, canManagePeople: bo
43
95
  ];
44
96
  }
45
97
 
98
+ /** A view that is not the usual one, said plainly over the bar, with the one action back. */
99
+ function ViewNote({
100
+ icon,
101
+ text,
102
+ action,
103
+ onAction,
104
+ }: {
105
+ icon: 'briefcase-01' | 'filter-lines';
106
+ text: string;
107
+ action: string;
108
+ onAction: () => void;
109
+ }) {
110
+ return (
111
+ <p className="rv-alert rv-viewing">
112
+ <Icon name={icon} size={14} />
113
+ <span>{text}</span>
114
+ <Button kind="tertiary" size={null} className="rv-act" label={action} onClick={onAction} />
115
+ </p>
116
+ );
117
+ }
118
+
46
119
  function Alert({ error, onDismiss }: { error: string; onDismiss: () => void }) {
47
120
  return (
48
121
  <p className="rv-alert" role="alert">
@@ -114,17 +187,37 @@ export function Bar(p: Props) {
114
187
  resolved: p.onResolved,
115
188
  people: p.onPeople,
116
189
  hide: p.onHide,
190
+ clientView: () => p.onClientView(!p.clientView),
191
+ 'filter:all': () => p.onFilter('all'),
192
+ 'filter:internal': () => p.onFilter('internal'),
193
+ 'filter:client': () => p.onFilter('client'),
117
194
  };
118
195
  const more = useMenu({
119
196
  className: 'rv-menu',
120
197
  label: 'Comment options',
121
198
  width: 264,
122
199
  align: 'end',
123
- items: moreItems(p.resolved, p.resolvedCount, p.canManagePeople),
200
+ items: [...audienceItems(p), ...moreItems(p.resolved, p.resolvedCount, p.canManagePeople)],
124
201
  onSelect: (v) => actions[v ?? '']?.(),
125
202
  });
126
203
  return (
127
204
  <div className="rv-bar-stack">
205
+ {p.clientView && (
206
+ <ViewNote
207
+ icon="briefcase-01"
208
+ text="Client view: comments as a client sees them"
209
+ action="Leave"
210
+ onAction={() => p.onClientView(false)}
211
+ />
212
+ )}
213
+ {p.filterNote && (
214
+ <ViewNote
215
+ icon="filter-lines"
216
+ text={p.filterNote}
217
+ action="Show all"
218
+ onAction={() => p.onFilter('all')}
219
+ />
220
+ )}
128
221
  {p.error && <Alert error={p.error} onDismiss={p.onDismissError} />}
129
222
  <section className="rv-bar" aria-label="Comment mode">
130
223
  <Toggle scope={p.scope} onScope={p.onScope} />
@@ -1,8 +1,11 @@
1
- // The People card, for Studio: invite someone, hand over their link, and see
2
- // who can comment.
1
+ // The People card, for Studio: add someone, hand over their one-time link,
2
+ // and see who can comment and until when. A link signs in one device, then
3
+ // stops working, so each row offers another link for another device, a sign
4
+ // out everywhere, a change of access length, and Revoke.
5
+ import { fmtDate } from '@kit/format';
3
6
  import { Button, Select } from '@kit/ui';
4
- import { type FormEvent, useId, useRef, useState } from 'react';
5
- import { INVITE_DAYS, LIMITS, type PersonKind } from '../../core/review/model';
7
+ import { type FormEvent, type ReactNode, useId, useRef, useState } from 'react';
8
+ import { type Access, LIMITS, LINK_DAYS, type PersonKind } from '../../core/review/model';
6
9
  import { Action } from './Card';
7
10
  import { act, type Me, type ReviewStore } from './client';
8
11
 
@@ -15,15 +18,40 @@ const KIND_OPTIONS: { value: PersonKind; label: string; desc: string }[] = [
15
18
  {
16
19
  value: 'studio',
17
20
  label: KIND_NAMES.studio,
18
- desc: 'Also sorts, deletes any comment and invites',
21
+ desc: 'Also sorts, deletes any comment and manages people',
19
22
  },
20
23
  ];
21
24
 
22
- function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link) => void }) {
25
+ const ACCESS_NAMES: Record<Access, string> = { '3m': '3 months', '6m': '6 months', open: 'Open-ended' };
26
+
27
+ const LENGTH_OPTIONS: { value: Access; label: string }[] = [
28
+ { value: '3m', label: ACCESS_NAMES['3m'] },
29
+ { value: '6m', label: ACCESS_NAMES['6m'] },
30
+ { value: 'open', label: ACCESS_NAMES.open },
31
+ ];
32
+
33
+ /** The add form's choices: the default for this kind first, then each length. */
34
+ function accessOptions(kind: PersonKind, projectDefault: Access | null) {
35
+ const fallback =
36
+ kind === 'studio' ? 'Open-ended for Studio' : `Project default: ${ACCESS_NAMES[projectDefault ?? '3m']}`;
37
+ return [{ value: 'default', label: 'Default', desc: fallback }, ...LENGTH_OPTIONS];
38
+ }
39
+
40
+ function AddForm({
41
+ store,
42
+ projectDefault,
43
+ onLink,
44
+ }: {
45
+ store: ReviewStore;
46
+ projectDefault: Access | null;
47
+ onLink: (link: Link) => void;
48
+ }) {
23
49
  const [kind, setKind] = useState<PersonKind>('client');
50
+ const [access, setAccess] = useState('default');
24
51
  const [busy, setBusy] = useState(false);
25
52
  const kindLabel = useId();
26
- const invite = (e: FormEvent<HTMLFormElement>) => {
53
+ const accessLabel = useId();
54
+ const add = (e: FormEvent<HTMLFormElement>) => {
27
55
  e.preventDefault();
28
56
  const form = e.currentTarget;
29
57
  const f = new FormData(form);
@@ -31,7 +59,7 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
31
59
  setBusy(true);
32
60
  act(
33
61
  store
34
- .invite(name, String(f.get('team') ?? ''), kind)
62
+ .addPerson(name, String(f.get('team') ?? ''), kind, access === 'default' ? null : (access as Access))
35
63
  .then((href) => {
36
64
  onLink({ name, href });
37
65
  form.reset();
@@ -40,7 +68,7 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
40
68
  );
41
69
  };
42
70
  return (
43
- <form className="rv-invite" onSubmit={invite}>
71
+ <form className="rv-invite" onSubmit={add}>
44
72
  <label className="field">
45
73
  <span className="field-label">Name</span>
46
74
  <input
@@ -75,7 +103,19 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
75
103
  onChange={(next) => setKind(next as PersonKind)}
76
104
  />
77
105
  </div>
78
- <Button type="submit" kind="primary" size={null} label="Create invite link" busy={busy} />
106
+ <div className="field">
107
+ <span id={accessLabel} className="field-label">
108
+ Access
109
+ </span>
110
+ <Select
111
+ labelId={accessLabel}
112
+ menuClassName="rv-menu"
113
+ value={access}
114
+ options={accessOptions(kind, projectDefault)}
115
+ onChange={setAccess}
116
+ />
117
+ </div>
118
+ <Button type="submit" kind="primary" size={null} label="Create link" busy={busy} />
79
119
  </form>
80
120
  );
81
121
  }
@@ -92,7 +132,8 @@ function ShareLink({ link }: { link: Link }) {
92
132
  return (
93
133
  <div className="rv-share" role="status">
94
134
  <p>
95
- Send this link to {link.name}. It works for {INVITE_DAYS} days, and a new link replaces it.
135
+ Send this link to {link.name} only. It signs in one device, then stops working. Unused, it lasts{' '}
136
+ {LINK_DAYS} days.
96
137
  </p>
97
138
  <div className="rv-share-row">
98
139
  <input
@@ -100,7 +141,7 @@ function ShareLink({ link }: { link: Link }) {
100
141
  className="input"
101
142
  readOnly
102
143
  value={link.href}
103
- aria-label={`Invite link for ${link.name}`}
144
+ aria-label={`Sign-in link for ${link.name}`}
104
145
  onFocus={(e) => e.currentTarget.select()}
105
146
  />
106
147
  <Button size={null} className="rv-copy" label={copied ? 'Copied' : 'Copy'} onClick={copy} />
@@ -109,48 +150,141 @@ function ShareLink({ link }: { link: Link }) {
109
150
  );
110
151
  }
111
152
 
112
- function PersonRow({
113
- person,
114
- store,
115
- onLink,
153
+ /** How links behave, said once where Studio shares them. */
154
+ function HowLinksWork() {
155
+ return (
156
+ <p className="rv-muted rv-disclosure">
157
+ Each person gets their own link. A link signs in one device, then stops working, so a second device
158
+ needs a new link. An unused link lasts {LINK_DAYS} days. Revoking someone ends their access everywhere.
159
+ </p>
160
+ );
161
+ }
162
+
163
+ const ended = (p: Me) => p.accessEndsAt !== null && p.accessEndsAt <= new Date().toISOString();
164
+
165
+ /** When someone's access ends, as the row says it. */
166
+ function accessText(p: Me): string {
167
+ if (p.accessEndsAt === null) return 'open-ended';
168
+ const day = fmtDate(p.accessEndsAt.slice(0, 10));
169
+ return ended(p) ? `access ended ${day}` : `until ${day}`;
170
+ }
171
+
172
+ type Mode = 'idle' | 'signOut' | 'revoke' | 'access';
173
+
174
+ function Confirm({
175
+ text,
176
+ label,
177
+ onYes,
178
+ onNo,
116
179
  }: {
117
- person: Me;
118
- store: ReviewStore;
119
- onLink: (link: Link) => void;
180
+ text: string;
181
+ label: string;
182
+ onYes: () => void;
183
+ onNo: () => void;
120
184
  }) {
121
- const [confirming, setConfirming] = useState(false);
122
185
  return (
123
- <div className="rv-row rv-acts">
124
- {confirming ? (
125
- <>
126
- <span className="rv-confirm">Remove {person.name}’s access?</span>
127
- <Action
128
- label="Revoke"
129
- danger
130
- onClick={() => act(store.revoke(person.id).then(() => setConfirming(false)))}
131
- />
132
- <Action label="Keep" onClick={() => setConfirming(false)} />
133
- </>
134
- ) : (
135
- <>
136
- <Action
137
- label="New link"
138
- onClick={() => act(store.reissue(person.id).then((href) => onLink({ name: person.name, href })))}
139
- />
140
- <Action label="Revoke" onClick={() => setConfirming(true)} />
141
- </>
142
- )}
143
- </div>
186
+ <>
187
+ <span className="rv-confirm">{text}</span>
188
+ <Action label={label} danger onClick={onYes} />
189
+ <Action label="Keep" onClick={onNo} />
190
+ </>
191
+ );
192
+ }
193
+
194
+ function AccessPicker({ person, store, onDone }: { person: Me; store: ReviewStore; onDone: () => void }) {
195
+ const label = useId();
196
+ return (
197
+ <>
198
+ <span id={label} className="rv-confirm">
199
+ Access from today
200
+ </span>
201
+ <Select
202
+ labelId={label}
203
+ menuClassName="rv-menu"
204
+ value={null}
205
+ placeholder="Choose"
206
+ options={LENGTH_OPTIONS}
207
+ onChange={(next) => act(store.setAccess(person.id, next as Access).then(onDone))}
208
+ />
209
+ <Action label="Cancel" onClick={onDone} />
210
+ </>
211
+ );
212
+ }
213
+
214
+ type RowProps = { person: Me; store: ReviewStore; onLink: (link: Link) => void };
215
+
216
+ function PersonActions({ person, store, onLink, setMode }: RowProps & { setMode: (m: Mode) => void }) {
217
+ const linked = (pending: Promise<string>) =>
218
+ act(pending.then((href) => onLink({ name: person.name, href })));
219
+ // A link would open nothing once access has ended, so the row offers the fix instead.
220
+ if (ended(person))
221
+ return (
222
+ <>
223
+ <Action label="Change access" onClick={() => setMode('access')} />
224
+ <Action label="Revoke" onClick={() => setMode('revoke')} />
225
+ </>
226
+ );
227
+ return (
228
+ <>
229
+ <Action label="New link" onClick={() => linked(store.newLink(person.id))} />
230
+ <Action label="Sign out everywhere" onClick={() => setMode('signOut')} />
231
+ <Action label="Access" onClick={() => setMode('access')} />
232
+ <Action label="Revoke" onClick={() => setMode('revoke')} />
233
+ </>
144
234
  );
145
235
  }
146
236
 
147
- export function People({ store, me, people }: { store: ReviewStore; me: Me | null; people: Me[] | null }) {
237
+ function PersonRow({ person, store, onLink }: RowProps) {
238
+ const [mode, setMode] = useState<Mode>('idle');
239
+ const idle = () => setMode('idle');
240
+ const views: Record<Mode, () => ReactNode> = {
241
+ idle: () => <PersonActions person={person} store={store} onLink={onLink} setMode={setMode} />,
242
+ access: () => <AccessPicker person={person} store={store} onDone={idle} />,
243
+ revoke: () => (
244
+ <Confirm
245
+ text={`Remove ${person.name}’s access everywhere?`}
246
+ label="Revoke"
247
+ onYes={() => act(store.revoke(person.id).then(idle))}
248
+ onNo={idle}
249
+ />
250
+ ),
251
+ signOut: () => (
252
+ <Confirm
253
+ text={`Sign ${person.name} out of every device? They get one new link.`}
254
+ label="Sign out"
255
+ onYes={() =>
256
+ act(
257
+ store.signOut(person.id).then((href) => {
258
+ onLink({ name: person.name, href });
259
+ idle();
260
+ }),
261
+ )
262
+ }
263
+ onNo={idle}
264
+ />
265
+ ),
266
+ };
267
+ return <div className="rv-row rv-acts">{views[mode]()}</div>;
268
+ }
269
+
270
+ export function People({
271
+ store,
272
+ me,
273
+ people,
274
+ access,
275
+ }: {
276
+ store: ReviewStore;
277
+ me: Me | null;
278
+ people: Me[] | null;
279
+ access: Access | null;
280
+ }) {
148
281
  const [link, setLink] = useState<Link | null>(null);
149
282
  return (
150
283
  <div className="rv-body">
151
- <InviteForm store={store} onLink={setLink} />
284
+ <AddForm store={store} projectDefault={access} onLink={setLink} />
152
285
  {/* Keyed by the link, so a second one starts on Copy again. */}
153
286
  {link && <ShareLink key={link.href} link={link} />}
287
+ <HowLinksWork />
154
288
  {people === null ? (
155
289
  <p className="rv-muted">Loading people…</p>
156
290
  ) : (
@@ -160,8 +294,7 @@ export function People({ store, me, people }: { store: ReviewStore; me: Me | nul
160
294
  <div className="rv-person">
161
295
  <strong>{p.name}</strong>
162
296
  <span className="rv-muted">
163
- {p.team} · {KIND_NAMES[p.kind]}
164
- {p.revokedAt && ' · revoked'}
297
+ {p.team} · {KIND_NAMES[p.kind]} · {p.revokedAt ? 'revoked' : accessText(p)}
165
298
  </span>
166
299
  </div>
167
300
  {p.id !== me?.id && !p.revokedAt && <PersonRow person={p} store={store} onLink={setLink} />}
@@ -2,8 +2,10 @@
2
2
  // written. In comment mode they are the way into a thread, so each is a real
3
3
  // button in the tab order. The button is the hit area and never changes size;
4
4
  // the face inside it is what presses and lifts, so a press near the edge
5
- // still ends on the pin. An open thread's pin is solid and numbered; a
6
- // resolved one is pale and carries a check.
5
+ // still ends on the pin. An open thread's pin is solid and numbered; an
6
+ // open internal one is numbered too, on a lighter face with a dashed edge; a
7
+ // resolved one is pale and carries a check. The number is the thread's own,
8
+ // never its place in the list.
7
9
  import { Icon } from '@kit/Icon';
8
10
  import { useEffect, useRef } from 'react';
9
11
  import type { Comment } from '../../core/review/model';
@@ -16,15 +18,45 @@ const moveTo = (el: HTMLElement, at: { x: number; y: number } | null) => {
16
18
  if (at) el.style.transform = `translate(${at.x}px, ${at.y}px)`;
17
19
  };
18
20
 
21
+ /** "Comment 3, internal, resolved, by Rae": the number when it has one, then what the face shows. */
22
+ function pinLabel(c: Comment): string {
23
+ const words = [
24
+ c.number ? `Comment ${c.number}` : 'Comment',
25
+ c.audience === 'internal' && 'internal',
26
+ c.status === 'resolved' && 'resolved',
27
+ ];
28
+ return `${words.filter(Boolean).join(', ')}, by ${c.author.name}`;
29
+ }
30
+
31
+ function Pin({ c, active, onOpen }: { c: Comment; active: boolean; onOpen: (id: string) => void }) {
32
+ const resolved = c.status === 'resolved';
33
+ // A Client is never sent an internal thread, so only Studio ever sees this face.
34
+ const internal = c.audience === 'internal';
35
+ return (
36
+ <button
37
+ type="button"
38
+ className="rv-pin"
39
+ data-pin={c.id}
40
+ data-resolved={resolved ? '' : undefined}
41
+ data-internal={internal ? '' : undefined}
42
+ data-active={active ? '' : undefined}
43
+ aria-label={pinLabel(c)}
44
+ aria-pressed={active}
45
+ hidden
46
+ onClick={() => onOpen(c.id)}
47
+ >
48
+ <span className="rv-pin-face">{resolved ? <Icon name="check" size={12} /> : c.number || null}</span>
49
+ </button>
50
+ );
51
+ }
52
+
19
53
  export function Pins({
20
54
  comments,
21
- number,
22
55
  active,
23
56
  draft,
24
57
  onOpen,
25
58
  }: {
26
59
  comments: Comment[];
27
- number: Map<string, number>;
28
60
  active: string | null;
29
61
  draft: Draft | null;
30
62
  onOpen: (id: string) => void;
@@ -67,26 +99,9 @@ export function Pins({
67
99
 
68
100
  return (
69
101
  <div ref={layer} className="rv-pins">
70
- {comments.map((c) => {
71
- const n = number.get(c.id);
72
- const resolved = c.status === 'resolved';
73
- return (
74
- <button
75
- key={c.id}
76
- type="button"
77
- className="rv-pin"
78
- data-pin={c.id}
79
- data-resolved={resolved ? '' : undefined}
80
- data-active={active === c.id ? '' : undefined}
81
- aria-label={`Comment ${n}${resolved ? ', resolved,' : ''} by ${c.author.name}`}
82
- aria-pressed={active === c.id}
83
- hidden
84
- onClick={() => onOpen(c.id)}
85
- >
86
- <span className="rv-pin-face">{resolved ? <Icon name="check" size={12} /> : n}</span>
87
- </button>
88
- );
89
- })}
102
+ {comments.map((c) => (
103
+ <Pin key={c.id} c={c} active={active === c.id} onOpen={onOpen} />
104
+ ))}
90
105
  {draft?.offset && (
91
106
  <span className="rv-pin" data-draft="" data-new="" aria-hidden="true" hidden>
92
107
  <span className="rv-pin-face" />