|
1 | 1 | /* Home = the es dashboard: attention queue + thread cards, from :7777. */ |
2 | 2 | import { createMemo, createSignal, For, onMount, Show } from "solid-js" |
3 | 3 | import { A, useNavigate } from "@solidjs/router" |
4 | | -import { ago, linkUrl, sessionHref, useDashboard } from "../state" |
| 4 | +import { ago, linkUrl, sessionHref, useDashboard, type SessionRow } from "../state" |
5 | 5 | import { ticketUrl } from "../ticket-url" |
6 | 6 | import { es as esApi } from "../api" |
7 | 7 | import { PrList } from "../components/pr" |
@@ -327,6 +327,87 @@ function AllSessions() { |
327 | 327 | ) |
328 | 328 | } |
329 | 329 |
|
| 330 | +/* All-projects landing: the board is per project, so `/` under All lists every |
| 331 | + * active root session grouped by project instead of one project's board. */ |
| 332 | +function AllProjectsLanding() { |
| 333 | + const { sessions, sessionsLoading, sessionsError, notifications, dotFor, editspaces, setEditspace, markViewed } = |
| 334 | + useDashboard() |
| 335 | + const groups = createMemo(() => { |
| 336 | + const byProject = new Map<string, SessionRow[]>() |
| 337 | + for (const s of sessions()) { |
| 338 | + const key = s.project || s.directory.split("/").filter(Boolean).at(-1) || s.directory |
| 339 | + byProject.set(key, [...(byProject.get(key) ?? []), s]) |
| 340 | + } |
| 341 | + // sessions() is activity-sorted, so each group's first row is its newest |
| 342 | + return [...byProject].sort((a, b) => b[1][0].updated - a[1][0].updated) |
| 343 | + }) |
| 344 | + // a group has a board when any of its sessions lives under a registered editspace |
| 345 | + const boardFor = (name: string, rows: SessionRow[]) => (editspaces()?.editspaces ?? []).find((item) => { |
| 346 | + const root = item.root.replace(/\/+$/, "").replace(/\/\.editspace$/, "") |
| 347 | + return item.name === name || rows.some((s) => s.directory === root || s.directory.startsWith(`${root}/`)) |
| 348 | + })?.name |
| 349 | + return ( |
| 350 | + <main class="all-landing"> |
| 351 | + <AppHeader> |
| 352 | + <h1>All projects</h1> |
| 353 | + <span class="dim"> |
| 354 | + {sessions().length} active session{sessions().length === 1 ? "" : "s"} · {groups().length} project{groups().length === 1 ? "" : "s"} |
| 355 | + </span> |
| 356 | + <span style="flex:1" /> |
| 357 | + <span class="dim">choose a project for its board</span> |
| 358 | + </AppHeader> |
| 359 | + <Show when={notifications().length}> |
| 360 | + <h2>Needs you</h2> |
| 361 | + <div class="session-list"> |
| 362 | + <For each={notifications()}> |
| 363 | + {(n) => ( |
| 364 | + <div class="pr"> |
| 365 | + <A href={sessionHref(n.session, n.directory)} onClick={() => markViewed(n.session, true)}> |
| 366 | + <span class={`dot ${dotFor({ id: n.session, updated: n.updated, pending: n.kind !== "idle" })}`} /> |
| 367 | + <SessionIcon /> |
| 368 | + {n.title} |
| 369 | + </A> |
| 370 | + <span class="dim">{n.editspace ? `${n.editspace} · ` : ""}{n.kind}</span> |
| 371 | + </div> |
| 372 | + )} |
| 373 | + </For> |
| 374 | + </div> |
| 375 | + </Show> |
| 376 | + <Show when={sessionsError()}><div class="err">{sessionsError()}</div></Show> |
| 377 | + <Show when={groups().length} fallback={<div class="dim">{sessionsLoading() ? "loading…" : "no active sessions"}</div>}> |
| 378 | + <For each={groups()}> |
| 379 | + {([project, rows]) => ( |
| 380 | + <section class="all-landing-project" aria-label={project}> |
| 381 | + <h2> |
| 382 | + {project} <span class="dim">({rows.length})</span> |
| 383 | + <Show when={boardFor(project, rows)}> |
| 384 | + {(name) => <button type="button" class="all-landing-board" title={`${name()} board`} onClick={() => setEditspace(name())}> |
| 385 | + {name() === project ? "board" : `${name()} board`} |
| 386 | + </button>} |
| 387 | + </Show> |
| 388 | + </h2> |
| 389 | + <div class="session-list"> |
| 390 | + <For each={rows}> |
| 391 | + {(s) => ( |
| 392 | + <div class="pr"> |
| 393 | + <A href={sessionHref(s.id, s.directory)} title={s.directory}> |
| 394 | + <span class={`dot ${dotFor(s)}`} /> |
| 395 | + <SessionIcon /> |
| 396 | + {s.title || s.id} |
| 397 | + </A> |
| 398 | + <span class="dim">{dotFor(s)} · {ago(s.updated)}</span> |
| 399 | + </div> |
| 400 | + )} |
| 401 | + </For> |
| 402 | + </div> |
| 403 | + </section> |
| 404 | + )} |
| 405 | + </For> |
| 406 | + </Show> |
| 407 | + </main> |
| 408 | + ) |
| 409 | +} |
| 410 | + |
330 | 411 | /* Front desk composer: one ask opens the concierge session (a normal session |
331 | 412 | * view). A busy front desk absorbs the ask — we navigate to it either way. */ |
332 | 413 | function FrontDesk() { |
@@ -410,87 +491,89 @@ export default function Home() { |
410 | 491 | } |
411 | 492 |
|
412 | 493 | return ( |
413 | | - <Show when={state()} fallback={<div class="dim">loading… (is es-dashboard running on :7777?)</div>}> |
414 | | - {(st) => ( |
415 | | - <main> |
416 | | - <AppHeader> |
417 | | - <h1>{st().editspace}</h1> |
418 | | - <span class="dim"> |
419 | | - updated {ago(st().generated_at * 1000)} · tracker {st().tracker_at ? ago(st().tracker_at * 1000) : "never"} · prs{" "} |
420 | | - {st().prs_at ? ago(st().prs_at * 1000) : "never"} |
421 | | - </span> |
422 | | - <span class="err"> |
423 | | - {[st().tracker_error && `tracker: ${st().tracker_error}`, st().prs_error && `prs: ${st().prs_error}`] |
424 | | - .filter(Boolean) |
425 | | - .join(" · ")} |
426 | | - </span> |
427 | | - <span style="flex:1" /> |
428 | | - <Show when={st().curated_at}> |
429 | | - <span class="dim">curated {ago(st().curated_at * 1000)}</span> |
430 | | - </Show> |
431 | | - <button onClick={curate} disabled={curating() || st().curating}> |
432 | | - {curating() || st().curating ? "curating…" : "curate"} |
433 | | - </button> |
434 | | - <button onClick={refresh} disabled={refreshing()}> |
435 | | - {refreshing() ? "refreshing…" : "refresh"} |
436 | | - </button> |
437 | | - </AppHeader> |
| 494 | + <Show when={!dashboard.allProjects()} fallback={<AllProjectsLanding />}> |
| 495 | + <Show when={state()} fallback={<div class="dim">loading… (is es-dashboard running on :7777?)</div>}> |
| 496 | + {(st) => ( |
| 497 | + <main> |
| 498 | + <AppHeader> |
| 499 | + <h1>{st().editspace}</h1> |
| 500 | + <span class="dim"> |
| 501 | + updated {ago(st().generated_at * 1000)} · tracker {st().tracker_at ? ago(st().tracker_at * 1000) : "never"} · prs{" "} |
| 502 | + {st().prs_at ? ago(st().prs_at * 1000) : "never"} |
| 503 | + </span> |
| 504 | + <span class="err"> |
| 505 | + {[st().tracker_error && `tracker: ${st().tracker_error}`, st().prs_error && `prs: ${st().prs_error}`] |
| 506 | + .filter(Boolean) |
| 507 | + .join(" · ")} |
| 508 | + </span> |
| 509 | + <span style="flex:1" /> |
| 510 | + <Show when={st().curated_at}> |
| 511 | + <span class="dim">curated {ago(st().curated_at * 1000)}</span> |
| 512 | + </Show> |
| 513 | + <button onClick={curate} disabled={curating() || st().curating}> |
| 514 | + {curating() || st().curating ? "curating…" : "curate"} |
| 515 | + </button> |
| 516 | + <button onClick={refresh} disabled={refreshing()}> |
| 517 | + {refreshing() ? "refreshing…" : "refresh"} |
| 518 | + </button> |
| 519 | + </AppHeader> |
438 | 520 |
|
439 | | - <FrontDesk /> |
| 521 | + <FrontDesk /> |
440 | 522 |
|
441 | | - <h2>Needs you</h2> |
442 | | - <Queue |
443 | | - attention={st().attention} |
444 | | - threads={st().threads} |
445 | | - directory={st().root} |
446 | | - briefing={st().briefing ?? []} |
447 | | - onBrief={brief} |
448 | | - /> |
| 523 | + <h2>Needs you</h2> |
| 524 | + <Queue |
| 525 | + attention={st().attention} |
| 526 | + threads={st().threads} |
| 527 | + directory={st().root} |
| 528 | + briefing={st().briefing ?? []} |
| 529 | + onBrief={brief} |
| 530 | + /> |
449 | 531 |
|
450 | | - <h2>Threads</h2> |
451 | | - <div class="grid"> |
452 | | - <For each={st().threads}> |
453 | | - {(t: any) => ( |
454 | | - <ThreadCard |
455 | | - t={t} |
456 | | - directory={st().root} |
457 | | - onDigest={digest} |
458 | | - onBrief={brief} |
459 | | - briefing={st().briefing ?? []} |
460 | | - /> |
461 | | - )} |
462 | | - </For> |
463 | | - </div> |
| 532 | + <h2>Threads</h2> |
| 533 | + <div class="grid"> |
| 534 | + <For each={st().threads}> |
| 535 | + {(t: any) => ( |
| 536 | + <ThreadCard |
| 537 | + t={t} |
| 538 | + directory={st().root} |
| 539 | + onDigest={digest} |
| 540 | + onBrief={brief} |
| 541 | + briefing={st().briefing ?? []} |
| 542 | + /> |
| 543 | + )} |
| 544 | + </For> |
| 545 | + </div> |
464 | 546 |
|
465 | | - <h2>Unattached PRs</h2> |
466 | | - <div> |
467 | | - <Show when={st().unattached_prs.length} fallback={<span class="dim">none</span>}> |
468 | | - <PrList prs={st().unattached_prs} /> |
469 | | - </Show> |
470 | | - </div> |
| 547 | + <h2>Unattached PRs</h2> |
| 548 | + <div> |
| 549 | + <Show when={st().unattached_prs.length} fallback={<span class="dim">none</span>}> |
| 550 | + <PrList prs={st().unattached_prs} /> |
| 551 | + </Show> |
| 552 | + </div> |
471 | 553 |
|
472 | | - <AllSessions /> |
| 554 | + <AllSessions /> |
473 | 555 |
|
474 | | - <h2>Frontier</h2> |
475 | | - <Show when={st().frontier.length} fallback={<span class="dim">empty</span>}> |
476 | | - <table> |
477 | | - <For each={st().frontier}> |
478 | | - {(f: any) => ( |
479 | | - <tr> |
480 | | - <td> |
481 | | - <a href={linkUrl(ticketUrl(f.key, f.url))} target="_blank"> |
482 | | - {f.key} |
483 | | - </a> |
484 | | - </td> |
485 | | - <td class="dim">{f.issue_type}</td> |
486 | | - <td>{f.summary}</td> |
487 | | - </tr> |
488 | | - )} |
489 | | - </For> |
490 | | - </table> |
491 | | - </Show> |
492 | | - </main> |
493 | | - )} |
| 556 | + <h2>Frontier</h2> |
| 557 | + <Show when={st().frontier.length} fallback={<span class="dim">empty</span>}> |
| 558 | + <table> |
| 559 | + <For each={st().frontier}> |
| 560 | + {(f: any) => ( |
| 561 | + <tr> |
| 562 | + <td> |
| 563 | + <a href={linkUrl(ticketUrl(f.key, f.url))} target="_blank"> |
| 564 | + {f.key} |
| 565 | + </a> |
| 566 | + </td> |
| 567 | + <td class="dim">{f.issue_type}</td> |
| 568 | + <td>{f.summary}</td> |
| 569 | + </tr> |
| 570 | + )} |
| 571 | + </For> |
| 572 | + </table> |
| 573 | + </Show> |
| 574 | + </main> |
| 575 | + )} |
| 576 | + </Show> |
494 | 577 | </Show> |
495 | 578 | ) |
496 | 579 | } |
0 commit comments