@milesroxas/design-hub 0.11.0 → 0.11.2

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.
@@ -273,13 +273,14 @@ export function checkAccess(input: unknown): Checked<Access> {
273
273
  return isAccess(input) ? { ok: true, value: input } : { ok: false, problems: [ACCESS_PROBLEM] };
274
274
  }
275
275
 
276
- export type PersonInput = Pick<Person, 'name' | 'team' | 'kind'> & { access: Access | null };
276
+ /** `team` absent: the service fills it, the studio's name for Studio and the client's for a Client. */
277
+ export type PersonInput = Pick<Person, 'name' | 'kind'> & { team?: string; access: Access | null };
277
278
 
278
279
  export function checkPersonInput(input: unknown): Checked<PersonInput> {
279
280
  const i = (input ?? {}) as Record<string, unknown>;
280
281
  const problems: string[] = [];
281
282
  const name = text(i.name, 'name', LIMITS.name, problems);
282
- const team = text(i.team, 'team', LIMITS.team, problems);
283
+ const team = i.team === undefined ? undefined : text(i.team, 'team', LIMITS.team, problems);
283
284
  // Most people added are on the client's side; Studio is the deliberate choice.
284
285
  const kind = i.kind ?? 'client';
285
286
  if (!PERSON_KINDS.includes(kind as PersonKind)) problems.push(`kind: one of ${PERSON_KINDS.join(', ')}`);
@@ -288,7 +289,15 @@ export function checkPersonInput(input: unknown): Checked<PersonInput> {
288
289
  if (access !== null && !isAccess(access)) problems.push(ACCESS_PROBLEM);
289
290
  return problems.length
290
291
  ? { ok: false, problems }
291
- : { ok: true, value: { name, team, kind: kind as PersonKind, access: access as Access | null } };
292
+ : {
293
+ ok: true,
294
+ value: {
295
+ name,
296
+ ...(team === undefined ? {} : { team }),
297
+ kind: kind as PersonKind,
298
+ access: access as Access | null,
299
+ },
300
+ };
292
301
  }
293
302
 
294
303
  export type ClientInput = Pick<Client, 'slug' | 'host' | 'name'>;
@@ -81,6 +81,22 @@ beforeEach(async () => {
81
81
  await review.setAudience(A, studio, anchor.prototype, 'client');
82
82
  });
83
83
 
84
+ test('without a team, a Studio person gets the studio’s, from whoever adds them, and a Client their client’s name', async () => {
85
+ const mo = (await review.addPerson(A, studio, { name: 'Mo', kind: 'studio' })).person;
86
+ assert.equal(mo.team, studio.team);
87
+ const kim = (await review.addPerson(A, studio, { name: 'Kim' })).person;
88
+ assert.equal(kim.team, 'acme');
89
+ assert.equal((await review.addPerson(B, studio, { name: 'Lu' })).person.team, 'bravo');
90
+ // A team given still wins, and an empty one is still refused.
91
+ assert.equal(
92
+ (await review.addPerson(A, studio, { name: 'Jo', team: 'Freelance' })).person.team,
93
+ 'Freelance',
94
+ );
95
+ await rejects(review.addPerson(A, studio, { name: 'Al', team: ' ' }), 'invalid');
96
+ // The studio's first person has no one to take a team from.
97
+ await rejects(review.addStudioPerson(studio, { name: 'Owner' }), 'invalid');
98
+ });
99
+
84
100
  test('a link works once, and looking at it uses nothing up', async () => {
85
101
  assert.equal((await review.peekLink(A, clientToken))?.id, client.id);
86
102
  assert.equal((await review.peekLink(A, clientToken))?.id, client.id);
@@ -320,10 +320,13 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
320
320
 
321
321
  /** A new Studio person, with no link yet; their records live with the studio. */
322
322
  async function newStudioPerson(input: unknown): Promise<Person> {
323
- const { access, ...fields } = valid(checkPersonInput({ ...(input as object), kind: 'studio' }));
323
+ const { access, team, ...fields } = valid(checkPersonInput({ ...(input as object), kind: 'studio' }));
324
+ // The studio's first person names the studio's team: there is no one to take it from.
325
+ if (!team) throw new ReviewError('invalid', 'Name the team.', ['team: required']);
324
326
  const p: Person = {
325
327
  id: newId(),
326
328
  ...fields,
329
+ team,
327
330
  client: null,
328
331
  email: null,
329
332
  accessEndsAt: accessEnd(access ?? 'open', deps.now()),
@@ -797,16 +800,20 @@ export function createReview(kv: KV, overrides: Partial<Deps> = {}) {
797
800
  /**
798
801
  * A new person and their first link: a Client of the scope's client, or a
799
802
  * Studio person. Without an access length, a Client gets the default and
800
- * Studio is open-ended.
803
+ * Studio is open-ended. Without a team, a Studio person gets the studio's,
804
+ * which every Studio person carries, so the adder's; a Client gets their
805
+ * client's name.
801
806
  */
802
807
  async addPerson(scope: Scope, actor: Person | null, input: unknown): Promise<Issued> {
803
- await allow(scope, actor, 'people', NO_PERSON);
804
- const { access, ...fields } = valid(checkPersonInput(input));
808
+ const by = await allow(scope, actor, 'people', NO_PERSON);
809
+ const { access, team, ...fields } = valid(checkPersonInput(input));
805
810
  // S13: the person's own length, else (a Client) the client's default, then the studio's, then 3m.
806
811
  const length = access ?? (fields.kind === 'studio' ? 'open' : await readDefault(scope));
807
812
  const p: Person = {
808
813
  id: newId(),
809
814
  ...fields,
815
+ team:
816
+ team ?? (fields.kind === 'studio' ? by.team : ((await clientAt(scope.client))?.name ?? 'Client')),
810
817
  client: fields.kind === 'studio' ? null : scope.client,
811
818
  email: null,
812
819
  accessEndsAt: accessEnd(length, deps.now()),
@@ -199,7 +199,9 @@ export type Checked<T> = {
199
199
  problems: string[];
200
200
  };
201
201
  export declare function checkAccess(input: unknown): Checked<Access>;
202
- export type PersonInput = Pick<Person, 'name' | 'team' | 'kind'> & {
202
+ /** `team` absent: the service fills it, the studio's name for Studio and the client's for a Client. */
203
+ export type PersonInput = Pick<Person, 'name' | 'kind'> & {
204
+ team?: string;
203
205
  access: Access | null;
204
206
  };
205
207
  export declare function checkPersonInput(input: unknown): Checked<PersonInput>;
@@ -145,7 +145,7 @@ export function checkPersonInput(input) {
145
145
  const i = (input ?? {});
146
146
  const problems = [];
147
147
  const name = text(i.name, 'name', LIMITS.name, problems);
148
- const team = text(i.team, 'team', LIMITS.team, problems);
148
+ const team = i.team === undefined ? undefined : text(i.team, 'team', LIMITS.team, problems);
149
149
  // Most people added are on the client's side; Studio is the deliberate choice.
150
150
  const kind = i.kind ?? 'client';
151
151
  if (!PERSON_KINDS.includes(kind))
@@ -156,7 +156,15 @@ export function checkPersonInput(input) {
156
156
  problems.push(ACCESS_PROBLEM);
157
157
  return problems.length
158
158
  ? { ok: false, problems }
159
- : { ok: true, value: { name, team, kind: kind, access: access } };
159
+ : {
160
+ ok: true,
161
+ value: {
162
+ name,
163
+ ...(team === undefined ? {} : { team }),
164
+ kind: kind,
165
+ access: access,
166
+ },
167
+ };
160
168
  }
161
169
  /** A new client: a client slug, the host name it is served on (lower case), and its name. */
162
170
  export function checkClientInput(input) {
@@ -166,7 +166,9 @@ export declare function createReview(kv: KV, overrides?: Partial<Deps>): {
166
166
  /**
167
167
  * A new person and their first link: a Client of the scope's client, or a
168
168
  * Studio person. Without an access length, a Client gets the default and
169
- * Studio is open-ended.
169
+ * Studio is open-ended. Without a team, a Studio person gets the studio's,
170
+ * which every Studio person carries, so the adder's; a Client gets their
171
+ * client's name.
170
172
  */
171
173
  addPerson(scope: Scope, actor: Person | null, input: unknown): Promise<Issued>;
172
174
  /** Another one-time link, for another device. Their sessions and other unused links stay. */
@@ -227,10 +227,14 @@ export function createReview(kv, overrides = {}) {
227
227
  }
228
228
  /** A new Studio person, with no link yet; their records live with the studio. */
229
229
  async function newStudioPerson(input) {
230
- const { access, ...fields } = valid(checkPersonInput({ ...input, kind: 'studio' }));
230
+ const { access, team, ...fields } = valid(checkPersonInput({ ...input, kind: 'studio' }));
231
+ // The studio's first person names the studio's team: there is no one to take it from.
232
+ if (!team)
233
+ throw new ReviewError('invalid', 'Name the team.', ['team: required']);
231
234
  const p = {
232
235
  id: newId(),
233
236
  ...fields,
237
+ team,
234
238
  client: null,
235
239
  email: null,
236
240
  accessEndsAt: accessEnd(access ?? 'open', deps.now()),
@@ -673,16 +677,19 @@ export function createReview(kv, overrides = {}) {
673
677
  /**
674
678
  * A new person and their first link: a Client of the scope's client, or a
675
679
  * Studio person. Without an access length, a Client gets the default and
676
- * Studio is open-ended.
680
+ * Studio is open-ended. Without a team, a Studio person gets the studio's,
681
+ * which every Studio person carries, so the adder's; a Client gets their
682
+ * client's name.
677
683
  */
678
684
  async addPerson(scope, actor, input) {
679
- await allow(scope, actor, 'people', NO_PERSON);
680
- const { access, ...fields } = valid(checkPersonInput(input));
685
+ const by = await allow(scope, actor, 'people', NO_PERSON);
686
+ const { access, team, ...fields } = valid(checkPersonInput(input));
681
687
  // S13: the person's own length, else (a Client) the client's default, then the studio's, then 3m.
682
688
  const length = access ?? (fields.kind === 'studio' ? 'open' : await readDefault(scope));
683
689
  const p = {
684
690
  id: newId(),
685
691
  ...fields,
692
+ team: team ?? (fields.kind === 'studio' ? by.team : ((await clientAt(scope.client))?.name ?? 'Client')),
686
693
  client: fields.kind === 'studio' ? null : scope.client,
687
694
  email: null,
688
695
  accessEndsAt: accessEnd(length, deps.now()),
@@ -1,4 +1,4 @@
1
- import type { Scope } from '../../core/review/model.ts';
1
+ import type { Person, Scope } from '../../core/review/model.ts';
2
2
  import { type Review } from '../../core/review/service.ts';
3
3
  import { type ProjectDeps } from './linked.ts';
4
4
  /** Where a linked project's command acts: the studio, the client and its host, and the project. */
@@ -8,15 +8,18 @@ type Where = {
8
8
  host: string;
9
9
  project: string;
10
10
  };
11
+ /** `actor` is who the CLI acts as: Studio, on the studio's team in a linked project, so the people it adds are too. */
11
12
  export type CliReview = {
12
13
  review: Review;
13
14
  store: 'local';
14
15
  scope: Scope;
16
+ actor: Person;
15
17
  studio?: undefined;
16
18
  } | {
17
19
  review: Review;
18
20
  store: 'studio';
19
21
  scope: Scope;
22
+ actor: Person;
20
23
  studio: Where;
21
24
  };
22
25
  /**
@@ -24,5 +27,5 @@ export type CliReview = {
24
27
  * project's studio, else this machine's. --local is always this machine's.
25
28
  */
26
29
  export declare function cliReview(local: boolean, deps?: ProjectDeps): Promise<CliReview>;
27
- export declare const cliActor: () => import("../../core/review/model.ts").Person;
30
+ export declare const cliActor: () => Person;
28
31
  export {};
@@ -10,7 +10,12 @@ import { isStudioFolder } from './studios.js';
10
10
  /** This machine's store, the dev server's, in its one scope. */
11
11
  function localReview(root) {
12
12
  const triage = jevTriager(readEnv(root).TYPESAFE_API_KEY ?? '', checks);
13
- return { review: createReview(fileKV(LOCAL_STORE), { triage }), store: 'local', scope: LOCAL_SCOPE };
13
+ return {
14
+ review: createReview(fileKV(LOCAL_STORE), { triage }),
15
+ store: 'local',
16
+ scope: LOCAL_SCOPE,
17
+ actor: cliActor(),
18
+ };
14
19
  }
15
20
  /**
16
21
  * The store a review command acts on, and the scope it acts in: a linked
@@ -28,11 +33,12 @@ export async function cliReview(local, deps = realProjectDeps()) {
28
33
  });
29
34
  return localReview(deps.root);
30
35
  }
31
- const { review, scope, client } = await openLinked(deps, link);
36
+ const { review, scope, client, studio } = await openLinked(deps, link);
32
37
  return {
33
38
  review,
34
39
  store: 'studio',
35
40
  scope,
41
+ actor: localStudio('cli', studio.config.name),
36
42
  studio: { studio: link.studio, client: client.slug, host: client.host, project: link.project },
37
43
  };
38
44
  }
@@ -18,7 +18,7 @@ export declare const spec: {
18
18
  };
19
19
  readonly team: {
20
20
  readonly type: 'string';
21
- readonly description: "For add: the studio, or the client's company.";
21
+ readonly description: "For add: shown beside their name. Absent, the studio's name for studio and the client's name for client.";
22
22
  };
23
23
  readonly kind: {
24
24
  readonly type: 'string';
@@ -9,7 +9,7 @@
9
9
  import { ACCESS, PERSON_KINDS } from '../core/review/model.js';
10
10
  import { CliError } from './lib/cli.js';
11
11
  import { realProjectDeps } from './lib/linked.js';
12
- import { cliActor, cliReview } from './lib/review.js';
12
+ import { cliReview } from './lib/review.js';
13
13
  export const spec = {
14
14
  name: 'people',
15
15
  summary: 'List or add the people who comment on the deployed prototypes, give them sign-in links, sign them out, revoke them, and set how long they keep access.',
@@ -22,7 +22,10 @@ export const spec = {
22
22
  ],
23
23
  flags: {
24
24
  name: { type: 'string', description: 'For add: their name as it shows on comments.' },
25
- team: { type: 'string', description: "For add: the studio, or the client's company." },
25
+ team: {
26
+ type: 'string',
27
+ description: "For add: shown beside their name. Absent, the studio's name for studio and the client's name for client.",
28
+ },
26
29
  kind: {
27
30
  type: 'string',
28
31
  default: 'client',
@@ -98,7 +101,7 @@ export async function run({ positionals: [action = 'list', id], flags }, deps) {
98
101
  const found = await cliReview(flags.local, deps);
99
102
  const { review, store, scope } = found;
100
103
  // A linked project's links sign in on its client's own host, and nowhere else.
101
- const done = await act({ review, scope, actor: cliActor(), flags, id, host: found.studio?.host });
104
+ const done = await act({ review, scope, actor: found.actor, flags, id, host: found.studio?.host });
102
105
  return {
103
106
  store,
104
107
  ...(found.studio ? { studio: found.studio } : {}),
@@ -101,7 +101,7 @@ export async function run({ flags }, deps) {
101
101
  ...(guide ? { guide: `${address}${guide}` } : {}),
102
102
  })),
103
103
  ...(await prune(store, scope)),
104
- next: `Send ${address} with each person’s own sign-in link: pnpm people add --name "<name>" --team "<team>" prints one on ${client.host}. Someone already signed in there sees the project at once. A link signs in one device, then stops working.`,
104
+ next: `Send ${address} with each person’s own sign-in link: pnpm people add --name "<name>" prints one on ${client.host}. Someone already signed in there sees the project at once. A link signs in one device, then stops working.`,
105
105
  };
106
106
  }
107
107
  finally {
@@ -38,7 +38,8 @@ const listed = ({ slug, name }) => ({ slug, name });
38
38
  async function query(op, params, { review, actor, scope }) {
39
39
  switch (op) {
40
40
  case 'me':
41
- return { person: actor ? visible(actor) : null };
41
+ // The client is this request's: the page judges its controls in it, as the service does every op.
42
+ return actor ? { person: visible(actor), client: scope.client } : { person: null };
42
43
  case 'comments':
43
44
  // viewAs=client is Studio's Client view; the service checks the value and never widens a Client's view.
44
45
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milesroxas/design-hub",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
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": {
@@ -59,7 +59,7 @@ function AddForm({
59
59
  setBusy(true);
60
60
  act(
61
61
  store
62
- .addPerson(name, String(f.get('team') ?? ''), kind, access === 'default' ? null : (access as Access))
62
+ .addPerson(name, kind, access === 'default' ? null : (access as Access))
63
63
  .then((href) => {
64
64
  onLink({ name, href });
65
65
  form.reset();
@@ -80,17 +80,6 @@ function AddForm({
80
80
  data-autofocus=""
81
81
  />
82
82
  </label>
83
- <label className="field">
84
- <span className="field-label">Team</span>
85
- <input
86
- className="input"
87
- name="team"
88
- required
89
- maxLength={LIMITS.team}
90
- autoComplete="off"
91
- placeholder="Studio, or the client’s company"
92
- />
93
- </label>
94
83
  <div className="field">
95
84
  <span id={kindLabel} className="field-label">
96
85
  Kind
@@ -14,7 +14,7 @@ import { can, viewOf } from '../../core/review/policy';
14
14
  import { captureAnchor, currentUrl, openAnchor, pinPoint, resumeAnchor } from './anchor';
15
15
  import { Bar } from './Bar';
16
16
  import { Card } from './Card';
17
- import { createReviewStore, ownScope, type ReviewStore, useReviewState } from './client';
17
+ import { createReviewStore, pageScope, type ReviewStore, useReviewState } from './client';
18
18
  import { Field } from './Field';
19
19
  import { Launcher } from './Launcher';
20
20
  import { People } from './People';
@@ -44,8 +44,9 @@ type State = ReturnType<ReviewStore['get']>;
44
44
  type Where = { prototype: string; feature: string };
45
45
  type Lens = ReturnType<typeof lensOf>;
46
46
 
47
- /** Studio in Client view: the same person, judged by the rules as a Client, so Studio's controls step aside. */
48
- const asClient = (s: State): State => (s.me ? { ...s, me: { ...s.me, kind: 'client' } } : s);
47
+ /** Studio in Client view: the same person, judged by the rules as a Client of this page's client, so Studio's controls step aside. */
48
+ const asClient = (s: State): State =>
49
+ s.me ? { ...s, me: { ...s.me, kind: 'client', client: s.client } } : s;
49
50
 
50
51
  /** The page's path, query and hash, kept current as hash routes change. */
51
52
  function useCurrentUrl(): string {
@@ -300,7 +301,7 @@ function ModeBar({
300
301
  }}
301
302
  resolved={v.resolved}
302
303
  resolvedCount={roots.filter((c) => c.status === 'resolved').length}
303
- canManagePeople={can(s.me, ownScope(s.me), 'people')}
304
+ canManagePeople={can(s.me, pageScope(s), 'people')}
304
305
  canFilter={lens.asStudio}
305
306
  filter={v.filter}
306
307
  filterNote={filterNote(v)}
@@ -351,6 +352,7 @@ function OpenThread({
351
352
  <ThreadCard
352
353
  store={store}
353
354
  me={s.me}
355
+ scope={pageScope(s)}
354
356
  root={root}
355
357
  replies={s.comments.filter((c) => c.thread === root.id && c.id !== root.id)}
356
358
  mark={mark}
@@ -8,10 +8,18 @@
8
8
  import { Icon } from '@kit/Icon';
9
9
  import { Button, type MenuEntry, useMenu } from '@kit/ui';
10
10
  import { type KeyboardEvent, useEffect, useState } from 'react';
11
- import { type Audience, type Comment, KINDS, type Kind, LIMITS, threadLabel } from '../../core/review/model';
11
+ import {
12
+ type Audience,
13
+ type Comment,
14
+ KINDS,
15
+ type Kind,
16
+ LIMITS,
17
+ type Scope,
18
+ threadLabel,
19
+ } from '../../core/review/model';
12
20
  import { can } from '../../core/review/policy';
13
21
  import { Action, Card } from './Card';
14
- import { act, type Me, ownScope, type ReviewStore } from './client';
22
+ import { act, type Me, type ReviewStore } from './client';
15
23
  import { Field, useTextBox } from './Field';
16
24
 
17
25
  const KIND_LABEL: Record<Kind, string> = { bug: 'Bug', taste: 'Taste', copy: 'Copy' };
@@ -152,12 +160,15 @@ function Tags({ tags }: { tags: string[] }) {
152
160
  function Entry({
153
161
  store,
154
162
  me,
163
+ scope,
155
164
  root,
156
165
  comment,
157
166
  tags = [],
158
167
  }: {
159
168
  store: ReviewStore;
160
169
  me: Me | null;
170
+ /** The page's scope, which the controls are judged in (pageScope). */
171
+ scope: Scope;
161
172
  root: Comment;
162
173
  comment: Comment;
163
174
  tags?: string[];
@@ -169,7 +180,7 @@ function Entry({
169
180
  <div className="rv-msg-main">
170
181
  <EntryHead
171
182
  comment={comment}
172
- canEdit={can(me, ownScope(me), 'edit', root, comment) && !editing}
183
+ canEdit={can(me, scope, 'edit', root, comment) && !editing}
173
184
  onEdit={() => setEditing(true)}
174
185
  />
175
186
  {editing ? (
@@ -442,6 +453,7 @@ function ThreadHead({
442
453
  export function ThreadCard({
443
454
  store,
444
455
  me,
456
+ scope,
445
457
  root,
446
458
  replies,
447
459
  mark,
@@ -455,6 +467,7 @@ export function ThreadCard({
455
467
  }: {
456
468
  store: ReviewStore;
457
469
  me: Me | null;
470
+ scope: Scope;
458
471
  root: Comment;
459
472
  replies: Comment[];
460
473
  mark: boolean;
@@ -484,9 +497,9 @@ export function ThreadCard({
484
497
  index={index}
485
498
  total={total}
486
499
  states={states}
487
- canResolve={can(me, ownScope(me), 'resolve', root)}
488
- canTriage={can(me, ownScope(me), 'triage', root)}
489
- canDelete={can(me, ownScope(me), 'delete', root)}
500
+ canResolve={can(me, scope, 'resolve', root)}
501
+ canTriage={can(me, scope, 'triage', root)}
502
+ canDelete={can(me, scope, 'delete', root)}
490
503
  onStep={onStep}
491
504
  onClose={onClose}
492
505
  onShow={onShow}
@@ -494,9 +507,9 @@ export function ThreadCard({
494
507
  />
495
508
  <ResolvedBand root={root} />
496
509
  <div className="rv-card-body">
497
- <Entry store={store} me={me} root={root} comment={root} tags={tagsOf(root)} />
510
+ <Entry store={store} me={me} scope={scope} root={root} comment={root} tags={tagsOf(root)} />
498
511
  {replies.map((r) => (
499
- <Entry key={r.id} store={store} me={me} root={root} comment={r} />
512
+ <Entry key={r.id} store={store} me={me} scope={scope} root={root} comment={r} />
500
513
  ))}
501
514
  </div>
502
515
  <Foot store={store} root={root} confirming={confirming} onKeep={() => setConfirming(false)} />
@@ -11,17 +11,20 @@ import { afterFailure, signedOutState } from './view';
11
11
  export type Me = Omit<Person, 'epoch'>;
12
12
 
13
13
  /**
14
- * The scope the page judges its own controls in: the person's own. The
15
- * server answers nothing outside the real one, so this only decides which
16
- * buttons show.
14
+ * The scope the page judges its own controls in: the client this page is
15
+ * in, as `me` names it. Studio has no client of its own, so its person's
16
+ * `client` cannot stand in. The server answers nothing outside the real
17
+ * scope, so this only decides which buttons show.
17
18
  */
18
- export const ownScope = (me: Me | null): Scope => ({ client: me?.client ?? '' });
19
+ export const pageScope = (s: { client: string }): Scope => ({ client: s.client });
19
20
  /** off: this site has no review store, so the UI stays out of the way. guest: the session ended since the page loaded. */
20
21
  type Status = 'loading' | 'ready' | 'guest' | 'off';
21
22
 
22
23
  type State = {
23
24
  status: Status;
24
25
  me: Me | null;
26
+ /** The client this page is in, from `me`; empty until it loads. */
27
+ client: string;
25
28
  comments: Comment[];
26
29
  people: Me[] | null;
27
30
  /** The project default access length, loaded with the people. */
@@ -102,7 +105,15 @@ export const noApi = (error: unknown) =>
102
105
  isOff(error) || (error instanceof ApiError && error.notJson && !signedOut(error));
103
106
 
104
107
  export function createReviewStore(prototype: string) {
105
- let state: State = { status: 'loading', me: null, comments: [], people: null, access: null, error: null };
108
+ let state: State = {
109
+ status: 'loading',
110
+ me: null,
111
+ client: '',
112
+ comments: [],
113
+ people: null,
114
+ access: null,
115
+ error: null,
116
+ };
106
117
  const listeners = new Set<() => void>();
107
118
  /** Counts loads, so an answer to an older one (Client view turned on and off fast) is dropped. */
108
119
  let loads = 0;
@@ -156,13 +167,13 @@ export function createReviewStore(prototype: string) {
156
167
  async load(viewAs?: PersonKind) {
157
168
  const n = ++loads;
158
169
  try {
159
- const { person } = await call<{ person: Me | null }>('me');
170
+ const { person, client = '' } = await call<{ person: Me | null; client?: string }>('me');
160
171
  if (n !== loads) return;
161
172
  if (!person) return set({ status: 'guest', me: null });
162
173
  const params = { prototype, ...(viewAs ? { viewAs } : {}) };
163
174
  const { comments } = await call<{ comments: Comment[] }>('comments', undefined, params);
164
175
  if (n !== loads) return;
165
- set({ status: 'ready', me: person, comments, error: null });
176
+ set({ status: 'ready', me: person, client, comments, error: null });
166
177
  } catch (error) {
167
178
  if (n !== loads) return;
168
179
  if (signedOut(error)) set(signedOutState());
@@ -218,8 +229,9 @@ export function createReviewStore(prototype: string) {
218
229
  set({ people, access });
219
230
  }),
220
231
  /** A new person; `access` null takes the default for their kind. Resolves to their link. */
221
- addPerson: (name: string, team: string, kind: PersonKind, access: Access | null) =>
222
- linkOf(call('people.add', { name, team, kind, ...(access ? { access } : {}) })),
232
+ /** The server names their team: the studio's for Studio, the client's for a Client. */
233
+ addPerson: (name: string, kind: PersonKind, access: Access | null) =>
234
+ linkOf(call('people.add', { name, kind, ...(access ? { access } : {}) })),
223
235
  /** Another one-time link, for another device. */
224
236
  newLink: (id: string) => linkOf(call('people.link', { id })),
225
237
  /** Ends every session and unused link; resolves to the one new link. */
@@ -121,10 +121,10 @@ Before the handover, check that each prototype it names is switched to client-fa
121
121
  People belong to the linked project's client. Each gets their own link, on the client's address:
122
122
 
123
123
  ```bash
124
- pnpm people add --name "<name>" --team "<company>"
124
+ pnpm people add --name "<name>"
125
125
  ```
126
126
 
127
- A Client is the default kind. `--kind studio` makes a Studio person, who sees every client of the studio; the command says so in `notice`. Studio adds people from the People tab too (the round comments button, then **⋯**, **People**).
127
+ A Client is the default kind. Their team, shown beside their name, is the client's name; a Studio person's is the studio's. `--team` overrides it, only for someone outside both (a freelancer's own company). `--kind studio` makes a Studio person, who sees every client of the studio; the command says so in `notice`. Studio adds people from the People tab too (the round comments button, then **⋯**, **People**).
128
128
 
129
129
  - **A link signs in one device, then stops working.** Opening it shows who it is for and a Continue button; Continue uses it up. Why: a mail or chat preview opens links too, and must not use one up. An unused link lasts 14 days.
130
130
  - **Another device, or a link that stopped working:** `pnpm people link <id>` gives one more link. Their other devices stay signed in.
@@ -92,7 +92,7 @@ The user does nothing in a terminal here; each step that needs them is one link
92
92
  1. A new client, with the owner's word: `pnpm --dir <path> signin` first (signed out, it prints a `url`: send it to the user, then `pnpm --dir <path> signin --wait 300`), then `pnpm --dir <path> client add <client> --studio <studio> --name "<client name>" --person "<client's first person>" --team "<their company>"`. `links.client` is for that person only: put it in a message addressed to them, and tell the user not to open it, since it signs in whoever opens it first. `links.studio` is the studio owner's link on the client's address: it is the user's when they are the owner. `miles-deploy` has the rest.
93
93
  2. `pnpm --dir <path> project link --studio <studio> --client <client> --project <name>`, then commit `.design-hub/studio.json`.
94
94
  3. `pnpm --dir <path> share`. On `ok: false`, follow `stage` and `fix` (the pre-flight steps are in `miles-deploy`).
95
- 4. The user's own Studio link, unless `links.studio` was theirs: when `pnpm --dir <path> people` lists them, `pnpm --dir <path> people link <id>`; else `pnpm --dir <path> people add --name "<user>" --team "<studio name>" --kind studio`.
95
+ 4. The user's own Studio link, unless `links.studio` was theirs: when `pnpm --dir <path> people` lists them, `pnpm --dir <path> people link <id>`; else `pnpm --dir <path> people add --name "<user>" --kind studio`.
96
96
 
97
97
  Give the user the `address` and their own `link` in the closing message, say the link signs in one device and then stops working, that each prototype is internal until they switch it to client-facing, and that the address shows the samples until the first feature replaces them.
98
98
 
@@ -32,7 +32,7 @@ Each thread line starts with its label and its audience: `- #I3 (internal) Ed (S
32
32
 
33
33
  - Every person is **Studio** or **Client**. Both comment, reply, edit their own words, and resolve or reopen any thread they can see. A Client sees client-facing threads only; Studio sees all, internal ones included. A thread's audience never changes: to tell the client what an internal thread says, Studio writes a new client-facing comment in the panel. Never paste internal words into a client-facing one without the user's say. Studio also deletes any comment, sorts comments and manages people; a Client deletes only their own. The studio's team are Studio; everyone on the client's side is Client, the default.
34
34
  - **Team** is the company: `Studio`, or the client's name. It shows beside every name, so a reviewer reads who said what.
35
- - People belong to the linked project's client. The studio's owner gets a link on each new client's address from `client add`; anyone else comes from `pnpm people add --name <n> --team <t> [--kind studio]`, or from the People tab.
35
+ - People belong to the linked project's client. The studio's owner gets a link on each new client's address from `client add`; anyone else comes from `pnpm people add --name <n> [--kind studio]`, or from the People tab.
36
36
  - A link signs in one device, then stops working; unused, it lasts 14 days. `pnpm people link <id>` gives another for another device, `sign-out <id>` ends every session and gives one new link, and `revoke <id>` ends their access everywhere within five minutes. `miles-deploy` holds the rest: access length, the handover.
37
37
  - Never paste a link into a commit, a document, a ticket or a comment. Why: whoever opens it first signs in as that person.
38
38
 
@@ -34,7 +34,7 @@ In a project, once its studio is listed on the machine:
34
34
  ```bash
35
35
  design-hub project link --studio <studio> --client <client> --project <project> # commit .design-hub/studio.json
36
36
  design-hub share # prints https://<client host>/<project>/
37
- design-hub people add --name "<name>" --team "<team>" # a link on the client's host
37
+ design-hub people add --name "<name>" # a link on the client's host
38
38
  ```
39
39
 
40
40
  - **DNS.** `vercel`: the apex is on Vercel's nameservers and one wildcard serves
@@ -9,7 +9,7 @@
9
9
  "build": "node build.mjs"
10
10
  },
11
11
  "dependencies": {
12
- "@milesroxas/design-hub": "0.11.0",
12
+ "@milesroxas/design-hub": "0.11.2",
13
13
  "react": "^19.3.1",
14
14
  "react-dom": "^19.3.1"
15
15
  }