p-backlog 0.10.2 → 0.11.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.
Files changed (24) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cli.js +86 -25
  3. package/dist/web/assets/{CodeTab-V2SPooxh.js → CodeTab-DvhAb0kx.js} +1 -1
  4. package/dist/web/assets/{CostTab-D4rugc-u.js → CostTab-DHmrPaIY.js} +1 -1
  5. package/dist/web/assets/{EffectTab-BCaZDgQu.js → EffectTab-C-W3n29N.js} +1 -1
  6. package/dist/web/assets/{Figure-CFYBcH57.js → Figure-DUapj1C7.js} +1 -1
  7. package/dist/web/assets/{OverviewTab-kASqwnf1.js → OverviewTab-B-6PIEfD.js} +1 -1
  8. package/dist/web/assets/{Page-DI7Zd0Be.js → Page-U8D0vJva.js} +2 -2
  9. package/dist/web/assets/{QualityTab-CplJleEW.js → QualityTab-B9ahq43v.js} +1 -1
  10. package/dist/web/assets/ShareBar-B-seexQa.js +1 -0
  11. package/dist/web/assets/{StatsPage-FwqJDfSs.js → StatsPage-DBqHQi5S.js} +1 -1
  12. package/dist/web/assets/{StatsTabState-BSoHN7Xc.js → StatsTabState-DlqTtrvX.js} +1 -1
  13. package/dist/web/assets/{StatsTable-BfRFy0MD.js → StatsTable-ClPy3aOI.js} +1 -1
  14. package/dist/web/assets/UnavailableRepos-8SE6XJSM.js +1 -0
  15. package/dist/web/assets/{index-DV2SbUU8.js → index-wzgTQj7a.js} +2 -2
  16. package/dist/web/assets/{start-BOIixvFc.js → start-BR6m00jS.js} +4 -4
  17. package/dist/web/assets/{use-grain-panel-1Qp5t-fC.js → use-grain-panel-DpW0vjfB.js} +1 -1
  18. package/dist/web/assets/{web-paths-CM_0PJMa.js → web-paths-X1IR2jNR.js} +1 -1
  19. package/dist/web/index.html +1 -1
  20. package/package.json +1 -1
  21. package/skill/backlog/SKILL.md +8 -1
  22. package/skill/backlog-en/SKILL.md +9 -1
  23. package/dist/web/assets/ShareBar-BlEi1dd3.js +0 -1
  24. package/dist/web/assets/UnavailableRepos-C5PoIyCp.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ - `backlog check` and the Stop hook no longer ask to re-check a task whose own lines are intact. Before, lines inserted
6
+ right next to the task's line, an edit of a neighbouring line or more uncommitted edits in the same file after the
7
+ task was filed counted as "the code changed", and the agent spent a turn only to move the task to its new line; now
8
+ the task moves there silently. Anchors written by earlier versions get the hash of the task's own lines on the next
9
+ check while their lines are still in place.
10
+ - The Stop hook no longer stops the session for a task whose `source` has no line number when its file changes:
11
+ such reminders never led to a fix. `backlog check` still lists them.
12
+ - The skill now has the agent re-check only the tasks the Stop hook names, and in Claude Code hand that re-check to a
13
+ subagent. A hook turn in a long session cost about 4 million tokens, almost all of it the session's context re-read
14
+ on every request; one turn grew to 16 requests by working through every other candidate too.
15
+ - `backlog take --next` first hands out a task of the project that is already in progress and has not changed for over a
16
+ day, with a note to finish it, before any new task. Before, a task taken and abandoned by an earlier session stayed in
17
+ progress for weeks while `--next` kept taking new ones.
18
+ - New alert "Checklist done but the task is not closed" for a task in progress for over a day with every checklist item
19
+ checked; it shows in the statistics and once a day in the Stop hook.
20
+
3
21
  ## 0.10.2
4
22
 
5
23
  - `backlog serve`: a project created in the first moments after the server starts now updates live in an open web UI
package/dist/cli.js CHANGED
@@ -1074,6 +1074,8 @@ function signal(s) {
1074
1074
  return `Urgent tasks have been waiting more than ${count(s.params.days, "day")}: ${s.params.count}`;
1075
1075
  case "stuck":
1076
1076
  return `Stuck in progress: ${s.params.count}, longest ${s.params.id} \u2014 ${days(s.params.days)}`;
1077
+ case "done-unclosed":
1078
+ return `Checklist done but the task is not closed: ${s.params.count}, longest ${s.params.id} \u2014 close it (backlog close) or add what is left`;
1077
1079
  case "noisy-check": {
1078
1080
  const { evidence: evidence2, method, percent: percent2, decided, windowDays } = s.params;
1079
1081
  const name = method === null ? `"${LABELS.evidence[evidence2]}"` : `"${LABELS.evidence[evidence2]}" ${LABELS.checkMethod[method]}`;
@@ -1317,6 +1319,8 @@ function signal2(s) {
1317
1319
  return `\u0421\u0440\u043E\u0447\u043D\u044B\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0436\u0434\u0443\u0442 \u0434\u043E\u043B\u044C\u0448\u0435 ${genitive(s.params.days, "day")}: ${s.params.count}`;
1318
1320
  case "stuck":
1319
1321
  return `\u0417\u0430\u0441\u0442\u0440\u044F\u043B\u0438 \u0432 \u0440\u0430\u0431\u043E\u0442\u0435: ${s.params.count}, \u0434\u043E\u043B\u044C\u0448\u0435 \u0432\u0441\u0435\u0445 ${s.params.id} \u2014 ${days2(s.params.days)}`;
1322
+ case "done-unclosed":
1323
+ return `\u0427\u0435\u043A\u043B\u0438\u0441\u0442 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D, \u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043D\u0435 \u0437\u0430\u043A\u0440\u044B\u0442\u0430: ${s.params.count}, \u0434\u043E\u043B\u044C\u0448\u0435 \u0432\u0441\u0435\u0445 ${s.params.id} \u2014 \u0437\u0430\u043A\u0440\u043E\u0439\u0442\u0435 (backlog close) \u0438\u043B\u0438 \u0434\u043E\u043F\u0438\u0448\u0438\u0442\u0435, \u0447\u0442\u043E \u043E\u0441\u0442\u0430\u043B\u043E\u0441\u044C`;
1320
1324
  case "noisy-check": {
1321
1325
  const { evidence: evidence2, method, percent: percent2, decided, windowDays } = s.params;
1322
1326
  const name = method === null ? `\xAB${LABELS2.evidence[evidence2]}\xBB` : `\xAB${LABELS2.evidence[evidence2]}\xBB ${LABELS2.checkMethod[method]}`;
@@ -2588,6 +2592,7 @@ var cliEn = {
2588
2592
  alreadyInStatus: (id, status) => `${id} is already ${status}`,
2589
2593
  blockedByOpenTasks: (id) => `${id} is blocked by open tasks:`,
2590
2594
  noTakeableInProject: (id) => `Project ${id} has no tasks that can be taken`,
2595
+ resumeAbandoned: (id) => `${id} is already in progress and has not changed for over a day \u2014 finish it first: continue its checklist and "Notes" in the task file`,
2591
2596
  hookUsage: (stopEvent, agents) => `${stopEvent} [--agent ${agents.map(({ agent }) => agent).join("|")}] (for the Stop hook in ${joinAlternatives(
2592
2597
  agents.map(({ label }) => label),
2593
2598
  "or"
@@ -2767,6 +2772,7 @@ var cliRu = {
2767
2772
  alreadyInStatus: (id, status) => `${id} \u0443\u0436\u0435 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 ${status}`,
2768
2773
  blockedByOpenTasks: (id) => `${id} \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u0430 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u043C\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043C\u0438:`,
2769
2774
  noTakeableInProject: (id) => `\u0412 \u043F\u0440\u043E\u0435\u043A\u0442\u0435 ${id} \u043D\u0435\u0442 \u0437\u0430\u0434\u0430\u0447, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u043C\u043E\u0436\u043D\u043E \u0432\u0437\u044F\u0442\u044C \u0432 \u0440\u0430\u0431\u043E\u0442\u0443`,
2775
+ resumeAbandoned: (id) => `${id} \u0443\u0436\u0435 \u0432 \u0440\u0430\u0431\u043E\u0442\u0435 \u0438 \u043D\u0435 \u043C\u0435\u043D\u044F\u043B\u0430\u0441\u044C \u0431\u043E\u043B\u044C\u0448\u0435 \u0441\u0443\u0442\u043E\u043A \u2014 \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u0434\u043E\u0434\u0435\u043B\u0430\u0439 \u0435\u0451: \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438 \u0447\u0435\u043A\u043B\u0438\u0441\u0442 \u0438 \xAB\u0417\u0430\u043C\u0435\u0442\u043A\u0438\xBB \u0432 \u0444\u0430\u0439\u043B\u0435 \u0437\u0430\u0434\u0430\u0447\u0438`,
2770
2776
  hookUsage: (stopEvent, agents) => `${stopEvent} [--agent ${agents.map(({ agent }) => agent).join("|")}] (\u0434\u043B\u044F \u0445\u0443\u043A\u0430 Stop \u0432 ${joinAlternatives(
2771
2777
  agents.map(({ label }) => label),
2772
2778
  "\u0438\u043B\u0438"
@@ -3411,12 +3417,19 @@ var SNIPPET_CONTEXT = 5;
3411
3417
  var HASH_LENGTH = 12;
3412
3418
  var LINE_NUMBER_WIDTH = 5;
3413
3419
  var MIN_MOVABLE_CHARS = 24;
3414
- var ANCHOR_FORMAT = /^([0-9a-f]+)@(\d+)-(\d+)$/;
3420
+ var ANCHOR_FORMAT = /^([0-9a-f]+)@(\d+)-(\d+)(?:\/([0-9a-f]+))?$/;
3415
3421
  function anchorOf(text, source) {
3416
3422
  const span2 = sourceSpan(source);
3417
3423
  const lines = fileLines(text);
3418
3424
  const window = span2 === null ? null : windowOf(span2, lines.length);
3419
- return window === null ? null : `${hashLines(lines.slice(window.from - 1, window.to))}@${window.from}-${window.to}`;
3425
+ if (span2 === null || window === null) return null;
3426
+ return `${hashLines(lines.slice(window.from - 1, window.to))}@${window.from}-${window.to}/${hashLines(lines.slice(span2.first - 1, span2.last))}`;
3427
+ }
3428
+ function windowMatches(text, source, anchor) {
3429
+ const current = anchorOf(text, source);
3430
+ const expected = parseAnchor(anchor);
3431
+ const found = current === null ? null : parseAnchor(current);
3432
+ return expected !== null && found !== null && found.hash === expected.hash && found.from === expected.from && found.to === expected.to;
3420
3433
  }
3421
3434
  function sourceRange(source) {
3422
3435
  const span2 = source === void 0 ? null : sourceSpan(source);
@@ -3427,7 +3440,7 @@ function anchorRange(source) {
3427
3440
  return span2 === null ? null : withContext(span2);
3428
3441
  }
3429
3442
  function locateAnchor(text, source, anchor) {
3430
- return anchorOf(text, source) === anchor ? source : findMoved(text, source, anchor);
3443
+ return windowMatches(text, source, anchor) ? source : findMoved(text, source, anchor);
3431
3444
  }
3432
3445
  function isAnchorFor(anchor, source) {
3433
3446
  const parsed = parseAnchor(anchor);
@@ -3440,18 +3453,28 @@ function findMoved(text, source, anchor) {
3440
3453
  const parsed = parseAnchor(anchor);
3441
3454
  const span2 = sourceSpan(source);
3442
3455
  if (parsed === null || span2 === null) return null;
3443
- const lines = fileLines(text);
3444
- const length = parsed.to - parsed.from + 1;
3445
- const matches = [];
3446
- for (let start2 = 1; start2 + length - 1 <= lines.length; start2++) {
3447
- if (hashLines(lines.slice(start2 - 1, start2 - 1 + length)) === parsed.hash) matches.push(start2);
3448
- }
3449
- const [start] = matches;
3450
- if (matches.length !== 1 || start === void 0) return null;
3451
- if (significantChars(lines.slice(start - 1, start - 1 + length)) < MIN_MOVABLE_CHARS) return null;
3456
+ const start = uniqueBlockStart(fileLines(text), parsed.to - parsed.from + 1, parsed.hash);
3457
+ if (start === null) return null;
3452
3458
  const shift = start - parsed.from;
3453
3459
  return withLines(source, span2.first + shift, span2.isRange ? span2.last + shift : void 0);
3454
3460
  }
3461
+ function findIntactLines(text, source, anchor) {
3462
+ const linesHash = parseAnchor(anchor)?.linesHash;
3463
+ const span2 = sourceSpan(source);
3464
+ if (linesHash === void 0 || span2 === null) return null;
3465
+ const length = span2.last - span2.first + 1;
3466
+ const start = uniqueBlockStart(fileLines(text), length, linesHash);
3467
+ return start === null ? null : withLines(source, start, span2.isRange ? start + length - 1 : void 0);
3468
+ }
3469
+ function uniqueBlockStart(lines, length, hash) {
3470
+ const starts = [];
3471
+ for (let start2 = 1; start2 + length - 1 <= lines.length; start2++) {
3472
+ if (hashLines(lines.slice(start2 - 1, start2 - 1 + length)) === hash) starts.push(start2);
3473
+ }
3474
+ const [start] = starts;
3475
+ if (starts.length !== 1 || start === void 0) return null;
3476
+ return significantChars(lines.slice(start - 1, start - 1 + length)) < MIN_MOVABLE_CHARS ? null : start;
3477
+ }
3455
3478
  function remappedSource(source, lineAt) {
3456
3479
  const span2 = sourceSpan(source);
3457
3480
  return span2 === null ? null : withLines(source, lineAt(span2.first), span2.isRange ? lineAt(span2.last) : void 0);
@@ -3483,7 +3506,7 @@ function withContext(span2) {
3483
3506
  }
3484
3507
  function parseAnchor(anchor) {
3485
3508
  const match = ANCHOR_FORMAT.exec(anchor);
3486
- return match === null ? null : { hash: match[1] ?? "", from: Number(match[2]), to: Number(match[3]) };
3509
+ return match === null ? null : { hash: match[1] ?? "", from: Number(match[2]), to: Number(match[3]), linesHash: match[4] };
3487
3510
  }
3488
3511
  function fileLines(text) {
3489
3512
  const lines = text.split("\n");
@@ -3535,8 +3558,7 @@ function codeCandidate(task, anchor, facts, knownCommits = /* @__PURE__ */ new S
3535
3558
  }
3536
3559
  function anchorPlan(task, anchor, facts) {
3537
3560
  if (task.source === void 0) return [];
3538
- if (anchor.kind === "moved") return [movedPlan(task.id, task.source, anchor)];
3539
- if (anchor.kind === "same") return [];
3561
+ if (anchor.kind === "moved") return [anchor.source === task.source ? { id: task.id, changes: { anchor: anchor.anchor } } : movedPlan(task.id, task.source, anchor)];
3540
3562
  const text = facts.texts.get(sourcePath(task.source));
3541
3563
  const fresh = text === void 0 ? null : anchorOf(text, task.source);
3542
3564
  return fresh === null || fresh === task.anchor ? [] : [{ id: task.id, changes: { anchor: fresh } }];
@@ -3569,8 +3591,8 @@ function anchorState(task, facts) {
3569
3591
  function anchorStateIn(task, text) {
3570
3592
  if (task.anchor === void 0 || task.source === void 0 || !hasLines(task.source) || !isAnchorFor(task.anchor, task.source)) return { kind: "none" };
3571
3593
  if (text === void 0) return { kind: "none" };
3572
- if (anchorOf(text, task.source) === task.anchor) return { kind: "same", source: task.source, anchor: task.anchor };
3573
- const moved = findMoved(text, task.source, task.anchor);
3594
+ if (windowMatches(text, task.source, task.anchor)) return { kind: "same", source: task.source, anchor: task.anchor };
3595
+ const moved = findMoved(text, task.source, task.anchor) ?? findIntactLines(text, task.source, task.anchor);
3574
3596
  const movedAnchor = moved === null ? null : anchorOf(text, moved);
3575
3597
  return moved === null || movedAnchor === null ? { kind: "changed" } : { kind: "moved", source: moved, anchor: movedAnchor };
3576
3598
  }
@@ -4082,7 +4104,7 @@ async function traceSource(task, facts, diffs) {
4082
4104
  if (text === void 0) return UNTRACED;
4083
4105
  const { commits, uncommitted } = changesSince(facts, sourcePath(source), reviewMark(task));
4084
4106
  const fileUntouched = commits.length === 0 && !uncommitted;
4085
- if (fileUntouched && (anchor === void 0 || anchorOf(text, source) === anchor)) return { kind: "traced", current: source, linesChanged: false };
4107
+ if (fileUntouched && (anchor === void 0 || windowMatches(text, source, anchor))) return { kind: "traced", current: source, linesChanged: false };
4086
4108
  const traced = { ...task, source };
4087
4109
  const reference = await referenceOf(traced, text, commits, diffs);
4088
4110
  if (reference.kind === "not-on-branch") return fileUntouched ? { kind: "not-on-branch" } : UNTRACED;
@@ -4527,8 +4549,19 @@ function isQueuedTask(task) {
4527
4549
  return task.type === "task" && task.status === "backlog";
4528
4550
  }
4529
4551
  function pickNextTask(tasks, projectId, index) {
4530
- const candidates = tasks.filter((task) => task.projectId === projectId && isQueuedTask(task) && !isBlocked(task, index));
4531
- return candidates.sort((a, b) => priorityRank(b.priority) - priorityRank(a.priority) || Date.parse(a.created) - Date.parse(b.created) || compareIds(a.id, b.id))[0];
4552
+ return firstInQueueOrder(tasks.filter((task) => task.projectId === projectId && isQueuedTask(task) && !isBlocked(task, index)));
4553
+ }
4554
+ var ABANDONED_AFTER_MS2 = DAY_MS;
4555
+ function pickAbandonedTask(tasks, projectId, index, lastTouched2, now) {
4556
+ const cutoff = now.getTime() - ABANDONED_AFTER_MS2;
4557
+ const abandoned = tasks.filter((task) => task.projectId === projectId && isTakenTask(task) && !isBlocked(task, index) && (lastTouched2.get(task.id) ?? now.getTime()) < cutoff);
4558
+ return firstInQueueOrder(abandoned);
4559
+ }
4560
+ function isTakenTask(task) {
4561
+ return task.type === "task" && task.status === "in-progress";
4562
+ }
4563
+ function firstInQueueOrder(tasks) {
4564
+ return tasks.toSorted((a, b) => priorityRank(b.priority) - priorityRank(a.priority) || Date.parse(a.created) - Date.parse(b.created) || compareIds(a.id, b.id))[0];
4532
4565
  }
4533
4566
  var STALE_LOW_DAYS = DAYS_PER_MONTH;
4534
4567
  function staleLowTasks(tasks, now) {
@@ -5914,12 +5947,20 @@ function outcomeCounts(episodes) {
5914
5947
  // src/core/stats/signals/signals.ts
5915
5948
  var GROWTH_WEEKS = 3;
5916
5949
  var STUCK_AFTER_DAYS = { "in-progress": 7, blocked: 14 };
5950
+ var DONE_UNCLOSED_AFTER_DAYS = 1;
5917
5951
  var NOISY_MIN_DECIDED = 10;
5918
5952
  var NOISY_MAX_PERCENT = 20;
5919
5953
  var NOISY_WINDOW_DAYS = 14;
5920
5954
  function statsSignals(context) {
5921
5955
  const { now } = context.input;
5922
- return [...debtGrowing(weeklyFlow(context.histories, now)), ...urgentStale(urgentStaleCount(context.openTasks, now)), ...stuck(context), ...noisyChecks(context), ...staleLow(context)];
5956
+ return [
5957
+ ...debtGrowing(weeklyFlow(context.histories, now)),
5958
+ ...urgentStale(urgentStaleCount(context.openTasks, now)),
5959
+ ...stuck(context),
5960
+ ...doneUnclosed(context),
5961
+ ...noisyChecks(context),
5962
+ ...staleLow(context)
5963
+ ];
5923
5964
  }
5924
5965
  function debtGrowing(weeks) {
5925
5966
  const recent = weeks.slice(0, -1).slice(-GROWTH_WEEKS);
@@ -5937,6 +5978,16 @@ function stuck({ scope, tasks, input: { now } }) {
5937
5978
  if (longest === void 0) return [];
5938
5979
  return [{ kind: "stuck", params: { count: stuckTasks.length, id: longest.id, days: longest.days } }];
5939
5980
  }
5981
+ function doneUnclosed({ scope, tasks, input: { now } }) {
5982
+ const checklistDone = new Set(tasks.filter((task) => task.status === "in-progress" && isChecklistDone(task.body)).map((task) => task.id));
5983
+ const unclosed = inWorkTasks(tasks, scope.historiesWithEpics, now).filter((item) => checklistDone.has(item.id) && item.days >= DONE_UNCLOSED_AFTER_DAYS);
5984
+ const longest = unclosed[0];
5985
+ return longest === void 0 ? [] : [{ kind: "done-unclosed", params: { count: unclosed.length, id: longest.id } }];
5986
+ }
5987
+ function isChecklistDone(body) {
5988
+ const items = checklistItems(body);
5989
+ return items.length > 0 && items.every((item) => item.checked);
5990
+ }
5940
5991
  function staleLow({ scope, input: { now } }) {
5941
5992
  const stale = staleLowTasks(scope.tasksWithEpics, now);
5942
5993
  return stale.length === 0 ? [] : [{ kind: "stale-low", params: { days: STALE_LOW_DAYS, count: stale.length } }];
@@ -6061,8 +6112,9 @@ async function runHook(args, io) {
6061
6112
  if (!await isFirstHookOfTurn(agent, event, io)) return EXIT.ok;
6062
6113
  const { candidates } = await checkBacklog(io.backlogRoot, loaded, { projectIds: [project.id], mode: "changed", now: io.now(), places, messages: io.core, warn: io.warn, workingRoots: repoRootsOf(cwdRoots) });
6063
6114
  const lowPriority = new Set(loaded.tasks.filter((task) => task.priority === "low").map((task) => task.id));
6064
- const worthTelling = candidates.filter((candidate) => !lowPriority.has(candidate.task.id));
6065
- const lowCount = candidates.length - worthTelling.length;
6115
+ const pinpointed = candidates.filter((candidate) => !(candidate.kind === "source-changed" && candidate.method === "file"));
6116
+ const worthTelling = pinpointed.filter((candidate) => !lowPriority.has(candidate.task.id));
6117
+ const lowCount = pinpointed.length - worthTelling.length;
6066
6118
  const session = await sessionMemory(project, event.session, io);
6067
6119
  const blocking = worthTelling.filter((candidate) => !session.told.has(candidate.task.id));
6068
6120
  const signals = carriesSystemMessage(agent) ? await freshSignals(
@@ -9972,7 +10024,7 @@ async function runTake(args, io) {
9972
10024
  if (projectWithId || forceWithoutId) throw usageError(takeCommand, io.language);
9973
10025
  const loaded = await loadBacklog(io.backlogRoot);
9974
10026
  if (mode.kind === "path") return takeByPath(loaded, io, mode.path, values.project, { json: values.json });
9975
- const selected = mode.kind === "next" ? selectNext(loaded, io, values.project) : selectById(loaded, io, mode.id);
10027
+ const selected = mode.kind === "next" ? await selectNext(loaded, io, values.project) : selectById(loaded, io, mode.id);
9976
10028
  if (!selected.ok) return selected.exitCode;
9977
10029
  const refusal = takeRefusal(io, selected.task, buildIndex(loaded.tasks), { ignoreBlockers: values.force });
9978
10030
  if (refusal) {
@@ -10043,16 +10095,25 @@ function selectById(loaded, io, id) {
10043
10095
  const task = findTaskOrWarn(loaded, io, id);
10044
10096
  return task ? { ok: true, task } : { ok: false, exitCode: EXIT.notFound };
10045
10097
  }
10046
- function selectNext(loaded, io, projectId) {
10098
+ async function selectNext(loaded, io, projectId) {
10047
10099
  const project = findProjectOrWarn(loaded, io, projectId);
10048
10100
  if (!project) return { ok: false, exitCode: EXIT.notFound };
10049
10101
  const index = buildIndex(loaded.tasks);
10102
+ const abandoned = pickAbandonedTask(loaded.tasks, project.id, index, await lastTouched(loaded.tasks.filter(isTakenTask)), io.now());
10103
+ if (abandoned) {
10104
+ io.warn(io.cli.resumeAbandoned(abandoned.id));
10105
+ return { ok: true, task: abandoned };
10106
+ }
10050
10107
  const task = pickNextTask(loaded.tasks, project.id, index);
10051
10108
  if (task) return { ok: true, task };
10052
10109
  io.warn(io.cli.noTakeableInProject(project.id));
10053
10110
  const blocked = loaded.tasks.some((candidate) => candidate.projectId === project.id && isQueuedTask(candidate) && openBlockers(candidate, index).length > 0);
10054
10111
  return { ok: false, exitCode: blocked ? EXIT.refused : EXIT.notFound };
10055
10112
  }
10113
+ async function lastTouched(tasks) {
10114
+ const touches2 = await Promise.all(tasks.map(async (task) => [task.id, (await statOrNull(task.path))?.mtimeMs]));
10115
+ return new Map(touches2.flatMap(([id, mtimeMs]) => mtimeMs === void 0 ? [] : [[id, mtimeMs]]));
10116
+ }
10056
10117
  function takeRefusal(io, task, index, { ignoreBlockers }) {
10057
10118
  if (task.type === "epic") {
10058
10119
  const openChildren = epicChildren(task, index).filter((child) => !isClosed(child.status));
@@ -1 +1 @@
1
- import{ft as e,h as t,j as n,ln as r}from"./Page-DI7Zd0Be.js";import{a as i,i as a,n as o,o as s,r as c,s as l}from"./StatsTabState-BSoHN7Xc.js";import{t as u}from"./PanelRows.module-ZonfBTD-.js";import{t as d}from"./ShareBar-BlEi1dd3.js";import{t as f}from"./UnavailableRepos-C5PoIyCp.js";var p={churnRow:`_churnRow_ledt8_1`,densityRow:`_densityRow_ledt8_8`},m=r();function h({churn:e,period:t}){let{stats:r}=n(),a=i(),o=e[0]?.score??1;return(0,m.jsxs)(s,{title:r.churnTitle,period:a.of(`churn`,t),children:[(0,m.jsx)(l,{children:r.churnHint}),e.length===0?(0,m.jsx)(l,{children:r.churnEmpty}):(0,m.jsx)(`ul`,{className:u.rows,children:e.map(e=>(0,m.jsxs)(`li`,{className:p.churnRow,children:[(0,m.jsx)(`code`,{className:u.rowLabel,children:e.label}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.commits(e.commits)}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.churnTasks(e.tasks,e.weight)}),(0,m.jsx)(d,{share:e.score/o})]},e.label))})]})}function g({density:e}){let{stats:t}=n();return(0,m.jsx)(s,{title:t.densityTitle,period:t.periodNow,children:e.projects.length===0?(0,m.jsx)(l,{children:t.noCodeData}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(_,{rows:e.projects.map(e=>({key:e.projectId,label:e.name,row:e}))}),e.folders.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:u.subTitle,children:t.folders}),(0,m.jsx)(_,{rows:e.folders.map(e=>({key:e.label,label:(0,m.jsx)(`code`,{children:e.label}),row:e}))})]})]})})}function _({rows:e}){let{stats:t,core:r}=n();return(0,m.jsx)(`ul`,{className:u.rows,children:e.map(({key:e,label:n,row:i})=>(0,m.jsxs)(`li`,{className:p.densityRow,children:[(0,m.jsx)(`span`,{className:u.rowLabel,children:n}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.count(i.lines,`line`)}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.count(i.open,`task`)}),(0,m.jsx)(`span`,{className:u.rowValue,children:i.perKloc===null?`—`:t.perKloc(i.perKloc)})]},e))})}function v(){let{projectId:n}=e(),r=t(`code`,n);return(0,m.jsx)(o,{query:r,children:e=>(0,m.jsx)(y,{report:e})})}function y({report:e}){let{stats:t}=n();return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(f,{repos:e.unavailableRepos}),(0,m.jsxs)(`div`,{className:a.blocks,children:[(0,m.jsx)(`div`,{className:a.wide,children:(0,m.jsx)(h,{churn:e.churn,period:e.periods.churn})}),(0,m.jsx)(g,{density:e.density})]}),(0,m.jsx)(c,{children:t.codeNote})]})}export{v as CodeTab};
1
+ import{ft as e,h as t,j as n,ln as r}from"./Page-U8D0vJva.js";import{a as i,i as a,n as o,o as s,r as c,s as l}from"./StatsTabState-DlqTtrvX.js";import{t as u}from"./PanelRows.module-ZonfBTD-.js";import{t as d}from"./ShareBar-B-seexQa.js";import{t as f}from"./UnavailableRepos-8SE6XJSM.js";var p={churnRow:`_churnRow_ledt8_1`,densityRow:`_densityRow_ledt8_8`},m=r();function h({churn:e,period:t}){let{stats:r}=n(),a=i(),o=e[0]?.score??1;return(0,m.jsxs)(s,{title:r.churnTitle,period:a.of(`churn`,t),children:[(0,m.jsx)(l,{children:r.churnHint}),e.length===0?(0,m.jsx)(l,{children:r.churnEmpty}):(0,m.jsx)(`ul`,{className:u.rows,children:e.map(e=>(0,m.jsxs)(`li`,{className:p.churnRow,children:[(0,m.jsx)(`code`,{className:u.rowLabel,children:e.label}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.commits(e.commits)}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.churnTasks(e.tasks,e.weight)}),(0,m.jsx)(d,{share:e.score/o})]},e.label))})]})}function g({density:e}){let{stats:t}=n();return(0,m.jsx)(s,{title:t.densityTitle,period:t.periodNow,children:e.projects.length===0?(0,m.jsx)(l,{children:t.noCodeData}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(_,{rows:e.projects.map(e=>({key:e.projectId,label:e.name,row:e}))}),e.folders.length>0&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{className:u.subTitle,children:t.folders}),(0,m.jsx)(_,{rows:e.folders.map(e=>({key:e.label,label:(0,m.jsx)(`code`,{children:e.label}),row:e}))})]})]})})}function _({rows:e}){let{stats:t,core:r}=n();return(0,m.jsx)(`ul`,{className:u.rows,children:e.map(({key:e,label:n,row:i})=>(0,m.jsxs)(`li`,{className:p.densityRow,children:[(0,m.jsx)(`span`,{className:u.rowLabel,children:n}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.count(i.lines,`line`)}),(0,m.jsx)(`span`,{className:u.rowValue,children:r.count(i.open,`task`)}),(0,m.jsx)(`span`,{className:u.rowValue,children:i.perKloc===null?`—`:t.perKloc(i.perKloc)})]},e))})}function v(){let{projectId:n}=e(),r=t(`code`,n);return(0,m.jsx)(o,{query:r,children:e=>(0,m.jsx)(y,{report:e})})}function y({report:e}){let{stats:t}=n();return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(f,{repos:e.unavailableRepos}),(0,m.jsxs)(`div`,{className:a.blocks,children:[(0,m.jsx)(`div`,{className:a.wide,children:(0,m.jsx)(h,{churn:e.churn,period:e.periods.churn})}),(0,m.jsx)(g,{density:e.density})]}),(0,m.jsx)(c,{children:t.codeNote})]})}export{v as CodeTab};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,c as n,ft as r,i,j as a,ln as o,u as s,un as c}from"./Page-DI7Zd0Be.js";import{_ as l,d as u,h as d,v as f}from"./index-DV2SbUU8.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./StatsTabState-BSoHN7Xc.js";import{n as y,t as b}from"./Figure-CFYBcH57.js";import{t as x}from"./StatsTable-BfRFy0MD.js";import{_ as S,c as C,g as w,h as T,m as E,p as D,t as O}from"./use-grain-panel-1Qp5t-fC.js";var k=o();function A({totals:e,period:n}){let{stats:r}=a(),i=t(),o=p(),s=S(i);return(0,k.jsxs)(y,{period:o.of(`lastWeek`,n),children:[(0,k.jsx)(b,{label:r.backlogTokens,value:s(e.tokens),note:r.backlogTokensNote(s(e.hookTokens),s(e.cliTokens))}),(0,k.jsx)(b,{label:r.apiPrice,value:w(i,e.cost),note:e.hasUnpricedTokens?r.unpricedNote:void 0}),(0,k.jsx)(b,{label:r.hookTurns,value:s(e.hookTurns),note:r.hookRunsNote(s(e.hookRuns))}),(0,k.jsx)(b,{label:r.cliCalls,value:s(e.cliRuns)})]})}function j({models:e,period:n}){let{stats:r}=a(),i=t(),o=p();return(0,k.jsx)(h,{title:r.byModel,period:o.of(`days`,n),children:e.length===0?(0,k.jsx)(_,{children:r.noModels}):(0,k.jsx)(x,{label:r.byModel,head:r.modelsHead,rows:e.map(e=>({key:`${e.model}:${e.fast}`,cells:[e.fast?r.fastModel(e.model):e.model,l(i,e.tokens),d(i,e.cost)]}))})})}function M({commands:e,period:n}){let{stats:r}=a(),i=t(),o=p();return(0,k.jsx)(h,{title:r.commandsTitle,period:o.of(`days`,n),children:e.length===0?(0,k.jsx)(_,{children:r.noCommands}):(0,k.jsx)(x,{label:r.commandsTitle,head:r.commandsHead,rows:e.map(e=>({key:e.command,cells:[e.command,l(i,e.runs),r.milliseconds(e.avgMs),r.mebibytes(e.avgRssMb),r.mebibytes(e.maxRssMb)]}))})})}var N=`var(--chart-line-bright)`,P=`var(--chart-line-blue)`;function F(){let{stats:e}=a(),t=[{key:`rssMb`,label:e.processMemory,shape:`line`,color:N,format:e.mebibytes},{key:`heapUsedMb`,label:e.jsHeap,shape:`dashed`,color:P,format:e.mebibytes}],n=s().data?.samples??[],r=n.at(-1)?.rssMb??null,i=n.length===0?null:Math.max(...n.map(e=>e.rssMb)),o=t=>t===null?`—`:e.mebibytes(t);return(0,k.jsxs)(h,{title:e.serverMemory,children:[(0,k.jsx)(_,{children:e.memoryRestartNote}),(0,k.jsx)(E,{name:e.serverMemory,summary:e.memorySummary(o(r),o(i)),data:n,series:t,axes:{left:{tickFormatter:e.mebibytes}}})]})}var I=e(c(),1),L=`var(--chart-bar-warm)`,R=`var(--chart-bar-neutral)`,z=`var(--chart-line-green)`,B=`var(--chart-line-yellow)`;function V({day:e,...t}){return{start:e,...t}}function H({weeks:e,days:n,windows:r}){let{stats:i}=a(),o=t(),s=(0,I.useMemo)(()=>n.map(V),[n]),{grain:c,periods:l,period:u,toggle:d}=O(`spend`,`day`,{weeks:e,days:s},r),f=i.spendBy[c],p=S(o),m=[{key:`hookTokens`,label:i.hookTurnTokens,tooltipLabel:i.hookTurnsTooltip,shape:`bar`,color:L,stack:`tokens`,format:i.tokens},{key:`cliTokens`,label:i.cliOutputTokens,tooltipLabel:i.cliOutput,shape:`bar`,color:R,stack:`tokens`,format:i.tokens},{label:i.apiPriceTooltip,format:e=>e.hasUnpricedTokens&&e.cost!==null?`${w(o,e.cost)} (${i.unpricedNote})`:w(o,e.cost)},{key:`hookRuns`,label:i.hookRuns,shape:`line`,color:z,axis:`right`,format:p},{key:`cliRuns`,label:i.otherCommands,shape:`dashed`,color:B,axis:`right`,format:p}];return(0,k.jsx)(h,{title:f,period:u,aside:d,children:(0,k.jsx)(D,{name:f,grain:c,summary:i.spendSummary(C(o,c,l)),data:l,series:m,axes:{right:T}})})}function U(){let{projectId:e}=r(),t=n(e),{stats:i}=a();return(0,k.jsx)(v,{query:t,children:e=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(W,{scan:e.scan}),(0,k.jsx)(K,{report:e}),(0,k.jsx)(g,{children:i.costNote})]})})}function W({scan:e}){let{stats:t}=a(),n=G(t,e);return(0,k.jsx)(i,{className:m.warning,shown:n!==null,role:`status`,children:n})}function G(e,t){return t.listed?t.filesTotal===0?e.noTranscripts:t.bytesLeft>0?e.scanProgress(t.filesDone,t.filesTotal):null:e.scanStarting}function K({report:e}){let{stats:n}=a(),r=t(),i=q(e);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{totals:e.totals,period:e.periods.totals}),i!==null&&(0,k.jsx)(g,{children:n.costSince(u(r,i))}),(0,k.jsxs)(`div`,{className:m.blocks,children:[(0,k.jsx)(`div`,{className:m.wide,children:(0,k.jsx)(H,{weeks:e.weeks,days:e.days,windows:e.periods})}),(0,k.jsx)(j,{models:e.models,period:e.periods.days}),(0,k.jsx)(F,{}),(0,k.jsx)(`div`,{className:m.wide,children:(0,k.jsx)(M,{commands:e.commands,period:e.periods.days})})]})]})}function q({since:e,periods:t}){return e!==null&&f(e)>f(t.weeks.from)?e:null}export{U as CostTab};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,c as n,ft as r,i,j as a,ln as o,u as s,un as c}from"./Page-U8D0vJva.js";import{_ as l,d as u,h as d,v as f}from"./index-wzgTQj7a.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./StatsTabState-DlqTtrvX.js";import{n as y,t as b}from"./Figure-DUapj1C7.js";import{t as x}from"./StatsTable-ClPy3aOI.js";import{_ as S,c as C,g as w,h as T,m as E,p as D,t as O}from"./use-grain-panel-DpW0vjfB.js";var k=o();function A({totals:e,period:n}){let{stats:r}=a(),i=t(),o=p(),s=S(i);return(0,k.jsxs)(y,{period:o.of(`lastWeek`,n),children:[(0,k.jsx)(b,{label:r.backlogTokens,value:s(e.tokens),note:r.backlogTokensNote(s(e.hookTokens),s(e.cliTokens))}),(0,k.jsx)(b,{label:r.apiPrice,value:w(i,e.cost),note:e.hasUnpricedTokens?r.unpricedNote:void 0}),(0,k.jsx)(b,{label:r.hookTurns,value:s(e.hookTurns),note:r.hookRunsNote(s(e.hookRuns))}),(0,k.jsx)(b,{label:r.cliCalls,value:s(e.cliRuns)})]})}function j({models:e,period:n}){let{stats:r}=a(),i=t(),o=p();return(0,k.jsx)(h,{title:r.byModel,period:o.of(`days`,n),children:e.length===0?(0,k.jsx)(_,{children:r.noModels}):(0,k.jsx)(x,{label:r.byModel,head:r.modelsHead,rows:e.map(e=>({key:`${e.model}:${e.fast}`,cells:[e.fast?r.fastModel(e.model):e.model,l(i,e.tokens),d(i,e.cost)]}))})})}function M({commands:e,period:n}){let{stats:r}=a(),i=t(),o=p();return(0,k.jsx)(h,{title:r.commandsTitle,period:o.of(`days`,n),children:e.length===0?(0,k.jsx)(_,{children:r.noCommands}):(0,k.jsx)(x,{label:r.commandsTitle,head:r.commandsHead,rows:e.map(e=>({key:e.command,cells:[e.command,l(i,e.runs),r.milliseconds(e.avgMs),r.mebibytes(e.avgRssMb),r.mebibytes(e.maxRssMb)]}))})})}var N=`var(--chart-line-bright)`,P=`var(--chart-line-blue)`;function F(){let{stats:e}=a(),t=[{key:`rssMb`,label:e.processMemory,shape:`line`,color:N,format:e.mebibytes},{key:`heapUsedMb`,label:e.jsHeap,shape:`dashed`,color:P,format:e.mebibytes}],n=s().data?.samples??[],r=n.at(-1)?.rssMb??null,i=n.length===0?null:Math.max(...n.map(e=>e.rssMb)),o=t=>t===null?`—`:e.mebibytes(t);return(0,k.jsxs)(h,{title:e.serverMemory,children:[(0,k.jsx)(_,{children:e.memoryRestartNote}),(0,k.jsx)(E,{name:e.serverMemory,summary:e.memorySummary(o(r),o(i)),data:n,series:t,axes:{left:{tickFormatter:e.mebibytes}}})]})}var I=e(c(),1),L=`var(--chart-bar-warm)`,R=`var(--chart-bar-neutral)`,z=`var(--chart-line-green)`,B=`var(--chart-line-yellow)`;function V({day:e,...t}){return{start:e,...t}}function H({weeks:e,days:n,windows:r}){let{stats:i}=a(),o=t(),s=(0,I.useMemo)(()=>n.map(V),[n]),{grain:c,periods:l,period:u,toggle:d}=O(`spend`,`day`,{weeks:e,days:s},r),f=i.spendBy[c],p=S(o),m=[{key:`hookTokens`,label:i.hookTurnTokens,tooltipLabel:i.hookTurnsTooltip,shape:`bar`,color:L,stack:`tokens`,format:i.tokens},{key:`cliTokens`,label:i.cliOutputTokens,tooltipLabel:i.cliOutput,shape:`bar`,color:R,stack:`tokens`,format:i.tokens},{label:i.apiPriceTooltip,format:e=>e.hasUnpricedTokens&&e.cost!==null?`${w(o,e.cost)} (${i.unpricedNote})`:w(o,e.cost)},{key:`hookRuns`,label:i.hookRuns,shape:`line`,color:z,axis:`right`,format:p},{key:`cliRuns`,label:i.otherCommands,shape:`dashed`,color:B,axis:`right`,format:p}];return(0,k.jsx)(h,{title:f,period:u,aside:d,children:(0,k.jsx)(D,{name:f,grain:c,summary:i.spendSummary(C(o,c,l)),data:l,series:m,axes:{right:T}})})}function U(){let{projectId:e}=r(),t=n(e),{stats:i}=a();return(0,k.jsx)(v,{query:t,children:e=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(W,{scan:e.scan}),(0,k.jsx)(K,{report:e}),(0,k.jsx)(g,{children:i.costNote})]})})}function W({scan:e}){let{stats:t}=a(),n=G(t,e);return(0,k.jsx)(i,{className:m.warning,shown:n!==null,role:`status`,children:n})}function G(e,t){return t.listed?t.filesTotal===0?e.noTranscripts:t.bytesLeft>0?e.scanProgress(t.filesDone,t.filesTotal):null:e.scanStarting}function K({report:e}){let{stats:n}=a(),r=t(),i=q(e);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{totals:e.totals,period:e.periods.totals}),i!==null&&(0,k.jsx)(g,{children:n.costSince(u(r,i))}),(0,k.jsxs)(`div`,{className:m.blocks,children:[(0,k.jsx)(`div`,{className:m.wide,children:(0,k.jsx)(H,{weeks:e.weeks,days:e.days,windows:e.periods})}),(0,k.jsx)(j,{models:e.models,period:e.periods.days}),(0,k.jsx)(F,{}),(0,k.jsx)(`div`,{className:m.wide,children:(0,k.jsx)(M,{commands:e.commands,period:e.periods.days})})]})]})}function q({since:e,periods:t}){return e!==null&&f(e)>f(t.weeks.from)?e:null}export{U as CostTab};
@@ -1 +1 @@
1
- import{A as e,ft as t,h as n,j as r,ln as i}from"./Page-DI7Zd0Be.js";import{S as a,_ as o}from"./index-DV2SbUU8.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./StatsTabState-BSoHN7Xc.js";import{t as p}from"./UnavailableRepos-C5PoIyCp.js";import{n as m,t as h}from"./Figure-CFYBcH57.js";import{t as g}from"./StatsTable-BfRFy0MD.js";import{l as _,n as v,p as y,r as b,s as x,t as S,u as C}from"./use-grain-panel-1Qp5t-fC.js";var w={steps:`_steps_advmo_1`,now:`_now_advmo_13`},T=i();function E({totals:t}){let{stats:n}=r(),i=e();return(0,T.jsx)(u,{title:n.explainerTitle,children:(0,T.jsxs)(`ol`,{className:w.steps,children:[(0,T.jsx)(`li`,{children:n.explainerTask}),(0,T.jsxs)(`li`,{children:[n.explainerFixed,(0,T.jsx)(D,{children:n.fixedNow(t.fixedTasks,b(i,t.fixedLines))})]}),(0,T.jsxs)(`li`,{children:[n.explainerPending,(0,T.jsx)(D,{children:O(n,i,t)})]}),(0,T.jsxs)(`li`,{children:[n.explainerTests,(0,T.jsx)(D,{children:n.codeAndTests(v(i,t))})]}),(0,T.jsxs)(`li`,{children:[n.explainerNoise,(0,T.jsx)(D,{children:k(n,i,t)})]})]})})}function D({children:e}){let{stats:t}=r();return(0,T.jsxs)(`span`,{className:w.now,children:[t.now,` `,e]})}function O(e,t,n){return n.openTasks===0?e.noPending:n.estimatedLines===null?e.pendingWithoutEstimate(n.openTasks):e.pendingEstimated(x(t,n.openTasks,n.estimatedLines))}function k(e,t,n){if(n.estimatedLines===null&&n.openTasks>0)return e.estimateLater;if(n.noiseShare===null)return e.noCommitsSinceAdoption;let r=e=>_(t,e,n.estimatedLines);return e.noiseFormula(r(n.deferredLines),o(t,n.realLines),r(n.estimatedLines??0),C(n.noiseShare,n.estimatedLines))}var A=`var(--chart-bar-neutral)`,j=`var(--accent-ink)`;function M({periods:t,totals:n,grain:i}){let{stats:a,core:s}=r(),c=e(),l=[{key:`onTopicLines`,label:a.onTopicSeries,shape:`bar`,color:A,stack:`lines`,format:e=>s.count(Math.round(e),`line`)},{key:`deferredLines`,label:a.deferredSeries,shape:`hatch`,color:j,stack:`lines`,format:(e,t)=>_(c,e,t.estimatedLines)},{label:a.codeLines,format:e=>v(c,e).code},{label:a.testLines,format:e=>v(c,e).tests},{label:a.deferredTasks,format:e=>o(c,e.deferredTasks)}];return(0,T.jsx)(y,{name:a.effectTitle,grain:i,summary:N(a,c,i,t,n),data:t,series:l})}function N(e,t,n,r,i){let o=(n,r)=>e.linesText(b(t,n,r));if(n===`week`)return e.effectSummary(i.realLines,o(i.deferredLines,i.estimatedLines),C(i.noiseShare,i.estimatedLines));let s=e=>a(r.map(e)),c=o(s(e=>e.deferredLines),s(e=>e.estimatedLines??0));return e.effectDaysSummary(r.length,Math.round(s(e=>e.onTopicLines)),c)}function P({totals:t,period:n}){let{stats:i}=r(),a=e(),c=s();return(0,T.jsxs)(m,{period:c.labelled(i.effectWindow,n),children:[(0,T.jsx)(h,{label:i.keptOut,value:i.linesText(b(a,t.deferredLines,t.estimatedLines)),note:`${F(i,a,t)} · ${i.codeAndTests(v(a,t))}`}),(0,T.jsx)(h,{label:i.noiseWithoutBacklog,value:C(t.noiseShare,t.estimatedLines),note:i.noiseNote}),(0,T.jsx)(h,{label:i.deferredToBacklog,value:o(a,t.deferredTasks),note:i.deferredNote(t.fixedTasks,t.openTasks)}),(0,T.jsx)(h,{label:i.pullRequestLines,value:o(a,t.realLines)})]})}function F(e,t,n){let r=o(t,n.fixedLines);return n.estimatedLines===null?e.keptOutPending(r):e.keptOutEstimated(r,_(t,n.estimatedLines,n.estimatedLines))}function I({weeks:e,days:t,windows:n,totals:i}){let{stats:a}=r(),{grain:o,periods:s,period:c,toggle:l}=S(`effect`,`week`,{weeks:e,days:t},n);return(0,T.jsx)(u,{title:a.effectTitle,period:c,aside:l,children:(0,T.jsx)(M,{periods:s,totals:i,grain:o})})}function L({projects:t,period:n}){let{stats:i}=r(),a=e(),c=s();return(0,T.jsx)(u,{title:i.byProject,period:c.labelled(i.effectWindow,n),children:t.length===0?(0,T.jsx)(f,{children:i.noCodeData}):(0,T.jsx)(g,{label:i.byProject,head:i.projectsHead,rows:t.map(e=>({key:e.projectId,cells:[e.name,e.deferredTasks,o(a,e.fixedLines),e.estimatedLines===null?`—`:_(a,e.estimatedLines,e.estimatedLines),o(a,e.realLines),C(e.noiseShare,e.estimatedLines)]}))})})}function R(){let{projectId:e}=t(),r=n(`effect`,e);return(0,T.jsx)(l,{query:r,children:e=>(0,T.jsx)(z,{report:e})})}function z({report:e}){let{stats:t}=r(),n=e.totals.deferredTasks===0;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{repos:e.unavailableRepos}),n&&(0,T.jsx)(d,{children:t.noDeferredTasks}),(0,T.jsx)(P,{totals:e.totals,period:e.periods.weeks}),(0,T.jsxs)(`div`,{className:c.blocks,children:[(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(I,{weeks:e.weeks,days:e.days,windows:e.periods,totals:e.totals})}),(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(L,{projects:e.projects,period:e.periods.weeks})}),(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(E,{totals:e.totals})})]})]})}export{R as EffectTab};
1
+ import{A as e,ft as t,h as n,j as r,ln as i}from"./Page-U8D0vJva.js";import{S as a,_ as o}from"./index-wzgTQj7a.js";import{a as s,i as c,n as l,o as u,r as d,s as f}from"./StatsTabState-DlqTtrvX.js";import{t as p}from"./UnavailableRepos-8SE6XJSM.js";import{n as m,t as h}from"./Figure-DUapj1C7.js";import{t as g}from"./StatsTable-ClPy3aOI.js";import{l as _,n as v,p as y,r as b,s as x,t as S,u as C}from"./use-grain-panel-DpW0vjfB.js";var w={steps:`_steps_advmo_1`,now:`_now_advmo_13`},T=i();function E({totals:t}){let{stats:n}=r(),i=e();return(0,T.jsx)(u,{title:n.explainerTitle,children:(0,T.jsxs)(`ol`,{className:w.steps,children:[(0,T.jsx)(`li`,{children:n.explainerTask}),(0,T.jsxs)(`li`,{children:[n.explainerFixed,(0,T.jsx)(D,{children:n.fixedNow(t.fixedTasks,b(i,t.fixedLines))})]}),(0,T.jsxs)(`li`,{children:[n.explainerPending,(0,T.jsx)(D,{children:O(n,i,t)})]}),(0,T.jsxs)(`li`,{children:[n.explainerTests,(0,T.jsx)(D,{children:n.codeAndTests(v(i,t))})]}),(0,T.jsxs)(`li`,{children:[n.explainerNoise,(0,T.jsx)(D,{children:k(n,i,t)})]})]})})}function D({children:e}){let{stats:t}=r();return(0,T.jsxs)(`span`,{className:w.now,children:[t.now,` `,e]})}function O(e,t,n){return n.openTasks===0?e.noPending:n.estimatedLines===null?e.pendingWithoutEstimate(n.openTasks):e.pendingEstimated(x(t,n.openTasks,n.estimatedLines))}function k(e,t,n){if(n.estimatedLines===null&&n.openTasks>0)return e.estimateLater;if(n.noiseShare===null)return e.noCommitsSinceAdoption;let r=e=>_(t,e,n.estimatedLines);return e.noiseFormula(r(n.deferredLines),o(t,n.realLines),r(n.estimatedLines??0),C(n.noiseShare,n.estimatedLines))}var A=`var(--chart-bar-neutral)`,j=`var(--accent-ink)`;function M({periods:t,totals:n,grain:i}){let{stats:a,core:s}=r(),c=e(),l=[{key:`onTopicLines`,label:a.onTopicSeries,shape:`bar`,color:A,stack:`lines`,format:e=>s.count(Math.round(e),`line`)},{key:`deferredLines`,label:a.deferredSeries,shape:`hatch`,color:j,stack:`lines`,format:(e,t)=>_(c,e,t.estimatedLines)},{label:a.codeLines,format:e=>v(c,e).code},{label:a.testLines,format:e=>v(c,e).tests},{label:a.deferredTasks,format:e=>o(c,e.deferredTasks)}];return(0,T.jsx)(y,{name:a.effectTitle,grain:i,summary:N(a,c,i,t,n),data:t,series:l})}function N(e,t,n,r,i){let o=(n,r)=>e.linesText(b(t,n,r));if(n===`week`)return e.effectSummary(i.realLines,o(i.deferredLines,i.estimatedLines),C(i.noiseShare,i.estimatedLines));let s=e=>a(r.map(e)),c=o(s(e=>e.deferredLines),s(e=>e.estimatedLines??0));return e.effectDaysSummary(r.length,Math.round(s(e=>e.onTopicLines)),c)}function P({totals:t,period:n}){let{stats:i}=r(),a=e(),c=s();return(0,T.jsxs)(m,{period:c.labelled(i.effectWindow,n),children:[(0,T.jsx)(h,{label:i.keptOut,value:i.linesText(b(a,t.deferredLines,t.estimatedLines)),note:`${F(i,a,t)} · ${i.codeAndTests(v(a,t))}`}),(0,T.jsx)(h,{label:i.noiseWithoutBacklog,value:C(t.noiseShare,t.estimatedLines),note:i.noiseNote}),(0,T.jsx)(h,{label:i.deferredToBacklog,value:o(a,t.deferredTasks),note:i.deferredNote(t.fixedTasks,t.openTasks)}),(0,T.jsx)(h,{label:i.pullRequestLines,value:o(a,t.realLines)})]})}function F(e,t,n){let r=o(t,n.fixedLines);return n.estimatedLines===null?e.keptOutPending(r):e.keptOutEstimated(r,_(t,n.estimatedLines,n.estimatedLines))}function I({weeks:e,days:t,windows:n,totals:i}){let{stats:a}=r(),{grain:o,periods:s,period:c,toggle:l}=S(`effect`,`week`,{weeks:e,days:t},n);return(0,T.jsx)(u,{title:a.effectTitle,period:c,aside:l,children:(0,T.jsx)(M,{periods:s,totals:i,grain:o})})}function L({projects:t,period:n}){let{stats:i}=r(),a=e(),c=s();return(0,T.jsx)(u,{title:i.byProject,period:c.labelled(i.effectWindow,n),children:t.length===0?(0,T.jsx)(f,{children:i.noCodeData}):(0,T.jsx)(g,{label:i.byProject,head:i.projectsHead,rows:t.map(e=>({key:e.projectId,cells:[e.name,e.deferredTasks,o(a,e.fixedLines),e.estimatedLines===null?`—`:_(a,e.estimatedLines,e.estimatedLines),o(a,e.realLines),C(e.noiseShare,e.estimatedLines)]}))})})}function R(){let{projectId:e}=t(),r=n(`effect`,e);return(0,T.jsx)(l,{query:r,children:e=>(0,T.jsx)(z,{report:e})})}function z({report:e}){let{stats:t}=r(),n=e.totals.deferredTasks===0;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{repos:e.unavailableRepos}),n&&(0,T.jsx)(d,{children:t.noDeferredTasks}),(0,T.jsx)(P,{totals:e.totals,period:e.periods.weeks}),(0,T.jsxs)(`div`,{className:c.blocks,children:[(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(I,{weeks:e.weeks,days:e.days,windows:e.periods,totals:e.totals})}),(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(L,{projects:e.projects,period:e.periods.weeks})}),(0,T.jsx)(`div`,{className:c.wide,children:(0,T.jsx)(E,{totals:e.totals})})]})]})}export{R as EffectTab};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,ln as n,un as r}from"./Page-DI7Zd0Be.js";import{c as i}from"./StatsTabState-BSoHN7Xc.js";var a=e(r(),1),o={group:`_group_ihjlt_1`,figures:`_figures_ihjlt_7`,pair:`_pair_ihjlt_13`,figure:`_figure_ihjlt_7`,trend:`_trend_ihjlt_28`,value:`_value_ihjlt_33`,growth:`_growth_ihjlt_40`,decline:`_decline_ihjlt_44`},s=n(),c={growth:o.growth,decline:o.decline};function l({label:e,value:n,note:r,tone:l,trend:u}){let d=(0,a.useId)();return(0,s.jsxs)(`div`,{className:o.figure,role:`group`,"aria-labelledby":d,children:[(0,s.jsx)(`span`,{id:d,className:i.caption,children:e}),(0,s.jsx)(`span`,{className:t(o.value,l!==void 0&&c[l]),children:n}),u!==void 0&&(0,s.jsxs)(`span`,{className:t(o.trend,c[u.tone]),children:[(0,s.jsx)(`span`,{"aria-hidden":`true`,children:u.text}),(0,s.jsx)(`span`,{className:`visually-hidden`,children:u.speech})]}),r!==void 0&&(0,s.jsx)(`span`,{className:i.caption,children:r})]})}function u({columns:e,children:n}){return(0,s.jsx)(`div`,{className:t(o.figures,e===2&&o.pair),children:n})}function d({tone:e,children:t}){return(0,s.jsx)(`span`,{className:e===void 0?void 0:c[e],children:t})}function f({period:e,children:t}){let n=(0,a.useId)();return(0,s.jsxs)(`div`,{role:`group`,"aria-labelledby":n,className:o.group,children:[(0,s.jsx)(`p`,{id:n,className:i.caption,children:e}),(0,s.jsx)(u,{columns:4,children:t})]})}export{d as i,f as n,u as r,l as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,ln as n,un as r}from"./Page-U8D0vJva.js";import{c as i}from"./StatsTabState-DlqTtrvX.js";var a=e(r(),1),o={group:`_group_ihjlt_1`,figures:`_figures_ihjlt_7`,pair:`_pair_ihjlt_13`,figure:`_figure_ihjlt_7`,trend:`_trend_ihjlt_28`,value:`_value_ihjlt_33`,growth:`_growth_ihjlt_40`,decline:`_decline_ihjlt_44`},s=n(),c={growth:o.growth,decline:o.decline};function l({label:e,value:n,note:r,tone:l,trend:u}){let d=(0,a.useId)();return(0,s.jsxs)(`div`,{className:o.figure,role:`group`,"aria-labelledby":d,children:[(0,s.jsx)(`span`,{id:d,className:i.caption,children:e}),(0,s.jsx)(`span`,{className:t(o.value,l!==void 0&&c[l]),children:n}),u!==void 0&&(0,s.jsxs)(`span`,{className:t(o.trend,c[u.tone]),children:[(0,s.jsx)(`span`,{"aria-hidden":`true`,children:u.text}),(0,s.jsx)(`span`,{className:`visually-hidden`,children:u.speech})]}),r!==void 0&&(0,s.jsx)(`span`,{className:i.caption,children:r})]})}function u({columns:e,children:n}){return(0,s.jsx)(`div`,{className:t(o.figures,e===2&&o.pair),children:n})}function d({tone:e,children:t}){return(0,s.jsx)(`span`,{className:e===void 0?void 0:c[e],children:t})}function f({period:e,children:t}){let n=(0,a.useId)();return(0,s.jsxs)(`div`,{role:`group`,"aria-labelledby":n,className:o.group,children:[(0,s.jsx)(`p`,{id:n,className:i.caption,children:e}),(0,s.jsx)(u,{columns:4,children:t})]})}export{d as i,f as n,u as r,l as t};
@@ -1 +1 @@
1
- import{A as e,M as t,a as n,ft as r,h as i,j as a,ln as o}from"./Page-DI7Zd0Be.js";import{S as s,_ as c}from"./index-DV2SbUU8.js";import{c as l,n as u}from"./web-paths-CM_0PJMa.js";import{c as d,n as f,r as p}from"./start-BOIixvFc.js";import{a as m,i as h,n as g,o as _,s as v}from"./StatsTabState-BSoHN7Xc.js";import{t as y}from"./PanelRows.module-ZonfBTD-.js";import{t as b}from"./ShareBar-BlEi1dd3.js";import{i as x,r as S,t as C}from"./Figure-CFYBcH57.js";import{_ as w,a as T,d as E,f as D,h as O,o as k,p as A,t as j}from"./use-grain-panel-1Qp5t-fC.js";var M={columns:`_columns_1m2da_1`,countList:`_countList_1m2da_7`,ageRows:`_ageRows_1m2da_11`,ageRow:`_ageRow_1m2da_11`,ageLabel:`_ageLabel_1m2da_25`,ageTrack:`_ageTrack_1m2da_29`,ageSegment:`_ageSegment_1m2da_37`,legend:`_legend_1m2da_41`,legendItem:`_legendItem_1m2da_50`,share:`_share_1m2da_61`,critical:`_critical_1m2da_65`,high:`_high_1m2da_69`,medium:`_medium_1m2da_73`,low:`_low_1m2da_77`,done:`_done_1m2da_81`,fixed:`_fixed_1m2da_85`,obsolete:`_obsolete_1m2da_89`,duplicate:`_duplicate_1m2da_93`,cancelled:`_cancelled_1m2da_97`,unknown:`_unknown_1m2da_101`,shareBar:`_shareBar_1m2da_105`,alarm:`_alarm_1m2da_117`,alarmOn:`_alarmOn_1m2da_123`},N=o(),P=t.toReversed();function F(e,t){let n=P.filter(e=>t[e]>0).map(n=>`${e.priorityCounts[n]} ${t[n]}`);return n.length===0?``:` (${n.join(`, `)})`}function I({age:e}){let{stats:r,core:i}=a(),o=e.buckets.map(({bucket:e,byPriority:n})=>({bucket:e,total:s(t.map(e=>n[e])),byPriority:n})),c=Math.max(1,...o.map(({total:e})=>e)),l=o.map(({bucket:e,total:t,byPriority:n})=>`${r.ageBuckets[e]}: ${t}${F(r,n)}`).join(`; `);return(0,N.jsxs)(_,{title:r.openAge,period:r.periodNow,children:[(0,N.jsx)(`div`,{role:`img`,"aria-label":l,className:M.ageRows,children:o.map(({bucket:e,total:i,byPriority:a})=>(0,N.jsxs)(`div`,{className:M.ageRow,"aria-hidden":`true`,children:[(0,N.jsx)(`span`,{className:M.ageLabel,children:r.ageBuckets[e]}),(0,N.jsx)(`span`,{className:M.ageTrack,children:t.map(e=>(0,N.jsx)(`span`,{className:n(M.ageSegment,M[e]),style:{width:`${a[e]/c*100}%`}},e))}),(0,N.jsx)(`span`,{className:y.rowValue,children:i})]},e))}),(0,N.jsx)(`p`,{className:M.legend,children:P.map(e=>(0,N.jsx)(`span`,{className:n(M.legendItem,M[e]),children:i.priorityLabel(e)},e))}),(0,N.jsx)(`p`,{className:n(M.alarm,e.urgentStale>0&&M.alarmOn),children:r.urgentStale(e.urgentStale)})]})}var L={done:({stats:e})=>e.closingReasons.done,fixed:({core:e})=>e.resolutionLabel(`fixed`),obsolete:({core:e})=>e.resolutionLabel(`obsolete`),duplicate:({core:e})=>e.resolutionLabel(`duplicate`),cancelled:({stats:e})=>e.closingReasons.cancelled,unknown:({stats:e})=>e.closingReasons.unknown},R=Object.keys(L);function z({closing:e,period:t}){let r=a(),i=m(),{stats:o}=r,c=s(R.map(t=>e.byReason[t])),l=R.map(t=>`${L[t](r)}: ${e.byReason[t]}`).join(`; `);return(0,N.jsxs)(_,{title:o.closing,period:i.of(`weeks`,t),children:[(0,N.jsx)(`div`,{role:`img`,"aria-label":l,className:M.shareBar,children:R.map(t=>(0,N.jsx)(`span`,{className:n(M.share,M[t]),style:{width:c===0?0:`${e.byReason[t]/c*100}%`}},t))}),(0,N.jsx)(`ul`,{className:y.rows,children:R.map(t=>(0,N.jsxs)(`li`,{className:y.row,children:[(0,N.jsx)(`span`,{className:n(M.legendItem,M[t]),children:L[t](r)}),(0,N.jsx)(`span`,{className:y.rowValue,children:e.byReason[t]})]},t))}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:y.subTitle,children:o.noiseAndReopens}),(0,N.jsxs)(`ul`,{className:y.rows,children:[(0,N.jsx)(B,{label:o.duplicatesAmongClosed,value:E(e.duplicateShare)}),(0,N.jsx)(B,{label:o.noSourceAmongCreated,value:E(e.withoutSourceShare)}),(0,N.jsx)(B,{label:o.reopened,value:e.reopened})]})]})]})}function B({label:e,value:t}){return(0,N.jsxs)(`li`,{className:y.row,children:[(0,N.jsx)(`span`,{className:y.rowLabel,children:e}),(0,N.jsx)(`span`,{className:y.rowValue,children:t})]})}function V({hotspots:e,listPath:t}){let{stats:n}=a();return(0,N.jsx)(_,{title:n.hotspots,period:n.periodNow,children:(0,N.jsxs)(`div`,{className:M.columns,children:[(0,N.jsx)(H,{title:n.folders,empty:n.noSourceFolders,items:e.folders.map(({label:e,count:t})=>({key:e,label:(0,N.jsx)(`code`,{children:e}),count:t}))}),(0,N.jsx)(H,{title:n.tags,empty:n.noTags,items:e.tags.map(({tag:e,count:n})=>({key:e,label:(0,N.jsx)(l,{to:{pathname:t,search:p({...f,tags:[e]})},children:d(e)}),count:n}))})]})})}function H({title:e,empty:t,items:n}){let r=Math.max(1,...n.map(e=>e.count));return(0,N.jsxs)(`div`,{className:M.countList,children:[(0,N.jsx)(`h3`,{className:y.subTitle,children:e}),n.length===0?(0,N.jsx)(v,{children:t}):(0,N.jsx)(`ul`,{className:y.rows,children:n.map(e=>(0,N.jsxs)(`li`,{className:y.countRow,children:[(0,N.jsx)(`span`,{className:y.rowLabel,children:e.label}),(0,N.jsx)(`span`,{className:y.rowValue,children:e.count}),(0,N.jsx)(b,{share:e.count/r})]},e.key))})]})}var U=`var(--chart-bar-neutral)`,W=`var(--chart-bar-green)`,G=`var(--chart-line-bright)`;function K({weeks:t,days:n,windows:r}){let{stats:i}=a(),o=e(),{grain:s,periods:c,period:l,toggle:u}=j(`flow`,`week`,{weeks:t,days:n},r),d=w(o),f=[{key:`created`,label:i.flowCreated,shape:`bar`,color:U,format:d},{key:`closed`,label:i.flowClosed,shape:`bar`,color:W,format:d},{key:`openAtEnd`,label:i.flowOpenAtEnd[s],tooltipLabel:i.flowOpen,shape:`line`,color:G,axis:`right`,format:d}],p=i.debtBy[s];return(0,N.jsx)(_,{title:p,period:l,aside:u,children:(0,N.jsx)(A,{name:p,grain:s,summary:i.flowSummary(T(s,c)),data:c,series:f,axes:{left:O,right:O}})})}var q=`var(--chart-bar-warm)`;function J({weeks:e,days:t,windows:n}){let{stats:r,core:i}=a(),{grain:o,periods:s,period:c,toggle:l}=j(`intake`,`day`,{weeks:e,days:t},n),u=[{key:`created`,label:r.createdTasks,tooltipLabel:r.flowCreated,shape:`bar`,color:q,format:e=>i.count(e,`task`)}],d=r.createdBy[o];return(0,N.jsx)(_,{title:d,period:c,aside:l,children:(0,N.jsx)(A,{name:d,grain:o,summary:r.intakeSummary(k(o,s)),data:s,series:u,axes:{left:O}})})}var Y={decline:`↓`,growth:`↑`};function X(){let{projectId:e}=r(),t=i(`overview`,e);return(0,N.jsx)(g,{query:t,children:t=>(0,N.jsx)(Z,{report:t,taskListPath:u(e)})})}function Z({report:e,taskListPath:t}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Q,{totals:e.totals}),(0,N.jsxs)(`div`,{className:h.blocks,children:[(0,N.jsx)(K,{weeks:e.weeks,days:e.days,windows:e.periods}),(0,N.jsx)(J,{weeks:e.weeks,days:e.days,windows:e.periods}),(0,N.jsx)(V,{hotspots:e.hotspots,listPath:t}),(0,N.jsx)(I,{age:e.age}),(0,N.jsx)(z,{closing:e.closing,period:e.periods.weeks})]})]})}function Q({totals:t}){let{stats:n}=a(),r=e(),i=t.createdLastWeek-t.closedLastWeek;return(0,N.jsxs)(S,{columns:2,children:[(0,N.jsx)(C,{label:n.tasksToday,value:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(x,{tone:t.createdToday>0?`growth`:void 0,children:[`+`,t.createdToday]}),` `,(0,N.jsxs)(x,{tone:t.closedToday>0?`decline`:void 0,children:[`−`,t.closedToday]})]}),note:n.createdAndClosed}),(0,N.jsx)(C,{label:n.thisWeek,value:D(i),tone:$(i),note:n.weekNote(t.createdLastWeek,t.closedLastWeek),trend:ee(n,r,i,t.previous?.net)})]})}function $(e){if(e>0)return`growth`;if(e<0)return`decline`}function ee(e,t,n,r){if(r===void 0)return;let i=n-r,a=$(i);if(a===void 0)return;let o=c(t,Math.abs(i));return{text:e.weekTrend(Y[a],o),speech:e.weekTrendSpeech[a](o),tone:a}}export{X as OverviewTab};
1
+ import{A as e,M as t,a as n,ft as r,h as i,j as a,ln as o}from"./Page-U8D0vJva.js";import{S as s,_ as c}from"./index-wzgTQj7a.js";import{c as l,n as u}from"./web-paths-X1IR2jNR.js";import{c as d,n as f,r as p}from"./start-BR6m00jS.js";import{a as m,i as h,n as g,o as _,s as v}from"./StatsTabState-DlqTtrvX.js";import{t as y}from"./PanelRows.module-ZonfBTD-.js";import{t as b}from"./ShareBar-B-seexQa.js";import{i as x,r as S,t as C}from"./Figure-DUapj1C7.js";import{_ as w,a as T,d as E,f as D,h as O,o as k,p as A,t as j}from"./use-grain-panel-DpW0vjfB.js";var M={columns:`_columns_1m2da_1`,countList:`_countList_1m2da_7`,ageRows:`_ageRows_1m2da_11`,ageRow:`_ageRow_1m2da_11`,ageLabel:`_ageLabel_1m2da_25`,ageTrack:`_ageTrack_1m2da_29`,ageSegment:`_ageSegment_1m2da_37`,legend:`_legend_1m2da_41`,legendItem:`_legendItem_1m2da_50`,share:`_share_1m2da_61`,critical:`_critical_1m2da_65`,high:`_high_1m2da_69`,medium:`_medium_1m2da_73`,low:`_low_1m2da_77`,done:`_done_1m2da_81`,fixed:`_fixed_1m2da_85`,obsolete:`_obsolete_1m2da_89`,duplicate:`_duplicate_1m2da_93`,cancelled:`_cancelled_1m2da_97`,unknown:`_unknown_1m2da_101`,shareBar:`_shareBar_1m2da_105`,alarm:`_alarm_1m2da_117`,alarmOn:`_alarmOn_1m2da_123`},N=o(),P=t.toReversed();function F(e,t){let n=P.filter(e=>t[e]>0).map(n=>`${e.priorityCounts[n]} ${t[n]}`);return n.length===0?``:` (${n.join(`, `)})`}function I({age:e}){let{stats:r,core:i}=a(),o=e.buckets.map(({bucket:e,byPriority:n})=>({bucket:e,total:s(t.map(e=>n[e])),byPriority:n})),c=Math.max(1,...o.map(({total:e})=>e)),l=o.map(({bucket:e,total:t,byPriority:n})=>`${r.ageBuckets[e]}: ${t}${F(r,n)}`).join(`; `);return(0,N.jsxs)(_,{title:r.openAge,period:r.periodNow,children:[(0,N.jsx)(`div`,{role:`img`,"aria-label":l,className:M.ageRows,children:o.map(({bucket:e,total:i,byPriority:a})=>(0,N.jsxs)(`div`,{className:M.ageRow,"aria-hidden":`true`,children:[(0,N.jsx)(`span`,{className:M.ageLabel,children:r.ageBuckets[e]}),(0,N.jsx)(`span`,{className:M.ageTrack,children:t.map(e=>(0,N.jsx)(`span`,{className:n(M.ageSegment,M[e]),style:{width:`${a[e]/c*100}%`}},e))}),(0,N.jsx)(`span`,{className:y.rowValue,children:i})]},e))}),(0,N.jsx)(`p`,{className:M.legend,children:P.map(e=>(0,N.jsx)(`span`,{className:n(M.legendItem,M[e]),children:i.priorityLabel(e)},e))}),(0,N.jsx)(`p`,{className:n(M.alarm,e.urgentStale>0&&M.alarmOn),children:r.urgentStale(e.urgentStale)})]})}var L={done:({stats:e})=>e.closingReasons.done,fixed:({core:e})=>e.resolutionLabel(`fixed`),obsolete:({core:e})=>e.resolutionLabel(`obsolete`),duplicate:({core:e})=>e.resolutionLabel(`duplicate`),cancelled:({stats:e})=>e.closingReasons.cancelled,unknown:({stats:e})=>e.closingReasons.unknown},R=Object.keys(L);function z({closing:e,period:t}){let r=a(),i=m(),{stats:o}=r,c=s(R.map(t=>e.byReason[t])),l=R.map(t=>`${L[t](r)}: ${e.byReason[t]}`).join(`; `);return(0,N.jsxs)(_,{title:o.closing,period:i.of(`weeks`,t),children:[(0,N.jsx)(`div`,{role:`img`,"aria-label":l,className:M.shareBar,children:R.map(t=>(0,N.jsx)(`span`,{className:n(M.share,M[t]),style:{width:c===0?0:`${e.byReason[t]/c*100}%`}},t))}),(0,N.jsx)(`ul`,{className:y.rows,children:R.map(t=>(0,N.jsxs)(`li`,{className:y.row,children:[(0,N.jsx)(`span`,{className:n(M.legendItem,M[t]),children:L[t](r)}),(0,N.jsx)(`span`,{className:y.rowValue,children:e.byReason[t]})]},t))}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:y.subTitle,children:o.noiseAndReopens}),(0,N.jsxs)(`ul`,{className:y.rows,children:[(0,N.jsx)(B,{label:o.duplicatesAmongClosed,value:E(e.duplicateShare)}),(0,N.jsx)(B,{label:o.noSourceAmongCreated,value:E(e.withoutSourceShare)}),(0,N.jsx)(B,{label:o.reopened,value:e.reopened})]})]})]})}function B({label:e,value:t}){return(0,N.jsxs)(`li`,{className:y.row,children:[(0,N.jsx)(`span`,{className:y.rowLabel,children:e}),(0,N.jsx)(`span`,{className:y.rowValue,children:t})]})}function V({hotspots:e,listPath:t}){let{stats:n}=a();return(0,N.jsx)(_,{title:n.hotspots,period:n.periodNow,children:(0,N.jsxs)(`div`,{className:M.columns,children:[(0,N.jsx)(H,{title:n.folders,empty:n.noSourceFolders,items:e.folders.map(({label:e,count:t})=>({key:e,label:(0,N.jsx)(`code`,{children:e}),count:t}))}),(0,N.jsx)(H,{title:n.tags,empty:n.noTags,items:e.tags.map(({tag:e,count:n})=>({key:e,label:(0,N.jsx)(l,{to:{pathname:t,search:p({...f,tags:[e]})},children:d(e)}),count:n}))})]})})}function H({title:e,empty:t,items:n}){let r=Math.max(1,...n.map(e=>e.count));return(0,N.jsxs)(`div`,{className:M.countList,children:[(0,N.jsx)(`h3`,{className:y.subTitle,children:e}),n.length===0?(0,N.jsx)(v,{children:t}):(0,N.jsx)(`ul`,{className:y.rows,children:n.map(e=>(0,N.jsxs)(`li`,{className:y.countRow,children:[(0,N.jsx)(`span`,{className:y.rowLabel,children:e.label}),(0,N.jsx)(`span`,{className:y.rowValue,children:e.count}),(0,N.jsx)(b,{share:e.count/r})]},e.key))})]})}var U=`var(--chart-bar-neutral)`,W=`var(--chart-bar-green)`,G=`var(--chart-line-bright)`;function K({weeks:t,days:n,windows:r}){let{stats:i}=a(),o=e(),{grain:s,periods:c,period:l,toggle:u}=j(`flow`,`week`,{weeks:t,days:n},r),d=w(o),f=[{key:`created`,label:i.flowCreated,shape:`bar`,color:U,format:d},{key:`closed`,label:i.flowClosed,shape:`bar`,color:W,format:d},{key:`openAtEnd`,label:i.flowOpenAtEnd[s],tooltipLabel:i.flowOpen,shape:`line`,color:G,axis:`right`,format:d}],p=i.debtBy[s];return(0,N.jsx)(_,{title:p,period:l,aside:u,children:(0,N.jsx)(A,{name:p,grain:s,summary:i.flowSummary(T(s,c)),data:c,series:f,axes:{left:O,right:O}})})}var q=`var(--chart-bar-warm)`;function J({weeks:e,days:t,windows:n}){let{stats:r,core:i}=a(),{grain:o,periods:s,period:c,toggle:l}=j(`intake`,`day`,{weeks:e,days:t},n),u=[{key:`created`,label:r.createdTasks,tooltipLabel:r.flowCreated,shape:`bar`,color:q,format:e=>i.count(e,`task`)}],d=r.createdBy[o];return(0,N.jsx)(_,{title:d,period:c,aside:l,children:(0,N.jsx)(A,{name:d,grain:o,summary:r.intakeSummary(k(o,s)),data:s,series:u,axes:{left:O}})})}var Y={decline:`↓`,growth:`↑`};function X(){let{projectId:e}=r(),t=i(`overview`,e);return(0,N.jsx)(g,{query:t,children:t=>(0,N.jsx)(Z,{report:t,taskListPath:u(e)})})}function Z({report:e,taskListPath:t}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Q,{totals:e.totals}),(0,N.jsxs)(`div`,{className:h.blocks,children:[(0,N.jsx)(K,{weeks:e.weeks,days:e.days,windows:e.periods}),(0,N.jsx)(J,{weeks:e.weeks,days:e.days,windows:e.periods}),(0,N.jsx)(V,{hotspots:e.hotspots,listPath:t}),(0,N.jsx)(I,{age:e.age}),(0,N.jsx)(z,{closing:e.closing,period:e.periods.weeks})]})]})}function Q({totals:t}){let{stats:n}=a(),r=e(),i=t.createdLastWeek-t.closedLastWeek;return(0,N.jsxs)(S,{columns:2,children:[(0,N.jsx)(C,{label:n.tasksToday,value:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(x,{tone:t.createdToday>0?`growth`:void 0,children:[`+`,t.createdToday]}),` `,(0,N.jsxs)(x,{tone:t.closedToday>0?`decline`:void 0,children:[`−`,t.closedToday]})]}),note:n.createdAndClosed}),(0,N.jsx)(C,{label:n.thisWeek,value:D(i),tone:$(i),note:n.weekNote(t.createdLastWeek,t.closedLastWeek),trend:ee(n,r,i,t.previous?.net)})]})}function $(e){if(e>0)return`growth`;if(e<0)return`decline`}function ee(e,t,n,r){if(r===void 0)return;let i=n-r,a=$(i);if(a===void 0)return;let o=c(t,Math.abs(i));return{text:e.weekTrend(Y[a],o),speech:e.weekTrendSpeech[a](o),tone:a}}export{X as OverviewTab};