opencode-work-context 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -326,13 +326,16 @@ disable this TUI loader; the package does not use an internal keymap fallback.
326
326
  The optional TUI loader tracks linked OpenCode sessions that need attention.
327
327
  Questions, permission requests, errors, and a background session becoming idle
328
328
  after observed work remain marked until that native session is opened. Compact
329
- markers retain both a symbol and a textual reason: `[✓ response complete]`,
330
- `[? question]`, `[! permission]`, or `[x error]`. Aggregated markers append an
331
- `xN` session count. Attention does not change workspace or stage lifecycle state.
329
+ markers retain both a symbol and a textual reason in modals and switchers:
330
+ `[✓ response complete]`, `[? question]`, `[! permission]`, or `[x error]`.
331
+ The compact stages sidebar uses a dedicated signal column with `✓`, `?`, `!`,
332
+ or `×` and appends a numeric count when needed. Its workspace header groups
333
+ mixed unread reasons by priority, for example `Attention · ×1 !2 ?1 ✓3`.
334
+ Attention does not change workspace or stage lifecycle state.
332
335
 
333
336
  The stages sidebar separately observes live `busy` and `retry` events for active
334
- OpenCode sessions mapped to visible work-context stages. A braille loader appears
335
- beside the lifecycle marker while any such session is working and stops on idle,
337
+ OpenCode sessions mapped to visible work-context stages. A braille loader uses
338
+ the signal column before the lifecycle marker while any such session is working and stops on idle,
336
339
  question, permission, or error events. This live state is never persisted or
337
340
  inferred from stage status, historical sessions, or unread attention, so startup
338
341
  and missed mappings fail closed without a stale loader.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -16,6 +16,7 @@ const activeControllers = new WeakMap();
16
16
  const PRIORITY = { idle: 1, question: 2, permission: 3, error: 4 };
17
17
  const REASON_TEXT = { idle: "response complete", question: "question", permission: "permission", error: "error" };
18
18
  const REASON_MARKER = { idle: "✓", question: "?", permission: "!", error: "x" };
19
+ const REASON_SIGNAL = { idle: "✓", question: "?", permission: "!", error: "×" };
19
20
  const EVENT_TYPES = [
20
21
  "session.status",
21
22
  "session.idle",
@@ -75,6 +76,21 @@ export const attentionReasonText = (reason) => REASON_TEXT[reason] || "attention
75
76
  export const attentionIndicatorText = (attention) => attention
76
77
  ? `[${REASON_MARKER[attention.reason] || "!"} ${attentionReasonText(attention.reason)}${attention.count > 1 ? ` x${attention.count}` : ""}]`
77
78
  : "";
79
+ export const attentionSignalText = (attention, { alwaysCount = false } = {}) => attention
80
+ ? `${REASON_SIGNAL[attention.reason] || "!"}${alwaysCount || attention.count > 1 ? attention.count : ""}`
81
+ : "";
82
+ export const attentionSummaryText = (attention, options = {}) => {
83
+ if (!attention) return "";
84
+ if (!attention.items?.length) return attentionSignalText(attention, options);
85
+ const counts = attention.items.reduce((summary, item) => {
86
+ summary[item.reason] = (summary[item.reason] || 0) + 1;
87
+ return summary;
88
+ }, {});
89
+ return ["error", "permission", "question", "idle"]
90
+ .filter((reason) => counts[reason])
91
+ .map((reason) => attentionSignalText({ reason, count: counts[reason] }, options))
92
+ .join(" ");
93
+ };
78
94
  export const globalAttentionToast = (event) => {
79
95
  const context = [event?.projectTitle, event?.workspaceTitle, event?.stageTitle].filter(Boolean).join(" / ");
80
96
  return {
@@ -5,7 +5,7 @@ import { contextFor, titleFor } from "../src/opencode-adapter.js";
5
5
  import { renderDependencyTree, renderStagesPanel } from "../src/stages-renderer.js";
6
6
  import { jsx } from "@opentui/solid/jsx-runtime";
7
7
  import { createSignal } from "solid-js";
8
- import { attentionIndicatorText } from "./attention.js";
8
+ import { attentionSummaryText } from "./attention.js";
9
9
  import { createStageSwitcherFlow } from "./stage-switcher.js";
10
10
  import { readTuiState, updateTuiState } from "./tui-state.js";
11
11
 
@@ -42,28 +42,22 @@ const candidateSummaryText = (workspace) => workspace.candidates && (workspace.c
42
42
  export { readStagesSnapshot, renderStagesPanel };
43
43
 
44
44
  const defaultRuntime = { jsx };
45
- const renderAttentionText = (value, indicator, runtime) => {
46
- if (!indicator) return value;
47
- const parts = value.split(indicator);
48
- return parts.length === 1 ? value : parts.flatMap((part, index) => index
49
- ? [runtime.jsx("b", { children: indicator }), part]
50
- : [part]).filter(Boolean);
51
- };
52
-
53
- const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0]) => !result?.ok || !result.data?.workspace
54
- ? [
45
+ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0]) => {
46
+ if (!result?.ok || !result.data?.workspace) return [
55
47
  runtime.jsx("text", { children: runtime.jsx("b", { children: "Stages" }) }),
56
48
  ...renderStagesPanel(result).split("\n").slice(1).map((line) => runtime.jsx("text", { children: line })),
57
- ]
58
- : [
49
+ ];
50
+ const workspaceAttention = attentionSummaryText(attention?.attentionForWorkspace?.(result.data.workspace.id), { alwaysCount: true });
51
+ return [
59
52
  runtime.jsx("box", {
60
53
  marginBottom: 1,
61
54
  flexDirection: "column",
62
55
  children: [
63
- runtime.jsx("text", { wrapMode: "word", children: runtime.jsx("b", { children: `${attentionIndicatorText(attention?.attentionForWorkspace?.(result.data.workspace.id))} ${result.data.workspace.title}`.trim() }) }),
56
+ runtime.jsx("text", { wrapMode: "word", children: runtime.jsx("b", { children: result.data.workspace.title }) }),
64
57
  runtime.jsx("text", { fg: theme?.current?.textMuted, children: `Workflow · ${result.data.workspace.mode || "standard"}` }),
58
+ workspaceAttention && runtime.jsx("text", { children: ["Attention · ", runtime.jsx("b", { children: workspaceAttention })] }),
65
59
  candidateSummaryText(result.data.workspace) && runtime.jsx("text", { fg: theme?.current?.textMuted, children: candidateSummaryText(result.data.workspace) }),
66
- ],
60
+ ].filter(Boolean),
67
61
  }),
68
62
  runtime.jsx("box", {
69
63
  flexDirection: "row",
@@ -79,11 +73,10 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
79
73
  stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
80
74
  stage.depends_on?.length && `Deps: ${stage.depends_on.join(", ")}`,
81
75
  ].filter(Boolean).join(" · ") : "";
82
- const attentionText = attentionIndicatorText(unread);
76
+ const attentionSignal = attentionSummaryText(unread);
83
77
  const stageText = [
84
78
  `${stage.id}. ${stage.title}`,
85
79
  metadata,
86
- attentionText,
87
80
  ].filter(Boolean).join("\n");
88
81
  return runtime.jsx("box", {
89
82
  flexDirection: "row",
@@ -92,13 +85,19 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
92
85
  return onStageSelect?.(stage);
93
86
  },
94
87
  children: [
95
- working && runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: theme?.current?.warning, children: activityFrame() }),
88
+ runtime.jsx("text", {
89
+ flexShrink: 0,
90
+ marginRight: 1,
91
+ fg: working || stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted,
92
+ children: working ? activityFrame() : attentionSignal ? runtime.jsx("b", { children: attentionSignal }) : " ",
93
+ }),
96
94
  runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: statusMarker(stage.status) }),
97
- runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: renderAttentionText(stageText, attentionText, runtime) }),
98
- ].filter(Boolean),
95
+ runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: stageText }),
96
+ ],
99
97
  });
100
98
  }),
101
99
  ];
100
+ };
102
101
 
103
102
  export const renderStagesElement = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame) => {
104
103
  return runtime.jsx("box", {