@estiva-app/interop 0.101.1 → 0.102.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/interop",
3
- "version": "0.101.1",
3
+ "version": "0.102.1",
4
4
  "description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -46,6 +46,8 @@ export {
46
46
  isArchived,
47
47
  archivedAncestorOf,
48
48
  isClosedStatus,
49
+ progressOf,
50
+ type Stage,
49
51
  archiveImpact,
50
52
  type Archive,
51
53
  type ArchiveImpact,
package/src/projection.ts CHANGED
@@ -2336,6 +2336,12 @@ export const BODY_SLOT = 'body'
2336
2336
  /** The slot that is a file's summary, one line of plain text (SPEC §7.2). */
2337
2337
  const SUBTITLE_SLOT = 'subtitle'
2338
2338
 
2339
+ /** The slot progress is counted from: it carries the stage (SPEC §6.2). */
2340
+ const STATUS_SLOT = 'status'
2341
+
2342
+ /** One field as folded: its value, the format and stage its winning change carried. */
2343
+ type FoldedField = { value: string; format?: ContentFormat; stage?: Stage }
2344
+
2339
2345
 
2340
2346
  /**
2341
2347
  * Does this change sit in the Folder its target is filed in — SPEC §6.2.
@@ -2392,7 +2398,7 @@ function inTargetFolder(change: SignedEvent, folders: ReadonlySet<string> | unde
2392
2398
  * version where several are.
2393
2399
  */
2394
2400
  function foldChanges(changes: SignedEvent[], rule: RecordsRule, root: SignedEvent | undefined) {
2395
- const fields: Record<string, { value: string; by: string; at: number; format: ContentFormat; id: string }> = {}
2401
+ const fields: Record<string, { value: string; by: string; at: number; format: ContentFormat; id: string; stage?: Stage }> = {}
2396
2402
  const folders = targetFolders(root)
2397
2403
  const id = root && tagValue(root, 'd')
2398
2404
  for (const change of [...changes].filter((c) => inTargetFolder(c, folders)).sort(byOrder)) {
@@ -2410,18 +2416,28 @@ function foldChanges(changes: SignedEvent[], rule: RecordsRule, root: SignedEven
2410
2416
  // §13.4: "an app MUST read the tag from the event it took the value from,
2411
2417
  // never from the object's root" — a description created as marker text and
2412
2418
  // later edited into blocks is a root with no tag and a change with one.
2419
+ // The stage travels with the winning change too (SPEC §6.2): the one
2420
+ // naming this field, on a value that is not cleared. A later change with
2421
+ // none leaves none, never the older change's.
2422
+ const stage = value === '' ? undefined : stageTagOf(change, field)
2413
2423
  fields[field] = {
2414
2424
  value,
2415
2425
  by: change.pubkey,
2416
2426
  at: change.created_at,
2417
2427
  format: contentFormatOf(change),
2418
2428
  id: change.id,
2429
+ ...(stage ? { stage } : {}),
2419
2430
  }
2420
2431
  }
2421
2432
  }
2422
2433
  return fields
2423
2434
  }
2424
2435
 
2436
+ /** The stage an event (a change or a root) gives `field`: `["stage", <field>, <stage>]`, one of the four. */
2437
+ function stageTagOf(event: SignedEvent, field: string): Stage | undefined {
2438
+ return asStage(event.tags.find((t) => t[0] === 'stage' && t[1] === field)?.[2])
2439
+ }
2440
+
2425
2441
  /**
2426
2442
  * The fields one change sets under `rule`: one per `set` when it carries any
2427
2443
  * (SPEC §6.2, applied at the change's time as that many one-field changes),
@@ -2861,6 +2877,14 @@ export interface ResolvedSlot {
2861
2877
  * event body, which no action can set.
2862
2878
  */
2863
2879
  field?: string
2880
+ /**
2881
+ * What the status means, on the `status` slot only: the stage on the change
2882
+ * that set it, else its base type's directory stage, else its words (SPEC
2883
+ * §6.2). Undefined when none says, which counts as underway, not as done.
2884
+ * Every app counts by this ({@link progressOf}, {@link isClosedStatus}), so
2885
+ * a status a reader cannot look up still counts as its writer meant.
2886
+ */
2887
+ stage?: Stage
2864
2888
  }
2865
2889
 
2866
2890
  /**
@@ -2915,12 +2939,14 @@ function firstTag(root: SignedEvent, tag: string | string[] | undefined): string
2915
2939
  interface RawSlotValue {
2916
2940
  value: string
2917
2941
  format?: ContentFormat
2942
+ /** The stage the event the value came from gives its field (SPEC §6.2), a change's or a root's. */
2943
+ stage?: Stage
2918
2944
  }
2919
2945
 
2920
2946
  function rawSlotValue(
2921
2947
  spec: SlotSpec,
2922
2948
  root: SignedEvent,
2923
- folded: Record<string, { value: string; format?: ContentFormat }>,
2949
+ folded: Record<string, FoldedField>,
2924
2950
  isBody: boolean,
2925
2951
  ): RawSlotValue | undefined {
2926
2952
  // `fold` first, and a spec may carry both: a field that starts as a tag on
@@ -2930,7 +2956,7 @@ function rawSlotValue(
2930
2956
  // reassigning it from here.
2931
2957
  if (spec.fold) {
2932
2958
  const change = folded[spec.fold]
2933
- if (change) return { value: change.value, format: isBody ? (change.format ?? 'marker') : undefined }
2959
+ if (change) return { value: change.value, format: isBody ? (change.format ?? 'marker') : undefined, ...(change.stage ? { stage: change.stage } : {}) }
2934
2960
  /*
2935
2961
  Nobody has changed this field, so the object's own creation value stands.
2936
2962
  §7.2 rule 2 covers seeding from a tag; `field: "content"` seeds from the
@@ -2953,7 +2979,9 @@ function rawSlotValue(
2953
2979
  truncation guard reachable.
2954
2980
  */
2955
2981
  const seedTag = firstTag(root, spec.tag)
2956
- if (seedTag !== undefined) return { value: seedTag, format: isBody ? contentFormatOf(root) : undefined }
2982
+ // A root that sets a staged property carries its stage, as a change does (SPEC §6.2).
2983
+ const rootStage = stageTagOf(root, spec.fold)
2984
+ if (seedTag !== undefined) return { value: seedTag, format: isBody ? contentFormatOf(root) : undefined, ...(rootStage ? { stage: rootStage } : {}) }
2957
2985
  if (spec.field === 'content' && root.content !== '') {
2958
2986
  return { value: root.content, format: contentFormatOf(root) }
2959
2987
  }
@@ -2966,7 +2994,10 @@ function rawSlotValue(
2966
2994
  if (spec.tag) {
2967
2995
  const value = firstTag(root, spec.tag)
2968
2996
  if (value === undefined) return undefined
2969
- return { value, format: isBody ? contentFormatOf(root) : undefined }
2997
+ // The stage names the tag the value was read from, the first one the root carries.
2998
+ const read = (Array.isArray(spec.tag) ? spec.tag : [spec.tag]).find((name) => firstTag(root, name) !== undefined)
2999
+ const rootStage = read ? stageTagOf(root, read) : undefined
3000
+ return { value, format: isBody ? contentFormatOf(root) : undefined, ...(rootStage ? { stage: rootStage } : {}) }
2970
3001
  }
2971
3002
  if (spec.field === 'content') return { value: root.content, format: contentFormatOf(root) }
2972
3003
  /*
@@ -2990,7 +3021,7 @@ function rawSlotValue(
2990
3021
  function resolveSlot(
2991
3022
  spec: SlotSpec,
2992
3023
  root: SignedEvent,
2993
- folded: Record<string, { value: string; format?: ContentFormat }>,
3024
+ folded: Record<string, FoldedField>,
2994
3025
  manifest: Manifest,
2995
3026
  name?: string,
2996
3027
  ): ResolvedSlot | null {
@@ -3031,16 +3062,21 @@ function resolveSlot(
3031
3062
  const entry = manifest.vocabularies?.[spec.map]?.find((v) => v.value === raw)
3032
3063
  // A value outside the declared vocabulary is shown as-is rather than
3033
3064
  // dropped. Another app may have written it, and silently rendering nothing
3034
- // would hide exactly the corruption the honour system permits.
3065
+ // would hide exactly the corruption the honour system permits. By its id,
3066
+ // in the neutral grey of a status with no colour (Katerina, 30 Oct, EAC-2):
3067
+ // not `muted`, which draws as cancelled.
3035
3068
  value = entry?.label ?? raw
3036
- colour = entry?.colour ?? 'muted'
3069
+ colour = entry?.colour ?? 'neutral'
3037
3070
  }
3071
+ const field = spec.fold ?? (Array.isArray(spec.tag) ? spec.tag[0] : spec.tag)
3072
+ const stage = name === STATUS_SLOT ? stageOf(root.kind, field, spec, manifest, raw, value, source.stage) : undefined
3038
3073
  return {
3039
3074
  label: spec.label,
3040
3075
  value,
3041
3076
  colour,
3042
3077
  isPubkey: spec.as === 'pubkey',
3043
- field: spec.fold ?? (Array.isArray(spec.tag) ? spec.tag[0] : spec.tag),
3078
+ field,
3079
+ ...(stage ? { stage } : {}),
3044
3080
  // Present only on a slot that can carry a body. Absent is the honest shape
3045
3081
  // for a title read from a tag — and it keeps the key out of every existing
3046
3082
  // consumer's deep comparisons, which is not the reason but is a real cost
@@ -3122,7 +3158,7 @@ function withDefaultSubtitle(
3122
3158
  function resolveSlots(
3123
3159
  projection: { slots: Record<string, SlotSpec | SlotSpec[]> },
3124
3160
  root: SignedEvent,
3125
- folded: Record<string, { value: string; format?: ContentFormat }>,
3161
+ folded: Record<string, FoldedField>,
3126
3162
  manifest: Manifest,
3127
3163
  ): { slots: Record<string, ResolvedSlot>; meta: ResolvedSlot[] } {
3128
3164
  const slots: Record<string, ResolvedSlot> = {}
@@ -3188,6 +3224,13 @@ export interface ForeignObject {
3188
3224
  * a renderer can tell "this holds nothing" from "this holds no list".
3189
3225
  */
3190
3226
  children?: ForeignObject[]
3227
+ /**
3228
+ * How far along it is, from `children`: done over every child not dropped,
3229
+ * by each one's stage ({@link progressOf}). Absent when it has no children,
3230
+ * or one has no status. A renderer draws this rather than counting itself,
3231
+ * so every app counts a project the same way.
3232
+ */
3233
+ progress?: { done: number; total: number }
3191
3234
  /**
3192
3235
  * Whether the owning app declares a child list **and** says how to draw it.
3193
3236
  *
@@ -3997,7 +4040,11 @@ export async function resolveForeignRoots(
3997
4040
  viaRecommendation: resolved.viaRecommendation,
3998
4041
  childChanges: childEvents,
3999
4042
  })
4000
- if (children) parent.children = textUnread(children)
4043
+ if (children) {
4044
+ parent.children = textUnread(children)
4045
+ const progress = progressOf(children)
4046
+ if (progress) parent.progress = progress
4047
+ }
4001
4048
  }
4002
4049
  const objects = options.listRead ? textUnread(projected) : projected
4003
4050
  if (options.archivedWith) {
@@ -4663,7 +4710,10 @@ async function queryChunked(filters: Record<string, unknown>[], query: QueryFn):
4663
4710
  for (let start = 0; start < filters.length; start += MAX_FILTERS_PER_QUERY) {
4664
4711
  chunks.push(filters.slice(start, start + MAX_FILTERS_PER_QUERY))
4665
4712
  }
4666
- return (await Promise.all(chunks.map((chunk) => query(chunk)))).flat()
4713
+ // The relay answers each filter on its own: a file asked for itself and as its parent's child comes back twice, and
4714
+ // would be its parent's child twice, counted twice in its progress (EAC-2). Each event once.
4715
+ const seen = new Set<string>()
4716
+ return (await Promise.all(chunks.map((chunk) => query(chunk)))).flat().filter((e) => !seen.has(e.id) && !!seen.add(e.id))
4667
4717
  }
4668
4718
 
4669
4719
  /**
@@ -4934,7 +4984,8 @@ function peopleOf({ object, children }: AssembledObject): string[] {
4934
4984
  }
4935
4985
 
4936
4986
  function withPeople({ object, children }: AssembledObject, people: People): ForeignObject {
4937
- return { ...object, people, ...(children ? { children: children.map((c) => ({ ...c, people })) } : {}) }
4987
+ const progress = children && progressOf(children)
4988
+ return { ...object, people, ...(children ? { children: children.map((c) => ({ ...c, people })) } : {}), ...(progress ? { progress } : {}) }
4938
4989
  }
4939
4990
 
4940
4991
  /**
@@ -5496,9 +5547,9 @@ export interface FolderProject {
5496
5547
  * record from its own lists is saying it is no longer part of the project.
5497
5548
  */
5498
5549
  tickets: ForeignObject[]
5499
- /** Tickets still to do. With `doneCount`, the total the panel counts against. */
5550
+ /** Tickets still to do, every one not done or dropped. With `doneCount`, the total the panel counts against ({@link progressOf}). */
5500
5551
  openCount: number
5501
- /** Finished tickets — the numerator in the panel's "1/3". */
5552
+ /** Done tickets — the numerator in the panel's "1/3". A dropped one is in neither count. */
5502
5553
  doneCount: number
5503
5554
  }
5504
5555
 
@@ -5524,13 +5575,11 @@ export interface FolderProject {
5524
5575
  * ships, its words are not in the set, and its panel renders blank, which is
5525
5576
  * PEE-10's failure exactly. A declared stage is what removes the guess.
5526
5577
  *
5527
- * Two named sets rather than one allowlist and an "everything else": the panel
5528
- * reads "1/3", done over the two sets added together, and a status that is
5529
- * neither should land in neither. A parked "Backlog" or "Triage" is real work
5530
- * nobody is doing and it would inflate the total into meaninglessness; an
5531
- * unrecognised status some other app invented is not evidence of anything.
5578
+ * *EAC-2 (17 Nov):* the words are now the last of three readings (`stageOf`):
5579
+ * the change's own stage comes first, and a status none of them reads counts as
5580
+ * underway, in the total and not done, as Ship counts it (Miky, 17 Nov).
5532
5581
  *
5533
- * Leaving both out is also what keeps "3/3" reachable. A cancelled ticket is
5582
+ * A dropped status is left out of both numbers, which is what keeps "3/3" reachable. A cancelled ticket is
5534
5583
  * not outstanding and never becomes done, so counting it in the total would
5535
5584
  * leave a finished project stuck at 3/4 for good.
5536
5585
  *
@@ -5577,75 +5626,109 @@ const inSet = (set: Set<string>) => (raw: string | undefined, label: string | un
5577
5626
  const isOpenStatusByLabel = inSet(OPEN_STATUSES)
5578
5627
  const isDoneStatusByLabel = inSet(DONE_STATUSES)
5579
5628
 
5580
- /** The four stages a manifest may declare. Anything else is not a stage. */
5581
- type Stage = 'open' | 'started' | 'done' | 'dropped'
5629
+ /**
5630
+ * What a status means: `open`, `started`, `done` or `dropped` (SPEC §7.4).
5631
+ * Anything else is not a stage, and counts as absent rather than as a fifth.
5632
+ */
5633
+ export type Stage = 'open' | 'started' | 'done' | 'dropped'
5582
5634
  const STAGES = new Set<Stage>(['open', 'started', 'done', 'dropped'])
5635
+ const asStage = (value: string | undefined): Stage | undefined =>
5636
+ value !== undefined && STAGES.has(value as Stage) ? (value as Stage) : undefined
5583
5637
 
5584
5638
  /**
5585
- * The stage the owning app declares for a status value, or undefined.
5639
+ * A base type's default options and their stages, from its directory entry
5640
+ * (TYPES.md: `osnova.project`, `osnova.issue`), by kind and then by field.
5586
5641
  *
5587
- * `undefined` means "this manifest does not say", which is a different fact
5588
- * from "this status is not progress" and must not be collapsed into one — the
5589
- * caller falls back to the word lists only in the first case.
5590
- *
5591
- * A `stage` outside the four is ignored rather than trusted. Validation is an
5592
- * honour system (RFC 0.4 §13.4) and this is a consumer reading another app's
5593
- * self-description; an unrecognised value is treated as undeclared, which
5594
- * degrades to the fallback instead of inventing a fifth stage.
5642
+ * SPEC §7.4: until a relay knows which apps a workspace added, a reader takes a
5643
+ * base type's default stages from here, **never from a manifest it resolved**
5644
+ * — a manifest is one app's self-description, and anyone can publish one.
5645
+ * The company's own statuses never count either (§6.2): a guest who cannot
5646
+ * read them would count the same file differently.
5595
5647
  */
5596
- function declaredStage(
5597
- manifest: Manifest,
5598
- spec: SlotSpec | undefined,
5599
- raw: string | undefined,
5600
- ): Stage | undefined {
5601
- if (!spec?.map || raw === undefined) return undefined
5602
- const stage = manifest.vocabularies?.[spec.map]?.find((v) => v.value === raw)?.stage
5603
- return stage && STAGES.has(stage as Stage) ? (stage as Stage) : undefined
5648
+ const DIRECTORY_STAGES: Record<number, Record<string, Record<string, Stage>>> = {
5649
+ 30850: { status: { planned: 'open', in_progress: 'started', completed: 'done', cancelled: 'dropped' } },
5650
+ 30851: { status: { todo: 'open', in_progress: 'started', done: 'done', cancelled: 'dropped' } },
5604
5651
  }
5605
5652
 
5653
+ /** `cancelled` and its kin: finished, but not done. Split out of DONE_STATUSES so the words give a stage. */
5654
+ const DROPPED_STATUSES = new Set(['cancelled', 'canceled', 'duplicate'])
5606
5655
  /**
5607
- * Is this status finished work?
5656
+ * Started work sits above the queue.
5608
5657
  *
5609
- * `dropped` counts as done rather than open, which is what keeps "3/3"
5610
- * reachable: a cancelled ticket is never going to become done, so leaving it
5611
- * outstanding pins a finished project below its total for ever. It is not
5612
- * *progress* either, and an app that wanted to draw that distinction now can —
5613
- * the stage is on the wire and this fold is the consumer's, not the protocol's.
5658
+ * Both halves are open, but "in progress" is what somebody opened the panel to
5659
+ * find; ordering by activity alone would bury it under whatever was filed most
5660
+ * recently.
5614
5661
  */
5615
- function isDone(stage: Stage | undefined, raw: string | undefined, label: string | undefined) {
5616
- if (stage) return stage === 'done' || stage === 'dropped'
5617
- return isDoneStatusByLabel(raw, label)
5662
+ const STARTED = new Set(['in progress', 'started', 'doing', 'in review', 'review'])
5663
+ const isDroppedByLabel = inSet(DROPPED_STATUSES)
5664
+ const isStartedByLabel = inSet(STARTED)
5665
+
5666
+ /** The reader's own reading of the words, the last resort (SPEC §6.2): a stage, or nothing. */
5667
+ function stageByWords(raw: string | undefined, label: string | undefined): Stage | undefined {
5668
+ if (isDroppedByLabel(raw, label)) return 'dropped'
5669
+ if (isDoneStatusByLabel(raw, label)) return 'done'
5670
+ if (isStartedByLabel(raw, label)) return 'started'
5671
+ if (isOpenStatusByLabel(raw, label)) return 'open'
5672
+ return undefined
5618
5673
  }
5619
5674
 
5620
5675
  /**
5621
- * Is a resolved `status` slot finished work — done or dropped — by its words?
5676
+ * The stage a status counts by — the one read every app shares (SPEC §6.2,
5677
+ * record a-companys-statuses-are-its-own-layer-of-a-types-properties):
5622
5678
  *
5623
- * For a consumer holding only the object, not its manifest: the declared stage
5624
- * is not on a {@link ResolvedSlot}, so this is the word-list fallback alone.
5625
- * `[` uses it to put a closed issue after an open one (PEE-21).
5679
+ * 1. the stage on the change (or root) that set the field's current value,
5680
+ * when the field is staged;
5681
+ * 2. else, for a base type, its directory entry's stage for that id;
5682
+ * 3. else the words.
5683
+ *
5684
+ * A field is staged when the base type's directory gives its options stages,
5685
+ * or, for any other kind, when the vocabulary its slot maps to does. A stage on
5686
+ * an unstaged field is ignored, as is one outside the four.
5687
+ *
5688
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-companys-statuses-are-its-own-layer-of-a-types-properties.md
5626
5689
  */
5627
- export function isClosedStatus(slot: ResolvedSlot | undefined): boolean {
5628
- return slot !== undefined && isDoneStatusByLabel(slot.value, slot.label)
5690
+ function stageOf(
5691
+ kind: number,
5692
+ field: string | undefined,
5693
+ spec: SlotSpec,
5694
+ manifest: Manifest,
5695
+ raw: string,
5696
+ label: string,
5697
+ written: Stage | undefined,
5698
+ ): Stage | undefined {
5699
+ const directory = field !== undefined ? DIRECTORY_STAGES[kind]?.[field] : undefined
5700
+ const staged = directory !== undefined || (spec.map !== undefined && (manifest.vocabularies?.[spec.map] ?? []).some((v) => asStage(v.stage)))
5701
+ if (staged && written) return written
5702
+ if (directory?.[raw]) return directory[raw]
5703
+ return stageByWords(raw, label)
5629
5704
  }
5630
5705
 
5631
- function isOpen(stage: Stage | undefined, raw: string | undefined, label: string | undefined) {
5632
- if (stage) return stage === 'open' || stage === 'started'
5633
- return isOpenStatusByLabel(raw, label)
5634
- }
5706
+ /** Finished work, done or dropped: `[` puts a closed issue after an open one (PEE-21). */
5707
+ const isClosed = (stage: Stage | undefined) => stage === 'done' || stage === 'dropped'
5635
5708
 
5636
5709
  /**
5637
- * Started work sits above the queue.
5638
- *
5639
- * Both halves are open, but "in progress" is what somebody opened the panel to
5640
- * find; ordering by activity alone would bury it under whatever was filed most
5641
- * recently.
5710
+ * Is a resolved `status` slot finished work, done or dropped? By the stage it
5711
+ * counts by ({@link ResolvedSlot.stage}), else by its words for a slot built
5712
+ * before the stage was on it. `[` uses it to put a closed issue after an open
5713
+ * one (PEE-21).
5642
5714
  */
5643
- const STARTED = new Set(['in progress', 'started', 'doing', 'in review', 'review'])
5644
- const isStartedByLabel = inSet(STARTED)
5715
+ export function isClosedStatus(slot: ResolvedSlot | undefined): boolean {
5716
+ if (slot === undefined) return false
5717
+ return isClosed(slot.stage ?? stageByWords(slot.value, slot.label))
5718
+ }
5645
5719
 
5646
- function isStarted(stage: Stage | undefined, raw: string | undefined, label: string | undefined) {
5647
- if (stage) return stage === 'started'
5648
- return isStartedByLabel(raw, label)
5720
+ /**
5721
+ * How far along a project is: its done children over every child not dropped,
5722
+ * by the stage each counts by. A cancelled issue is out of both numbers, so a
5723
+ * finished project reads full (Miky, 3 Nov for Ship, 17 Nov for every app).
5724
+ * A child whose status has no stage (an unknown word) is in the total and not
5725
+ * done. `undefined` when there is nothing to count or a child has no status:
5726
+ * a list of things that are not work has no progress.
5727
+ */
5728
+ export function progressOf(children: readonly { slots: { status?: ResolvedSlot } }[]): { done: number; total: number } | undefined {
5729
+ if (!children.length || children.some((child) => !child.slots.status)) return undefined
5730
+ const stages = children.map((child) => child.slots.status?.stage)
5731
+ return { done: stages.filter((stage) => stage === 'done').length, total: stages.filter((stage) => stage !== 'dropped').length }
5649
5732
  }
5650
5733
 
5651
5734
  /**
@@ -6045,17 +6128,14 @@ export async function resolveFolderProject(
6045
6128
  }
6046
6129
  const ticketChanges = changesFor(pointerToAddress(ticketPointer))
6047
6130
  const folded = foldChanges(ticketChanges, records, event)
6048
- const status = statusSpec ? resolveSlot(statusSpec, event, folded, manifest) : null
6049
- const raw = statusSpec ? rawSlotValue(statusSpec, event, folded, false)?.value : undefined
6050
-
6051
- // The owning app's declaration first, the label guess only if it has none.
6052
- const stage = declaredStage(manifest, statusSpec, raw)
6053
- const done = isDone(stage, raw, status?.value)
6054
- if (done) doneCount += 1
6055
- else if (isOpen(stage, raw, status?.value)) openCount += 1
6056
- // A status in neither set — parked, or one this consumer has never seen —
6057
- // is still a ticket and still listed. It just cannot claim to be progress
6058
- // in either direction, so it stays out of both counts.
6131
+ const status = statusSpec ? resolveSlot(statusSpec, event, folded, manifest, STATUS_SLOT) : null
6132
+
6133
+ // The stage the change says, then the directory's, then the words: as
6134
+ // `progressOf` counts, done over everything not dropped.
6135
+ // A ticket with no status at all is listed and counted in neither, as before.
6136
+ const stage = status?.stage
6137
+ if (status && stage === 'done') doneCount += 1
6138
+ else if (status && stage !== 'dropped') openCount += 1
6059
6139
 
6060
6140
  rows.push({
6061
6141
  ticket: buildObject({
@@ -6067,7 +6147,7 @@ export async function resolveFolderProject(
6067
6147
  viaRecommendation,
6068
6148
  webTemplate: resolved.webTemplate,
6069
6149
  }),
6070
- rank: isStarted(stage, raw, status?.value) ? 0 : done ? 2 : 1,
6150
+ rank: stage === 'started' ? 0 : isClosed(stage) ? 2 : 1,
6071
6151
  activityMs: Math.max(event.created_at * 1000, ...ticketChanges.map(orderingMs)),
6072
6152
  })
6073
6153
  }