@try-works/dsh-minimal-router 0.2.6 → 0.2.8

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.
package/client/index.js CHANGED
@@ -65301,17 +65301,9 @@ var OverviewCss = [
65301
65301
  /* F-37-51: the session list reads like the recent-calls list - one row per
65302
65302
  session, the kit checkbox first, the id reduced to its tail. */
65303
65303
  ".router-sessions { display: flex; flex-direction: column; gap: 0; width: 100%; }",
65304
- ".router-sessions-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--spacing-4); padding-bottom: var(--spacing-2); }",
65305
- ".router-sessions-label { font-family: var(--font-mono); font-size: var(--text-caps); line-height: var(--leading-caps); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-meta); }",
65306
- ".router-session-hint { padding-top: var(--spacing-2); font-family: var(--font-ui); font-size: var(--text-caption); line-height: var(--leading-caption); color: var(--color-meta); text-wrap: pretty; }",
65307
- ".router-session-row { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-4); border-top: 1px solid var(--color-line-rule); padding: 10px 0; transition-property: background-color; transition-duration: 120ms; transition-timing-function: ease; }",
65308
- ".router-session-row:hover { background: var(--color-subtle); }",
65309
- ".router-session-row:focus-within { background: var(--color-subtle); }",
65310
- ".router-session-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-ui); font-size: var(--text-label); line-height: var(--leading-label); color: var(--color-ink); }",
65311
- ".router-session-state { flex-shrink: 0; width: 72px; text-align: right; font-family: var(--font-mono); font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--color-meta); }",
65312
- '.router-session-row[data-session-state="on"] .router-session-state { color: var(--color-ink); }',
65313
- ".router-session-meta { flex-shrink: 0; font-family: var(--font-mono); font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--color-meta); }",
65314
- ".router-session-empty { border-top: 1px solid var(--color-line-rule); padding: 8px 0; font-family: var(--font-ui); font-size: var(--text-meta); color: var(--color-meta); }",
65304
+ ,
65305
+ ,
65306
+ ".router-session-hint { padding: var(--spacing-3) 0 0; font-family: var(--font-ui); font-size: var(--text-caption); line-height: var(--leading-caption); color: var(--color-meta); text-wrap: pretty; }",
65315
65307
  ".router-meter-status { font-family: var(--font-mono); font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--color-meta); overflow-wrap: anywhere; }",
65316
65308
  /* The page's own error line (the one error role) and the recent-calls list:
65317
65309
  classes, not inline styles (F-34-15). The two remaining inline values are
@@ -65325,6 +65317,7 @@ var OverviewCss = [
65325
65317
  /* P8 (ui-review finding 14 + §5): 166P-0/175S-0 the id is Inter 13/18. */
65326
65318
  ".router-recent-id { flex: 1 1 auto; min-width: 0; font-size: var(--text-label); line-height: var(--leading-label); color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; }",
65327
65319
  ".router-recent-meta { font-family: var(--font-mono); color: var(--color-meta); }",
65320
+ '.router-recent-row[data-session-state="on"] .router-recent-meta { color: var(--color-ink); }',
65328
65321
  /* P8 (ui-review finding 14): 175Q-0 stacks the 390 recent row — time + id on
65329
65322
  the first line, the meta on its own full-width second line — so a request id
65330
65323
  can no longer wrap mid-token. 1756-0's meter block tightens to gap 8 / pad 20. */
@@ -65573,11 +65566,7 @@ var SaveSettings = Command_exports.make(
65573
65566
  );
65574
65567
  var OverviewSessionShortId = (id2) => id2.length <= 8 ? id2 : "\u2026" + id2.slice(-8);
65575
65568
  var OverviewSessionLabel = (row) => row.title !== null && row.title.length > 0 ? row.title : OverviewSessionShortId(row.id);
65576
- var OverviewSessionMeta = (row) => {
65577
- const at = row.updatedAt === null ? "" : row.updatedAt.slice(11, 16);
65578
- const hasTitle = row.title !== null && row.title.length > 0;
65579
- return [row.live ? "live" : null, at.length === 0 ? null : at, hasTitle ? OverviewSessionShortId(row.id) : null].filter((part) => part !== null).join(" \xB7 ");
65580
- };
65569
+ var OverviewSessionTime = (row) => row.updatedAt === null ? "" : row.updatedAt.slice(11, 16);
65581
65570
  var OverviewDef = Html_exports.component({
65582
65571
  name: "Overview",
65583
65572
  props: Schema_exports.Struct({
@@ -65727,12 +65716,12 @@ var Overview = OverviewDef.make({
65727
65716
  sessions2.length === 0 ? "none" : `${onCount} of ${sessions2.length} routing`
65728
65717
  )
65729
65718
  ),
65730
- ...sessions2.length === 0 ? [h3.div.class("router-session-empty").children("No recent sessions")] : sessions2.map(
65731
- (row) => h3.div.class("router-session-row").attr("data-session-row", row.id).attr("data-session-state", row.enabled ? "on" : "off").children(
65732
- h3.span.class("router-session-title").children(OverviewSessionLabel(row)),
65733
- h3.span.class("router-session-meta").children(OverviewSessionMeta(row)),
65734
- h3.span.class("router-session-state").children(
65735
- row.enabled ? "routing" : "not routing"
65719
+ ...sessions2.length === 0 ? [h3.div.class("router-recent-empty").children("No recent sessions")] : sessions2.map(
65720
+ (row) => h3.div.class("router-recent-row").attr("data-session-row", row.id).attr("data-session-state", row.enabled ? "on" : "off").children(
65721
+ h3.span.class("router-recent-time").children(OverviewSessionTime(row)),
65722
+ h3.span.class("router-recent-id").children(OverviewSessionLabel(row)),
65723
+ h3.span.class("router-recent-meta").children(
65724
+ (row.live ? "live \xB7 " : "") + (row.enabled ? "routing" : "not routing")
65736
65725
  )
65737
65726
  )
65738
65727
  ),
@@ -66604,7 +66593,7 @@ if (typeof document !== "undefined" && document.head !== null) {
66604
66593
  }
66605
66594
 
66606
66595
  // packages/plugin/client/build-id.ts
66607
- var clientBuildId = true ? "05bec211f5afe235f2510ce06128a98aa892db2e48f29d84d53d5093c2fc8bba" : "";
66596
+ var clientBuildId = true ? "d9258277dba958167f5f8dab2648f6008d81e0fdacbd8de7365440d84cb94fd1" : "";
66608
66597
  var compareBuildIds = (hostId, clientId) => {
66609
66598
  const host = typeof hostId === "string" && hostId.length > 0 ? hostId : null;
66610
66599
  const client = typeof clientId === "string" && clientId.length > 0 ? clientId : null;
package/lib/build-id.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // GENERATED by scripts/build-id.mjs - do not edit by hand.
2
2
  // sha256 over the canonical 19-file list (11 plugin lib + 8 domain contract
3
3
  // sources), so a domain-contract change moves the id too (DEC-30-01).
4
- export const buildId = "05bec211f5afe235f2510ce06128a98aa892db2e48f29d84d53d5093c2fc8bba"
4
+ export const buildId = "d9258277dba958167f5f8dab2648f6008d81e0fdacbd8de7365440d84cb94fd1"
package/lib/index.js CHANGED
@@ -1479,6 +1479,29 @@ export function apply(ctx, config = {}) {
1479
1479
  }
1480
1480
  void refreshRecentSessions()
1481
1481
  }
1482
+ // F-37-52 (Owner): a session row shows the session's TITLE, not its backend
1483
+ // id. DSH keeps the generated title in its session projection cache
1484
+ // (<storages>/session_projcache/sessions/<id>.json -> record.rows.title.val);
1485
+ // the session header carries no title. Read it defensively and cache by
1486
+ // mtime so the 5 s refresh does not re-parse unchanged files.
1487
+ const titleCache = new Map()
1488
+ const titleOfSession = (sessionId) => {
1489
+ if (typeof sessionId !== "string" || sessionId.length === 0) return null
1490
+ const file = path.join(path.dirname(dataDir), "session_projcache", "sessions", sessionId + ".json")
1491
+ try {
1492
+ const stat = fs.statSync(file)
1493
+ const cached = titleCache.get(sessionId)
1494
+ if (cached !== undefined && cached.mtimeMs === stat.mtimeMs) return cached.title
1495
+ const doc = JSON.parse(fs.readFileSync(file, "utf8"))
1496
+ const raw = doc?.record?.rows?.title?.val
1497
+ const full = typeof raw === "string" ? raw.trim().replace(/\s+/gu, " ") : null
1498
+ const title = full === null || full.length === 0 ? null : full.length > 72 ? full.slice(0, 72).trimEnd() + "…" : full
1499
+ titleCache.set(sessionId, { mtimeMs: stat.mtimeMs, title: title !== null && title.length > 0 ? title : null })
1500
+ return titleCache.get(sessionId).title
1501
+ } catch {
1502
+ return null
1503
+ }
1504
+ }
1482
1505
  const recentSessionRouting = async () => {
1483
1506
  const limit = 5
1484
1507
  const entries = []
@@ -1501,7 +1524,8 @@ export function apply(ctx, config = {}) {
1501
1524
  for (const record of Array.isArray(records) ? records : []) {
1502
1525
  const header = record?.header ?? {}
1503
1526
  const at = Number.isFinite(header.updatedAt) ? header.updatedAt : header.createdAt
1504
- push(header.id, header.title, at, record?.live === true)
1527
+ const headerTitle = typeof header.title === "string" && header.title.length > 0 ? header.title : null
1528
+ push(header.id, headerTitle ?? titleOfSession(header.id), at, record?.live === true)
1505
1529
  if (entries.length >= limit) break
1506
1530
  }
1507
1531
  }
@@ -1510,7 +1534,7 @@ export function apply(ctx, config = {}) {
1510
1534
  try {
1511
1535
  for (const row of ledgerRows()) {
1512
1536
  if (typeof row?.sessionId !== "string") continue
1513
- push(row.sessionId, null, Date.parse(row.at), false)
1537
+ push(row.sessionId, titleOfSession(row.sessionId), Date.parse(row.at), false)
1514
1538
  if (entries.length >= limit) break
1515
1539
  }
1516
1540
  } catch {}
@@ -1532,7 +1556,10 @@ export function apply(ctx, config = {}) {
1532
1556
  // Owner toggle any of them. The toggle is the same store the model picker
1533
1557
  // writes, so the two cannot disagree.
1534
1558
  if (typeof sessionId !== "string" || sessionId.length === 0) {
1535
- respondJson(res, 200, { sessions: await recentSessionRouting() })
1559
+ // Compute on read: the overview reads the cache, but the API is always
1560
+ // current (F-37-52 - a title must not lag a boot by one timer tick).
1561
+ recentSessionsCache = await recentSessionRouting()
1562
+ respondJson(res, 200, { sessions: recentSessionsCache })
1536
1563
  return
1537
1564
  }
1538
1565
  const entry = sessionRouting.get(sessionId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@try-works/dsh-minimal-router",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "DSH local router plugin: per-session auto-routing between a local engine and remote models, evidence pages, and a plugin-owned engine provider.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",