@software-dlc/cli 0.182.3 → 0.183.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.
@@ -66,398 +66,39 @@ export function releaseSubjectOf(query) {
66
66
  return { kind: 'task', ref: value };
67
67
  return refused;
68
68
  }
69
- function viewerHtml(input) {
69
+ /**
70
+ * What '<token>/' and the shell's addresses answer, with status 503, while the React viewer is not
71
+ * built (a source checkout never built): how to build it. It reads nothing, so it has no Back link;
72
+ * the api/ routes answer meanwhile, and the next load after a build serves the viewer.
73
+ */
74
+ function notBuiltHtml(input) {
70
75
  return `<!doctype html>
71
76
  <html lang="en">
72
77
  <head>
73
78
  <meta charset="utf-8">
74
79
  <meta name="viewport" content="width=device-width,initial-scale=1">
75
- <title>SDLC Workspace Viewer</title>
80
+ <title>Not built \u00b7 SDLC Workspace Viewer</title>
76
81
  <style nonce="${input.nonce}">
77
- :root{color-scheme:dark;--bg:#0a0c10;--panel:#12161d;--line:#2a303a;--ink:#f4f1e8;--muted:#9aa3af;--lime:#b7f46b;--amber:#f2c45c;--red:#f17676;--blue:#72b7ff;--card:#0d1117;font:14px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace}
78
- *{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at 15% -10%,#1a2730 0,transparent 35%),var(--bg);color:var(--ink)}
79
- main{max-width:1280px;margin:auto;padding:42px 28px 64px}header{display:flex;justify-content:space-between;gap:24px;align-items:flex-end;margin-bottom:28px}
80
- h1{font:600 clamp(28px,5vw,54px)/.95 ui-sans-serif,system-ui;margin:0;letter-spacing:-.05em}h2{font:600 15px/1.2 ui-sans-serif,system-ui;margin:0 0 14px;text-transform:uppercase;letter-spacing:.12em;color:var(--muted)}
81
- .eyebrow{color:var(--lime);text-transform:uppercase;letter-spacing:.18em;margin-bottom:10px}.muted{color:var(--muted)}.mono{overflow-wrap:anywhere}
82
- .pulse{display:inline-block;width:9px;height:9px;border-radius:50%;background:var(--lime);box-shadow:0 0 16px var(--lime);margin-right:8px}
83
- .metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:24px}.metric,.panel{background:color-mix(in srgb,var(--panel) 92%,transparent);border:1px solid var(--line);border-radius:14px}
84
- .metric{padding:18px}.metric strong{display:block;font:600 28px/1 ui-sans-serif,system-ui;margin-top:6px}.metric span{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.09em}
85
- .layout{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(310px,.6fr);gap:16px}.panel{padding:20px;min-width:0}.span{grid-column:1/-1}
86
- .workspace{position:relative;display:grid;grid-template-columns:minmax(150px,1fr) auto;gap:12px;padding:15px 16px;margin:9px 0;border:1px solid var(--line);border-left:3px solid var(--blue);border-radius:10px;background:var(--card)}
87
- .workspace.current{border-left-color:var(--lime)}.workspace.closed{opacity:.58}.workspace small{display:block;color:var(--muted);margin-top:4px}.badges{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px;align-content:start}
88
- .badge{border:1px solid var(--line);border-radius:999px;padding:3px 8px;font-size:11px;color:var(--muted)}.good{color:var(--lime);border-color:#426026}.warn{color:var(--amber);border-color:#6b5421}.bad{color:var(--red);border-color:#693232}
89
- .info{color:var(--blue);border-color:#264a6b}.purple{color:#c69cff;border-color:#4b3a6b}.thread-line{margin:4px 0 0;overflow-wrap:anywhere}.thread-line.good{color:var(--lime)}.thread-line.warn{color:var(--amber)}.thread-line.bad{color:var(--red)}.thread-line.info{color:var(--blue)}.thread-line.purple{color:#c69cff}
90
- .event{padding:12px 0;border-top:1px solid var(--line)}.event:first-of-type{border-top:0}.event-head{display:flex;justify-content:space-between;gap:10px}.empty{color:var(--muted);padding:18px 0}
91
- dl{display:grid;grid-template-columns:max-content 1fr;gap:8px 14px;margin:0}dt{color:var(--muted)}dd{margin:0;overflow-wrap:anywhere}.error{color:var(--red)}
92
- .group{font:500 13px/1.3 ui-sans-serif,system-ui;color:var(--muted);margin:16px 0 2px}.group .count{margin-left:6px;font-size:12px}.tools{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:flex-end}
93
- .pin{font-family:inherit;font-size:11px;font-weight:500;line-height:1;min-height:22px;padding:4px 9px;border:1px solid var(--line);border-radius:6px;background:transparent;color:var(--muted);cursor:pointer}.pin:hover{background:var(--line);color:var(--ink)}.pin.on{background:var(--line);color:var(--ink)}.pin.on:hover{border-color:var(--muted)}.pin:focus-visible{outline:2px solid var(--blue);outline-offset:2px}.pin[aria-busy=true]{cursor:progress}
94
- .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}#threads-error:empty{display:none}#shell-link{margin-left:14px}
95
- a{color:var(--blue);font:inherit;text-decoration:underline;text-underline-offset:2px}a:focus-visible,.rl input:focus-visible,.rl button:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
96
- .rl h2:focus,.rl h3:focus,.rl h4:focus{outline:none}.rl h3{font:600 15px/1.3 ui-sans-serif,system-ui;margin:10px 0 6px;overflow-wrap:anywhere}.rl h3 code{color:var(--muted);margin-right:8px}.rl h3 .small{font-size:12px;font-weight:400;margin-left:4px}.rl h3>span:not(.small){font-size:14px;font-weight:400;margin-left:4px}.rl h3>span.strong{font-weight:600}.rl h3 .clip{display:inline-block;max-width:60%;vertical-align:bottom;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
97
- .rl h4{font:500 13px/1.3 ui-sans-serif,system-ui;color:var(--muted);margin:14px 0 4px}.rl h4 .count{margin-left:4px;font-size:12px}.rl code{font:inherit}
98
- .rl-terms{grid-template-columns:100px minmax(0,1fr);margin-bottom:12px}.rl-row{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:8px;row-gap:2px;margin:3px 0;min-width:0}
99
- .rl-row .tight{margin-left:-8px}.rl-row .small{font-size:12px}.rl-row .strong{font-weight:600}.rl-row .clip{flex:1 1 0;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rl-row a.clip{flex:0 1 auto;max-width:24ch}.rl-row .below{flex:0 0 100%;min-width:0;padding-left:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.in1{padding-left:12px}.in2{padding-left:24px}
100
- .rl-actions,.rl-actions form{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0}.rl label{color:var(--muted);font-size:12px;font-weight:500}
101
- .rl input{font:inherit;height:28px;width:140px;padding:0 8px;border:1px solid var(--muted);border-radius:6px;background:var(--bg);color:var(--ink)}.rl input[aria-invalid=true]{border-color:var(--red)}.rl .pin{min-height:28px}
102
- .rl-back{display:inline-block;margin-bottom:2px}#rl-lookup-error{margin-top:6px}#rl-lookup-error:empty{display:none}.rl input::placeholder{color:var(--muted)}
103
- .rl-terms dd .rl-row{margin:0}.rl-head>:last-child{flex:1 1 16ch;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rl-said:focus{outline:none}
104
- #releases-status:empty{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
105
- .wq-head{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:12px;margin-bottom:14px}.wq-head h2{margin:0}.wq-head span{font-size:12px}#queues-status:empty{display:none}
106
- .wq-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(320px,100%),1fr));gap:12px;align-items:start}
107
- .wq-card{display:flex;flex-direction:column;gap:6px;padding:14px;border:1px solid var(--line);border-radius:10px;background:var(--card);min-width:0}
108
- .wq-card h3{font:600 14px/1.3 ui-sans-serif,system-ui;margin:0}.wq-card p{margin:0;font-size:12px;overflow-wrap:anywhere}
109
- .wq-alert{border:1px solid;border-radius:8px;padding:8px 10px;background:color-mix(in srgb,currentColor 10%,transparent);font-size:12px;overflow-wrap:anywhere}.wq-alert strong{display:block;font-size:13px;font-weight:600}
110
- .wq-rows{list-style:none;margin:4px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}.wq-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:10px;align-items:start}
111
- .wq-row .pos{color:var(--muted);font-size:12px;min-width:1.2em;text-align:right}.wq-row .title{overflow-wrap:anywhere}.wq-row .detail{color:var(--muted);font-size:12px;overflow-wrap:anywhere}.wq-row .badge{min-width:4.5em;text-align:center}
112
- .tg h3.group{margin:12px 0 2px}.fold{display:inline-flex;align-items:baseline;gap:6px;font:inherit;color:inherit;background:none;border:0;padding:2px 4px;margin-left:-4px;border-radius:4px;cursor:pointer}.fold:hover{color:var(--ink)}.fold:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
113
- .tg-row{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:8px;row-gap:2px;padding-left:16px;margin:3px 0;min-width:0}.tg-row .title,.tg-row .id,.tg-row a{overflow-wrap:anywhere;min-width:0}.tg .more{padding:4px 0 4px 16px}#issues-error:empty{display:none}
114
- .rl-back[hidden]{display:none}.popout{display:inline-flex;align-items:center;justify-content:center;min-width:24px;min-height:24px;text-decoration:none;align-self:center}#whole-view{margin-bottom:14px}
115
- .issue-toolbar{display:flex;flex-direction:column;gap:8px;margin:6px 0 4px}.tb-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.issue-toolbar[hidden],.tb-row[hidden]{display:none}.tb-row.chips{column-gap:14px}
116
- .issue-toolbar input,.issue-toolbar select{font:inherit;height:28px;padding:0 8px;border:1px solid var(--muted);border-radius:6px;background:var(--bg);color:var(--ink)}.issue-toolbar input{flex:1 1 160px;min-width:0}.issue-toolbar select{min-width:140px;max-width:100%}
117
- .issue-toolbar input:focus-visible,.issue-toolbar select:focus-visible,.issue-toolbar button:focus-visible{outline:2px solid var(--blue);outline-offset:2px}.issue-toolbar input::placeholder{color:var(--muted)}
118
- .chip:not(.on):hover{background:transparent;color:var(--muted);border-color:var(--muted)}.chip[aria-disabled=true]{opacity:.5;cursor:default}.chip[aria-disabled=true]:hover{border-color:var(--line)}
119
- .one-section .metrics,.one-section .popout,.one-section .layout>section:not(.keep){display:none}
120
- @media(max-width:800px){.rl-row .clip,.rl-row .below,.rl h3 .clip,.rl-head>:last-child{white-space:normal;max-width:none}header{display:block}.metrics{grid-template-columns:repeat(2,1fr)}.layout{grid-template-columns:1fr}.wq-grid{grid-template-columns:1fr}.workspace{grid-template-columns:1fr}.badges{justify-content:flex-start}.event-head{flex-wrap:wrap}.tools{justify-content:flex-start}}
82
+ :root{color-scheme:dark;font:14px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}
83
+ body{margin:0;background:#0a0c10;color:#f4f1e8}
84
+ main{max-width:640px;margin:64px auto;padding:0 16px}
85
+ .card{background:#12161d;border:1px solid #2a303a;border-radius:14px;padding:24px}
86
+ h1{font-size:20px;line-height:1.3;font-weight:600;margin:0 0 12px}
87
+ .why{margin:0 0 12px;color:#f4f1e8}
88
+ pre{margin:0 0 12px;padding:12px;border:1px solid #2a303a;border-radius:6px;background:#1a1f27;overflow-x:auto;white-space:pre-wrap;word-break:break-word}
89
+ code{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}
90
+ p{margin:0;color:#c3c9d2}
121
91
  </style>
122
92
  </head>
123
93
  <body>
124
94
  <main>
125
- <header><div><div class="eyebrow" id="eyebrow">Local coordination</div><h1>Workspace viewer</h1></div><div class="muted"><span class="pulse"></span><span id="connection">Connecting</span>${input.shell ? '<a id="shell-link" href="../">Back to the Workspace viewer</a>' : ''}</div></header>
126
- <a class="rl-back" id="whole-view" href="./" hidden>\u2190 Whole view</a>
127
- <section class="metrics" id="metrics" aria-label="Repository summary"></section>
128
- <div class="layout">
129
- <section class="panel span" id="threads-section" aria-labelledby="threads-heading"><div class="wq-head"><h2 id="threads-heading">Threads</h2><a class="popout" href="?section=threads" target="_blank" rel="opener" aria-label="Open Threads in its own tab" title="Open Threads in its own tab">\u2197</a></div><div id="threads-line" class="muted"></div><div id="threads-error" class="error" role="alert"></div><div id="threads"></div></section>
130
- <section class="panel span tg" id="tasks" aria-labelledby="tasks-heading" hidden><div class="wq-head"><h2 id="tasks-heading">Tasks</h2><a class="popout" href="?section=tasks" target="_blank" rel="opener" aria-label="Open Tasks in its own tab" title="Open Tasks in its own tab">\u2197</a></div><div id="tasks-line" class="muted"></div><div id="tasks-body"></div></section>
131
- <section class="panel span tg" id="issues" aria-labelledby="issues-heading" hidden><div class="wq-head"><h2 id="issues-heading">Issues</h2><a class="popout" href="?section=issues" target="_blank" rel="opener" aria-label="Open Issues in its own tab" title="Open Issues in its own tab">\u2197</a></div><div id="issues-line" class="muted"></div><div class="issue-toolbar" id="issue-toolbar" hidden><div class="tb-row"><input id="issue-search" type="search" placeholder="Search issues" aria-label="Search issues" title="Search issues (/)" aria-keyshortcuts="/" autocomplete="off"><select id="issue-owner" aria-label="Filter issues by owner"></select></div><div class="tb-row chips"><div class="tb-row" role="group" aria-label="Urgency"><button type="button" class="pin chip" data-key="urgent" data-label="Urgent" title="Open issues seen on staging or production that are not flakes" aria-describedby="issue-urgent-why"></button><span class="sr-only" id="issue-urgent-why">Open issues seen on staging or production that are not flakes</span></div><div class="tb-row" role="group" aria-labelledby="issue-seen-label"><span class="muted" id="issue-seen-label">Seen on</span><button type="button" class="pin chip" data-key="local" data-label="Local"></button><button type="button" class="pin chip" data-key="staging" data-label="Staging"></button><button type="button" class="pin chip" data-key="production" data-label="Production"></button></div></div><div class="tb-row"><span id="issue-count" class="muted" role="status" aria-live="polite"></span><span id="issue-clear-row" class="tb-row" hidden><span class="muted" aria-hidden="true">\u00b7</span><button type="button" class="pin" id="issue-clear" aria-label="Clear search and filters">Clear</button></span></div></div><div id="issues-error" class="error" role="alert"></div><div id="issues-body"></div></section>
132
- <section class="panel span rl" id="releases" aria-labelledby="releases-heading" hidden><h2 id="releases-heading" tabindex="-1">Releases</h2><div id="releases-status" class="muted" role="status"></div><div id="releases-body"></div></section>
133
- <section class="panel span" id="queues" aria-labelledby="queues-heading" hidden><div class="wq-head"><h2 id="queues-heading">Work queues</h2><span id="queues-caption" class="muted"></span></div><div id="queues-status" class="muted"></div><div id="queues-body"></div></section>
134
- <section class="panel"><h2>Workspace lineage</h2><div id="workspaces"></div></section>
135
- <section class="panel"><h2>Authority &amp; resolver</h2><div id="authority"></div></section>
136
- <section class="panel span"><h2>Integration activity</h2><div id="activity"></div></section>
137
- <section class="panel span"><h2>Handoffs</h2><div id="handoffs"></div></section>
95
+ <div class="card">
96
+ <h1>The React viewer is not built</h1>
97
+ <p class="why">This sdlc has no built viewer pages, so there is nothing to show at this address. Build them:</p>
98
+ <pre><code>pnpm --dir packages/viewer-web build &amp;&amp; pnpm --dir packages/sdlc build</code></pre>
99
+ <p>Reload this page once the build ends. The viewer's api/ routes answer meanwhile.</p>
138
100
  </div>
139
101
  </main>
140
- <script nonce="${input.nonce}">
141
- const q=(id)=>document.getElementById(id);
142
- // One section on its own (sp-viewer-section): ?section=threads|tasks|issues draws the header, a link
143
- // back to the whole view and that panel alone (Issues with Releases, as sdlc view --section issues
144
- // carries the Release block); any other section draws the whole view. The whole view names its
145
- // browser tab, so a section page's task and issue ids open their subject there, keeping the section.
146
- const SECTION=(()=>{const name=new URLSearchParams(location.search).get('section');return ['threads','tasks','issues'].includes(name)?name:null})();
147
- if(SECTION){const label=SECTION[0].toUpperCase()+SECTION.slice(1);document.title=label+' \u00b7 SDLC Workspace Viewer';q('eyebrow').textContent='Local coordination \u00b7 '+label;q('whole-view').hidden=false;document.body.classList.add('one-section');
148
- for(const id of SECTION==='threads'?['threads-section']:SECTION==='tasks'?['tasks']:['issues','releases'])q(id).classList.add('keep');
149
- // A tab that was the whole view keeps its name; a section page drops it, so its ids never open in itself.
150
- if(window.name==='sdlc-viewer')window.name=''}
151
- else window.name='sdlc-viewer';
152
- // Where a section page's ids open: the whole view's tab, unless this page shows the Releases panel.
153
- const ELSEWHERE=SECTION==='threads'||SECTION==='tasks';
154
- const node=(tag,cls,text)=>{const value=document.createElement(tag);if(cls)value.className=cls;if(text!==undefined)value.textContent=String(text);return value};
155
- const short=(value)=>value?String(value).slice(0,8):'—';
156
- const badge=(text,kind)=>node('span','badge '+(kind||''),text);
157
- const empty=(text)=>node('div','empty',text);
158
- function metric(label,value){const box=node('div','metric');box.append(node('span','',label),node('strong','',value));return box}
159
- function render(data){
160
- const workspaces=data.workspaces;const queues=data.integration_queues.flatMap((queue)=>queue.entries);const blocked=queues.filter((item)=>item.entry.status.startsWith('blocked')).length;
161
- q('metrics').replaceChildren(metric('Workspaces',workspaces.length),metric('Active',workspaces.filter((item)=>item.workspace.status==='active').length),metric('Queued',queues.filter((item)=>item.entry.status==='queued').length),metric('Blocked',blocked));
162
- const byParent=new Map();for(const item of workspaces){const key=item.workspace.source_workspace_id||'root';const list=byParent.get(key)||[];list.push(item);byParent.set(key,list)}
163
- const tree=node('div');const seen=new Set();
164
- function append(item,depth){if(seen.has(item.workspace.id))return;seen.add(item.workspace.id);const w=item.workspace;const card=node('article','workspace '+(w.id===data.current_workspace_id?'current ':'')+(w.status==='closed'?'closed':''));card.style.marginLeft=Math.min(depth*22,110)+'px';const title=node('div');title.append(node('strong','mono',(w.actor_kind==='human'?'Human':'AI')+' · '+short(w.id)),node('small','mono',w.git_worktree_path));const labels=node('div','badges');labels.append(badge(w.status,w.status==='active'?'good':''));if(item.projection.status==='available')labels.append(badge(item.projection.value.projection_dirty?'dirty':'clean',item.projection.value.projection_dirty?'warn':'good'));else labels.append(badge('unreadable','bad'));if(w.id===data.current_workspace_id)labels.append(badge('current','good'));card.append(title,labels);tree.append(card);for(const child of byParent.get(w.id)||[])append(child,depth+1)}
165
- for(const root of byParent.get('root')||[])append(root,0);for(const item of workspaces)append(item,0);q('workspaces').replaceChildren(tree);
166
- const auth=node('dl');const rows=[['Workspace',short(data.authority.workspace_id)],['Actor',data.authority.actor_kind],['Own head',data.authority.local_authority.own_sdlc_head],['Source',data.authority.local_authority.source_sdlc_head],['Git refs',data.authority.local_authority.git_refs],['Remotes',data.remotes.length],['Remote transport',data.authority.remote_authority.push],['Resolver',data.resolver.configured?(data.resolver.ready?'ready':'needs attention'):'not configured']];for(const [term,value] of rows)auth.append(node('dt','',term),node('dd','mono',value));q('authority').replaceChildren(auth);
167
- const activity=node('div');for(const queue of data.integration_queues){for(const item of queue.entries){const row=node('div','event');const head=node('div','event-head');head.append(node('strong','',short(item.entry.child_workspace_id)+' → '+short(queue.coordinator_workspace_id)),badge(item.entry.status,item.entry.status==='integrated'?'good':item.entry.status==='queued'?'': 'bad'));row.append(head,node('div','muted',item.attempts.length+' merge attempt(s) · '+item.resolution_attempts.length+' resolver attempt(s)'));activity.append(row)}}for(const group of data.reconciliations){for(const item of group.attempts){const row=node('div','event');const head=node('div','event-head');head.append(node('strong','',short(item.attempt.source_workspace_id)+' ⇢ '+short(group.child_workspace_id)),badge(item.attempt.status,item.attempt.status==='reconciled'?'good':'warn'));row.append(head,node('div','muted','Source reconciliation · '+item.resolution_attempts.length+' resolver attempt(s)'));activity.append(row)}}if(!activity.childNodes.length)activity.append(empty('No integration or reconciliation attempts yet.'));q('activity').replaceChildren(activity);
168
- const handoffs=node('div');for(const item of data.handoffs){const row=node('div','event');const head=node('div','event-head');head.append(node('strong','',short(item.handoff.child_workspace_id)+' → '+short(item.handoff.source_workspace_id)),badge(item.status,item.status==='ready'?'good':item.status==='applied'?'good':'warn'));row.append(head,node('div','muted','Pinned '+short(item.handoff.child_commit_id)+' onto '+short(item.handoff.source_commit_id)));if(item.error)row.append(node('div','error',item.error));handoffs.append(row)}if(!handoffs.childNodes.length)handoffs.append(empty('No Handoffs prepared yet.'));q('handoffs').replaceChildren(handoffs);
169
- }
170
- // A snapshot read can take minutes: the next refresh waits for the one asked, never piling up.
171
- let snapshotAsked=false;
172
- async function refresh(){if(snapshotAsked)return;snapshotAsked=true;try{const response=await fetch('./api/snapshot',{cache:'no-store'});if(!response.ok)throw new Error('HTTP '+response.status);render(await response.json());q('connection').textContent='Live · refreshes every 2s'}catch(error){q('connection').textContent='Disconnected';console.error(error)}finally{snapshotAsked=false}}
173
- // A section page draws none of the snapshot's panels, so it does not read it.
174
- if(!SECTION){refresh();setInterval(refresh,2000)}
175
- // Threads: the same view sdlc view prints (terminal.js panelData), refreshed every 10s. The
176
- // threads the user pinned lead under Pinned, as on every SDLC view; each row's Pin or Unpin
177
- // posts to api/pin, which writes the store they all share.
178
- const ROLES={ok:'good',you:'warn',alert:'bad',waiting:'info',blocked:'purple',muted:'',plain:''};
179
- const ROLE=new Proxy(ROLES,{get:(map,key)=>Object.hasOwn(map,key)?map[key]:''});
180
- // focusKey: the thread whose button takes a focus nobody holds, until its save settles.
181
- // movedKey: the thread whose held button is scrolled into view, until the read after its save.
182
- let lastThreads=null;let drawn='';let canPin=false;let pinning=null;let focusKey=null;let movedKey=null;
183
- // A group's name is its label and count, as the sidebar says it; its hint is its heading's
184
- // description, beside it, never part of its name.
185
- function groupHeading(label,count,hint){const h=node('h3','group',label);h.append(node('span','count',count));h.setAttribute('aria-label',label+', '+count);if(!hint)return [h];const id='hint-'+label.toLowerCase().replace(/\\W+/g,'-');const s=node('span','sr-only',hint);s.id=id;h.setAttribute('aria-describedby',id);return [h,s]}
186
- function pinButton(t){const b=node('button','pin'+(t.pinned?' on':''),t.pinned?'Unpin':'Pin');b.type='button';b.dataset.key=t.key;b.setAttribute('aria-label',t.pinned?'Unpin '+t.title:'Pin '+t.title+' to the top');if(pinning){b.setAttribute('aria-disabled','true');if(pinning===t.key)b.setAttribute('aria-busy','true')}b.addEventListener('click',()=>{if(!pinning)pin(t.key,!t.pinned)});return b}
187
- async function pin(key,on){pinning=key;focusKey=key;movedKey=key;if(lastThreads)renderThreads(lastThreads);let failed='';try{const response=await fetch('./api/pin',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json'},body:JSON.stringify({key,on})});if(!response.ok)failed=await response.text()}catch(error){failed=error&&error.message?error.message:String(error)}pinning=null;q('threads-error').textContent=failed?'The pin was not saved: '+failed:'';
188
- // The save settled: the button is no longer busy and shows what was saved, whether or not
189
- // the read after it works.
190
- if(lastThreads){if(!failed)lastThreads={...lastThreads,threads:lastThreads.threads.map((t)=>t.key===key?{...t,pinned:on}:t)};renderThreads(lastThreads)}await refreshThreads();
191
- // The read that moves the row is done, unless another pin has started since.
192
- if(movedKey===key)movedKey=null}
193
- function renderThreads(data){
194
- lastThreads=data;
195
- // A refresh that changes nothing drawn leaves the list, and the focus in it, alone.
196
- const state=JSON.stringify([data,canPin,pinning]);if(state===drawn)return;drawn=state;
197
- q('threads-line').textContent=data.line;
198
- const list=node('div');const pinned=data.pinnedCount||0;
199
- data.threads.forEach((t,i)=>{if(pinned&&i===0)list.append(...groupHeading('Pinned',pinned,'Threads you pinned; they stay first in every order'));if(pinned&&i===pinned)list.append(...groupHeading('Other threads',data.threads.length-pinned));
200
- const row=node('div','event');row.style.marginLeft=Math.min(t.depth*22,110)+'px';const head=node('div','event-head');const tools=node('div','tools');if(canPin&&t.key&&typeof t.pinned==='boolean')tools.append(pinButton(t));
201
- // Landed work another thread's deploy carried to staging: its tag takes the status badge's
202
- // place, then the release batch checking it in that batch's role; the tags' titles follow
203
- // the summary as a line (carriedDetail), so the next step is read, not hovered.
204
- if(t.carried){tools.append(badge(t.carried,'info'));if(t.carriedBatch)tools.append(badge(t.carriedBatch.text,ROLE[t.carriedBatch.role]))}else tools.append(badge(t.status,ROLE[t.role]));head.append(node('strong','',t.title),tools);row.append(head);
205
- row.append(node('div','muted',[t.agent,t.phase,t.age,t.waitsOn?'waits on '+t.waitsOn:''].filter(Boolean).join(' · ')));
206
- if(t.summary)row.append(node('div','thread-line muted',t.summary));if(t.carriedDetail)row.append(node('div','thread-line muted',t.carriedDetail));if(t.step)row.append(node('div','thread-line muted','step: '+t.step));
207
- for(const l of t.lines)row.append(node('div','thread-line '+(ROLE[l.role]||''),(l.state==='working'?'▶ ':l.state==='prod'?'↑ ':l.state==='planned'?'○ ':'• ')+l.text));
208
- for(const h of t.holds)row.append(node('div','thread-line '+(ROLE[h.role]||''),h.text));
209
- if(t.plan)row.append(node('div','thread-line muted',t.plan));list.append(row)});
210
- if(!data.threads.length)list.append(empty('No threads at work or waiting.'));
211
- if(data.hidden)list.append(empty(data.hidden+' older thread(s) not shown; sdlc view --all lists them.'));
212
- // A redraw replaces the buttons: the button that had the focus gives it to the same thread's
213
- // new button without scrolling the page, except a pin's own button, whose thread may have
214
- // moved, which is scrolled into view. With no focus held, a pin's button takes it while its
215
- // save runs and when it settles; a later read never pulls the focus back.
216
- const active=document.activeElement;const held=active&&active.matches&&active.matches('#threads button.pin')?active.dataset.key:null;
217
- q('threads').replaceChildren(list);
218
- const key=held||focusKey;
219
- if(key){const again=[...list.querySelectorAll('button.pin')].find((b)=>b.dataset.key===key);if(again)again.focus(key===focusKey||key===movedKey?undefined:{preventScroll:true})}
220
- if(!pinning)focusKey=null}
221
- fetch('./api/pin',{method:'HEAD',cache:'no-store'}).then((response)=>{canPin=response.ok;if(canPin&&lastThreads)renderThreads(lastThreads)}).catch(()=>{});
222
- async function refreshThreads(){try{const response=await fetch('./api/threads',{cache:'no-store'});if(response.status===404){const none='The threads view needs a SoftwareDLC checkout (tools/vscode-threads); this repository has none.';q('threads-line').textContent=none;q('threads').replaceChildren();drawn='';renderGroups({},none);if(SECTION)q('connection').textContent='Live \u00b7 refreshes every 10s';return}if(!response.ok)throw new Error(await response.text());const data=await response.json();renderThreads(data);renderGroups(data);
223
- // A section page reads no snapshot, so its live line follows the threads read.
224
- if(SECTION)q('connection').textContent='Live \u00b7 refreshes every 10s'}catch(error){const cause=error&&error.message?error.message:String(error);q('threads-line').textContent='Threads unavailable: '+cause;drawn='';if(SECTION)q('connection').textContent='Disconnected';
225
- // A Tasks or Issues page with nothing drawn yet says why in its panel; one drawn keeps it.
226
- if((SECTION==='tasks'||SECTION==='issues')&&!lastGroups)renderGroups({},SECTION[0].toUpperCase()+SECTION.slice(1)+' unavailable: '+cause)}}
227
- // Tasks and Issues (sp-viewer-ti): the shared task and issue group views api/threads carries
228
- // beside the threads (terminal.js panelData's groups), so a task or an issue reads as on every
229
- // SDLC view. Each group is a disclosure, an h3 holding a button with aria-expanded, folded as the
230
- // tab folds it; a fold the reader changes is kept across refreshes. Rows act only through their
231
- // links: a web page cannot open a local session. Left out with no checkout, or view code without
232
- // the groups; a failed read keeps them as last drawn.
233
- const tgOpen=new Map();let tgDrawn='';
234
- const tgTone=(tone)=>tone==='muted'||tone==='neutral'?'muted':ROLE[tone];
235
- // Parts set apart by the gap alone run together for assistive technology, so a space separates them.
236
- function tgRow(parts){const row=node('div','tg-row');parts.forEach((part,i)=>{if(i)row.append(node('span','sr-only','\u00a0'));row.append(part)});return row}
237
- const tgSep=()=>node('span','muted','\u00b7');
238
- // A link opens its subject in the Releases panel; while that panel is off, the id is text.
239
- let rlOn=false;const tgLinks=()=>ELSEWHERE?rlOn:!q('releases').hidden;
240
- function tgLink(text,hash){if(!tgLinks())return node('span','id',text);const a=node('a','',text);a.href=(ELSEWHERE?'./':'')+hash;if(ELSEWHERE){a.target='sdlc-viewer';a.title="Opens in the viewer's tab"}return a}
241
- function tgMarks(marks,before){return marks.filter((m)=>Boolean(m.before)===before)}
242
- // An id that names a task page links to it; a wait's id (a queue or hold Needs you lists) has
243
- // none, so it is muted text, as sdlc view prints it.
244
- function taskRow(r){const parts=[RL_REF.task.test(r.id)?tgLink(r.id,'#task='+encodeURIComponent(r.id)):node('span','muted id',r.id)];for(const m of tgMarks(r.marks,true))parts.push(node('span',tgTone(m.tone),m.word));parts.push(node('span','title',r.title));
245
- if(r.owner)parts.push(tgSep(),node('span','muted',r.owner));if(r.detail)parts.push(tgSep(),node('span',tgTone(r.tone),r.detail));
246
- for(const m of tgMarks(r.marks,false))parts.push(tgSep(),node('span',tgTone(m.tone),m.word));if(r.after&&r.after.length)parts.push(tgSep(),node('span','muted','after '+r.after.join(', ')));return tgRow(parts)}
247
- // While Urgent narrows, every row it keeps reads 'urgent', as on the VS Code tab: the group view
248
- // marks only Unowned's urgent rows.
249
- function issueRow(r){const parts=[tgLink(r.issue,'#issue='+encodeURIComponent(r.issue))];const before=tgMarks(r.marks,true);
250
- if(issueFilter.urgent&&(r.match||{}).urgentAny&&!before.some((m)=>m.word==='urgent'))before.unshift({word:'urgent',tone:'alert',before:true});for(const m of before)parts.push(node('span',tgTone(m.tone),m.word));parts.push(node('span','title',r.title));
251
- if(r.detail)parts.push(tgSep(),node('span','muted',r.detail));return tgRow(parts)}
252
- function tgGroup(kind,g,row){const key=kind+':'+g.key;const open=tgOpen.has(key)?tgOpen.get(key):!g.folded;const h=node('h3','group');const b=node('button','fold');b.type='button';b.dataset.key=key;b.setAttribute('aria-expanded',String(open));b.setAttribute('aria-label',g.label+', '+g.count);
253
- const mark=node('span','',open?'\u25be':'\u25b8');mark.setAttribute('aria-hidden','true');b.append(mark,node('span','',g.label),node('span','count',g.count));b.addEventListener('click',()=>{tgOpen.set(key,!open);if(lastGroups)renderGroups(lastGroups)});h.append(b);
254
- const out=[h];if(open){for(const r of g.rows)out.push(row(r));if(g.hidden)out.push(node('div','empty more','+'+g.hidden+' more; '+(g.more||'sdlc view --all lists them.')))}return out}
255
- // A redraw gives the focus a fold button or link had to the same one in the new list.
256
- function tgDraw(id,out){const body=q(id);const active=document.activeElement;const inside=active&&body.contains(active);
257
- const held=inside?(active.dataset&&active.dataset.key?{key:active.dataset.key}:active.tagName==='A'?{href:active.getAttribute('href')}:null):null;body.replaceChildren(...out);
258
- if(held){const again=held.key?body.querySelector('button.fold[data-key="'+held.key+'"]'):[...body.querySelectorAll('a')].find((a)=>a.getAttribute('href')===held.href);if(again)again.focus({preventScroll:true})}}
259
- let lastGroups=null;
260
- // Issue search (is-viewer): the VS Code Issues tab's toolbar and rule, which the spec holds to
261
- // model.issueMatches on the desktop pane's cases (plugins/sdlc-view/hooks/issues.fixture.ts): every
262
- // word of the search, ignoring case, in the ID, title, what happens, 'you reported', the caption,
263
- // the owner and 'seen on <env>'; the owner exact, or 'none'; Urgent and Seen on narrow each other,
264
- // and the Seen on buttons widen among themselves. The controls are built once, in the page, so a
265
- // refresh never takes the typing or the focus; the search lasts while the page is open.
266
- const SEEN=['local','staging','production'];
267
- let issueFilter={search:'',owner:'any',urgent:false,seen:[]};
268
- const issueText=(i)=>{const m=i.match||{};return [i.issue,i.title,m.actual,m.yours&&'you reported',i.detail,m.owner,m.seen&&'seen on '+m.seen].filter(Boolean).join(' ').toLowerCase()};
269
- function issueBase(i){const words=issueFilter.search.toLowerCase().split(/\\s+/).filter(Boolean);if(words.length&&!words.every((w)=>issueText(i).includes(w)))return false;
270
- const by=(i.match||{}).owner;if(issueFilter.owner==='none')return !by;return issueFilter.owner==='any'||by===issueFilter.owner}
271
- const passUrgent=(i)=>!issueFilter.urgent||Boolean((i.match||{}).urgentAny);
272
- const passSeen=(i)=>!issueFilter.seen.length||issueFilter.seen.includes((i.match||{}).seen||'');
273
- const issuePasses=(i)=>issueBase(i)&&passUrgent(i)&&passSeen(i);
274
- const issueNarrowed=()=>Boolean(issueFilter.search.trim()||issueFilter.urgent||issueFilter.seen.length||issueFilter.owner!=='any');
275
- // The toolbar's counts and owners for the issues listed: each button reads what it would show
276
- // given the search, the owner and the other buttons; a chosen owner with no issues stays listed.
277
- function drawToolbar(all){
278
- const count=(key)=>key==='urgent'?all.filter((i)=>issueBase(i)&&passSeen(i)&&(i.match||{}).urgentAny).length:all.filter((i)=>issueBase(i)&&passUrgent(i)&&(i.match||{}).seen===key).length;
279
- for(const b of q('issue-toolbar').querySelectorAll('button.chip')){const key=b.dataset.key;const on=key==='urgent'?issueFilter.urgent:issueFilter.seen.includes(key);const n=count(key);
280
- const mark=node('span','',on?'\u2713 ':'');mark.setAttribute('aria-hidden','true');b.replaceChildren(mark,document.createTextNode(b.dataset.label+' '+n));
281
- b.classList.toggle('on',on);b.setAttribute('aria-pressed',String(on));if(!on&&n===0)b.setAttribute('aria-disabled','true');else b.removeAttribute('aria-disabled')}
282
- const owners=new Map();for(const i of all){const by=(i.match||{}).owner;if(by)owners.set(by,(owners.get(by)||0)+1)}
283
- if(issueFilter.owner!=='any'&&issueFilter.owner!=='none'&&!owners.has(issueFilter.owner))owners.set(issueFilter.owner,0);
284
- const options=[['any','Any owner'],['none','No owner ('+all.filter((i)=>!(i.match||{}).owner).length+')']].concat([...owners].sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0])).map(([name,n])=>[name,name+' ('+n+')']));
285
- const select=q('issue-owner');const was=JSON.stringify([...select.options].map((o)=>[o.value,o.textContent]));
286
- if(was!==JSON.stringify(options)){select.replaceChildren(...options.map(([value,label])=>{const o=node('option','',label);o.value=value;return o}))}
287
- select.value=issueFilter.owner}
288
- function searchAgain(){tgDrawn='';if(lastGroups)renderGroups(lastGroups)}
289
- q('issue-search').addEventListener('input',(event)=>{issueFilter={...issueFilter,search:event.target.value};searchAgain()});
290
- q('issue-owner').addEventListener('change',(event)=>{issueFilter={...issueFilter,owner:event.target.value};searchAgain()});
291
- for(const b of q('issue-toolbar').querySelectorAll('button.chip'))b.addEventListener('click',()=>{if(b.getAttribute('aria-disabled')==='true')return;const key=b.dataset.key;
292
- issueFilter=key==='urgent'?{...issueFilter,urgent:!issueFilter.urgent}:{...issueFilter,seen:issueFilter.seen.includes(key)?issueFilter.seen.filter((s)=>s!==key):[...issueFilter.seen,key]};searchAgain()});
293
- // Clear takes the line it sits in away, so the focus goes to the search.
294
- q('issue-clear').addEventListener('click',()=>{issueFilter={search:'',owner:'any',urgent:false,seen:[]};q('issue-search').value='';searchAgain();q('issue-search').focus()});
295
- // '/' focuses the search, as on VS Code's Issues tab: not with a modifier, not from a field, and
296
- // only while the toolbar is shown, so the browser keeps its own '/' otherwise.
297
- document.addEventListener('keydown',(event)=>{if(event.key!=='/'||event.ctrlKey||event.metaKey||event.altKey)return;const at=document.activeElement;
298
- if(at&&(at.matches('input,textarea,select')||at.isContentEditable))return;if(q('issue-toolbar').hidden||q('issues').hidden||getComputedStyle(q('issues')).display==='none')return;
299
- event.preventDefault();q('issue-search').focus();q('issue-search').select()});
300
- // why: what the Threads line says when there is no answer; on a Tasks or Issues page, whose Threads
301
- // line is not shown, the panel stays and says it in place of its groups.
302
- function renderGroups(data,why){const has=Boolean(data&&data.tasks&&data.issues);q('tasks').hidden=!has;q('issues').hidden=!has;
303
- if(!has){lastGroups=null;tgDrawn='';if(SECTION==='tasks'||SECTION==='issues'){q(SECTION).hidden=false;q(SECTION+'-line').textContent='';const error=q(SECTION+'-error');if(error)error.textContent='';
304
- q(SECTION+'-body').replaceChildren(empty(why||'This view code has no '+SECTION[0].toUpperCase()+SECTION.slice(1)+' panel; update the SoftwareDLC checkout.'))}return}lastGroups=data;
305
- // A refresh that changes nothing drawn leaves the panels, and the focus in them, alone.
306
- const state=JSON.stringify([data.tasks,data.issues,[...tgOpen],tgLinks(),issueFilter]);if(state===tgDrawn)return;tgDrawn=state;
307
- const tasks=data.tasks;q('tasks-line').textContent=tasks.open?tasks.open+' open':'';
308
- tgDraw('tasks-body',tasks.groups.length?tasks.groups.flatMap((g)=>tgGroup('task',g,taskRow)):[empty('No tasks recorded yet.')]);
309
- // An unreadable store: its error, kept in place and changed only when its words do, so a
310
- // refresh does not announce it again; no count and no groups beside it.
311
- const issues=data.issues;const error=issues.error!==undefined?'Could not read issues: '+issues.error:'';if(q('issues-error').textContent!==error)q('issues-error').textContent=error;
312
- q('issues-line').textContent=!error&&issues.open?issues.open+' open':'';
313
- // View code that gives every row and how many a group shows can be searched; older code's rows
314
- // are already cut, so it gets no toolbar.
315
- const all=error?[]:issues.groups.flatMap((g)=>g.rows);const searchable=!error&&typeof issues.shown==='number'&&all.length>0;
316
- q('issue-toolbar').hidden=!searchable;const narrowed=searchable&&issueNarrowed();if(searchable)drawToolbar(all);
317
- const matched=narrowed?issues.groups.map((g)=>({...g,rows:g.rows.filter(issuePasses)})).filter((g)=>g.rows.length):[];
318
- const words=narrowed?matched.reduce((n,g)=>n+g.rows.length,0)+' of '+all.length+' issues':'';if(q('issue-count').textContent!==words)q('issue-count').textContent=words;q('issue-clear-row').hidden=!narrowed;
319
- // Narrowed: each group with a match under its heading, every match; otherwise each group folds and
320
- // lists the rows it shows.
321
- const cap=typeof issues.shown==='number'?issues.shown:Infinity;
322
- tgDraw('issues-body',error?[]:narrowed?(matched.length?matched.flatMap((g)=>[...groupHeading(g.label,g.rows.length),...g.rows.map(issueRow)]):[empty('No issues match.')])
323
- :(issues.open?[]:[empty('No open issues.')]).concat(issues.groups.flatMap((g)=>tgGroup('issue',{...g,rows:g.rows.slice(0,cap)},issueRow))))}
324
- refreshThreads();setInterval(refreshThreads,10000);
325
- // Releases (rl-ui-viewer): release links in sdlc view's words (terminal.js releasePanelData, read
326
- // through api/release-links). The address's hash names the subject, so Back and a reload return to
327
- // it; the summary is read again every five minutes. The page adds only its chrome.
328
- const RL_REF={release:/^(candidate|v?\\d{1,4}\\.\\d{1,4}\\.\\d{1,6}(?:-[0-9A-Za-z.]{1,40})?|[a-z][a-z0-9-]{0,63})$/,planned:/^([a-z0-9][a-z0-9-]{0,63})?$/i,issue:/^iss-\\d{1,9}$/,task:/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/};
329
- // rlMove: a move whose read has not drawn yet, so the read that draws (even a later one) moves the focus.
330
- // rlAfter: the section heading a section's Try again came from, which takes the focus once it redraws.
331
- let rlSeq=0;let rlShown=null;let rlAnswer=null;let rlDrawn='';const rlOpen=new Set();let rlLookup=null;let rlMove=false;let rlAfter=null;
332
- // A task page is read from task_page.py, not the release links (tg-task-page-viewer).
333
- const rlReading=(route)=>route&&route.kind==='task'?'Reading the task\\u2026':'Reading release links\\u2026';
334
- // The subject the hash names, its query, or the hash itself when it names none.
335
- function rlRoute(){let h='';try{h=decodeURIComponent(location.hash.slice(1))}catch{return{refused:location.hash}}
336
- if(!h)return{kind:'summary',q:''};if(h==='releases')return{kind:'releases',q:'releases'};
337
- const m=/^(release|planned|issue|task)(?:=(.*))?$/.exec(h);if(!m)return{refused:location.hash};
338
- const kind=m[1];const ref=m[2]===undefined?'':m[2];
339
- if(!RL_REF[kind].test(ref)||(kind!=='planned'&&!ref))return{refused:location.hash};
340
- return{kind,ref,q:m[2]===undefined?kind:kind+'='+encodeURIComponent(ref)}}
341
- // A thread part (a Planned Release's Serving threads) links to its row in the shell's Threads;
342
- // with no shell beside this page it stays text, since this page's hash names the Releases subject.
343
- const rlTo=(p)=>p.link||(p.thread&&q('shell-link')?'../threads#thread-'+encodeURIComponent(p.thread):'');
344
- const rlIndent=(b)=>b.indent===2?'in2':b.indent?'in1':'';
345
- function rlPart(p){const to=rlTo(p);const el=to?node('a','',p.text):node(p.code?'code':'span','',p.text);if(to)el.href=to;
346
- const cls=[p.tone==='muted'?'muted':p.tone==='alert'?'error':p.tone==='ok'?'good':p.tone==='you'?'warn':'',p.small?'small':'',p.strong?'strong':'',p.clip?'clip':'',p.tight?'tight':'',p.below?'below':''].filter(Boolean).join(' ');if(cls)el.className=cls;
347
- if(p.title)el.title=p.title;if(p.note)el.append(node('span','sr-only',' ('+p.note+')'));return el}
348
- // spaced: a space between parts set apart by the gap alone, so assistive technology reads them apart.
349
- function rlRow(parts,cls,spaced){const row=node('div','rl-row'+(cls?' '+cls:''));parts.forEach((p,i)=>{if(spaced&&i)row.append(node('span','sr-only','\\u00a0'));row.append(rlPart(p))});return row}
350
- function rlBack(){const a=node('a','rl-back','\\u2190 Releases');a.href='#';return a}
351
- // A list shows its first cap rows and a Show all N button, which shows the rest in place; the
352
- // button's name adds the list it opens (context), after its visible words.
353
- function rlList(list,key,cls,context){const out=[];const all=!list.cap||rlOpen.has(key)||list.items.length<=list.cap;
354
- for(const parts of all?list.items:list.items.slice(0,list.cap))out.push(rlRow(parts,cls,list.spaced));
355
- // Shown, the first row it revealed takes the focus the button had.
356
- if(!all){const b=node('button','pin','Show all '+list.items.length);b.type='button';if(context)b.setAttribute('aria-label','Show all '+list.items.length+' \\u00b7 '+context);b.addEventListener('click',()=>{rlOpen.add(key);rlDraw(true);const row=document.querySelectorAll('#releases-body [data-list="'+key+'"]')[list.cap];if(row){row.tabIndex=-1;row.focus()}});const wrap=node('div','rl-row '+cls);wrap.append(b);out.push(wrap)}
357
- for(const el of out)el.dataset.list=key;return out}
358
- const rlWords=(parts)=>parts.map((p)=>p.text).join(' ');
359
- // The issue lookup, kept across redraws so a half-typed id survives a refresh.
360
- function rlLookupForm(){if(rlLookup)return rlLookup;const box=node('div');const row=node('div','rl-actions');const all=node('a','','All releases');all.href='#releases';
361
- const form=node('form');form.noValidate=true;const label=node('label','','Issue');label.htmlFor='rl-issue';const input=node('input');input.id='rl-issue';input.placeholder='iss-12';input.autocomplete='off';input.setAttribute('aria-label','Issue id');input.setAttribute('aria-describedby','rl-lookup-error');
362
- const show=node('button','pin','Show');show.type='submit';const error=node('div','error');error.id='rl-lookup-error';error.setAttribute('role','alert');
363
- form.append(label,input,show);row.append(all,form);box.append(row,error);
364
- form.addEventListener('submit',(event)=>{event.preventDefault();const id=input.value.trim();if(RL_REF.issue.test(id)){error.textContent='';input.removeAttribute('aria-invalid');location.hash='issue='+id}else{error.textContent='Enter an issue id, such as iss-12.';input.setAttribute('aria-invalid','true');input.focus()}});
365
- input.addEventListener('input',()=>{if(error.textContent){error.textContent='';input.removeAttribute('aria-invalid')}});return rlLookup=box}
366
- function rlSummary(panel){const out=[];if(panel.rows.length){const dl=node('dl','rl-terms');for(const r of panel.rows){const dd=node('dd');dd.append(rlRow(r.parts));dl.append(node('dt','',r.term),dd)}out.push(dl)}out.push(rlLookupForm());return out}
367
- function rlSubject(panel){const out=[rlBack()];
368
- // Words set apart by margins alone run together for assistive technology, so a space separates them.
369
- if(panel.title){const h=node('h3');h.tabIndex=-1;if(panel.title.id){h.append(node('code','',panel.title.id),document.createTextNode(' '))}h.append(document.createTextNode(panel.title.text));
370
- // A task's state, release and thread take their own row under its title, as the terminal prints
371
- // them, its state keeping the body size it asks for; other subjects' parts are captions in the h3.
372
- const head=panel.kind==='task'?node('div','rl-row rl-meta'):h;
373
- for(const p of panel.title.parts||[])head.append(document.createTextNode(' '),rlPart(head!==h?{small:true,...p}:{...p,small:true}));out.push(h);if(head!==h&&head.childNodes.length)out.push(head)}
374
- // A list's Show all is kept under its subject and its place among the lists, so a block without
375
- // lists that comes or goes (the readiness line), or lists with their own key (Known issues), leave
376
- // the others' keys as they were. section: the heading's own words, which a section's Try again
377
- // finds again to give it the focus.
378
- let heading='';let section='';let n=0;
379
- panel.blocks.forEach((b)=>{const i=b.lists?(b.key||n++):'';if(b.heading){section=b.heading;heading=b.heading+(typeof b.count==='number'?' \\u00b7 '+b.count:'');const h=node('h4','',b.heading);if(b.count!==undefined)h.append(document.createTextNode(' '),node('span','count',b.count));for(const p of b.parts||[])h.append(document.createTextNode(' '),rlPart(p));out.push(h)}
380
- // A section that could not be read: Try again reads the subject again, saying so in its place,
381
- // and the section's heading takes the focus once it redraws. Whichever read answers next draws,
382
- // even an answer equal to the last drawn, since the section no longer shows it.
383
- else if(b.retry){const at=section;const retry=node('button','pin','Try again');retry.type='button';const wrap=node('div','rl-row'+(b.indent?' in1':''));wrap.append(retry);
384
- retry.addEventListener('click',()=>{rlAfter=at;rlDrawn='';const said=node('span','muted',rlReading(rlShown));said.tabIndex=-1;wrap.replaceChildren(said);said.focus();rlLoad(false,true)});out.push(wrap)}
385
- else if(b.group){out.push(rlRow(b.group,'in1 rl-head'));b.lists.forEach((l,j)=>out.push(...rlList(l,rlShown.q+':'+i+':'+j,'in2',rlWords(b.group))))}
386
- else if(b.lists){b.lists.forEach((l,j)=>out.push(...rlList(l,rlShown.q+':'+i+':'+j,rlIndent(b),heading)))}
387
- else if(b.line)out.push(rlRow(b.line,rlIndent(b),b.spaced))});return out}
388
- // A line that says what came of a move (an unknown subject, an address that is not one): it takes
389
- // the focus, so it is what is read.
390
- function rlSaid(text){const line=node('div','muted rl-said',text);line.tabIndex=-1;return line}
391
- // Where the focus goes after a move or a retry: the subject's h3, else what was said, else Try
392
- // again, else the panel's heading.
393
- function rlFocus(){const body=q('releases-body');const after=rlAfter;rlAfter=null;
394
- const section=after?[...body.querySelectorAll('h4')].find((h)=>h.firstChild&&h.firstChild.textContent===after):null;if(section){section.tabIndex=-1;section.focus();return}
395
- (body.querySelector('h3')||body.querySelector('.rl-said')||body.querySelector('.rl-retry')||q('releases-heading')).focus()}
396
- // Draws the last answer; a refresh that changes nothing leaves the panel, and the focus in it, alone.
397
- function rlDraw(force){const route=rlShown;const answer=rlAnswer;const state=JSON.stringify([route,answer,[...rlOpen]]);if(!force&&state===rlDrawn)return false;rlDrawn=state;
398
- const body=q('releases-body');let out;
399
- // A redraw keeps the focus where it was: on the same link or button (found again by its address,
400
- // words, and place among those that share them), on the subject's h3 or the said line, or in the
401
- // lookup field, which is kept across redraws and given its focus back as it is.
402
- const active=document.activeElement;const inside=active&&body.contains(active);
403
- const same=(el)=>(x)=>x.tagName===el.tagName&&x.getAttribute('href')===el.getAttribute('href')&&x.textContent===el.textContent;
404
- const held=inside&&active.matches('a,button')?{el:active,at:[...body.querySelectorAll(active.tagName)].filter(same(active)).indexOf(active)}:null;
405
- const spot=inside&&active.matches('h3,.rl-said')?(active.matches('h3')?'h3':'.rl-said'):null;const typing=active&&active.id==='rl-issue'?active:null;
406
- if(route.refused)out=[rlBack(),rlSaid('Not a release, Planned Release, issue or task: '+route.refused)];
407
- else if(answer.unknown)out=[rlBack(),rlSaid(answer.unknown)];
408
- else if(answer.error!==undefined){const line=node('div','error',(route.kind==='task'?'The task could not be read: ':'Release links could not be read: ')+answer.error);line.setAttribute('role','alert');const retry=node('button','pin rl-retry','Try again');retry.type='button';retry.addEventListener('click',()=>rlLoad(false,true));const wrap=node('div','rl-row');wrap.append(retry);out=(route.kind==='summary'?[]:[rlBack()]).concat(line,wrap)}
409
- else out=route.kind==='summary'?rlSummary(answer.panel):rlSubject(answer.panel);
410
- body.replaceChildren(...out);
411
- if(held){const again=[...body.querySelectorAll(held.el.tagName)].filter(same(held.el))[held.at];if(again)again.focus({preventScroll:true})}
412
- if(spot){const again=body.querySelector(spot);if(again)again.focus({preventScroll:true})}
413
- if(typing&&body.contains(typing))typing.focus({preventScroll:true});
414
- return true}
415
- // Reads the subject the hash names. moved: the reader moved to it, so the focus goes with them;
416
- // retry: Try again, which says it is reading and keeps the focus in the panel.
417
- async function rlLoad(moved,retry){const route=rlRoute();const seq=++rlSeq;if(moved||retry)rlMove=true;
418
- // A move drops a section retry's focus: its heading belongs to the page it left.
419
- if(moved)rlAfter=null;
420
- // The same address shows the same thing: one the server refused stays the refused view.
421
- const first=rlShown===null||(JSON.stringify(route)!==JSON.stringify(rlShown)&&!(rlShown.refused&&rlShown.refused===location.hash));
422
- if(route.refused){rlShown=route;rlAnswer={};q('releases-status').textContent='';const drew=rlDraw(first);if(rlMove){rlMove=false;if(drew||moved)rlFocus()}return}
423
- // A cleared panel has nothing drawn: the next answer draws, even one equal to the last drawn.
424
- if(first||retry)q('releases-status').textContent=rlReading(route);
425
- if(first&&(rlShown===null||rlShown.kind!==route.kind||moved)){q('releases-body').replaceChildren();rlDrawn=''}
426
- let answer;try{const response=await fetch('./api/release-links'+(route.q?'?'+route.q:''),{cache:'no-store'});
427
- if(response.status===404){q('releases').hidden=true;if(lastGroups)renderGroups(lastGroups);return}
428
- if(response.status===400)answer={refused:true};else if(!response.ok)answer={error:await response.text()};else answer=await response.json()}
429
- catch(error){answer={error:error&&error.message?error.message:String(error)}}
430
- if(seq!==rlSeq)return;q('releases-status').textContent='';
431
- rlShown=answer.refused?{refused:location.hash}:route;rlAnswer=answer.refused?{}:answer;
432
- // The read that answers takes up a pending move or retry: it moves the focus when it drew or was
433
- // itself the move or retry, and otherwise drops it, so a later refresh never moves the focus.
434
- const drew=rlDraw(first||retry);if(rlMove){rlMove=false;if(drew||moved||retry)rlFocus()}}
435
- fetch('./api/release-links',{method:'HEAD',cache:'no-store'}).then((response)=>{if(!response.ok)return;rlOn=true;
436
- // A Threads or Tasks page shows no Releases panel: the HEAD only lets its ids link to the whole view.
437
- if(ELSEWHERE){if(lastGroups)renderGroups(lastGroups);return}
438
- q('releases').hidden=false;if(lastGroups)renderGroups(lastGroups);rlLoad(false);
439
- window.addEventListener('hashchange',()=>rlLoad(true));setInterval(()=>rlLoad(false),300000)}).catch(()=>{});
440
- // Work queues (qv-viewer): the Process tab's cards in its words (terminal.js queuePanelData, read
441
- // through api/queues every 15 s), each turn as a badge in its role. Thread titles are plain text:
442
- // the viewer has no sidebar to select a thread in. A failed read keeps the cards drawn. A staging
443
- // entry whose deploy carries member work ends its detail with what it serves (plan fea8cf22).
444
- let wqDrawn='';
445
- function wqCard(c){const card=node('section','wq-card');card.setAttribute('aria-label',c.name);card.append(node('h3','',c.name),node('p','summary '+ROLE[c.role],c.summary));
446
- if(c.alert){const a=node('div','wq-alert '+(ROLE[c.alert.role]||'bad'));a.setAttribute('role','note');a.append(node('strong','',c.alert.title));if(c.alert.text)a.append(node('div','',c.alert.text));card.append(a)}
447
- for(const t of c.captions)card.append(node('p','muted',t));if(c.empty)card.append(node('p','muted',c.empty));
448
- if(c.rows.length){const list=node('ol','wq-rows');for(const r of c.rows){const row=node('li','wq-row');const body=node('div');body.append(node('div','title',r.title));const detail=node('div','detail',r.serves?r.detail+' \\u00b7 '+r.serves:r.detail);if(r.estimateTitle){detail.title=r.estimateTitle;detail.setAttribute('aria-description',r.estimateTitle)}body.append(detail);
449
- row.append(node('span','pos',r.position),body,badge(r.turn,ROLE[r.role]));list.append(row)}card.append(list)}return card}
450
- function wqDraw(data){const state=JSON.stringify(data);if(state===wqDrawn)return;wqDrawn=state;q('queues-caption').textContent=data.caption;
451
- if(data.state==='unreadable'){const line=node('div','error','Queue records could not be read: '+data.error);line.setAttribute('role','alert');q('queues-body').replaceChildren(line);return}
452
- const grid=node('div','wq-grid');for(const c of data.cards)grid.append(wqCard(c));q('queues-body').replaceChildren(grid)}
453
- async function refreshQueues(){try{const response=await fetch('./api/queues',{cache:'no-store'});if(response.status===404){q('queues').hidden=true;return false}if(!response.ok)throw new Error(await response.text());
454
- const data=await response.json();q('queues').hidden=false;q('queues-status').textContent='';wqDraw(data);return true}
455
- catch(error){q('queues').hidden=false;q('queues-status').textContent='Work queues unavailable: '+(error&&error.message?error.message:error);return true}}
456
- // Every 15 s while the page is visible (a hidden tab asks for nothing, as each read blocks the
457
- // viewer for about two seconds), and at once when it is shown again.
458
- if(!SECTION)refreshQueues().then((on)=>{if(!on)return;setInterval(()=>{if(document.visibilityState!=='hidden')refreshQueues()},15000);
459
- document.addEventListener('visibilitychange',()=>{if(document.visibilityState==='visible')refreshQueues()})});
460
- </script>
461
102
  </body>
462
103
  </html>`;
463
104
  }
@@ -631,8 +272,8 @@ export async function startLocalWorkspaceViewer(input) {
631
272
  let exact_origin = '';
632
273
  let exact_host = '';
633
274
  const root_path = `/${token}/`;
634
- // The classic page under the React shell; its relative api/ reads arrive under it too.
635
- const classic_path = `${root_path}classic/`;
275
+ // The retired classic page's address (la-retire-viewer), which redirects to the shell.
276
+ const classic_path = `${root_path}classic`;
636
277
  const assets_path = `${root_path}assets/`;
637
278
  const isShellPath = (path) => path.startsWith(root_path) && isShellAddress(path.slice(root_path.length));
638
279
  const api_path = `${root_path}api/snapshot`;
@@ -1086,10 +727,7 @@ export async function startLocalWorkspaceViewer(input) {
1086
727
  return;
1087
728
  }
1088
729
  const url = new URL(request.url ?? '/', exact_origin);
1089
- // The classic page under the React shell reads its api/ routes relative to classic/.
1090
- const path = url.pathname.startsWith(`${classic_path}api/`)
1091
- ? root_path + url.pathname.slice(classic_path.length)
1092
- : url.pathname;
730
+ const path = url.pathname;
1093
731
  if (path === pin_path && input.pin) {
1094
732
  if (writes)
1095
733
  await answerPin(request, response, input.pin);
@@ -1166,49 +804,38 @@ export async function startLocalWorkspaceViewer(input) {
1166
804
  reject(response, 405, 'Method not allowed.');
1167
805
  return;
1168
806
  }
1169
- // The classic page's own address ends with a slash, so its relative reads resolve under it.
1170
- if (path === classic_path.slice(0, -1)) {
1171
- redirect(response, classic_path + url.search);
807
+ // The retired classic page (classic, classic/) and the older section addresses
808
+ // ('<token>/?section=tasks') redirect to the shell: a section to its own address, which the shell
809
+ // forwards to its place, anything else to '<token>/'. A classic hash (#task=, #issue=,
810
+ // #release=, #planned, #releases) rides the redirect and the shell forwards it.
811
+ const section = url.searchParams.get('section');
812
+ if (path === classic_path || path === `${classic_path}/` || (path === root_path && section !== null)) {
813
+ redirect(response, section !== null && EARLIER_SECTIONS.has(section) ? root_path + section : root_path);
1172
814
  return;
1173
815
  }
1174
- if (bundle_index !== null) {
1175
- // An older section address ('<token>/?section=tasks') opens that section in the classic page,
1176
- // except Issues: the shell forwards '?section=issues' to the project's Issues page (la-issues).
1177
- const section = url.searchParams.get('section');
1178
- if (path === root_path && section !== null && section !== 'issues') {
1179
- redirect(response, classic_path + url.search);
1180
- return;
1181
- }
1182
- // The React shell answers the shell's addresses (isShellAddress's allow-list); with no
1183
- // bundle built, '<token>/' is the classic page as before. The classic page is always at classic/.
1184
- if (isShellPath(path)) {
1185
- // Read on each request, so a rebuild while the viewer runs serves the index that names its
1186
- // new assets; the one read at start answers only while a rebuild is replacing the directory.
1187
- const index = (await readBundleIndex(bundle)) ?? bundle_index;
1188
- // The page's relative addresses (its assets, api/ reads and links) resolve from the token
1189
- // path at every depth, so org/<org>/threads reads the same api/threads as '<token>/'.
1190
- // First in the document, before any element that uses an address.
1191
- const page = index.replace(/^(\s*<!doctype html>)?/i, `$1<base href="${root_path}">`);
1192
- secureHeaders({ response, nonce, content_type: 'text/html; charset=utf-8', bundle: true });
1193
- response.statusCode = 200;
1194
- response.end(request.method === 'HEAD' ? undefined : page);
816
+ // The React shell answers the shell's addresses (isShellAddress's allow-list).
817
+ if (isShellPath(path)) {
818
+ // Read on each request, so a rebuild while the viewer runs serves the index that names its
819
+ // new assets; the one read at start answers only while a rebuild is replacing the directory.
820
+ const index = (await readBundleIndex(bundle)) ?? bundle_index;
821
+ if (index === null) {
822
+ // Never built: how to build it, until a build lands and the next load serves the viewer.
823
+ secureHeaders({ response, nonce, content_type: 'text/html; charset=utf-8' });
824
+ response.statusCode = 503;
825
+ response.end(request.method === 'HEAD' ? undefined : notBuiltHtml({ nonce }));
1195
826
  return;
1196
827
  }
1197
- }
1198
- if (path === root_path || path === classic_path) {
1199
- secureHeaders({
1200
- response,
1201
- nonce,
1202
- content_type: 'text/html; charset=utf-8'
1203
- });
1204
- // Under classic/ beside the React shell, its header links back to the shell.
1205
- const body = viewerHtml({ nonce, shell: bundle_index !== null && path === classic_path });
828
+ // The page's relative addresses (its assets, api/ reads and links) resolve from the token
829
+ // path at every depth, so org/<org>/threads reads the same api/threads as '<token>/'.
830
+ // First in the document, before any element that uses an address.
831
+ const page = index.replace(/^(\s*<!doctype html>)?/i, `$1<base href="${root_path}">`);
832
+ secureHeaders({ response, nonce, content_type: 'text/html; charset=utf-8', bundle: true });
1206
833
  response.statusCode = 200;
1207
- response.end(request.method === 'HEAD' ? undefined : body);
834
+ response.end(request.method === 'HEAD' ? undefined : page);
1208
835
  return;
1209
836
  }
1210
837
  // The bundle's files: one name under assets/, of a known type, read from that directory only.
1211
- if (bundle && bundle_index !== null && path.startsWith(assets_path)) {
838
+ if (bundle && path.startsWith(assets_path)) {
1212
839
  const name = path.slice(assets_path.length);
1213
840
  const type = ASSET_TYPES[extname(name)];
1214
841
  if (!ASSET_NAME.test(name) || name.includes('..') || !type) {
@@ -1400,7 +1027,7 @@ export async function startLocalWorkspaceViewer(input) {
1400
1027
  url: `${exact_origin}${root_path}`,
1401
1028
  origin: exact_origin,
1402
1029
  port: address.port,
1403
- page: bundle_index === null ? 'classic' : 'react',
1030
+ built: bundle_index !== null,
1404
1031
  close: () => new Promise((resolve_close, reject_close) => {
1405
1032
  if (!server.listening) {
1406
1033
  resolve_close();