fix(webui): re-derive the task status filter when the served catalog lands
This commit is contained in:
1 parent
3c6772bd2e
commit
4720757cd9
5 files changed
+123
-43
No files matched your search
Vendored
+1
-1
@@ -16,4 +16,4 @@ Defaulting to \`null\`.`),null)}function Tx(e){return Cx(e)&&!Number.isNaN(e)&&e
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:nT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>nT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=iT(c),u=e+1<n.length?iT(n[e+1]):null;if(l&&u&&aT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=iT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>nT(e)),rows:r.map(e=>e.map(e=>nT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:nT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:nT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function iT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(eT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,DT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>_j?`${n.slice(0,_j).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var yj=[`title`],bj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>HA(n.event)),a=G(()=>vj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,yj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),xj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Sj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,xj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(bj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),Cj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),wj=`archie.setup-complete.dismissed.v1`;function Tj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(wj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Ej(e=globalThis.localStorage){e?.setItem?.(wj,`1`)}var Dj={class:`text-lg font-semibold text-link`},Oj={class:`flex flex-col gap-3`},kj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},Aj=N({__name:`SetupPanel`,setup(e){let t=k(Tj(FA.value));M(FA,()=>{t.value=Tj(FA.value)});let n=G(()=>FA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Ej(),t.value=Tj(FA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,Dj,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(Cj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,Oj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,kj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>_j?`${n.slice(0,_j).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var yj=[`title`],bj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>HA(n.event)),a=G(()=>vj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,yj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),xj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Sj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,xj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(bj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),Cj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),wj=`archie.setup-complete.dismissed.v1`;function Tj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(wj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Ej(e=globalThis.localStorage){e?.setItem?.(wj,`1`)}var Dj={class:`text-lg font-semibold text-link`},Oj={class:`flex flex-col gap-3`},kj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},Aj=N({__name:`SetupPanel`,setup(e){let t=k(Tj(FA.value));M(FA,()=>{t.value=Tj(FA.value)});let n=G(()=>FA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Ej(),t.value=Tj(FA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,Dj,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(Cj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,Oj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,kj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
|
||||
@@ -1,36 +1,3 @@
|
||||
<script lang="ts">
|
||||
import { attentionStatusIds, statusIds } from "@/lib/task-meta";
|
||||
|
||||
// The vocabulary is the server catalog, not a hand-synced copy: the "needs
|
||||
// you" grouping and the set of known statuses come straight from task-meta so
|
||||
// a status added on the backend shows up here without a frontend change.
|
||||
// "needs_you" is a UI pseudo-status (work waiting on a human), so it is
|
||||
// prepended rather than stored in the catalog.
|
||||
//
|
||||
// Both are read at call time rather than captured at import. The catalog
|
||||
// arrives after this module loads, so module-level constants here would freeze
|
||||
// the defaults for the life of the process -- which is what they did, leaving
|
||||
// the task filter unable to see a served status no matter when it landed.
|
||||
export function taskStatuses(): Set<string> {
|
||||
return new Set(["needs_you", ...statusIds()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A ?status= value, kept only when the catalog knows it: the query string is
|
||||
* operator input, and an unknown status would filter the whole board away with
|
||||
* no control showing why.
|
||||
*/
|
||||
export function initialTaskFilter(requested: string | null | undefined): string {
|
||||
return requested && taskStatuses().has(requested) ? requested : "";
|
||||
}
|
||||
|
||||
export function taskMatchesStatus(task: { status?: string }, status: string): boolean {
|
||||
if (!status) return true;
|
||||
if (status === "needs_you") return attentionStatusIds().has(task.status ?? "");
|
||||
return task.status === status;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
|
||||
@@ -19,8 +19,10 @@ import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { api } from "@/lib/api";
|
||||
import { statusList } from "@/lib/task-meta";
|
||||
import { useLiveResource } from "@/stores/live-updates";
|
||||
import TaskFilters, { initialTaskFilter, taskMatchesStatus } from "./TaskFilters.vue";
|
||||
import TaskFilters from "./TaskFilters.vue";
|
||||
import { initialTaskFilter, taskMatchesStatus } from "./task-filter";
|
||||
import type { Task } from "./TaskRow.vue";
|
||||
import TaskTable from "./TaskTable.vue";
|
||||
import TasksState from "./TasksState.vue";
|
||||
@@ -50,14 +52,14 @@ const requestedTaskId = computed(() => {
|
||||
|
||||
// The filter follows the URL as well as writing to it: a dashboard link or a
|
||||
// back-button step has to move the control, not just load the page behind it.
|
||||
const status = ref(initialTaskFilter(statusQuery.value));
|
||||
watch(statusQuery, (value) => {
|
||||
status.value = initialTaskFilter(value);
|
||||
});
|
||||
// It is derived from the query rather than captured from it, because the
|
||||
// served catalog lands after this page sets up -- a drop to the freeze-dried
|
||||
// defaults here would drop a shared link to a status the server serves.
|
||||
const status = computed(() => initialTaskFilter(statusQuery.value, statusList()));
|
||||
|
||||
const visible = computed(() =>
|
||||
(tasks.value ?? []).filter((task) => {
|
||||
if (!taskMatchesStatus(task, status.value)) return false;
|
||||
if (!taskMatchesStatus(task, status.value, statusList())) return false;
|
||||
const needle = search.value.trim().toLowerCase();
|
||||
if (!needle) return true;
|
||||
return `${task.title ?? ""} ${task.repo ?? ""}`.toLowerCase().includes(needle);
|
||||
@@ -93,12 +95,13 @@ useLiveResource("tasks", () => void load(), 500);
|
||||
onMounted(load);
|
||||
|
||||
// A filter change is a query-only route change, so it must not remount the
|
||||
// list: the table keeps its identity and only its rows move. An empty status is
|
||||
// list: the table keeps its identity and only its rows move. The query is the
|
||||
// only filter state -- the control re-derives from it -- and an empty status is
|
||||
// dropped from the query rather than written as `?status=`.
|
||||
function setStatus(value: string) {
|
||||
status.value = initialTaskFilter(value);
|
||||
const requested = initialTaskFilter(value, statusList());
|
||||
const query = { ...route.query };
|
||||
if (status.value) query.status = status.value;
|
||||
if (requested) query.status = requested;
|
||||
else delete query.status;
|
||||
void router.replace({ query });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// The status vocabulary the board filters by, as pure functions of the served
|
||||
// catalog. The catalog is an argument rather than a module-level import: it
|
||||
// arrives after the app boots, so anything that captured the freeze-dried
|
||||
// defaults at import or at setup kept them for the life of the page -- which
|
||||
// is how a shared link to a served-only status filtered nothing -- and there
|
||||
// is no way to test that capture without being able to replace the catalog.
|
||||
// A caller that passes the catalog from inside a `computed` re-derives when
|
||||
// `/api/task-meta` lands.
|
||||
import type { StatusMeta } from "@/lib/task-meta";
|
||||
|
||||
// The vocabulary is the server catalog, not a hand-synced copy: the set of
|
||||
// known statuses comes straight from what the server serves, so a status added
|
||||
// on the backend shows up here without a frontend change. "needs_you" is a UI
|
||||
// pseudo-status (work waiting on a human), so it is prepended rather than
|
||||
// stored in the catalog.
|
||||
export function taskStatuses(catalog: StatusMeta[]): Set<string> {
|
||||
return new Set(["needs_you", ...catalog.map((status) => status.id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A ?status= value, kept only when the catalog knows it: the query string is
|
||||
* operator input, and an unknown status would filter the whole board away with
|
||||
* no control showing why.
|
||||
*/
|
||||
export function initialTaskFilter(requested: string | null | undefined, catalog: StatusMeta[]): string {
|
||||
return requested && taskStatuses(catalog).has(requested) ? requested : "";
|
||||
}
|
||||
|
||||
/** taskMatchesStatus reports whether a task survives the status filter. */
|
||||
export function taskMatchesStatus(
|
||||
task: { status?: string },
|
||||
status: string,
|
||||
catalog: StatusMeta[],
|
||||
): boolean {
|
||||
if (!status) return true;
|
||||
if (status === "needs_you") return catalog.some((entry) => entry.needs_you && entry.id === (task.status ?? ""));
|
||||
return task.status === status;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
import { initialTaskFilter, taskMatchesStatus, taskStatuses } from "../src/tasks/task-filter.ts";
|
||||
|
||||
const QUEUED = { id: "queued", label: "Queued", kind: "idle" };
|
||||
const WAITING = { id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true };
|
||||
const TRIAGING = { id: "triaging", label: "Triaging", kind: "info" };
|
||||
|
||||
test("only a status the served catalog knows becomes a filter", () => {
|
||||
const catalog = [QUEUED, WAITING, TRIAGING];
|
||||
const cases: Array<[string | null | undefined, string]> = [
|
||||
["queued", "queued"],
|
||||
["needs_you", "needs_you"],
|
||||
["triaging", "triaging"],
|
||||
["archived_elsewhere", ""],
|
||||
[" ", ""],
|
||||
["", ""],
|
||||
[null, ""],
|
||||
[undefined, ""],
|
||||
];
|
||||
for (const [requested, expected] of cases) {
|
||||
assert.equal(initialTaskFilter(requested, catalog), expected, JSON.stringify(requested));
|
||||
}
|
||||
});
|
||||
|
||||
test("needs_you groups exactly the statuses the catalog marks for a human", () => {
|
||||
const catalog = [QUEUED, WAITING, TRIAGING];
|
||||
assert.deepEqual([...taskStatuses(catalog)], ["needs_you", "queued", "waiting_human", "triaging"]);
|
||||
|
||||
const cases: Array<[{ status?: string }, string, boolean]> = [
|
||||
[{ status: "waiting_human" }, "needs_you", true],
|
||||
[{ status: "triaging" }, "needs_you", false],
|
||||
[{ status: "queued" }, "", true],
|
||||
[{ status: "triaging" }, "triaging", true],
|
||||
[{ status: "queued" }, "triaging", false],
|
||||
[{}, "queued", false],
|
||||
];
|
||||
for (const [task, status, expected] of cases) {
|
||||
assert.equal(taskMatchesStatus(task, status, catalog), expected, `${task.status} against ${status}`);
|
||||
}
|
||||
});
|
||||
|
||||
// The defect: the board captured the filter at setup, before loadTaskMeta()
|
||||
// replaced the freeze-dried defaults, and the only re-derivation watched the
|
||||
// query string. A status the server serves but the defaults do not know was
|
||||
// therefore dropped, and the whole board rendered in place of the shared view.
|
||||
// Deriving the filter from the catalog instead makes the late catalog a
|
||||
// re-derivation, and the served id becomes the filter without a reload.
|
||||
test("a filter is re-derived when the served catalog lands", () => {
|
||||
const catalog = ref([QUEUED]);
|
||||
const query = ref("triaging");
|
||||
const status = computed(() => initialTaskFilter(query.value, catalog.value));
|
||||
|
||||
assert.equal(status.value, "", "an id no catalog has held yet is dropped");
|
||||
catalog.value = [...catalog.value, TRIAGING];
|
||||
assert.equal(status.value, "triaging", "the served id becomes the filter once it arrives");
|
||||
query.value = "queued";
|
||||
assert.equal(status.value, "queued", "a back-button step still moves the filter");
|
||||
query.value = "";
|
||||
assert.equal(status.value, "", "clearing the query clears the filter");
|
||||
});
|
||||
|
||||
test("the task board derives its filter from the query instead of freezing it at setup", async () => {
|
||||
const page = await readFile(new URL("../src/tasks/TasksPage.vue", import.meta.url), "utf8");
|
||||
assert.match(page, /const status = computed\(\(\) => initialTaskFilter\(statusQuery\.value/);
|
||||
assert.doesNotMatch(page, /watch\(statusQuery/);
|
||||
assert.doesNotMatch(page, /status\.value = /);
|
||||
});
|
||||
Reference in new issue
Block a user