@kolisachint/hoocode-agent 0.4.20 → 0.4.23

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 (118) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli/args.d.ts +1 -0
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +5 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/config.d.ts +2 -6
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +5 -9
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/agent-frontmatter.d.ts +3 -0
  11. package/dist/core/agent-frontmatter.d.ts.map +1 -1
  12. package/dist/core/agent-frontmatter.js +41 -1
  13. package/dist/core/agent-frontmatter.js.map +1 -1
  14. package/dist/core/agent-manifest-paths.d.ts +17 -0
  15. package/dist/core/agent-manifest-paths.d.ts.map +1 -0
  16. package/dist/core/agent-manifest-paths.js +27 -0
  17. package/dist/core/agent-manifest-paths.js.map +1 -0
  18. package/dist/core/agent-registry.d.ts +14 -7
  19. package/dist/core/agent-registry.d.ts.map +1 -1
  20. package/dist/core/agent-registry.js +114 -8
  21. package/dist/core/agent-registry.js.map +1 -1
  22. package/dist/core/agent-session.d.ts.map +1 -1
  23. package/dist/core/agent-session.js +9 -0
  24. package/dist/core/agent-session.js.map +1 -1
  25. package/dist/core/extensions/index.d.ts +1 -1
  26. package/dist/core/extensions/index.d.ts.map +1 -1
  27. package/dist/core/extensions/index.js.map +1 -1
  28. package/dist/core/extensions/runner.d.ts.map +1 -1
  29. package/dist/core/extensions/runner.js +1 -0
  30. package/dist/core/extensions/runner.js.map +1 -1
  31. package/dist/core/extensions/types.d.ts +26 -0
  32. package/dist/core/extensions/types.d.ts.map +1 -1
  33. package/dist/core/extensions/types.js.map +1 -1
  34. package/dist/core/keybindings.d.ts +8 -0
  35. package/dist/core/keybindings.d.ts.map +1 -1
  36. package/dist/core/keybindings.js +2 -0
  37. package/dist/core/keybindings.js.map +1 -1
  38. package/dist/core/package-manager.d.ts +2 -1
  39. package/dist/core/package-manager.d.ts.map +1 -1
  40. package/dist/core/package-manager.js +38 -9
  41. package/dist/core/package-manager.js.map +1 -1
  42. package/dist/core/resource-loader.d.ts +14 -0
  43. package/dist/core/resource-loader.d.ts.map +1 -1
  44. package/dist/core/resource-loader.js +12 -0
  45. package/dist/core/resource-loader.js.map +1 -1
  46. package/dist/core/sdk.d.ts +2 -0
  47. package/dist/core/sdk.d.ts.map +1 -1
  48. package/dist/core/sdk.js +1 -1
  49. package/dist/core/sdk.js.map +1 -1
  50. package/dist/core/skills.d.ts +9 -0
  51. package/dist/core/skills.d.ts.map +1 -1
  52. package/dist/core/skills.js +32 -1
  53. package/dist/core/skills.js.map +1 -1
  54. package/dist/core/source-info.d.ts +1 -1
  55. package/dist/core/source-info.d.ts.map +1 -1
  56. package/dist/core/source-info.js.map +1 -1
  57. package/dist/core/subagent-pool-instance.d.ts +7 -0
  58. package/dist/core/subagent-pool-instance.d.ts.map +1 -1
  59. package/dist/core/subagent-pool-instance.js +14 -1
  60. package/dist/core/subagent-pool-instance.js.map +1 -1
  61. package/dist/core/subagent-pool.d.ts +10 -0
  62. package/dist/core/subagent-pool.d.ts.map +1 -1
  63. package/dist/core/subagent-pool.js +14 -2
  64. package/dist/core/subagent-pool.js.map +1 -1
  65. package/dist/core/system-prompt.d.ts +7 -0
  66. package/dist/core/system-prompt.d.ts.map +1 -1
  67. package/dist/core/system-prompt.js +15 -3
  68. package/dist/core/system-prompt.js.map +1 -1
  69. package/dist/core/tools/bash.d.ts +10 -0
  70. package/dist/core/tools/bash.d.ts.map +1 -1
  71. package/dist/core/tools/bash.js +34 -0
  72. package/dist/core/tools/bash.js.map +1 -1
  73. package/dist/extensions/core/hoo-core.d.ts +10 -3
  74. package/dist/extensions/core/hoo-core.d.ts.map +1 -1
  75. package/dist/extensions/core/hoo-core.js +254 -13
  76. package/dist/extensions/core/hoo-core.js.map +1 -1
  77. package/dist/init-templates.generated.d.ts.map +1 -1
  78. package/dist/init-templates.generated.js +5 -4
  79. package/dist/init-templates.generated.js.map +1 -1
  80. package/dist/init.d.ts.map +1 -1
  81. package/dist/init.js +6 -2
  82. package/dist/init.js.map +1 -1
  83. package/dist/main.d.ts.map +1 -1
  84. package/dist/main.js +4 -0
  85. package/dist/main.js.map +1 -1
  86. package/dist/modes/interactive/components/ask-options.d.ts +44 -0
  87. package/dist/modes/interactive/components/ask-options.d.ts.map +1 -0
  88. package/dist/modes/interactive/components/ask-options.js +202 -0
  89. package/dist/modes/interactive/components/ask-options.js.map +1 -0
  90. package/dist/modes/interactive/components/config-selector.d.ts +1 -1
  91. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  92. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  93. package/dist/modes/interactive/components/index.d.ts +1 -0
  94. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/index.js +1 -0
  96. package/dist/modes/interactive/components/index.js.map +1 -1
  97. package/dist/modes/interactive/components/task-panel.d.ts +15 -4
  98. package/dist/modes/interactive/components/task-panel.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/task-panel.js +178 -63
  100. package/dist/modes/interactive/components/task-panel.js.map +1 -1
  101. package/dist/modes/interactive/interactive-mode.d.ts +10 -0
  102. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  103. package/dist/modes/interactive/interactive-mode.js +51 -2
  104. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  105. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  106. package/dist/modes/rpc/rpc-mode.js +26 -0
  107. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  108. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  109. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  110. package/examples/extensions/sandbox/package.json +1 -1
  111. package/examples/extensions/with-deps/package.json +1 -1
  112. package/examples/sdk/12-full-control.ts +2 -0
  113. package/package.json +4 -4
  114. package/templates/agents/doc.md +1 -1
  115. package/templates/agents/edit.md +1 -0
  116. package/templates/agents/explore.md +3 -3
  117. package/templates/agents/general-purpose.md +36 -0
  118. package/templates/agents/review.md +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAA0B,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAA2C,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AACrH,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAA+C,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAChH,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAA6B,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAA6B,MAAM,sBAAsB,CAAC","sourcesContent":["// UI Components for extensions\nexport { ArminComponent } from \"./armin.js\";\nexport { AssistantMessageComponent } from \"./assistant-message.js\";\nexport { BashExecutionComponent } from \"./bash-execution.js\";\nexport { BorderedLoader } from \"./bordered-loader.js\";\nexport { BranchSummaryMessageComponent } from \"./branch-summary-message.js\";\nexport { CompactionSummaryMessageComponent } from \"./compaction-summary-message.js\";\nexport { CustomEditor } from \"./custom-editor.js\";\nexport { CustomMessageComponent } from \"./custom-message.js\";\nexport { DaxnutsComponent } from \"./daxnuts.js\";\nexport { type RenderDiffOptions, renderDiff } from \"./diff.js\";\nexport { DynamicBorder } from \"./dynamic-border.js\";\nexport { ExtensionEditorComponent } from \"./extension-editor.js\";\nexport { ExtensionInputComponent } from \"./extension-input.js\";\nexport { ExtensionSelectorComponent } from \"./extension-selector.js\";\nexport { FooterComponent } from \"./footer.js\";\nexport { keyHint, keyText, rawKeyHint } from \"./keybinding-hints.js\";\nexport { LoginDialogComponent } from \"./login-dialog.js\";\nexport { ModelSelectorComponent } from \"./model-selector.js\";\nexport { OAuthSelectorComponent } from \"./oauth-selector.js\";\nexport { type ModelsCallbacks, type ModelsConfig, ScopedModelsSelectorComponent } from \"./scoped-models-selector.js\";\nexport { SessionSelectorComponent } from \"./session-selector.js\";\nexport { type SettingsCallbacks, type SettingsConfig, SettingsSelectorComponent } from \"./settings-selector.js\";\nexport { ShowImagesSelectorComponent } from \"./show-images-selector.js\";\nexport { SkillInvocationMessageComponent } from \"./skill-invocation-message.js\";\nexport { TaskPanelComponent } from \"./task-panel.js\";\nexport { ThemeSelectorComponent } from \"./theme-selector.js\";\nexport { ThinkingSelectorComponent } from \"./thinking-selector.js\";\nexport { ToolExecutionComponent, type ToolExecutionOptions } from \"./tool-execution.js\";\nexport { TreeSelectorComponent } from \"./tree-selector.js\";\nexport { UserMessageComponent } from \"./user-message.js\";\nexport { UserMessageSelectorComponent } from \"./user-message-selector.js\";\nexport { truncateToVisualLines, type VisualTruncateResult } from \"./visual-truncate.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CA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AmB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAA6B,MAAM,sBAAsB,CAAC","sourcesContent":["// UI Components for extensions\nexport { ArminComponent } from \"./armin.js\";\nexport { AskOptionsComponent } from \"./ask-options.js\";\nexport { AssistantMessageComponent } from \"./assistant-message.js\";\nexport { BashExecutionComponent } from \"./bash-execution.js\";\nexport { BorderedLoader } from \"./bordered-loader.js\";\nexport { BranchSummaryMessageComponent } from \"./branch-summary-message.js\";\nexport { CompactionSummaryMessageComponent } from \"./compaction-summary-message.js\";\nexport { CustomEditor } from \"./custom-editor.js\";\nexport { CustomMessageComponent } from \"./custom-message.js\";\nexport { DaxnutsComponent } from \"./daxnuts.js\";\nexport { type RenderDiffOptions, renderDiff } from \"./diff.js\";\nexport { DynamicBorder } from \"./dynamic-border.js\";\nexport { ExtensionEditorComponent } from \"./extension-editor.js\";\nexport { ExtensionInputComponent } from \"./extension-input.js\";\nexport { ExtensionSelectorComponent } from \"./extension-selector.js\";\nexport { FooterComponent } from \"./footer.js\";\nexport { keyHint, keyText, rawKeyHint } from \"./keybinding-hints.js\";\nexport { LoginDialogComponent } from \"./login-dialog.js\";\nexport { ModelSelectorComponent } from \"./model-selector.js\";\nexport { OAuthSelectorComponent } from \"./oauth-selector.js\";\nexport { type ModelsCallbacks, type ModelsConfig, ScopedModelsSelectorComponent } from \"./scoped-models-selector.js\";\nexport { SessionSelectorComponent } from \"./session-selector.js\";\nexport { type SettingsCallbacks, type SettingsConfig, SettingsSelectorComponent } from \"./settings-selector.js\";\nexport { ShowImagesSelectorComponent } from \"./show-images-selector.js\";\nexport { SkillInvocationMessageComponent } from \"./skill-invocation-message.js\";\nexport { TaskPanelComponent } from \"./task-panel.js\";\nexport { ThemeSelectorComponent } from \"./theme-selector.js\";\nexport { ThinkingSelectorComponent } from \"./thinking-selector.js\";\nexport { ToolExecutionComponent, type ToolExecutionOptions } from \"./tool-execution.js\";\nexport { TreeSelectorComponent } from \"./tree-selector.js\";\nexport { UserMessageComponent } from \"./user-message.js\";\nexport { UserMessageSelectorComponent } from \"./user-message-selector.js\";\nexport { truncateToVisualLines, type VisualTruncateResult } from \"./visual-truncate.js\";\n"]}
@@ -1,18 +1,29 @@
1
- import type { Component } from "@kolisachint/hoocode-tui";
1
+ import type { Component, TUI } from "@kolisachint/hoocode-tui";
2
2
  /**
3
3
  * Task panel rendered just above the editor prompt.
4
4
  *
5
- * - A ledger header (watched/reviewed stamp + done/total count) tops the list.
5
+ * - A state-colored left rail groups the pane (working=warning, reviewed=success,
6
+ * stopped=error) without drawing a box.
7
+ * - A ledger header tops the list: a state stamp + deterministic progress bar +
8
+ * done/total count on the left, the per-turn token/elapsed/cost delta on the right.
6
9
  * - Shows all tasks with all statuses (pending / in_progress / done / failed).
7
- * - Subagent mode is intentionally NOT shown here (e.g. no "[explore]" tag) — the
8
- * task title is the meaningful label; the mode adds noise in the pane.
10
+ * The active row animates a braille spinner; pending rows read `queued`.
11
+ * - Subagent mode is intentionally NOT shown here (e.g. no "[explore]" tag).
9
12
  * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).
10
13
  * - Finished tasks carry their wall-clock cost and stay visible until the next
11
14
  * user message arrives (see taskStore.reset()), not the moment they finish.
12
15
  * - Collapses to zero lines when there are no tasks.
13
16
  */
14
17
  export declare class TaskPanelComponent implements Component {
18
+ private readonly ui;
19
+ private frame;
20
+ private animationTimer;
21
+ constructor(ui?: TUI);
15
22
  invalidate(): void;
23
+ /** Run the spinner timer only while a task is active, ticking re-renders. */
24
+ private ensureAnimation;
25
+ /** Stop the spinner timer. Call on teardown. */
26
+ dispose(): void;
16
27
  render(width: number): string[];
17
28
  }
18
29
  //# sourceMappingURL=task-panel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"task-panel.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAwJ1D;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IACnD,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAW9B;CACD","sourcesContent":["import type { Component } from \"@kolisachint/hoocode-tui\";\nimport { truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { Task, TaskStatus } from \"../../../core/task-store.js\";\nimport { taskStore } from \"../../../core/task-store.js\";\nimport { theme } from \"../theme/theme.js\";\n\nconst TASK_STATUS_ICON: Record<TaskStatus, string> = {\n\tpending: \"●\",\n\tin_progress: \"◐\",\n\tdone: \"✓\",\n\tfailed: \"✗\",\n};\n\nfunction taskStatusColor(status: TaskStatus): \"dim\" | \"warning\" | \"success\" | \"error\" {\n\tswitch (status) {\n\t\tcase \"in_progress\":\n\t\t\treturn \"warning\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tdefault:\n\t\t\treturn \"dim\";\n\t}\n}\n\n/** Wall-clock time a task occupied, derived from its create/update stamps. */\nfunction formatElapsed(task: Task): string {\n\tconst secs = Math.max(0, (task.updatedAt - task.createdAt) / 1000);\n\tif (secs < 10) return `${secs.toFixed(1)}s`;\n\tif (secs < 60) return `${Math.round(secs)}s`;\n\tconst mins = Math.floor(secs / 60);\n\tconst rem = Math.round(secs % 60);\n\treturn `${mins}m${rem.toString().padStart(2, \"0\")}s`;\n}\n\n/** Sum the token + cost usage reported by the tasks shown this turn. */\nfunction sumTurnUsage(tasks: readonly Task[]): { input: number; output: number; cost: number } | null {\n\tlet input = 0;\n\tlet output = 0;\n\tlet cost = 0;\n\tfor (const task of tasks) {\n\t\tif (!task.usage) continue;\n\t\tinput += task.usage.input;\n\t\toutput += task.usage.output;\n\t\tcost += task.usage.cost;\n\t}\n\tif (input === 0 && output === 0 && cost === 0) return null;\n\treturn { input, output, cost };\n}\n\n/**\n * Ledger header: a watched/reviewed stamp plus done/total count on the left, and\n * the per-turn token + cost delta (summed across the tasks below) on the right.\n * The panel is an audit trail — the stamp makes the deterministic \"every task\n * watched & reviewed\" state glanceable, and the delta surfaces what the turn cost.\n */\nfunction formatHeader(tasks: readonly Task[], width: number): string {\n\tconst total = tasks.length;\n\tconst done = tasks.filter((t) => t.status === \"done\").length;\n\tconst watching = tasks.some((t) => t.status === \"in_progress\" || t.status === \"pending\");\n\n\tconst stampPlain = watching ? \"⟳ watching\" : \"reviewed ✓ · deterministic\";\n\t// Header is quiet audit chrome: the reviewed stamp sits in dim, only the active\n\t// \"watching\" state earns a warning tint. (Design: .task-head color = fg-dim.)\n\tconst stamp = watching ? theme.fg(\"warning\", \"⟳ watching\") : theme.fg(\"dim\", stampPlain);\n\n\tconst countPlain = `${done}/${total} done`;\n\tconst leftPlain = `${stampPlain} ${countPlain}`;\n\tconst left = `${stamp} ${theme.fg(\"dim\", countPlain)}`;\n\n\tconst turn = sumTurnUsage(tasks);\n\tif (!turn) {\n\t\treturn truncateToWidth(left, width, \"…\");\n\t}\n\n\t// Cost is omitted when zero (e.g. subscription/untracked) — still show tokens.\n\tconst showCost = turn.cost > 0;\n\tconst costPlain = showCost ? ` $${turn.cost.toFixed(3)}` : \"\";\n\tconst turnPlain = `turn ↑${formatTokens(turn.input)} ↓${formatTokens(turn.output)}${costPlain}`;\n\t// Turn delta: muted framing with the numbers one step brighter (bold/full fg),\n\t// matching the design's `.turntok` (fg-muted) / `.turntok b` (fg) hierarchy.\n\tlet turnText =\n\t\ttheme.fg(\"muted\", \"turn ↑\") +\n\t\ttheme.bold(formatTokens(turn.input)) +\n\t\ttheme.fg(\"muted\", \" ↓\") +\n\t\ttheme.bold(formatTokens(turn.output));\n\tif (showCost) {\n\t\tturnText += ` ${theme.bold(`$${turn.cost.toFixed(3)}`)}`;\n\t}\n\n\tif (visibleWidth(leftPlain) + 2 + visibleWidth(turnPlain) > width) {\n\t\t// Too narrow for both — keep the stamp + count.\n\t\treturn truncateToWidth(left, width, \"…\");\n\t}\n\tconst pad = Math.max(2, width - visibleWidth(leftPlain) - visibleWidth(turnPlain));\n\treturn left + \" \".repeat(pad) + turnText;\n}\n\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\treturn `${(count / 1000000).toFixed(1)}M`;\n}\n\nfunction formatTaskLine(task: Task, width: number): string {\n\tconst icon = theme.fg(taskStatusColor(task.status), TASK_STATUS_ICON[task.status]);\n\tconst idLabel = `#${task.id}`;\n\tconst title = task.title;\n\t// The id recedes (dim) so the title carries the line. Done tasks fade their\n\t// title to muted (work that's settled); active/failed keep full foreground.\n\t// (Design: .task .id = fg-dim, .task .ttitle = fg, .task.is-done .ttitle = fg-muted.)\n\tconst styledId = theme.fg(\"dim\", idLabel);\n\tconst styledTitle = task.status === \"done\" ? theme.fg(\"muted\", title) : title;\n\n\t// Finished tasks carry an audit stamp: total tokens used + elapsed time. The\n\t// token count sits one step brighter (muted) than the time (dim), per the\n\t// design's `.cost` (fg-dim) / `.cost b` (fg-muted) split.\n\tconst settled = task.status === \"done\" || task.status === \"failed\";\n\tlet rightPlain = \"\";\n\tlet rightStyled = \"\";\n\tif (settled) {\n\t\tconst parts: string[] = [];\n\t\tlet tokenText = \"\";\n\t\tif (task.usage) {\n\t\t\tconst total = task.usage.input + task.usage.output;\n\t\t\tif (total > 0) tokenText = formatTokens(total);\n\t\t}\n\t\tconst elapsed = formatElapsed(task);\n\t\tif (tokenText) {\n\t\t\tparts.push(tokenText, elapsed);\n\t\t\trightStyled = theme.fg(\"muted\", tokenText) + theme.fg(\"dim\", ` · ${elapsed}`);\n\t\t} else {\n\t\t\tparts.push(elapsed);\n\t\t\trightStyled = theme.fg(\"dim\", elapsed);\n\t\t}\n\t\trightPlain = parts.join(\" · \");\n\t}\n\tconst rightWidth = rightPlain ? visibleWidth(rightPlain) + 1 : 0;\n\tconst leftWidth = Math.max(0, width - rightWidth);\n\n\tconst plainText = `${TASK_STATUS_ICON[task.status]} ${idLabel} ${title}`;\n\tconst available = Math.max(0, leftWidth - visibleWidth(plainText) + visibleWidth(title));\n\tconst left = truncateToWidth(`${icon} ${styledId} ${styledTitle}`, available, \"…\");\n\n\tif (!rightPlain) return left;\n\n\tconst pad = Math.max(1, width - visibleWidth(left) - visibleWidth(rightPlain));\n\treturn left + \" \".repeat(pad) + rightStyled;\n}\n\n/**\n * Task panel rendered just above the editor prompt.\n *\n * - A ledger header (watched/reviewed stamp + done/total count) tops the list.\n * - Shows all tasks with all statuses (pending / in_progress / done / failed).\n * - Subagent mode is intentionally NOT shown here (e.g. no \"[explore]\" tag) — the\n * task title is the meaningful label; the mode adds noise in the pane.\n * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).\n * - Finished tasks carry their wall-clock cost and stay visible until the next\n * user message arrives (see taskStore.reset()), not the moment they finish.\n * - Collapses to zero lines when there are no tasks.\n */\nexport class TaskPanelComponent implements Component {\n\tinvalidate(): void {\n\t\t// No cached rendering state.\n\t}\n\n\trender(width: number): string[] {\n\t\tconst tasks = taskStore.list();\n\t\tif (tasks.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst lines: string[] = [formatHeader(tasks, width)];\n\t\tfor (const task of tasks) {\n\t\t\tlines.push(formatTaskLine(task, width));\n\t\t}\n\t\treturn lines;\n\t}\n}\n"]}
1
+ {"version":3,"file":"task-panel.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAiP/D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IACnD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAa;IAChC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,cAAc,CAA+C;IAErE,YAAY,EAAE,CAAC,EAAE,GAAG,EAEnB;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,6EAA6E;IAC7E,OAAO,CAAC,eAAe;IAcvB,gDAAgD;IAChD,OAAO,IAAI,IAAI,CAKd;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB9B;CACD","sourcesContent":["import type { Component, TUI } from \"@kolisachint/hoocode-tui\";\nimport { truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { Task, TaskStatus } from \"../../../core/task-store.js\";\nimport { taskStore } from \"../../../core/task-store.js\";\nimport { theme } from \"../theme/theme.js\";\n\nconst TASK_STATUS_ICON: Record<TaskStatus, string> = {\n\tpending: \"●\",\n\tin_progress: \"◐\",\n\tdone: \"✓\",\n\tfailed: \"✗\",\n};\n\n/** Braille spinner frames + cadence, matched to the TUI Loader so the active row animates in step. */\nconst SPINNER_FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\nconst SPINNER_INTERVAL_MS = 80;\n\n/** A thin colored left rail groups the pane without a box, the way the design's `border-left` does. */\nconst RAIL = \"▎\";\n\n/** Cells in the deterministic progress bar (matches the design's 14-cell track). */\nconst PROGRESS_CELLS = 14;\n\n/** Overall pane state, derived from the task statuses. Drives the rail color + header stamp. */\ntype PanelState = \"working\" | \"reviewed\" | \"stopped\";\n\ninterface StatePresentation {\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly color: \"warning\" | \"success\" | \"error\";\n}\n\nconst STATE_PRESENTATION: Record<PanelState, StatePresentation> = {\n\tworking: { icon: \"◐\", label: \"working\", color: \"warning\" },\n\treviewed: { icon: \"✓\", label: \"reviewed\", color: \"success\" },\n\tstopped: { icon: \"✗\", label: \"stopped\", color: \"error\" },\n};\n\nfunction panelState(tasks: readonly Task[]): PanelState {\n\tif (tasks.some((t) => t.status === \"failed\")) return \"stopped\";\n\tconst active = tasks.some((t) => t.status === \"in_progress\" || t.status === \"pending\");\n\treturn active ? \"working\" : \"reviewed\";\n}\n\nfunction taskStatusColor(status: TaskStatus): \"dim\" | \"warning\" | \"success\" | \"error\" {\n\tswitch (status) {\n\t\tcase \"in_progress\":\n\t\t\treturn \"warning\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tdefault:\n\t\t\treturn \"dim\";\n\t}\n}\n\n/** Format a duration in seconds into a compact, terminal-friendly string. */\nfunction formatDuration(secs: number): string {\n\tconst s = Math.max(0, secs);\n\tif (s < 10) return `${s.toFixed(1)}s`;\n\tif (s < 60) return `${Math.round(s)}s`;\n\tconst mins = Math.floor(s / 60);\n\tconst rem = Math.round(s % 60);\n\treturn `${mins}m${rem.toString().padStart(2, \"0\")}s`;\n}\n\n/** Wall-clock time a task occupied, derived from its create/update stamps. */\nfunction taskElapsedSecs(task: Task): number {\n\treturn Math.max(0, (task.updatedAt - task.createdAt) / 1000);\n}\n\n/** Sum the token + cost usage reported by the tasks shown this turn. */\nfunction sumTurnUsage(tasks: readonly Task[]): { input: number; output: number; cost: number } | null {\n\tlet input = 0;\n\tlet output = 0;\n\tlet cost = 0;\n\tfor (const task of tasks) {\n\t\tif (!task.usage) continue;\n\t\tinput += task.usage.input;\n\t\toutput += task.usage.output;\n\t\tcost += task.usage.cost;\n\t}\n\tif (input === 0 && output === 0 && cost === 0) return null;\n\treturn { input, output, cost };\n}\n\n/**\n * Deterministic block-glyph progress bar: a heavy run (━) for the completed\n * fraction over a dim track. In-progress tasks count as half, so the bar moves\n * the moment work starts. Fraction is the only input — no animation, no guess.\n */\nfunction progressBar(done: number, active: number, total: number): { plain: string; styled: string } {\n\tconst ratio = total > 0 ? Math.max(0, Math.min(1, (done + active * 0.5) / total)) : 0;\n\tconst filled = Math.round(ratio * PROGRESS_CELLS);\n\tconst fill = \"━\".repeat(filled);\n\tconst track = \"━\".repeat(PROGRESS_CELLS - filled);\n\treturn {\n\t\tplain: fill + track,\n\t\tstyled: theme.fg(\"success\", fill) + theme.fg(\"dim\", track),\n\t};\n}\n\n/**\n * Ledger header: a state stamp (◐ working / ✓ reviewed / ✗ stopped) + a\n * deterministic progress bar and done/total count on the left, and the per-turn\n * token + elapsed + cost delta (summed across the tasks below) on the right.\n */\nfunction formatHeader(tasks: readonly Task[], width: number, state: PanelState, totalSecs: number): string {\n\tconst total = tasks.length;\n\tconst done = tasks.filter((t) => t.status === \"done\").length;\n\tconst active = tasks.filter((t) => t.status === \"in_progress\").length;\n\n\tconst { icon, label, color } = STATE_PRESENTATION[state];\n\tconst stampPlain = `${icon} ${label.toUpperCase()}`;\n\tconst stamp = `${theme.fg(color, icon)} ${theme.bold(theme.fg(color, label.toUpperCase()))}`;\n\n\tconst bar = progressBar(done, active, total);\n\tconst countPlain = `${done}/${total}`;\n\tconst count = theme.fg(\"muted\", `${done}`) + theme.fg(\"dim\", \"/\") + theme.fg(\"muted\", `${total}`);\n\n\t// Left cluster has a full form (stamp · bar · count) and a compact fallback\n\t// (stamp · count) that drops the bar when the terminal is too narrow.\n\tconst leftFullPlain = `${stampPlain} ${bar.plain} ${countPlain}`;\n\tconst leftFull = `${stamp} ${bar.styled} ${count}`;\n\tconst leftMinPlain = `${stampPlain} ${countPlain}`;\n\tconst leftMin = `${stamp} ${count}`;\n\n\tconst turn = sumTurnUsage(tasks);\n\tlet turnPlain = \"\";\n\tlet turnText = \"\";\n\tif (turn) {\n\t\tconst inTok = formatTokens(turn.input);\n\t\tconst outTok = formatTokens(turn.output);\n\t\tconst elapsed = formatDuration(totalSecs);\n\t\tconst showCost = turn.cost > 0;\n\t\tconst costStr = showCost ? `$${turn.cost.toFixed(3)}` : \"\";\n\t\tturnPlain = `turn ↑${inTok} ↓${outTok} · ${elapsed}${showCost ? ` · ${costStr}` : \"\"}`;\n\t\t// Turn delta: muted framing, numbers one step brighter (bold), separators dim.\n\t\tturnText =\n\t\t\ttheme.fg(\"muted\", \"turn ↑\") +\n\t\t\ttheme.bold(inTok) +\n\t\t\ttheme.fg(\"muted\", \" ↓\") +\n\t\t\ttheme.bold(outTok) +\n\t\t\ttheme.fg(\"dim\", \" · \") +\n\t\t\ttheme.fg(\"muted\", elapsed) +\n\t\t\t(showCost ? theme.fg(\"dim\", \" · \") + theme.bold(costStr) : \"\");\n\t}\n\n\tif (turnPlain) {\n\t\tif (visibleWidth(leftFullPlain) + 2 + visibleWidth(turnPlain) <= width) {\n\t\t\tconst pad = Math.max(2, width - visibleWidth(leftFullPlain) - visibleWidth(turnPlain));\n\t\t\treturn leftFull + \" \".repeat(pad) + turnText;\n\t\t}\n\t\tif (visibleWidth(leftMinPlain) + 2 + visibleWidth(turnPlain) <= width) {\n\t\t\tconst pad = Math.max(2, width - visibleWidth(leftMinPlain) - visibleWidth(turnPlain));\n\t\t\treturn leftMin + \" \".repeat(pad) + turnText;\n\t\t}\n\t}\n\tif (visibleWidth(leftFullPlain) <= width) return leftFull;\n\treturn truncateToWidth(leftMin, width, \"…\");\n}\n\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\treturn `${(count / 1000000).toFixed(1)}M`;\n}\n\nfunction formatTaskLine(task: Task, width: number, frame: number): string {\n\tconst isProgress = task.status === \"in_progress\";\n\tconst iconGlyph = isProgress\n\t\t? (SPINNER_FRAMES[frame] ?? TASK_STATUS_ICON.in_progress)\n\t\t: TASK_STATUS_ICON[task.status];\n\tconst icon = theme.fg(taskStatusColor(task.status), iconGlyph);\n\n\tconst idLabel = `#${task.id}`;\n\tconst title = task.title;\n\t// The id recedes (dim); the title carries the line. Done titles fade to muted\n\t// (settled work), pending dim (not started), active goes bold, failed turns red.\n\tconst styledId = theme.fg(\"dim\", idLabel);\n\tlet styledTitle: string;\n\tswitch (task.status) {\n\t\tcase \"done\":\n\t\t\tstyledTitle = theme.fg(\"muted\", title);\n\t\t\tbreak;\n\t\tcase \"pending\":\n\t\t\tstyledTitle = theme.fg(\"dim\", title);\n\t\t\tbreak;\n\t\tcase \"failed\":\n\t\t\tstyledTitle = theme.fg(\"error\", title);\n\t\t\tbreak;\n\t\tcase \"in_progress\":\n\t\t\tstyledTitle = theme.bold(title);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstyledTitle = title;\n\t}\n\n\t// Right column: settled rows carry their audit stamp (tokens + elapsed); the\n\t// active row reads `running…`, pending rows read `queued`.\n\tlet rightPlain = \"\";\n\tlet rightStyled = \"\";\n\tif (task.status === \"done\" || task.status === \"failed\") {\n\t\tconst parts: string[] = [];\n\t\tlet tokenText = \"\";\n\t\tif (task.usage) {\n\t\t\tconst totalTok = task.usage.input + task.usage.output;\n\t\t\tif (totalTok > 0) tokenText = formatTokens(totalTok);\n\t\t}\n\t\tconst elapsed = formatDuration(taskElapsedSecs(task));\n\t\tif (tokenText) {\n\t\t\tparts.push(tokenText, elapsed);\n\t\t\trightStyled = theme.fg(\"muted\", tokenText) + theme.fg(\"dim\", ` · ${elapsed}`);\n\t\t} else {\n\t\t\tparts.push(elapsed);\n\t\t\trightStyled = theme.fg(\"dim\", elapsed);\n\t\t}\n\t\trightPlain = parts.join(\" · \");\n\t} else if (task.status === \"in_progress\") {\n\t\trightPlain = \"running…\";\n\t\trightStyled = theme.fg(\"warning\", rightPlain);\n\t} else if (task.status === \"pending\") {\n\t\trightPlain = \"queued\";\n\t\trightStyled = theme.fg(\"dim\", rightPlain);\n\t}\n\n\tconst rightWidth = rightPlain ? visibleWidth(rightPlain) + 1 : 0;\n\tconst leftWidth = Math.max(0, width - rightWidth);\n\n\tconst plainText = `${iconGlyph} ${idLabel} ${title}`;\n\tconst available = Math.max(0, leftWidth - visibleWidth(plainText) + visibleWidth(title));\n\tconst left = truncateToWidth(`${icon} ${styledId} ${styledTitle}`, available, \"…\");\n\n\tif (!rightPlain) return left;\n\n\tconst pad = Math.max(1, width - visibleWidth(left) - visibleWidth(rightPlain));\n\treturn left + \" \".repeat(pad) + rightStyled;\n}\n\n/**\n * Task panel rendered just above the editor prompt.\n *\n * - A state-colored left rail groups the pane (working=warning, reviewed=success,\n * stopped=error) without drawing a box.\n * - A ledger header tops the list: a state stamp + deterministic progress bar +\n * done/total count on the left, the per-turn token/elapsed/cost delta on the right.\n * - Shows all tasks with all statuses (pending / in_progress / done / failed).\n * The active row animates a braille spinner; pending rows read `queued`.\n * - Subagent mode is intentionally NOT shown here (e.g. no \"[explore]\" tag).\n * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).\n * - Finished tasks carry their wall-clock cost and stay visible until the next\n * user message arrives (see taskStore.reset()), not the moment they finish.\n * - Collapses to zero lines when there are no tasks.\n */\nexport class TaskPanelComponent implements Component {\n\tprivate readonly ui: TUI | null;\n\tprivate frame = 0;\n\tprivate animationTimer: ReturnType<typeof setInterval> | null = null;\n\n\tconstructor(ui?: TUI) {\n\t\tthis.ui = ui ?? null;\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached rendering state.\n\t}\n\n\t/** Run the spinner timer only while a task is active, ticking re-renders. */\n\tprivate ensureAnimation(active: boolean): void {\n\t\tif (active && this.ui && !this.animationTimer) {\n\t\t\tthis.animationTimer = setInterval(() => {\n\t\t\t\tthis.frame = (this.frame + 1) % SPINNER_FRAMES.length;\n\t\t\t\tthis.ui?.requestRender();\n\t\t\t}, SPINNER_INTERVAL_MS);\n\t\t\tthis.animationTimer.unref?.();\n\t\t} else if (!active && this.animationTimer) {\n\t\t\tclearInterval(this.animationTimer);\n\t\t\tthis.animationTimer = null;\n\t\t\tthis.frame = 0;\n\t\t}\n\t}\n\n\t/** Stop the spinner timer. Call on teardown. */\n\tdispose(): void {\n\t\tif (this.animationTimer) {\n\t\t\tclearInterval(this.animationTimer);\n\t\t\tthis.animationTimer = null;\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tconst tasks = taskStore.list();\n\t\tif (tasks.length === 0) {\n\t\t\tthis.ensureAnimation(false);\n\t\t\treturn [];\n\t\t}\n\n\t\tconst hasActive = tasks.some((t) => t.status === \"in_progress\");\n\t\tthis.ensureAnimation(hasActive);\n\n\t\tconst state = panelState(tasks);\n\t\tconst totalSecs = tasks.reduce((sum, t) => sum + taskElapsedSecs(t), 0);\n\t\tconst railColor = STATE_PRESENTATION[state].color;\n\t\tconst gutter = `${theme.fg(railColor, RAIL)} `;\n\t\tconst inner = Math.max(0, width - visibleWidth(RAIL) - 1);\n\n\t\tconst lines: string[] = [gutter + formatHeader(tasks, inner, state, totalSecs)];\n\t\tfor (const task of tasks) {\n\t\t\tlines.push(gutter + formatTaskLine(task, inner, this.frame));\n\t\t}\n\t\treturn lines;\n\t}\n}\n"]}
@@ -7,6 +7,24 @@ const TASK_STATUS_ICON = {
7
7
  done: "✓",
8
8
  failed: "✗",
9
9
  };
10
+ /** Braille spinner frames + cadence, matched to the TUI Loader so the active row animates in step. */
11
+ const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
12
+ const SPINNER_INTERVAL_MS = 80;
13
+ /** A thin colored left rail groups the pane without a box, the way the design's `border-left` does. */
14
+ const RAIL = "▎";
15
+ /** Cells in the deterministic progress bar (matches the design's 14-cell track). */
16
+ const PROGRESS_CELLS = 14;
17
+ const STATE_PRESENTATION = {
18
+ working: { icon: "◐", label: "working", color: "warning" },
19
+ reviewed: { icon: "✓", label: "reviewed", color: "success" },
20
+ stopped: { icon: "✗", label: "stopped", color: "error" },
21
+ };
22
+ function panelState(tasks) {
23
+ if (tasks.some((t) => t.status === "failed"))
24
+ return "stopped";
25
+ const active = tasks.some((t) => t.status === "in_progress" || t.status === "pending");
26
+ return active ? "working" : "reviewed";
27
+ }
10
28
  function taskStatusColor(status) {
11
29
  switch (status) {
12
30
  case "in_progress":
@@ -19,17 +37,21 @@ function taskStatusColor(status) {
19
37
  return "dim";
20
38
  }
21
39
  }
22
- /** Wall-clock time a task occupied, derived from its create/update stamps. */
23
- function formatElapsed(task) {
24
- const secs = Math.max(0, (task.updatedAt - task.createdAt) / 1000);
25
- if (secs < 10)
26
- return `${secs.toFixed(1)}s`;
27
- if (secs < 60)
28
- return `${Math.round(secs)}s`;
29
- const mins = Math.floor(secs / 60);
30
- const rem = Math.round(secs % 60);
40
+ /** Format a duration in seconds into a compact, terminal-friendly string. */
41
+ function formatDuration(secs) {
42
+ const s = Math.max(0, secs);
43
+ if (s < 10)
44
+ return `${s.toFixed(1)}s`;
45
+ if (s < 60)
46
+ return `${Math.round(s)}s`;
47
+ const mins = Math.floor(s / 60);
48
+ const rem = Math.round(s % 60);
31
49
  return `${mins}m${rem.toString().padStart(2, "0")}s`;
32
50
  }
51
+ /** Wall-clock time a task occupied, derived from its create/update stamps. */
52
+ function taskElapsedSecs(task) {
53
+ return Math.max(0, (task.updatedAt - task.createdAt) / 1000);
54
+ }
33
55
  /** Sum the token + cost usage reported by the tasks shown this turn. */
34
56
  function sumTurnUsage(tasks) {
35
57
  let input = 0;
@@ -47,45 +69,74 @@ function sumTurnUsage(tasks) {
47
69
  return { input, output, cost };
48
70
  }
49
71
  /**
50
- * Ledger header: a watched/reviewed stamp plus done/total count on the left, and
51
- * the per-turn token + cost delta (summed across the tasks below) on the right.
52
- * The panel is an audit trail the stamp makes the deterministic "every task
53
- * watched & reviewed" state glanceable, and the delta surfaces what the turn cost.
72
+ * Deterministic block-glyph progress bar: a heavy run (━) for the completed
73
+ * fraction over a dim track. In-progress tasks count as half, so the bar moves
74
+ * the moment work starts. Fraction is the only input no animation, no guess.
75
+ */
76
+ function progressBar(done, active, total) {
77
+ const ratio = total > 0 ? Math.max(0, Math.min(1, (done + active * 0.5) / total)) : 0;
78
+ const filled = Math.round(ratio * PROGRESS_CELLS);
79
+ const fill = "━".repeat(filled);
80
+ const track = "━".repeat(PROGRESS_CELLS - filled);
81
+ return {
82
+ plain: fill + track,
83
+ styled: theme.fg("success", fill) + theme.fg("dim", track),
84
+ };
85
+ }
86
+ /**
87
+ * Ledger header: a state stamp (◐ working / ✓ reviewed / ✗ stopped) + a
88
+ * deterministic progress bar and done/total count on the left, and the per-turn
89
+ * token + elapsed + cost delta (summed across the tasks below) on the right.
54
90
  */
55
- function formatHeader(tasks, width) {
91
+ function formatHeader(tasks, width, state, totalSecs) {
56
92
  const total = tasks.length;
57
93
  const done = tasks.filter((t) => t.status === "done").length;
58
- const watching = tasks.some((t) => t.status === "in_progress" || t.status === "pending");
59
- const stampPlain = watching ? "⟳ watching" : "reviewed ✓ · deterministic";
60
- // Header is quiet audit chrome: the reviewed stamp sits in dim, only the active
61
- // "watching" state earns a warning tint. (Design: .task-head color = fg-dim.)
62
- const stamp = watching ? theme.fg("warning", "⟳ watching") : theme.fg("dim", stampPlain);
63
- const countPlain = `${done}/${total} done`;
64
- const leftPlain = `${stampPlain} ${countPlain}`;
65
- const left = `${stamp} ${theme.fg("dim", countPlain)}`;
94
+ const active = tasks.filter((t) => t.status === "in_progress").length;
95
+ const { icon, label, color } = STATE_PRESENTATION[state];
96
+ const stampPlain = `${icon} ${label.toUpperCase()}`;
97
+ const stamp = `${theme.fg(color, icon)} ${theme.bold(theme.fg(color, label.toUpperCase()))}`;
98
+ const bar = progressBar(done, active, total);
99
+ const countPlain = `${done}/${total}`;
100
+ const count = theme.fg("muted", `${done}`) + theme.fg("dim", "/") + theme.fg("muted", `${total}`);
101
+ // Left cluster has a full form (stamp · bar · count) and a compact fallback
102
+ // (stamp · count) that drops the bar when the terminal is too narrow.
103
+ const leftFullPlain = `${stampPlain} ${bar.plain} ${countPlain}`;
104
+ const leftFull = `${stamp} ${bar.styled} ${count}`;
105
+ const leftMinPlain = `${stampPlain} ${countPlain}`;
106
+ const leftMin = `${stamp} ${count}`;
66
107
  const turn = sumTurnUsage(tasks);
67
- if (!turn) {
68
- return truncateToWidth(left, width, "");
69
- }
70
- // Cost is omitted when zero (e.g. subscription/untracked) — still show tokens.
71
- const showCost = turn.cost > 0;
72
- const costPlain = showCost ? ` $${turn.cost.toFixed(3)}` : "";
73
- const turnPlain = `turn ↑${formatTokens(turn.input)} ↓${formatTokens(turn.output)}${costPlain}`;
74
- // Turn delta: muted framing with the numbers one step brighter (bold/full fg),
75
- // matching the design's `.turntok` (fg-muted) / `.turntok b` (fg) hierarchy.
76
- let turnText = theme.fg("muted", "turn ↑") +
77
- theme.bold(formatTokens(turn.input)) +
78
- theme.fg("muted", " ") +
79
- theme.bold(formatTokens(turn.output));
80
- if (showCost) {
81
- turnText += ` ${theme.bold(`$${turn.cost.toFixed(3)}`)}`;
108
+ let turnPlain = "";
109
+ let turnText = "";
110
+ if (turn) {
111
+ const inTok = formatTokens(turn.input);
112
+ const outTok = formatTokens(turn.output);
113
+ const elapsed = formatDuration(totalSecs);
114
+ const showCost = turn.cost > 0;
115
+ const costStr = showCost ? `$${turn.cost.toFixed(3)}` : "";
116
+ turnPlain = `turn ↑${inTok} ↓${outTok} · ${elapsed}${showCost ? ` · ${costStr}` : ""}`;
117
+ // Turn delta: muted framing, numbers one step brighter (bold), separators dim.
118
+ turnText =
119
+ theme.fg("muted", "turn ") +
120
+ theme.bold(inTok) +
121
+ theme.fg("muted", " ↓") +
122
+ theme.bold(outTok) +
123
+ theme.fg("dim", " · ") +
124
+ theme.fg("muted", elapsed) +
125
+ (showCost ? theme.fg("dim", " · ") + theme.bold(costStr) : "");
82
126
  }
83
- if (visibleWidth(leftPlain) + 2 + visibleWidth(turnPlain) > width) {
84
- // Too narrow for both keep the stamp + count.
85
- return truncateToWidth(left, width, "…");
127
+ if (turnPlain) {
128
+ if (visibleWidth(leftFullPlain) + 2 + visibleWidth(turnPlain) <= width) {
129
+ const pad = Math.max(2, width - visibleWidth(leftFullPlain) - visibleWidth(turnPlain));
130
+ return leftFull + " ".repeat(pad) + turnText;
131
+ }
132
+ if (visibleWidth(leftMinPlain) + 2 + visibleWidth(turnPlain) <= width) {
133
+ const pad = Math.max(2, width - visibleWidth(leftMinPlain) - visibleWidth(turnPlain));
134
+ return leftMin + " ".repeat(pad) + turnText;
135
+ }
86
136
  }
87
- const pad = Math.max(2, width - visibleWidth(leftPlain) - visibleWidth(turnPlain));
88
- return left + " ".repeat(pad) + turnText;
137
+ if (visibleWidth(leftFullPlain) <= width)
138
+ return leftFull;
139
+ return truncateToWidth(leftMin, width, "…");
89
140
  }
90
141
  function formatTokens(count) {
91
142
  if (count < 1000)
@@ -96,30 +147,47 @@ function formatTokens(count) {
96
147
  return `${Math.round(count / 1000)}k`;
97
148
  return `${(count / 1000000).toFixed(1)}M`;
98
149
  }
99
- function formatTaskLine(task, width) {
100
- const icon = theme.fg(taskStatusColor(task.status), TASK_STATUS_ICON[task.status]);
150
+ function formatTaskLine(task, width, frame) {
151
+ const isProgress = task.status === "in_progress";
152
+ const iconGlyph = isProgress
153
+ ? (SPINNER_FRAMES[frame] ?? TASK_STATUS_ICON.in_progress)
154
+ : TASK_STATUS_ICON[task.status];
155
+ const icon = theme.fg(taskStatusColor(task.status), iconGlyph);
101
156
  const idLabel = `#${task.id}`;
102
157
  const title = task.title;
103
- // The id recedes (dim) so the title carries the line. Done tasks fade their
104
- // title to muted (work that's settled); active/failed keep full foreground.
105
- // (Design: .task .id = fg-dim, .task .ttitle = fg, .task.is-done .ttitle = fg-muted.)
158
+ // The id recedes (dim); the title carries the line. Done titles fade to muted
159
+ // (settled work), pending dim (not started), active goes bold, failed turns red.
106
160
  const styledId = theme.fg("dim", idLabel);
107
- const styledTitle = task.status === "done" ? theme.fg("muted", title) : title;
108
- // Finished tasks carry an audit stamp: total tokens used + elapsed time. The
109
- // token count sits one step brighter (muted) than the time (dim), per the
110
- // design's `.cost` (fg-dim) / `.cost b` (fg-muted) split.
111
- const settled = task.status === "done" || task.status === "failed";
161
+ let styledTitle;
162
+ switch (task.status) {
163
+ case "done":
164
+ styledTitle = theme.fg("muted", title);
165
+ break;
166
+ case "pending":
167
+ styledTitle = theme.fg("dim", title);
168
+ break;
169
+ case "failed":
170
+ styledTitle = theme.fg("error", title);
171
+ break;
172
+ case "in_progress":
173
+ styledTitle = theme.bold(title);
174
+ break;
175
+ default:
176
+ styledTitle = title;
177
+ }
178
+ // Right column: settled rows carry their audit stamp (tokens + elapsed); the
179
+ // active row reads `running…`, pending rows read `queued`.
112
180
  let rightPlain = "";
113
181
  let rightStyled = "";
114
- if (settled) {
182
+ if (task.status === "done" || task.status === "failed") {
115
183
  const parts = [];
116
184
  let tokenText = "";
117
185
  if (task.usage) {
118
- const total = task.usage.input + task.usage.output;
119
- if (total > 0)
120
- tokenText = formatTokens(total);
186
+ const totalTok = task.usage.input + task.usage.output;
187
+ if (totalTok > 0)
188
+ tokenText = formatTokens(totalTok);
121
189
  }
122
- const elapsed = formatElapsed(task);
190
+ const elapsed = formatDuration(taskElapsedSecs(task));
123
191
  if (tokenText) {
124
192
  parts.push(tokenText, elapsed);
125
193
  rightStyled = theme.fg("muted", tokenText) + theme.fg("dim", ` · ${elapsed}`);
@@ -130,9 +198,17 @@ function formatTaskLine(task, width) {
130
198
  }
131
199
  rightPlain = parts.join(" · ");
132
200
  }
201
+ else if (task.status === "in_progress") {
202
+ rightPlain = "running…";
203
+ rightStyled = theme.fg("warning", rightPlain);
204
+ }
205
+ else if (task.status === "pending") {
206
+ rightPlain = "queued";
207
+ rightStyled = theme.fg("dim", rightPlain);
208
+ }
133
209
  const rightWidth = rightPlain ? visibleWidth(rightPlain) + 1 : 0;
134
210
  const leftWidth = Math.max(0, width - rightWidth);
135
- const plainText = `${TASK_STATUS_ICON[task.status]} ${idLabel} ${title}`;
211
+ const plainText = `${iconGlyph} ${idLabel} ${title}`;
136
212
  const available = Math.max(0, leftWidth - visibleWidth(plainText) + visibleWidth(title));
137
213
  const left = truncateToWidth(`${icon} ${styledId} ${styledTitle}`, available, "…");
138
214
  if (!rightPlain)
@@ -143,27 +219,66 @@ function formatTaskLine(task, width) {
143
219
  /**
144
220
  * Task panel rendered just above the editor prompt.
145
221
  *
146
- * - A ledger header (watched/reviewed stamp + done/total count) tops the list.
222
+ * - A state-colored left rail groups the pane (working=warning, reviewed=success,
223
+ * stopped=error) without drawing a box.
224
+ * - A ledger header tops the list: a state stamp + deterministic progress bar +
225
+ * done/total count on the left, the per-turn token/elapsed/cost delta on the right.
147
226
  * - Shows all tasks with all statuses (pending / in_progress / done / failed).
148
- * - Subagent mode is intentionally NOT shown here (e.g. no "[explore]" tag) — the
149
- * task title is the meaningful label; the mode adds noise in the pane.
227
+ * The active row animates a braille spinner; pending rows read `queued`.
228
+ * - Subagent mode is intentionally NOT shown here (e.g. no "[explore]" tag).
150
229
  * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).
151
230
  * - Finished tasks carry their wall-clock cost and stay visible until the next
152
231
  * user message arrives (see taskStore.reset()), not the moment they finish.
153
232
  * - Collapses to zero lines when there are no tasks.
154
233
  */
155
234
  export class TaskPanelComponent {
235
+ ui;
236
+ frame = 0;
237
+ animationTimer = null;
238
+ constructor(ui) {
239
+ this.ui = ui ?? null;
240
+ }
156
241
  invalidate() {
157
242
  // No cached rendering state.
158
243
  }
244
+ /** Run the spinner timer only while a task is active, ticking re-renders. */
245
+ ensureAnimation(active) {
246
+ if (active && this.ui && !this.animationTimer) {
247
+ this.animationTimer = setInterval(() => {
248
+ this.frame = (this.frame + 1) % SPINNER_FRAMES.length;
249
+ this.ui?.requestRender();
250
+ }, SPINNER_INTERVAL_MS);
251
+ this.animationTimer.unref?.();
252
+ }
253
+ else if (!active && this.animationTimer) {
254
+ clearInterval(this.animationTimer);
255
+ this.animationTimer = null;
256
+ this.frame = 0;
257
+ }
258
+ }
259
+ /** Stop the spinner timer. Call on teardown. */
260
+ dispose() {
261
+ if (this.animationTimer) {
262
+ clearInterval(this.animationTimer);
263
+ this.animationTimer = null;
264
+ }
265
+ }
159
266
  render(width) {
160
267
  const tasks = taskStore.list();
161
268
  if (tasks.length === 0) {
269
+ this.ensureAnimation(false);
162
270
  return [];
163
271
  }
164
- const lines = [formatHeader(tasks, width)];
272
+ const hasActive = tasks.some((t) => t.status === "in_progress");
273
+ this.ensureAnimation(hasActive);
274
+ const state = panelState(tasks);
275
+ const totalSecs = tasks.reduce((sum, t) => sum + taskElapsedSecs(t), 0);
276
+ const railColor = STATE_PRESENTATION[state].color;
277
+ const gutter = `${theme.fg(railColor, RAIL)} `;
278
+ const inner = Math.max(0, width - visibleWidth(RAIL) - 1);
279
+ const lines = [gutter + formatHeader(tasks, inner, state, totalSecs)];
165
280
  for (const task of tasks) {
166
- lines.push(formatTaskLine(task, width));
281
+ lines.push(gutter + formatTaskLine(task, inner, this.frame));
167
282
  }
168
283
  return lines;
169
284
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-panel.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-panel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,gBAAgB,GAA+B;IACpD,OAAO,EAAE,KAAG;IACZ,WAAW,EAAE,KAAG;IAChB,IAAI,EAAE,KAAG;IACT,MAAM,EAAE,KAAG;CACX,CAAC;AAEF,SAAS,eAAe,CAAC,MAAkB,EAA2C;IACrF,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,aAAa;YACjB,OAAO,SAAS,CAAC;QAClB,KAAK,MAAM;YACV,OAAO,SAAS,CAAC;QAClB,KAAK,QAAQ;YACZ,OAAO,OAAO,CAAC;QAChB;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AAAA,CACD;AAED,8EAA8E;AAC9E,SAAS,aAAa,CAAC,IAAU,EAAU;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,IAAI,IAAI,G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K,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/E,OAAO,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;AAAA,CAC5C;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAkB;IAC9B,UAAU,GAAS;QAClB,6BAA6B;IADV,CAEnB;IAED,MAAM,CAAC,KAAa,EAAY;QAC/B,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,KAAK,GAAa,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import type { Component } from \"@kolisachint/hoocode-tui\";\nimport { truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { Task, TaskStatus } from \"../../../core/task-store.js\";\nimport { taskStore } from \"../../../core/task-store.js\";\nimport { theme } from \"../theme/theme.js\";\n\nconst TASK_STATUS_ICON: Record<TaskStatus, string> = {\n\tpending: \"●\",\n\tin_progress: \"◐\",\n\tdone: \"✓\",\n\tfailed: \"✗\",\n};\n\nfunction taskStatusColor(status: TaskStatus): \"dim\" | \"warning\" | \"success\" | \"error\" {\n\tswitch (status) {\n\t\tcase \"in_progress\":\n\t\t\treturn \"warning\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tdefault:\n\t\t\treturn \"dim\";\n\t}\n}\n\n/** Wall-clock time a task occupied, derived from its create/update stamps. */\nfunction formatElapsed(task: Task): string {\n\tconst secs = Math.max(0, (task.updatedAt - task.createdAt) / 1000);\n\tif (secs < 10) return `${secs.toFixed(1)}s`;\n\tif (secs < 60) return `${Math.round(secs)}s`;\n\tconst mins = Math.floor(secs / 60);\n\tconst rem = Math.round(secs % 60);\n\treturn `${mins}m${rem.toString().padStart(2, \"0\")}s`;\n}\n\n/** Sum the token + cost usage reported by the tasks shown this turn. */\nfunction sumTurnUsage(tasks: readonly Task[]): { input: number; output: number; cost: number } | null {\n\tlet input = 0;\n\tlet output = 0;\n\tlet cost = 0;\n\tfor (const task of tasks) {\n\t\tif (!task.usage) continue;\n\t\tinput += task.usage.input;\n\t\toutput += task.usage.output;\n\t\tcost += task.usage.cost;\n\t}\n\tif (input === 0 && output === 0 && cost === 0) return null;\n\treturn { input, output, cost };\n}\n\n/**\n * Ledger header: a watched/reviewed stamp plus done/total count on the left, and\n * the per-turn token + cost delta (summed across the tasks below) on the right.\n * The panel is an audit trail — the stamp makes the deterministic \"every task\n * watched & reviewed\" state glanceable, and the delta surfaces what the turn cost.\n */\nfunction formatHeader(tasks: readonly Task[], width: number): string {\n\tconst total = tasks.length;\n\tconst done = tasks.filter((t) => t.status === \"done\").length;\n\tconst watching = tasks.some((t) => t.status === \"in_progress\" || t.status === \"pending\");\n\n\tconst stampPlain = watching ? \"⟳ watching\" : \"reviewed ✓ · deterministic\";\n\t// Header is quiet audit chrome: the reviewed stamp sits in dim, only the active\n\t// \"watching\" state earns a warning tint. (Design: .task-head color = fg-dim.)\n\tconst stamp = watching ? theme.fg(\"warning\", \"⟳ watching\") : theme.fg(\"dim\", stampPlain);\n\n\tconst countPlain = `${done}/${total} done`;\n\tconst leftPlain = `${stampPlain} ${countPlain}`;\n\tconst left = `${stamp} ${theme.fg(\"dim\", countPlain)}`;\n\n\tconst turn = sumTurnUsage(tasks);\n\tif (!turn) {\n\t\treturn truncateToWidth(left, width, \"…\");\n\t}\n\n\t// Cost is omitted when zero (e.g. subscription/untracked) — still show tokens.\n\tconst showCost = turn.cost > 0;\n\tconst costPlain = showCost ? ` $${turn.cost.toFixed(3)}` : \"\";\n\tconst turnPlain = `turn ↑${formatTokens(turn.input)} ↓${formatTokens(turn.output)}${costPlain}`;\n\t// Turn delta: muted framing with the numbers one step brighter (bold/full fg),\n\t// matching the design's `.turntok` (fg-muted) / `.turntok b` (fg) hierarchy.\n\tlet turnText =\n\t\ttheme.fg(\"muted\", \"turn ↑\") +\n\t\ttheme.bold(formatTokens(turn.input)) +\n\t\ttheme.fg(\"muted\", \" ↓\") +\n\t\ttheme.bold(formatTokens(turn.output));\n\tif (showCost) {\n\t\tturnText += ` ${theme.bold(`$${turn.cost.toFixed(3)}`)}`;\n\t}\n\n\tif (visibleWidth(leftPlain) + 2 + visibleWidth(turnPlain) > width) {\n\t\t// Too narrow for both — keep the stamp + count.\n\t\treturn truncateToWidth(left, width, \"…\");\n\t}\n\tconst pad = Math.max(2, width - visibleWidth(leftPlain) - visibleWidth(turnPlain));\n\treturn left + \" \".repeat(pad) + turnText;\n}\n\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\treturn `${(count / 1000000).toFixed(1)}M`;\n}\n\nfunction formatTaskLine(task: Task, width: number): string {\n\tconst icon = theme.fg(taskStatusColor(task.status), TASK_STATUS_ICON[task.status]);\n\tconst idLabel = `#${task.id}`;\n\tconst title = task.title;\n\t// The id recedes (dim) so the title carries the line. Done tasks fade their\n\t// title to muted (work that's settled); active/failed keep full foreground.\n\t// (Design: .task .id = fg-dim, .task .ttitle = fg, .task.is-done .ttitle = fg-muted.)\n\tconst styledId = theme.fg(\"dim\", idLabel);\n\tconst styledTitle = task.status === \"done\" ? theme.fg(\"muted\", title) : title;\n\n\t// Finished tasks carry an audit stamp: total tokens used + elapsed time. The\n\t// token count sits one step brighter (muted) than the time (dim), per the\n\t// design's `.cost` (fg-dim) / `.cost b` (fg-muted) split.\n\tconst settled = task.status === \"done\" || task.status === \"failed\";\n\tlet rightPlain = \"\";\n\tlet rightStyled = \"\";\n\tif (settled) {\n\t\tconst parts: string[] = [];\n\t\tlet tokenText = \"\";\n\t\tif (task.usage) {\n\t\t\tconst total = task.usage.input + task.usage.output;\n\t\t\tif (total > 0) tokenText = formatTokens(total);\n\t\t}\n\t\tconst elapsed = formatElapsed(task);\n\t\tif (tokenText) {\n\t\t\tparts.push(tokenText, elapsed);\n\t\t\trightStyled = theme.fg(\"muted\", tokenText) + theme.fg(\"dim\", ` · ${elapsed}`);\n\t\t} else {\n\t\t\tparts.push(elapsed);\n\t\t\trightStyled = theme.fg(\"dim\", elapsed);\n\t\t}\n\t\trightPlain = parts.join(\" · \");\n\t}\n\tconst rightWidth = rightPlain ? visibleWidth(rightPlain) + 1 : 0;\n\tconst leftWidth = Math.max(0, width - rightWidth);\n\n\tconst plainText = `${TASK_STATUS_ICON[task.status]} ${idLabel} ${title}`;\n\tconst available = Math.max(0, leftWidth - visibleWidth(plainText) + visibleWidth(title));\n\tconst left = truncateToWidth(`${icon} ${styledId} ${styledTitle}`, available, \"…\");\n\n\tif (!rightPlain) return left;\n\n\tconst pad = Math.max(1, width - visibleWidth(left) - visibleWidth(rightPlain));\n\treturn left + \" \".repeat(pad) + rightStyled;\n}\n\n/**\n * Task panel rendered just above the editor prompt.\n *\n * - A ledger header (watched/reviewed stamp + done/total count) tops the list.\n * - Shows all tasks with all statuses (pending / in_progress / done / failed).\n * - Subagent mode is intentionally NOT shown here (e.g. no \"[explore]\" tag) — the\n * task title is the meaningful label; the mode adds noise in the pane.\n * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).\n * - Finished tasks carry their wall-clock cost and stay visible until the next\n * user message arrives (see taskStore.reset()), not the moment they finish.\n * - Collapses to zero lines when there are no tasks.\n */\nexport class TaskPanelComponent implements Component {\n\tinvalidate(): void {\n\t\t// No cached rendering state.\n\t}\n\n\trender(width: number): string[] {\n\t\tconst tasks = taskStore.list();\n\t\tif (tasks.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst lines: string[] = [formatHeader(tasks, width)];\n\t\tfor (const task of tasks) {\n\t\t\tlines.push(formatTaskLine(task, width));\n\t\t}\n\t\treturn lines;\n\t}\n}\n"]}
1
+ {"version":3,"file":"task-panel.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-panel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,gBAAgB,GAA+B;IACpD,OAAO,EAAE,KAAG;IACZ,WAAW,EAAE,KAAG;IAChB,IAAI,EAAE,KAAG;IACT,MAAM,EAAE,KAAG;CACX,CAAC;AAEF,sGAAsG;AACtG,MAAM,cAAc,GAAG,CAAC,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,CAAC,CAAC;AAC1E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,uGAAuG;AACvG,MAAM,IAAI,GAAG,KAAG,CAAC;AAEjB,oFAAoF;AACpF,MAAM,cAAc,GAAG,EAAE,CAAC;AAW1B,MAAM,kBAAkB,GAA0C;IACjE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IAC1D,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE;IAC5D,OAAO,EAAE,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE;CACxD,CAAC;AAE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AO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import type { Component, TUI } from \"@kolisachint/hoocode-tui\";\nimport { truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { Task, TaskStatus } from \"../../../core/task-store.js\";\nimport { taskStore } from \"../../../core/task-store.js\";\nimport { theme } from \"../theme/theme.js\";\n\nconst TASK_STATUS_ICON: Record<TaskStatus, string> = {\n\tpending: \"●\",\n\tin_progress: \"◐\",\n\tdone: \"✓\",\n\tfailed: \"✗\",\n};\n\n/** Braille spinner frames + cadence, matched to the TUI Loader so the active row animates in step. */\nconst SPINNER_FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\nconst SPINNER_INTERVAL_MS = 80;\n\n/** A thin colored left rail groups the pane without a box, the way the design's `border-left` does. */\nconst RAIL = \"▎\";\n\n/** Cells in the deterministic progress bar (matches the design's 14-cell track). */\nconst PROGRESS_CELLS = 14;\n\n/** Overall pane state, derived from the task statuses. Drives the rail color + header stamp. */\ntype PanelState = \"working\" | \"reviewed\" | \"stopped\";\n\ninterface StatePresentation {\n\treadonly icon: string;\n\treadonly label: string;\n\treadonly color: \"warning\" | \"success\" | \"error\";\n}\n\nconst STATE_PRESENTATION: Record<PanelState, StatePresentation> = {\n\tworking: { icon: \"◐\", label: \"working\", color: \"warning\" },\n\treviewed: { icon: \"✓\", label: \"reviewed\", color: \"success\" },\n\tstopped: { icon: \"✗\", label: \"stopped\", color: \"error\" },\n};\n\nfunction panelState(tasks: readonly Task[]): PanelState {\n\tif (tasks.some((t) => t.status === \"failed\")) return \"stopped\";\n\tconst active = tasks.some((t) => t.status === \"in_progress\" || t.status === \"pending\");\n\treturn active ? \"working\" : \"reviewed\";\n}\n\nfunction taskStatusColor(status: TaskStatus): \"dim\" | \"warning\" | \"success\" | \"error\" {\n\tswitch (status) {\n\t\tcase \"in_progress\":\n\t\t\treturn \"warning\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tdefault:\n\t\t\treturn \"dim\";\n\t}\n}\n\n/** Format a duration in seconds into a compact, terminal-friendly string. */\nfunction formatDuration(secs: number): string {\n\tconst s = Math.max(0, secs);\n\tif (s < 10) return `${s.toFixed(1)}s`;\n\tif (s < 60) return `${Math.round(s)}s`;\n\tconst mins = Math.floor(s / 60);\n\tconst rem = Math.round(s % 60);\n\treturn `${mins}m${rem.toString().padStart(2, \"0\")}s`;\n}\n\n/** Wall-clock time a task occupied, derived from its create/update stamps. */\nfunction taskElapsedSecs(task: Task): number {\n\treturn Math.max(0, (task.updatedAt - task.createdAt) / 1000);\n}\n\n/** Sum the token + cost usage reported by the tasks shown this turn. */\nfunction sumTurnUsage(tasks: readonly Task[]): { input: number; output: number; cost: number } | null {\n\tlet input = 0;\n\tlet output = 0;\n\tlet cost = 0;\n\tfor (const task of tasks) {\n\t\tif (!task.usage) continue;\n\t\tinput += task.usage.input;\n\t\toutput += task.usage.output;\n\t\tcost += task.usage.cost;\n\t}\n\tif (input === 0 && output === 0 && cost === 0) return null;\n\treturn { input, output, cost };\n}\n\n/**\n * Deterministic block-glyph progress bar: a heavy run (━) for the completed\n * fraction over a dim track. In-progress tasks count as half, so the bar moves\n * the moment work starts. Fraction is the only input — no animation, no guess.\n */\nfunction progressBar(done: number, active: number, total: number): { plain: string; styled: string } {\n\tconst ratio = total > 0 ? Math.max(0, Math.min(1, (done + active * 0.5) / total)) : 0;\n\tconst filled = Math.round(ratio * PROGRESS_CELLS);\n\tconst fill = \"━\".repeat(filled);\n\tconst track = \"━\".repeat(PROGRESS_CELLS - filled);\n\treturn {\n\t\tplain: fill + track,\n\t\tstyled: theme.fg(\"success\", fill) + theme.fg(\"dim\", track),\n\t};\n}\n\n/**\n * Ledger header: a state stamp (◐ working / ✓ reviewed / ✗ stopped) + a\n * deterministic progress bar and done/total count on the left, and the per-turn\n * token + elapsed + cost delta (summed across the tasks below) on the right.\n */\nfunction formatHeader(tasks: readonly Task[], width: number, state: PanelState, totalSecs: number): string {\n\tconst total = tasks.length;\n\tconst done = tasks.filter((t) => t.status === \"done\").length;\n\tconst active = tasks.filter((t) => t.status === \"in_progress\").length;\n\n\tconst { icon, label, color } = STATE_PRESENTATION[state];\n\tconst stampPlain = `${icon} ${label.toUpperCase()}`;\n\tconst stamp = `${theme.fg(color, icon)} ${theme.bold(theme.fg(color, label.toUpperCase()))}`;\n\n\tconst bar = progressBar(done, active, total);\n\tconst countPlain = `${done}/${total}`;\n\tconst count = theme.fg(\"muted\", `${done}`) + theme.fg(\"dim\", \"/\") + theme.fg(\"muted\", `${total}`);\n\n\t// Left cluster has a full form (stamp · bar · count) and a compact fallback\n\t// (stamp · count) that drops the bar when the terminal is too narrow.\n\tconst leftFullPlain = `${stampPlain} ${bar.plain} ${countPlain}`;\n\tconst leftFull = `${stamp} ${bar.styled} ${count}`;\n\tconst leftMinPlain = `${stampPlain} ${countPlain}`;\n\tconst leftMin = `${stamp} ${count}`;\n\n\tconst turn = sumTurnUsage(tasks);\n\tlet turnPlain = \"\";\n\tlet turnText = \"\";\n\tif (turn) {\n\t\tconst inTok = formatTokens(turn.input);\n\t\tconst outTok = formatTokens(turn.output);\n\t\tconst elapsed = formatDuration(totalSecs);\n\t\tconst showCost = turn.cost > 0;\n\t\tconst costStr = showCost ? `$${turn.cost.toFixed(3)}` : \"\";\n\t\tturnPlain = `turn ↑${inTok} ↓${outTok} · ${elapsed}${showCost ? ` · ${costStr}` : \"\"}`;\n\t\t// Turn delta: muted framing, numbers one step brighter (bold), separators dim.\n\t\tturnText =\n\t\t\ttheme.fg(\"muted\", \"turn ↑\") +\n\t\t\ttheme.bold(inTok) +\n\t\t\ttheme.fg(\"muted\", \" ↓\") +\n\t\t\ttheme.bold(outTok) +\n\t\t\ttheme.fg(\"dim\", \" · \") +\n\t\t\ttheme.fg(\"muted\", elapsed) +\n\t\t\t(showCost ? theme.fg(\"dim\", \" · \") + theme.bold(costStr) : \"\");\n\t}\n\n\tif (turnPlain) {\n\t\tif (visibleWidth(leftFullPlain) + 2 + visibleWidth(turnPlain) <= width) {\n\t\t\tconst pad = Math.max(2, width - visibleWidth(leftFullPlain) - visibleWidth(turnPlain));\n\t\t\treturn leftFull + \" \".repeat(pad) + turnText;\n\t\t}\n\t\tif (visibleWidth(leftMinPlain) + 2 + visibleWidth(turnPlain) <= width) {\n\t\t\tconst pad = Math.max(2, width - visibleWidth(leftMinPlain) - visibleWidth(turnPlain));\n\t\t\treturn leftMin + \" \".repeat(pad) + turnText;\n\t\t}\n\t}\n\tif (visibleWidth(leftFullPlain) <= width) return leftFull;\n\treturn truncateToWidth(leftMin, width, \"…\");\n}\n\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\treturn `${(count / 1000000).toFixed(1)}M`;\n}\n\nfunction formatTaskLine(task: Task, width: number, frame: number): string {\n\tconst isProgress = task.status === \"in_progress\";\n\tconst iconGlyph = isProgress\n\t\t? (SPINNER_FRAMES[frame] ?? TASK_STATUS_ICON.in_progress)\n\t\t: TASK_STATUS_ICON[task.status];\n\tconst icon = theme.fg(taskStatusColor(task.status), iconGlyph);\n\n\tconst idLabel = `#${task.id}`;\n\tconst title = task.title;\n\t// The id recedes (dim); the title carries the line. Done titles fade to muted\n\t// (settled work), pending dim (not started), active goes bold, failed turns red.\n\tconst styledId = theme.fg(\"dim\", idLabel);\n\tlet styledTitle: string;\n\tswitch (task.status) {\n\t\tcase \"done\":\n\t\t\tstyledTitle = theme.fg(\"muted\", title);\n\t\t\tbreak;\n\t\tcase \"pending\":\n\t\t\tstyledTitle = theme.fg(\"dim\", title);\n\t\t\tbreak;\n\t\tcase \"failed\":\n\t\t\tstyledTitle = theme.fg(\"error\", title);\n\t\t\tbreak;\n\t\tcase \"in_progress\":\n\t\t\tstyledTitle = theme.bold(title);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstyledTitle = title;\n\t}\n\n\t// Right column: settled rows carry their audit stamp (tokens + elapsed); the\n\t// active row reads `running…`, pending rows read `queued`.\n\tlet rightPlain = \"\";\n\tlet rightStyled = \"\";\n\tif (task.status === \"done\" || task.status === \"failed\") {\n\t\tconst parts: string[] = [];\n\t\tlet tokenText = \"\";\n\t\tif (task.usage) {\n\t\t\tconst totalTok = task.usage.input + task.usage.output;\n\t\t\tif (totalTok > 0) tokenText = formatTokens(totalTok);\n\t\t}\n\t\tconst elapsed = formatDuration(taskElapsedSecs(task));\n\t\tif (tokenText) {\n\t\t\tparts.push(tokenText, elapsed);\n\t\t\trightStyled = theme.fg(\"muted\", tokenText) + theme.fg(\"dim\", ` · ${elapsed}`);\n\t\t} else {\n\t\t\tparts.push(elapsed);\n\t\t\trightStyled = theme.fg(\"dim\", elapsed);\n\t\t}\n\t\trightPlain = parts.join(\" · \");\n\t} else if (task.status === \"in_progress\") {\n\t\trightPlain = \"running…\";\n\t\trightStyled = theme.fg(\"warning\", rightPlain);\n\t} else if (task.status === \"pending\") {\n\t\trightPlain = \"queued\";\n\t\trightStyled = theme.fg(\"dim\", rightPlain);\n\t}\n\n\tconst rightWidth = rightPlain ? visibleWidth(rightPlain) + 1 : 0;\n\tconst leftWidth = Math.max(0, width - rightWidth);\n\n\tconst plainText = `${iconGlyph} ${idLabel} ${title}`;\n\tconst available = Math.max(0, leftWidth - visibleWidth(plainText) + visibleWidth(title));\n\tconst left = truncateToWidth(`${icon} ${styledId} ${styledTitle}`, available, \"…\");\n\n\tif (!rightPlain) return left;\n\n\tconst pad = Math.max(1, width - visibleWidth(left) - visibleWidth(rightPlain));\n\treturn left + \" \".repeat(pad) + rightStyled;\n}\n\n/**\n * Task panel rendered just above the editor prompt.\n *\n * - A state-colored left rail groups the pane (working=warning, reviewed=success,\n * stopped=error) without drawing a box.\n * - A ledger header tops the list: a state stamp + deterministic progress bar +\n * done/total count on the left, the per-turn token/elapsed/cost delta on the right.\n * - Shows all tasks with all statuses (pending / in_progress / done / failed).\n * The active row animates a braille spinner; pending rows read `queued`.\n * - Subagent mode is intentionally NOT shown here (e.g. no \"[explore]\" tag).\n * - LIFO within the window: newest tasks appear at the bottom (closest to the prompt).\n * - Finished tasks carry their wall-clock cost and stay visible until the next\n * user message arrives (see taskStore.reset()), not the moment they finish.\n * - Collapses to zero lines when there are no tasks.\n */\nexport class TaskPanelComponent implements Component {\n\tprivate readonly ui: TUI | null;\n\tprivate frame = 0;\n\tprivate animationTimer: ReturnType<typeof setInterval> | null = null;\n\n\tconstructor(ui?: TUI) {\n\t\tthis.ui = ui ?? null;\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached rendering state.\n\t}\n\n\t/** Run the spinner timer only while a task is active, ticking re-renders. */\n\tprivate ensureAnimation(active: boolean): void {\n\t\tif (active && this.ui && !this.animationTimer) {\n\t\t\tthis.animationTimer = setInterval(() => {\n\t\t\t\tthis.frame = (this.frame + 1) % SPINNER_FRAMES.length;\n\t\t\t\tthis.ui?.requestRender();\n\t\t\t}, SPINNER_INTERVAL_MS);\n\t\t\tthis.animationTimer.unref?.();\n\t\t} else if (!active && this.animationTimer) {\n\t\t\tclearInterval(this.animationTimer);\n\t\t\tthis.animationTimer = null;\n\t\t\tthis.frame = 0;\n\t\t}\n\t}\n\n\t/** Stop the spinner timer. Call on teardown. */\n\tdispose(): void {\n\t\tif (this.animationTimer) {\n\t\t\tclearInterval(this.animationTimer);\n\t\t\tthis.animationTimer = null;\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tconst tasks = taskStore.list();\n\t\tif (tasks.length === 0) {\n\t\t\tthis.ensureAnimation(false);\n\t\t\treturn [];\n\t\t}\n\n\t\tconst hasActive = tasks.some((t) => t.status === \"in_progress\");\n\t\tthis.ensureAnimation(hasActive);\n\n\t\tconst state = panelState(tasks);\n\t\tconst totalSecs = tasks.reduce((sum, t) => sum + taskElapsedSecs(t), 0);\n\t\tconst railColor = STATE_PRESENTATION[state].color;\n\t\tconst gutter = `${theme.fg(railColor, RAIL)} `;\n\t\tconst inner = Math.max(0, width - visibleWidth(RAIL) - 1);\n\n\t\tconst lines: string[] = [gutter + formatHeader(tasks, inner, state, totalSecs)];\n\t\tfor (const task of tasks) {\n\t\t\tlines.push(gutter + formatTaskLine(task, inner, this.frame));\n\t\t}\n\t\treturn lines;\n\t}\n}\n"]}
@@ -77,6 +77,7 @@ export declare class InteractiveMode {
77
77
  private shutdownRequested;
78
78
  private extensionSelector;
79
79
  private extensionInput;
80
+ private askOptions;
80
81
  private extensionEditor;
81
82
  private extensionTerminalInputUnsubscribers;
82
83
  private extensionWidgetsAbove;
@@ -198,6 +199,15 @@ export declare class InteractiveMode {
198
199
  * Hide the extension selector.
199
200
  */
200
201
  private hideExtensionSelector;
202
+ /**
203
+ * Show the options pane — the agent asking the user one or more questions.
204
+ * Resolves with one answer per question, or undefined if skipped/aborted.
205
+ */
206
+ private showAskOptions;
207
+ /**
208
+ * Hide the options pane and restore the editor.
209
+ */
210
+ private hideAskOptions;
201
211
  private showExtensionConfirm;
202
212
  private promptForMissingSessionCwd;
203
213
  /**