dsh-pilot-board 0.1.0 → 0.2.0

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.js CHANGED
@@ -34,7 +34,7 @@ window.__ModuleLoader__.load({
34
34
  factory(require) {
35
35
  const React = require('react')
36
36
  const h = React.createElement
37
- const { useCallback, useEffect, useRef, useState, useSyncExternalStore } = React
37
+ const { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } = React
38
38
  let createPortal
39
39
  try {
40
40
  createPortal = require('react-dom').createPortal
@@ -337,7 +337,7 @@ window.__ModuleLoader__.load({
337
337
  'integrate.qaMatchesHead': 'Commit {commit} matches branch HEAD.',
338
338
  'integrate.qaStaleHead': 'Tested commit {commit}; branch HEAD is now {head}.',
339
339
  'integrate.qaRetry': 'Retry QA check',
340
- 'kanban.subagents': 'Subagent configuration',
340
+ 'kanban.subagents': 'Project agents',
341
341
  'kanban.subagentsClose': 'Close',
342
342
  'kanban.subagentsUnsaved': 'Save or cancel the open agent form before closing.',
343
343
  'kanban.panel': 'Roadmap board',
@@ -357,6 +357,9 @@ window.__ModuleLoader__.load({
357
357
  'kanban.empty': 'No tasks',
358
358
  'kanban.doneShow': 'Show the Done column ({count})',
359
359
  'kanban.doneHide': 'Collapse the Done column',
360
+ 'kanban.doneGroup.label': '{id} {title}, {count} done tasks',
361
+ 'kanban.doneGroup.labelOne': '{id} {title}, 1 done task',
362
+ 'kanban.doneGroup.toggle': 'Show or hide the done tasks of {id}',
360
363
  'kanban.search': 'Search tasks',
361
364
  'kanban.searchPlaceholder': 'Search id or title… ( / )',
362
365
  'kanban.milestones': 'Filter by milestone',
@@ -607,11 +610,60 @@ window.__ModuleLoader__.load({
607
610
  'timeline.empty': 'Nothing has happened yet.',
608
611
  /* ── milestone pilot (M14.5) ─────────────────────────────────────────── */
609
612
  'pilot.button': 'Pilot',
610
- 'pilot.open': 'Pilot a milestone',
613
+ 'pilot.start': 'Start pilot…',
614
+ 'pilot.options': 'Pilot options',
615
+ 'pilot.toolbarAttention': 'Pilot — {count} need your decision',
616
+ 'pilot.toolbarAttentionOne': 'Pilot — 1 needs your decision',
617
+ 'pilot.attentionTitle': '{count} need your decision',
618
+ 'pilot.attentionTitleOne': '1 needs your decision',
619
+ 'pilot.attentionOpen': 'Open gate',
620
+ 'pilot.attentionAnswer': 'Answer',
621
+ 'pilot.attentionOpenPilot': 'Open pilot',
622
+ 'pilot.attentionAction': '{action} for {id}',
623
+ 'pilot.attentionUnavailable': 'Pilot status unavailable',
624
+ 'pilot.attentionPlan': 'review the spec and plan (revision {number})',
625
+ 'pilot.attentionQuestion': 'question: {question}',
626
+ 'pilot.attentionReview': 'review the result and merge',
627
+ 'pilot.milestonesProgress': '{done} / {total} done',
628
+ 'pilot.milestoneDoneUnmerged': 'Done (unmerged)',
629
+ 'pilot.milestonesProvisional': 'The pilot marked this done; the roadmap records it when the pilot merges',
630
+ 'pilot.card.label': 'Pilot milestone {id}: {title}',
631
+ 'pilot.card.kind': 'Pilot milestone',
632
+ 'pilot.card.now': 'Now: {id} {title}',
633
+ 'pilot.card.input': 'Needs your input',
634
+ 'pilot.card.blocked': 'Blocked',
635
+ 'pilot.card.mergeFailed': 'The merge returned the pilot to implementation',
636
+ 'pilot.card.stopped': 'Stopped',
637
+ 'pilot.card.cleanup': 'Merged · cleanup kept items',
638
+ 'pilot.card.toggle': 'Show or hide the tasks of {id}',
639
+ 'pilot.card.action.answer': 'Answer',
640
+ 'pilot.card.action.review-plan': 'Review plan',
641
+ 'pilot.card.action.review-merge': 'Review & merge',
642
+ 'pilot.card.action.open': 'Open pilot',
643
+ 'pilot.card.action.resume': 'Resume',
644
+ 'pilot.card.action.retry': 'Retry cleanup',
645
+ 'pilot.card.action.dismiss': 'Dismiss',
646
+ 'pilot.card.mergedNotice': '{id}: {text} · {cleanup}',
647
+ 'pilot.cleanup.kept.worktree': 'Kept worktree: {reason}',
648
+ 'pilot.cleanup.kept.branch': 'Kept branch: {reason}',
649
+ 'pilot.cleanup.kept.session': 'Kept session: {reason}',
650
+ 'pilot.cleanup.removed.worktree': 'worktree removed',
651
+ 'pilot.cleanup.removed.branch': 'branch deleted',
652
+ 'pilot.cleanup.removed.session': 'session archived',
653
+ 'pilot.cleanup.absent.worktree': 'no worktree',
654
+ 'pilot.cleanup.absent.branch': 'no branch',
655
+ 'pilot.cleanup.absent.session': 'no session',
656
+ 'pilot.agentsNone': 'Project agents · none ready · the pilot runs solo',
657
+ 'pilot.agentsReady': 'Project agents · {count} ready',
658
+ 'pilot.gate.changesSince': 'Changes since revision {number}',
659
+ 'pilot.gate.diffTooLarge': '{label} was largely rewritten, too much to show line by line here; open it above to read the new revision.',
660
+ 'pilot.roundCap.title': 'Pilot round cap',
661
+ 'pilot.roundCap.hint': 'Automatic continuations before the goal stops',
611
662
  'pilot.title': 'Milestone pilot',
612
663
  'pilot.dialog.title': 'Pilot {id}: {title}',
613
664
  'pilot.dialog.branch': 'Branch: {branch}',
614
665
  'pilot.dialog.openTasks': '{count} open tasks run in dependency order',
666
+ 'pilot.dialog.openTaskOne': '1 open task runs in dependency order',
615
667
  'pilot.dialog.start': 'Start pilot',
616
668
  'pilot.dialog.starting': 'Starting pilot…',
617
669
  'pilot.dialog.none': 'No milestone can be piloted right now.',
@@ -630,13 +682,21 @@ window.__ModuleLoader__.load({
630
682
  'pilot.phase.blocked': 'Blocked',
631
683
  'pilot.phase.done': 'Merged',
632
684
  'pilot.phase.aborted': 'Aborted',
633
- 'pilot.tasks': 'Tasks {done}/{total}',
634
- 'pilot.rounds': 'Round {used}/{max}',
685
+ 'pilot.tasks': '{done} of {total} tasks done',
686
+ 'pilot.tasksOne': '{done} of 1 task done',
687
+ 'pilot.rounds': '{used} of {max} rounds',
635
688
  'pilot.disarmed': 'This session restarted: the goal is not continuing on its own. Resume to re-arm it.',
636
689
  'pilot.chat': 'Pilot chat',
637
690
  'pilot.pause': 'Pause',
638
691
  'pilot.resume': 'Resume',
639
692
  'pilot.abort': 'Abort',
693
+ 'pilot.abortOpen': 'Abort…',
694
+ 'pilot.copy': 'Copy',
695
+ 'pilot.copied': 'Copied',
696
+ 'pilot.copyFailed': 'Copy failed',
697
+ 'pilot.copyFact': 'Copy {label}',
698
+ 'pilot.pickRun': 'Choose pilot run',
699
+ 'pilot.empty': 'No active milestone pilots.',
640
700
  'pilot.abortConfirm': 'Abort this pilot (branch and session are kept)',
641
701
  'pilot.abortCancel': 'Keep piloting',
642
702
  'pilot.stripLabel': 'Milestone pilot {id}',
@@ -649,33 +709,69 @@ window.__ModuleLoader__.load({
649
709
  'pilot.gate.diffHide': 'Hide the changes',
650
710
  'pilot.gate.spec': 'Spec',
651
711
  'pilot.gate.planText': 'Plan',
652
- 'pilot.gate.approve': 'Approve',
712
+ 'pilot.gate.approve': 'Approve and continue',
653
713
  'pilot.gate.changes': 'Request changes',
654
714
  'pilot.gate.changesPlaceholder': 'What should change?',
655
715
  'pilot.gate.review': 'Final review',
716
+ 'pilot.close': 'Close the pilot panel',
717
+ 'settings.agentsHint': 'The project’s agents and their mapped models; the pilot delegates to them',
718
+ 'settings.agentsManage': 'Manage',
719
+ 'pilot.branch': 'Branch',
720
+ 'pilot.worktree': 'Worktree',
721
+ 'pilot.loading': 'Loading pilots…',
722
+ 'pilot.pausing': 'Pausing…',
723
+ 'pilot.resuming': 'Resuming…',
724
+ 'pilot.aborting': 'Aborting…',
725
+ 'pilot.disarmedShort': 'Restarted — Resume re-arms the goal',
726
+ 'pilot.gate.showSpec': 'Show spec ({count} lines)',
727
+ 'pilot.gate.showSpecOne': 'Show spec (1 line)',
728
+ 'pilot.gate.showPlan': 'Show plan ({count} lines)',
729
+ 'pilot.gate.showPlanOne': 'Show plan (1 line)',
730
+ 'pilot.gate.specTitle': 'Pilot spec',
731
+ 'pilot.gate.planTitle': 'Pilot plan',
732
+ 'pilot.gate.noDiff': 'No spec or plan changes since the previous revision.',
733
+ 'pilot.gate.showDetail': 'Review details ({count} QA reports)',
734
+ 'pilot.gate.showDetailOne': 'Review details (1 QA report)',
735
+ 'pilot.gate.noReports': 'No QA report recorded for this run.',
656
736
  'pilot.gate.reviewCode': 'Code review: {verdict} at {commit}',
657
737
  'pilot.gate.reviewMinor': 'Deferred minors: {text}',
658
738
  'pilot.gate.reviewQa': 'Blind QA: {verdict} at {commit}',
659
739
  'pilot.gate.reviewQaReports': 'QA reports: {ids}',
660
740
  'pilot.gate.confirmTitle': 'Approve and merge',
741
+ 'pilot.gate.noToken': 'The merge token has not arrived yet. Reload the board before merging.',
661
742
  'pilot.gate.confirm': 'Rebase and merge {branch} into {base}, remove worktree {worktree}, and mark {count} tasks done.',
743
+ 'pilot.gate.confirmOne': 'Rebase and merge {branch} into {base}, remove worktree {worktree}, and mark 1 task done.',
662
744
  'pilot.gate.merge': 'Approve and merge',
663
745
  'pilot.gate.merging': 'Merging…',
664
746
  'pilot.gate.mergeCancel': 'Cancel',
665
- 'pilot.gate.stale': 'This review changed since the page loaded. Reload the board and review it again.',
747
+ 'pilot.gate.stale': 'This review changed. Cancel and reopen to review the current merge details.',
748
+ 'pilot.gate.testedCommit': 'Tested commit: {commit}',
749
+ 'pilot.gate.verifyCommand': 'Verification command: {command}',
666
750
  'pilot.mergeFailed': 'The merge returned the pilot to implementation',
667
751
  'pilot.skills.title': 'Superpowers skills',
668
752
  'pilot.skills.loading': 'Checking your skills…',
669
- 'pilot.skills.installed': 'All pilot skills are installed.',
670
- 'pilot.skills.partial': '{count} pilot skills are missing.',
753
+ 'pilot.skills.installed': 'All pilot skills installed',
754
+ 'pilot.skills.count': '{installed} of {total} installed',
755
+ 'pilot.skills.partial': '{count} pilot skills missing',
756
+ 'pilot.skills.summary': 'Superpowers · {status}{mode}',
757
+ 'pilot.skills.error': 'Superpowers status unavailable · open Roadmap settings to retry',
758
+ 'pilot.skills.enabled': 'Enabled',
759
+ 'pilot.skills.disabled': 'Disabled',
760
+ 'pilot.skills.settings': 'Settings',
671
761
  'pilot.skills.enable': 'Use Superpowers skills in pilot runs',
672
- 'pilot.skills.setup': 'Set up Superpowers',
673
- 'pilot.skills.user': 'Install for your user (~/.agents/skills)',
674
- 'pilot.skills.project': 'Add to the next pilot branch',
762
+ 'pilot.skills.setup': 'Install…',
763
+ 'pilot.skills.user': 'For my user — ~/.agents/skills, available to every project',
764
+ 'pilot.skills.project': 'For this project — committed on the next pilot branch; main stays clean',
765
+ 'pilot.skills.confirmTitle': 'Install Superpowers skills?',
766
+ 'pilot.skills.confirmHint': 'Nothing is downloaded until you confirm. Existing skill folders are never overwritten.',
767
+ 'pilot.skills.confirmOne': 'Install 1 skill',
768
+ 'pilot.skills.confirmMany': 'Install {count} skills',
769
+ 'pilot.skills.cancel': 'Cancel',
675
770
  'pilot.skills.projectQueued': 'Queued: the skills are committed on the next pilot branch, so main stays clean.',
676
771
  'pilot.skills.missing': 'Missing: {names}',
677
- 'pilot.skills.source': 'Source: {repo} @ {tag}. Existing skills are never overwritten.',
772
+ 'pilot.skills.source': 'Source: {repo} · tag {tag}',
678
773
  'pilot.skills.failed': 'Could not set up Superpowers: {code}',
774
+ 'pilot.agents': 'Project agents · managed in Roadmap settings',
679
775
  'error.pilot-goal-unavailable': 'Piloting needs the DSH goal service and session controller.',
680
776
  'error.pilot-not-startable': 'This milestone cannot be piloted',
681
777
  'error.milestone-piloted': 'A pilot already manages this milestone',
@@ -1910,6 +2006,49 @@ window.__ModuleLoader__.load({
1910
2006
  return nonBlank(values?.title) && !/[\r\n]/.test(values.title) && nonBlank(values?.criteria)
1911
2007
  }
1912
2008
 
2009
+ const PILOT_MILESTONES_CSS = `
2010
+ .rb-pilot-card{display:flex;flex-direction:column;border:1px solid var(--dsw-alias-border-l2);border-inline-start:4px solid var(--rb-swatch,var(--dsw-alias-state-business-primary));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);overflow:hidden}
2011
+ .rb-pilot-card-input,.rb-pilot-card-cleanup{border-color:var(--dsw-alias-state-warn-primary)}
2012
+ .rb-pilot-card-blocked{border-color:var(--dsw-alias-state-error-primary)}
2013
+ .rb-pilot-card-head{display:flex;flex-direction:column;gap:5px;width:100%;padding:8px 10px;border:0;background:none;color:inherit;font:inherit;text-align:left}
2014
+ button.rb-pilot-card-head{cursor:pointer}
2015
+ button.rb-pilot-card-head:hover{background:var(--dsw-alias-interactive-bg-hover)}
2016
+ .rb-pilot-card-row{display:flex;align-items:center;gap:7px;min-width:0}
2017
+ .rb-pilot-card-kind{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:var(--dsw-alias-label-tertiary)}
2018
+ .rb-pilot-card-chev{margin-inline-start:auto;color:var(--dsw-alias-label-tertiary)}
2019
+ .rb-pilot-card-title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2020
+ .rb-pilot-card-row .rb-pilot-step{display:inline-flex;align-items:center;gap:4px}
2021
+ .rb-pilot-card-dot{width:6px;height:6px;border-radius:999px;flex:none;background:currentColor}
2022
+ .rb-pilot-card-prov>span{background:repeating-linear-gradient(45deg,var(--dsw-alias-state-success-primary) 0 4px,transparent 4px 8px)}
2023
+ .rb-pilot-card-status{display:flex;flex-direction:column;gap:6px;margin:0 10px 8px;padding:7px 9px;border:1px solid;border-radius:var(--dsw-radius-sm,6px)}
2024
+ .rb-pilot-card-status strong{display:inline-flex;align-items:center;gap:6px}
2025
+ .rb-pilot-card-status-input,.rb-pilot-card-status-cleanup{border-color:var(--dsw-alias-state-warn-primary)}
2026
+ .rb-pilot-card-status-input strong,.rb-pilot-card-status-cleanup strong{color:var(--dsw-alias-state-warn-primary)}
2027
+ .rb-pilot-card-status-blocked{border-color:var(--dsw-alias-state-error-primary)}
2028
+ .rb-pilot-card-status-blocked strong{color:var(--dsw-alias-state-error-primary)}
2029
+ .rb-pilot-card-status-stopped{border-color:var(--rb-pilot-stopped,var(--dsw-alias-state-done-primary))}
2030
+ .rb-pilot-card-status-stopped strong{color:var(--rb-pilot-stopped,var(--dsw-alias-state-done-primary))}
2031
+ .rb-pilot-card-why{margin:0;white-space:pre-line;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary)}
2032
+ .rb-pilot-card-tasks{list-style:none;margin:0;padding:0 0 4px;border-top:1px solid var(--dsw-alias-border-l1)}
2033
+ .rb-pilot-card .rb-pilot-card-taskrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:8px;align-items:center;width:100%;height:auto;min-height:32px;padding:4px 10px;border:0;border-radius:0;white-space:nowrap;text-align:left}
2034
+ .rb-pilot-card-tasktitle{overflow:hidden;text-overflow:ellipsis}
2035
+ .rb-pilot-card-match{background:var(--dsw-alias-state-warn-secondary)}
2036
+ .rb-pilot-card-foot{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:7px 10px;border-top:1px solid var(--dsw-alias-border-l1)}
2037
+ .rb-pilot-card-branch{margin-inline-start:auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2038
+ .rb-pilot-card-head:focus-visible,.rb-pilot-card-taskrow:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
2039
+ `
2040
+ /* ── Done column milestone groups (M16) ─────────────────────────────── */
2041
+ const DONE_GROUPS_CSS = `
2042
+ .rb-kb-done-groups{display:flex;flex-direction:column;gap:8px;padding:2px 8px 10px;overflow-y:auto;min-height:0}
2043
+ .rb-kb-done-group{display:flex;flex-direction:column;gap:6px}
2044
+ .rb-kb-done-head{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-height:30px;padding:5px 8px;border:1px solid var(--dsw-alias-border-l2);border-inline-start:4px solid var(--rb-mc,var(--dsw-alias-state-business-primary));border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:inherit;font:inherit;font-weight:600;text-align:left;cursor:pointer}
2045
+ .rb-kb-done-head:hover{background:var(--dsw-alias-interactive-bg-hover)}
2046
+ .rb-kb-done-head:focus-visible{outline:2px solid var(--dsw-alias-border-selected);outline-offset:1px}
2047
+ .rb-kb-done-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:400}
2048
+ .rb-kb-done-list{padding:0 0 0 6px;overflow:visible}
2049
+ .rb-kb-done-match>.rb-kb-card{background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 14%,var(--dsw-alias-bg-base));border-color:var(--dsw-alias-state-warn-primary);border-left-color:var(--rb-mc)}
2050
+ .rb-kb-compact .rb-kb-done-head{min-height:32px}
2051
+ `
1913
2052
  /* ── styles (theme tokens only, one <style> id) ───────────────────────── */
1914
2053
 
1915
2054
  const STYLE_ID = 'dsh-roadmap-board-style'
@@ -1944,7 +2083,7 @@ window.__ModuleLoader__.load({
1944
2083
  textarea.rb-input{min-height:54px;resize:vertical}
1945
2084
  .rb-select{box-sizing:border-box;max-width:100%;height:24px;border-radius:var(--dsw-radius-sm);border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;padding:0 4px}
1946
2085
  .rb-label{display:flex;flex-direction:column;gap:3px;font-size:11px;color:var(--dsw-alias-label-secondary);min-width:0}
1947
- .rb-bar{position:relative;display:inline-block;height:4px;border-radius:999px;background:var(--dsw-alias-fill-l1);overflow:hidden;flex:1 1 48px;min-width:40px;vertical-align:middle}
2086
+ .rb-bar{position:relative;display:inline-block;height:4px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);overflow:hidden;flex:1 1 48px;min-width:40px;vertical-align:middle}
1948
2087
  .rb-bar-sm{height:3px}
1949
2088
  .rb-bar-fill{position:absolute;inset:0 auto 0 0;border-radius:999px;background:var(--dsw-alias-state-success-primary)}
1950
2089
  .rb-bar-in_progress .rb-bar-fill{background:var(--dsw-alias-state-business-primary)}
@@ -2046,8 +2185,8 @@ textarea.rb-input{min-height:54px;resize:vertical}
2046
2185
  .rb-qa-banner{display:flex;flex-direction:column;gap:4px;margin:6px 0;padding:6px 8px;border-radius:var(--dsw-radius-sm);border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base)}
2047
2186
  .rb-qa-superseded{color:var(--dsw-alias-state-warn-primary)}
2048
2187
  .rb-qa-old{opacity:.92}
2049
- .rb-diff-add{color:var(--dsw-alias-state-success-primary);background:var(--dsw-alias-fill-l1)}
2050
- .rb-diff-del{color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-fill-l1)}
2188
+ .rb-diff-add{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-code-diff-added)}
2189
+ .rb-diff-del{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-code-diff-deleted)}
2051
2190
  .rb-kb{position:relative;box-sizing:border-box;display:flex;flex-direction:column;flex:1 1 auto;height:100%;min-height:0;min-width:0;overflow:hidden;font-size:12px;line-height:1.45;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);overflow-wrap:anywhere}
2052
2191
  .rb-kb-head{display:flex;flex-direction:column;gap:8px;padding:12px 16px;padding-top:calc(12px + var(--dsh-frame-top-clearance, 0px));border-bottom:1px solid var(--dsw-alias-border-l1)}
2053
2192
  .rb-kb-top{position:relative;display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}
@@ -2181,24 +2320,102 @@ textarea.rb-input{min-height:54px;resize:vertical}
2181
2320
  @keyframes rb-kb-spin{to{transform:rotate(360deg)}}
2182
2321
  @media (prefers-reduced-motion:no-preference){.rb-kb-spin{animation:rb-kb-spin 1s linear infinite}}
2183
2322
  @media (prefers-reduced-motion:reduce){.rb-kb *{transition:none!important;animation:none!important}}
2184
- .rb-pilot-root{display:flex;flex-direction:column;gap:8px;margin:8px 0}
2185
- .rb-pilot-actions{align-items:center}
2186
- .rb-pilot{display:flex;flex-direction:column;gap:6px;border-left:3px solid var(--dsw-alias-brand-primary)}
2187
- .rb-pilot-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
2188
- .rb-pilot-title{font-weight:600}
2189
- .rb-pilot-step{border:1px solid var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
2190
- .rb-pilot-branch{margin:0;font-size:12px;color:var(--dsw-alias-text-secondary);word-break:break-all}
2191
2323
  .rb-pilot-disarmed{border-color:var(--dsw-alias-state-warn-primary)}
2192
2324
  .rb-pilot-gate{display:flex;flex-direction:column;gap:8px}
2193
2325
  .rb-pilot-question{margin:0;font-weight:500}
2194
2326
  .rb-pilot-field{display:flex;flex-direction:column;gap:4px}
2195
- .rb-pilot-textarea{width:100%;font:inherit;padding:6px 8px;border-radius:var(--dsw-radius-sm);border:1px solid var(--dsw-alias-border-secondary);background:var(--dsw-alias-bg-layer-1);color:inherit;resize:vertical}
2327
+ .rb-pilot-textarea{width:100%;font:inherit;padding:6px 8px;border-radius:var(--dsw-radius-sm);border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:inherit;resize:vertical}
2196
2328
  .rb-pilot-doc{max-height:220px;overflow:auto;margin:0}
2197
2329
  .rb-pilot-diff{max-height:200px;overflow:auto;margin:0}
2198
2330
  .rb-pilot-confirm{display:flex;flex-direction:column;gap:6px;padding:8px;border-radius:var(--dsw-radius-sm);border:1px solid var(--dsw-alias-state-warn-primary);background:var(--dsw-alias-bg-layer-1)}
2199
- .rb-pilot-skills{display:flex;flex-direction:column;gap:6px}
2200
- .rb-pilot-start{display:flex;flex-direction:column;gap:8px}
2201
-
2331
+ .rb-pilot-skills-summary{justify-content:space-between}
2332
+ .rb-pilot-start{box-sizing:border-box;width:min(460px,calc(100% - 32px));max-height:calc(100% - 32px);padding:16px;display:flex;flex-direction:column;gap:8px;overflow:auto;color:inherit;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md)}
2333
+ .rb-pilot-start::backdrop{background:var(--dsw-alias-bg-mask-1)}
2334
+
2335
+ .rb-kb-pilotbtn{display:inline-flex;align-items:center;gap:6px;padding:0 10px;height:30px}
2336
+ .rb-kb-pilotlabel{font-size:12px;font-weight:600}
2337
+ .rb-kb-nowrap{display:contents}
2338
+ .rb-kb-pilotwrap{display:flex;flex:1 1 auto;align-items:stretch;align-content:flex-start;flex-wrap:wrap;gap:0;min-width:0;min-height:0;overflow:auto}
2339
+ .rb-pilot-trigger{display:inline-flex;flex:none}
2340
+ .rb-pilot-trigger .rb-kb-badge{position:static;background:var(--dsw-alias-label-primary-foreground);color:var(--dsw-alias-button-primary-fill)}
2341
+ .rb-pilot-trigger:has(.rb-pilot-options) .rb-kb-pilotbtn{border-start-end-radius:0;border-end-end-radius:0}
2342
+ .rb-pilot-options{height:30px;padding:0 7px;border-start-start-radius:0;border-end-start-radius:0}
2343
+ .rb-btn-ghost{border-color:transparent;background:transparent;color:var(--dsw-alias-label-secondary)}
2344
+ .rb-pilot-attention{display:grid;gap:6px;margin:0 12px 8px;padding:8px 10px;border:1px solid var(--dsw-alias-state-warn-primary);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-state-warn-tertiary)}
2345
+ .rb-pilot-attention h3{margin:0;color:var(--dsw-alias-label-primary);font-size:12px;letter-spacing:.05em;text-transform:uppercase}
2346
+ .rb-pilot-attention-row{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;font-size:13px}
2347
+ .rb-pilot-attention-row code{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-xs);padding:0 4px}
2348
+ .rb-pilot-attention-row button{margin-inline-start:auto;color:var(--dsw-alias-label-primary);text-decoration:underline}
2349
+ .rb-kb-mainboard{display:flex;flex:1 1 640px;flex-direction:column;min-width:0;min-height:0}
2350
+ .rb-pilot-panel{display:flex;flex:0 0 372px;flex-direction:column;min-height:0;max-width:100%;border-left:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1)}
2351
+ .rb-pilot-panel-compact{flex:1 1 auto;width:auto;border-left:0;border-top:1px solid var(--dsw-alias-border-l2)}
2352
+ .rb-pilot-panelhead{display:flex;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid var(--dsw-alias-border-l2)}
2353
+ .rb-pilot-panelbody{display:flex;flex:1 1 auto;flex-direction:column;gap:10px;padding:10px;overflow:auto;min-height:0}
2354
+ .rb-pilot-panelfoot{position:sticky;bottom:0;z-index:1;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:9px 10px;border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1)}
2355
+ .rb-pilot-footactions:empty{display:none}
2356
+ .rb-pilot-footactions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
2357
+ .rb-pilot-fact{display:flex;align-items:center;gap:6px;min-width:0}
2358
+ .rb-pilot-agents{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-secondary);border-top:1px solid var(--dsw-alias-border-l1);padding-top:8px}
2359
+ .rb-pilot-agents .rb-btn-link{margin-inline-start:auto}
2360
+ .rb-pilot-dot{flex:none;width:7px;height:7px;border-radius:50%}
2361
+ .rb-pilot-dot-ok{background:var(--dsw-alias-state-success-primary)}
2362
+ .rb-pilot-dot-warn{background:var(--dsw-alias-state-warn-primary)}
2363
+ .rb-pilot-changes-title{margin:0;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}
2364
+ .rb-pilot-attention-why{color:var(--dsw-alias-label-secondary)}
2365
+ .rb-settings-roundcap{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-border-l2)}
2366
+ .rb-settings-roundcap p{margin:2px 0 0}
2367
+ .rb-pilot{display:flex;flex-direction:column;gap:7px;padding:9px 10px;border:1px solid var(--dsw-alias-border-l2);border-left:3px solid var(--dsw-alias-brand-primary);border-radius:var(--dsw-radius-sm)}
2368
+ .rb-pilot-headtitle{display:flex;align-items:center;gap:8px;min-width:0;margin:0}
2369
+ .rb-pilot-title{font-size:13px;font-weight:600}
2370
+ .rb-pilot-status{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
2371
+ .rb-pilot-step{border:1px solid var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:600}
2372
+ .rb-pilot-progress{height:6px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);overflow:hidden}
2373
+ .rb-pilot-progress>span{display:block;height:100%;background:var(--dsw-alias-brand-primary)}
2374
+ .rb-pilot-facts{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px;margin:0;font-size:12px}
2375
+ .rb-pilot-facts dt{color:var(--dsw-alias-label-secondary)}
2376
+ .rb-pilot-facts dd{margin:0;min-width:0}
2377
+ .rb-pilot-trunc{display:block;font-family:monospace;font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2378
+ .rb-pilot-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
2379
+ .rb-pilot-danger{color:var(--dsw-alias-state-error-primary)}
2380
+ .rb-pilot-disclosure{display:inline-flex;align-items:center;gap:6px;border:0;background:none;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer;padding:2px 0;text-align:left}
2381
+ .rb-pilot-disclosure-strong{color:var(--dsw-alias-label-primary);font-weight:600}
2382
+ .rb-pilot-chev{flex:none}
2383
+ .rb-pilot-diffs{display:flex;flex-direction:column;gap:8px}
2384
+ .rb-pilot-diff{border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-xs);overflow:auto;max-height:200px;font-family:monospace;font-size:11.5px;line-height:1.6}
2385
+ .rb-pilot-hunk{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);padding:2px 8px;border-bottom:1px solid var(--dsw-alias-border-l2)}
2386
+ .rb-pilot-line{display:grid;grid-template-columns:14px minmax(0,1fr);gap:6px;padding:0 8px;white-space:pre-wrap}
2387
+ .rb-pilot-sign{user-select:none;text-align:center;opacity:.75}
2388
+ .rb-pilot-add{background:var(--dsw-alias-code-diff-added);color:var(--dsw-alias-label-primary)}
2389
+ .rb-pilot-del{background:var(--dsw-alias-code-diff-deleted);color:var(--dsw-alias-label-primary)}
2390
+ .rb-pilot-context{color:var(--dsw-alias-label-secondary)}
2391
+ .rb-pilot-detail{display:flex;flex-direction:column;gap:4px}
2392
+ .rb-settings-extra{border-top:1px solid var(--dsw-alias-border-l2);margin-top:8px;padding-top:8px}
2393
+ .rb-settings-skills{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-border-l2)}
2394
+ .rb-settings-skills p{margin:4px 0 0}
2395
+ .rb-settings-skills-pin{overflow-wrap:anywhere}
2396
+ .rb-settings-skills-switch{appearance:none;position:relative;width:32px;height:18px;margin:0;border:1px solid currentColor;border-radius:999px;color:inherit;background:transparent;cursor:pointer}
2397
+ .rb-settings-skills-switch::before{content:"";position:absolute;inset:3px auto 3px 3px;width:10px;border-radius:50%;background:currentColor}
2398
+ .rb-settings-skills-switch:checked::before{left:auto;right:3px}
2399
+ .rb-settings-skills-switch:disabled{opacity:.55;cursor:default}
2400
+ .rb-settings-skills-dialog{box-sizing:border-box;width:min(420px,calc(100% - 32px));max-height:calc(100% - 32px);padding:16px;overflow:auto;color:inherit;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md)}
2401
+ .rb-settings-skills-dialog::backdrop{background:var(--dsw-alias-bg-mask-1)}
2402
+ .rb-settings-skills-dialog form,.rb-settings-skills-dialog fieldset{display:grid;gap:8px}
2403
+ .rb-settings-skills-dialog fieldset{border:0;margin:0;padding:0;min-width:0}
2404
+ .rb-settings-skills-dialog label{align-items:baseline;font-size:12px}
2405
+ .rb-settings-skills-dialog input{flex:none}
2406
+ .rb-settings-skills-source{padding:8px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);overflow-wrap:anywhere;font-size:12px}
2407
+ .rb-settings-skills-actions{justify-content:flex-end}
2408
+ @media (max-width:900px){.rb-kb-pilotwrap .rb-kb-board{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}}
2409
+ @media (max-width:1100px){
2410
+ .rb-kb-pilotwrap{flex-direction:column;flex-wrap:nowrap;overflow:auto}
2411
+ .rb-kb-mainboard{flex:0 0 auto;min-height:360px}
2412
+ .rb-pilot-panel{flex:0 0 auto;width:100%;max-height:65vh;border-left:0;border-top:1px solid var(--dsw-alias-border-l2)}
2413
+ }
2414
+ @media (min-width:1101px){.rb-kb-pilotwrap .rb-kb-mainboard .rb-kb-col:not(.rb-kb-collapsed){min-width:0}}
2415
+ @media (pointer:coarse){.rb-pilot-panel .rb-btn,.rb-pilot-disclosure,.rb-pilot-attention-row .rb-btn{min-height:40px}}
2416
+
2417
+ ${PILOT_MILESTONES_CSS}
2418
+ ${DONE_GROUPS_CSS}
2202
2419
  `
2203
2420
  let ownsStyle = false
2204
2421
 
@@ -2225,7 +2442,6 @@ textarea.rb-input{min-height:54px;resize:vertical}
2225
2442
  existing?.remove?.()
2226
2443
  ownsStyle = false
2227
2444
  }
2228
-
2229
2445
  /* ── components ───────────────────────────────────────────────────────── */
2230
2446
 
2231
2447
  /** `t`, with a guard for a stubbed locale that echoes keys. */
@@ -2266,7 +2482,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
2266
2482
  return h('p', { className: 'rb-notice rb-notice-error', role: 'alert', title: message }, text)
2267
2483
  }
2268
2484
 
2269
- function SettingsForm({ view, busy, onClose, onSave, onError, t }) {
2485
+ function SettingsForm({ view, busy, onClose, onSave, onError, extra = null, t }) {
2270
2486
  const [baseBranch, setBaseBranch] = useState(() => String(view?.project?.baseBranch ?? ''))
2271
2487
  const [roadmapPath, setRoadmapPath] = useState(() => String(view?.project?.roadmapPath ?? ''))
2272
2488
  const [verifyCommand, setVerifyCommand] = useState(() => String(view?.project?.verifyCommand ?? ''))
@@ -2333,7 +2549,9 @@ textarea.rb-input{min-height:54px;resize:vertical}
2333
2549
  })),
2334
2550
  h('div', { className: 'rb-row', style: { marginTop: '2px' } },
2335
2551
  h('span', { className: 'rb-grow' }),
2336
- h('button', { type: 'submit', className: 'rb-btn rb-btn-primary', disabled: busy === true }, t('header.settingsSave')))))
2552
+ h('button', { type: 'submit', className: 'rb-btn rb-btn-primary', disabled: busy === true }, t('header.settingsSave')))),
2553
+ // A slot for settings that belong to a feature (M14.5: project agents).
2554
+ extra === null || extra === undefined ? null : h('div', { className: 'rb-settings-extra' }, extra))
2337
2555
  }
2338
2556
 
2339
2557
  /** One event line of a timeline (newest first). */
@@ -3458,63 +3676,6 @@ textarea.rb-input{min-height:54px;resize:vertical}
3458
3676
  return `${String(task?.id ?? '')}\n${String(task?.title ?? '')}`.toLowerCase().includes(needle)
3459
3677
  }
3460
3678
 
3461
- /**
3462
- * Everything the Kanban board renders from one BoardView. Removed tasks
3463
- * (ledger state ROADMAP.md no longer lists) are not on the board. Column
3464
- * `totals`, milestone `chips` and `total` ignore the filters; `columns` and
3465
- * `shown` apply them. `progress` counts done/all tasks of milestones that
3466
- * are not dropped.
3467
- * @param {any} view
3468
- * @param {{ query?: string, hidden?: Iterable<string> }} [filters]
3469
- */
3470
- function kanbanModel(view, { query = '', hidden = [] } = {}) {
3471
- const index = taskIndex(view)
3472
- const hiddenSet = new Set(hidden)
3473
- const needle = String(query ?? '').trim().toLowerCase()
3474
- const columns = Object.fromEntries(KANBAN_COLUMNS.map(id => [id, []]))
3475
- const totals = Object.fromEntries(KANBAN_COLUMNS.map(id => [id, 0]))
3476
- const chips = []
3477
- const cards = new Map()
3478
- let shown = 0
3479
- let total = 0
3480
- const progress = { done: 0, total: 0 }
3481
- // A dropped milestone has no chip; its in-flight tasks (anything not `dropped`) stay as cards.
3482
- validMilestones(view).forEach((milestone, position) => {
3483
- const dropped = milestone.dropped !== null && milestone.dropped !== undefined
3484
- const tasks = (Array.isArray(milestone.tasks) ? milestone.tasks : [])
3485
- .filter(task => task !== null && typeof task === 'object' && typeof task.id === 'string' && task.id !== '')
3486
- .filter(task => !dropped || task.status !== 'dropped')
3487
- const swatch = milestoneSwatch(position)
3488
- if (!dropped) chips.push({
3489
- id: milestone.id, title: String(milestone.title ?? ''), swatch,
3490
- done: tasks.filter(task => task.status === 'done').length, total: tasks.length,
3491
- hidden: hiddenSet.has(milestone.id),
3492
- })
3493
- if (!dropped) {
3494
- progress.total += tasks.length
3495
- progress.done += tasks.filter(task => task.status === 'done').length
3496
- }
3497
- for (const task of tasks) {
3498
- const column = kanbanColumn(task, index)
3499
- totals[column] += 1
3500
- total += 1
3501
- const card = {
3502
- task, column, swatch, milestoneId: milestone.id, milestoneTitle: String(milestone.title ?? ''),
3503
- flags: {
3504
- blocked: task.status === 'blocked',
3505
- waiting: column === 'locked' ? waitingOn(task, index) : [],
3506
- droppedDeps: (Array.isArray(task.depends) ? task.depends : []).filter(id => index.get(id)?.status === 'dropped'),
3507
- },
3508
- }
3509
- cards.set(task.id, card)
3510
- if ((!dropped && hiddenSet.has(milestone.id)) || !matchesQuery(task, needle)) continue
3511
- shown += 1
3512
- columns[column].push(card)
3513
- }
3514
- })
3515
- return { index, columns, totals, chips, cards, shown, total, progress }
3516
- }
3517
-
3518
3679
  /** The project to show: the remembered one while it is still known, else the first. */
3519
3680
  function pickProject(projects, remembered) {
3520
3681
  const list = Array.isArray(projects) ? projects : []
@@ -3574,6 +3735,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
3574
3735
  lock: ['M7 11V7a5 5 0 0 1 10 0v4', 'M5 11h14v10H5z'],
3575
3736
  play: ['M7 4l13 8-13 8z'],
3576
3737
  run: ['M21 12a9 9 0 1 1-3-6.7L21 8', 'M21 3v5h-5'],
3738
+ flag: ['M5 3v18', 'M5 4h13l-2.5 4 2.5 4H5'], chevronDown: ['M6 9l6 6 6-6'],
3577
3739
  eye: ['M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z', 'M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z'],
3578
3740
  check: ['M20 6L9 17l-5-5'],
3579
3741
  msg: ['M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'],
@@ -3735,36 +3897,42 @@ textarea.rb-input{min-height:54px;resize:vertical}
3735
3897
  }
3736
3898
 
3737
3899
  /** One column: tone + glyph + name + count, a hint, and its cards; Done can collapse to a rail. */
3738
- function KanbanColumn({ id, cards, collapsed, onToggle, selectedId, busy, startingId, onOpen, onStart, onChat, compact, t }) {
3900
+ function KanbanColumn({ id, cards, collapsed, onToggle, selectedId, busy, startingId, onOpen, onStart, onChat, compact, t, pilotCards = [], pilotActions, doneGroups, projectId = null }) {
3739
3901
  const name = t(`kanban.column.${id}`)
3740
- const label = t('kanban.columnLabel', { name, count: cards.length })
3902
+ const count = cards.length + pilotCards.length
3903
+ const label = t('kanban.columnLabel', { name, count })
3741
3904
  if (collapsed) {
3742
3905
  return h('section', { className: `rb-kb-col rb-kb-c-${id} rb-kb-collapsed`, 'aria-label': label, 'data-kanban-column': id, tabIndex: compact ? -1 : undefined },
3743
3906
  h('button', {
3744
3907
  type: 'button', className: 'rb-kb-expand', 'aria-expanded': false,
3745
- 'aria-label': t('kanban.doneShow', { count: cards.length }), title: t('kanban.doneShow', { count: cards.length }),
3908
+ 'aria-label': t('kanban.doneShow', { count }), title: t('kanban.doneShow', { count }),
3746
3909
  onClick: onToggle,
3747
3910
  },
3748
3911
  h('span', { className: 'rb-kb-colicon' }, h(Glyph, { name: COLUMN_GLYPH[id] })),
3749
3912
  h('span', null, name),
3750
- h('span', { className: 'rb-kb-count' }, String(cards.length))))
3913
+ h('span', { className: 'rb-kb-count' }, String(count))))
3751
3914
  }
3752
3915
  return h('section', { className: `rb-kb-col rb-kb-c-${id}`, 'aria-label': label, 'data-kanban-column': id, tabIndex: compact ? -1 : undefined },
3753
3916
  h('div', { className: 'rb-kb-colhead' },
3754
3917
  h('span', { className: 'rb-kb-tone', 'aria-hidden': 'true' }),
3755
3918
  h('span', { className: 'rb-kb-colicon' }, h(Glyph, { name: COLUMN_GLYPH[id] })),
3756
3919
  h('h3', { className: 'rb-kb-colname' }, name),
3757
- h('span', { className: 'rb-kb-count' }, String(cards.length)),
3920
+ h('span', { className: 'rb-kb-count' }, String(count)),
3758
3921
  h('span', { className: 'rb-grow' }),
3759
3922
  typeof onToggle === 'function' ? h('button', {
3760
3923
  type: 'button', className: 'rb-btn rb-btn-icon', 'aria-expanded': true,
3761
3924
  'aria-label': t('kanban.doneHide'), title: t('kanban.doneHide'), onClick: onToggle,
3762
3925
  }, h(Glyph, { name: 'x', size: 12 })) : null),
3763
3926
  h('p', { className: 'rb-kb-hint' }, t(`kanban.hint.${id}`)),
3764
- cards.length === 0
3927
+ count === 0
3765
3928
  ? h('p', { className: 'rb-kb-empty' }, t('kanban.empty'))
3766
- : h('ul', { className: 'rb-kb-list' }, cards.map(card => h('li', { key: card.task.id },
3767
- h(KanbanCard, { card, selected: selectedId === card.task.id, busy, startingId, onOpen, onStart, onChat, t })))))
3929
+ : id === 'done'
3930
+ ? h(DoneGroups, { groups: doneGroups ?? doneGroupsOf(cards), projectId, selectedId, cardProps: { busy, startingId, onOpen, onStart, onChat }, t })
3931
+ : h('ul', { className: 'rb-kb-list' },
3932
+ pilotCards.map(card => h('li', { key: `pilot:${card.id}` },
3933
+ h(PilotRunningCard, { card, selectedId, actions: pilotActions, t }))),
3934
+ cards.map(card => h('li', { key: card.task.id },
3935
+ h(KanbanCard, { card, selected: selectedId === card.task.id, busy, startingId, onOpen, onStart, onChat, t })))))
3768
3936
  }
3769
3937
 
3770
3938
  /**
@@ -3836,7 +4004,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
3836
4004
  }
3837
4005
 
3838
4006
  /** Header: project picker, title, base, live status, progress by column, then the toolbar (children). */
3839
- function KanbanHeader({ state, projects, model, onSelectProject, t, children }) {
4007
+ function KanbanHeader({ state, projects, model, onSelectProject, t, lead = null, children }) {
3840
4008
  const view = state.view
3841
4009
  const projectId = state.projectId
3842
4010
  const known = projectId === null || projects.some(project => project.projectId === projectId) ? projects
@@ -3854,6 +4022,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
3854
4022
  onChange: (event) => onSelectProject(String(event.target.value ?? '')),
3855
4023
  }, known.map(project => h('option', { key: project.projectId, value: project.projectId },
3856
4024
  t('header.projectOption', { repo: String(project.repoName ?? ''), id: project.projectId })))),
4025
+ lead,
3857
4026
  h('h2', { className: 'rb-kb-title', title: String(view?.title ?? '') }, String(view?.title ?? t('header.untitled'))),
3858
4027
  view === null ? null : view.project?.roadmapSource === 'db'
3859
4028
  ? h('span', { className: 'rb-mono rb-caption', 'data-roadmap-source': 'db' }, t('roadmapStore.source.db', { version: view.project.roadmapVersion ?? 0 }))
@@ -3942,12 +4111,20 @@ textarea.rb-input{min-height:54px;resize:vertical}
3942
4111
  }
3943
4112
 
3944
4113
  /** Settings popover markup (called, not mounted: SettingsForm owns the state). */
3945
- function kanbanSettingsPopover({ id, popoverRef, view, busy, onClose, onSave, onKeyDown, onBlur, t }) {
4114
+ function kanbanSettingsPopover({ id, popoverRef, view, busy, onClose, onSave, onAgents = null, skillsContent = null, onKeyDown, onBlur, t }) {
3946
4115
  const formKey = `${view?.project?.projectId ?? ''}:${view?.project?.baseBranch ?? ''}:${view?.project?.roadmapPath ?? ''}:${view?.project?.verifyCommand ?? ''}`
3947
4116
  return h('div', {
3948
4117
  id, ref: popoverRef, className: 'rb-kb-pop rb-kb-settings-pop', role: 'dialog', 'aria-label': t('kanban.settings'),
3949
4118
  onKeyDown, onBlur,
3950
- }, h(SettingsForm, { key: formKey, view, busy, onClose, onSave, onError: () => {}, t }))
4119
+ }, h(SettingsForm, {
4120
+ key: formKey, view, busy, onClose, onSave, onError: () => {}, t,
4121
+ extra: h(React.Fragment, null, typeof onAgents !== 'function' ? null : h('div', { className: 'rb-row' },
4122
+ h('div', null,
4123
+ h('div', { className: 'rb-label' }, t('kanban.subagents')),
4124
+ h('p', { className: 'rb-caption', style: { margin: '0' } }, t('settings.agentsHint'))),
4125
+ h('span', { className: 'rb-grow' }),
4126
+ h('button', { type: 'button', className: 'rb-btn', 'data-settings-agents': '', onClick: () => { onClose?.(); onAgents() } }, t('settings.agentsManage'))), skillsContent),
4127
+ }))
3951
4128
  }
3952
4129
 
3953
4130
  /**
@@ -3955,7 +4132,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
3955
4132
  * GET /projects, the last pick is remembered per browser, and each project
3956
4133
  * renders on its own project-keyed store.
3957
4134
  */
3958
- function KanbanPanel({ openSession, t, requestedProject = null, onManualProject, chat }) {
4135
+ function KanbanPanel({ openSession, t, requestedProject = null, requestedPilot = null, onManualProject, chat }) {
3959
4136
  const [projects, setProjects] = useState(null)
3960
4137
  const [loadError, setLoadError] = useState(null)
3961
4138
  const [projectId, setProjectId] = useState(() => requestedProject ?? rememberedProject())
@@ -3996,9 +4173,216 @@ textarea.rb-input{min-height:54px;resize:vertical}
3996
4173
  }
3997
4174
  const store = storeForProject(active)
3998
4175
  return h(KanbanBoard, { key: store.key, store, projects: known, onSelectProject: choose, onRefreshProjects: refresh, openSession, t,
3999
- focusOnMount: requestedProject !== null, chat })
4176
+ focusOnMount: requestedProject !== null && requestedPilot === null, requestedPilot, chat })
4000
4177
  }
4178
+ /* ── Kanban model (M9.1) and its pilot milestone cards ──────────────── */
4001
4179
 
4180
+ /**
4181
+ * Everything the Kanban board renders from one BoardView. Removed tasks
4182
+ * are not on the board. Column `totals`, milestone `chips` and `total`
4183
+ * ignore the filters; `columns` and `shown` apply them. `progress` counts
4184
+ * done/all tasks of milestones that are not dropped.
4185
+ *
4186
+ * An active pilot (docs/superpowers/specs/2026-12-04-pilot-running-card-design.md)
4187
+ * takes its milestone's tasks out of every lane and becomes one entry of
4188
+ * `pilotCards`, listed first in Running and counted there as one. A done
4189
+ * pilot whose teardown kept something stays as a cleanup-only card while
4190
+ * its tasks show in their lanes.
4191
+ * `doneGroups` is `columns.done` grouped by milestone (M16, see doneGroupsOf).
4192
+ * @param {any} view
4193
+ * @param {{ query?: string, hidden?: Iterable<string>, pilotRuns?: any[] }} [filters]
4194
+ */
4195
+ function kanbanModel(view, { query = '', hidden = [], pilotRuns = [] } = {}) {
4196
+ const index = taskIndex(view)
4197
+ const hiddenSet = new Set(hidden)
4198
+ const needle = String(query ?? '').trim().toLowerCase()
4199
+ const columns = Object.fromEntries(KANBAN_COLUMNS.map(id => [id, []]))
4200
+ const totals = Object.fromEntries(KANBAN_COLUMNS.map(id => [id, 0]))
4201
+ const chips = []
4202
+ const cards = new Map()
4203
+ const pilotCards = []
4204
+ let shown = 0
4205
+ let total = 0
4206
+ const progress = { done: 0, total: 0 }
4207
+ // The Host lists runs newest first: the first active run per milestone wins.
4208
+ const activeBy = new Map()
4209
+ const cleanupBy = new Map()
4210
+ for (const pilot of Array.isArray(pilotRuns) ? pilotRuns : []) {
4211
+ if (pilot === null || typeof pilot !== 'object' || typeof pilot.milestoneId !== 'string') continue
4212
+ if (!['done', 'aborted'].includes(pilot.phase)) {
4213
+ if (!activeBy.has(pilot.milestoneId)) activeBy.set(pilot.milestoneId, pilot)
4214
+ } else if (pilotCleanupPending(pilot) && !cleanupBy.has(pilot.milestoneId)) {
4215
+ cleanupBy.set(pilot.milestoneId, pilot)
4216
+ }
4217
+ }
4218
+ // A dropped milestone has no chip; its in-flight tasks (anything not `dropped`) stay as cards.
4219
+ validMilestones(view).forEach((milestone, position) => {
4220
+ const dropped = milestone.dropped !== null && milestone.dropped !== undefined
4221
+ const tasks = (Array.isArray(milestone.tasks) ? milestone.tasks : [])
4222
+ .filter(task => task !== null && typeof task === 'object' && typeof task.id === 'string' && task.id !== '')
4223
+ .filter(task => !dropped || task.status !== 'dropped')
4224
+ const swatch = milestoneSwatch(position)
4225
+ const title = String(milestone.title ?? '')
4226
+ const active = dropped ? undefined : activeBy.get(milestone.id)
4227
+ const pilot = active ?? (dropped ? undefined : cleanupBy.get(milestone.id))
4228
+ const pilotCard = pilot === undefined ? null : {
4229
+ pilot, id: milestone.id, title, swatch, done: 0, total: tasks.length,
4230
+ rows: [], matches: [], provisional: [], current: null, cleanupOnly: active === undefined,
4231
+ }
4232
+ const doneCount = tasks.filter(task => task.status === 'done').length
4233
+ const milestoneHidden = !dropped && hiddenSet.has(milestone.id)
4234
+ if (!dropped) {
4235
+ chips.push({ id: milestone.id, title, swatch, done: doneCount, total: tasks.length, hidden: milestoneHidden })
4236
+ progress.total += tasks.length
4237
+ progress.done += doneCount
4238
+ }
4239
+ for (const task of tasks) {
4240
+ const column = kanbanColumn(task, index)
4241
+ total += 1
4242
+ const card = {
4243
+ task, column, swatch, milestoneId: milestone.id, milestoneTitle: title,
4244
+ flags: {
4245
+ blocked: task.status === 'blocked',
4246
+ waiting: column === 'locked' ? waitingOn(task, index) : [],
4247
+ droppedDeps: (Array.isArray(task.depends) ? task.depends : []).filter(id => index.get(id)?.status === 'dropped'),
4248
+ },
4249
+ }
4250
+ cards.set(task.id, card)
4251
+ const matched = matchesQuery(task, needle)
4252
+ if (active !== undefined) {
4253
+ pilotCard.rows.push(card)
4254
+ if (!milestoneHidden && matched) {
4255
+ shown += 1
4256
+ if (needle !== '') pilotCard.matches.push(task.id)
4257
+ }
4258
+ continue
4259
+ }
4260
+ totals[column] += 1
4261
+ if (milestoneHidden || !matched) continue
4262
+ shown += 1
4263
+ columns[column].push(card)
4264
+ }
4265
+ if (pilotCard === null) return
4266
+ // The pilot marks a task done before the merge writes the roadmap; count either mark.
4267
+ const live = pilot.taskProgress ?? {}
4268
+ const merged = task => task.status === 'done'
4269
+ const unmerged = task => !merged(task) && live[task.id]?.done === true
4270
+ pilotCard.done = tasks.filter(task => merged(task) || unmerged(task)).length
4271
+ pilotCard.provisional = tasks.filter(unmerged).map(task => task.id)
4272
+ pilotCard.current = pilot.phase === 'implementing'
4273
+ ? pilotCard.rows.find(card => !merged(card.task) && !unmerged(card.task)) ?? null
4274
+ : null
4275
+ totals.running += 1
4276
+ if (!milestoneHidden && (pilotCard.cleanupOnly || needle === '' || pilotCard.matches.length > 0)) pilotCards.push(pilotCard)
4277
+ })
4278
+ return { index, columns, totals, chips, cards, shown, total, progress, pilotCards, doneGroups: doneGroupsOf(columns.done, needle) }
4279
+ }
4280
+ /* ── Done column grouped by milestone (M16, docs/features/done-groups.md) ── */
4281
+
4282
+ /** A group's collapsed choice, per project and milestone, in this browser (`'1'` = collapsed). */
4283
+ const DONE_GROUP_KEY = 'dsh-roadmap-board.done-group'
4284
+ /** Natural id order: M3.2 before M3.10. */
4285
+ const compareTaskIds = (a, b) => String(a).localeCompare(String(b), 'en', { numeric: true })
4286
+ /** List ids for aria-controls; a counter, so a full and a compact board never share one. */
4287
+ let doneGroupIds = 0
4288
+
4289
+ /**
4290
+ * The Done column's cards (already filtered, roadmap order) grouped by
4291
+ * milestone. Newest-completed milestone first: the newest `updatedAtOf`
4292
+ * among its tasks (none counts as 0), a tie going to the later milestone.
4293
+ * Tasks inside a group are in id order; `matches` lists the ids a non-empty
4294
+ * search (`needle`, lower case) matched.
4295
+ */
4296
+ function doneGroupsOf(cards, needle = '') {
4297
+ const groups = new Map()
4298
+ for (const card of Array.isArray(cards) ? cards : []) {
4299
+ let group = groups.get(card.milestoneId)
4300
+ if (group === undefined) {
4301
+ group = { id: card.milestoneId, title: card.milestoneTitle, swatch: card.swatch, cards: [], latestAt: 0, matches: [], position: groups.size }
4302
+ groups.set(card.milestoneId, group)
4303
+ }
4304
+ group.cards.push(card)
4305
+ const at = updatedAtOf(card.task)
4306
+ if (typeof at === 'number' && at > group.latestAt) group.latestAt = at
4307
+ if (needle !== '' && matchesQuery(card.task, needle)) group.matches.push(card.task.id)
4308
+ }
4309
+ return [...groups.values()]
4310
+ .sort((a, b) => b.latestAt - a.latestAt || b.position - a.position)
4311
+ .map(({ position, ...group }) => ({
4312
+ ...group, count: group.cards.length,
4313
+ cards: [...group.cards].sort((x, y) => compareTaskIds(x.task.id, y.task.id)),
4314
+ }))
4315
+ }
4316
+
4317
+ function readDoneGroupCollapsed(projectId, milestoneId) {
4318
+ try {
4319
+ return globalThis.localStorage?.getItem(`${DONE_GROUP_KEY}.${projectId ?? ''}.${milestoneId}`) === '1'
4320
+ } catch {
4321
+ return false
4322
+ }
4323
+ }
4324
+
4325
+ function writeDoneGroupCollapsed(projectId, milestoneId, collapsed) {
4326
+ try {
4327
+ globalThis.localStorage?.setItem(`${DONE_GROUP_KEY}.${projectId ?? ''}.${milestoneId}`, collapsed ? '1' : '0')
4328
+ } catch {
4329
+ // Private mode or a full quota: the choice holds for this page only.
4330
+ }
4331
+ }
4332
+
4333
+ /**
4334
+ * The Done column's open state. Collapsed by default; a search that matches
4335
+ * a done task shows it open, and its toggle then closes it for that query only.
4336
+ */
4337
+ function useDoneColumn(query, doneCount) {
4338
+ const [open, setOpen] = useState(false)
4339
+ const [closedFor, setClosedFor] = useState(null)
4340
+ const key = String(query ?? '').trim().toLowerCase()
4341
+ const searching = key !== '' && doneCount > 0
4342
+ return {
4343
+ collapsed: searching ? closedFor === key : !open,
4344
+ toggle: () => (searching ? setClosedFor(closedFor === key ? null : key) : setOpen(value => !value)),
4345
+ }
4346
+ }
4347
+
4348
+ /** One milestone in Done: a header that toggles, then its done cards. */
4349
+ function DoneGroup({ group, projectId, selectedId, cardProps, t }) {
4350
+ const [stored, setStored] = useState(() => readDoneGroupCollapsed(projectId, group.id))
4351
+ // A search opens the group for its matches; closing it then holds only for that same set.
4352
+ const [closedFor, setClosedFor] = useState(null)
4353
+ const [listId] = useState(() => `rb-kb-done-${++doneGroupIds}`)
4354
+ const matchKey = group.matches.join(',')
4355
+ const searching = group.matches.length > 0
4356
+ const open = searching ? closedFor !== matchKey : !stored
4357
+ const toggle = () => {
4358
+ if (searching) {
4359
+ setClosedFor(closedFor === matchKey ? null : matchKey)
4360
+ return
4361
+ }
4362
+ writeDoneGroupCollapsed(projectId, group.id, !stored)
4363
+ setStored(!stored)
4364
+ }
4365
+ const name = t(group.count === 1 ? 'kanban.doneGroup.labelOne' : 'kanban.doneGroup.label', { id: group.id, title: group.title, count: group.count })
4366
+ return h('section', { className: `rb-kb-done-group ${group.swatch}`, 'data-done-group': group.id, 'aria-label': name },
4367
+ h('button', {
4368
+ type: 'button', className: 'rb-kb-done-head', 'aria-expanded': open, 'aria-controls': open ? listId : undefined,
4369
+ 'aria-label': name, title: t('kanban.doneGroup.toggle', { id: group.id }), onClick: toggle,
4370
+ },
4371
+ h(Glyph, { name: open ? 'chevronDown' : 'chevron', size: 12 }),
4372
+ h('span', { className: 'rb-kb-tag' }, group.id),
4373
+ h('span', { className: 'rb-kb-done-title', title: group.title }, group.title),
4374
+ h('span', { className: 'rb-kb-count' }, String(group.count))),
4375
+ !open ? null : h('ul', { id: listId, className: 'rb-kb-list rb-kb-done-list' }, group.cards.map(card => h('li', {
4376
+ key: card.task.id, className: group.matches.includes(card.task.id) ? 'rb-kb-done-match' : undefined,
4377
+ }, h(KanbanCard, { ...cardProps, card, selected: selectedId === card.task.id, t })))))
4378
+ }
4379
+
4380
+ /** The open Done column's body: one group per milestone. */
4381
+ function DoneGroups({ groups, projectId, selectedId, cardProps, t }) {
4382
+ return h('div', { className: 'rb-kb-done-groups' }, groups.map(group => h(DoneGroup, {
4383
+ key: `${projectId ?? ''}:${group.id}`, group, projectId, selectedId, cardProps, t,
4384
+ })))
4385
+ }
4002
4386
  /* ── retained chat target (shared by task chat and Master) ── */
4003
4387
 
4004
4388
  /** Reference-source label for `ctx.sessions.retain` (a free-form consumer id). */
@@ -4390,7 +4774,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
4390
4774
 
4391
4775
 
4392
4776
  function KanbanBoard({ store, projects, onSelectProject, onRefreshProjects, openSession, t,
4393
- compact = false, onOpenFull, sessionStore, sessionId, focusOnMount = false, chat }) {
4777
+ compact = false, onOpenFull, requestedPilot = null, sessionStore, sessionId, focusOnMount = false, chat }) {
4394
4778
  const state = useBoard(store)
4395
4779
  const projectId = state.projectId
4396
4780
  const view = state.view
@@ -4401,12 +4785,36 @@ textarea.rb-input{min-height:54px;resize:vertical}
4401
4785
  const [now, setNow] = useState(() => Date.now())
4402
4786
  const [capabilities, setCapabilities] = useState(() => CAPABILITIES ?? { start: false })
4403
4787
  const [startingId, setStartingId] = useState(null)
4404
- // The pilot panel reads its own state, so it mounts only once opened,
4405
- // like the Master pane; a plain board render stays request-free.
4406
- const [pilotOpen, setPilotOpen] = useState(false)
4788
+ const pilotData = usePilots(viewProject)
4789
+ const [pilotPanel, setPilotPanel] = useState(() => requestedPilot === null ? null : { projectId, selectedPilotId: requestedPilot.id ?? null, openStart: false })
4790
+ const handledPilotRequest = useRef(null)
4791
+ const pilotOpen = pilotPanel !== null && pilotPanel.projectId === projectId
4792
+ const waitingPilots = pilotData.pilots.filter(pilotNeedsAttention)
4793
+ const pilotAttention = waitingPilots.length
4794
+ const pilotButtonRef = useRef(null)
4795
+ const showPilot = (selectedPilotId = null, openStart = false) => {
4796
+ // One side pane at a time: the task drawer, inbox and chat are absolute
4797
+ // panes and would otherwise sit over the pilot drawer.
4798
+ setSelectedId(null)
4799
+ setFeedback(null)
4800
+ setMilestoneInbox(null)
4801
+ if (chatReturn.current !== null) {
4802
+ chatReturn.current.focus = false
4803
+ setChatId(null)
4804
+ }
4805
+ setPilotPanel({ projectId, selectedPilotId, openStart })
4806
+ }
4807
+ const closePilot = () => { setPilotPanel(null); pilotButtonRef.current?.focus?.() }
4808
+ // The full board resolves its project a beat after mounting; honour the
4809
+ // attention jump once the project is known, and once per request.
4810
+ useEffect(() => {
4811
+ if (requestedPilot === null || projectId === null) return
4812
+ if (handledPilotRequest.current === requestedPilot.nonce) return
4813
+ handledPilotRequest.current = requestedPilot.nonce
4814
+ setPilotPanel({ projectId, selectedPilotId: requestedPilot.id ?? null, openStart: false })
4815
+ }, [requestedPilot, projectId])
4407
4816
  const [query, setQuery] = useState('')
4408
4817
  const [hidden, setHidden] = useState([])
4409
- const [doneOpen, setDoneOpen] = useState(false)
4410
4818
  const [selectedId, setSelectedId] = useState(null)
4411
4819
  // Give feedback from the drawer: `{ taskId, milestoneId, nonce }` opens that milestone's capture form.
4412
4820
  const [feedback, setFeedback] = useState(null)
@@ -4484,7 +4892,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
4484
4892
  setAgentsProjectId(null)
4485
4893
  agentsDirty.current = false
4486
4894
  setAgentsBlocked(false)
4487
- agentsButtonRef.current?.focus?.()
4895
+ settingsButtonRef.current?.focus?.()
4488
4896
  }, [projectId, agentsOpen, agentsProjectId])
4489
4897
  /** Close unless an agent form is open; then say why and keep it. */
4490
4898
  const closeAgents = () => {
@@ -4640,7 +5048,9 @@ textarea.rb-input{min-height:54px;resize:vertical}
4640
5048
  const drawer = root?.querySelector?.('[data-kanban-drawer]')
4641
5049
  if (active !== null && active !== undefined && active !== globalThis.document?.body && active.isConnected !== false
4642
5050
  && !(drawer?.contains?.(active) ?? false)) return
4643
- const card = [...(root?.querySelectorAll?.('[data-kanban-task]') ?? [])].find(element => element.getAttribute('data-kanban-task') === id)
5051
+ // A card inside a collapsed column or a closed pilot card is hidden; focus its opener instead.
5052
+ const card = [...(root?.querySelectorAll?.('[data-kanban-task]') ?? [])]
5053
+ .find(element => element.getAttribute('data-kanban-task') === id && element.getClientRects?.().length > 0)
4644
5054
  const target = card ?? (opener?.isConnected === true && opener !== globalThis.document?.body ? opener : root)
4645
5055
  target?.focus?.()
4646
5056
  } catch {
@@ -4648,7 +5058,9 @@ textarea.rb-input{min-height:54px;resize:vertical}
4648
5058
  }
4649
5059
  }, [selectedId])
4650
5060
 
4651
- const model = kanbanModel(view, { query, hidden })
5061
+ const model = kanbanModel(view, { query, hidden, pilotRuns: pilotData.pilots })
5062
+ const done = useDoneColumn(query, model.columns.done.length)
5063
+ const pilotActions = usePilotCardActions({ pilots: pilotData.pilots, compact, projectId, onOpenFull, showPilot, openSession, openTask: open, refresh: pilotData.refresh, setNotice, setActionError, t })
4652
5064
  const selected = selectedId === null ? undefined : model.cards.get(selectedId)
4653
5065
  // A task that left the roadmap closes its drawer for good (it does not pop back if it returns).
4654
5066
  const selectionGone = selectedId !== null && view !== null && selected === undefined
@@ -4711,7 +5123,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
4711
5123
  setAgentsProjectId(null)
4712
5124
  agentsDirty.current = false
4713
5125
  setAgentsBlocked(false)
4714
- agentsButtonRef.current?.focus?.()
5126
+ settingsButtonRef.current?.focus?.()
4715
5127
  },
4716
5128
  },
4717
5129
  h('div', { className: 'rb-kb-drawerhead' },
@@ -4770,7 +5182,11 @@ textarea.rb-input{min-height:54px;resize:vertical}
4770
5182
  }
4771
5183
  const onSettingsBlur = popoverBlurHandler(settingsPopRef, settingsButtonRef, () => setSettingsProjectId(null))
4772
5184
  const feedbackCounts = projectId === null ? undefined : FEEDBACK_COUNTS.get(projectId)
5185
+ const pilotTrigger = projectId === null ? null : PilotToolbar({
5186
+ compact, pilotOpen, pilotStartOpen: pilotPanel?.openStart === true, pilotAttention, pilotButtonRef, showPilot, closePilot, onOpenFull, projectId, t,
5187
+ })
4773
5188
  const tools = h('div', { className: 'rb-kb-tools' },
5189
+ compact ? null : h(RoadmapCreateTools, { store, projectId, view, t, fallbackRequest: onboarding.editorRequest }),
4774
5190
  view === null ? null : h('button', {
4775
5191
  type: 'button', ref: searchButtonRef, className: `rb-btn rb-kb-tool${searchVisible ? ' rb-kb-tool-active' : ''}`,
4776
5192
  'aria-label': t('kanban.search'), title: t('kanban.search'), 'aria-expanded': searchVisible,
@@ -4813,20 +5229,15 @@ textarea.rb-input{min-height:54px;resize:vertical}
4813
5229
  !settingsOpen ? null : kanbanSettingsPopover({
4814
5230
  id: toolIds.settings, popoverRef: settingsPopRef, view, busy,
4815
5231
  onClose: () => closeSettings(true),
4816
- onSave: patch => perform(() => saveSettings(store, projectId, patch)),
5232
+ onSave: patch => perform(() => saveSettings(store, projectId, patch)),
5233
+ onAgents: () => setAgentsProjectId(projectId),
5234
+ skillsContent: h(PilotSkillsSettings, {
5235
+ projectId, skills: pilotData.skills, refresh: pilotData.refresh, store, busy,
5236
+ configVersion: view?.project?.configVersion ?? 1, loadError: pilotData.skillsError, onRetry: pilotData.refresh,
5237
+ roundCap: view?.project?.pilotConfig?.maxGoalRounds ?? null, t,
5238
+ }),
4817
5239
  onKeyDown: onSettingsKey, onBlur: onSettingsBlur, t,
4818
5240
  }),
4819
- compact ? null : h('button', {
4820
- type: 'button', ref: agentsButtonRef, className: 'rb-btn rb-kb-tool', disabled: projectId === null,
4821
- 'aria-label': t('kanban.subagents'), title: t('kanban.subagents'), 'aria-haspopup': 'dialog',
4822
- onClick: () => setAgentsProjectId(projectId),
4823
- }, h(Glyph, { name: 'agents', size: 16 })),
4824
- compact ? null : h(RoadmapCreateTools, { store, projectId, view, t, fallbackRequest: onboarding.editorRequest }),
4825
- h('button', {
4826
- type: 'button', className: `rb-btn rb-kb-tool${pilotOpen ? ' rb-kb-tool-active' : ''}`, disabled: projectId === null,
4827
- 'aria-label': t('pilot.open'), title: t('pilot.open'), 'aria-pressed': pilotOpen, 'data-pilot-tool': '',
4828
- onClick: () => setPilotOpen(value => !value),
4829
- }, h(Glyph, { name: 'run', size: 16 })),
4830
5241
  h('button', { type: 'button', className: `rb-btn rb-kb-tool${masterOpen ? ' rb-kb-tool-active' : ''}`, disabled: projectId === null,
4831
5242
  'aria-label': t('master.open'), title: t('master.open'), 'aria-pressed': masterOpen, onClick: () => openChat(MASTER_CHAT) }, h(Glyph, { name: 'chat', size: 16 })),
4832
5243
  compact ? h('button', {
@@ -4838,7 +5249,7 @@ textarea.rb-input{min-height:54px;resize:vertical}
4838
5249
  },
4839
5250
  }, h(Glyph, { name: 'expand', size: 16 })) : null)
4840
5251
  const header = h('header', { className: 'rb-kb-head' },
4841
- h(KanbanHeader, { state, projects, model, onSelectProject, t }, tools),
5252
+ h(KanbanHeader, { state, projects, model, onSelectProject, t, lead: pilotTrigger }, tools),
4842
5253
  view === null || (!searchVisible && !filtered) ? null : h('div', { className: 'rb-kb-filters' },
4843
5254
  !searchVisible ? null : h('label', { className: 'rb-kb-search', id: toolIds.search },
4844
5255
  h(Glyph, { name: 'search', size: 14 }),
@@ -4862,6 +5273,8 @@ textarea.rb-input{min-height:54px;resize:vertical}
4862
5273
  !filtered ? null : h('span', { className: 'rb-row' },
4863
5274
  h('span', { className: 'rb-caption', role: 'status' }, t('kanban.filtered', { shown: model.shown, total: model.total })),
4864
5275
  clearButton())),
5276
+ PilotAttention({ pilots: waitingPilots, error: pilotData.error, onRetry: pilotData.refresh,
5277
+ onOpen: compact ? id => onOpenFull?.(projectId, id) : showPilot, t }),
4865
5278
  view === null ? null : h(KanbanAttention, { model, onOpen: open, onChat: openChat, t }))
4866
5279
 
4867
5280
  const rootProps = { className: `${compact ? 'rb-kb rb-kb-compact' : 'rb-kb'}${chatOpen ? ' rb-kb-chatopen' : ''}`, ref: rootRef, tabIndex: -1,
@@ -4883,6 +5296,31 @@ textarea.rb-input{min-height:54px;resize:vertical}
4883
5296
  : h('p', { className: 'rb-notice', role: 'status' }, t('loading'))))
4884
5297
  }
4885
5298
 
5299
+ // Columns and the milestone jumps, so the pilot drawer can sit beside them.
5300
+ const mainContent = h('div', { className: 'rb-kb-mainboard' },
5301
+ !compact || model.chips.length + model.total === 0 || noResults ? null : h('div', { className: 'rb-kb-jumps', role: 'group', 'aria-label': t('kanban.jumpColumns') },
5302
+ KANBAN_COLUMNS.map(id => {
5303
+ const name = t(`kanban.column.${id}`)
5304
+ const count = model.columns[id].length + (id === 'running' ? model.pilotCards.length : 0)
5305
+ return h('button', {
5306
+ key: id, type: 'button', className: `rb-btn rb-kb-jump rb-kb-c-${id}`, 'data-kanban-jump': id,
5307
+ 'aria-label': t('kanban.columnLabel', { name, count }), onClick: () => jumpToColumn(scrollerRef.current, id),
5308
+ }, h(Glyph, { name: COLUMN_GLYPH[id], size: 12 }), h('span', null, name), h('span', { className: 'rb-kb-count' }, count))
5309
+ })),
5310
+ model.chips.length + model.total === 0
5311
+ ? h(BlankBoard, { ...onboarding, t })
5312
+ : noResults
5313
+ ? h('p', { className: 'rb-notice rb-kb-notice rb-kb-noresults' }, h('span', null, t('kanban.noResults')), clearButton())
5314
+ : h('div', { className: 'rb-kb-board', ref: scrollerRef }, KANBAN_COLUMNS.map(id => h(KanbanColumn, {
5315
+ key: id, id, cards: model.columns[id], t, busy, startingId, selectedId, compact,
5316
+ pilotCards: id === 'running' ? model.pilotCards : [], pilotActions, doneGroups: model.doneGroups, projectId,
5317
+ collapsed: id === 'done' && done.collapsed,
5318
+ onToggle: id === 'done' ? done.toggle : undefined,
5319
+ onOpen: open,
5320
+ onStart: typeof handlers.start === 'function' ? handlers.start : undefined,
5321
+ onChat: openChat,
5322
+ }))),
5323
+ )
4886
5324
  const inboxMilestone = activeInboxId === null ? undefined : validMilestones(view).find(item => item.id === activeInboxId)
4887
5325
  const inboxChip = activeInboxId === null ? undefined : model.chips.find(chip => chip.id === activeInboxId)
4888
5326
  // The full board reserves its header beside an open drawer (see .rb-kb-draweropen).
@@ -4895,28 +5333,18 @@ textarea.rb-input{min-height:54px;resize:vertical}
4895
5333
  state.reconnectDelayMs === null ? t('connection.reconnecting')
4896
5334
  : `${t('connection.reconnecting')} ${Math.round(state.reconnectDelayMs / 1000)}s`),
4897
5335
  h(ErrorsBlock, { errors: onboarding.errors, t }),
4898
- pilotOpen && projectId !== null ? h(PilotBoardSection, { view, projectId, store, compact, t }) : null,
4899
- !compact || model.chips.length + model.total === 0 || noResults ? null : h('div', { className: 'rb-kb-jumps', role: 'group', 'aria-label': t('kanban.jumpColumns') },
4900
- KANBAN_COLUMNS.map(id => {
4901
- const name = t(`kanban.column.${id}`)
4902
- const count = model.columns[id].length
4903
- return h('button', {
4904
- key: id, type: 'button', className: `rb-btn rb-kb-jump rb-kb-c-${id}`, 'data-kanban-jump': id,
4905
- 'aria-label': t('kanban.columnLabel', { name, count }), onClick: () => jumpToColumn(scrollerRef.current, id),
4906
- }, h(Glyph, { name: COLUMN_GLYPH[id], size: 12 }), h('span', null, name), h('span', { className: 'rb-kb-count' }, count))
4907
- })),
4908
- model.chips.length + model.total === 0
4909
- ? h(BlankBoard, { ...onboarding, t })
4910
- : noResults
4911
- ? h('p', { className: 'rb-notice rb-kb-notice rb-kb-noresults' }, h('span', null, t('kanban.noResults')), clearButton())
4912
- : h('div', { className: 'rb-kb-board', ref: scrollerRef }, KANBAN_COLUMNS.map(id => h(KanbanColumn, {
4913
- key: id, id, cards: model.columns[id], t, busy, startingId, selectedId, compact,
4914
- collapsed: id === 'done' && !doneOpen,
4915
- onToggle: id === 'done' ? () => setDoneOpen(value => !value) : undefined,
4916
- onOpen: open,
4917
- onStart: typeof handlers.start === 'function' ? handlers.start : undefined,
4918
- onChat: openChat,
4919
- }))),
5336
+ // One wrapper for both states: remounting mainContent would reset a collapsed
5337
+ // pilot group and the columns' scroll whenever the pilot drawer opens or closes.
5338
+ h('div', { className: pilotOpen && projectId !== null ? 'rb-kb-pilotwrap' : 'rb-kb-nowrap' },
5339
+ mainContent,
5340
+ pilotOpen && projectId !== null ? h(PilotBoardSection, {
5341
+ key: projectId, view, projectId, store, compact, t, openChat, openSession, pilotData,
5342
+ selectedPilotId: pilotPanel.selectedPilotId, onSelectPilot: showPilot,
5343
+ onOpenStart: () => showPilot(pilotPanel.selectedPilotId, true),
5344
+ openStart: pilotPanel.openStart, onCloseStart: () => showPilot(pilotPanel.selectedPilotId),
5345
+ onOpenSettings: () => { setSettingsProjectId(projectId); settingsButtonRef.current?.focus?.() },
5346
+ onClose: closePilot,
5347
+ }) : null),
4920
5348
  h(DroppedGroup, { milestones: droppedMilestones(view), t }),
4921
5349
  selected === undefined || chatOpen ? null : h(KanbanDrawer, {
4922
5350
  key: `drawer:${selected.task.id}`, card: selected, model, view, projectId, now, busy, handlers, t,
@@ -5702,18 +6130,206 @@ textarea.rb-input{min-height:54px;resize:vertical}
5702
6130
  const reports = qa === undefined ? [] : qaReportsOf(qa.state.list, task.id)
5703
6131
  return reports.length === 0 ? [] : [h(QaSection, { key: 'qa', reports, state: qa.state, controls: qa.controls, t })]
5704
6132
  }
6133
+ function PilotToolbar({ compact, pilotOpen, pilotStartOpen, pilotAttention, pilotButtonRef, showPilot, closePilot, onOpenFull, projectId, t }) {
6134
+ const name = pilotAttention ? pilotTriggerName(pilotAttention, t) : t('pilot.button')
6135
+ return h('div', { className: 'rb-pilot-trigger' },
6136
+ h('button', {
6137
+ type: 'button', ref: pilotButtonRef, className: 'rb-btn rb-btn-primary rb-kb-pilotbtn',
6138
+ 'aria-label': name, title: name,
6139
+ 'aria-expanded': compact ? undefined : pilotOpen, 'data-pilot-tool': '',
6140
+ 'aria-controls': compact || !pilotOpen ? undefined : `pilot-panel-${projectId}`,
6141
+ onClick: () => compact ? onOpenFull(projectId, '') : pilotOpen ? closePilot() : showPilot(),
6142
+ }, h(Glyph, { name: 'flag', size: 14 }), t('pilot.button'),
6143
+ pilotAttention ? h('span', { className: 'rb-kb-badge', 'aria-hidden': 'true' }, String(pilotAttention)) : null),
6144
+ !compact ? h('button', {
6145
+ type: 'button', className: 'rb-btn rb-btn-primary rb-kb-pilotbtn rb-pilot-options', 'aria-label': t('pilot.options'),
6146
+ title: t('pilot.options'), 'aria-haspopup': 'dialog', 'aria-expanded': Boolean(pilotStartOpen),
6147
+ 'aria-controls': pilotStartOpen ? 'pilot-start-dialog' : undefined,
6148
+ onClick: () => showPilot(null, true),
6149
+ }, h(Glyph, { name: 'chevronDown', size: 14 })) : null)
6150
+ }
6151
+
6152
+ function PilotAttention({ pilots, onOpen, error = null, onRetry = null, t }) {
6153
+ if (pilots.length === 0 && error === null) return null
6154
+ return h('div', { 'aria-live': 'polite' }, h('section', { className: 'rb-pilot-attention' },
6155
+ h('h3', null, pilots.length === 0 ? t('pilot.attentionUnavailable') : pilotAttentionTitle(pilots.length, t)),
6156
+ pilots.map(pilot => {
6157
+ const gate = PILOT_GATE_STEPS.includes(pilot.phase)
6158
+ const action = pilot.phase === 'asking' ? t('pilot.attentionAnswer') : gate ? t('pilot.attentionOpen') : t('pilot.attentionOpenPilot')
6159
+ return h('div', { key: pilot.id, className: 'rb-pilot-attention-row' },
6160
+ h('code', null, pilot.milestoneId), h('strong', null, pilot.milestoneTitle),
6161
+ h('span', { className: 'rb-pilot-attention-why' }, `· ${pilotAttentionWhy(pilot, t)}`),
6162
+ h('button', { type: 'button', className: 'rb-btn rb-btn-link', 'aria-label': t('pilot.attentionAction', { action, id: pilot.milestoneId }), onClick: () => onOpen(pilot.id) },
6163
+ action))
6164
+ }),
6165
+ pilots.length === 0 && typeof onRetry === 'function'
6166
+ ? h('button', { type: 'button', className: 'rb-btn rb-btn-link', onClick: () => onRetry() }, t('retry'))
6167
+ : null))
6168
+ }
6169
+
6170
+ /** What the pilot asks of the human, worded as in the mockup. */
6171
+ function pilotAttentionWhy(pilot, t) {
6172
+ if (pilot.phase === 'asking' && pilot.pendingQuestion?.question) {
6173
+ const question = String(pilot.pendingQuestion.question).replace(/\s+/g, ' ').trim()
6174
+ return t('pilot.attentionQuestion', { question: question.length > 80 ? `${question.slice(0, 79)}…` : question })
6175
+ }
6176
+ const revision = Array.isArray(pilot.revisions) ? pilot.revisions.at(-1)?.number : undefined
6177
+ if (pilot.phase === 'awaiting_approval' && Number.isInteger(revision)) return t('pilot.attentionPlan', { number: revision })
6178
+ if (pilot.phase === 'awaiting_review') return t('pilot.attentionReview')
6179
+ if (PILOT_GATE_STEPS.includes(pilot.phase)) return pilotStepLabel(pilot.phase, t)
6180
+ return pilot.phase === 'blocked' ? t('pilot.phase.blocked') : t('pilot.disarmedShort')
6181
+ }
6182
+ function PilotCopyFact({ value, label, t }) {
6183
+ const [status, setStatus] = useState(null)
6184
+ const text = String(value ?? '')
6185
+ const copy = async () => {
6186
+ try {
6187
+ await globalThis.navigator.clipboard.writeText(text)
6188
+ setStatus({ text, key: 'pilot.copied' })
6189
+ } catch {
6190
+ setStatus({ text, key: 'pilot.copyFailed' })
6191
+ }
6192
+ }
6193
+ return h('div', { className: 'rb-pilot-fact' },
6194
+ h('span', { className: 'rb-pilot-trunc', title: text }, text),
6195
+ text === '' ? null : h('button', { type: 'button', className: 'rb-btn rb-btn-ghost', 'aria-label': t('pilot.copyFact', { label: String(label).toLowerCase() }), onClick: copy }, t('pilot.copy')),
6196
+ h('span', { className: 'rb-caption', role: 'status' }, status?.text === text ? t(status.key) : ''))
6197
+ }
6198
+
6199
+ function pilotFooter(actions, footer) {
6200
+ return footer != null && typeof createPortal === 'function' ? createPortal(actions, footer) : actions
6201
+ }
6202
+
6203
+ /** The roster the pilot may delegate to: "none configured", "N ready", or unknown. */
6204
+ function PilotAgentsLine({ roster, onOpenSettings, t }) {
6205
+ const ready = Number.isInteger(roster?.ready) ? roster.ready : null
6206
+ const text = ready === null ? t('pilot.agents') : ready === 0 ? t('pilot.agentsNone') : t('pilot.agentsReady', { count: ready })
6207
+ return h('div', { className: 'rb-pilot-agents', 'data-pilot-agents': ready === null ? '' : String(ready) },
6208
+ ready === null ? null : h('span', { className: `rb-pilot-dot rb-pilot-dot-${ready === 0 ? 'warn' : 'ok'}`, 'aria-hidden': 'true' }),
6209
+ h('span', null, text),
6210
+ typeof onOpenSettings === 'function' ? h('button', {
6211
+ type: 'button', className: 'rb-btn rb-btn-link', 'aria-label': t('kanban.settings'), onClick: onOpenSettings,
6212
+ }, t('pilot.skills.settings')) : null)
6213
+ }
6214
+ /**
6215
+ * Myers' O(ND) line diff. A set comparison reports a reordered line as a
6216
+ * removal, and a two-ended trim reports repeated lines at the wrong place;
6217
+ * this keeps the real longest common subsequence, so both are accurate.
6218
+ *
6219
+ * Each step keeps only the diagonals its backtrack reads (2d+3 cells, so
6220
+ * about D² in total, not D·(N+M)), and the whole trace is capped: past
6221
+ * {@link PILOT_DIFF_BUDGET} cells the answer is `null` ("too large to diff
6222
+ * here") rather than a memory spike on the board's main thread.
6223
+ */
6224
+ const PILOT_DIFF_BUDGET = 4_000_000 // Int32 cells: at most 16 MB, and an edit distance of about 2,000 lines
6225
+ function pilotDiffOps(before, after) {
6226
+ const n = before.length
6227
+ const m = after.length
6228
+ const max = n + m
6229
+ if (max === 0) return []
6230
+ const offset = max + 1
6231
+ const v = new Int32Array(2 * max + 3).fill(-1)
6232
+ v[offset + 1] = 0
6233
+ const trace = []
6234
+ let stored = 0
6235
+ for (let d = 0; d <= max; d += 1) {
6236
+ stored += 2 * d + 3
6237
+ if (stored > PILOT_DIFF_BUDGET) return null
6238
+ // Diagonals -(d+1)..d+1: everything the backtrack of step d reads.
6239
+ trace.push(v.slice(offset - d - 1, offset + d + 2))
6240
+ for (let k = -d; k <= d; k += 2) {
6241
+ const down = k === -d || (k !== d && v[offset + k - 1] < v[offset + k + 1])
6242
+ let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1
6243
+ let y = x - k
6244
+ while (x < n && y < m && before[x] === after[y]) { x += 1; y += 1 }
6245
+ v[offset + k] = x
6246
+ if (x >= n && y >= m) return pilotDiffBacktrack(trace, before, after, d)
6247
+ }
6248
+ }
6249
+ return []
6250
+ }
6251
+
6252
+ function pilotDiffBacktrack(trace, before, after, distance) {
6253
+ const ops = []
6254
+ let x = before.length
6255
+ let y = after.length
6256
+ for (let d = distance; d >= 0; d -= 1) {
6257
+ const row = trace[d]
6258
+ const at = k => row[k + d + 1]
6259
+ const k = x - y
6260
+ const down = k === -d || (k !== d && at(k - 1) < at(k + 1))
6261
+ const previousK = down ? k + 1 : k - 1
6262
+ const previousX = at(previousK)
6263
+ const previousY = previousX - previousK
6264
+ while (x > previousX && y > previousY) {
6265
+ ops.push({ kind: 'context', text: before[x - 1] })
6266
+ x -= 1
6267
+ y -= 1
6268
+ }
6269
+ if (d === 0) break
6270
+ if (x === previousX) { ops.push({ kind: 'add', text: after[y - 1] }); y -= 1 }
6271
+ else { ops.push({ kind: 'del', text: before[x - 1] }); x -= 1 }
6272
+ }
6273
+ return ops.reverse()
6274
+ }
6275
+
6276
+ /** Emit unified hunks with two context lines, merging overlapping context. */
6277
+ function pilotDiffHunks(before, after, oldOffset = 0, newOffset = 0) {
6278
+ const lines = pilotDiffOps(before, after)
6279
+ if (lines === null) return null
6280
+ const spans = []
6281
+ for (let i = 0; i < lines.length; i += 1) {
6282
+ if (lines[i].kind === 'context') continue
6283
+ const start = Math.max(0, i - 2)
6284
+ const end = Math.min(lines.length, i + 3)
6285
+ const previous = spans.at(-1)
6286
+ if (previous && start <= previous.end) previous.end = end
6287
+ else spans.push({ start, end })
6288
+ }
6289
+ let oldPosition = 0
6290
+ let newPosition = 0
6291
+ let cursor = 0
6292
+ return spans.map(({ start, end }) => {
6293
+ while (cursor < start) {
6294
+ if (lines[cursor].kind !== 'add') oldPosition += 1
6295
+ if (lines[cursor].kind !== 'del') newPosition += 1
6296
+ cursor += 1
6297
+ }
6298
+ const hunk = lines.slice(start, end)
6299
+ const oldCount = hunk.reduce((count, line) => count + Number(line.kind !== 'add'), 0)
6300
+ const newCount = hunk.reduce((count, line) => count + Number(line.kind !== 'del'), 0)
6301
+ const header = `@@ -${oldOffset + oldPosition + Number(oldCount > 0)},${oldCount} +${newOffset + newPosition + Number(newCount > 0)},${newCount} @@`
6302
+ oldPosition += oldCount
6303
+ newPosition += newCount
6304
+ cursor = end
6305
+ return { header, lines: hunk }
6306
+ })
6307
+ }
5705
6308
  /* ── milestone pilot (M14.5; docs/features/pilot.md) ──────────────────── */
5706
6309
 
5707
- /** Which milestone step needs the human, and the card it shows. */
6310
+ /** Which milestone steps need a human decision. */
5708
6311
  const PILOT_GATE_STEPS = ['asking', 'awaiting_approval', 'awaiting_review']
6312
+ /** Gates plus a pilot that stopped and needs a human to restart or unblock it. */
6313
+ const pilotNeedsAttention = pilot => !['done', 'aborted'].includes(pilot.phase)
6314
+ && (PILOT_GATE_STEPS.includes(pilot.phase) || pilot.phase === 'blocked' || pilot.goalDisarmed === true)
6315
+ /** Steps where the pilot works on its own, so Pause is the meaningful control. */
6316
+ const PILOT_AGENT_STEPS = ['spec', 'planning', 'implementing', 'local_review', 'qa', 'merging']
6317
+
6318
+ /** Steps whose drawer has no footer. */
6319
+ const PILOT_FOOTLESS_STEPS = ['done', 'aborted', 'merging']
6320
+
6321
+ const PILOT_GATE_PLAN = 'plan'
6322
+ const PILOT_GATE_REVIEW = 'review'
5709
6323
 
5710
6324
  /** `pilot/<milestone-id>-<slug>`, as the Host names the branch (model.mjs). */
5711
6325
  function pilotBranchName(milestoneId, title) {
5712
- const slug = String(title ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40).replace(/-+$/g, '')
6326
+ // Same rule as the Host (src/features/pilot/model.mjs): one 80-character
6327
+ // cap, so a long title promises exactly the branch that will be created.
6328
+ const slug = String(title ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 80).replace(/^-|-$/g, '')
5713
6329
  return `pilot/${String(milestoneId ?? '').toLowerCase()}-${slug}`
5714
6330
  }
5715
6331
 
5716
- /** A milestone a pilot could take: not dropped, with work left. */
6332
+ /** A milestone a pilot could take: not dropped, with work left, not already piloted. */
5717
6333
  function pilotableMilestone(milestone, pilots) {
5718
6334
  if (milestone === null || typeof milestone !== 'object') return false
5719
6335
  if (milestone.dropped !== null && milestone.dropped !== undefined) return false
@@ -5740,36 +6356,71 @@ textarea.rb-input{min-height:54px;resize:vertical}
5740
6356
  /**
5741
6357
  * The project's pilots and Superpowers status. Read after every change and
5742
6358
  * whenever the board view moves, so another tab's pilot appears here too.
6359
+ * Read on mount and on a slow timer: an idle board stays request-free
6360
+ * between polls, while another tab's gate or an agent tool still arrives.
5743
6361
  */
5744
- function usePilots(projectId, view) {
5745
- const [state, setState] = useState({ pilots: [], skills: null, error: null, loading: true })
6362
+ function usePilots(projectId) {
6363
+ const [state, setState] = useState(null)
5746
6364
  const [attempt, setAttempt] = useState(0)
5747
- const refreshKey = `${projectId ?? ''}:${view?.updatedAt ?? ''}:${view?.project?.configVersion ?? ''}:${attempt}`
5748
6365
  useEffect(() => {
5749
6366
  if (projectId === null || projectId === undefined) return undefined
5750
6367
  let cancelled = false
5751
- Promise.all([
5752
- pilotRequests.list(projectId).catch(error => ({ pilots: [], error })),
5753
- pilotRequests.skills(projectId).catch(error => ({ skills: null, error })),
5754
- ]).then(([listed, skills]) => {
5755
- if (cancelled) return
5756
- setState({
5757
- pilots: Array.isArray(listed?.pilots) ? listed.pilots : [],
5758
- skills: skills?.skills ?? null,
5759
- error: listed?.error ?? skills?.error ?? null,
6368
+ let timer = null
6369
+ // Only the newest read schedules the next one: a visibility read that
6370
+ // overlaps a poll must not start a second timer chain.
6371
+ let latest = 0
6372
+ const load = async () => {
6373
+ const mine = ++latest
6374
+ const [listed, skills] = await Promise.all([
6375
+ pilotRequests.list(projectId).catch(error => ({ pilots: [], error })),
6376
+ pilotRequests.skills(projectId).catch(error => ({ skills: null, error })),
6377
+ ])
6378
+ if (cancelled || mine !== latest) return
6379
+ // A failed read keeps the last good list: it decides where tickets show,
6380
+ // and emptying it would move an active pilot's tickets back into the lanes.
6381
+ const pilots = Array.isArray(listed?.pilots) ? listed.pilots : null
6382
+ setState(previous => ({
6383
+ projectId,
6384
+ pilots: pilots ?? (previous?.projectId === projectId ? previous.pilots : []),
6385
+ roster: listed?.roster ?? previous?.roster ?? null,
6386
+ skills: skills?.skills ?? previous?.skills ?? null,
6387
+ error: listed?.error ?? null,
6388
+ skillsError: skills?.error ?? null,
5760
6389
  loading: false,
5761
- })
5762
- }, (error) => { if (!cancelled) setState(current => ({ ...current, error, loading: false })) })
5763
- return () => { cancelled = true }
5764
- }, [refreshKey])
6390
+ }))
6391
+ // Gates need a prompt refresh; a pilot that is merely paused or
6392
+ // blocked can wait longer, and a hidden tab waits longer still.
6393
+ const waiting = pilots === null || pilots.some(pilot => PILOT_GATE_STEPS.includes(pilot.phase) || pilot.phase === 'merging')
6394
+ const hidden = globalThis.document?.visibilityState === 'hidden'
6395
+ schedule(hidden ? 30000 : waiting ? 8000 : 30000)
6396
+ }
6397
+ // A failed read still schedules the next one, so polling never stops silently.
6398
+ const poll = () => load().catch(() => schedule(30000))
6399
+ const schedule = delay => {
6400
+ if (cancelled) return
6401
+ if (timer !== null) globalThis.clearTimeout(timer)
6402
+ timer = globalThis.setTimeout(poll, delay)
6403
+ }
6404
+ poll()
6405
+ // A tab that comes back into view reads at once instead of waiting out a hidden-tab delay.
6406
+ const doc = globalThis.document
6407
+ const onVisible = () => {
6408
+ if (cancelled || doc?.visibilityState !== 'visible') return
6409
+ if (timer !== null) globalThis.clearTimeout(timer)
6410
+ timer = null
6411
+ poll()
6412
+ }
6413
+ doc?.addEventListener?.('visibilitychange', onVisible)
6414
+ return () => {
6415
+ cancelled = true
6416
+ if (timer !== null) globalThis.clearTimeout(timer)
6417
+ doc?.removeEventListener?.('visibilitychange', onVisible)
6418
+ }
6419
+ }, [projectId, attempt])
5765
6420
  const refresh = useCallback(() => setAttempt(value => value + 1), [])
5766
- return { ...state, refresh }
6421
+ return { ...(state?.projectId === projectId ? state : { pilots: [], roster: null, skills: null, error: null, skillsError: null, loading: true }), refresh }
5767
6422
  }
5768
6423
 
5769
- /** The two decision kinds of a pilot, named without the retired task words. */
5770
- const PILOT_GATE_PLAN = 'plan'
5771
- const PILOT_GATE_REVIEW = 'review'
5772
-
5773
6424
  /** The label of one pilot step, by copy key (an unknown step shows its id). */
5774
6425
  function pilotStepLabel(step, t) {
5775
6426
  const key = `pilot.phase.${String(step ?? '')}`
@@ -5777,49 +6428,141 @@ textarea.rb-input{min-height:54px;resize:vertical}
5777
6428
  return label === key ? String(step ?? '') : label
5778
6429
  }
5779
6430
 
5780
- /** One pilot, its step, its progress and the controls a human has. */
5781
- function PilotStrip({ pilot, busy, onAction, t }) {
5782
- const [confirming, setConfirming] = useState(false)
6431
+ /** How many of this pilot's tasks are done. */
6432
+ function pilotDoneCount(pilot) {
6433
+ return Object.values(pilot?.taskProgress ?? {}).filter(entry => entry?.done === true).length
6434
+ }
6435
+
6436
+ function pilotAttentionTitle(count, t) {
6437
+ return count === 1 ? t('pilot.attentionTitleOne') : t('pilot.attentionTitle', { count })
6438
+ }
6439
+
6440
+ function pilotTriggerName(count, t) {
6441
+ return count === 1 ? t('pilot.toolbarAttentionOne') : t('pilot.toolbarAttention', { count })
6442
+ }
6443
+
6444
+ /** What changed between two revisions of one document; `null` when the rewrite is too large to diff here. */
6445
+ function pilotRevisionDiff(previous, current) {
6446
+ const before = String(previous ?? '')
6447
+ const after = String(current ?? '')
6448
+ if (before === after) return []
6449
+ const oldLines = before === '' ? [] : before.split('\n')
6450
+ const newLines = after === '' ? [] : after.split('\n')
6451
+ // Trim the unchanged ends first: a pilot plan usually changes in one place,
6452
+ // and Myers only needs the differing span plus two context lines.
6453
+ let prefix = 0
6454
+ while (prefix < oldLines.length && prefix < newLines.length && oldLines[prefix] === newLines[prefix]) prefix += 1
6455
+ let suffix = 0
6456
+ while (suffix < oldLines.length - prefix && suffix < newLines.length - prefix
6457
+ && oldLines[oldLines.length - 1 - suffix] === newLines[newLines.length - 1 - suffix]) suffix += 1
6458
+ const from = Math.max(0, prefix - 2)
6459
+ const oldEnd = Math.min(oldLines.length, oldLines.length - suffix + 2)
6460
+ const newEnd = Math.min(newLines.length, newLines.length - suffix + 2)
6461
+ return pilotDiffHunks(oldLines.slice(from, oldEnd), newLines.slice(from, newEnd), from, from)
6462
+ }
6463
+
6464
+ /**
6465
+ * Whether the panel keeps focus where it is. A poll that only changes the
6466
+ * step must not move it, but a focused gate action that unmounted (the
6467
+ * merge succeeded) must hand focus to the new step's control.
6468
+ * Focus outside the panel stays put: the panel is non-modal, so the user
6469
+ * may be typing in the chat composer while a poll changes the step.
6470
+ */
6471
+ function pilotKeepFocus(previous, { id, withFooter, focusLost }) {
6472
+ return !focusLost && previous != null && previous.id === id && (previous.withFooter || !withFooter)
6473
+ }
6474
+
6475
+ /** Whether nothing holds focus: the focused node unmounted and focus fell back to the page. */
6476
+ function pilotFocusLost(holder, doc = globalThis.document) {
6477
+ return holder == null || holder === doc?.body || holder === doc?.documentElement
6478
+ }
6479
+
6480
+ /** A disclosure row: label plus a chevron, expanded on demand. */
6481
+ function PilotDisclosure({ label, open, onToggle, strong = false }) {
6482
+ return h('button', {
6483
+ type: 'button', className: `rb-pilot-disclosure${strong ? ' rb-pilot-disclosure-strong' : ''}`,
6484
+ 'aria-expanded': open, onClick: onToggle,
6485
+ },
6486
+ h('svg', {
6487
+ className: 'rb-pilot-chev', width: 12, height: 12, viewBox: '0 0 24 24', fill: 'none',
6488
+ stroke: 'currentColor', strokeWidth: 2, 'aria-hidden': 'true', focusable: 'false',
6489
+ style: { transform: open ? 'rotate(90deg)' : 'none', transition: 'transform 150ms ease' },
6490
+ }, h('path', { d: 'M9 6l6 6-6 6' })),
6491
+ h('span', null, label))
6492
+ }
6493
+
6494
+ /** One pilot: step, progress and copyable identity (its id and title head the drawer). */
6495
+ function PilotStrip({ pilot, t }) {
5783
6496
  const total = Array.isArray(pilot.taskIds) ? pilot.taskIds.length : 0
5784
- const done = Object.values(pilot.taskProgress ?? {}).filter(entry => entry?.done === true).length
6497
+ const done = pilotDoneCount(pilot)
5785
6498
  const terminal = pilot.phase === 'done' || pilot.phase === 'aborted'
5786
- return h('section', { className: 'rb-card rb-pilot', 'data-pilot': pilot.id, 'aria-label': t('pilot.stripLabel', { id: pilot.milestoneId }) },
5787
- h('div', { className: 'rb-pilot-head' },
5788
- h('span', { className: 'rb-kb-tag' }, pilot.milestoneId),
5789
- h('strong', { className: 'rb-pilot-title' }, String(pilot.milestoneTitle ?? '')),
5790
- h('span', { className: 'rb-chip rb-pilot-step', 'data-pilot-step': pilot.phase }, pilotStepLabel(pilot.phase, t)),
5791
- h('span', { className: 'rb-caption' }, t('pilot.tasks', { done, total }))),
5792
- h('p', { className: 'rb-pilot-branch rb-mono' }, t('pilot.dialog.branch', { branch: pilot.branch })),
6499
+ return h('section', { className: 'rb-pilot', 'data-pilot': pilot.id, 'aria-label': t('pilot.stripLabel', { id: pilot.milestoneId }) },
6500
+ h('div', { className: 'rb-pilot-status' },
6501
+ h('span', { className: 'rb-pilot-step', 'data-pilot-step': pilot.phase }, pilotStepLabel(pilot.phase, t)),
6502
+ h('span', { className: 'rb-caption' }, t(total === 1 ? 'pilot.tasksOne' : 'pilot.tasks', { done, total })),
6503
+ pilot.maxGoalRounds === null || pilot.maxGoalRounds === undefined
6504
+ ? null
6505
+ : h('span', { className: 'rb-caption' }, t('pilot.rounds', { used: pilot.roundsStarted ?? 0, max: pilot.maxGoalRounds }))),
6506
+
6507
+ h('div', { className: 'rb-pilot-progress', 'aria-hidden': 'true' },
6508
+ h('span', { style: { width: `${total === 0 ? 0 : Math.round((done / total) * 100)}%` } })),
6509
+
5793
6510
  pilot.goalDisarmed === true && !terminal
5794
6511
  ? h('p', { className: 'rb-notice rb-pilot-disarmed', role: 'status' }, t('pilot.disarmed'))
5795
6512
  : null,
5796
6513
  pilot.phase === 'implementing' && pilot.lastMerge !== null && pilot.lastMerge !== undefined && pilot.lastMerge.outcome !== 'merged'
5797
6514
  ? h('p', { className: 'rb-notice rb-notice-error', role: 'alert' }, `${t('pilot.mergeFailed')} (${pilot.lastMerge.outcome})`)
5798
6515
  : null,
5799
- h('div', { className: 'rb-row rb-wrap' },
5800
- typeof pilot.sessionId === 'string' && typeof onAction.openChat === 'function'
5801
- ? h('button', { type: 'button', className: 'rb-btn', onClick: () => onAction.openChat(pilot.sessionId) }, h(Glyph, { name: 'chat', size: 12 }), t('pilot.chat'))
6516
+
6517
+ h('dl', { className: 'rb-pilot-facts' },
6518
+ h('dt', null, t('pilot.branch')),
6519
+ h('dd', null, h(PilotCopyFact, { value: pilot.branch, label: t('pilot.branch'), t })),
6520
+ h('dt', null, t('pilot.worktree')),
6521
+ h('dd', null, h(PilotCopyFact, { value: pilot.worktree, label: t('pilot.worktree'), t }))))
6522
+ }
6523
+
6524
+ function PilotRunActions({ pilot, busyAction, onAction, t }) {
6525
+ const [confirming, setConfirming] = useState(false)
6526
+ const terminal = ['done', 'aborted'].includes(pilot.phase)
6527
+ const agentStep = PILOT_AGENT_STEPS.includes(pilot.phase) && pilot.phase !== 'merging'
6528
+ // A disarmed goal is already stopped, so it offers Resume only: Pause
6529
+ // beside it would be a second, conflicting request.
6530
+ const canPause = agentStep && pilot.goalDisarmed !== true
6531
+ const canResume = pilot.phase === 'paused' || pilot.phase === 'blocked' || (agentStep && pilot.goalDisarmed === true)
6532
+ // Only the pressed control shows a busy label; Chat never blocks on a
6533
+ // lifecycle request, and lifecycle siblings stay focusable but inert.
6534
+ const lifecycleBusy = ['pause', 'resume', 'abort'].includes(busyAction)
6535
+ const act = action => onAction.run(action, pilot.id)
6536
+
6537
+ return terminal || pilot.phase === 'merging' ? null : h('div', { className: 'rb-pilot-actions' },
6538
+ typeof pilot.sessionId === 'string' && (typeof onAction.openSession === 'function' || typeof onAction.openChat === 'function')
6539
+ ? h('button', { type: 'button', className: 'rb-btn', onClick: () => (onAction.openSession ?? onAction.openChat)(pilot.sessionId) },
6540
+ h(Glyph, { name: 'chat', size: 12 }), t('pilot.chat'))
5802
6541
  : null,
5803
- terminal ? null : h('button', {
5804
- type: 'button', className: 'rb-btn', disabled: busy, 'data-pilot-action': 'pause',
5805
- onClick: () => onAction.run('pause', pilot.id),
5806
- }, t('pilot.pause')),
5807
- terminal ? null : h('button', {
5808
- type: 'button', className: 'rb-btn', disabled: busy, 'data-pilot-action': 'resume',
5809
- // A paused pilot resumes its step; a restarted session only re-arms the goal.
5810
- onClick: () => onAction.run('resume', pilot.id),
5811
- }, t('pilot.resume')),
5812
- terminal ? null : (confirming
6542
+ // Only the action that fits this step: Pause while it works, Resume once stopped.
6543
+ canPause ? h('button', {
6544
+ type: 'button', className: 'rb-btn', 'aria-disabled': lifecycleBusy ? 'true' : undefined,
6545
+ 'aria-busy': busyAction === 'pause' ? 'true' : undefined, 'data-pilot-action': 'pause',
6546
+ onClick: () => { if (!lifecycleBusy) act('pause') },
6547
+ }, busyAction === 'pause' ? t('pilot.pausing') : t('pilot.pause')) : null,
6548
+ canResume ? h('button', {
6549
+ type: 'button', className: 'rb-btn rb-btn-primary', 'aria-disabled': lifecycleBusy ? 'true' : undefined,
6550
+ 'aria-busy': busyAction === 'resume' ? 'true' : undefined, 'data-pilot-action': 'resume',
6551
+ onClick: () => { if (!lifecycleBusy) act('resume') },
6552
+ }, busyAction === 'resume' ? t('pilot.resuming') : t('pilot.resume')) : null,
6553
+ h('span', { className: 'rb-grow' }),
6554
+ confirming
5813
6555
  ? h('span', { className: 'rb-row' },
5814
6556
  h('span', { className: 'rb-caption' }, t('pilot.abortConfirm')),
5815
- h('button', { type: 'button', className: 'rb-btn rb-btn-danger', disabled: busy, 'data-pilot-action': 'abort', onClick: () => onAction.run('abort', pilot.id) }, t('pilot.abort')),
6557
+ h('button', { type: 'button', className: 'rb-btn rb-btn-danger', 'aria-disabled': lifecycleBusy ? 'true' : undefined,
6558
+ 'data-pilot-action': 'abort', onClick: () => { if (!lifecycleBusy) act('abort') } },
6559
+ busyAction === 'abort' ? t('pilot.aborting') : t('pilot.abort')),
5816
6560
  h('button', { type: 'button', className: 'rb-btn', onClick: () => setConfirming(false) }, t('pilot.abortCancel')))
5817
- : h('button', { type: 'button', className: 'rb-btn', disabled: busy, onClick: () => setConfirming(true) }, t('pilot.abort'))),
5818
- h('span', { className: 'rb-caption' }, t('pilot.rounds', { used: pilot.roundsStarted ?? 0, max: pilot.maxGoalRounds ?? '—' }))))
6561
+ : h('button', { type: 'button', className: 'rb-btn rb-btn-ghost rb-pilot-danger', onClick: () => setConfirming(true) }, t('pilot.abortOpen')))
5819
6562
  }
5820
6563
 
5821
6564
  /** The question a pilot is waiting on, with a reply box. */
5822
- function PilotQuestionGate({ pilot, busy, onAction, t }) {
6565
+ function PilotQuestionGate({ pilot, busy, onAction, footer, t }) {
5823
6566
  const [text, setText] = useState('')
5824
6567
  const question = pilot.pendingQuestion
5825
6568
  if (question === null || question === undefined) return null
@@ -5832,247 +6575,645 @@ textarea.rb-input{min-height:54px;resize:vertical}
5832
6575
  className: 'rb-pilot-textarea', rows: 3, value: text, 'data-pilot-answer': pilot.id,
5833
6576
  onChange: event => setText(String(event?.target?.value ?? '')),
5834
6577
  })),
5835
- h('button', {
6578
+ pilotFooter(h('button', {
5836
6579
  type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy || text.trim() === '',
5837
6580
  onClick: () => onAction.run('answer', pilot.id, { text: text.trim() }),
5838
- }, t('pilot.gate.send')))
5839
- }
5840
-
5841
- /** A minimal line diff between the previous revision and this one. */
5842
- function pilotRevisionDiff(previous, current) {
5843
- const before = new Set(String(previous ?? '').split('\n'))
5844
- const after = new Set(String(current ?? '').split('\n'))
5845
- return [
5846
- ...String(previous ?? '').split('\n').filter(line => line.trim() !== '' && !after.has(line)).map(line => `- ${line}`),
5847
- ...String(current ?? '').split('\n').filter(line => line.trim() !== '' && !before.has(line)).map(line => `+ ${line}`),
5848
- ]
6581
+ }, t('pilot.gate.send')), footer))
5849
6582
  }
5850
6583
 
5851
- /** The spec-and-plan approval of one pilot. */
5852
- function PilotPlanGate({ pilot, busy, onAction, t }) {
6584
+ /** The spec approval gate: collapsed documents, the change diff, two decisions. */
6585
+ function PilotPlanGate({ pilot, busy, onAction, footer, t }) {
5853
6586
  const [reason, setReason] = useState('')
5854
- const [showDiff, setShowDiff] = useState(false)
6587
+ const [showSpec, setShowSpec] = useState(false)
6588
+ const [showOutline, setShowOutline] = useState(false)
5855
6589
  const revisions = Array.isArray(pilot.revisions) ? pilot.revisions : []
5856
6590
  const latest = revisions.at(-1)
5857
- if (latest === undefined) return null
5858
6591
  const previous = revisions.length > 1 ? revisions[revisions.length - 2] : null
5859
- const changes = previous === null ? [] : pilotRevisionDiff(previous.plan, latest.plan)
6592
+ const changes = useMemo(() => previous === null || latest === undefined ? [] : pilotRevisionDiff(previous[PILOT_GATE_PLAN], latest[PILOT_GATE_PLAN]), [previous?.[PILOT_GATE_PLAN], latest?.[PILOT_GATE_PLAN]])
6593
+ const specChanges = useMemo(() => previous === null || latest === undefined ? [] : pilotRevisionDiff(previous.spec, latest.spec), [previous?.spec, latest?.spec])
6594
+ if (latest === undefined) return null
6595
+ const specLines = String(latest.spec ?? '').split('\n').length
6596
+ const outlineLines = String(latest[PILOT_GATE_PLAN] ?? '').split('\n').length
5860
6597
  const decide = decision => onAction.run('decide', pilot.id, {
5861
6598
  gate: PILOT_GATE_PLAN, revision: latest.number, decision, text: decision === 'changes' ? reason.trim() : null,
5862
6599
  })
6600
+ const block = (label, { lines, header }) => h('div', { key: `${label} ${header}`, className: 'rb-pilot-diff' },
6601
+ h('div', { className: 'rb-pilot-hunk' }, `${label} · ${header}`),
6602
+ lines.map((line, position) => h('div', {
6603
+ key: `l${position}`, className: `rb-pilot-line rb-pilot-${line.kind}`,
6604
+ }, h('span', { className: 'rb-pilot-sign' }, line.kind === 'add' ? '+' : line.kind === 'del' ? '−' : ' '),
6605
+ h('span', null, line.text === '' ? ' ' : line.text))))
5863
6606
  return h('section', { className: 'rb-card rb-pilot-gate', 'data-pilot-gate': 'plan' },
5864
6607
  h('h3', { className: 'rb-section-title' }, t('pilot.gate.plan')),
5865
- h('div', { className: 'rb-row rb-wrap' },
5866
- h('span', { className: 'rb-chip' }, t('pilot.gate.revision', { number: latest.number })),
5867
- h('button', { type: 'button', className: 'rb-btn rb-btn-link', 'aria-expanded': showDiff, onClick: () => setShowDiff(value => !value) },
5868
- showDiff ? t('pilot.gate.diffHide') : t('pilot.gate.diffShow'))),
5869
- showDiff && previous !== null
5870
- ? h('pre', { className: 'rb-pre rb-pilot-diff', 'data-pilot-diff': pilot.id },
5871
- changes.length === 0 ? '—' : changes.join('\n'))
5872
- : null,
5873
- h('h4', { className: 'rb-caption' }, t('pilot.gate.spec')),
5874
- h('pre', { className: 'rb-pre rb-pilot-doc' }, String(latest.spec ?? '')),
5875
- h('h4', { className: 'rb-caption' }, t('pilot.gate.planText')),
5876
- h('pre', { className: 'rb-pre rb-pilot-doc' }, String(latest.plan ?? '')),
5877
- h('div', { className: 'rb-row rb-wrap' },
5878
- h('button', { type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy, 'data-pilot-approve': pilot.id, onClick: () => decide('approve') }, t('pilot.gate.approve')),
6608
+ h('p', { className: 'rb-caption' }, t('pilot.gate.revision', { number: latest.number })),
6609
+ h(PilotDisclosure, { label: t(specLines === 1 ? 'pilot.gate.showSpecOne' : 'pilot.gate.showSpec', { count: specLines }), open: showSpec, onToggle: () => setShowSpec(value => !value) }),
6610
+ showSpec ? h('pre', { className: 'rb-pre rb-pilot-doc' }, String(latest.spec ?? '')) : null,
6611
+ h(PilotDisclosure, { label: t(outlineLines === 1 ? 'pilot.gate.showPlanOne' : 'pilot.gate.showPlan', { count: outlineLines }), open: showOutline, onToggle: () => setShowOutline(value => !value) }),
6612
+ showOutline ? h('pre', { className: 'rb-pre rb-pilot-doc' }, String(latest[PILOT_GATE_PLAN] ?? '')) : null,
6613
+ previous === null ? null : h('div', { className: 'rb-pilot-diffs' },
6614
+ h('h4', { className: 'rb-pilot-changes-title' }, t('pilot.gate.changesSince', { number: previous.number })),
6615
+ (specChanges?.length ?? 1) + (changes?.length ?? 1) === 0 ? h('p', { className: 'rb-caption' }, t('pilot.gate.noDiff')) : null,
6616
+ // A rewrite too large to diff is said so plainly; the document stays one click away.
6617
+ specChanges === null ? h('p', { className: 'rb-caption', 'data-pilot-diff-too-large': 'spec' }, t('pilot.gate.diffTooLarge', { label: t('pilot.gate.specTitle') }))
6618
+ : specChanges.map(hunk => block(t('pilot.gate.specTitle'), hunk)),
6619
+ changes === null ? h('p', { className: 'rb-caption', 'data-pilot-diff-too-large': 'plan' }, t('pilot.gate.diffTooLarge', { label: t('pilot.gate.planTitle') }))
6620
+ : changes.map(hunk => block(t('pilot.gate.planTitle'), hunk))),
6621
+ h('label', { className: 'rb-pilot-field' },
6622
+ h('span', { className: 'rb-caption' }, t('pilot.gate.changesPlaceholder')),
6623
+ h('textarea', {
6624
+ className: 'rb-pilot-textarea', rows: 2, value: reason,
6625
+ onChange: event => setReason(String(event?.target?.value ?? '')),
6626
+ })),
6627
+ pilotFooter(h('div', { className: 'rb-row rb-wrap' },
6628
+ h('button', { type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy, 'data-pilot-approve': pilot.id, onClick: () => decide('approve') },
6629
+ t('pilot.gate.approve')),
5879
6630
  h('button', {
5880
6631
  type: 'button', className: 'rb-btn', disabled: busy || reason.trim() === '', 'data-pilot-changes': pilot.id,
5881
6632
  onClick: () => decide('changes'),
5882
- }, t('pilot.gate.changes'))),
5883
- h('label', { className: 'rb-pilot-field' },
5884
- h('span', { className: 'rb-caption' }, t('pilot.gate.changesPlaceholder')),
5885
- h('textarea', { className: 'rb-pilot-textarea', rows: 2, value: reason, onChange: event => setReason(String(event?.target?.value ?? '')) })))
6633
+ }, t('pilot.gate.changes'))), footer))
5886
6634
  }
5887
6635
 
5888
6636
  /** The final review: what was reviewed, what QA found, and the merge consent. */
5889
- function PilotReviewGate({ pilot, project, busy, onAction, t }) {
6637
+ function PilotReviewGate({ pilot, project, busy, busyAction, onAction, footer, t }) {
5890
6638
  const [reason, setReason] = useState('')
6639
+ const [showDetail, setShowDetail] = useState(false)
5891
6640
  // What the human opened and therefore saw: the token, branch and worktree
5892
6641
  // at that moment. A board update between opening and confirming must not
5893
6642
  // swap in a newer consent, so the snapshot is compared on every render.
5894
6643
  const [pending, setPending] = useState(null)
6644
+ const mergeButton = useRef(null)
6645
+ const confirmButton = useRef(null)
6646
+ const hadPending = useRef(false)
5895
6647
  const review = Array.isArray(pilot.reviews) ? pilot.reviews.at(-1) : null
5896
6648
  const run = Array.isArray(pilot.qaRuns) ? pilot.qaRuns.at(-1) : null
5897
6649
  const reports = Array.isArray(run?.reportIds) ? run.reportIds : []
5898
6650
  const decide = (decision, extra = {}) => onAction.run('decide', pilot.id, { gate: PILOT_GATE_REVIEW, decision, ...extra })
5899
- const stale = pending !== null && pending.token !== pilot.confirmation
5900
- const openConsent = () => setPending({ token: pilot.confirmation, branch: pilot.branch, worktree: pilot.worktree })
5901
- const merge = () => {
5902
- if (pending === null || pending.token === null || pending.token === undefined) {
5903
- onAction.fail(new BoardError('pilot-stale-revision', t('pilot.gate.stale')))
5904
- return
6651
+ const visible = {
6652
+ id: pilot.id, phase: pilot.phase, token: pilot.confirmation,
6653
+ branch: String(pilot.branch ?? ''), base: String(project?.baseBranch ?? 'main'),
6654
+ worktree: String(pilot.worktree ?? ''), count: Array.isArray(pilot.taskIds) ? pilot.taskIds.length : 0,
6655
+ commit: String(run?.commit ?? review?.commit ?? ''), command: String(project?.verifyCommand ?? ''),
6656
+ }
6657
+ const stale = pending !== null && Object.keys(visible).some(key => pending[key] !== visible[key])
6658
+ const hasToken = typeof visible.token === 'string' && visible.token.length > 0
6659
+ const openConsent = () => { if (!busy && hasToken) setPending(visible) }
6660
+ useEffect(() => {
6661
+ if (pending !== null) {
6662
+ hadPending.current = true
6663
+ mergeButton.current?.focus?.()
6664
+ } else if (hadPending.current) {
6665
+ hadPending.current = false
6666
+ confirmButton.current?.focus?.()
5905
6667
  }
5906
- if (stale) return
6668
+ }, [pending])
6669
+ const merge = () => {
6670
+ if (busy || stale || pending === null || !hasToken) return
5907
6671
  decide('approve', { confirmation: pending.token })
5908
6672
  }
5909
6673
  return h('section', { className: 'rb-card rb-pilot-gate', 'data-pilot-gate': 'review' },
5910
6674
  h('h3', { className: 'rb-section-title' }, t('pilot.gate.review')),
5911
- h('p', { className: 'rb-pilot-branch rb-mono' }, t('pilot.dialog.branch', { branch: pilot.branch })),
5912
6675
  review === null ? null : h('p', { className: 'rb-caption' }, t('pilot.gate.reviewCode', { verdict: review.verdict, commit: String(review.commit).slice(0, 7) })),
5913
- review !== null && Array.isArray(review.deferredMinors) && review.deferredMinors.length > 0
5914
- ? h('p', { className: 'rb-caption' }, t('pilot.gate.reviewMinor', { text: review.deferredMinors.join('; ') }))
5915
- : null,
5916
6676
  run === null ? null : h('p', { className: 'rb-caption' }, t('pilot.gate.reviewQa', { verdict: run.verdict, commit: String(run.commit).slice(0, 7) })),
5917
- reports.length === 0 ? null : h('p', { className: 'rb-caption rb-mono', style: { wordBreak: 'break-all' } }, t('pilot.gate.reviewQaReports', { ids: reports.join(', ') })),
5918
- pending === null
5919
- ? h('div', { className: 'rb-row rb-wrap' },
5920
- h('button', { type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy, 'data-pilot-confirm': pilot.id, onClick: openConsent },
5921
- h(Glyph, { name: 'check', size: 12 }), t('pilot.gate.merge')),
5922
- h('button', {
5923
- type: 'button', className: 'rb-btn', disabled: busy || reason.trim() === '',
5924
- 'data-pilot-review-changes': pilot.id,
5925
- onClick: () => decide('changes', { text: reason.trim() }),
5926
- }, t('pilot.gate.changes')))
5927
- : h('div', { className: 'rb-pilot-confirm' },
6677
+ h(PilotDisclosure, {
6678
+ label: t(reports.length === 1 ? 'pilot.gate.showDetailOne' : 'pilot.gate.showDetail', { count: reports.length }), open: showDetail, onToggle: () => setShowDetail(value => !value),
6679
+ }),
6680
+ showDetail ? h('div', { className: 'rb-pilot-detail' },
6681
+ review !== null && Array.isArray(review.deferredMinors) && review.deferredMinors.length > 0
6682
+ ? h('p', { className: 'rb-caption' }, t('pilot.gate.reviewMinor', { text: review.deferredMinors.join('; ') }))
6683
+ : null,
6684
+ reports.length === 0
6685
+ ? h('p', { className: 'rb-caption' }, t('pilot.gate.noReports'))
6686
+ : h('p', { className: 'rb-caption rb-mono' }, t('pilot.gate.reviewQaReports', { ids: reports.join(', ') }))) : null,
6687
+ pending === null ? null : h('div', { className: 'rb-pilot-confirm', role: 'group', 'aria-live': 'polite' },
5928
6688
  h('p', { className: 'rb-caption' }, t('pilot.gate.confirmTitle')),
5929
- stale
5930
- ? h('p', { className: 'rb-notice rb-notice-error', role: 'alert', 'data-pilot-stale': pilot.id }, t('pilot.gate.stale'))
5931
- : h('p', null, t('pilot.gate.confirm', {
5932
- branch: pending.branch, base: String(project?.baseBranch ?? 'main'), worktree: pending.worktree,
5933
- count: Array.isArray(pilot.taskIds) ? pilot.taskIds.length : 0,
5934
- })),
5935
- h('div', { className: 'rb-row rb-wrap' },
5936
- h('button', {
5937
- type: 'button', className: 'rb-btn rb-btn-primary', 'data-pilot-merge': pilot.id,
5938
- disabled: busy || stale, onClick: merge,
5939
- }, busy ? t('pilot.gate.merging') : t('pilot.gate.merge')),
5940
- h('button', { type: 'button', className: 'rb-btn', onClick: () => setPending(null) }, t('pilot.gate.mergeCancel')))),
6689
+ stale ? h('p', { className: 'rb-notice rb-notice-error', role: 'alert', 'data-pilot-stale': pilot.id }, t('pilot.gate.stale')) : null,
6690
+ h('p', null, t(pending.count === 1 ? 'pilot.gate.confirmOne' : 'pilot.gate.confirm', pending)),
6691
+ pending.commit === '' ? null : h('p', { className: 'rb-caption rb-mono' }, t('pilot.gate.testedCommit', { commit: pending.commit })),
6692
+ pending.command === '' ? null : h('p', { className: 'rb-caption rb-mono' }, t('pilot.gate.verifyCommand', { command: pending.command }))),
5941
6693
  h('label', { className: 'rb-pilot-field' },
5942
6694
  h('span', { className: 'rb-caption' }, t('pilot.gate.changesPlaceholder')),
5943
- h('textarea', { className: 'rb-pilot-textarea', rows: 2, value: reason, onChange: event => setReason(String(event?.target?.value ?? '')) })))
6695
+ h('textarea', { className: 'rb-pilot-textarea', rows: 2, value: reason, onChange: event => setReason(String(event?.target?.value ?? '')) })),
6696
+ pilotFooter(h('div', { className: 'rb-row rb-wrap' },
6697
+ pending === null && !hasToken ? h('p', { className: 'rb-caption', role: 'status' }, t('pilot.gate.noToken')) : null,
6698
+ pending === null
6699
+ ? h('button', { type: 'button', ref: confirmButton, className: 'rb-btn rb-btn-primary', disabled: busy || !hasToken, 'data-pilot-confirm': pilot.id, onClick: openConsent },
6700
+ h(Glyph, { name: 'check', size: 12 }), t('pilot.gate.merge'))
6701
+ : h('button', {
6702
+ type: 'button', ref: mergeButton, className: 'rb-btn rb-btn-primary', 'data-pilot-merge': pilot.id,
6703
+ disabled: busy || stale, onClick: merge,
6704
+ }, busyAction === 'decide' ? t('pilot.gate.merging') : t('pilot.gate.merge')),
6705
+ pending === null ? null : h('button', { type: 'button', className: 'rb-btn', onClick: () => setPending(null) }, t('pilot.gate.mergeCancel')),
6706
+ pending === null ? h('button', {
6707
+ type: 'button', className: 'rb-btn', disabled: busy || reason.trim() === '',
6708
+ onClick: () => decide('changes', { text: reason.trim() }),
6709
+ }, t('pilot.gate.changes')) : null), footer))
5944
6710
  }
5945
6711
 
5946
6712
  /** Which gate card a pilot needs, if any. */
5947
- function PilotGate({ pilot, project, busy, onAction, t }) {
5948
- if (pilot.phase === 'asking') return h(PilotQuestionGate, { pilot, busy, onAction, t })
5949
- if (pilot.phase === 'awaiting_approval') return h(PilotPlanGate, { pilot, busy, onAction, t })
5950
- if (pilot.phase === 'awaiting_review') return h(PilotReviewGate, { pilot, project, busy, onAction, t })
6713
+ function PilotGate({ pilot, project, busy, busyAction, onAction, footer, t }) {
6714
+ if (pilot.phase === 'asking') return h(PilotQuestionGate, { pilot, busy, onAction, footer, t })
6715
+ if (pilot.phase === 'awaiting_approval') return h(PilotPlanGate, { pilot, busy, onAction, footer, t })
6716
+ if (pilot.phase === 'awaiting_review') return h(PilotReviewGate, { pilot, project, busy, busyAction, onAction, footer, t })
5951
6717
  return null
5952
6718
  }
5953
6719
 
5954
- /** The Superpowers setup: an Enable switch when everything is installed. */
5955
- function PilotSkillsPanel({ projectId, skills, busy, onAction, t }) {
5956
- if (skills === null || skills === undefined) return null
5957
- const missing = Array.isArray(skills.missing) ? skills.missing : []
5958
- const base = onAction.configVersion
5959
- return h('section', { className: 'rb-card rb-pilot-skills', 'data-pilot-skills': projectId },
5960
- h('h3', { className: 'rb-section-title' }, t('pilot.skills.title')),
5961
- h('p', { className: 'rb-caption' }, missing.length === 0 ? t('pilot.skills.installed') : t('pilot.skills.partial', { count: missing.length })),
5962
- missing.length === 0 ? null : h('p', { className: 'rb-caption' }, t('pilot.skills.missing', { names: missing.join(', ') })),
5963
- missing.length === 0
5964
- ? h('label', { className: 'rb-row' },
5965
- h('input', {
5966
- type: 'checkbox', checked: skills.enabled === true, disabled: busy, 'data-pilot-skills-toggle': projectId,
5967
- onChange: event => onAction.skills('enabled', { enabled: event?.target?.checked === true, baseConfigVersion: base }),
5968
- }),
5969
- h('span', null, t('pilot.skills.enable')))
5970
- : h('div', { className: 'rb-row rb-wrap' },
5971
- h('button', { type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy, 'data-pilot-skills-install': 'user', onClick: () => onAction.skills('install', { scope: 'user', baseConfigVersion: base }) }, t('pilot.skills.user')),
5972
- h('button', { type: 'button', className: 'rb-btn', disabled: busy, 'data-pilot-skills-install': 'project', onClick: () => onAction.skills('install', { scope: 'project', baseConfigVersion: base }) }, t('pilot.skills.project'))),
5973
- skills.installQueued === true ? h('p', { className: 'rb-notice', role: 'status' }, t('pilot.skills.projectQueued')) : null,
5974
- h('p', { className: 'rb-caption' }, t('pilot.skills.source', { repo: skills.source?.repo ?? '', tag: skills.source?.tag ?? '' })))
6720
+ /** The drawer reports status; only Roadmap settings can change it. */
6721
+ function PilotSkillsPanel({ projectId, skills, error = null, onOpenSettings, t }) {
6722
+ const tone = skills == null ? null : (skills.missing?.length ?? 0) > 0 ? 'warn' : 'ok'
6723
+ return h('div', { className: 'rb-row rb-wrap rb-pilot-skills-summary', 'data-pilot-skills-summary': projectId },
6724
+ tone === null ? null : h('span', { className: `rb-pilot-dot rb-pilot-dot-${tone}`, 'aria-hidden': 'true' }),
6725
+ h('span', { className: 'rb-caption' }, skills === null && error !== null ? t('pilot.skills.error') : t('pilot.skills.summary', {
6726
+ status: pilotSkillsStatusText(skills, t),
6727
+ mode: skills == null ? '' : ` · ${t(skills.enabled ? 'pilot.skills.enabled' : 'pilot.skills.disabled')}`,
6728
+ })),
6729
+ typeof onOpenSettings !== 'function' ? null : h('button', {
6730
+ type: 'button', className: 'rb-btn rb-btn-link', 'aria-label': t('kanban.settings'), onClick: onOpenSettings,
6731
+ }, t('pilot.skills.settings')))
5975
6732
  }
5976
6733
 
5977
6734
  /** The milestone to pilot, with its branch and open work. */
5978
- function PilotStartDialog({ view, projectId, pilots, busy, onStart, onClose, t }) {
6735
+ function PilotStartDialog({ view, projectId, pilots, busy, error, onStart, onClose, t }) {
5979
6736
  const milestones = validMilestones(view).filter(milestone => pilotableMilestone(milestone, pilots))
5980
6737
  const [picked, setPicked] = useState(null)
5981
6738
  const chosen = milestones.find(milestone => milestone.id === picked) ?? milestones[0] ?? null
5982
- return h('section', { className: 'rb-card rb-pilot-start', role: 'dialog', 'aria-label': t('pilot.title'), 'data-pilot-start': projectId },
5983
- h('h3', { className: 'rb-section-title' }, t('pilot.title')),
6739
+ const dialog = useRef(null)
6740
+ useEffect(() => {
6741
+ const node = dialog.current
6742
+ if (!node) return undefined
6743
+ const previousFocus = node.ownerDocument.activeElement
6744
+ if (!node.open) node.showModal?.()
6745
+ return () => { if (node.open) node.close?.(); if (previousFocus?.isConnected) previousFocus.focus() }
6746
+ }, [])
6747
+ return h('dialog', {
6748
+ ref: dialog, id: 'pilot-start-dialog', className: 'rb-card rb-pilot-start', 'aria-modal': 'true',
6749
+ 'aria-labelledby': 'pilot-start-title', 'data-pilot-start': projectId,
6750
+ onCancel: event => { event.preventDefault(); onClose?.() },
6751
+ onKeyDown: event => { event.stopPropagation() },
6752
+ },
6753
+ h('h3', { id: 'pilot-start-title', className: 'rb-section-title' }, t('pilot.title')),
5984
6754
  milestones.length === 0
5985
6755
  ? h('p', { className: 'rb-notice' }, t('pilot.dialog.none'))
5986
6756
  : h('div', null,
5987
6757
  h('label', { className: 'rb-pilot-field' },
5988
6758
  h('span', { className: 'rb-caption' }, t('pilot.dialog.choose')),
5989
6759
  h('select', {
5990
- className: 'rb-select', value: chosen?.id ?? '', 'aria-label': t('pilot.dialog.choose'),
6760
+ className: 'rb-select', value: chosen?.id ?? '', disabled: busy, autoFocus: true, 'aria-label': t('pilot.dialog.choose'),
5991
6761
  onChange: event => setPicked(String(event?.target?.value ?? '')),
5992
6762
  }, milestones.map(milestone => h('option', { key: milestone.id, value: milestone.id },
5993
6763
  t('pilot.dialog.title', { id: milestone.id, title: String(milestone.title ?? '') }))))),
5994
6764
  h('p', { className: 'rb-caption' }, t('pilot.dialog.branch', { branch: pilotBranchName(chosen.id, chosen.title) })),
5995
- h('p', { className: 'rb-caption' }, t('pilot.dialog.openTasks', {
6765
+ h('p', { className: 'rb-caption' }, t(chosen.tasks.filter(task => task.status !== 'done').length === 1
6766
+ ? 'pilot.dialog.openTaskOne' : 'pilot.dialog.openTasks', {
5996
6767
  count: chosen.tasks.filter(task => task.status !== 'done').length,
5997
6768
  })),
5998
- h('div', { className: 'rb-row rb-wrap' },
6769
+ h('div', { className: 'rb-row rb-wrap' },
5999
6770
  h('button', {
6000
6771
  type: 'button', className: 'rb-btn rb-btn-primary', disabled: busy, 'data-pilot-start-confirm': chosen.id,
6001
6772
  onClick: () => onStart(chosen.id),
6002
- }, busy ? t('pilot.dialog.starting') : t('pilot.dialog.start')),
6003
- h('button', { type: 'button', className: 'rb-btn', onClick: onClose }, t('pilot.dialog.close')))))
6773
+ }, busy ? t('pilot.dialog.starting') : t('pilot.dialog.start')))),
6774
+ busy ? h('p', { className: 'rb-caption', role: 'status' }, t('pilot.dialog.starting')) : null,
6775
+ h('button', { type: 'button', className: 'rb-btn', onClick: onClose }, t('pilot.dialog.close')),
6776
+ h(ErrorLine, { error, t }))
6004
6777
  }
6005
6778
 
6006
6779
  /**
6007
6780
  * Everything the pilot feature shows on the board: the start control, the
6008
- * strip of running pilots, the gate the human must answer, and the
6009
- * Superpowers setup. Reads its own state; refreshes the board after a merge.
6781
+ * panel of running pilots, the gate the human must answer, and the
6782
+ * Superpowers status. Mounted as a right-hand drawer on the full board,
6783
+ * reading the project's pilots and refreshing the board after a merge.
6010
6784
  */
6011
- function PilotBoardSection({ view, projectId, store, compact = false, t, openChat }) {
6012
- const { pilots, skills, error, loading, refresh } = usePilots(projectId, view)
6013
- const [busy, setBusy] = useState(false)
6785
+ function PilotBoardSection({ view, projectId, store, compact = false, t, openChat, openSession, onClose,
6786
+ pilotData, selectedPilotId, onSelectPilot, openStart, onOpenStart, onCloseStart, onOpenSettings }) {
6787
+ const { pilots = [], roster = null, skills, error, skillsError, loading, refresh } = pilotData ?? {}
6788
+ const [busyAction, setBusyAction] = useState(null)
6014
6789
  const [actionError, setActionError] = useState(null)
6015
- const [showStart, setShowStart] = useState(false)
6016
- const [showSkills, setShowSkills] = useState(false)
6790
+ const [footer, setFooter] = useState(null)
6791
+ const actionLock = useRef(false)
6792
+ const panelRef = useRef(null)
6793
+ const closeButton = useRef(null)
6794
+ const startsOpen = useRef(openStart)
6017
6795
  const project = view?.project ?? {}
6796
+ const working = busyAction !== null
6018
6797
  const after = useCallback(() => {
6019
- refresh()
6020
- if (store !== null && projectId !== null) reloadProject(store, projectId).catch(() => {})
6798
+ if (store != null && projectId != null) reloadProject(store, projectId).catch(() => {})
6799
+ return refresh?.()
6021
6800
  }, [refresh, store, projectId])
6801
+ async function perform(action, requestAction, success = after) {
6802
+ if (actionLock.current) return
6803
+ actionLock.current = true
6804
+ setBusyAction(action)
6805
+ setActionError(null)
6806
+ try { await success(await requestAction()) }
6807
+ catch (failure) { setActionError(failure) }
6808
+ finally { actionLock.current = false; setBusyAction(null) }
6809
+ }
6022
6810
  const onAction = {
6023
- configVersion: project.configVersion ?? 1,
6024
6811
  openChat,
6025
- fail: setActionError,
6812
+ openSession,
6026
6813
  run(action, pilotId, body) {
6027
- setBusy(true)
6028
- setActionError(null)
6029
- const call = action === 'pause' ? pilotRequests.pause(pilotId)
6814
+ return perform(action, () => action === 'pause' ? pilotRequests.pause(pilotId)
6030
6815
  : action === 'resume' ? pilotRequests.resume(pilotId)
6031
6816
  : action === 'abort' ? pilotRequests.abort(pilotId)
6032
6817
  : action === 'answer' ? pilotRequests.answer(pilotId, body?.text ?? '')
6033
- : pilotRequests.decide(pilotId, body)
6034
- call.then(after, setActionError).finally(() => setBusy(false))
6818
+ : pilotRequests.decide(pilotId, body))
6035
6819
  },
6036
- skills(kind, body) {
6037
- setBusy(true)
6038
- setActionError(null)
6039
- const call = kind === 'install'
6040
- ? pilotRequests.installSkills(projectId, body.scope, body.baseConfigVersion)
6041
- : pilotRequests.setSkills(projectId, body.enabled, body.baseConfigVersion)
6042
- call.then(() => { refresh(); if (store !== null) reloadProject(store, projectId).catch(() => {}) }, setActionError)
6043
- .finally(() => setBusy(false))
6820
+ }
6821
+ const start = milestoneId => perform('start', () => pilotRequests.start(projectId, milestoneId), result => {
6822
+ onCloseStart?.()
6823
+ // Opened through ▾: once a pilot starts, its gate may take focus as usual.
6824
+ startsOpen.current = false
6825
+ if (result?.pilot?.id) onSelectPilot?.(result.pilot.id)
6826
+ const sessionId = result?.pilot?.sessionId
6827
+ if (typeof sessionId === 'string') {
6828
+ if (typeof openSession === 'function') openSession(sessionId)
6829
+ else if (typeof openChat === 'function') openChat(sessionId)
6830
+ }
6831
+ return after()
6832
+ })
6833
+ const active = pilots.filter(pilot => !['done', 'aborted'].includes(pilot.phase))
6834
+ const selected = pilots.find(pilot => pilot.id === selectedPilotId) ?? active[0] ?? null
6835
+ useEffect(() => { if (selected === null) setFooter(null) }, [selected?.id])
6836
+ // Opening the panel, or selecting another pilot, lands on the gate (or its
6837
+ // answer box); the close button is the first stop when there is nothing to
6838
+ // act on. A poll that only changes the step never moves focus; a pilot that
6839
+ // first appears (just started) does.
6840
+ const focused = useRef(null)
6841
+ useEffect(() => {
6842
+ if (startsOpen.current) return
6843
+ const id = selected?.id ?? null
6844
+ const root = panelRef.current
6845
+ const focusLost = pilotFocusLost(globalThis.document?.activeElement)
6846
+ // The gate actions start inline and move into the footer portal once its
6847
+ // node exists: refocus that once, after the move, and never again for
6848
+ // this pilot (a footer that unmounts on a poll must not pull focus).
6849
+ if (pilotKeepFocus(focused.current, { id, withFooter: footer !== null, focusLost })) return
6850
+ // Wait for a footer only when this step renders one; otherwise a poll that
6851
+ // later mounts it (a failed merge back to implementing) would pull focus.
6852
+ focused.current = { id, withFooter: footer !== null || PILOT_FOOTLESS_STEPS.includes(selected?.phase) }
6853
+ const ctas = root?.querySelectorAll?.('[data-pilot-confirm], [data-pilot-approve], [data-pilot-action="resume"]') ?? []
6854
+ const target = [...ctas].find(node => !node.disabled && node.getAttribute?.('aria-disabled') !== 'true')
6855
+ ?? root?.querySelector?.('[data-pilot-gate] textarea')
6856
+ ;(target ?? closeButton.current)?.focus?.()
6857
+ }, [selected?.id, footer])
6858
+ return h('aside', {
6859
+ className: `rb-pilot-panel${compact ? ' rb-pilot-panel-compact' : ''}`, 'data-pilot-panel': projectId ?? '',
6860
+ id: `pilot-panel-${projectId}`, role: 'dialog', 'aria-modal': 'false', 'aria-label': t('pilot.title'), ref: panelRef,
6861
+ onKeyDown: event => {
6862
+ // A typed draft survives the first Escape: it closes only when the
6863
+ // field is empty or focus is outside an editor.
6864
+ const editing = event.target?.tagName === 'TEXTAREA' && String(event.target.value ?? '').trim() !== ''
6865
+ if (event.key === 'Escape' && !event.defaultPrevented && !openStart && !editing) { event.stopPropagation(); onClose?.() }
6044
6866
  },
6867
+ },
6868
+ h('header', { className: 'rb-pilot-panelhead' },
6869
+ // The mockup heads the drawer with the pilot itself: "M14 Milestone pilot".
6870
+ ...(selected === null
6871
+ ? [h('h3', { key: 'title', className: 'rb-section-title' }, t('pilot.title'))]
6872
+ // The id sits inside the heading, so its accessible name is "M14 Milestone pilot".
6873
+ : [h('h3', { key: 'title', className: 'rb-pilot-title rb-pilot-headtitle', title: String(selected.milestoneTitle ?? '') },
6874
+ h('span', { className: 'rb-kb-tag' }, selected.milestoneId),
6875
+ h('span', { className: 'rb-kb-ellipsis' }, String(selected.milestoneTitle ?? '') || t('pilot.title')))]),
6876
+ h('span', { className: 'rb-grow' }),
6877
+ onOpenStart && (selected === null || compact) ? h('button', {
6878
+ type: 'button', className: 'rb-btn', disabled: projectId == null || working, 'data-pilot-milestones': '',
6879
+ 'aria-expanded': Boolean(openStart), onClick: () => { setActionError(null); onOpenStart() },
6880
+ }, t('pilot.start')) : null,
6881
+ typeof onClose === 'function' ? h('button', {
6882
+ ref: closeButton, type: 'button', className: 'rb-btn rb-btn-icon', 'aria-label': t('pilot.close'), title: t('pilot.close'), onClick: onClose,
6883
+ }, h(Glyph, { name: 'x', size: 14 })) : null),
6884
+
6885
+ openStart ? h(PilotStartDialog, { view, projectId, pilots, busy: working, error: actionError, onStart: start, onClose: () => { startsOpen.current = false; onCloseStart?.() }, t }) : null,
6886
+ h('div', { className: 'rb-pilot-panelbody' },
6887
+ active.length > 1 || (active.length > 0 && selected !== null && !active.includes(selected)) ? h('label', { className: 'rb-pilot-field' },
6888
+ h('span', { className: 'rb-caption' }, t('pilot.pickRun')),
6889
+ h('select', { className: 'rb-select', value: selected?.id ?? '', disabled: working, onChange: event => { setActionError(null); onSelectPilot?.(event.target.value) } },
6890
+ (active.includes(selected) ? active : [selected, ...active]).map(pilot => h('option', { key: pilot.id, value: pilot.id },
6891
+ `${pilot.milestoneId} · ${pilot.milestoneTitle ?? ''}`)))) : null,
6892
+ loading && pilots.length === 0 ? h('p', { className: 'rb-notice' }, t('pilot.loading')) : null,
6893
+ selected === null && !loading ? h('p', { className: 'rb-caption' }, t('pilot.empty')) : null,
6894
+ selected === null ? null : h(PilotStrip, { key: selected.id, pilot: selected, t }),
6895
+ h(PilotSkillsPanel, { projectId, skills, error: skillsError, onOpenSettings, t }),
6896
+ h(PilotAgentsLine, { roster, onOpenSettings, t }),
6897
+ selected === null ? null : h(PilotGate, { key: `${selected.id}:${selected.phase}`, pilot: selected, project, busy: working, busyAction, onAction, footer, t }),
6898
+ h(ErrorLine, { error: (!openStart && actionError) || error, t })),
6899
+ selected === null || PILOT_FOOTLESS_STEPS.includes(selected.phase) ? null : h('footer', { className: 'rb-pilot-panelfoot' },
6900
+ h('div', { ref: setFooter, className: 'rb-pilot-footactions' }),
6901
+ h(PilotRunActions, { key: selected.id, pilot: selected, busyAction, onAction, t })))
6902
+ }
6903
+ /* ── Superpowers in Roadmap settings ────────────────────────────── */
6904
+
6905
+ function pilotSkillsStatusText(skills, t) {
6906
+ if (skills == null) return t('pilot.skills.loading')
6907
+ const count = skills.missing?.length ?? 0
6908
+ const total = skills.skills?.length ?? 0
6909
+ if (total > 0) return t('pilot.skills.count', { installed: total - count, total })
6910
+ return count ? t('pilot.skills.partial', { count }) : t('pilot.skills.installed')
6911
+ }
6912
+
6913
+ function PilotSkillsSettings({ projectId, skills, configVersion, store = null, refresh, busy = false, loadError = null, onRetry = null, roundCap = null, t }) {
6914
+ const dialog = useRef(null)
6915
+ const lock = useRef(false)
6916
+ const [working, setWorking] = useState(false)
6917
+ const [error, setError] = useState(null)
6918
+ const disabled = busy || working
6919
+ const missing = skills?.missing ?? []
6920
+ const source = skills?.source ? t('pilot.skills.source', skills.source) : null
6921
+ const run = async call => {
6922
+ if (busy || lock.current) return
6923
+ lock.current = true
6924
+ setWorking(true)
6925
+ setError(null)
6926
+ try {
6927
+ await call()
6928
+ dialog.current?.close?.()
6929
+ } catch (failure) {
6930
+ setError(failure)
6931
+ } finally {
6932
+ refresh?.()
6933
+ if (store !== null) await reloadProject(store, projectId).catch(() => {})
6934
+ lock.current = false
6935
+ setWorking(false)
6936
+ }
6045
6937
  }
6046
- const start = milestoneId => {
6047
- setBusy(true)
6048
- setActionError(null)
6049
- pilotRequests.start(projectId, milestoneId)
6050
- .then(async (result) => {
6051
- setShowStart(false)
6052
- const sessionId = result?.pilot?.sessionId
6053
- if (typeof sessionId === 'string' && typeof openChat === 'function') openChat(sessionId)
6054
- after()
6055
- }, setActionError)
6056
- .finally(() => setBusy(false))
6938
+ const open = () => {
6939
+ if (busy || lock.current || dialog.current?.open) return
6940
+ setError(null)
6941
+ dialog.current?.querySelector?.('form')?.reset()
6942
+ dialog.current?.showModal()
6943
+ }
6944
+ const cancel = () => dialog.current?.close()
6945
+ const install = event => {
6946
+ event.preventDefault()
6947
+ if (!dialog.current?.open || missing.length === 0) return
6948
+ const scope = event.currentTarget.elements.scope.value
6949
+ if (scope !== 'user' && scope !== 'project') return
6950
+ return run(() => pilotRequests.installSkills(projectId, scope, configVersion))
6951
+ }
6952
+ return h('section', { className: 'rb-settings-skills', 'data-pilot-skills': projectId },
6953
+ h('div', { className: 'rb-row rb-wrap' },
6954
+ h('div', { className: 'rb-grow' },
6955
+ h('div', { className: 'rb-label' }, t('pilot.skills.title')),
6956
+ h('p', { className: 'rb-caption' }, pilotSkillsStatusText(skills, t))),
6957
+ skills == null ? null : missing.length === 0
6958
+ ? h('input', {
6959
+ type: 'checkbox', role: 'switch', className: 'rb-settings-skills-switch', 'aria-label': t('pilot.skills.enable'),
6960
+ checked: skills.enabled === true, disabled, 'data-pilot-skills-toggle': projectId,
6961
+ onChange: event => {
6962
+ const enabled = event.target.checked
6963
+ return run(() => pilotRequests.setSkills(projectId, enabled, configVersion))
6964
+ },
6965
+ })
6966
+ : h('button', { type: 'button', className: 'rb-btn', disabled, 'aria-haspopup': 'dialog',
6967
+ 'data-pilot-skills-install-open': '', onClick: open }, t('pilot.skills.setup'))),
6968
+ source === null ? null : h('p', { className: 'rb-caption rb-mono rb-settings-skills-pin' }, source),
6969
+ skills?.installQueued ? h('p', { className: 'rb-notice', role: 'status' }, t('pilot.skills.projectQueued')) : null,
6970
+ h(ErrorLine, { error: error ?? loadError, t }),
6971
+ loadError !== null && typeof onRetry === 'function'
6972
+ ? h('button', { type: 'button', className: 'rb-btn', onClick: () => onRetry() }, t('retry'))
6973
+ : null,
6974
+ // Read-only, as in the mockup: a pilot's goal stops after this many automatic rounds.
6975
+ Number.isInteger(roundCap) ? h('div', { className: 'rb-row rb-settings-roundcap', 'data-pilot-round-cap': String(roundCap) },
6976
+ h('div', { className: 'rb-grow' },
6977
+ h('div', { className: 'rb-label' }, t('pilot.roundCap.title')),
6978
+ h('p', { className: 'rb-caption' }, t('pilot.roundCap.hint'))),
6979
+ h('code', { className: 'rb-mono' }, String(roundCap))) : null,
6980
+ h('dialog', {
6981
+ ref: dialog, id: 'pilot-skills-install', className: 'rb-settings-skills-dialog', 'aria-labelledby': 'pilot-skills-install-title',
6982
+ onBlur: event => event.stopPropagation(),
6983
+ onCancel: event => { event.preventDefault(); cancel() },
6984
+ onKeyDown: event => { event.stopPropagation() },
6985
+ }, h('form', { onSubmit: install },
6986
+ h('h4', { id: 'pilot-skills-install-title', className: 'rb-section-title' }, t('pilot.skills.confirmTitle')),
6987
+ h('p', { className: 'rb-caption' }, t('pilot.skills.confirmHint')),
6988
+ source === null ? null : h('p', { className: 'rb-settings-skills-source rb-mono' }, source),
6989
+ h('p', { className: 'rb-caption' }, t('pilot.skills.missing', { names: missing.join(', ') })),
6990
+ h('fieldset', { disabled }, ['user', 'project'].map(scope => h('label', { key: scope, className: 'rb-row' },
6991
+ h('input', { type: 'radio', name: 'scope', value: scope, defaultChecked: scope === 'user', autoFocus: scope === 'user' }),
6992
+ t(`pilot.skills.${scope}`)))),
6993
+ h(ErrorLine, { error, t }),
6994
+ h('div', { className: 'rb-row rb-settings-skills-actions' },
6995
+ h('button', { type: 'button', className: 'rb-btn', onClick: cancel,
6996
+ 'data-pilot-skills-install-cancel': '' }, t('pilot.skills.cancel')),
6997
+ h('button', { type: 'submit', className: 'rb-btn rb-btn-primary', disabled: disabled || !missing.length,
6998
+ 'data-pilot-skills-install-confirm': '' },
6999
+ t(missing.length === 1 ? 'pilot.skills.confirmOne' : 'pilot.skills.confirmMany', { count: missing.length }))))))
7000
+ }
7001
+ /* ── pilot milestone card in Running (docs/superpowers/specs/2026-12-04-pilot-running-card-design.md) ── */
7002
+
7003
+ /** Merge outcomes that send the pilot back to work. */
7004
+ const PILOT_FAILED_MERGES = ['conflict', 'check-failed', 'blocked']
7005
+ /** What a pilot teardown touches, in report order. */
7006
+ const PILOT_CLEANUP_ITEMS = ['worktree', 'branch', 'session']
7007
+ /** The card action for each gate step. */
7008
+ const PILOT_GATE_ACTION = { asking: 'answer', awaiting_approval: 'review-plan', awaiting_review: 'review-merge' }
7009
+
7010
+ /** Teardown items a done pilot kept. */
7011
+ function pilotCleanupKept(pilot) {
7012
+ return PILOT_CLEANUP_ITEMS.filter(name => pilot?.cleanup?.[name]?.state === 'kept')
7013
+ }
7014
+
7015
+ /** A done pilot whose teardown kept something that the human has not dismissed. */
7016
+ function pilotCleanupPending(pilot) {
7017
+ return pilot?.phase === 'done' && pilot.cleanup !== null && typeof pilot.cleanup === 'object'
7018
+ && (pilot.cleanup.dismissedAt ?? null) === null && pilotCleanupKept(pilot).length > 0
7019
+ }
7020
+
7021
+ /**
7022
+ * The status block of one pilot card, or null while the pilot works on its own.
7023
+ * First match wins: cleanup, input, blocked, failed merge, stopped.
7024
+ */
7025
+ function pilotCardStatus(pilot, t) {
7026
+ if (pilot === null || typeof pilot !== 'object') return null
7027
+ if (pilotCleanupPending(pilot)) {
7028
+ const why = pilotCleanupKept(pilot)
7029
+ .map(name => t(`pilot.cleanup.kept.${name}`, { reason: String(pilot.cleanup[name].message ?? '') }))
7030
+ .join('\n')
7031
+ return { kind: 'cleanup', title: t('pilot.card.cleanup'), why, action: 'retry', secondary: 'dismiss' }
6057
7032
  }
6058
- const active = pilots.filter(pilot => !['done', 'aborted'].includes(pilot.phase))
6059
- const gates = active.filter(pilot => PILOT_GATE_STEPS.includes(pilot.phase))
6060
- return h('div', { className: 'rb-pilot-root', 'data-pilot-root': projectId ?? '' },
6061
- h('div', { className: 'rb-row rb-wrap rb-pilot-actions' },
6062
- h('button', {
6063
- type: 'button', className: 'rb-btn rb-btn-primary', disabled: projectId === null, 'data-pilot-milestones': '',
6064
- 'aria-expanded': showStart, onClick: () => setShowStart(value => !value),
6065
- }, h(Glyph, { name: 'play', size: 12 }), t('pilot.button')),
7033
+ if (PILOT_GATE_STEPS.includes(pilot.phase)) {
7034
+ return { kind: 'input', title: t('pilot.card.input'), why: pilotAttentionWhy(pilot, t), action: PILOT_GATE_ACTION[pilot.phase], secondary: null }
7035
+ }
7036
+ if (pilot.phase === 'blocked') {
7037
+ return { kind: 'blocked', title: t('pilot.card.blocked'), why: String(pilot.blockerReason ?? ''), action: 'open', secondary: 'resume' }
7038
+ }
7039
+ if (pilot.phase === 'implementing' && PILOT_FAILED_MERGES.includes(pilot.lastMerge?.outcome)) {
7040
+ return { kind: 'blocked', title: t('pilot.card.mergeFailed'), why: String(pilot.lastMerge.text ?? ''), action: 'open', secondary: null }
7041
+ }
7042
+ if (pilot.phase === 'paused') {
7043
+ return { kind: 'stopped', title: t('pilot.card.stopped'), why: t('pilot.phase.paused'), action: 'resume', secondary: 'open' }
7044
+ }
7045
+ // `merging` is the board's own step: re-arming the goal there would message a session mid-merge.
7046
+ if (pilot.goalDisarmed === true && PILOT_AGENT_STEPS.includes(pilot.phase) && pilot.phase !== 'merging') {
7047
+ return { kind: 'stopped', title: t('pilot.card.stopped'), why: t('pilot.disarmed'), action: 'resume', secondary: 'open' }
7048
+ }
7049
+ return null
7050
+ }
7051
+
7052
+ /** Cleanup and the merge notice speak through these two calls, separate from the drawer's. */
7053
+ const pilotCleanupRequests = {
7054
+ retry: pilotId => request(`/pilot/runs/${encodeURIComponent(pilotId)}/cleanup`, { method: 'POST' }),
7055
+ dismiss: pilotId => request(`/pilot/runs/${encodeURIComponent(pilotId)}/cleanup/dismiss`, { method: 'POST' }),
7056
+ }
7057
+
7058
+ /** Whether a card's task list is open, per project and milestone, in this browser. */
7059
+ const PILOT_CARD_KEY = 'dsh-roadmap-board.pilot-card'
7060
+ function readPilotCardOpen(projectId, milestoneId) {
7061
+ try {
7062
+ return globalThis.localStorage?.getItem(`${PILOT_CARD_KEY}.${projectId}.${milestoneId}`) === '1'
7063
+ } catch {
7064
+ return false
7065
+ }
7066
+ }
7067
+ function writePilotCardOpen(projectId, milestoneId, open) {
7068
+ try {
7069
+ globalThis.localStorage?.setItem(`${PILOT_CARD_KEY}.${projectId}.${milestoneId}`, open ? '1' : '0')
7070
+ } catch {
7071
+ // Private mode or a full quota: the choice holds for this page only.
7072
+ }
7073
+ }
7074
+
7075
+ const PILOT_CARD_ICON = { input: 'alert', blocked: 'ban', stopped: 'flag', cleanup: 'alert' }
7076
+
7077
+ function PilotCardStatus({ status, busy = false, onAction, t }) {
7078
+ const urgent = status.kind === 'input' || status.kind === 'blocked'
7079
+ // aria-disabled, not disabled: a pressed button keeps focus while its request runs (as in the drawer).
7080
+ const button = (action, primary) => h('button', {
7081
+ type: 'button', className: `rb-btn${primary ? ' rb-btn-primary' : ''}`, 'aria-disabled': busy ? 'true' : undefined, 'data-pilot-card-action': action,
7082
+ onClick: () => { if (!busy) onAction(action) },
7083
+ }, t(`pilot.card.action.${action}`))
7084
+ return h('div', { className: `rb-pilot-card-status rb-pilot-card-status-${status.kind}`, role: urgent ? 'alert' : 'status' },
7085
+ h('strong', null, h(Glyph, { name: PILOT_CARD_ICON[status.kind], size: 12 }), status.title),
7086
+ status.why === '' ? null : h('p', { className: 'rb-pilot-card-why' }, status.why),
7087
+ h('span', { className: 'rb-row rb-wrap' },
7088
+ button(status.action, status.kind === 'input' || status.kind === 'cleanup'),
7089
+ status.secondary === null ? null : button(status.secondary, false)))
7090
+ }
7091
+
7092
+ /** One active pilot in Running: header (the expand toggle), status block, task rows, footer. */
7093
+ function PilotRunningCard({ card, selectedId = null, actions, t }) {
7094
+ const { pilot } = card
7095
+ const [stored, setStored] = useState(() => readPilotCardOpen(pilot.projectId, card.id))
7096
+ // A search opens the card for its matches; closing it then holds only for that same set of matches.
7097
+ const [closedFor, setClosedFor] = useState(null)
7098
+ const matchKey = card.matches.join(',')
7099
+ const searching = card.matches.length > 0
7100
+ const open = !card.cleanupOnly && (searching ? closedFor !== matchKey : stored)
7101
+ const status = pilotCardStatus(pilot, t)
7102
+ const percent = card.total === 0 ? 0 : Math.round((card.done / card.total) * 100)
7103
+ const listId = `rb-pilot-card-${card.id}`
7104
+ const press = action => {
7105
+ const name = Object.values(PILOT_GATE_ACTION).includes(action) ? 'open' : action
7106
+ actions?.[name]?.(pilot)
7107
+ }
7108
+ const toggle = () => {
7109
+ if (searching) {
7110
+ setClosedFor(closedFor === matchKey ? null : matchKey)
7111
+ return
7112
+ }
7113
+ const next = !stored
7114
+ writePilotCardOpen(pilot.projectId, card.id, next)
7115
+ setStored(next)
7116
+ }
7117
+ const head = [
7118
+ h('span', { key: 'top', className: 'rb-pilot-card-row' },
7119
+ h('span', { className: 'rb-kb-tag' }, card.id),
7120
+ h('span', { className: 'rb-pilot-card-kind' }, t('pilot.card.kind')),
7121
+ card.cleanupOnly ? null : h('span', { className: 'rb-pilot-card-chev' }, h(Glyph, { name: open ? 'chevronDown' : 'chevron', size: 12 }))),
7122
+ h('span', { key: 'title', className: 'rb-pilot-card-title', title: card.title }, card.title),
7123
+ card.cleanupOnly ? null : h('span', { key: 'step', className: 'rb-pilot-card-row' },
7124
+ h('span', { className: 'rb-pilot-step', 'data-pilot-step': pilot.phase },
7125
+ h('span', { className: 'rb-pilot-card-dot', 'aria-hidden': 'true' }), pilotStepLabel(pilot.phase, t)),
7126
+ h('span', { className: 'rb-caption' }, t('pilot.milestonesProgress', { done: card.done, total: card.total }))),
7127
+ card.cleanupOnly ? null : h('span', { key: 'bar', className: `rb-pilot-progress${card.provisional.length > 0 ? ' rb-pilot-card-prov' : ''}`, 'aria-hidden': 'true' },
7128
+ h('span', { style: { width: `${percent}%` } })),
7129
+ card.current === null ? null : h('span', { key: 'now', className: 'rb-caption rb-pilot-card-now' },
7130
+ t('pilot.card.now', { id: card.current.task.id, title: String(card.current.task.title ?? '') })),
7131
+ ]
7132
+ return h('article', {
7133
+ className: `rb-pilot-card ${card.swatch}${status === null ? '' : ` rb-pilot-card-${status.kind}`}`,
7134
+ 'data-pilot-card': card.id, 'aria-label': t('pilot.card.label', { id: card.id, title: card.title }),
7135
+ },
7136
+ card.cleanupOnly
7137
+ ? h('div', { className: 'rb-pilot-card-head' }, head)
7138
+ : h('button', {
7139
+ type: 'button', className: 'rb-pilot-card-head', 'aria-expanded': open, 'aria-controls': open ? listId : undefined,
7140
+ title: t('pilot.card.toggle', { id: card.id }), onClick: toggle,
7141
+ }, head),
7142
+ status === null ? null : h(PilotCardStatus, { status, busy: actions?.busy != null, onAction: press, t }),
7143
+ !open ? null : h('ul', { id: listId, className: 'rb-pilot-card-tasks' }, card.rows.map(row => {
7144
+ const id = row.task.id
7145
+ const title = String(row.task.title ?? '')
7146
+ return h('li', { key: id, className: card.matches.includes(id) ? 'rb-pilot-card-match' : undefined },
6066
7147
  h('button', {
6067
- type: 'button', className: 'rb-btn rb-btn-link', disabled: projectId === null,
6068
- 'data-pilot-skills-open': '', 'aria-expanded': showSkills, onClick: () => setShowSkills(value => !value),
6069
- }, skills === null ? t('pilot.skills.loading') : t('pilot.skills.title'))),
6070
- showStart ? h(PilotStartDialog, { view, projectId, pilots, busy, onStart: start, onClose: () => setShowStart(false), t }) : null,
6071
- loading && pilots.length === 0 ? h('p', { className: 'rb-notice' }, t('pilot.skills.loading')) : null,
6072
- active.map(pilot => h(PilotStrip, { key: `strip:${pilot.id}`, pilot, busy, onAction, t })),
6073
- gates.map(pilot => h(PilotGate, { key: `gate:${pilot.id}`, pilot, project, busy, onAction, t })),
6074
- showSkills ? h(PilotSkillsPanel, { projectId, skills, busy, onAction, t }) : null,
6075
- h(ErrorLine, { error: error ?? actionError, t }))
7148
+ type: 'button', className: 'rb-btn rb-pilot-card-taskrow', 'data-kanban-task': id,
7149
+ 'aria-current': selectedId === id ? 'true' : undefined, onClick: () => actions?.openTask?.(id),
7150
+ },
7151
+ h('span', { className: 'rb-mono' }, id),
7152
+ h('span', { className: 'rb-pilot-card-tasktitle', title }, title),
7153
+ card.provisional.includes(id)
7154
+ ? h('span', { className: 'rb-badge rb-st-done', title: t('pilot.milestonesProvisional') },
7155
+ h('span', { className: 'rb-dot', 'aria-hidden': 'true' }), t('pilot.milestoneDoneUnmerged'))
7156
+ : h(StatusBadge, { status: row.task.status, t })))
7157
+ })),
7158
+ card.cleanupOnly ? null : h('div', { className: 'rb-pilot-card-foot' },
7159
+ typeof actions?.chat === 'function'
7160
+ ? h('button', { type: 'button', className: 'rb-btn', 'data-pilot-card-action': 'chat', onClick: () => actions.chat(pilot) },
7161
+ h(Glyph, { name: 'chat', size: 12 }), t('pilot.chat'))
7162
+ : null,
7163
+ h('button', { type: 'button', className: 'rb-btn', 'data-pilot-card-action': 'open', onClick: () => actions?.open?.(pilot) }, t('pilot.card.action.open')),
7164
+ h('span', { className: 'rb-mono rb-caption rb-pilot-card-branch', title: String(pilot.branch ?? '') }, String(pilot.branch ?? ''))))
7165
+ }
7166
+
7167
+ /**
7168
+ * One notice per pilot that this board saw active and now reads as done with
7169
+ * a clean teardown. A kept item shows the cleanup card instead. Mutates `seen`.
7170
+ */
7171
+ function pilotMergeNotices(seen, pilots, t) {
7172
+ const notices = []
7173
+ for (const pilot of Array.isArray(pilots) ? pilots : []) {
7174
+ if (!['done', 'aborted'].includes(pilot?.phase)) {
7175
+ seen.add(pilot.id)
7176
+ continue
7177
+ }
7178
+ if (!seen.has(pilot.id) || pilot.phase !== 'done' || pilot.cleanup === null || typeof pilot.cleanup !== 'object') continue
7179
+ seen.delete(pilot.id)
7180
+ if (pilotCleanupKept(pilot).length > 0) continue
7181
+ const cleanup = PILOT_CLEANUP_ITEMS.map(name => t(`pilot.cleanup.${pilot.cleanup[name]?.state === 'absent' ? 'absent' : 'removed'}.${name}`)).join(', ')
7182
+ notices.push(t('pilot.card.mergedNotice', { id: pilot.milestoneId, text: String(pilot.lastMerge?.text ?? ''), cleanup }))
7183
+ }
7184
+ return notices
7185
+ }
7186
+
7187
+ /** What the Running card's buttons do on this board, plus the one-time merge notice. */
7188
+ function usePilotCardActions({ pilots, compact, projectId, onOpenFull, showPilot, openSession, openTask, refresh, setNotice, setActionError, t }) {
7189
+ const [busy, setBusy] = useState(null)
7190
+ const seen = useRef(new Set())
7191
+ useEffect(() => {
7192
+ const notices = pilotMergeNotices(seen.current, pilots, t)
7193
+ if (notices.length > 0) setNotice(notices.join('\n'))
7194
+ }, [pilots])
7195
+ const call = async (pilot, name, send) => {
7196
+ if (busy !== null) return
7197
+ setBusy(`${name}:${pilot.id}`)
7198
+ setActionError(null)
7199
+ try {
7200
+ await send(pilot.id)
7201
+ refresh()
7202
+ } catch (error) {
7203
+ setActionError(error)
7204
+ } finally {
7205
+ setBusy(null)
7206
+ }
7207
+ }
7208
+ return {
7209
+ busy,
7210
+ open: pilot => (compact ? onOpenFull?.(projectId, pilot.id) : showPilot(pilot.id)),
7211
+ openTask,
7212
+ chat: typeof openSession === 'function' ? pilot => openSession(pilot.sessionId) : undefined,
7213
+ resume: pilot => call(pilot, 'resume', pilotRequests.resume),
7214
+ retry: pilot => call(pilot, 'retry', pilotCleanupRequests.retry),
7215
+ dismiss: pilot => call(pilot, 'dismiss', pilotCleanupRequests.dismiss),
7216
+ }
6076
7217
  }
6077
7218
  /* ── Master agent pane (spec 2026-12-01-master-agent §5, docs/features/master.md) ── */
6078
7219
 
@@ -6964,20 +8105,25 @@ textarea.rb-input{min-height:54px;resize:vertical}
6964
8105
  return () => panelListeners.delete(listener)
6965
8106
  }
6966
8107
  const getPanelRequest = () => panelRequest
6967
- const openFullBoard = (projectId) => {
8108
+ let pilotRequestSerial = 0
8109
+ const openFullBoard = (projectId, pilotId) => {
6968
8110
  ctx.layout.selectPanel(PANEL_ID)
6969
8111
  rememberProject(projectId)
6970
- panelRequest = { projectId, serial: panelRequest.serial + 1 }
8112
+ panelRequest = {
8113
+ projectId,
8114
+ requestedPilot: pilotId === undefined ? null : { id: pilotId === '' ? null : pilotId, nonce: ++pilotRequestSerial },
8115
+ serial: panelRequest.serial + 1,
8116
+ }
6971
8117
  for (const notify of panelListeners) notify()
6972
8118
  }
6973
8119
  const recordManualProject = (projectId) => {
6974
8120
  if (panelRequest.projectId === null) return
6975
- panelRequest = { ...panelRequest, projectId }
8121
+ panelRequest = { ...panelRequest, projectId, requestedPilot: null }
6976
8122
  for (const notify of panelListeners) notify()
6977
8123
  }
6978
8124
  function MainBoard({ chat }) {
6979
- const { projectId, serial } = useSyncExternalStore(subscribePanel, getPanelRequest, getPanelRequest)
6980
- return h(KanbanPanel, { key: serial, requestedProject: projectId, onManualProject: recordManualProject, openSession, chat, t })
8125
+ const { projectId, requestedPilot, serial } = useSyncExternalStore(subscribePanel, getPanelRequest, getPanelRequest)
8126
+ return h(KanbanPanel, { key: serial, requestedProject: projectId, requestedPilot, onManualProject: recordManualProject, openSession, chat, t })
6981
8127
  }
6982
8128
 
6983
8129
  // Embedded task chat. `sessions` is NOT in `face.inject`: this Cordis has
@@ -7026,7 +8172,6 @@ textarea.rb-input{min-height:54px;resize:vertical}
7026
8172
  const title = typeof state.view?.title === 'string' && state.view.title !== '' ? state.view.title : t('tab.title')
7027
8173
  return h('span', { title }, '▦ ', title)
7028
8174
  }
7029
-
7030
8175
  /* ── one-pass render (the unit test drives it; also usable from a console) ── */
7031
8176
 
7032
8177
  /**
@@ -7159,9 +8304,14 @@ textarea.rb-input{min-height:54px;resize:vertical}
7159
8304
  /** M10.5 Master pane: requests, the pane, a proposal card, the built-in master model row. */
7160
8305
  masterRequests, MASTER_CHAT, masterPane: MasterPane, proposalCard: ProposalCard, masterModelRow: MasterModelRow,
7161
8306
  /** M14.5 milestone pilot: requests, the board section, gates, strip and helpers. */
7162
- pilotRequests, pilotSection: PilotBoardSection, pilotStrip: PilotStrip, pilotGate: PilotGate,
8307
+ pilotRequests, pilotStrip: PilotStrip, pilotGate: PilotGate,
7163
8308
  pilotPlanGate: PilotPlanGate, pilotReviewGate: PilotReviewGate, pilotQuestionGate: PilotQuestionGate,
7164
- pilotSkillsPanel: PilotSkillsPanel, pilotStartDialog: PilotStartDialog, pilotBranchName, pilotableMilestone, pilotRevisionDiff,
8309
+ pilotToolbar: PilotToolbar, pilotAttention: PilotAttention, pilotRunActions: PilotRunActions,
8310
+ pilotAgentsLine: PilotAgentsLine, pilotAttentionWhy, pilotSection: PilotBoardSection,
8311
+ pilotRunningCard: PilotRunningCard, pilotMergeNotices: (seen, pilots, t) => pilotMergeNotices(seen, pilots, t),
8312
+ pilotCardStatus: (pilot, t) => pilotCardStatus(pilot, t),
8313
+ pilotCleanupPending: pilot => pilotCleanupPending(pilot),
8314
+ pilotSkillsPanel: PilotSkillsPanel, pilotSkillsSettings: PilotSkillsSettings, pilotStartDialog: PilotStartDialog, pilotBranchName, pilotableMilestone, pilotRevisionDiff, pilotKeepFocus, pilotFocusLost,
7165
8315
  chatBoundary: ChatBoundary,
7166
8316
  glyphs: GLYPHS,
7167
8317
  taskConversation: TaskConversation,
@@ -7180,6 +8330,10 @@ textarea.rb-input{min-height:54px;resize:vertical}
7180
8330
  kanbanColumn: (task, index) => kanbanColumn(task, index),
7181
8331
  kanbanKeyAction: (event, state) => kanbanKeyAction(event, state),
7182
8332
  kanbanModel: (view, filters) => kanbanModel(view, filters),
8333
+ /** M16: the Done column grouped by milestone. */
8334
+ doneGroupsOf: (cards, needle) => doneGroupsOf(cards, needle),
8335
+ useDoneColumn: (query, doneCount) => useDoneColumn(query, doneCount),
8336
+ doneGroup: (props) => DoneGroup(props),
7183
8337
  kanbanColumns: () => [...KANBAN_COLUMNS],
7184
8338
  pickProject: (projects, remembered) => pickProject(projects, remembered),
7185
8339
  kanbanPanel: KanbanPanel,