@d86e/hive-panel 1.0.12 → 1.0.14

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/public/panel.js CHANGED
@@ -10,6 +10,8 @@ const MAX_EVENTS = 80;
10
10
  const DEFAULT_SNAPSHOT_URL = "/api/snapshot";
11
11
  const DEFAULT_ACTIONS_URL = "/api/actions";
12
12
  const DEFAULT_SUPERVISOR_URL = "/api/hive-runner";
13
+ const DEFAULT_TASKS_URL = "/api/tasks";
14
+ const DEFAULT_TASK_URL = "/api/tasks/{id}";
13
15
  const QUEEN_DISMISS_KEY = "hive.queenNoticeDismissed";
14
16
  const DEFAULT_INTERVAL_MS = 3000;
15
17
 
@@ -1476,58 +1478,7 @@ const PANEL_STYLES = `.hive { position: relative; }
1476
1478
  overflow: auto;
1477
1479
  }
1478
1480
 
1479
- .hive-card-run {
1480
- border: 1px solid var(--hive-line);
1481
- border-radius: var(--hive-radius-md);
1482
- background: var(--hive-surface);
1483
- overflow: hidden;
1484
- }
1485
-
1486
- .hive-card-run-title {
1487
- padding: 8px 10px;
1488
- color: var(--hive-fg-soft);
1489
- font-size: 12px;
1490
- font-weight: 650;
1491
- letter-spacing: 0.08em;
1492
- line-height: 1.5;
1493
- text-transform: uppercase;
1494
- }
1495
-
1496
- .hive-card-run-meta {
1497
- padding: 0 10px 8px;
1498
- overflow-wrap: anywhere;
1499
- color: var(--hive-fg-soft);
1500
- font-family: var(--hive-mono);
1501
- font-size: 12px;
1502
- line-height: 1.5;
1503
- }
1504
-
1505
- .hive-card-run-empty {
1506
- margin: 0 10px 10px;
1507
- }
1508
-
1509
- .hive-card-run-output {
1510
- max-height: 360px;
1511
- max-height: 20lh; /* longer output scrolls inside the pre */
1512
- margin: 0;
1513
- padding: 10px;
1514
- overflow: auto;
1515
- border-top: 1px solid var(--hive-line);
1516
- background: var(--hive-surface);
1517
- font-family: var(--hive-mono);
1518
- font-size: 12px;
1519
- line-height: 1.5;
1520
- white-space: pre-wrap;
1521
- overflow-wrap: anywhere;
1522
- }
1523
1481
 
1524
- .hive-card-run-foot {
1525
- display: flex;
1526
- justify-content: flex-end;
1527
- gap: 8px;
1528
- padding: 8px 10px;
1529
- border-top: 1px solid var(--hive-line);
1530
- }
1531
1482
 
1532
1483
  .hive-card-actions {
1533
1484
  justify-content: flex-end;
@@ -1983,7 +1934,7 @@ dialog.hive-dialog {
1983
1934
  dialog.hive-dialog .hive-dialog-head,
1984
1935
  dialog.hive-dialog .hive-dialog-foot { flex: 0 0 auto; }
1985
1936
  dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
1986
- .hive-card-run-output { max-height: 20lh; overflow: auto; }
1937
+ .hive-card-run-output { overflow: visible; overflow-wrap: anywhere; word-break: break-word; }
1987
1938
  .hive-card-actions { flex-wrap: wrap; justify-content: flex-end; }
1988
1939
  /* Virtual lanes: fixed 26px cards, 2px gaps, 28px stride. */
1989
1940
  .hive-lane-cards {
@@ -2047,7 +1998,7 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2047
1998
  .hive-markdown .hive-md-list { margin: 0 0 8px; padding-left: 20px; }
2048
1999
  .hive-markdown .hive-md-list li { margin: 2px 0; }
2049
2000
  .hive-markdown .hive-md-code-inline { padding: 1px 4px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; }
2050
- .hive-markdown .hive-md-code-block { max-width: 100%; margin: 8px 0; padding: 10px; overflow-x: auto; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; line-height: 1.55; white-space: pre; scrollbar-color: var(--hive-line) transparent; scrollbar-width: thin; }
2001
+ .hive-markdown .hive-md-code-block { max-width: 100%; margin: 8px 0; padding: 10px; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 11px; line-height: 1.55; white-space: pre; scrollbar-color: var(--hive-line) transparent; scrollbar-width: thin; }
2051
2002
  .hive-markdown .hive-md-code-block code { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; white-space: pre; }
2052
2003
  .hive-markdown .hive-md-quote { margin: 8px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--hive-line); color: var(--hive-fg-soft); }
2053
2004
  .hive-markdown .hive-md-link { color: var(--hive-accent); text-decoration: underline; text-underline-offset: 2px; }
@@ -2099,6 +2050,76 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
2099
2050
  .hive-section-content { padding: 10px; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); }
2100
2051
  .hive-section-content > :first-child { margin-top: 0; }
2101
2052
  .hive-section-content > :last-child { margin-bottom: 0; }
2053
+ /* Shared-experience block in the task dialog. */
2054
+ .hive-exp-count { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.6; }
2055
+ .hive-exp-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; min-width: 0; }
2056
+ .hive-exp-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; font-size: 11px; line-height: 1.5; }
2057
+ .hive-exp-scope { max-width: 100%; padding: 1px 5px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg); font-family: var(--hive-mono); font-size: 10.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
2058
+ .hive-exp-text { color: var(--hive-fg-soft); overflow-wrap: anywhere; }
2059
+ .hive-exp-more { align-self: flex-start; padding: 2px 6px; font-size: 10.5px; }
2060
+ /* The run section uses the same outer structure as every other section; the
2061
+ content surface comes from .hive-section-content, so the legacy run box is
2062
+ intentionally transparent. */
2063
+ .hive-card-run { display: block; margin: 0 0 12px; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
2064
+ .hive-section-meta { margin: 0 0 6px; padding: 0; overflow-wrap: anywhere; color: var(--hive-fg-soft); font-family: var(--hive-mono); font-size: 11px; line-height: 1.5; }
2065
+ .hive-card-run-empty { margin: 0; }
2066
+ .hive-card-run-output { margin: 0; padding: 0; overflow: visible; border: 0; background: transparent; font-family: var(--hive-mono); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }
2067
+ .hive-card-run-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0; border: 0; }
2068
+ .hive-run-files { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 8px; min-width: 0; }
2069
+ .hive-run-field-label { flex: 0 0 auto; color: var(--hive-fg-faint); font-size: 11px; font-weight: 600; line-height: 1.5; }
2070
+ .hive-run-failure { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hive-line-2); }
2071
+ .hive-run-failure-text { margin-top: 2px; color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
2072
+ /* The panel fills the host; each lane owns its height and scrollbar. */
2073
+ .hive-viewport { height: 100%; min-height: 0; overflow: hidden; }
2074
+ .hive { height: 100%; min-height: 0; overflow: hidden; }
2075
+ .hive-main { min-height: 0; }
2076
+ .hive-board { flex: 1 1 auto; min-height: 0; }
2077
+ .hive-stage { flex: 1 1 auto; min-height: 0; }
2078
+ .hive-lanes { flex: 1 1 auto; align-items: stretch; min-height: 0; }
2079
+ .hive-lane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
2080
+ .hive-lane-head { flex: 0 0 auto; }
2081
+ .hive-lane-cards { flex: 1 1 auto; min-height: 0; max-height: none; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
2082
+ .hive-skeleton { flex: 1 1 auto; min-height: 0; }
2083
+ @media (max-width: 920px) {
2084
+ .hive-viewport { height: auto; min-height: 100dvh; overflow: auto; }
2085
+ .hive { height: auto; min-height: 100dvh; overflow: visible; }
2086
+ .hive-main { display: flex; flex-direction: column; min-height: 0; }
2087
+ .hive-board { flex: 0 0 auto; min-height: 600px; }
2088
+ .hive-stage { min-height: 560px; }
2089
+ .hive-lanes { flex-direction: column; min-height: 0; overflow-x: visible; overflow-y: visible; }
2090
+ .hive-lane { flex: 0 0 520px; width: 100%; min-height: 520px; }
2091
+ .hive-lane-cards { min-height: 480px; max-height: none; }
2092
+ .hive-skeleton { grid-template-columns: 1fr; min-height: 0; }
2093
+ }
2094
+ /* Task search and per-lane pagination controls. */
2095
+ .hive-search { flex: 0 0 auto; padding: 8px 10px 0; }
2096
+ .hive-search-input { box-sizing: border-box; width: 100%; padding: 5px 8px; border: 1px solid var(--hive-line); border-radius: var(--hive-radius-sm); background: var(--hive-bg-layer-1); color: var(--hive-fg); font: inherit; font-size: 12px; }
2097
+ .hive-search-input:focus { outline: 1px solid var(--hive-selected); outline-offset: 0; }
2098
+ .hive-search-results { margin-top: 6px; padding: 6px; border: 1px solid var(--hive-line-2); border-radius: var(--hive-radius-md); background: var(--hive-bg-layer-1); }
2099
+ .hive-search-results.is-hidden { display: none; }
2100
+ .hive-search-summary, .hive-search-empty { color: var(--hive-fg-faint); font-size: 11px; line-height: 1.5; }
2101
+ .hive-search-result { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; border: 0; background: transparent; color: var(--hive-fg); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
2102
+ .hive-search-result:hover { background: var(--hive-hover); }
2103
+ .hive-search-status { flex: 0 0 auto; font-size: 10px; }
2104
+ .hive-search-status.is-done { color: var(--hive-ok); }
2105
+ .hive-search-status.is-failed { color: var(--hive-danger); }
2106
+ .hive-search-status.is-claimed { color: var(--hive-accent); }
2107
+ .hive-search-status.is-pending { color: var(--hive-fg-faint); }
2108
+ .hive-search-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2109
+ .hive-search-id { flex: 0 0 auto; color: var(--hive-fg-faint); font-family: var(--hive-mono); font-size: 10.5px; }
2110
+ .hive-lane-paging { flex: 0 0 auto; padding: 0 7px 7px; }
2111
+ .hive-lane-more { width: 100%; padding: 3px 6px; font-size: 11px; }
2112
+ .hive-lane-page-error { margin-top: 4px; color: var(--hive-danger); font-size: 10.5px; line-height: 1.4; overflow-wrap: anywhere; }
2113
+ .hive-lane-page-error.is-hidden, .hive-lane-more.is-hidden { display: none; }
2114
+ .hive-lane-loading { padding: 6px 8px; color: var(--hive-fg-faint); font-size: 11px; line-height: 1.5; text-align: center; }
2115
+ .hive-lane-loading.is-hidden { display: none; }
2116
+ .hive-lane-head-actions { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
2117
+ .hive-lane-more-top, .hive-lane-latest { padding: 1px 5px; font-size: 10px; font-weight: 600; letter-spacing: 0; line-height: 1.4; text-transform: none; }
2118
+ .hive-lane-more-top.is-hidden, .hive-lane-latest.is-hidden { display: none; }
2119
+ .hive-lane-recycle { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; padding: 4px 7px; border-bottom: 1px solid var(--hive-line-2); background: var(--hive-bg-layer-2); color: var(--hive-fg-soft); font-size: 10px; line-height: 1.4; }
2120
+ .hive-lane-recycle.is-hidden { display: none; }
2121
+ .hive-lane-recycle-text { min-width: 0; overflow-wrap: anywhere; }
2122
+ .hive-lane-recycle-reload { flex: 0 0 auto; padding: 1px 5px; font-size: 10px; }
2102
2123
  `;
2103
2124
 
2104
2125
  const LANE_LABEL_KEYS = Object.freeze({
@@ -2130,6 +2151,18 @@ export const messages = Object.freeze({
2130
2151
  "pane.board": "Task board",
2131
2152
  "pane.events": "events",
2132
2153
  "board.filtersAria": "Filter by state",
2154
+ "board.loadMore": "Load more",
2155
+ "board.latest": "Back to latest",
2156
+ "board.recycled": "Recycled {count} older tasks",
2157
+ "board.reloadLatest": "Reload latest",
2158
+ "board.latestAria": "Scroll back to the newest tasks",
2159
+ "board.loading": "Loading…",
2160
+ "board.loadFailed": "Could not load more",
2161
+ "board.retry": "Retry",
2162
+ "board.searchPlaceholder": "Search task id or title",
2163
+ "board.searchAria": "Search tasks by id or title",
2164
+ "board.searchEmpty": "No matching tasks",
2165
+ "board.searchResults": "{count} matching tasks",
2133
2166
  "board.all": "all",
2134
2167
  "board.showAll": "Show all tasks",
2135
2168
  "board.filterChip": "Show {lane} tasks ({count})",
@@ -2192,9 +2225,28 @@ export const messages = Object.freeze({
2192
2225
  "drawer.removeClaimed": "A claimed task must be released or reopened before it can be deleted.",
2193
2226
  "drawer.rawJson": "raw json",
2194
2227
  "drawer.lastRun": "Last run",
2228
+ "drawer.runningTitle": "Running",
2229
+ "drawer.resultTitle": "Execution result",
2230
+ "drawer.claimedWaiting": "Claimed; waiting for the first heartbeat",
2231
+ "drawer.agent": "Agent {agent}",
2232
+ "drawer.startedAt": "Started {time}",
2233
+ "drawer.elapsed": "Elapsed {duration}",
2234
+ "drawer.lastHeartbeat": "Last heartbeat {time}",
2235
+ "drawer.status": "Status {status}",
2236
+ "drawer.duration": "Duration {duration}",
2237
+ "drawer.commit": "Commit {commit}",
2238
+ "drawer.files": "Files",
2239
+ "drawer.failureReason": "Failure reason",
2240
+ "drawer.outputTail": "Output tail",
2195
2241
  "drawer.noOutput": "(no output)",
2196
2242
  "drawer.scopeTitle": "Work scope",
2197
- "drawer.dependenciesTitle": "Dependencies",
2243
+ "drawer.dependenciesTitle": "Dependency relationships",
2244
+ "drawer.dependenciesHint": "What this task depends on, and what depends on it.",
2245
+ "drawer.experienceTitle": "Experience",
2246
+ "drawer.experienceHint": "Shared experience this task read and wrote.",
2247
+ "drawer.experienceRead": "Read {count}",
2248
+ "drawer.experienceWritten": "Wrote {count}",
2249
+ "drawer.experienceMore": "+{count} more",
2198
2250
  "drawer.dependsOn": "Depends on",
2199
2251
  "drawer.requiredBy": "Required by",
2200
2252
  "drawer.scopeHint": "Directories/files this task changes.",
@@ -2408,6 +2460,18 @@ export const messages = Object.freeze({
2408
2460
  "pane.board": "任务看板",
2409
2461
  "pane.events": "事件",
2410
2462
  "board.filtersAria": "按状态筛选",
2463
+ "board.loadMore": "加载更多",
2464
+ "board.latest": "回到最新",
2465
+ "board.recycled": "已回收更早的 {count} 条",
2466
+ "board.reloadLatest": "重新加载",
2467
+ "board.latestAria": "滚动回最新任务",
2468
+ "board.loading": "加载中…",
2469
+ "board.loadFailed": "加载失败",
2470
+ "board.retry": "重试",
2471
+ "board.searchPlaceholder": "搜索任务 ID 或标题",
2472
+ "board.searchAria": "按 ID 或标题搜索任务",
2473
+ "board.searchEmpty": "没有匹配任务",
2474
+ "board.searchResults": "{count} 个匹配任务",
2411
2475
  "board.all": "全部",
2412
2476
  "board.showAll": "显示全部任务",
2413
2477
  "board.filterChip": "只看{lane}任务({count})",
@@ -2470,9 +2534,28 @@ export const messages = Object.freeze({
2470
2534
  "drawer.removeClaimed": "已认领的任务必须先释放或重开才能删除。",
2471
2535
  "drawer.rawJson": "原始 JSON",
2472
2536
  "drawer.lastRun": "最近一次执行",
2537
+ "drawer.runningTitle": "正在执行",
2538
+ "drawer.resultTitle": "执行结果",
2539
+ "drawer.claimedWaiting": "已认领,等待首次心跳",
2540
+ "drawer.agent": "智能体 {agent}",
2541
+ "drawer.startedAt": "开始 {time}",
2542
+ "drawer.elapsed": "已运行 {duration}",
2543
+ "drawer.lastHeartbeat": "最后心跳 {time}",
2544
+ "drawer.status": "状态 {status}",
2545
+ "drawer.duration": "耗时 {duration}",
2546
+ "drawer.commit": "提交 {commit}",
2547
+ "drawer.files": "涉及文件",
2548
+ "drawer.failureReason": "失败原因",
2549
+ "drawer.outputTail": "输出尾部",
2473
2550
  "drawer.noOutput": "(无输出)",
2474
2551
  "drawer.scopeTitle": "工作范围",
2475
- "drawer.dependenciesTitle": "依赖",
2552
+ "drawer.dependenciesTitle": "依赖关系",
2553
+ "drawer.dependenciesHint": "这个任务依赖谁、谁依赖它",
2554
+ "drawer.experienceTitle": "经验",
2555
+ "drawer.experienceHint": "这个任务读取与写入的共享经验",
2556
+ "drawer.experienceRead": "读取 {count} 条",
2557
+ "drawer.experienceWritten": "写入 {count} 条",
2558
+ "drawer.experienceMore": "+{count} 条",
2476
2559
  "drawer.dependsOn": "依赖",
2477
2560
  "drawer.requiredBy": "被依赖",
2478
2561
  "drawer.scopeHint": "这个任务改动的目录/文件",
@@ -2766,6 +2849,8 @@ function normalizeLastRun(value) {
2766
2849
  endedAt: asString(value.endedAt),
2767
2850
  status,
2768
2851
  commit: asString(value.commit),
2852
+ lastHeartbeat: asString(value.lastHeartbeat || value.heartbeat || value.lastOutputAt || value.updatedAt),
2853
+ reason: asString(value.reason || value.failureReason || value.error),
2769
2854
  exitCode: typeof value.exitCode === "number" && Number.isFinite(value.exitCode) ? value.exitCode : null,
2770
2855
  // Hive-runner records the worker activation's Session id; a host that can
2771
2856
  // navigate can open that conversation, an older record simply has none.
@@ -2778,6 +2863,71 @@ function normalizeLastRun(value) {
2778
2863
  };
2779
2864
  }
2780
2865
 
2866
+ function normalizeExperienceItem(value) {
2867
+ if (typeof value === "string") {
2868
+ const scope = value.trim();
2869
+ return scope ? { scope, text: "" } : null;
2870
+ }
2871
+ if (!isRecord(value)) return null;
2872
+ const scope = asString(value.scope || value.path || value.key || value.file);
2873
+ const text = asString(value.text || value.summary || value.lesson || value.title);
2874
+ if (!scope && !text) return null;
2875
+ return { scope, text };
2876
+ }
2877
+
2878
+ function normalizeExperienceSide(value, fallbackCount, fallbackItems) {
2879
+ let count = asCount(fallbackCount, 0);
2880
+ let items = Array.isArray(fallbackItems) ? fallbackItems : [];
2881
+ if (typeof value === "number" && Number.isFinite(value)) count = value;
2882
+ else if (Array.isArray(value)) {
2883
+ items = value;
2884
+ count = value.length;
2885
+ } else if (isRecord(value)) {
2886
+ count = asCount(value.count, count);
2887
+ const rawItems = value.items || value.list || value.lessons || value.entries;
2888
+ if (Array.isArray(rawItems)) items = rawItems;
2889
+ }
2890
+ const normalized = items
2891
+ .map(normalizeExperienceItem)
2892
+ .filter(Boolean);
2893
+ if (count === 0 && normalized.length > 0) count = normalized.length;
2894
+ return { count, items: normalized };
2895
+ }
2896
+
2897
+ function normalizeExperience(task) {
2898
+ const source = isRecord(task && task.experience) ? task.experience : {};
2899
+ const lessons = isRecord(task && task.lessons) ? task.lessons : {};
2900
+ const runLessons =
2901
+ isRecord(task) && isRecord(task.lastRun) && isRecord(task.lastRun.lessons)
2902
+ ? task.lastRun.lessons
2903
+ : {};
2904
+ const readSource = source.read !== undefined ? source.read : lessons.read !== undefined ? lessons.read : undefined;
2905
+ const writeSource =
2906
+ source.written !== undefined
2907
+ ? source.written
2908
+ : source.write !== undefined
2909
+ ? source.write
2910
+ : lessons.written !== undefined
2911
+ ? lessons.written
2912
+ : lessons.write !== undefined
2913
+ ? lessons.write
2914
+ : undefined;
2915
+ const read = normalizeExperienceSide(
2916
+ readSource,
2917
+ asCount(source.readCount, asCount(lessons.readCount, asCount(lessons.count, asCount(runLessons.count, 0)))),
2918
+ Array.isArray(lessons.items) ? lessons.items : [],
2919
+ );
2920
+ const written = normalizeExperienceSide(
2921
+ writeSource,
2922
+ asCount(
2923
+ source.writtenCount,
2924
+ asCount(source.writeCount, asCount(lessons.writtenCount, asCount(lessons.writeCount, 0))),
2925
+ ),
2926
+ Array.isArray(lessons.writtenItems) ? lessons.writtenItems : [],
2927
+ );
2928
+ return { read, written };
2929
+ }
2930
+
2781
2931
  function normalizeCard(task) {
2782
2932
  return {
2783
2933
  id: asString(task.id),
@@ -2791,6 +2941,7 @@ function normalizeCard(task) {
2791
2941
  stateChangedAt: asString(task.stateChangedAt),
2792
2942
  createdAt: asString(task.createdAt),
2793
2943
  updatedAt: asString(task.updatedAt),
2944
+ experience: normalizeExperience(task),
2794
2945
  lastRun: normalizeLastRun(task.lastRun),
2795
2946
  };
2796
2947
  }
@@ -3003,6 +3154,21 @@ export function renderModel(snapshot) {
3003
3154
  error: rawRoles ? asString(rawRoles.error) || null : null,
3004
3155
  };
3005
3156
 
3157
+ const rawLanePages = isRecord(source.lanePages) ? source.lanePages : null;
3158
+ const lanePages = {};
3159
+ for (const state of LANE_ORDER) {
3160
+ const rows = lanes[state];
3161
+ const raw = rawLanePages && isRecord(rawLanePages[state]) ? rawLanePages[state] : null;
3162
+ const total = raw ? asCount(raw.total, rows.length) : rows.length;
3163
+ const cursor = raw ? asCount(raw.cursor, rows.length) : rows.length;
3164
+ lanePages[state] = {
3165
+ loaded: rows.length,
3166
+ total,
3167
+ cursor,
3168
+ hasMore: raw ? raw.hasMore === true || rows.length < total : false,
3169
+ };
3170
+ }
3171
+
3006
3172
  return {
3007
3173
  at: asString(source.at),
3008
3174
  repo: asString(source.repo),
@@ -3013,6 +3179,7 @@ export function renderModel(snapshot) {
3013
3179
  writable,
3014
3180
  lanes,
3015
3181
  laneOrder: [...LANE_ORDER],
3182
+ lanePages,
3016
3183
  taskList: tasks.map(normalizeCard),
3017
3184
  stats: normalizeStats(source.stats, tasks),
3018
3185
  agents: normalizeAgents(source.board),
@@ -3707,6 +3874,8 @@ export function mount(root, options = {}) {
3707
3874
  const snapshotUrl = asString(opts.snapshotUrl) || DEFAULT_SNAPSHOT_URL;
3708
3875
  const supervisorUrl = asString(opts.supervisorUrl) || DEFAULT_SUPERVISOR_URL;
3709
3876
  const actionsUrl = (asString(opts.actionsUrl) || DEFAULT_ACTIONS_URL).replace(/\/+$/, "");
3877
+ const tasksUrl = asString(opts.tasksUrl) || DEFAULT_TASKS_URL;
3878
+ const taskUrl = asString(opts.taskUrl) || DEFAULT_TASK_URL;
3710
3879
 
3711
3880
  const requestedInterval = Number(opts.intervalMs);
3712
3881
  const intervalMs =
@@ -3998,6 +4167,22 @@ export function mount(root, options = {}) {
3998
4167
  const stage = element(doc, "div", "hive-stage");
3999
4168
  const stageChips = element(doc, "div", "hive-stage-chips");
4000
4169
  setAttr(stageChips, "aria-label", translate("board.filtersAria"));
4170
+ const searchBox = element(doc, "div", "hive-search");
4171
+ const searchInput = element(doc, "input", "hive-search-input");
4172
+ setAttr(searchInput, "type", "search");
4173
+ setAttr(searchInput, "placeholder", translate("board.searchPlaceholder"));
4174
+ setAttr(searchInput, "aria-label", translate("board.searchAria"));
4175
+ const searchResults = element(doc, "div", "hive-search-results is-hidden");
4176
+ searchBox.appendChild(searchInput);
4177
+ searchBox.appendChild(searchResults);
4178
+ stage.appendChild(searchBox);
4179
+ searchInput.addEventListener("input", () => {
4180
+ void runSearch(searchInput.value);
4181
+ });
4182
+ searchInput.addEventListener("keydown", (event) => {
4183
+ if (event && event.key === "Enter") void runSearch(searchInput.value);
4184
+ });
4185
+
4001
4186
  const lanesNode = element(doc, "div", "hive-lanes");
4002
4187
  const filterEmpty = element(doc, "div", "hive-filter-empty", "");
4003
4188
  stage.appendChild(stageChips);
@@ -5793,11 +5978,13 @@ function renderMarkdownInto(doc, host, source) {
5793
5978
  return { section, content, title, head };
5794
5979
  }
5795
5980
 
5796
- function buildRunSection(run, actionHost) {
5981
+ function buildRunSection(card, lane, actionHost) {
5982
+ if (lane === "pending") return null;
5983
+ const claimed = lane === "claimed";
5984
+ const run = card.lastRun;
5797
5985
  const part = createSection({
5798
- title: translate("drawer.lastRun"),
5986
+ title: claimed ? translate("drawer.runningTitle") : translate("drawer.resultTitle"),
5799
5987
  className: "hive-card-run",
5800
- titleClass: "hive-card-run-title",
5801
5988
  });
5802
5989
  const section = part.section;
5803
5990
  const content = part.content;
@@ -5806,82 +5993,130 @@ function renderMarkdownInto(doc, host, source) {
5806
5993
  else if (actionHost && typeof actionHost.appendChild === "function") actionHost.appendChild(node);
5807
5994
  else section.appendChild(node);
5808
5995
  };
5996
+
5809
5997
  if (!run) {
5810
- content.appendChild(element(doc, "div", "hive-note hive-card-run-empty", translate("drawer.noRuns")));
5811
- return section;
5812
- }
5813
- const started = formatRunStamp(run.startedAt);
5814
- const ended = formatRunStamp(run.endedAt);
5815
- const metaParts = [run.status, run.agent];
5816
- if (started || ended) metaParts.push(started + (ended ? " → " + ended : ""));
5817
- if (run.commit) metaParts.push(shortCommit(run.commit));
5818
- const metaPartsText = metaParts.filter(Boolean).join(" · ");
5819
- const meta = element(doc, "div", "hive-card-run-meta", metaPartsText);
5820
- setAttr(meta, "title", metaPartsText);
5821
- content.appendChild(meta);
5822
- // Consensus announcements: the other agents that announced the same paths. Invalid
5823
- // entries are dropped by normalizeLastRun, duplicates collapse to one name,
5824
- // and no overlapping writer means no row at all.
5825
- const writers = [];
5826
- for (const overlap of run.overlaps) {
5827
- const agent = asString(overlap.agent);
5828
- if (agent !== "" && !writers.includes(agent)) writers.push(agent);
5829
- }
5830
- if (writers.length > 0) {
5831
- const overlapsLabel = translate("drawer.runOverlaps");
5832
- // The zh dictionary copy uses the full-width colon elsewhere in the panel.
5833
- const separator = /[\u4e00-\u9fff]/.test(overlapsLabel) ? ":" : ": ";
5834
5998
  content.appendChild(
5835
- element(doc, "div", "hive-card-run-meta", overlapsLabel + separator + writers.join(", ")),
5999
+ element(
6000
+ doc,
6001
+ "div",
6002
+ "hive-note hive-card-run-empty",
6003
+ claimed ? translate("drawer.claimedWaiting") : translate("drawer.noRuns"),
6004
+ ),
5836
6005
  );
5837
- }
5838
- // Memory recall: the worker always reports whether it read lessons, so the
5839
- // block keeps one line even when the record predates that field.
5840
- const lessonCount = run.lessons ? asCount(run.lessons.count, 0) : 0;
5841
- const lessonsText =
5842
- lessonCount > 0
5843
- ? translate("drawer.runLessons").replace("{count}", String(lessonCount))
5844
- : translate("drawer.runNoLessons");
5845
- content.appendChild(element(doc, "div", "hive-card-run-meta", lessonsText));
5846
- const output = element(doc, "div", "hive-card-run-output hive-markdown");
5847
- const outputText = asString(run.output);
5848
- if (outputText.trim() === "") {
5849
- output.appendChild(element(doc, "div", "hive-markdown-empty", translate("drawer.noOutput")));
5850
- } else {
5851
- renderMarkdownInto(doc, output, outputText);
5852
- }
5853
- content.appendChild(output);
5854
- const foot = element(doc, "div", "hive-card-run-foot");
5855
- const copy = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-copy", translate("drawer.copyOutput"));
5856
- setAttr(copy, "type", "button");
5857
- setAttr(copy, "title", translate("drawer.copyOutput"));
5858
- setAttr(copy, "aria-label", translate("drawer.copyOutput"));
5859
- copy.addEventListener("click", () => {
5860
- copyToClipboard(doc, run.output);
5861
- });
5862
- if (Array.isArray(actionHost) || actionHost) addAction(copy);
5863
- else foot.appendChild(copy);
5864
- // Only render the jump-to-chat control when both halves exist: a recorded
5865
- // worker Session and a host navigation callback. The status does not matter:
5866
- // a running card exposes its Session as soon as the worker starts, and the
5867
- // button must be there while the card is still in progress. No disabled stub.
5868
- const canOpenChat = asString(run.sessionId) !== "" && typeof openSession === "function";
5869
- if (canOpenChat) {
5870
- const chat = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-open", translate("drawer.openChat"));
5871
- setAttr(chat, "type", "button");
5872
- setAttr(chat, "title", translate("drawer.openChat"));
5873
- setAttr(chat, "aria-label", translate("drawer.openChat"));
5874
- chat.addEventListener("click", () => {
5875
- try {
5876
- openSession(run.sessionId);
5877
- } catch (error) {
5878
- reportError(error);
6006
+ if (claimed) return section;
6007
+ }
6008
+
6009
+ if (run) {
6010
+ const appendMeta = (text) => {
6011
+ if (!text) return;
6012
+ const meta = element(doc, "div", "hive-section-meta", text);
6013
+ setAttr(meta, "title", text);
6014
+ content.appendChild(meta);
6015
+ };
6016
+ if (claimed) {
6017
+ const started = formatRunStamp(run.startedAt);
6018
+ const heartbeat = formatRunStamp(run.lastHeartbeat);
6019
+ const elapsed = durationBetween(run.startedAt, null);
6020
+ appendMeta(
6021
+ [
6022
+ run.agent ? translate("drawer.agent").replace("{agent}", run.agent) : "",
6023
+ started ? translate("drawer.startedAt").replace("{time}", started) : "",
6024
+ elapsed ? translate("drawer.elapsed").replace("{duration}", elapsed) : "",
6025
+ translate("drawer.lastHeartbeat").replace("{time}", heartbeat || "—"),
6026
+ ]
6027
+ .filter(Boolean)
6028
+ .join(" · "),
6029
+ );
6030
+ if (Array.isArray(card.scope) && card.scope.length > 0) {
6031
+ const files = element(doc, "div", "hive-run-files");
6032
+ files.appendChild(element(doc, "span", "hive-run-field-label", translate("drawer.files")));
6033
+ for (const scope of card.scope) {
6034
+ const path = element(doc, "code", "hive-scope-path", asString(scope));
6035
+ setAttr(path, "title", asString(scope));
6036
+ files.appendChild(path);
6037
+ }
6038
+ content.appendChild(files);
5879
6039
  }
5880
- });
5881
- if (Array.isArray(actionHost) || actionHost) addAction(chat);
5882
- else foot.appendChild(chat);
6040
+ } else {
6041
+ const duration = durationBetween(run.startedAt, run.endedAt);
6042
+ appendMeta(
6043
+ [
6044
+ translate("drawer.status").replace("{status}", laneLabel(run.status || lane)),
6045
+ duration ? translate("drawer.duration").replace("{duration}", duration) : "",
6046
+ run.commit ? translate("drawer.commit").replace("{commit}", shortCommit(run.commit)) : "",
6047
+ ]
6048
+ .filter(Boolean)
6049
+ .join(" · "),
6050
+ );
6051
+ }
6052
+
6053
+ // Consensus announcements: the other agents that announced the same paths.
6054
+ const writers = [];
6055
+ for (const overlap of run.overlaps) {
6056
+ const agent = asString(overlap.agent);
6057
+ if (agent !== "" && !writers.includes(agent)) writers.push(agent);
6058
+ }
6059
+ if (writers.length > 0) {
6060
+ const overlapsLabel = translate("drawer.runOverlaps");
6061
+ const separator = /[\u4e00-\u9fff]/.test(overlapsLabel) ? ":" : ": ";
6062
+ appendMeta(overlapsLabel + separator + writers.join(", "));
6063
+ }
6064
+
6065
+ const outputText = asString(run.output);
6066
+ if (claimed) {
6067
+ content.appendChild(
6068
+ element(doc, "div", "hive-run-field-label", translate("drawer.outputTail")),
6069
+ );
6070
+ }
6071
+ const output = element(doc, "div", "hive-card-run-output hive-markdown");
6072
+ const shownOutput = claimed ? outputText.split("\n").slice(-30).join("\n") : outputText;
6073
+ if (shownOutput.trim() === "") {
6074
+ output.appendChild(element(doc, "div", "hive-markdown-empty", translate("drawer.noOutput")));
6075
+ } else {
6076
+ renderMarkdownInto(doc, output, shownOutput);
6077
+ }
6078
+ content.appendChild(output);
6079
+
6080
+ if (lane === "failed") {
6081
+ const reason = asString(run.reason) || asString(card.reason);
6082
+ if (reason) {
6083
+ const failure = element(doc, "div", "hive-run-failure");
6084
+ failure.appendChild(element(doc, "div", "hive-run-field-label", translate("drawer.failureReason")));
6085
+ failure.appendChild(element(doc, "div", "hive-run-failure-text", reason));
6086
+ content.appendChild(failure);
6087
+ }
6088
+ }
6089
+
6090
+ const foot = element(doc, "div", "hive-card-run-foot");
6091
+ if (outputText.trim() !== "") {
6092
+ const copy = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-copy", translate("drawer.copyOutput"));
6093
+ setAttr(copy, "type", "button");
6094
+ setAttr(copy, "title", translate("drawer.copyOutput"));
6095
+ setAttr(copy, "aria-label", translate("drawer.copyOutput"));
6096
+ copy.addEventListener("click", () => {
6097
+ copyToClipboard(doc, run.output);
6098
+ });
6099
+ if (Array.isArray(actionHost) || actionHost) addAction(copy);
6100
+ else foot.appendChild(copy);
6101
+ }
6102
+ const canOpenChat = asString(run.sessionId) !== "" && typeof openSession === "function";
6103
+ if (canOpenChat) {
6104
+ const chat = element(doc, "button", "hive-btn hive-btn-ghost hive-card-run-open", translate("drawer.openChat"));
6105
+ setAttr(chat, "type", "button");
6106
+ setAttr(chat, "title", translate("drawer.openChat"));
6107
+ setAttr(chat, "aria-label", translate("drawer.openChat"));
6108
+ chat.addEventListener("click", () => {
6109
+ try {
6110
+ openSession(run.sessionId);
6111
+ } catch (error) {
6112
+ reportError(error);
6113
+ }
6114
+ });
6115
+ if (Array.isArray(actionHost) || actionHost) addAction(chat);
6116
+ else foot.appendChild(chat);
6117
+ }
6118
+ if (!actionHost && foot.children.length > 0) section.appendChild(foot);
5883
6119
  }
5884
- if (!actionHost) section.appendChild(foot);
5885
6120
  return section;
5886
6121
  }
5887
6122
 
@@ -5903,6 +6138,7 @@ function renderMarkdownInto(doc, host, source) {
5903
6138
 
5904
6139
  const part = createSection({
5905
6140
  title: translate("drawer.dependenciesTitle"),
6141
+ hint: translate("drawer.dependenciesHint"),
5906
6142
  className: "hive-deps",
5907
6143
  });
5908
6144
  const block = part.section;
@@ -5942,6 +6178,106 @@ function renderMarkdownInto(doc, host, source) {
5942
6178
  if (content.children.length > 0) body.appendChild(block);
5943
6179
  }
5944
6180
 
6181
+ function renderExperience(card, body) {
6182
+ const experience = card.experience;
6183
+ if (!experience) return;
6184
+ const readCount = experience.read.count;
6185
+ const writtenCount = experience.written.count;
6186
+ if (readCount === 0 && writtenCount === 0) return;
6187
+ const part = createSection({
6188
+ title: translate("drawer.experienceTitle"),
6189
+ hint: translate("drawer.experienceHint"),
6190
+ className: "hive-experience",
6191
+ });
6192
+ if (readCount > 0) {
6193
+ part.content.appendChild(
6194
+ element(
6195
+ doc,
6196
+ "div",
6197
+ "hive-exp-count",
6198
+ translate("drawer.experienceRead").replace("{count}", String(readCount)),
6199
+ ),
6200
+ );
6201
+ }
6202
+ if (writtenCount > 0) {
6203
+ part.content.appendChild(
6204
+ element(
6205
+ doc,
6206
+ "div",
6207
+ "hive-exp-count",
6208
+ translate("drawer.experienceWritten").replace("{count}", String(writtenCount)),
6209
+ ),
6210
+ );
6211
+ }
6212
+ const items = [
6213
+ ...experience.read.items.map((item) => ({ ...item, side: "read" })),
6214
+ ...experience.written.items.map((item) => ({ ...item, side: "written" })),
6215
+ ];
6216
+ if (items.length > 0) {
6217
+ const list = element(doc, "div", "hive-exp-list");
6218
+ const appendItem = (item) => {
6219
+ const row = element(doc, "div", "hive-exp-item");
6220
+ if (item.scope) row.appendChild(element(doc, "code", "hive-exp-scope", item.scope));
6221
+ if (item.text) row.appendChild(element(doc, "span", "hive-exp-text", item.text));
6222
+ list.appendChild(row);
6223
+ };
6224
+ for (const item of items.slice(0, 3)) appendItem(item);
6225
+ const hidden = items.slice(3);
6226
+ if (hidden.length > 0) {
6227
+ const more = element(
6228
+ doc,
6229
+ "button",
6230
+ "hive-btn hive-btn-ghost hive-exp-more",
6231
+ translate("drawer.experienceMore").replace("{count}", String(hidden.length)),
6232
+ );
6233
+ setAttr(more, "type", "button");
6234
+ const moreLabel = translate("drawer.experienceMore").replace("{count}", String(hidden.length));
6235
+ setAttr(more, "title", moreLabel);
6236
+ setAttr(more, "aria-label", moreLabel);
6237
+ more.addEventListener("click", () => {
6238
+ for (const item of hidden) appendItem(item);
6239
+ more.parentNode.removeChild(more);
6240
+ });
6241
+ list.appendChild(more);
6242
+ }
6243
+ part.content.appendChild(list);
6244
+ }
6245
+ body.appendChild(part.section);
6246
+ }
6247
+
6248
+ async function openCardDetail(card, lane, trigger) {
6249
+ // Open immediately from the list row so the click never waits on I/O, then
6250
+ // refresh the dialog from the id-only detail endpoint when it arrives.
6251
+ openDrawer(card, lane, trigger);
6252
+ let detail = null;
6253
+ let detailLane = lane;
6254
+ if (fetchImpl && card && card.id) {
6255
+ let url = taskUrl;
6256
+ if (url.includes("{id}")) url = url.replace("{id}", encodeURIComponent(String(card.id)));
6257
+ else url = url.replace(/\/+$/, "") + "/" + encodeURIComponent(String(card.id));
6258
+ try {
6259
+ const response = await fetchImpl(url, {
6260
+ cache: "no-store",
6261
+ headers: { accept: "application/json" },
6262
+ });
6263
+ if (response && response.ok !== false) {
6264
+ const payload = await response.json();
6265
+ const task = payload && isRecord(payload.task) ? payload.task : isRecord(payload) ? payload : null;
6266
+ if (task && task.id) {
6267
+ detail = task;
6268
+ detailLane = asString(task.state) || lane;
6269
+ }
6270
+ }
6271
+ } catch (error) {
6272
+ reportError(error);
6273
+ }
6274
+ }
6275
+ if (destroyed || !detail) return;
6276
+ if (drawerState && drawerState.card && drawerState.card.id === card.id) {
6277
+ openDrawer(normalizeCard(detail), detailLane, trigger);
6278
+ }
6279
+ }
6280
+
5945
6281
  function openDrawer(card, lane, trigger) {
5946
6282
  closeHelp(false);
5947
6283
  closePlanDialog(false);
@@ -6019,8 +6355,10 @@ function renderMarkdownInto(doc, host, source) {
6019
6355
  }
6020
6356
 
6021
6357
  renderDependencies(card, body);
6358
+ renderExperience(card, body);
6022
6359
  const runActions = [];
6023
- body.appendChild(buildRunSection(card.lastRun, runActions));
6360
+ const runSection = buildRunSection(card, lane, runActions);
6361
+ if (runSection) body.appendChild(runSection);
6024
6362
  dialog.appendChild(body);
6025
6363
 
6026
6364
  const actions = actionsForState(lane, lastModel ? lastModel.writable : false);
@@ -6649,6 +6987,19 @@ function renderMarkdownInto(doc, host, source) {
6649
6987
  return translate(key).replace("{count}", String(count));
6650
6988
  }
6651
6989
 
6990
+ function durationBetween(start, end) {
6991
+ const from = parseDate(start);
6992
+ if (!from) return "";
6993
+ const to = parseDate(end) || new Date();
6994
+ const seconds = Math.max(0, Math.floor((to.getTime() - from.getTime()) / 1000));
6995
+ if (seconds < 60) return translate("stats.duration.justNow");
6996
+ const minutes = Math.floor(seconds / 60);
6997
+ if (minutes < 60) return durationLabel(minutes, "stats.duration.minute", "stats.duration.minutes");
6998
+ const hours = Math.floor(minutes / 60);
6999
+ if (hours < 24) return durationLabel(hours, "stats.duration.hour", "stats.duration.hours");
7000
+ return durationLabel(Math.floor(hours / 24), "stats.duration.day", "stats.duration.days");
7001
+ }
7002
+
6652
7003
  function elapsedLabel(createdAt) {
6653
7004
  const date = parseDate(createdAt);
6654
7005
  if (!date) return "";
@@ -6763,12 +7114,12 @@ function renderMarkdownInto(doc, host, source) {
6763
7114
  setAttr(node, "tabindex", "0");
6764
7115
  setAttr(node, "role", "button");
6765
7116
  node.addEventListener("click", () => {
6766
- if (node._hiveCard) openDrawer(node._hiveCard, node._hiveLane, node);
7117
+ if (node._hiveCard) void openCardDetail(node._hiveCard, node._hiveLane, node);
6767
7118
  });
6768
7119
  node.addEventListener("keydown", (event) => {
6769
7120
  if (!event || (event.key !== "Enter" && event.key !== " ")) return;
6770
7121
  if (typeof event.preventDefault === "function") event.preventDefault();
6771
- if (node._hiveCard) openDrawer(node._hiveCard, node._hiveLane, node);
7122
+ if (node._hiveCard) void openCardDetail(node._hiveCard, node._hiveLane, node);
6772
7123
  });
6773
7124
  node._hiveTitle = element(doc, "div", "hive-card-title", "");
6774
7125
  node.appendChild(node._hiveTitle);
@@ -6811,6 +7162,12 @@ function renderMarkdownInto(doc, host, source) {
6811
7162
  }
6812
7163
  }
6813
7164
 
7165
+ function resetLaneScroll() {
7166
+ for (const state of laneRenderState.values()) {
7167
+ state.list.scrollTop = 0;
7168
+ }
7169
+ }
7170
+
6814
7171
  function selectStageFilter(filter) {
6815
7172
  stageFilter = filter;
6816
7173
  for (const entry of stageChipEntries) {
@@ -6818,6 +7175,7 @@ function renderMarkdownInto(doc, host, source) {
6818
7175
  setAttr(entry.chip, "aria-pressed", entry.filter === filter ? "true" : "false");
6819
7176
  }
6820
7177
  if (lastModel) renderLanes(lastModel);
7178
+ resetLaneScroll();
6821
7179
  }
6822
7180
 
6823
7181
  function cardSortTime(card) {
@@ -6845,8 +7203,11 @@ function renderMarkdownInto(doc, host, source) {
6845
7203
  }
6846
7204
 
6847
7205
  const LANE_ROW_HEIGHT = 28;
6848
- const LANE_ROW_BUFFER = 10;
7206
+ const LANE_ROW_BUFFER = 4;
7207
+ const LANE_MAX_ROWS = 20;
6849
7208
  const LANE_VIEWPORT_FALLBACK = 480;
7209
+ const LANE_DATA_LIMIT = 5000;
7210
+ const LANE_PAGE_SIZE = 200;
6850
7211
 
6851
7212
  function createLaneState(lane) {
6852
7213
  const column = element(doc, "section", "hive-lane hive-lane-" + lane);
@@ -6854,7 +7215,24 @@ function renderMarkdownInto(doc, host, source) {
6854
7215
  head.appendChild(element(doc, "span", "hive-lane-name", laneLabel(lane)));
6855
7216
  const count = element(doc, "span", "hive-count", "0");
6856
7217
  head.appendChild(count);
7218
+ const headActions = element(doc, "span", "hive-lane-head-actions");
7219
+ const topMore = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-more-top is-hidden", translate("board.loadMore"));
7220
+ setAttr(topMore, "type", "button");
7221
+ const latest = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-latest", translate("board.latest"));
7222
+ setAttr(latest, "type", "button");
7223
+ setAttr(latest, "title", translate("board.latestAria"));
7224
+ setAttr(latest, "aria-label", translate("board.latestAria"));
7225
+ headActions.appendChild(topMore);
7226
+ headActions.appendChild(latest);
7227
+ head.appendChild(headActions);
6857
7228
  column.appendChild(head);
7229
+ const recycle = element(doc, "div", "hive-lane-recycle is-hidden");
7230
+ const recycleText = element(doc, "span", "hive-lane-recycle-text", "");
7231
+ const recycleButton = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-recycle-reload", translate("board.reloadLatest"));
7232
+ setAttr(recycleButton, "type", "button");
7233
+ recycle.appendChild(recycleText);
7234
+ recycle.appendChild(recycleButton);
7235
+ column.appendChild(recycle);
6858
7236
 
6859
7237
  const list = element(doc, "div", "hive-lane-cards");
6860
7238
  const inner = element(doc, "div", "hive-lane-virtual");
@@ -6863,7 +7241,42 @@ function renderMarkdownInto(doc, host, source) {
6863
7241
  lanesNode.appendChild(column);
6864
7242
 
6865
7243
  const state = { lane, column, list, inner, count, cards: [], visible: new Map() };
6866
- list.addEventListener("scroll", () => renderLaneVirtual(state));
7244
+ const loadingRow = element(doc, "div", "hive-lane-loading is-hidden", translate("board.loading"));
7245
+ list.appendChild(loadingRow);
7246
+ list.addEventListener("scroll", () => {
7247
+ renderLaneVirtual(state);
7248
+ maybeLoadNextPage(state);
7249
+ });
7250
+ const paging = element(doc, "div", "hive-lane-paging");
7251
+ const more = element(doc, "button", "hive-btn hive-btn-ghost hive-lane-more is-hidden", translate("board.loadMore"));
7252
+ setAttr(more, "type", "button");
7253
+ const pageError = element(doc, "div", "hive-lane-page-error is-hidden", "");
7254
+ paging.appendChild(more);
7255
+ paging.appendChild(pageError);
7256
+ column.appendChild(paging);
7257
+ state.more = more;
7258
+ state.pageError = pageError;
7259
+ state.loadingRow = loadingRow;
7260
+ state.recycle = recycle;
7261
+ state.recycleText = recycleText;
7262
+ state.recycleButton = recycleButton;
7263
+ state.recycled = 0;
7264
+ state.loadingPage = false;
7265
+ state.pageFailure = "";
7266
+ more.addEventListener("click", () => {
7267
+ void loadLanePage(state.lane, state);
7268
+ });
7269
+ topMore.addEventListener("click", () => {
7270
+ void loadLanePage(state.lane, state);
7271
+ });
7272
+ recycleButton.addEventListener("click", () => {
7273
+ void reloadLaneLatest(state.lane, state);
7274
+ });
7275
+ latest.addEventListener("click", () => {
7276
+ state.list.scrollTop = 0;
7277
+ });
7278
+ state.topMore = topMore;
7279
+ state.latest = latest;
6867
7280
  return state;
6868
7281
  }
6869
7282
 
@@ -6877,7 +7290,8 @@ function renderMarkdownInto(doc, host, source) {
6877
7290
  : LANE_VIEWPORT_FALLBACK;
6878
7291
  const scrollTop = Number(state.list.scrollTop) || 0;
6879
7292
  const start = Math.max(0, Math.floor(scrollTop / row) - LANE_ROW_BUFFER);
6880
- const end = Math.min(total, Math.ceil((scrollTop + viewport) / row) + LANE_ROW_BUFFER);
7293
+ let end = Math.min(total, Math.ceil((scrollTop + viewport) / row) + LANE_ROW_BUFFER);
7294
+ if (end - start > LANE_MAX_ROWS) end = start + LANE_MAX_ROWS;
6881
7295
  const height = total === 0 ? 0 : total * row - 2;
6882
7296
  setStyle(state.inner, "height", String(height) + "px");
6883
7297
 
@@ -6898,6 +7312,211 @@ function renderMarkdownInto(doc, host, source) {
6898
7312
  state.count.textContent = String(total);
6899
7313
  }
6900
7314
 
7315
+ let searchSeq = 0;
7316
+
7317
+ function taskSearchUrl(query) {
7318
+ const params = ["search=" + encodeURIComponent(query), "limit=200"];
7319
+ return tasksUrl + (tasksUrl.includes("?") ? "&" : "?") + params.join("&");
7320
+ }
7321
+
7322
+ function renderSearchResults(items, total) {
7323
+ clearNode(searchResults);
7324
+ searchResults.className = "hive-search-results";
7325
+ if (!Array.isArray(items) || items.length === 0) {
7326
+ searchResults.appendChild(element(doc, "div", "hive-search-empty", translate("board.searchEmpty")));
7327
+ return;
7328
+ }
7329
+ searchResults.appendChild(
7330
+ element(
7331
+ doc,
7332
+ "div",
7333
+ "hive-search-summary",
7334
+ translate("board.searchResults").replace("{count}", String(asCount(total, items.length))),
7335
+ ),
7336
+ );
7337
+ for (const taskData of items) {
7338
+ const task = normalizeCard(taskData);
7339
+ const button = element(doc, "button", "hive-search-result");
7340
+ setAttr(button, "type", "button");
7341
+ button.appendChild(element(doc, "span", "hive-search-status is-" + safeClassToken(task.state), "●"));
7342
+ button.appendChild(element(doc, "span", "hive-search-title", task.title || task.id));
7343
+ button.appendChild(element(doc, "span", "hive-search-id", task.id));
7344
+ button.addEventListener("click", () => {
7345
+ void openCardDetail(task, task.state, null);
7346
+ });
7347
+ searchResults.appendChild(button);
7348
+ }
7349
+ }
7350
+
7351
+ async function runSearch(rawQuery) {
7352
+ const query = asString(rawQuery).trim();
7353
+ resetLaneScroll();
7354
+ searchSeq += 1;
7355
+ const seq = searchSeq;
7356
+ if (!query) {
7357
+ clearNode(searchResults);
7358
+ searchResults.className = "hive-search-results is-hidden";
7359
+ return;
7360
+ }
7361
+ if (!fetchImpl) return;
7362
+ try {
7363
+ const response = await fetchImpl(taskSearchUrl(query), {
7364
+ cache: "no-store",
7365
+ headers: { accept: "application/json" },
7366
+ });
7367
+ if (!response || response.ok === false) throw new Error("task search failed");
7368
+ const payload = await response.json();
7369
+ if (destroyed || seq !== searchSeq) return;
7370
+ const items = Array.isArray(payload && payload.items) ? payload.items : [];
7371
+ renderSearchResults(items, payload && payload.total);
7372
+ } catch (error) {
7373
+ if (!destroyed && seq === searchSeq) {
7374
+ clearNode(searchResults);
7375
+ searchResults.className = "hive-search-results";
7376
+ searchResults.appendChild(element(doc, "div", "hive-search-empty", translate("board.searchEmpty")));
7377
+ }
7378
+ reportError(error);
7379
+ }
7380
+ }
7381
+
7382
+ function taskPageUrl(state, cursor) {
7383
+ let url = tasksUrl;
7384
+ const params = [];
7385
+ if (url.includes("{state}")) url = url.replace("{state}", encodeURIComponent(state));
7386
+ else params.push("state=" + encodeURIComponent(state));
7387
+ if (url.includes("{cursor}")) url = url.replace("{cursor}", encodeURIComponent(String(cursor)));
7388
+ else params.push("cursor=" + encodeURIComponent(String(cursor)));
7389
+ params.push("limit=200");
7390
+ return url + (url.includes("?") ? "&" : "?") + params.join("&");
7391
+ }
7392
+
7393
+ function pageErrorMessage(error) {
7394
+ return asString(error && error.message) || translate("board.loadFailed");
7395
+ }
7396
+
7397
+ function maybeLoadNextPage(state) {
7398
+ if (destroyed || state.loadingPage || !lastModel) return;
7399
+ const page = lastModel.lanePages ? lastModel.lanePages[state.lane] : null;
7400
+ if (!page || !page.hasMore) return;
7401
+ const list = state.list;
7402
+ const scrollTop = Number(list.scrollTop) || 0;
7403
+ const clientHeight = Number(list.clientHeight) || 0;
7404
+ const scrollHeight = Number(list.scrollHeight) || 0;
7405
+ if (scrollHeight <= 0 || clientHeight <= 0) return;
7406
+ if (scrollTop + clientHeight >= scrollHeight - 24) {
7407
+ void loadLanePage(state.lane, state);
7408
+ }
7409
+ }
7410
+
7411
+ async function loadLanePage(lane, state) {
7412
+ if (destroyed || state.loadingPage) return;
7413
+ const model = lastModel;
7414
+ const page = model && model.lanePages ? model.lanePages[lane] : null;
7415
+ if (!page || !page.hasMore || !fetchImpl) return;
7416
+ state.loadingPage = true;
7417
+ state.pageFailure = "";
7418
+ state.more.disabled = true;
7419
+ state.more.textContent = translate("board.loading");
7420
+ state.topMore.disabled = true;
7421
+ state.topMore.textContent = translate("board.loading");
7422
+ state.loadingRow.className = "hive-lane-loading";
7423
+ state.pageError.className = "hive-lane-page-error is-hidden";
7424
+ const list = state.list;
7425
+ const beforeTop = Number(list.scrollTop) || 0;
7426
+ let added = 0;
7427
+ try {
7428
+ const response = await fetchImpl(taskPageUrl(lane, page.cursor), {
7429
+ cache: "no-store",
7430
+ headers: { accept: "application/json" },
7431
+ });
7432
+ if (!response || response.ok === false) {
7433
+ throw new Error("tasks page failed with status " + (response ? response.status : "none"));
7434
+ }
7435
+ const payload = await response.json();
7436
+ const items = Array.isArray(payload && payload.items)
7437
+ ? payload.items
7438
+ : Array.isArray(payload && payload.tasks)
7439
+ ? payload.tasks
7440
+ : null;
7441
+ if (!items) throw new Error("tasks page returned no items");
7442
+ const total = asCount(payload && payload.total, page.total);
7443
+ const cursor = asCount(payload && payload.cursor, page.cursor + items.length);
7444
+ const hasMore = payload && payload.hasMore === true ? true : cursor < total;
7445
+ if (!lastSnapshot) throw new Error("the board is not ready");
7446
+ const existing = Array.isArray(lastSnapshot.tasks) ? lastSnapshot.tasks : [];
7447
+ const seen = new Set(existing.map((task) => String(task && task.id)));
7448
+ const merged = [...existing];
7449
+ for (const task of items) {
7450
+ const id = String(task && task.id);
7451
+ if (!id || seen.has(id)) continue;
7452
+ seen.add(id);
7453
+ merged.push(task);
7454
+ added += 1;
7455
+ }
7456
+ let kept = merged;
7457
+ const laneRows = merged.filter((task) => (task && (task.state || "pending")) === lane);
7458
+ let dropped = 0;
7459
+ if (laneRows.length > LANE_DATA_LIMIT) {
7460
+ const dropIds = new Set(laneRows.slice(LANE_DATA_LIMIT).map((task) => String(task && task.id)));
7461
+ dropped = dropIds.size;
7462
+ kept = merged.filter((task) => !dropIds.has(String(task && task.id)));
7463
+ }
7464
+ state.recycled += dropped;
7465
+ const lanePages = { ...(isRecord(lastSnapshot.lanePages) ? lastSnapshot.lanePages : {}) };
7466
+ lanePages[lane] = { total, cursor, hasMore };
7467
+ setSnapshot({ ...lastSnapshot, tasks: kept, lanePages });
7468
+ } catch (error) {
7469
+ state.pageFailure = pageErrorMessage(error);
7470
+ reportError(error);
7471
+ } finally {
7472
+ state.loadingPage = false;
7473
+ state.loadingRow.className = "hive-lane-loading is-hidden";
7474
+ if (!destroyed && lastModel) renderLanes(lastModel);
7475
+ if (!destroyed && added > 0) {
7476
+ list.scrollTop = beforeTop;
7477
+ }
7478
+ }
7479
+ }
7480
+
7481
+ async function reloadLaneLatest(lane, state) {
7482
+ if (destroyed || state.loadingPage || !fetchImpl || !lastSnapshot) return;
7483
+ state.loadingPage = true;
7484
+ state.pageFailure = "";
7485
+ state.more.disabled = true;
7486
+ state.more.textContent = translate("board.loading");
7487
+ state.topMore.disabled = true;
7488
+ state.topMore.textContent = translate("board.loading");
7489
+ state.loadingRow.className = "hive-lane-loading";
7490
+ state.pageError.className = "hive-lane-page-error is-hidden";
7491
+ state.list.scrollTop = 0;
7492
+ try {
7493
+ const response = await fetchImpl(taskPageUrl(lane, 0), {
7494
+ cache: "no-store",
7495
+ headers: { accept: "application/json" },
7496
+ });
7497
+ if (!response || response.ok === false) throw new Error("tasks page failed with status " + (response ? response.status : "none"));
7498
+ const payload = await response.json();
7499
+ const items = Array.isArray(payload && payload.items) ? payload.items : [];
7500
+ const total = asCount(payload && payload.total, items.length);
7501
+ const cursor = asCount(payload && payload.cursor, items.length);
7502
+ const hasMore = payload && payload.hasMore === true ? true : cursor < total;
7503
+ const others = (Array.isArray(lastSnapshot.tasks) ? lastSnapshot.tasks : [])
7504
+ .filter((task) => (task && (task.state || "pending")) !== lane);
7505
+ const lanePages = { ...(isRecord(lastSnapshot.lanePages) ? lastSnapshot.lanePages : {}) };
7506
+ lanePages[lane] = { total, cursor, hasMore };
7507
+ state.recycled = 0;
7508
+ setSnapshot({ ...lastSnapshot, tasks: [...others, ...items], lanePages });
7509
+ state.list.scrollTop = 0;
7510
+ } catch (error) {
7511
+ state.pageFailure = pageErrorMessage(error);
7512
+ reportError(error);
7513
+ } finally {
7514
+ state.loadingPage = false;
7515
+ state.loadingRow.className = "hive-lane-loading is-hidden";
7516
+ if (!destroyed && lastModel) renderLanes(lastModel);
7517
+ }
7518
+ }
7519
+
6901
7520
  function renderLanes(model) {
6902
7521
  if (model.initialised === false) {
6903
7522
  clearNode(lanesNode);
@@ -6920,6 +7539,31 @@ function renderMarkdownInto(doc, host, source) {
6920
7539
  if (stageFilter !== "all" && stageFilter !== lane) classes.push("is-filtered-out");
6921
7540
  state.column.className = classes.join(" ");
6922
7541
  renderLaneVirtual(state);
7542
+ const pageInfo = model.lanePages && model.lanePages[lane] ? model.lanePages[lane] : null;
7543
+ const loaded = cards.length;
7544
+ const total = pageInfo ? pageInfo.total : loaded;
7545
+ state.count.textContent = total > loaded ? loaded + " / " + total : String(loaded);
7546
+ const hasMore = Boolean(pageInfo && pageInfo.hasMore);
7547
+ state.more.className = "hive-btn hive-btn-ghost hive-lane-more" + (hasMore ? "" : " is-hidden");
7548
+ state.recycle.className = "hive-lane-recycle" + (state.recycled > 0 ? "" : " is-hidden");
7549
+ state.recycleText.textContent = state.recycled > 0
7550
+ ? translate("board.recycled").replace("{count}", String(state.recycled)) + " · "
7551
+ : "";
7552
+ state.loadingRow.className = "hive-lane-loading" + (state.loadingPage ? "" : " is-hidden");
7553
+ state.topMore.className = "hive-btn hive-btn-ghost hive-lane-more-top" + (hasMore ? "" : " is-hidden");
7554
+ state.topMore.disabled = state.loadingPage === true;
7555
+ state.topMore.textContent = state.loadingPage ? translate("board.loading") : translate("board.loadMore");
7556
+ state.latest.className = "hive-btn hive-btn-ghost hive-lane-latest" + (loaded > 0 ? "" : " is-hidden");
7557
+ state.more.disabled = state.loadingPage === true;
7558
+ state.more.textContent = state.loadingPage
7559
+ ? translate("board.loading")
7560
+ : state.pageFailure
7561
+ ? translate("board.retry")
7562
+ : translate("board.loadMore");
7563
+ state.pageError.className = "hive-lane-page-error" + (state.pageFailure ? "" : " is-hidden");
7564
+ state.pageError.textContent = state.pageFailure
7565
+ ? translate("board.loadFailed") + ": " + state.pageFailure
7566
+ : "";
6923
7567
  seen.add(lane);
6924
7568
  }
6925
7569
  for (const [lane, state] of laneRenderState) {
@@ -7020,6 +7664,8 @@ function renderMarkdownInto(doc, host, source) {
7020
7664
  // --- data flow -----------------------------------------------------------
7021
7665
 
7022
7666
  function resetRepoState() {
7667
+ for (const state of laneRenderState.values()) state.recycled = 0;
7668
+ resetLaneScroll();
7023
7669
  initRequestSeq += 1;
7024
7670
  initBusy = false;
7025
7671
  initOutput = null;