@op1/threads 0.1.1 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/tui.ts +9 -4
package/README.md CHANGED
@@ -75,7 +75,9 @@ Plugin option `maxWorkers` defaults to 4 and accepts integers from 1 through 32.
75
75
 
76
76
  The terminal synchronizes workers before opening native tabs without changing focus. A TUI memory index survives plugin reloads and respects manually closed tabs. `/threads` explicitly reopens workers for open coordinator tabs. A new TUI recovers workers from durable storage. Closing the TUI does not interrupt workers.
77
77
 
78
- All open native root-session tabs are automatically grouped by OpenCode project ID, including sessions not managed by this plugin. Projects follow their first appearance in the current tab order; sessions keep their relative order within each project. Worktrees with the same project ID stay together. Each tab with unloaded project metadata stays in its own group until that metadata becomes available. Reconciliation moves only out-of-order tabs, without changing focus or closing and reopening them. Native tabs do not support divider rows.
78
+ All open native root-session tabs are automatically grouped by OpenCode project ID, including sessions not managed by this plugin. Projects follow their first appearance in the current tab order. Worktrees with the same project ID stay together.
79
+
80
+ Within each project, running sessions, the selected tab, and sessions waiting for input come before idle sessions. Tabs with the same priority keep their relative order. Finished runs remain visible below active work and rise again when resumed or selected. Idle is a display priority, not a completion verdict. Each tab with unloaded project metadata stays in its own group until that metadata becomes available. Reconciliation moves only out-of-order tabs, without changing focus or closing and reopening them. Native tabs do not support divider rows.
79
81
 
80
82
  The read-only RPC definition is `ThreadsRpc` in `src/rpc.ts`, with ID `threads` and method `snapshot`:
81
83
 
@@ -90,7 +92,7 @@ The input accepts at most 100 coordinator IDs. Raw HTTP RPC requests wrap the in
90
92
 
91
93
  Run `bun run typecheck`, `bun test`, and `bun run verify:live`. The live check requires OpenCode 2.0.3, Python, and `uv`. It starts a separate local server, a deterministic model endpoint, and a terminal process with isolated configuration and data. It verifies actual tool calls, durable messages, permission restrictions, worker limits, deleted-worker cleanup, restart behavior, and native tab visibility, busy state, and focus.
92
94
 
93
- Run `bun run verify:tabs` to verify project grouping across real git worktrees, new worker insertion, focus preservation, and TUI reopening.
95
+ Run `bun run verify:tabs` to verify project grouping across real git worktrees, activity-based ordering, permission prompts, completed and resumed workers, focus preservation, and TUI reopening.
94
96
 
95
97
  Pass an extracted package directory to test the release artifact: `bun run verify:live /absolute/path/to/package`.
96
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op1/threads",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Visible top-level worker sessions for OpenCode V2, with native tabs and durable reports.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/tui.ts CHANGED
@@ -16,23 +16,28 @@ export default Plugin.define({
16
16
  const projectID = ctx.data.session.get(tab.sessionID)?.projectID;
17
17
  return {
18
18
  sessionID: tab.sessionID,
19
+ priority: tab.busy || tab.active || tab.attention,
19
20
  projectID:
20
21
  typeof projectID === "string" && projectID.length > 0
21
22
  ? projectID
22
23
  : undefined,
23
24
  };
24
25
  });
25
- const groups = new Map<string, string[]>();
26
+ const groups = new Map<string, typeof tabs>();
26
27
  for (const tab of tabs) {
27
28
  const key =
28
29
  tab.projectID === undefined
29
30
  ? `session:${tab.sessionID}`
30
31
  : `project:${tab.projectID}`;
31
32
  const group = groups.get(key);
32
- if (group) group.push(tab.sessionID);
33
- else groups.set(key, [tab.sessionID]);
33
+ if (group) group.push(tab);
34
+ else groups.set(key, [tab]);
34
35
  }
35
- const ordered = [...groups.values()].flat();
36
+ const ordered = [...groups.values()].flatMap((group) =>
37
+ group
38
+ .sort((left, right) => Number(right.priority) - Number(left.priority))
39
+ .map((tab) => tab.sessionID),
40
+ );
36
41
  for (const [index, sessionID] of ordered.entries()) {
37
42
  if (ctx.ui.tabs.list()[index]?.sessionID === sessionID) continue;
38
43
  if (!ctx.ui.tabs.move(sessionID, index)) break;