@pokit/tabs-ink 0.0.39 → 0.0.40

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.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAwB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK/E;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAoH/C;AAMD,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,QAAQ,EACb,OAAO,GAAE,mBAAwB,GAChC;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAgFzB"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAwB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK/E;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAuH/C;AAMD,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,QAAQ,EACb,OAAO,GAAE,mBAAwB,GAChC;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAgFzB"}
package/dist/adapter.js CHANGED
@@ -27,8 +27,10 @@ export function createTabsAdapter() {
27
27
  if (items.length === 0) {
28
28
  return;
29
29
  }
30
+ // Clear the main screen before switching to alternate screen buffer.
31
+ // This ensures the menu output is not visible when we return from alternate screen.
32
+ process.stdout.write('\x1b[2J\x1b[H');
30
33
  // Switch to alternate screen buffer (like vim/less)
31
- // This preserves the main terminal content and provides a clean canvas
32
34
  process.stdout.write('\x1b[?1049h\x1b[H');
33
35
  // Ensure stdin is not paused - previous CLI operations (prompts, spinners)
34
36
  // may have left it in a paused state
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-app.d.ts","sourceRoot":"","sources":["../src/tabs-app.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIxD,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,CAAC;AAOF,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,2CAkS/D"}
1
+ {"version":3,"file":"tabs-app.d.ts","sourceRoot":"","sources":["../src/tabs-app.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAaxD,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,CAAC;AAOF,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,YAAY,2CA2R/D"}
package/dist/tabs-app.js CHANGED
@@ -3,6 +3,16 @@ import { useState, useEffect, useCallback, useRef } from 'react';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { TabbedView } from './tabbed-view.js';
5
5
  import { OutputBuffer, MAX_OUTPUT_LINES, MAX_LINE_LENGTH, BUFFER_WARNING_THRESHOLD, } from '@pokit/tabs-core';
6
+ function killProcessTree(proc) {
7
+ if (proc.killed || proc.pid == null)
8
+ return;
9
+ try {
10
+ process.kill(-proc.pid, 'SIGTERM');
11
+ }
12
+ catch {
13
+ // Process may have already exited
14
+ }
15
+ }
6
16
  const OUTPUT_BATCH_MS = 16;
7
17
  export function TabsApp({ items, options, onExit }) {
8
18
  // Ring buffers for storing all output per tab (with O(1) operations)
@@ -97,6 +107,7 @@ export function TabsApp({ items, options, onExit }) {
97
107
  FORCE_COLOR: '1',
98
108
  },
99
109
  stdio: ['pipe', 'pipe', 'pipe'],
110
+ detached: true,
100
111
  });
101
112
  const handleData = (data) => appendOutput(index, data);
102
113
  proc.stdout?.on('data', handleData);
@@ -137,24 +148,21 @@ export function TabsApp({ items, options, onExit }) {
137
148
  processesRef.current = procs;
138
149
  return () => {
139
150
  for (const proc of processesRef.current) {
140
- if (proc && !proc.killed) {
141
- proc.kill('SIGTERM');
142
- }
151
+ if (proc)
152
+ killProcessTree(proc);
143
153
  }
144
154
  };
145
155
  }, [items, spawnProcess]);
146
156
  const killAll = useCallback(() => {
147
157
  for (const proc of processesRef.current) {
148
- if (proc && !proc.killed) {
149
- proc.kill('SIGTERM');
150
- }
158
+ if (proc)
159
+ killProcessTree(proc);
151
160
  }
152
161
  }, []);
153
162
  const handleRestart = useCallback((index) => {
154
163
  const existingProc = processesRef.current[index];
155
- if (existingProc && !existingProc.killed) {
156
- existingProc.kill('SIGTERM');
157
- }
164
+ if (existingProc)
165
+ killProcessTree(existingProc);
158
166
  // Clear both batch buffer and ring buffer
159
167
  batchBuffersRef.current.delete(index);
160
168
  const tabId = `tab-${index}`;
@@ -179,9 +187,8 @@ export function TabsApp({ items, options, onExit }) {
179
187
  }, [spawnProcess]);
180
188
  const handleKill = useCallback((index) => {
181
189
  const proc = processesRef.current[index];
182
- if (proc && !proc.killed) {
183
- proc.kill('SIGTERM');
184
- }
190
+ if (proc)
191
+ killProcessTree(proc);
185
192
  setTabs((prev) => {
186
193
  const next = [...prev];
187
194
  const tab = next[index];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokit/tabs-ink",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "Ink-based tab renderer for pok CLI applications",
5
5
  "keywords": [
6
6
  "cli",
@@ -51,12 +51,12 @@
51
51
  "devDependencies": {
52
52
  "@types/bun": "latest",
53
53
  "@types/react": "^19.2.0",
54
- "@pokit/core": "0.0.39",
55
- "@pokit/tabs-core": "0.0.39"
54
+ "@pokit/core": "0.0.40",
55
+ "@pokit/tabs-core": "0.0.40"
56
56
  },
57
57
  "peerDependencies": {
58
- "@pokit/core": "0.0.39",
59
- "@pokit/tabs-core": "0.0.39"
58
+ "@pokit/core": "0.0.40",
59
+ "@pokit/tabs-core": "0.0.40"
60
60
  },
61
61
  "engines": {
62
62
  "bun": ">=1.0.0"
package/src/adapter.tsx CHANGED
@@ -31,8 +31,11 @@ export function createTabsAdapter(): TabsAdapter {
31
31
  return;
32
32
  }
33
33
 
34
+ // Clear the main screen before switching to alternate screen buffer.
35
+ // This ensures the menu output is not visible when we return from alternate screen.
36
+ process.stdout.write('\x1b[2J\x1b[H');
37
+
34
38
  // Switch to alternate screen buffer (like vim/less)
35
- // This preserves the main terminal content and provides a clean canvas
36
39
  process.stdout.write('\x1b[?1049h\x1b[H');
37
40
 
38
41
  // Ensure stdin is not paused - previous CLI operations (prompts, spinners)
package/src/tabs-app.tsx CHANGED
@@ -10,6 +10,15 @@ import {
10
10
  import type { TabProcess } from './types.js';
11
11
  import type { TabSpec, TabsOptions } from '@pokit/core';
12
12
 
13
+ function killProcessTree(proc: ChildProcess): void {
14
+ if (proc.killed || proc.pid == null) return;
15
+ try {
16
+ process.kill(-proc.pid, 'SIGTERM');
17
+ } catch {
18
+ // Process may have already exited
19
+ }
20
+ }
21
+
13
22
  const OUTPUT_BATCH_MS = 16;
14
23
 
15
24
  type TabsAppProps = {
@@ -132,6 +141,7 @@ export function TabsApp({ items, options, onExit }: TabsAppProps) {
132
141
  FORCE_COLOR: '1',
133
142
  } as NodeJS.ProcessEnv,
134
143
  stdio: ['pipe', 'pipe', 'pipe'],
144
+ detached: true,
135
145
  });
136
146
 
137
147
  const handleData = (data: Buffer) => appendOutput(index, data);
@@ -179,27 +189,21 @@ export function TabsApp({ items, options, onExit }: TabsAppProps) {
179
189
 
180
190
  return () => {
181
191
  for (const proc of processesRef.current) {
182
- if (proc && !proc.killed) {
183
- proc.kill('SIGTERM');
184
- }
192
+ if (proc) killProcessTree(proc);
185
193
  }
186
194
  };
187
195
  }, [items, spawnProcess]);
188
196
 
189
197
  const killAll = useCallback(() => {
190
198
  for (const proc of processesRef.current) {
191
- if (proc && !proc.killed) {
192
- proc.kill('SIGTERM');
193
- }
199
+ if (proc) killProcessTree(proc);
194
200
  }
195
201
  }, []);
196
202
 
197
203
  const handleRestart = useCallback(
198
204
  (index: number) => {
199
205
  const existingProc = processesRef.current[index];
200
- if (existingProc && !existingProc.killed) {
201
- existingProc.kill('SIGTERM');
202
- }
206
+ if (existingProc) killProcessTree(existingProc);
203
207
 
204
208
  // Clear both batch buffer and ring buffer
205
209
  batchBuffersRef.current.delete(index);
@@ -229,9 +233,7 @@ export function TabsApp({ items, options, onExit }: TabsAppProps) {
229
233
 
230
234
  const handleKill = useCallback((index: number) => {
231
235
  const proc = processesRef.current[index];
232
- if (proc && !proc.killed) {
233
- proc.kill('SIGTERM');
234
- }
236
+ if (proc) killProcessTree(proc);
235
237
 
236
238
  setTabs((prev) => {
237
239
  const next = [...prev];