opencode-work-context 0.4.4 → 0.4.6

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
@@ -244,10 +244,12 @@ titles plus a controlled reason. Prompts, messages, tool output, secrets, raw
244
244
  provider errors, and full project paths are never published. No daemon, socket,
245
245
  terminal multiplexer integration, or arbitrary command is required.
246
246
 
247
- If the runtime channel or in-TUI toast API is unavailable, Linux falls back to
248
- one best-effort desktop notification when `notify-send` and a desktop DBus
249
- session are available. Desktop fallback is enabled by default. Disable it while
250
- retaining project-local attention indicators with:
247
+ On Linux, each newly created background attention also requests one best-effort
248
+ desktop notification when `notify-send` and a desktop DBus session are
249
+ available. This delivery is independent of the in-TUI toast, so cross-project
250
+ attention can appear both inside active OpenCode B and in the system notification
251
+ center. Desktop delivery is enabled by default. Disable it while retaining
252
+ in-TUI toasts and project-local attention indicators with:
251
253
 
252
254
  ```yaml
253
255
  notifications:
@@ -257,22 +259,26 @@ notifications:
257
259
  The package invokes the fixed `notify-send` executable directly without a shell
258
260
  or configurable command. Missing commands, unsupported platforms, unavailable
259
261
  desktop sessions, timeouts, and delivery errors are ignored so they cannot
260
- interrupt TUI startup or event processing. Clicking a notification does not
261
- navigate to its session in this release.
262
+ interrupt TUI startup or event processing. If the runtime channel is unavailable,
263
+ desktop delivery remains a best-effort fallback. Clicking a notification does
264
+ not navigate to its session in this release.
262
265
 
263
266
  Background includes a linked native session that is not selected and any session
264
267
  owned by an OpenCode instance other than the most recently active live instance.
265
268
  Each instance refreshes its lease independently, so a crashed process expires
266
269
  without holding ownership. If the global channel is unavailable, focus falls
267
270
  back to OpenTUI's renderer events and unknown focus is conservatively treated as
268
- foreground.
271
+ foreground. Attention indicators omit the native session already open in the
272
+ current route; retained background state is acknowledged when that session
273
+ receives focus or keyboard activity.
269
274
 
270
275
  To verify cross-project delivery, install and load the TUI integration in two
271
276
  projects, start work in linked session A, then interact with OpenCode B before A
272
- finishes or asks a question. Expect a `Work Context` toast inside B and a
273
- persistent `[ATTN]` marker in A. Stop B or use an environment without a valid
274
- private `XDG_RUNTIME_DIR` to test the Linux desktop fallback. Open A's affected
275
- native session to clear its marker.
277
+ finishes or asks a question. Expect a `Work Context` toast inside B, one system
278
+ notification, and a persistent `[ATTN]` marker in A. Open A's affected native
279
+ session to clear its marker. Set `notifications.desktop` to `false`, restart
280
+ OpenCode, and repeat to verify that the toast and marker remain without the
281
+ system notification.
276
282
 
277
283
  Tools are registered by the installed server export and are not copied into the
278
284
  project. Core and storage remain in the installed package; projects should not
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -78,7 +78,9 @@ export const globalAttentionToast = (event) => {
78
78
  duration: 5000,
79
79
  };
80
80
  };
81
- export const attentionForSession = (api, sessionId) => api?.workContextAttention?.attentionFor?.(sessionId) || null;
81
+ export const attentionForSession = (api, sessionId) => sessionId === currentSessionId(api)
82
+ ? null
83
+ : api?.workContextAttention?.attentionFor?.(sessionId) || null;
82
84
  export const acknowledgeNavigation = (api, sessionId, observedEventKey) => {
83
85
  if (!sessionId || !observedEventKey) return false;
84
86
  return api?.workContextAttention?.acknowledge?.(sessionId, observedEventKey) === true;
@@ -306,7 +308,9 @@ export const createAttentionTuiController = ({ api, projectRoot, read = readWork
306
308
  const acknowledge = (sessionId, observedEventKey) => engine.acknowledge(sessionId, observedEventKey);
307
309
  const aggregate = (matches) => {
308
310
  const bySession = new Map();
311
+ const current = currentSessionId(api);
309
312
  for (const attention of engine.list()) {
313
+ if (attention.sessionId === current) continue;
310
314
  const records = (snapshot?.workspaces || []).flatMap((workspace) => (workspace.sessions || [])
311
315
  .filter((session) => session.opencode_session_id === attention.sessionId)
312
316
  .map((session) => ({ workspace, session })));
@@ -367,14 +371,14 @@ export const tui = async (api, options = {}) => {
367
371
  try { options.onAttention?.(change); } catch {}
368
372
  const context = change.contexts?.[0];
369
373
  if (!context) return;
370
- const published = globalDelivery && globalChannel.publish({
374
+ if (globalDelivery) globalChannel.publish({
371
375
  dedupeKey: `${projectRoot}\0${change.sessionId}\0${change.attention.eventKey}`,
372
376
  reason: context.reason,
373
377
  projectTitle: path.basename(projectRoot),
374
378
  workspaceTitle: context.workspaceTitle,
375
379
  stageTitle: context.stageTitle,
376
380
  });
377
- if (!published) void Promise.resolve(desktopNotifier.notify(context)).catch(() => {});
381
+ void Promise.resolve(desktopNotifier.notify(context)).catch(() => {});
378
382
  },
379
383
  now: options.now,
380
384
  });