@ravshansbox/pi-next-issue 1.0.7 → 1.0.9

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 +1 -1
  2. package/index.ts +12 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ Run these in pi, inside a git repository:
16
16
  - `/next-issue stop` stops the run. The issue keeps its saved state, and the next run resumes it.
17
17
  - `/next-issue status` shows where the run is.
18
18
 
19
- The footer shows the issue, the stage, the number of tool calls and the time spent on the issue, for example `next-issue #12 · review 1/3 · 37 tools · 4m12s`. A line above the editor shows the last tool call. A note appears when an issue is merged or needs a human.
19
+ The footer shows the issue, the stage, the number of tool calls and the time spent on the issue, for example `next-issue #12 · review 1/3 · 37 tools · 4m12s`. A line above the editor shows the last tool call. In the terminal, both use the dim colour of the theme, like the rest of the footer. A note appears when an issue is merged or needs a human.
20
20
 
21
21
  The run does not belong to a session: it goes on after `/new`, `/resume`, a fork or a reload, and the new session shows it. It stops when you quit pi.
22
22
 
package/index.ts CHANGED
@@ -6,7 +6,7 @@ import { type Progress, Runner } from './src/runner.ts';
6
6
 
7
7
  type Launch = (cwd: string) => Promise<Runner>;
8
8
 
9
- type Holder = { runner?: Runner };
9
+ type Holder = { runner?: Runner; launching?: boolean };
10
10
 
11
11
  const KEY = Symbol.for('pi-next-issue');
12
12
  const STATUS_KEY = 'next-issue';
@@ -68,6 +68,7 @@ const launchFromRepo: Launch = async (cwd) => {
68
68
  export function createExtension(launch: Launch) {
69
69
  return (pi: ExtensionAPI) => {
70
70
  let ui: ExtensionContext['ui'] | undefined;
71
+ let coloured = false;
71
72
  let timer: ReturnType<typeof setInterval> | undefined;
72
73
  let unsubscribe: (() => void) | undefined;
73
74
  let handled = 0;
@@ -79,9 +80,11 @@ export function createExtension(launch: Launch) {
79
80
  return;
80
81
  }
81
82
  const progress = runner.progress;
82
- ui.setStatus(STATUS_KEY, formatStatus(progress, Date.now()));
83
+ const theme = ui.theme;
84
+ const dim = (text: string) => (coloured ? theme.fg('dim', text) : text);
85
+ ui.setStatus(STATUS_KEY, dim(formatStatus(progress, Date.now())));
83
86
  const active = progress.status === 'running' && progress.lastTool !== undefined;
84
- ui.setWidget(STATUS_KEY, active ? [`↳ ${progress.lastTool}`] : undefined);
87
+ ui.setWidget(STATUS_KEY, active ? [dim(`↳ ${progress.lastTool}`)] : undefined);
85
88
  };
86
89
 
87
90
  const onChange = (progress: Progress) => {
@@ -128,6 +131,7 @@ export function createExtension(launch: Launch) {
128
131
  return;
129
132
  }
130
133
  ui = ctx.ui;
134
+ coloured = ctx.mode === 'tui';
131
135
  timer ??= setInterval(render, 1000);
132
136
  timer.unref?.();
133
137
  const runner = holder().runner;
@@ -157,10 +161,11 @@ export function createExtension(launch: Launch) {
157
161
  const busy =
158
162
  current?.progress.status === 'running' || current?.progress.status === 'stopping';
159
163
  if (action === 'start') {
160
- if (busy) {
164
+ if (busy || holder().launching) {
161
165
  ctx.ui.notify('next-issue is running already', 'warning');
162
166
  return;
163
167
  }
168
+ holder().launching = true;
164
169
  let runner: Runner;
165
170
  try {
166
171
  runner = await launch(ctx.cwd);
@@ -170,10 +175,13 @@ export function createExtension(launch: Launch) {
170
175
  'error',
171
176
  );
172
177
  return;
178
+ } finally {
179
+ holder().launching = false;
173
180
  }
174
181
  holder().runner = runner;
175
182
  if (ctx.hasUI) {
176
183
  ui = ctx.ui;
184
+ coloured = ctx.mode === 'tui';
177
185
  follow(runner);
178
186
  }
179
187
  void runner.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravshansbox/pi-next-issue",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Pi extension that works through GitHub issues in the background",
5
5
  "license": "MIT",
6
6
  "type": "module",