@leitwerk-dev/ui 0.4.0 → 0.4.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.
Files changed (39) hide show
  1. package/dist/assets/{ChronicleMarkdown-6T_LF-3B.js → ChronicleMarkdown-CDe1jngc.js} +1 -1
  2. package/dist/assets/DashboardPage-BRxe3uuy.css +1 -0
  3. package/dist/assets/DashboardPage-LiQ0_72g.js +1 -0
  4. package/dist/assets/{FutureLaunchDetailPage-D5Gc8YmZ.js → FutureLaunchDetailPage-DvyW_J5d.js} +1 -1
  5. package/dist/assets/GenericLauncher-D1qQy9hq.js +4 -0
  6. package/dist/assets/HomePage-Cnmp6osB.js +1 -0
  7. package/dist/assets/ProcessActionsMenu-DEQynjFa.js +1 -0
  8. package/dist/assets/{ProcessDetailPage-0c-fMf4Y.js → ProcessDetailPage-DvjQQTDj.js} +9 -9
  9. package/dist/assets/{ProcessesPage-CVvENTJg.js → ProcessesPage-B4BMXJT7.js} +1 -1
  10. package/dist/assets/SettingsPage-w1RHZ2l6.js +2 -0
  11. package/dist/assets/SkillsPage-Ber36rAD.js +2 -0
  12. package/dist/assets/{WatchersPage-D-uT5vWk.js → WatchersPage-Btq_SIk3.js} +1 -1
  13. package/dist/assets/{WikiPage-BNdWnJ6L.js → WikiPage-BjncVYf1.js} +1 -1
  14. package/dist/assets/http-contracts-public-BUgTIHYG.js +1 -0
  15. package/dist/assets/index-Dz0T5gKc.js +21 -0
  16. package/dist/assets/index-DzKWCM-z.css +1 -0
  17. package/dist/index.html +2 -2
  18. package/package.json +8 -8
  19. package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +8 -0
  20. package/src/components/GenericLauncher.svelte +69 -102
  21. package/src/components/ProcessActionsMenu.svelte +37 -59
  22. package/src/lib/api.ts +11 -0
  23. package/src/lib/dashboard-refresh.ts +47 -0
  24. package/src/lib/router-logic.ts +26 -5
  25. package/src/lib/router.svelte.ts +6 -2
  26. package/src/pages/DashboardPage.svelte +194 -0
  27. package/src/pages/FutureLaunchDetailPage.svelte +2 -2
  28. package/src/pages/HomePage.svelte +4 -4
  29. package/src/shell/AppShell.svelte +51 -57
  30. package/src/shell/Sidebar.svelte +134 -240
  31. package/src/test-support/wait.ts +19 -0
  32. package/dist/assets/GenericLauncher-4BQGl6fT.js +0 -4
  33. package/dist/assets/HomePage-mb9RzXht.js +0 -1
  34. package/dist/assets/ProcessActionsMenu-CEzADnZT.js +0 -1
  35. package/dist/assets/SettingsPage-CbNM5RWn.js +0 -2
  36. package/dist/assets/SkillsPage-rCSwSz89.js +0 -2
  37. package/dist/assets/http-contracts-public-BXXSFKbw.js +0 -1
  38. package/dist/assets/index-DybyOt1_.css +0 -1
  39. package/dist/assets/index-gVt2yBO1.js +0 -21
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { Actor } from "@leitwerk-dev/domain";
3
+ import type { Snippet } from "svelte";
3
4
  import { type FutureActionSummary, type FutureExecutionSummary, logout } from "../lib/api.js";
4
5
 
5
6
  import {
@@ -17,6 +18,7 @@ import {
17
18
  } from "../lib/processes.svelte";
18
19
  import type { Route } from "../lib/router.svelte";
19
20
  import {
21
+ buildCreateProcessPath,
20
22
  buildFutureLaunchPath,
21
23
  buildHomePath,
22
24
  buildProcessesPath,
@@ -45,6 +47,7 @@ let {
45
47
  }: Props = $props();
46
48
 
47
49
  const homePath = buildHomePath();
50
+ const createProcessPath = buildCreateProcessPath();
48
51
  const processesPath = buildProcessesPath();
49
52
  const watchersPath = buildWatchersPath();
50
53
  const skillsPath = buildSkillsPath();
@@ -69,9 +72,8 @@ const runningRows = $derived(
69
72
  const futureRows = $derived($futureExecutions);
70
73
  let observedReconnectCount = $state<number | null>(null);
71
74
  let sidebarCollapsed = $state(false);
72
- let currentProcessesPopoverOpen = $state(false);
73
- let futureExecutionsPopoverOpen = $state(false);
74
- let userPopoverOpen = $state(false);
75
+ type Popover = "current" | "future" | "user";
76
+ let openPopover = $state<Popover | null>(null);
75
77
  let logoutPending = $state(false);
76
78
  let logoutError = $state<string | null>(null);
77
79
  let collapseSupported = $state(
@@ -103,11 +105,11 @@ const connectionIssue = $derived.by(() => {
103
105
  const effectiveSidebarCollapsed = $derived(collapseSupported && sidebarCollapsed);
104
106
  const currentProcessesControlActive = $derived(
105
107
  effectiveSidebarCollapsed &&
106
- (currentProcessesPopoverOpen || currentRoute.page === "process-detail"),
108
+ (openPopover === "current" || currentRoute.page === "process-detail"),
107
109
  );
108
110
  const futureExecutionsControlActive = $derived(
109
111
  effectiveSidebarCollapsed &&
110
- (futureExecutionsPopoverOpen || currentRoute.page === "future-launch-detail"),
112
+ (openPopover === "future" || currentRoute.page === "future-launch-detail"),
111
113
  );
112
114
  const userName = $derived(authEnabled ? (actor.displayName ?? actor.id) : "Anonymous");
113
115
 
@@ -141,18 +143,14 @@ $effect(() => {
141
143
  return;
142
144
  }
143
145
  sidebarCollapsed = false;
144
- currentProcessesPopoverOpen = false;
145
- futureExecutionsPopoverOpen = false;
146
- userPopoverOpen = false;
146
+ openPopover = null;
147
147
  });
148
148
 
149
149
  $effect(() => {
150
150
  if (effectiveSidebarCollapsed) {
151
151
  return;
152
152
  }
153
- currentProcessesPopoverOpen = false;
154
- futureExecutionsPopoverOpen = false;
155
- userPopoverOpen = false;
153
+ openPopover = null;
156
154
  });
157
155
 
158
156
  $effect(() => {
@@ -161,22 +159,18 @@ $effect(() => {
161
159
  return;
162
160
  }
163
161
  observedRouteKey = routeKey;
164
- currentProcessesPopoverOpen = false;
165
- futureExecutionsPopoverOpen = false;
166
- userPopoverOpen = false;
162
+ openPopover = null;
167
163
  });
168
164
 
169
165
  $effect(() => {
170
- if (!currentProcessesPopoverOpen && !futureExecutionsPopoverOpen && !userPopoverOpen) {
166
+ if (!openPopover) {
171
167
  return;
172
168
  }
173
169
 
174
170
  const handleDocumentClick = (event: MouseEvent) => {
175
171
  const target = event.target as Node | null;
176
172
  if (!target) {
177
- currentProcessesPopoverOpen = false;
178
- futureExecutionsPopoverOpen = false;
179
- userPopoverOpen = false;
173
+ openPopover = null;
180
174
  return;
181
175
  }
182
176
  if (
@@ -193,23 +187,20 @@ $effect(() => {
193
187
  ) {
194
188
  return;
195
189
  }
196
- currentProcessesPopoverOpen = false;
197
- futureExecutionsPopoverOpen = false;
198
- userPopoverOpen = false;
190
+ openPopover = null;
199
191
  };
200
192
 
201
193
  const handleDocumentKeydown = (event: KeyboardEvent) => {
202
194
  if (event.key !== "Escape") {
203
195
  return;
204
196
  }
205
- const focusTarget = currentProcessesPopoverOpen
206
- ? currentProcessesTriggerRef
207
- : futureExecutionsPopoverOpen
208
- ? futureExecutionsTriggerRef
209
- : userTriggerRef;
210
- currentProcessesPopoverOpen = false;
211
- futureExecutionsPopoverOpen = false;
212
- userPopoverOpen = false;
197
+ const focusTarget =
198
+ openPopover === "current"
199
+ ? currentProcessesTriggerRef
200
+ : openPopover === "future"
201
+ ? futureExecutionsTriggerRef
202
+ : userTriggerRef;
203
+ openPopover = null;
213
204
  focusTarget?.focus();
214
205
  };
215
206
 
@@ -221,10 +212,6 @@ $effect(() => {
221
212
  };
222
213
  });
223
214
 
224
- function processPath(instanceId: string): string {
225
- return buildProcessPath(instanceId);
226
- }
227
-
228
215
  function isSelectedRow(row: ProcessRowView): boolean {
229
216
  return (
230
217
  currentRoute.page === "process-detail" && currentRoute.params.instanceId === row.instanceId
@@ -249,7 +236,7 @@ function stateKind(row: ProcessRowView): string {
249
236
 
250
237
  function futurePath(item: FutureExecutionSummary): string {
251
238
  if (item.kind === "action") {
252
- return processPath(item.instanceId);
239
+ return buildProcessPath(item.instanceId);
253
240
  }
254
241
  return buildFutureLaunchPath(item.id);
255
242
  }
@@ -307,56 +294,31 @@ function futureStateKind(item: FutureExecutionSummary): string {
307
294
 
308
295
  function openFutureItem(item: FutureExecutionSummary, event: MouseEvent) {
309
296
  event.preventDefault();
310
- futureExecutionsPopoverOpen = false;
297
+ if (openPopover === "future") openPopover = null;
311
298
  navigate(futurePath(item));
312
299
  }
313
300
 
314
- function closePopovers() {
315
- currentProcessesPopoverOpen = false;
316
- futureExecutionsPopoverOpen = false;
317
- userPopoverOpen = false;
318
- }
319
-
320
301
  function toggleSidebar() {
321
302
  if (!collapseSupported) {
322
303
  return;
323
304
  }
324
305
  sidebarCollapsed = !sidebarCollapsed;
325
- closePopovers();
306
+ openPopover = null;
326
307
  }
327
308
 
328
309
  function openSidebar() {
329
310
  sidebarCollapsed = false;
330
- closePopovers();
311
+ openPopover = null;
331
312
  }
332
313
 
333
- function toggleCurrentProcessesPopover() {
334
- if (!effectiveSidebarCollapsed) {
335
- return;
336
- }
337
- currentProcessesPopoverOpen = !currentProcessesPopoverOpen;
338
- futureExecutionsPopoverOpen = false;
339
- userPopoverOpen = false;
340
- }
341
-
342
- function toggleFutureExecutionsPopover() {
343
- if (!effectiveSidebarCollapsed) {
344
- return;
345
- }
346
- futureExecutionsPopoverOpen = !futureExecutionsPopoverOpen;
347
- currentProcessesPopoverOpen = false;
348
- userPopoverOpen = false;
349
- }
350
-
351
- function toggleUserPopover() {
352
- userPopoverOpen = !userPopoverOpen;
353
- currentProcessesPopoverOpen = false;
354
- futureExecutionsPopoverOpen = false;
355
- logoutError = null;
314
+ function togglePopover(popover: Popover) {
315
+ if (popover !== "user" && !effectiveSidebarCollapsed) return;
316
+ openPopover = openPopover === popover ? null : popover;
317
+ if (popover === "user") logoutError = null;
356
318
  }
357
319
 
358
320
  function showHelp() {
359
- userPopoverOpen = false;
321
+ openPopover = null;
360
322
  openKeyboardShortcutHelp();
361
323
  }
362
324
 
@@ -375,15 +337,78 @@ async function logOut() {
375
337
  }
376
338
 
377
339
  function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
378
- currentProcessesPopoverOpen = false;
379
- followLink(event, processPath(row.instanceId));
340
+ if (openPopover === "current") openPopover = null;
341
+ followLink(event, buildProcessPath(row.instanceId));
380
342
  }
381
343
  </script>
382
344
 
345
+ {#snippet primaryLink(page: Route["page"], href: string, label: string, action: string | null, icon: Snippet, railLabel = label, railTitle = label)}
346
+ {@const rail = effectiveSidebarCollapsed}
347
+ {@const active = currentRoute.page === page}
348
+ <a
349
+ href={href}
350
+ class={rail ? "rail-icon-control" : "sidebar-nav-link"}
351
+ data-action={action ?? undefined}
352
+ data-pressable={action ? "true" : undefined}
353
+ class:is-active={active}
354
+ aria-current={active ? "page" : undefined}
355
+ aria-label={rail ? railTitle : page === "dashboard" ? label : undefined}
356
+ title={rail ? railTitle : page === "dashboard" ? label : undefined}
357
+ onclick={(event) => followLink(event, href)}
358
+ >
359
+ <span class={rail ? "rail-control-icon" : "sidebar-nav-icon"} aria-hidden="true">{@render icon()}</span>
360
+ <span class={rail ? "rail-control-label" : "sidebar-nav-label"}>{rail ? railLabel : label}</span>
361
+ </a>
362
+ {/snippet}
363
+
364
+ {#snippet dashboardIcon()}
365
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
366
+ <rect x="3.5" y="3.5" width="6.5" height="6.5" rx="1"></rect><rect x="14" y="3.5" width="6.5" height="6.5" rx="1"></rect>
367
+ <rect x="3.5" y="14" width="6.5" height="6.5" rx="1"></rect><rect x="14" y="14" width="6.5" height="6.5" rx="1"></rect>
368
+ </svg>
369
+ {/snippet}
370
+
371
+ {#snippet createProcessIcon()}
372
+ {#if effectiveSidebarCollapsed}
373
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
374
+ <circle cx="12" cy="12" r="8"></circle>
375
+ <path d="M12 8v8"></path><path d="M8 12h8"></path>
376
+ </svg>
377
+ {:else}+{/if}
378
+ {/snippet}
379
+
380
+ {#snippet watchersIcon()}
381
+ {#if effectiveSidebarCollapsed}
382
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
383
+ <path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z"></path>
384
+ <circle cx="12" cy="12" r="2.5"></circle>
385
+ </svg>
386
+ {:else}◌{/if}
387
+ {/snippet}
388
+
389
+ {#snippet processesIcon()}
390
+ {#if effectiveSidebarCollapsed}
391
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
392
+ <path d="M5 5.5h14"></path><path d="M5 12h14"></path>
393
+ <path d="M5 18.5h9"></path><path d="M17 17l2 2 2-2"></path>
394
+ </svg>
395
+ {:else}⌘{/if}
396
+ {/snippet}
397
+
398
+ {#snippet wikiIcon()}
399
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v15M12 5C9 3 5 3 2 4v15c3-1 7-1 10 1 3-2 7-2 10-1V4c-3-1-7-1-10 1Z"></path></svg>
400
+ {/snippet}
401
+
402
+ {#snippet skillsIcon()}
403
+ <svg viewBox="0 0 20 20" fill="none">
404
+ <path d="M4 5.5h12M4 10h12M4 14.5h8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" />
405
+ </svg>
406
+ {/snippet}
407
+
383
408
  {#snippet processRowList(rows: readonly ProcessRowView[], extraListClass = "")}
384
409
  <div class="process-list {extraListClass}">
385
410
  {#each rows as row (row.instanceId)}
386
- {@const href = processPath(row.instanceId)}
411
+ {@const href = buildProcessPath(row.instanceId)}
387
412
  <a
388
413
  href={href}
389
414
  class="process-row"
@@ -458,71 +483,11 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
458
483
  <span class="rail-control-label">Open</span>
459
484
  </button>
460
485
 
461
- <a
462
- href={homePath}
463
- class="rail-icon-control"
464
- data-action="create-process"
465
- data-pressable="true"
466
- class:is-active={currentRoute.page === "home"}
467
- aria-current={currentRoute.page === "home" ? "page" : undefined}
468
- aria-label="Start process"
469
- title="Start process"
470
- onclick={(event) => followLink(event, homePath)}
471
- >
472
- <span class="rail-control-icon" aria-hidden="true">
473
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
474
- <circle cx="12" cy="12" r="8"></circle>
475
- <path d="M12 8v8"></path>
476
- <path d="M8 12h8"></path>
477
- </svg>
478
- </span>
479
- <span class="rail-control-label">New</span>
480
- </a>
481
-
482
- <a
483
- href={watchersPath}
484
- class="rail-icon-control"
485
- data-action="view-watchers"
486
- data-pressable="true"
487
- class:is-active={currentRoute.page === "watchers"}
488
- aria-current={currentRoute.page === "watchers" ? "page" : undefined}
489
- aria-label="Watchers"
490
- title="Watchers"
491
- onclick={(event) => followLink(event, watchersPath)}
492
- >
493
- <span class="rail-control-icon" aria-hidden="true">
494
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
495
- <path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6z"></path>
496
- <circle cx="12" cy="12" r="2.5"></circle>
497
- </svg>
498
- </span>
499
- <span class="rail-control-label">Watch</span>
500
- </a>
501
- <a href="/wiki" class="rail-icon-control" class:is-active={currentRoute.page === "wiki"} aria-current={currentRoute.page === "wiki" ? "page" : undefined} aria-label="Solution wikis" title="Solution wikis" onclick={(event) => followLink(event, "/wiki")}>
502
- <span class="rail-control-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v15M12 5C9 3 5 3 2 4v15c3-1 7-1 10 1 3-2 7-2 10-1V4c-3-1-7-1-10 1Z"></path></svg></span><span class="rail-control-label">Wikis</span>
503
- </a>
504
-
505
- <a
506
- href={processesPath}
507
- class="rail-icon-control"
508
- data-action="view-all-processes"
509
- data-pressable="true"
510
- class:is-active={currentRoute.page === "processes"}
511
- aria-current={currentRoute.page === "processes" ? "page" : undefined}
512
- aria-label="All processes"
513
- title="All processes"
514
- onclick={(event) => followLink(event, processesPath)}
515
- >
516
- <span class="rail-control-icon" aria-hidden="true">
517
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
518
- <path d="M5 5.5h14"></path>
519
- <path d="M5 12h14"></path>
520
- <path d="M5 18.5h9"></path>
521
- <path d="M17 17l2 2 2-2"></path>
522
- </svg>
523
- </span>
524
- <span class="rail-control-label">All</span>
525
- </a>
486
+ {@render primaryLink("dashboard", homePath, "Dashboard", "view-dashboard", dashboardIcon)}
487
+ {@render primaryLink("home", createProcessPath, "Start a process", "create-process", createProcessIcon, "New", "Start process")}
488
+ {@render primaryLink("watchers", watchersPath, "Watchers", "view-watchers", watchersIcon, "Watch")}
489
+ {@render primaryLink("wiki", "/wiki", "Solution wikis", null, wikiIcon, "Wikis")}
490
+ {@render primaryLink("processes", processesPath, "All processes", "view-all-processes", processesIcon, "All")}
526
491
 
527
492
  <div class="current-processes-anchor">
528
493
  <button
@@ -534,11 +499,11 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
534
499
  data-pressable="true"
535
500
  aria-haspopup="dialog"
536
501
  aria-controls="current-processes-popover"
537
- aria-expanded={currentProcessesPopoverOpen}
502
+ aria-expanded={openPopover === "current"}
538
503
  aria-label="Waiting and running processes"
539
504
  title={connectionIssue ? `Waiting and running processes — ${connectionIssue}` : "Waiting and running processes"}
540
505
  bind:this={currentProcessesTriggerRef}
541
- onclick={toggleCurrentProcessesPopover}
506
+ onclick={() => togglePopover("current")}
542
507
  >
543
508
  <span class="rail-control-icon" aria-hidden="true">
544
509
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
@@ -551,7 +516,7 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
551
516
  <span class="rail-control-label">Work</span>
552
517
  </button>
553
518
 
554
- {#if currentProcessesPopoverOpen}
519
+ {#if openPopover === "current"}
555
520
  <div
556
521
  id="current-processes-popover"
557
522
  class="current-processes-popover"
@@ -576,28 +541,20 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
576
541
  {:else if currentRows.length === 0}
577
542
  <div class="empty-state">No waiting or running processes. Start one above and it will appear here.</div>
578
543
  {:else}
579
- <div class="popover-section">
580
- <div class="group-header compact">
581
- <div class="group-heading">Waiting</div>
582
- <span class="group-count" aria-label={`${waitingRows.length} waiting process${waitingRows.length === 1 ? "" : "es"}`}>{waitingRows.length}</span>
583
- </div>
584
- {#if waitingRows.length === 0}
585
- <div class="empty-state">No waiting processes.</div>
586
- {:else}
587
- {@render processRowList(waitingRows, "popover-process-list")}
588
- {/if}
589
- </div>
590
- <div class="popover-section">
591
- <div class="group-header compact">
592
- <div class="group-heading">Running</div>
593
- <span class="group-count" aria-label={`${runningRows.length} running process${runningRows.length === 1 ? "" : "es"}`}>{runningRows.length}</span>
544
+ {#each [{ label: "Waiting", rows: waitingRows }, { label: "Running", rows: runningRows }] as group (group.label)}
545
+ {@const kind = group.label.toLowerCase()}
546
+ <div class="popover-section">
547
+ <div class="group-header compact">
548
+ <div class="group-heading">{group.label}</div>
549
+ <span class="group-count" aria-label={`${group.rows.length} ${kind} process${group.rows.length === 1 ? "" : "es"}`}>{group.rows.length}</span>
550
+ </div>
551
+ {#if group.rows.length === 0}
552
+ <div class="empty-state">No {kind} processes.</div>
553
+ {:else}
554
+ {@render processRowList(group.rows, "popover-process-list")}
555
+ {/if}
594
556
  </div>
595
- {#if runningRows.length === 0}
596
- <div class="empty-state">No running processes.</div>
597
- {:else}
598
- {@render processRowList(runningRows, "popover-process-list")}
599
- {/if}
600
- </div>
557
+ {/each}
601
558
  {/if}
602
559
  </div>
603
560
  </div>
@@ -613,11 +570,11 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
613
570
  data-pressable="true"
614
571
  aria-haspopup="dialog"
615
572
  aria-controls="future-executions-popover"
616
- aria-expanded={futureExecutionsPopoverOpen}
573
+ aria-expanded={openPopover === "future"}
617
574
  aria-label="Future scheduled work"
618
575
  title="Future scheduled work"
619
576
  bind:this={futureExecutionsTriggerRef}
620
- onclick={toggleFutureExecutionsPopover}
577
+ onclick={() => togglePopover("future")}
621
578
  >
622
579
  <span class="rail-control-icon" aria-hidden="true">
623
580
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
@@ -631,7 +588,7 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
631
588
  <span class="rail-control-label">Future</span>
632
589
  </button>
633
590
 
634
- {#if futureExecutionsPopoverOpen}
591
+ {#if openPopover === "future"}
635
592
  <div
636
593
  id="future-executions-popover"
637
594
  class="current-processes-popover"
@@ -686,65 +643,15 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
686
643
  </div>
687
644
 
688
645
  <nav class="sidebar-primary-nav" aria-label="Primary sidebar">
689
- <a
690
- href={homePath}
691
- class="sidebar-nav-link"
692
- data-action="create-process"
693
- data-pressable="true"
694
- class:is-active={currentRoute.page === "home"}
695
- aria-current={currentRoute.page === "home" ? "page" : undefined}
696
- onclick={(event) => followLink(event, homePath)}
697
- >
698
- <span class="sidebar-nav-icon" aria-hidden="true">+</span>
699
- <span class="sidebar-nav-label">Start a process</span>
700
- </a>
701
- <a
702
- href={processesPath}
703
- class="sidebar-nav-link"
704
- class:is-active={currentRoute.page === "processes"}
705
- data-action="view-all-processes"
706
- data-pressable="true"
707
- aria-current={currentRoute.page === "processes" ? "page" : undefined}
708
- onclick={(event) => followLink(event, processesPath)}
709
- >
710
- <span class="sidebar-nav-icon" aria-hidden="true">⌘</span>
711
- <span class="sidebar-nav-label">All processes</span>
712
- </a>
713
- <a href="/wiki" class="sidebar-nav-link" class:is-active={currentRoute.page === "wiki"} aria-current={currentRoute.page === "wiki" ? "page" : undefined} onclick={(event) => followLink(event, "/wiki")}>
714
- <span class="sidebar-nav-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v15M12 5C9 3 5 3 2 4v15c3-1 7-1 10 1 3-2 7-2 10-1V4c-3-1-7-1-10 1Z"></path></svg></span>
715
- <span class="sidebar-nav-label">Solution wikis</span>
716
- </a>
646
+ {@render primaryLink("dashboard", homePath, "Dashboard", "view-dashboard", dashboardIcon)}
647
+ {@render primaryLink("home", createProcessPath, "Start a process", "create-process", createProcessIcon)}
648
+ {@render primaryLink("processes", processesPath, "All processes", "view-all-processes", processesIcon)}
649
+ {@render primaryLink("wiki", "/wiki", "Solution wikis", null, wikiIcon)}
717
650
  <a href="/settings" class="sidebar-nav-link" data-action="view-settings" data-pressable="true" class:is-active={currentRoute.page === "settings"} aria-current={currentRoute.page === "settings" ? "page" : undefined} onclick={(event) => followLink(event, "/settings")}>
718
651
  <span class="sidebar-nav-icon" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none"><path d="M4 5h12M4 10h12M4 15h12M7 3v4M13 8v4M8 13v4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" /></svg></span><span class="sidebar-nav-label">Settings</span>
719
652
  </a>
720
- <a
721
- href={skillsPath}
722
- class="sidebar-nav-link"
723
- data-action="view-skills"
724
- data-pressable="true"
725
- class:is-active={currentRoute.page === "skills"}
726
- aria-current={currentRoute.page === "skills" ? "page" : undefined}
727
- onclick={(event) => followLink(event, skillsPath)}
728
- >
729
- <span class="sidebar-nav-icon" aria-hidden="true">
730
- <svg viewBox="0 0 20 20" fill="none">
731
- <path d="M4 5.5h12M4 10h12M4 14.5h8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" />
732
- </svg>
733
- </span>
734
- <span class="sidebar-nav-label">Skills</span>
735
- </a>
736
- <a
737
- href={watchersPath}
738
- class="sidebar-nav-link"
739
- data-action="view-watchers"
740
- data-pressable="true"
741
- class:is-active={currentRoute.page === "watchers"}
742
- aria-current={currentRoute.page === "watchers" ? "page" : undefined}
743
- onclick={(event) => followLink(event, watchersPath)}
744
- >
745
- <span class="sidebar-nav-icon" aria-hidden="true">◌</span>
746
- <span class="sidebar-nav-label">Watchers</span>
747
- </a>
653
+ {@render primaryLink("skills", skillsPath, "Skills", "view-skills", skillsIcon)}
654
+ {@render primaryLink("watchers", watchersPath, "Watchers", "view-watchers", watchersIcon)}
748
655
  </nav>
749
656
  </div>
750
657
 
@@ -797,11 +704,11 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
797
704
  data-pressable="true"
798
705
  aria-haspopup="dialog"
799
706
  aria-controls="user-menu-popover"
800
- aria-expanded={userPopoverOpen}
707
+ aria-expanded={openPopover === "user"}
801
708
  aria-label={`User menu for ${userName}`}
802
709
  title={userName}
803
710
  bind:this={userTriggerRef}
804
- onclick={toggleUserPopover}
711
+ onclick={() => togglePopover("user")}
805
712
  >
806
713
  <span class="footer-icon" aria-hidden="true">
807
714
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
@@ -812,7 +719,7 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
812
719
  {#if !effectiveSidebarCollapsed}<span class="user-name">{userName}</span>{/if}
813
720
  </button>
814
721
 
815
- {#if userPopoverOpen}
722
+ {#if openPopover === "user"}
816
723
  <div
817
724
  id="user-menu-popover"
818
725
  class="user-popover"
@@ -823,7 +730,7 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
823
730
  aria-label={`User options for ${userName}`}
824
731
  bind:this={userPopoverRef}
825
732
  >
826
- <a class="user-popover-action" href="/account/api-tokens" onclick={(event) => { userPopoverOpen = false; followLink(event, "/account/api-tokens"); }}>API tokens</a>
733
+ <a class="user-popover-action" href="/account/api-tokens" onclick={(event) => { openPopover = null; followLink(event, "/account/api-tokens"); }}>API tokens</a>
827
734
  <button type="button" class="user-popover-action" onclick={showHelp}>Show help</button>
828
735
  {#if authEnabled}
829
736
  <button
@@ -918,7 +825,11 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
918
825
 
919
826
  .rail-icon-control:hover,
920
827
  .rail-icon-control.is-active,
921
- .rail-icon-control[aria-expanded="true"] {
828
+ .rail-icon-control[aria-expanded="true"],
829
+ .sidebar-nav-link:hover,
830
+ .sidebar-nav-link.is-active,
831
+ .user-trigger:hover,
832
+ .user-trigger[aria-expanded="true"] {
922
833
  border-color: color-mix(in srgb, var(--chronicle-border) 72%, transparent 28%);
923
834
  background: color-mix(in srgb, var(--chronicle-card-surface) 78%, transparent 22%);
924
835
  color: var(--chronicle-text);
@@ -981,13 +892,6 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
981
892
  text-decoration: none;
982
893
  }
983
894
 
984
- .sidebar-nav-link:hover,
985
- .sidebar-nav-link.is-active {
986
- background: color-mix(in srgb, var(--chronicle-card-surface) 78%, transparent 22%);
987
- border-color: color-mix(in srgb, var(--chronicle-border) 72%, transparent 28%);
988
- color: var(--chronicle-text);
989
- }
990
-
991
895
  .sidebar-nav-link.is-active {
992
896
  background: color-mix(in srgb, var(--chronicle-accent) 9%, var(--chronicle-card-surface) 91%);
993
897
  border-color: color-mix(in srgb, var(--chronicle-accent) 25%, var(--chronicle-border) 75%);
@@ -1134,13 +1038,6 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
1134
1038
  cursor: pointer;
1135
1039
  }
1136
1040
 
1137
- .user-trigger:hover,
1138
- .user-trigger[aria-expanded="true"] {
1139
- border-color: color-mix(in srgb, var(--chronicle-border) 72%, transparent 28%);
1140
- background: color-mix(in srgb, var(--chronicle-card-surface) 78%, transparent 22%);
1141
- color: var(--chronicle-text);
1142
- }
1143
-
1144
1041
  .user-trigger.is-collapsed {
1145
1042
  display: grid;
1146
1043
  grid-template-columns: 1fr;
@@ -1410,10 +1307,7 @@ function openCurrentProcessRow(row: ProcessRowView, event: MouseEvent) {
1410
1307
  }
1411
1308
 
1412
1309
  .empty-state {
1413
- font-size: 0.875rem;
1414
- line-height: 1.55;
1415
1310
  color: var(--chronicle-text-muted);
1416
- padding: 2px 0;
1417
1311
  }
1418
1312
 
1419
1313
  .connection-overlay {
@@ -0,0 +1,19 @@
1
+ import { vi } from "vitest";
2
+
3
+ /** Drain pending microtasks and yield once to the UI. @internal */
4
+ export async function flushUi() {
5
+ await new Promise((resolve) => setTimeout(resolve, 0));
6
+ }
7
+
8
+ /** @internal */
9
+ export function waitForSelector(target: HTMLElement, selector: string, timeoutMs = 250) {
10
+ return vi.waitFor(
11
+ () => {
12
+ const element = target.querySelector(selector);
13
+ if (!(element instanceof HTMLElement))
14
+ throw new Error(`Timed out waiting for selector: ${selector}`);
15
+ return element;
16
+ },
17
+ { timeout: timeoutMs, interval: 1 },
18
+ );
19
+ }