specpilot 2.18.0 → 2.19.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/README.md +4 -2
- package/dist/core/ideConfig.js +1 -1
- package/dist/core/ideConfig.js.map +1 -1
- package/dist/core/specFiles.js +7 -7
- package/dist/core/specFiles.js.map +1 -1
- package/dist/utils/mcpLocal.d.ts +1 -1
- package/dist/utils/mcpLocal.d.ts.map +1 -1
- package/dist/utils/mcpLocal.js +19 -5
- package/dist/utils/mcpLocal.js.map +1 -1
- package/dist/utils/specReader.d.ts +23 -2
- package/dist/utils/specReader.d.ts.map +1 -1
- package/dist/utils/specReader.js +71 -15
- package/dist/utils/specReader.js.map +1 -1
- package/dist/utils/specServer.d.ts.map +1 -1
- package/dist/utils/specServer.js +50 -3
- package/dist/utils/specServer.js.map +1 -1
- package/dist/utils/specValidator.d.ts +7 -0
- package/dist/utils/specValidator.d.ts.map +1 -1
- package/dist/utils/specValidator.js +42 -1
- package/dist/utils/specValidator.js.map +1 -1
- package/dist/utils/taskMover.d.ts +27 -0
- package/dist/utils/taskMover.d.ts.map +1 -1
- package/dist/utils/taskMover.js +102 -5
- package/dist/utils/taskMover.js.map +1 -1
- package/package.json +1 -1
- package/ui/app.css +17 -0
- package/ui/app.js +156 -13
- package/ui/index.html +8 -0
package/ui/app.js
CHANGED
|
@@ -189,7 +189,7 @@ function taskRow({t,i},col){
|
|
|
189
189
|
return `<div class="card"><button type="button" class="row act" data-col="${col}" data-i="${i}"${mv?' draggable="true" aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"':''}>
|
|
190
190
|
<span class="st ${DOT[col]}" aria-hidden="true"></span>
|
|
191
191
|
<div class="body"><div class="ttl clamp">${col==='completed'?`<span class="num" translate="no">${esc(t.num)}</span>`:''}<span class="id" translate="no">${mdi(t.id)}</span>${mdi(t.description)}</div></div>
|
|
192
|
-
<div class="trail">${col==='review'&&t.approved?'<span class="pill green chip">Approved</span>':''}${chev}</div>
|
|
192
|
+
<div class="trail">${chips(t)}${col==='review'&&t.approved?'<span class="pill green chip">Approved</span>':''}${chev}</div>
|
|
193
193
|
</button><button type="button" class="dots" data-menu="${col}:${i}" aria-haspopup="menu" aria-expanded="false" aria-label="Actions for ${esc(t.id)}"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-dots"/></svg></button></div>`;
|
|
194
194
|
}
|
|
195
195
|
function group(col,items){
|
|
@@ -256,7 +256,30 @@ function headingMessages(T){
|
|
|
256
256
|
`<p>Fix: edit <span class="mono" translate="no">${TASKS_FILE}</span> and turn the section into a table with ${esc(cols)} columns, one row per task, best done by your AI IDE so that every task keeps its ID and references.</p>`+
|
|
257
257
|
`<div class="actions">${openBtn}<button type="button" class="btn sm" data-prompt="${esc(prompt)}">Copy prompt</button></div></div>${x('data-hidewarn','Hide the warnings for now')}</div>`;
|
|
258
258
|
});
|
|
259
|
-
|
|
259
|
+
// BL-120: a table whose header has another column count than the lane reads
|
|
260
|
+
// BL-125: for Backlog, Current Sprint and Review the header names neither shape; it is read in the plain one
|
|
261
|
+
const TYPED_COLS='ID, Type, Priority and Description';
|
|
262
|
+
const colWarns=Object.entries(H.columnsFound||{}).map(([h,{columns:n,names:found,unread:k}])=>{
|
|
263
|
+
const lane=h.slice(3),shaped=SHAPED.some(c=>'## '+COLS[c]===h),names=H.columns[h]||['ID','Description'],m=names.length,cols=shaped?TYPED_COLS:joinAnd(names);
|
|
264
|
+
const prompt=shaped?`In ${TASKS_FILE}, turn the "${h}" section into a markdown table with ${TYPED_COLS} columns, one row per task, keeping every task's ID and text; put an existing priority into Priority as P1, P2 or P3 (high, medium, low), and move any status that says more than "open" to the start of the description, so SpecPilot's Tasks board reads it.`
|
|
265
|
+
:`In ${TASKS_FILE}, turn the "${h}" section into a markdown table with ${cols} columns, one row per task${h==='## Completed'?' (numbered from 1 with the oldest entry first)':''}, keeping every task's ID and text, so SpecPilot's Tasks board reads it.`;
|
|
266
|
+
const body=n>m?'The extra columns show inside each row\'s description.':k?`${k===1?'1 row is':k+' rows are'} listed under Rows that could not be parsed.`:'';
|
|
267
|
+
const title=shaped?`it has ${n===1?'1 column':n+' columns'}, ${esc(joinAnd(found||[]))}; the board reads ${TYPED_COLS}, or ID and Description`:`it has ${n===1?'1 column':n+' columns'}, the board reads ${m}`;
|
|
268
|
+
return `<div class="msg warn"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-warn"/></svg><div class="mb"><div class="mt"><span class="mw">Warning</span> The ${esc(lane)} lane cannot read its table: ${title}</div>`+
|
|
269
|
+
(body?`<p>${body}</p>`:'')+
|
|
270
|
+
`<p>Fix: edit <span class="mono" translate="no">${TASKS_FILE}</span> and give the table ${esc(cols)} columns, one row per task, best done by your AI IDE so that every task keeps its ID and text.</p>`+
|
|
271
|
+
`<div class="actions">${openBtn}<button type="button" class="btn sm" data-prompt="${esc(prompt)}">Copy prompt</button></div></div>${x('data-hidewarn','Hide the warnings for now')}</div>`;
|
|
272
|
+
});
|
|
273
|
+
// BL-125: the three lanes do not share one shape, so rows with a Type or Priority cannot move into the plain ones
|
|
274
|
+
const sh=H.shapes||{},plain=SHAPED.filter(c=>sh['## '+COLS[c]]==='plain').map(c=>COLS[c]);
|
|
275
|
+
const shapeWarns=plain.length&&SHAPED.some(c=>sh['## '+COLS[c]]==='typed')?[(()=>{
|
|
276
|
+
const prompt=`In ${TASKS_FILE}, give the ${joinAnd(plain)} table${plain.length===1?'':'s'} ${TYPED_COLS} columns, with empty Type and Priority cells in every row, so SpecPilot's Tasks board can move rows between lanes.`;
|
|
277
|
+
return `<div class="msg warn"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-warn"/></svg><div class="mb"><div class="mt"><span class="mw">Warning</span> Backlog, Current Sprint and Review have different table shapes</div>`+
|
|
278
|
+
`<p>${esc(joinAnd(plain))} ${plain.length===1?'has':'have'} no Type and Priority columns, so a row with a Type or Priority cannot move into ${plain.length===1?'it':'them'}.</p>`+
|
|
279
|
+
`<p>Fix: edit <span class="mono" translate="no">${TASKS_FILE}</span> and give ${plain.length===1?'that table':'those tables'} ${TYPED_COLS} columns, with empty cells in every row, best done by your AI IDE.</p>`+
|
|
280
|
+
`<div class="actions">${openBtn}<button type="button" class="btn sm" data-prompt="${esc(prompt)}">Copy prompt</button></div></div>${x('data-hidewarn','Hide the warnings for now')}</div>`;
|
|
281
|
+
})()]:[];
|
|
282
|
+
warns.push(...lineWarns,...colWarns,...shapeWarns);
|
|
260
283
|
const candidates=new Set([].concat(...Object.values(H.variants)));
|
|
261
284
|
const hidden=hiddenNotes(H.unknown.slice().sort());
|
|
262
285
|
const notes=H.unknown.filter(h=>!candidates.has(h)&&!hidden.includes(h)).map(h=>{
|
|
@@ -265,6 +288,12 @@ function headingMessages(T){
|
|
|
265
288
|
return `<div class="msg info"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-info"/></svg><div class="mb"><div class="mt"><span class="mw">Note</span> ${title}</div>`+
|
|
266
289
|
`<p>The board shows ${joinAnd(REQUIRED.map(l=>COLS[l]))}. The rows stay in tasks.md.</p><div class="actions">${openBtn}</div></div>${x(`data-hidenote="${esc(h)}"`,'Hide this note')}</div>`;
|
|
267
290
|
});
|
|
291
|
+
// BL-125 (d): every moving lane with a table is plain, so no card has Type or Priority; a note, since nothing is wrong
|
|
292
|
+
if(SHAPED.some(c=>sh['## '+COLS[c]]==='plain')&&!SHAPED.some(c=>sh['## '+COLS[c]]==='typed')&&!hidden.includes(PLAIN_NOTE)){
|
|
293
|
+
const prompt=`In ${TASKS_FILE}, give the Backlog, Current Sprint and Review tables ${TYPED_COLS} columns, with empty Type and Priority cells in every row, keeping every task's ID and text, so SpecPilot's Tasks board can show and set Type and Priority.`;
|
|
294
|
+
notes.push(`<div class="msg info"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-info"/></svg><div class="mb"><div class="mt"><span class="mw">Note</span> Type and Priority are off: Backlog, Current Sprint and Review have no Type and Priority columns</div>`+
|
|
295
|
+
`<p>Add the columns to show Priority and Type on each card and set them in the task details. Rows keep their text; each gets two empty cells.</p><div class="actions">${openBtn}<button type="button" class="btn sm" data-prompt="${esc(prompt)}">Copy prompt</button></div></div>${x(`data-hidenote="${PLAIN_NOTE}"`,'Hide this note')}</div>`);
|
|
296
|
+
}
|
|
268
297
|
const bar=warns.length&&warnHidden?`<div class="msgbar"><span>${warns.length} warning${warns.length===1?'':'s'} about tasks.md</span><button type="button" class="btn sm" data-showwarn>Show</button></div>`:'';
|
|
269
298
|
return (warnHidden?bar:warns.join(''))+notes.join('');
|
|
270
299
|
}
|
|
@@ -293,12 +322,65 @@ function openTask(col,i,quiet){
|
|
|
293
322
|
insp.innerHTML=`<div class="ih">${col==='completed'?`<span class="id" translate="no">${esc(t.num)}</span>`:''}<span class="id" translate="no">${mdi(t.id)}</span><span class="pill ${PILL[col]}">${esc(COLS[col])}</span>${col==='review'&&t.approved?'<span class="pill green">Approved</span>':''}<button type="button" class="ib x" id="inspX" aria-label="Close Details"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-x"/></svg></button></div>
|
|
294
323
|
<div class="ib2">
|
|
295
324
|
<div class="gl"><div class="gh">Description <span class="cnt" translate="no">tasks.md · ## ${esc(COLS[col])}</span></div><div class="box"><div class="desc md">${md(t.description)}</div></div></div>
|
|
296
|
-
${reason}${hist}
|
|
325
|
+
${fieldsBlock(col,t)}${reason}${hist}
|
|
297
326
|
<div class="actions"><a class="btn sm" href="${esc(editorUrl(DATA.project.root+'/.specs/planning/tasks.md',t.line))}">Open tasks.md in VS Code</a></div>
|
|
298
327
|
</div>${foot}`;
|
|
299
328
|
if(foot)bindReview(col,i);
|
|
329
|
+
bindRadios(insp,(key,btn)=>chooseField(col,i,key,btn));
|
|
300
330
|
openInsp(quiet);
|
|
301
331
|
}
|
|
332
|
+
/* ---------------- Type and Priority (BL-125) ----------------
|
|
333
|
+
A row of a typed Backlog, Current Sprint or Review table carries a Type and a Priority: chips on the card's bottom
|
|
334
|
+
line, two radio groups in the detail panel that write through POST /api/tasks/fields on choice, the same two in
|
|
335
|
+
New Task. A value outside the set is shown as written and checks no radio; a plain table has neither. */
|
|
336
|
+
const PRIORITIES=['P1','P2','P3'],TYPES=['feat','bug','chore'],SHAPED=['backlog','currentSprint','review'];
|
|
337
|
+
const PLAIN_NOTE='#plain-tables'; // the plain-tables note's key among the hidden notes: no heading starts with #
|
|
338
|
+
const shapeOf=col=>((DATA.tasks&&DATA.tasks.headings&&DATA.tasks.headings.shapes)||{})['## '+COLS[col]];
|
|
339
|
+
/* A value's colour class, shared by its chip and its chosen radio; none for a value outside the set, which stays muted. */
|
|
340
|
+
const tone=v=>[...PRIORITIES,...TYPES].includes(v)?' v-'+v.toLowerCase():'';
|
|
341
|
+
function chips(t){
|
|
342
|
+
return (t.priority?`<span class="pill chip pri${tone(t.priority)}" translate="no">${esc(t.priority)}</span>`:'')+(t.type?`<span class="pill chip ty${tone(t.type)}" translate="no">${esc(t.type)}</span>`:'');
|
|
343
|
+
}
|
|
344
|
+
/* One radio group: `id` names it (its buttons are `<id>-<value>`, `<id>-none`), `key` is the field it sets. */
|
|
345
|
+
function radios(id,key,label,vals,cur){
|
|
346
|
+
const all=[...vals,''],on=all.includes(cur||'')?(cur||''):null;
|
|
347
|
+
return `<div class="tfr"><span class="tfl" id="${id}L">${label}</span><div class="seg" role="radiogroup" aria-labelledby="${id}L" id="${id}" data-key="${key}">${all.map(v=>{const c=v===on,first=on===null&&v===all[0];
|
|
348
|
+
return `<button type="button" role="radio" id="${id}-${v||'none'}" data-v="${v}" aria-checked="${c}" tabindex="${c||first?0:-1}" class="${((c?'on':'')+tone(v)).trim()}" translate="no">${v||'None'}</button>`;}).join('')}</div></div>`;
|
|
349
|
+
}
|
|
350
|
+
function checkRadio(btn){btn.closest('[role="radiogroup"]').querySelectorAll('[role="radio"]').forEach(b=>{const c=b===btn;b.setAttribute('aria-checked',c);b.classList.toggle('on',c);b.tabIndex=c?0:-1;});}
|
|
351
|
+
/* Click chooses; arrow keys move and choose, as a radio group does. */
|
|
352
|
+
function bindRadios(root,choose){
|
|
353
|
+
root.querySelectorAll('[role="radiogroup"]').forEach(g=>{
|
|
354
|
+
const bs=[...g.querySelectorAll('[role="radio"]')];
|
|
355
|
+
bs.forEach((b,n)=>{
|
|
356
|
+
b.onclick=()=>choose(g.dataset.key,b);
|
|
357
|
+
b.onkeydown=e=>{const d={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!d||e.altKey||e.metaKey||e.ctrlKey)return;e.preventDefault();e.stopPropagation();const nb=bs[(n+d+bs.length)%bs.length];nb.focus();choose(g.dataset.key,nb);};
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function fieldsBlock(col,t){
|
|
362
|
+
if(!SHAPED.includes(col))return '';
|
|
363
|
+
if(shapeOf(col)!=='typed')return '<p class="tfnote" id="tfNote">This lane\'s table has no Type and Priority columns. Add them to set Priority and Type here.</p>';
|
|
364
|
+
if(!TOKEN)return `<div class="gl"><div class="gh">Priority and Type</div><div class="box"><p class="tfv" translate="no">Priority ${esc(t.priority||'None')} · Type ${esc(t.type||'None')}</p></div></div>`;
|
|
365
|
+
return `<div class="gl"><div class="gh">Priority and Type</div><div class="box tf" id="tfBox">${radios('tfPri','priority','Priority',PRIORITIES,t.priority)}${radios('tfType','type','Type',TYPES,t.type)}<p class="err" id="tfErr" role="alert" hidden></p></div></div>`;
|
|
366
|
+
}
|
|
367
|
+
let fielding=false;
|
|
368
|
+
async function chooseField(col,i,key,btn){
|
|
369
|
+
const t=DATA.tasks[col]&&DATA.tasks[col][i],p=PROJECT,v=btn.dataset.v;if(!t||fielding||(t[key]||'')===v)return;
|
|
370
|
+
fielding=true;checkRadio(btn);const box=$('#tfBox');if(box)box.setAttribute('aria-busy','true');
|
|
371
|
+
let r,body={};
|
|
372
|
+
try{
|
|
373
|
+
r=await fetch('/api/tasks/fields?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN,'If-Match':DATA.tasks.sha256},body:JSON.stringify({id:t.id,[key]:v})});
|
|
374
|
+
body=await r.json().catch(()=>({}));
|
|
375
|
+
}catch(e){r=null;}
|
|
376
|
+
fielding=false;
|
|
377
|
+
if(p!==PROJECT)return;
|
|
378
|
+
if(r&&r.status===200){wrote(['.specs/planning/tasks.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md']);return;} // the panel is redrawn from the file; focus stays on the chosen radio
|
|
379
|
+
if(r&&r.status===409&&body.specs)await apply(body.specs,null);
|
|
380
|
+
const k=findRow(col,t.id,i);if(k>=0&&inspOpen&&inspOpen.id===t.id)openTask(col,k,true); // the earlier choice, as the file has it
|
|
381
|
+
const e=$('#tfErr');if(e){e.textContent=!r?'The server did not answer. Nothing was changed.':body.error||`Nothing was changed (HTTP ${r.status}).`;e.hidden=false;}
|
|
382
|
+
const g='#'+(key==='priority'?'tfPri':'tfType'),f=$(`${g} [aria-checked="true"]`)||$(`${g} [role="radio"]`);if(f)f.focus();
|
|
383
|
+
}
|
|
302
384
|
/* ---------------- review (BL-113) ----------------
|
|
303
385
|
Approve appends ` Approved <date>` to the row; Send back appends ` Sent back <date>: <note>` and moves the row to the
|
|
304
386
|
top of Current Sprint; each toast's Undo sends the inverse action, which removes exactly that marker. One route,
|
|
@@ -345,7 +427,7 @@ async function review(col,i,action,extra,isUndo){
|
|
|
345
427
|
if(r.status===200){
|
|
346
428
|
const toLane=action==='sendBack'?'currentSprint':'review';
|
|
347
429
|
if(action==='sendBack'||action==='unsendBack'){lastFocus=null;closeInsp();}
|
|
348
|
-
await apply(body.specs,['.specs/planning/tasks.md']);
|
|
430
|
+
wrote(['.specs/planning/tasks.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md']);
|
|
349
431
|
const j=DATA.tasks[toLane].findIndex(x=>x.id===t.id);
|
|
350
432
|
if(action==='sendBack'||action==='unsendBack'){const el=$(`#v-board .row[data-col="${toLane}"][data-i="${j}"]`);if(el)el.focus();}
|
|
351
433
|
else{const b=$(action==='approve'?'#rvSend':'#rvApprove')||$('#inspX');if(b&&insp.classList.contains('open'))b.focus();}
|
|
@@ -598,8 +680,8 @@ document.addEventListener('keydown',e=>{
|
|
|
598
680
|
const mod=e.metaKey||e.ctrlKey;const inField=/INPUT|SELECT|TEXTAREA/.test(e.target.tagName);
|
|
599
681
|
if(mod&&e.key.toLowerCase()==='k'){e.preventDefault();palVeil.classList.contains('open')?closePal():openPal();return}
|
|
600
682
|
if(mod&&/^[1-9]$/.test(e.key)){e.preventDefault();const n=NAV[+e.key-1];if(n)go(n[0],n[1]);return}
|
|
601
|
-
if(e.key==='Escape'){if(!ideMenu.hidden){closeIde(true);return}if(!cardMenu.hidden){closeCardMenu(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();closeArchive();setNav(false);return}
|
|
602
|
-
if(inField||mod||e.altKey||!cardMenu.hidden||taskVeil.classList.contains('open')||archVeil.classList.contains('open'))return;
|
|
683
|
+
if(e.key==='Escape'){if(busyVeil.classList.contains('open')){closeBusy();return}if(!ideMenu.hidden){closeIde(true);return}if(!cardMenu.hidden){closeCardMenu(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();closeArchive();setNav(false);return}
|
|
684
|
+
if(inField||mod||e.altKey||!cardMenu.hidden||taskVeil.classList.contains('open')||archVeil.classList.contains('open')||busyVeil.classList.contains('open'))return;
|
|
603
685
|
if(e.key==='h'&&TOKEN&&!openVeil.classList.contains('open')){go('home');return;}
|
|
604
686
|
if(/^[1-9]$/.test(e.key)){const n=NAV[+e.key-1];if(n)go(n[0],n[1]);}
|
|
605
687
|
if((e.key==='j'||e.key==='k')&&curView==='board'){const rows=$$('#v-board .row[data-col]');if(!rows.length)return;let i=rows.findIndex(r=>r.dataset.col+':'+r.dataset.i===selected);i=e.key==='j'?Math.min(rows.length-1,i+1):Math.max(0,i-1);if(i<0)i=0;openTask(rows[i].dataset.col,+rows[i].dataset.i);rows[i].scrollIntoView({block:'nearest'});rows[i].focus();}
|
|
@@ -646,8 +728,15 @@ function altMove(r,e){
|
|
|
646
728
|
else if(go2)move(col,i,go2[0],go2[1]);
|
|
647
729
|
else if(e.key==='ArrowRight'&&LANES[LANES.indexOf(col)+1]==='completed')toast(COMPLETED_HINT); // D15: Alt+→ from the lane before Completed
|
|
648
730
|
}
|
|
649
|
-
async function move(col,i,toSection,toIndex,isUndo){
|
|
731
|
+
async function move(col,i,toSection,toIndex,isUndo,asked){
|
|
650
732
|
const t=DATA.tasks[col][i],p=PROJECT;if(!t||moving)return;
|
|
733
|
+
// BL-127: on a branch or while something else writes .specs/, ask first; an Undo is not asked again
|
|
734
|
+
if(!isUndo&&!asked){const s=busySignals();if(s.length)return askBusy(t,col,s,()=>{
|
|
735
|
+
if(p!==PROJECT)return; // asked for this project only
|
|
736
|
+
const k=DATA.tasks[col].findIndex(x=>x.id===t.id);
|
|
737
|
+
if(k<0){toast(`${t.id} is no longer in ## ${COLS[col]}. Nothing was moved.`);return;}
|
|
738
|
+
move(col,k,toSection,toIndex,false,true);
|
|
739
|
+
});}
|
|
651
740
|
moving=true;
|
|
652
741
|
let r,body={};
|
|
653
742
|
try{
|
|
@@ -657,7 +746,7 @@ async function move(col,i,toSection,toIndex,isUndo){
|
|
|
657
746
|
moving=false;
|
|
658
747
|
if(p!==PROJECT)return; // the page switched projects while the move was in flight
|
|
659
748
|
if(r.status===200){
|
|
660
|
-
await apply(body.specs,['.specs/planning/tasks.md']);
|
|
749
|
+
wrote(['.specs/planning/tasks.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md']);
|
|
661
750
|
const j=DATA.tasks[toSection].findIndex(x=>x.id===t.id);
|
|
662
751
|
const el=$(`#v-board .row[data-col="${toSection}"][data-i="${j}"]`);if(el)el.focus();
|
|
663
752
|
const msg=col===toSection?`${t.id} moved within ## ${COLS[col]} in planning/tasks.md`:`${t.id} moved from ## ${COLS[col]} to ## ${COLS[toSection]} in planning/tasks.md`;
|
|
@@ -668,6 +757,53 @@ async function move(col,i,toSection,toIndex,isUndo){
|
|
|
668
757
|
}else toast(body.error||`The move was not made (HTTP ${r.status}).`);
|
|
669
758
|
}
|
|
670
759
|
|
|
760
|
+
/* ---------------- work in progress (BL-127) ----------------
|
|
761
|
+
Two signals before a move or Archive: a branch other than main or master, and a .specs/ change drawn in the last
|
|
762
|
+
120 s that is not the echo of this page's own last write (same paths, the hash that write answered with). Only
|
|
763
|
+
what the page has seen counts; no git is run. */
|
|
764
|
+
const BUSY_MS=120000,busyVeil=$('#busyVeil');
|
|
765
|
+
let lastWrite=null,activity=null,busyGo=null,busyFrom=null; // activity: {p, at, paths}; busyFrom: the card's lane and ID, for focus
|
|
766
|
+
function wrote(paths,d){lastWrite={paths,sha:d&&d.tasks?d.tasks.sha256:null};}
|
|
767
|
+
function noteActivity(paths,d){
|
|
768
|
+
const sp=(paths||[]).filter(x=>x.startsWith('.specs/'));if(!sp.length)return;
|
|
769
|
+
if(lastWrite&&d.tasks&&d.tasks.sha256===lastWrite.sha&&sp.every(x=>lastWrite.paths.includes(x)))return; // our own write's echo
|
|
770
|
+
activity={p:PROJECT,at:Date.now(),paths:sp};
|
|
771
|
+
}
|
|
772
|
+
const branchOff=()=>{const b=DATA&&DATA.project&&DATA.project.branch;return b&&b!=='main'&&b!=='master'?b:null;};
|
|
773
|
+
const branchRisk=what=>`${what} is written to this branch's planning/tasks.md, so it is committed with this branch's work, and merging the branch can conflict with tasks.md changes made on the default branch.`;
|
|
774
|
+
/* `<file> changed on disk <n> seconds ago, not from this page`, or null outside the window. */
|
|
775
|
+
function recentActivity(){
|
|
776
|
+
if(!activity||activity.p!==PROJECT)return null;
|
|
777
|
+
const ms=Date.now()-activity.at;if(ms<0||ms>=BUSY_MS)return null;
|
|
778
|
+
const n=Math.floor(ms/1000),ps=activity.paths,f=ps.includes('.specs/planning/tasks.md')?'.specs/planning/tasks.md':ps[0],k=ps.length-1;
|
|
779
|
+
return `${f}${k?` and ${k} more ${k===1?'file':'files'}`:''} changed on disk ${n} ${n===1?'second':'seconds'} ago, not from this page`;
|
|
780
|
+
}
|
|
781
|
+
function busySignals(){
|
|
782
|
+
const out=[],b=branchOff(),a=recentActivity();
|
|
783
|
+
if(b)out.push(`You are on branch ${b}, not the default branch. ${branchRisk('The move')}`);
|
|
784
|
+
if(a)out.push(`${a}: an agent or editor may still be working on the specs. If it saves planning/tasks.md from a copy it read before your move, your move is lost; if it edits after, its edit can fail or land on the wrong row because the rows moved under it. Wait until it is done, or ask it to make the move.`);
|
|
785
|
+
return out;
|
|
786
|
+
}
|
|
787
|
+
function askBusy(t,col,signals,go){
|
|
788
|
+
closeCardMenu(false);hideTip();
|
|
789
|
+
busyGo=go;busyFrom={col,id:t.id};
|
|
790
|
+
$('#busyTitle').textContent=`Move ${t.id} while work is in progress?`;
|
|
791
|
+
$('#busyBody').innerHTML=signals.map(x=>`<div class="gate warn"><span class="st orange" aria-hidden="true"></span><span class="gt">${esc(x)}</span></div>`).join('');
|
|
792
|
+
busyVeil.classList.add('open');
|
|
793
|
+
setTimeout(()=>$('#busyCancel').focus(),50);
|
|
794
|
+
}
|
|
795
|
+
/* Cancel, Escape or the backdrop: nothing written, focus back on the card. */
|
|
796
|
+
function closeBusy(){
|
|
797
|
+
if(!busyVeil.classList.contains('open'))return;
|
|
798
|
+
busyVeil.classList.remove('open');busyGo=null;
|
|
799
|
+
const f=busyFrom;busyFrom=null;
|
|
800
|
+
const k=f&&DATA&&DATA.tasks&&DATA.tasks[f.col]?DATA.tasks[f.col].findIndex(x=>x.id===f.id):-1;
|
|
801
|
+
const el=k>=0&&$(`#v-board .row[data-col="${f.col}"][data-i="${k}"]`);if(el)el.focus();
|
|
802
|
+
}
|
|
803
|
+
$('#busyCancel').onclick=closeBusy;
|
|
804
|
+
busyVeil.onclick=e=>{if(e.target===busyVeil)closeBusy();};
|
|
805
|
+
$('#busyGo').onclick=()=>{const go=busyGo;busyGo=null;busyFrom=null;busyVeil.classList.remove('open');if(go)go();};
|
|
806
|
+
|
|
671
807
|
/* ---------------- new task (BL-PM-005) ----------------
|
|
672
808
|
The server appends one row, `| <ID> | <description> |`, to the chosen section and picks the ID.
|
|
673
809
|
The description goes as typed; a refusal is shown in the form with what was typed kept. */
|
|
@@ -676,7 +812,10 @@ let taskSection='backlog',adding=false,taskFrom=null; // taskFrom: the opener, a
|
|
|
676
812
|
function taskError(m){const e=$('#taskErr');e.textContent=m||'';e.hidden=!m;}
|
|
677
813
|
/* The ID the server would give now, from the last payload; a suggestion, the write picks the ID (BL-TB-05). */
|
|
678
814
|
function taskHint(){const n=DATA&&DATA.tasks&&DATA.tasks.nextIds;$('#taskNext').textContent=n?n[taskSection]:'';$('#taskNextWrap').hidden=!n;}
|
|
679
|
-
function openNewTask(section,from){if(!TOKEN||!DATA||!DATA.tasks||!ADDABLE[section])return;hideTip();taskIn.value='';taskError('');taskSection=section;taskFrom=from;$('#taskLane').textContent=COLS[section];taskHint();taskVeil.classList.add('open');setTimeout(()=>taskIn.focus(),50);}
|
|
815
|
+
function openNewTask(section,from){if(!TOKEN||!DATA||!DATA.tasks||!ADDABLE[section])return;hideTip();taskIn.value='';taskError('');taskSection=section;taskFrom=from;$('#taskLane').textContent=COLS[section];taskHint();taskFields();taskVeil.classList.add('open');setTimeout(()=>taskIn.focus(),50);}
|
|
816
|
+
/* BL-125: Priority and Type, both None, for a typed lane; nothing for a plain one. */
|
|
817
|
+
function taskFields(){const f=$('#taskFields'),typed=shapeOf(taskSection)==='typed';f.innerHTML=typed?radios('ntPri','priority','Priority',PRIORITIES,'')+radios('ntType','type','Type',TYPES,''):'';f.hidden=!typed;bindRadios(f,(key,b)=>checkRadio(b));}
|
|
818
|
+
const taskValue=id=>{const b=$(`#${id} [aria-checked="true"]`);return b?b.dataset.v:'';};
|
|
680
819
|
function focusOpener(){const b=(taskFrom&&$(taskFrom))||$('#v-board [data-add]');if(b)b.focus();}
|
|
681
820
|
function closeNewTask(){if(!taskVeil.classList.contains('open')||adding)return;taskVeil.classList.remove('open');focusOpener();}
|
|
682
821
|
async function addTask(){
|
|
@@ -686,7 +825,7 @@ async function addTask(){
|
|
|
686
825
|
adding=true;$('#taskGo').disabled=true;taskError('');
|
|
687
826
|
let r,body={};
|
|
688
827
|
try{
|
|
689
|
-
r=await fetch('/api/tasks/new?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN,'If-Match':DATA.tasks.sha256},body:JSON.stringify({description:taskIn.value,section})});
|
|
828
|
+
r=await fetch('/api/tasks/new?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN,'If-Match':DATA.tasks.sha256},body:JSON.stringify({description:taskIn.value,section,...(shapeOf(section)==='typed'?{priority:taskValue('ntPri'),type:taskValue('ntType')}:{})})});
|
|
690
829
|
body=await r.json().catch(()=>({}));
|
|
691
830
|
}catch(e){r=null;}
|
|
692
831
|
adding=false;$('#taskGo').disabled=false;
|
|
@@ -694,7 +833,7 @@ async function addTask(){
|
|
|
694
833
|
if(p!==PROJECT)return;
|
|
695
834
|
if(r.status===200){
|
|
696
835
|
taskVeil.classList.remove('open');
|
|
697
|
-
await apply(body.specs,['.specs/planning/tasks.md']);
|
|
836
|
+
wrote(['.specs/planning/tasks.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md']);
|
|
698
837
|
focusOpener(); // what closing the inspector returns to
|
|
699
838
|
openTask(section,body.index);
|
|
700
839
|
const el=$(`#v-board .row[data-col="${section}"][data-i="${body.index}"]`);if(el)el.scrollIntoView({block:'nearest'});
|
|
@@ -720,10 +859,12 @@ function archGates(){
|
|
|
720
859
|
const b=DATA.project.branch,a=DATA.tasks.archive,n=DATA.tasks.completed.length,out=[];
|
|
721
860
|
if(!b)out.push({key:'branch',text:'No git branch.'});
|
|
722
861
|
else if(b==='main'||b==='master')out.push({key:'branch',text:`On ${b}.`});
|
|
723
|
-
else out.push({key:'branch:'+b,warn:true,text:`On branch ${b}. Archive is recommended only on the default branch after merging. Archive on this branch anyway.`});
|
|
862
|
+
else out.push({key:'branch:'+b,warn:true,text:`On branch ${b}. Archive is recommended only on the default branch after merging. ${branchRisk('The archive')} Archive on this branch anyway.`});
|
|
724
863
|
if(!a.rows)out.push({key:'none',off:true,text:`Nothing to archive: ## Completed has ${n} ${n===1?'row':'rows'}, and an archive keeps the newest 20.`});
|
|
725
864
|
else if(a.lines>40)out.push({key:'limit',text:`## Completed is ${a.lines} lines, over its 40-line limit: ${a.rows} rows move, the newest 20 stay.`});
|
|
726
865
|
else out.push({key:'force',warn:true,text:`## Completed is ${a.lines} lines, within its 40-line limit. Archive ${a.rows} rows anyway; the newest 20 stay.`});
|
|
866
|
+
const act=recentActivity();
|
|
867
|
+
if(act)out.push({key:'activity',warn:true,text:`${act}: an agent or editor may still be working on the specs. If it saves planning/tasks.md from a copy it read before the archive, the archive is lost; if it edits after, its edit can fail or land on the wrong row because the rows moved under it. Archive anyway.`});
|
|
727
868
|
return out;
|
|
728
869
|
}
|
|
729
870
|
/* Draw the gates from the latest payload; a tick stays on a gate still shown under the same key (a redraw while open). */
|
|
@@ -756,7 +897,7 @@ async function archiveCompleted(){
|
|
|
756
897
|
if(p!==PROJECT)return;
|
|
757
898
|
if(r.status===200){
|
|
758
899
|
archVeil.classList.remove('open');
|
|
759
|
-
await apply(body.specs,['.specs/planning/tasks.md','.specs/planning/tasks-archive.md']);
|
|
900
|
+
wrote(['.specs/planning/tasks.md','.specs/planning/tasks-archive.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md','.specs/planning/tasks-archive.md']);
|
|
760
901
|
focusArchive();
|
|
761
902
|
toast(`Moved ${body.linesMoved} rows from ## Completed to planning/tasks-archive.md`);
|
|
762
903
|
return;
|
|
@@ -900,6 +1041,7 @@ async function redraw(paths){
|
|
|
900
1041
|
let d;const p=PROJECT;
|
|
901
1042
|
try{const r=await fetch('/api/specs?'+pq(),{cache:'no-store'});if(!r.ok)return;d=await r.json();}catch(e){return;} // server gone: keep what is shown
|
|
902
1043
|
if(p!==PROJECT)return; // switched projects meanwhile
|
|
1044
|
+
noteActivity(paths,d);
|
|
903
1045
|
// The poller's echo of a move this page just made: same tasks.md hash, nothing to redraw.
|
|
904
1046
|
if(paths&&paths.length&&paths.every(p=>p==='.specs/planning/tasks.md')&&DATA&&DATA.tasks&&d.tasks&&d.tasks.sha256===DATA.tasks.sha256)return;
|
|
905
1047
|
await apply(d,paths);document.documentElement.dataset.rev=+(document.documentElement.dataset.rev||0)+1; // live reloads drawn: the browser tests wait on it
|
|
@@ -954,6 +1096,7 @@ async function switchProject(n,keepRoute){
|
|
|
954
1096
|
}
|
|
955
1097
|
/* Draw project PROJECT from payload d: the tail of a switch, also used with the payload an open returns (BL-067). */
|
|
956
1098
|
function showProject(d,keepRoute){
|
|
1099
|
+
busyVeil.classList.remove('open');busyGo=null;busyFrom=null; // BL-127: a dialog never outlives its project
|
|
957
1100
|
Object.keys(fileCache).forEach(k=>{delete fileCache[k];});secShown.clear();
|
|
958
1101
|
DATA=d;selected=null;setRegenNote([]);
|
|
959
1102
|
renderAll();listen();
|
package/ui/index.html
CHANGED
|
@@ -241,6 +241,7 @@
|
|
|
241
241
|
<div class="sh"><div><h2 id="taskTitle">New Task · <span id="taskLane">Backlog</span></h2><p>Adds one row to <span class="mono" translate="no">planning/tasks.md</span>, as you type it. <span id="taskNextWrap" hidden>Next ID <span class="mono" id="taskNext" translate="no"></span></span></p></div></div>
|
|
242
242
|
<form class="sb" id="taskForm" autocomplete="off">
|
|
243
243
|
<div class="gl"><div class="gh"><label for="taskIn">Description</label></div><div class="box"><div class="field"><textarea id="taskIn" name="task-description" rows="3" aria-describedby="taskErr" placeholder="What needs doing"></textarea></div></div></div>
|
|
244
|
+
<div class="tf" id="taskFields" hidden></div>
|
|
244
245
|
<p class="err" id="taskErr" role="alert" hidden></p>
|
|
245
246
|
</form>
|
|
246
247
|
<div class="sf"><button type="button" class="btn" id="taskCancel">Cancel</button><button type="submit" class="btn pri" id="taskGo" form="taskForm">Add Task</button></div>
|
|
@@ -256,6 +257,13 @@
|
|
|
256
257
|
<div class="sf"><button type="button" class="btn" id="archCancel">Cancel</button><button type="submit" class="btn pri" id="archGo" form="archForm">Archive</button></div>
|
|
257
258
|
</div></div>
|
|
258
259
|
|
|
260
|
+
<!-- BUSY (BL-127): a move while on a branch or while something else writes .specs/; what could happen, Cancel or Move anyway -->
|
|
261
|
+
<div class="veil" id="busyVeil"><div class="sheet task" role="alertdialog" aria-modal="true" aria-labelledby="busyTitle" aria-describedby="busyBody" tabindex="-1">
|
|
262
|
+
<div class="sh"><div><h2 id="busyTitle">Move while work is in progress?</h2></div></div>
|
|
263
|
+
<div class="sb"><div class="gl"><div class="box" id="busyBody"></div></div></div>
|
|
264
|
+
<div class="sf"><button type="button" class="btn" id="busyCancel">Cancel</button><button type="button" class="btn pri" id="busyGo">Move anyway</button></div>
|
|
265
|
+
</div></div>
|
|
266
|
+
|
|
259
267
|
<!-- PALETTE -->
|
|
260
268
|
<div class="veil pal-veil" id="palVeil"><div class="pal"><input id="palIn" type="search" name="q" aria-label="Search views, spec files and tasks" placeholder="Jump to a view, spec file or task…" autocomplete="off" spellcheck="false"><ul id="palList"></ul></div></div>
|
|
261
269
|
<!-- CARD MENU (BL-TB-11): a task card's actions, built from the move table of /api/specs -->
|