@skillcdn/console 0.4.5 → 0.4.7

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 (138) hide show
  1. package/README.md +4 -4
  2. package/dist/api.d.ts +2 -2
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/api.js +2 -2
  5. package/dist/api.js.map +1 -1
  6. package/dist/cli/cli.d.ts +6 -0
  7. package/dist/cli/cli.d.ts.map +1 -1
  8. package/dist/cli/cli.js +83 -42
  9. package/dist/cli/cli.js.map +1 -1
  10. package/dist/cli/format.d.ts +8 -1
  11. package/dist/cli/format.d.ts.map +1 -1
  12. package/dist/cli/format.js +11 -2
  13. package/dist/cli/format.js.map +1 -1
  14. package/dist/cli/help.d.ts.map +1 -1
  15. package/dist/cli/help.js +22 -10
  16. package/dist/cli/help.js.map +1 -1
  17. package/dist/cli/keys.d.ts +10 -0
  18. package/dist/cli/keys.d.ts.map +1 -0
  19. package/dist/cli/keys.js +59 -0
  20. package/dist/cli/keys.js.map +1 -0
  21. package/dist/cli/main.js +2 -1
  22. package/dist/cli/main.js.map +1 -1
  23. package/dist/cli/terminal.d.ts +7 -0
  24. package/dist/cli/terminal.d.ts.map +1 -1
  25. package/dist/cli/terminal.js +39 -0
  26. package/dist/cli/terminal.js.map +1 -1
  27. package/dist/client.d.ts +9 -1
  28. package/dist/client.d.ts.map +1 -1
  29. package/dist/client.js +5 -1
  30. package/dist/client.js.map +1 -1
  31. package/dist/components/plugin-frame.d.ts.map +1 -1
  32. package/dist/components/plugin-frame.js +73 -17
  33. package/dist/components/plugin-frame.js.map +1 -1
  34. package/dist/components/sessions.d.ts +15 -0
  35. package/dist/components/sessions.d.ts.map +1 -0
  36. package/dist/components/sessions.js +17 -0
  37. package/dist/components/sessions.js.map +1 -0
  38. package/dist/components/shell.d.ts.map +1 -1
  39. package/dist/components/shell.js +198 -28
  40. package/dist/components/shell.js.map +1 -1
  41. package/dist/components/workspace.d.ts +2 -0
  42. package/dist/components/workspace.d.ts.map +1 -1
  43. package/dist/components/workspace.js +19 -4
  44. package/dist/components/workspace.js.map +1 -1
  45. package/dist/console.css +228 -21
  46. package/dist/console.d.ts +5 -2
  47. package/dist/console.d.ts.map +1 -1
  48. package/dist/console.js +106 -21
  49. package/dist/console.js.map +1 -1
  50. package/dist/data.d.ts +7 -1
  51. package/dist/data.d.ts.map +1 -1
  52. package/dist/data.js +26 -5
  53. package/dist/data.js.map +1 -1
  54. package/dist/i18n/en.d.ts +24 -0
  55. package/dist/i18n/en.d.ts.map +1 -1
  56. package/dist/i18n/en.js +21 -0
  57. package/dist/i18n/en.js.map +1 -1
  58. package/dist/i18n/index.d.ts +2 -2
  59. package/dist/i18n/index.d.ts.map +1 -1
  60. package/dist/i18n/index.js +7 -3
  61. package/dist/i18n/index.js.map +1 -1
  62. package/dist/i18n/ko.d.ts.map +1 -1
  63. package/dist/i18n/ko.js +23 -2
  64. package/dist/i18n/ko.js.map +1 -1
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -0
  68. package/dist/index.js.map +1 -1
  69. package/dist/plugin/bridge.d.ts +7 -3
  70. package/dist/plugin/bridge.d.ts.map +1 -1
  71. package/dist/plugin/bridge.js +1 -0
  72. package/dist/plugin/bridge.js.map +1 -1
  73. package/dist/plugin/context.d.ts +16 -1
  74. package/dist/plugin/context.d.ts.map +1 -1
  75. package/dist/plugin/define.d.ts.map +1 -1
  76. package/dist/plugin/define.js +6 -3
  77. package/dist/plugin/define.js.map +1 -1
  78. package/dist/plugin/sandbox.d.ts.map +1 -1
  79. package/dist/plugin/sandbox.js +8 -1
  80. package/dist/plugin/sandbox.js.map +1 -1
  81. package/dist/plugin/web.d.ts +16 -3
  82. package/dist/plugin/web.d.ts.map +1 -1
  83. package/dist/plugin/web.js +8 -1
  84. package/dist/plugin/web.js.map +1 -1
  85. package/dist/router.d.ts +6 -0
  86. package/dist/router.d.ts.map +1 -1
  87. package/dist/router.js +5 -0
  88. package/dist/router.js.map +1 -1
  89. package/dist/routes.d.ts +3 -1
  90. package/dist/routes.d.ts.map +1 -1
  91. package/dist/routes.js +2 -0
  92. package/dist/routes.js.map +1 -1
  93. package/dist/schemas.d.ts +38 -0
  94. package/dist/schemas.d.ts.map +1 -1
  95. package/dist/schemas.js +37 -1
  96. package/dist/schemas.js.map +1 -1
  97. package/dist/tokens.d.ts.map +1 -1
  98. package/dist/tokens.js +1 -0
  99. package/dist/tokens.js.map +1 -1
  100. package/dist/vocabulary.d.ts +6 -0
  101. package/dist/vocabulary.d.ts.map +1 -1
  102. package/dist/vocabulary.js +7 -0
  103. package/dist/vocabulary.js.map +1 -1
  104. package/docs/specs/cli.md +5 -5
  105. package/docs/specs/plugins.md +28 -15
  106. package/docs/specs/rest.md +12 -8
  107. package/package.json +1 -1
  108. package/skills/building-a-plugin/SKILL.md +3 -3
  109. package/skills/planning-the-board/references/setting-up.md +1 -1
  110. package/src/api.ts +6 -0
  111. package/src/cli/cli.ts +115 -43
  112. package/src/cli/format.ts +15 -2
  113. package/src/cli/help.ts +22 -10
  114. package/src/cli/keys.ts +69 -0
  115. package/src/cli/main.ts +2 -1
  116. package/src/cli/terminal.ts +40 -0
  117. package/src/client.ts +18 -0
  118. package/src/components/plugin-frame.tsx +92 -24
  119. package/src/components/sessions.tsx +108 -0
  120. package/src/components/shell.tsx +265 -52
  121. package/src/components/workspace.tsx +46 -2
  122. package/src/console.tsx +181 -16
  123. package/src/data.ts +33 -5
  124. package/src/i18n/en.ts +25 -0
  125. package/src/i18n/index.ts +11 -3
  126. package/src/i18n/ko.ts +27 -2
  127. package/src/index.ts +1 -0
  128. package/src/plugin/bridge.ts +8 -3
  129. package/src/plugin/context.ts +16 -1
  130. package/src/plugin/define.ts +10 -2
  131. package/src/plugin/sandbox.ts +9 -1
  132. package/src/plugin/web.ts +21 -4
  133. package/src/router.ts +7 -0
  134. package/src/routes.ts +3 -1
  135. package/src/schemas.ts +41 -0
  136. package/src/styles/console.css +228 -21
  137. package/src/tokens.ts +1 -0
  138. package/src/vocabulary.ts +9 -0
package/src/console.tsx CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  type RestProjectRules,
32
32
  type RestReachedDecision,
33
33
  type RestRules,
34
+ type RestSessions,
34
35
  type RestTask,
35
36
  type RestTaskInput,
36
37
  type RestToken,
@@ -72,6 +73,7 @@ import {
72
73
  import { type RemotePictureSrc, RemotePicturesContext } from "./components/remote-pictures.js";
73
74
  import { GoalTimeline } from "./components/roadmap.js";
74
75
  import { RulesForm, RulesView } from "./components/rules.js";
76
+ import { SessionList, type SessionListProps } from "./components/sessions.js";
75
77
  import {
76
78
  type Brand,
77
79
  isPlainClick,
@@ -166,6 +168,7 @@ export interface ConsoleComponents {
166
168
  readonly EventFeed: ComponentType<EventFeedProps>;
167
169
  readonly SignIn: ComponentType<SignInProps>;
168
170
  readonly TokenList: ComponentType<TokenListProps>;
171
+ readonly SessionList: ComponentType<SessionListProps>;
169
172
  readonly PeopleList: ComponentType<PeopleListProps>;
170
173
  readonly TeamList: ComponentType<TeamListProps>;
171
174
  readonly SkillList: ComponentType<SkillListProps>;
@@ -185,6 +188,7 @@ export const DEFAULT_COMPONENTS: ConsoleComponents = {
185
188
  EventFeed,
186
189
  SignIn,
187
190
  TokenList,
191
+ SessionList,
188
192
  PeopleList,
189
193
  TeamList,
190
194
  SkillList,
@@ -414,12 +418,14 @@ export function languageToKeep(
414
418
 
415
419
  /**
416
420
  * The pages a console that holds a token does not offer: the tokens themselves, and the
417
- * approval of an agent's connection, which makes one; a person's own doing on the console's
418
- * own pages, signed in. Everything else a person may do, their agent may (ADR-0021).
421
+ * approval of an agent's connection, which makes one; the browsers signed in; a person's own
422
+ * doing on the console's own pages, signed in. Everything else a person may do, their agent may
423
+ * (ADR-0021).
419
424
  */
420
425
  export function onlyOnOwnPages(route: Route): boolean {
421
426
  return (
422
427
  route.name === "agents" ||
428
+ route.name === "sessions" ||
423
429
  route.name === "new-token" ||
424
430
  route.name === "person-agents" ||
425
431
  route.name === "connect"
@@ -1796,6 +1802,106 @@ function ProjectSettingsPage(props: {
1796
1802
  );
1797
1803
  }
1798
1804
 
1805
+ /**
1806
+ * The views of the settings: the workspace's, read by everyone, and the browsers the person is
1807
+ * signed in on (board #309), which a console that holds a token does not offer, and so does not
1808
+ * name.
1809
+ */
1810
+ function SettingsViews(props: { readonly on: "workspace" | "sessions" }) {
1811
+ const views = useWords().settings.views;
1812
+ return (
1813
+ <nav className="sc-subtabs sc-settings-views" aria-label={views.aria}>
1814
+ <a
1815
+ className={cx("sc-tab", props.on === "workspace" && "sc-tab-current")}
1816
+ href={PATHS.settings}
1817
+ aria-current={props.on === "workspace" ? "page" : undefined}
1818
+ >
1819
+ {views.workspace}
1820
+ </a>
1821
+ <a
1822
+ className={cx("sc-tab", props.on === "sessions" && "sc-tab-current")}
1823
+ href={PATHS.sessions}
1824
+ aria-current={props.on === "sessions" ? "page" : undefined}
1825
+ >
1826
+ {views.sessions}
1827
+ </a>
1828
+ </nav>
1829
+ );
1830
+ }
1831
+
1832
+ /**
1833
+ * The browsers whoever is signed in is signed in on (board #309): read when the page opens, and
1834
+ * again once one of them, or all the others, are signed out.
1835
+ */
1836
+ function SessionsPage(props: {
1837
+ readonly data: ConsoleData;
1838
+ readonly components: ConsoleComponents;
1839
+ }) {
1840
+ const words = useWords();
1841
+ const { data, components } = props;
1842
+ const { busy, error, act } = useAction();
1843
+ const [sessions, setSessions] = useState<RestSessions | undefined>(undefined);
1844
+ const [failure, setFailure] = useState<string | undefined>(undefined);
1845
+ const read = data.actions.sessions;
1846
+ useEffect(() => {
1847
+ const controller = new AbortController();
1848
+ read(controller.signal)
1849
+ .then((found) => {
1850
+ if (!controller.signal.aborted) {
1851
+ setSessions(found);
1852
+ }
1853
+ })
1854
+ .catch((caught: unknown) => {
1855
+ if (!controller.signal.aborted) {
1856
+ setFailure(errorWords(caught, words.common.somethingWentWrong, words));
1857
+ }
1858
+ });
1859
+ return () => controller.abort();
1860
+ }, [read, words]);
1861
+ return (
1862
+ <>
1863
+ <div className="sc-page-head">
1864
+ <h1 className="sc-page-title">{words.settings.title}</h1>
1865
+ </div>
1866
+ <SettingsViews on="sessions" />
1867
+ {(error ?? failure) !== undefined && <Callout tone="danger">{error ?? failure}</Callout>}
1868
+ {sessions === undefined ? (
1869
+ failure === undefined && (
1870
+ <div className="sc-loading">
1871
+ <Spinner label={words.sessions.loading} />
1872
+ </div>
1873
+ )
1874
+ ) : (
1875
+ <components.SessionList
1876
+ sessions={sessions.items}
1877
+ idleDays={sessions.idleDays}
1878
+ busy={busy}
1879
+ onEnd={(session) =>
1880
+ void act(async () => {
1881
+ // Read again whether it went or not: one ended from elsewhere, or whose time
1882
+ // ended, is not found, and its row goes all the same.
1883
+ try {
1884
+ await data.actions.endSession(session.id);
1885
+ } finally {
1886
+ setSessions(await read());
1887
+ }
1888
+ })
1889
+ }
1890
+ onEndOthers={() =>
1891
+ void act(async () => {
1892
+ try {
1893
+ await data.actions.endOtherSessions();
1894
+ } finally {
1895
+ setSessions(await read());
1896
+ }
1897
+ })
1898
+ }
1899
+ />
1900
+ )}
1901
+ </>
1902
+ );
1903
+ }
1904
+
1799
1905
  /**
1800
1906
  * The workspace's settings (ADR-0023): its rules, the console's own until an administrator
1801
1907
  * writes the organization's; its categories, kept on their own page; and where its skills come
@@ -1943,6 +2049,7 @@ function WorkspaceSettingsPage(props: {
1943
2049
  return (
1944
2050
  <>
1945
2051
  {head}
2052
+ {!holdsToken(data) && <SettingsViews on="workspace" />}
1946
2053
  {error !== undefined && <Callout tone="danger">{error}</Callout>}
1947
2054
  {workspace !== undefined && (
1948
2055
  <section className="sc-panel" aria-label={words.settings.workspace.aria}>
@@ -2169,10 +2276,23 @@ interface Plate {
2169
2276
  * A plate, read when the page is opened: the person's own, or another person's for whoever
2170
2277
  * oversees them. The week at the top is the address's.
2171
2278
  */
2279
+ /**
2280
+ * What a person's own pages showed last, by what each read: come back to, a page stands at once
2281
+ * with what it showed and reads again behind it, rather than wait on the server every time a
2282
+ * tab is pressed. Forgotten when the person signs out.
2283
+ */
2284
+ const shownBefore = new Map<string, unknown>();
2285
+
2286
+ function rememberedAs<T>(key: string): T | undefined {
2287
+ return shownBefore.get(key) as T | undefined;
2288
+ }
2289
+
2172
2290
  function PlatePage(props: {
2173
2291
  readonly components: ConsoleComponents;
2174
2292
  /** Reads the plate; stable across renders, since the page reads again whenever it changes. */
2175
2293
  readonly load: (signal: AbortSignal) => Promise<Plate>;
2294
+ /** What the plate is remembered by, with whose it is: come back to, the page shows it at once and reads again. */
2295
+ readonly remember: string;
2176
2296
  readonly title: string;
2177
2297
  /** What stands beside the title: the way back, on another person's plate. */
2178
2298
  readonly aside?: ReactNode;
@@ -2188,18 +2308,19 @@ function PlatePage(props: {
2188
2308
  readonly weekStart?: WeekStart | undefined;
2189
2309
  }) {
2190
2310
  const words = useWords();
2191
- const { components, load, couldNotLoad, refused } = props;
2192
- const [plate, setPlate] = useState<Plate | undefined>(undefined);
2311
+ const { components, load, couldNotLoad, refused, remember } = props;
2312
+ const [plate, setPlate] = useState<Plate | undefined>(() => rememberedAs<Plate>(remember));
2193
2313
  const [problem, setProblem] = useState<string | undefined>(undefined);
2194
2314
  const [forbidden, setForbidden] = useState(false);
2195
2315
  useEffect(() => {
2196
2316
  const controller = new AbortController();
2197
- setPlate(undefined);
2317
+ setPlate(rememberedAs<Plate>(remember));
2198
2318
  setProblem(undefined);
2199
2319
  setForbidden(false);
2200
2320
  load(controller.signal)
2201
2321
  .then((answer) => {
2202
2322
  if (!controller.signal.aborted) {
2323
+ shownBefore.set(remember, answer);
2203
2324
  setPlate(answer);
2204
2325
  }
2205
2326
  })
@@ -2218,7 +2339,7 @@ function PlatePage(props: {
2218
2339
  }
2219
2340
  });
2220
2341
  return () => controller.abort();
2221
- }, [load, couldNotLoad, refused]);
2342
+ }, [load, couldNotLoad, refused, remember]);
2222
2343
  return (
2223
2344
  <>
2224
2345
  <div className="sc-page-head">
@@ -2336,13 +2457,25 @@ interface DecisionsRead {
2336
2457
  }
2337
2458
 
2338
2459
  /** The decisions addressed to the person, or, with `raised`, those they raised for someone else (ADR-0042). */
2460
+ /** The first page of a person's decisions as it was shown last, remembered for the next time. */
2461
+ interface RememberedDecisions {
2462
+ readonly items: RestMyDecisions["items"];
2463
+ readonly more: boolean;
2464
+ }
2465
+
2339
2466
  function useMyDecisions(
2340
2467
  myDecisions: ConsoleData["actions"]["myDecisions"],
2341
2468
  raised: boolean,
2342
2469
  couldNotLoad: string,
2470
+ /** What the first page is remembered by, with whose it is. */
2471
+ remember: string,
2343
2472
  ): DecisionsRead {
2344
- const [items, setItems] = useState<RestMyDecisions["items"] | undefined>(undefined);
2345
- const [more, setMore] = useState(false);
2473
+ const [items, setItems] = useState<RestMyDecisions["items"] | undefined>(
2474
+ () => rememberedAs<RememberedDecisions>(remember)?.items,
2475
+ );
2476
+ const [more, setMore] = useState(
2477
+ () => rememberedAs<RememberedDecisions>(remember)?.more ?? false,
2478
+ );
2346
2479
  const [busy, setBusy] = useState(false);
2347
2480
  const [problem, setProblem] = useState<string | undefined>(undefined);
2348
2481
  const read = useCallback(
@@ -2353,6 +2486,9 @@ function useMyDecisions(
2353
2486
  if (signal?.aborted === true) {
2354
2487
  return;
2355
2488
  }
2489
+ if (offset === 0) {
2490
+ shownBefore.set(remember, { items: page.items, more: page.more });
2491
+ }
2356
2492
  setItems((before) => (offset === 0 ? page.items : [...(before ?? []), ...page.items]));
2357
2493
  setMore(page.more);
2358
2494
  } catch (failure: unknown) {
@@ -2365,15 +2501,17 @@ function useMyDecisions(
2365
2501
  }
2366
2502
  }
2367
2503
  },
2368
- [myDecisions, raised, couldNotLoad],
2504
+ [myDecisions, raised, couldNotLoad, remember],
2369
2505
  );
2370
2506
  useEffect(() => {
2371
2507
  const controller = new AbortController();
2372
- setItems(undefined);
2508
+ const kept = rememberedAs<RememberedDecisions>(remember);
2509
+ setItems(kept?.items);
2510
+ setMore(kept?.more ?? false);
2373
2511
  setProblem(undefined);
2374
2512
  void read(0, controller.signal);
2375
2513
  return () => controller.abort();
2376
- }, [read]);
2514
+ }, [read, remember]);
2377
2515
  const readMore = useCallback(() => void read(items?.length ?? 0), [read, items]);
2378
2516
  const reload = useCallback(() => void read(0), [read]);
2379
2517
  return { items, more, busy, problem, readMore, reload };
@@ -2386,8 +2524,19 @@ function useMyDecisions(
2386
2524
  function MyDecisionsPage(props: { readonly data: ConsoleData }) {
2387
2525
  const words = useWords();
2388
2526
  const { myDecisions, answerReachedDecision } = props.data.actions;
2389
- const addressed = useMyDecisions(myDecisions, false, words.myDecisions.couldNotLoad);
2390
- const raised = useMyDecisions(myDecisions, true, words.myDecisions.couldNotLoad);
2527
+ const whose = props.data.me?.person?.id ?? "";
2528
+ const addressed = useMyDecisions(
2529
+ myDecisions,
2530
+ false,
2531
+ words.myDecisions.couldNotLoad,
2532
+ `decisions:${whose}:addressed`,
2533
+ );
2534
+ const raised = useMyDecisions(
2535
+ myDecisions,
2536
+ true,
2537
+ words.myDecisions.couldNotLoad,
2538
+ `decisions:${whose}:raised`,
2539
+ );
2391
2540
  const { busy, error, act } = useAction();
2392
2541
  const problem = addressed.problem ?? raised.problem ?? error;
2393
2542
  // Answered at the decision's own address (ADR-0068), so that one that reaches the person from a
@@ -2441,6 +2590,7 @@ function WorkPage(props: {
2441
2590
  <PlatePage
2442
2591
  components={props.components}
2443
2592
  load={work}
2593
+ remember={`work:${props.data.me?.person?.id ?? ""}`}
2444
2594
  title={words.work.title}
2445
2595
  week={props.week}
2446
2596
  weekStart={weekStartOf(props.data.me?.workspace)}
@@ -2469,6 +2619,7 @@ function PersonWorkPage(props: {
2469
2619
  <PlatePage
2470
2620
  components={props.components}
2471
2621
  load={load}
2622
+ remember={`work:${data.me?.person?.id ?? ""}:${id}`}
2472
2623
  title={words.people.workOf(name)}
2473
2624
  aside={<LinkButton href={PATHS.people}>{words.nav.people}</LinkButton>}
2474
2625
  week={props.week}
@@ -2530,6 +2681,9 @@ function WorkspacePage(props: {
2530
2681
  if (route.name === "person-work") {
2531
2682
  return <PersonWorkPage id={route.id} data={data} components={components} week={route.week} />;
2532
2683
  }
2684
+ if (route.name === "sessions") {
2685
+ return <SessionsPage data={data} components={components} />;
2686
+ }
2533
2687
  if (route.name === "workspace-settings") {
2534
2688
  return (
2535
2689
  <WorkspaceSettingsPage
@@ -2818,16 +2972,19 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
2818
2972
  const failure = signInFailureOf(location.search);
2819
2973
  const title = data.me?.workspace.name ?? fallbackTitle;
2820
2974
  const viaToken = holdsToken(data);
2821
- // The language: the person's own, else the browser's, else the first the console speaks.
2975
+ // The language: the person's own, else the browser's, else the workspace's (ADR-0081), else
2976
+ // the first the console speaks.
2822
2977
  const chosen = data.me?.language;
2978
+ const fallback = data.me?.workspace.language;
2823
2979
  const pack = useMemo(
2824
2980
  () =>
2825
2981
  chooseLanguage(
2826
2982
  chosen,
2827
2983
  typeof navigator === "undefined" ? [] : navigator.languages,
2828
2984
  languages,
2985
+ fallback,
2829
2986
  ),
2830
- [chosen],
2987
+ [chosen, fallback],
2831
2988
  );
2832
2989
  const words = pack.messages;
2833
2990
 
@@ -2951,6 +3108,7 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
2951
3108
  label: words.nav.settings,
2952
3109
  current:
2953
3110
  route.name === "workspace-settings" ||
3111
+ route.name === "sessions" ||
2954
3112
  route.name === "categories" ||
2955
3113
  route.name === "plugins-settings",
2956
3114
  },
@@ -3147,7 +3305,14 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
3147
3305
  ))
3148
3306
  }
3149
3307
  onNavigate={(href) => navigation.go(href)}
3150
- onSignOut={viaToken ? undefined : () => void data.actions.signOut()}
3308
+ onSignOut={
3309
+ viaToken
3310
+ ? undefined
3311
+ : () => {
3312
+ shownBefore.clear();
3313
+ void data.actions.signOut();
3314
+ }
3315
+ }
3151
3316
  >
3152
3317
  {page}
3153
3318
  </components.Shell>
package/src/data.ts CHANGED
@@ -49,6 +49,7 @@ import {
49
49
  type RestRulesInput,
50
50
  type RestRulesPlugin,
51
51
  type RestRun,
52
+ type RestSessions,
52
53
  type RestSkills,
53
54
  type RestTask,
54
55
  type RestTaskInput,
@@ -212,6 +213,12 @@ export interface ConsoleActions {
212
213
  /** Makes a token for whoever is signed in; the answer carries the secret, this once. */
213
214
  createToken(input: RestTokenInput): Promise<RestTokenCreated>;
214
215
  revokeToken(id: string): Promise<void>;
216
+ /** The browsers whoever is signed in is signed in on (board #309), the current first: read by the page that shows them. */
217
+ sessions(signal?: AbortSignal): Promise<RestSessions>;
218
+ /** Ends one of the person's other sessions. */
219
+ endSession(id: string): Promise<void>;
220
+ /** Ends every session of the person but this browser's. */
221
+ endOtherSessions(): Promise<void>;
215
222
  /** What asks to connect under a code (ADR-0011), for the person who approves it. */
216
223
  connectRequest(code: string, signal?: AbortSignal): Promise<RestConnectRequest>;
217
224
  approveConnection(code: string, input: RestTokenInput): Promise<RestConnectRequest>;
@@ -487,10 +494,27 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
487
494
  setError(undefined);
488
495
  setFailure(undefined);
489
496
  const run = async () => {
497
+ // The workspace's lists and the person's tokens are asked for along with who is signed
498
+ // in, rather than once that answer has come: a round trip fewer before a page stands.
499
+ // Where nobody is signed in they are given up unheard, and so are the tokens where an
500
+ // agent's token asks, since a token cannot list tokens: a console that holds one has none
501
+ // to show.
502
+ const asked = new AbortController();
503
+ const askedTokens = new AbortController();
504
+ const giveUp = () => {
505
+ asked.abort();
506
+ askedTokens.abort();
507
+ };
508
+ signal.addEventListener("abort", giveUp);
509
+ const lists = refreshWorkspace(asked.signal);
510
+ const tokens = client.tokens(askedTokens.signal);
511
+ lists.catch(() => undefined);
512
+ tokens.catch(() => undefined);
490
513
  let answer: RestMe;
491
514
  try {
492
515
  answer = await client.me(signal);
493
516
  } catch (failure) {
517
+ giveUp();
494
518
  if (!signal.aborted) {
495
519
  setFailure(failure);
496
520
  setError(wordsOf(failure, "The server could not be reached."));
@@ -502,15 +526,16 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
502
526
  }
503
527
  setMe(answer);
504
528
  if (answer.person === null) {
529
+ giveUp();
505
530
  setLoaded(false);
506
531
  return;
507
532
  }
533
+ if (answer.agent !== null) {
534
+ askedTokens.abort();
535
+ }
508
536
  try {
509
- const [, mine] = await Promise.all([
510
- refreshWorkspace(signal),
511
- // A token cannot list tokens: a console that holds one has none to show.
512
- answer.agent === null ? client.tokens(signal) : Promise.resolve({ items: [] }),
513
- ]);
537
+ await lists;
538
+ const mine = answer.agent === null ? await tokens : { items: [] };
514
539
  if (signal.aborted) {
515
540
  return;
516
541
  }
@@ -898,6 +923,9 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
898
923
  await client.revokeToken(id);
899
924
  setTokens((current) => current.filter((token) => token.id !== id));
900
925
  },
926
+ sessions: (signal) => client.sessions(signal),
927
+ endSession: (id) => client.endSession(id),
928
+ endOtherSessions: () => client.endOtherSessions(),
901
929
  rules: (signal) => client.rules(signal),
902
930
  writeRules: (input) => client.writeRules(input),
903
931
  archiveRules: () => client.archiveRules(),
package/src/i18n/en.ts CHANGED
@@ -266,6 +266,7 @@ export const en = {
266
266
  "task.too_many": "The project has as many tasks as it can hold.",
267
267
  "token.expiry_at_most": "A token can't last that many days here.",
268
268
  "token.not_found": "The token was not found.",
269
+ "session.not_found": "The session was not found.",
269
270
  "token.too_many": "You have as many tokens as you can hold. Remove one first.",
270
271
  "workspace.pack_connect_refused": "SkillCDN refused the connection.",
271
272
  "workspace.pack_connect_unsupported": "This console can't connect a pack.",
@@ -923,6 +924,7 @@ export const en = {
923
924
 
924
925
  settings: {
925
926
  title: "Settings",
927
+ views: { aria: "Settings", workspace: "Workspace", sessions: "Sessions" },
926
928
  categories: "Categories",
927
929
  manageCategories: "Manage the categories",
928
930
  skills: "Skills",
@@ -939,6 +941,10 @@ export const en = {
939
941
  aria: "Workspace settings",
940
942
  consoleVersion: "Console version",
941
943
  consoleTakes: (range: string) => `Takes the console command ${range}`,
944
+ language: "Default language",
945
+ languageHint:
946
+ "For whoever has not chosen a language: the pages speak it to someone whose browser asks for none the console speaks, and plugins write in it to someone who has never opened the pages, in a decision, a task or a chat. Everyone who chose a language keeps their own.",
947
+ languageNone: "Not set: English",
942
948
  peopleVisibility: "Member visibility",
943
949
  peopleVisibilityHint:
944
950
  "Whom a member sees on the People page and in the pickers: everyone of the workspace, or only the people they share a project with. An administrator always sees everyone, and a project open to the workspace has everyone in it.",
@@ -1035,6 +1041,7 @@ export const en = {
1035
1041
  peopleVisibility: "the member visibility",
1036
1042
  weekStart: "the first day of the week",
1037
1043
  timeZone: "the time zone",
1044
+ language: "the default language",
1038
1045
  packToken: "the SkillCDN token",
1039
1046
  } as Readonly<Record<string, string>>,
1040
1047
  event: {
@@ -1425,6 +1432,24 @@ export const en = {
1425
1432
  },
1426
1433
  },
1427
1434
 
1435
+ sessions: {
1436
+ title: "Sessions",
1437
+ list: "Your sessions",
1438
+ loading: "Loading the sessions",
1439
+ intro:
1440
+ "The browsers signed in to your account. Sign out of any you do not recognize or no longer use.",
1441
+ introIdle: (days: string) =>
1442
+ `The browsers signed in to your account. Sign out of any you do not recognize or no longer use. A session not used for ${days} days ends on its own.`,
1443
+ current: "Current session",
1444
+ on: (browser: string, platform: string) => `${browser} on ${platform}`,
1445
+ unknownBrowser: "Unknown browser",
1446
+ lastActive: "Last active",
1447
+ signedIn: "Signed in",
1448
+ from: (address: string) => `IP ${address}`,
1449
+ end: "Sign out",
1450
+ endOthers: "Sign out of all other sessions",
1451
+ },
1452
+
1428
1453
  connect: {
1429
1454
  title: "Connect an agent",
1430
1455
  aria: "Connect",
package/src/i18n/index.ts CHANGED
@@ -4,7 +4,8 @@ import { ko } from "./ko.js";
4
4
 
5
5
  // The languages the pages speak (ADR-0012): a pack is a tag, a label and every word the
6
6
  // default console shows; the components take their words from a context, with English where
7
- // there is none above them; the person's choice, else the browser's languages, else English.
7
+ // there is none above them; the person's choice, else the browser's languages, else the
8
+ // workspace's language (ADR-0081), else English.
8
9
 
9
10
  export type { Messages } from "./en.js";
10
11
 
@@ -68,12 +69,19 @@ export function browserPack(
68
69
 
69
70
  /**
70
71
  * The language to speak: the person's own when it names a pack, else the first of the browser's
71
- * languages that does, else the first pack.
72
+ * languages that does, else the workspace's (ADR-0081) when it names one, else the first pack.
72
73
  */
73
74
  export function chooseLanguage(
74
75
  chosen: string | null | undefined,
75
76
  browser: readonly string[],
76
77
  packs: readonly LanguagePack[] = DEFAULT_LANGUAGES,
78
+ workspace?: string | null | undefined,
77
79
  ): LanguagePack {
78
- return packFor(chosen, packs) ?? browserPack(browser, packs) ?? packs[0] ?? ENGLISH;
80
+ return (
81
+ packFor(chosen, packs) ??
82
+ browserPack(browser, packs) ??
83
+ packFor(workspace, packs) ??
84
+ packs[0] ??
85
+ ENGLISH
86
+ );
79
87
  }
package/src/i18n/ko.ts CHANGED
@@ -222,6 +222,7 @@ export const ko: Messages = {
222
222
  "task.too_many": "프로젝트에 만들 수 있는 작업 수를 다 채웠습니다.",
223
223
  "token.expiry_at_most": "이 콘솔에서는 토큰을 그렇게 오래 쓰도록 만들 수 없습니다.",
224
224
  "token.not_found": "토큰을 찾을 수 없습니다.",
225
+ "session.not_found": "세션을 찾을 수 없습니다.",
225
226
  "token.too_many": "만들 수 있는 토큰 수를 다 채웠습니다. 먼저 하나를 삭제하세요.",
226
227
  "workspace.pack_connect_refused": "SkillCDN이 연결을 거부했습니다.",
227
228
  "workspace.pack_connect_unsupported": "이 콘솔에서는 팩을 연결할 수 없습니다.",
@@ -500,7 +501,7 @@ export const ko: Messages = {
500
501
  packToken: {
501
502
  aria: "SkillCDN 토큰",
502
503
  intro:
503
- "비공개 팩은 저장소에 대한 SkillCDN 토큰으로 읽습니다. 공개 팩에는 필요 없습니다. SkillCDN에서 승인한 코드로 연결하거나, 거기서 직접 만든 토큰을 붙여 넣으세요. 콘솔은 토큰을 봉인해 보관하고 누구에게도 보여 주지 않습니다. 조직의 팩을 읽는 프로젝트는 워크스페이스 설정의 토큰을 그대로 쓸 수 있습니다.",
504
+ "비공개 팩은 저장소에 대한 SkillCDN 토큰으로 읽습니다. 공개 팩에는 필요 없습니다. SkillCDN에서 승인한 코드로 연결하거나, 거기서 직접 만든 토큰을 붙여 넣으세요. 콘솔은 토큰을 암호화해 보관하고 누구에게도 보여 주지 않습니다. 조직의 팩을 읽는 프로젝트는 워크스페이스 설정의 토큰을 그대로 쓸 수 있습니다.",
504
505
  connectTitle: "SkillCDN에서 승인한 코드로",
505
506
  pasteTitle: "직접 만든 토큰으로",
506
507
  pasteAria: "토큰 붙여넣기",
@@ -854,6 +855,7 @@ export const ko: Messages = {
854
855
 
855
856
  settings: {
856
857
  title: "설정",
858
+ views: { aria: "설정", workspace: "워크스페이스", sessions: "로그인 세션" },
857
859
  categories: "카테고리",
858
860
  manageCategories: "카테고리 관리",
859
861
  skills: "스킬",
@@ -864,12 +866,16 @@ export const ko: Messages = {
864
866
  "콘솔을 운영하는 쪽이 설정으로 정합니다. 스킬을 읽어 오는 배포와 조직의 주소.",
865
867
  skillsToken: "SkillCDN 토큰",
866
868
  skillsTokenIntro:
867
- "자기 주소도 자기 토큰도 없는 모든 프로젝트가 이 토큰으로 조직의 팩을 읽습니다. 공개 팩에는 필요 없습니다. SkillCDN에서 승인한 코드로 연결하거나, 거기서 직접 만든 토큰을 붙여 넣으세요. 콘솔은 토큰을 봉인해 보관하고 누구에게도 보여 주지 않습니다.",
869
+ "자기 주소도 자기 토큰도 없는 모든 프로젝트가 이 토큰으로 조직의 팩을 읽습니다. 공개 팩에는 필요 없습니다. SkillCDN에서 승인한 코드로 연결하거나, 거기서 직접 만든 토큰을 붙여 넣으세요. 콘솔은 토큰을 암호화해 보관하고 누구에게도 보여 주지 않습니다.",
868
870
  workspace: {
869
871
  title: "워크스페이스",
870
872
  aria: "워크스페이스 설정",
871
873
  consoleVersion: "콘솔 버전",
872
874
  consoleTakes: (range) => `받는 console 명령: ${range}`,
875
+ language: "기본 언어",
876
+ languageHint:
877
+ "언어를 정하지 않은 사람에게 쓰는 언어입니다. 브라우저가 콘솔이 쓰지 않는 언어만 요청하는 사람에게 화면이 이 언어로 나오고, 콘솔을 한 번도 열지 않은 사람에게 플러그인이 결정·태스크·채팅으로 쓰는 글도 이 언어로 씁니다. 자기 언어를 정한 사람은 그대로입니다.",
878
+ languageNone: "정하지 않음: 영어",
873
879
  peopleVisibility: "멤버 공개 범위",
874
880
  peopleVisibilityHint:
875
881
  "멤버가 사람들 페이지와 선택 목록에서 보는 범위: 워크스페이스의 모두, 또는 같은 프로젝트에 속한 사람만. 관리자는 언제나 모두를 보고, 워크스페이스에 공개된 프로젝트에는 모두가 속합니다.",
@@ -965,6 +971,7 @@ export const ko: Messages = {
965
971
  peopleVisibility: "멤버 공개 범위",
966
972
  weekStart: "주의 시작 요일",
967
973
  timeZone: "타임존",
974
+ language: "기본 언어",
968
975
  packToken: "SkillCDN 토큰",
969
976
  },
970
977
  event: {
@@ -1345,6 +1352,24 @@ export const ko: Messages = {
1345
1352
  },
1346
1353
  },
1347
1354
 
1355
+ sessions: {
1356
+ title: "로그인 세션",
1357
+ list: "내 로그인 세션",
1358
+ loading: "로그인 세션을 불러오는 중",
1359
+ intro:
1360
+ "내 계정으로 로그인한 브라우저입니다. 모르는 브라우저나 더 쓰지 않는 브라우저는 로그아웃하세요.",
1361
+ introIdle: (days) =>
1362
+ `내 계정으로 로그인한 브라우저입니다. 모르는 브라우저나 더 쓰지 않는 브라우저는 로그아웃하세요. ${days}일 동안 쓰지 않은 세션은 자동으로 로그아웃됩니다.`,
1363
+ current: "현재 세션",
1364
+ on: (browser, platform) => `${browser} · ${platform}`,
1365
+ unknownBrowser: "알 수 없는 브라우저",
1366
+ lastActive: "마지막 활동",
1367
+ signedIn: "로그인",
1368
+ from: (address) => `IP ${address}`,
1369
+ end: "로그아웃",
1370
+ endOthers: "다른 세션 모두 로그아웃",
1371
+ },
1372
+
1348
1373
  connect: {
1349
1374
  title: "에이전트 연결",
1350
1375
  aria: "연결",
package/src/index.ts CHANGED
@@ -188,6 +188,7 @@ export {
188
188
  peopleSearch,
189
189
  projectsSearch,
190
190
  } from "./components/searches.js";
191
+ export { SessionList, type SessionListProps } from "./components/sessions.js";
191
192
  export {
192
193
  type Brand,
193
194
  isPlainClick,
@@ -45,6 +45,9 @@ export interface BridgePerson {
45
45
  /** The workspace as a page lays itself out for it: what it is called, the languages it writes in, its clock and the day its week begins on. */
46
46
  export interface BridgeWorkspace {
47
47
  readonly name: string;
48
+ /** The language for whoever has none of their own (ADR-0081): the workspace's, else `en`; none from a console older than it. */
49
+ readonly language?: string;
50
+ /** The languages the console speaks, the workspace's first. */
48
51
  readonly languages: readonly string[];
49
52
  readonly timeZone: string;
50
53
  /** The workspace's setting (ADR-0035): `auto` leaves the week to the language of the pages. */
@@ -161,9 +164,10 @@ export interface BridgeDownload {
161
164
  }
162
165
 
163
166
  /**
164
- * A link a person pressed in the frame, for the console's page to open in a new tab (ADR-0067):
165
- * the frame's sandbox opens no window itself, and the page opens one only for a web or a mail
166
- * address, and only right after a person pressed.
167
+ * A link a person pressed in a frame built before 0.4.6, for the console's page to open in a new
168
+ * tab (ADR-0067): such a frame's sandbox opened no window itself. The page opens one for a web
169
+ * or a mail address alone, and only as far as it can tell of a press in that frame (ADR-0078). A
170
+ * frame since opens its links itself, and the page stops hearing this at the next line.
167
171
  */
168
172
  export interface BridgeOpen {
169
173
  readonly v: 1;
@@ -273,6 +277,7 @@ function isWorkspace(value: unknown): boolean {
273
277
  return (
274
278
  isRecord(value) &&
275
279
  typeof value.name === "string" &&
280
+ (value.language === undefined || isLine(value.language, 35)) &&
276
281
  Array.isArray(value.languages) &&
277
282
  value.languages.every((language) => typeof language === "string") &&
278
283
  isLine(value.timeZone, 100) &&