@tshu-w/pi-agents 0.2.2 → 0.4.0

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/src/workbench.mjs CHANGED
@@ -8,7 +8,7 @@ import { join } from 'node:path';
8
8
  import { pathToFileURL } from 'node:url';
9
9
  import { styleText } from 'node:util';
10
10
  import { setTimeout as delay } from 'node:timers/promises';
11
- import { alive, attach, listHosts, settledHosts, startHost } from './host/client.mjs';
11
+ import { alive, attach, drain, listHosts, settledHosts, startHost } from './host/client.mjs';
12
12
  import { detachKey, detachMatcher } from './host/keys.mjs';
13
13
  import { piPackage } from './pi.mjs';
14
14
  import { ensureDaemon, sendViaDaemon } from './daemon/client.mjs';
@@ -351,7 +351,8 @@ export async function workbench({ pi: executable, paths, sessionDir }) {
351
351
  async function attachTo(socket) {
352
352
  ui.stop();
353
353
  let result;
354
- try { result = await attach(socket, { isDetach }); }
354
+ // The list reads the terminal again at once, and skips late key releases itself.
355
+ try { result = await attach(socket, { isDetach, drainInput: false }); }
355
356
  finally {
356
357
  process.stdout.write(ALT_SCREEN);
357
358
  ui.start();
@@ -551,9 +552,8 @@ export async function workbench({ pi: executable, paths, sessionDir }) {
551
552
  fold();
552
553
  summarize('branch summary');
553
554
  } else if (message.role === 'custom') {
554
- const from = message.customType === 'pi-agents' ? message.details?.sender?.name ?? message.details?.sender?.id : undefined;
555
555
  fold();
556
- summarize(from ? `message from ${from}` : `${message.customType} message`);
556
+ summarize(`${message.customType} message`);
557
557
  }
558
558
  }
559
559
  fold();
@@ -623,10 +623,14 @@ export async function workbench({ pi: executable, paths, sessionDir }) {
623
623
  if (quitting) return;
624
624
  quitting = true;
625
625
  stream?.close();
626
- // Late key releases would otherwise leak into the shell, as Pi avoids on exit.
627
626
  themeSync.disableAutoSync();
628
- await terminal.drainInput(1000);
629
627
  ui.stop();
628
+ // Late key releases would otherwise leak into the shell, as when detaching from a Session.
629
+ process.stdin.setRawMode(true);
630
+ process.stdin.resume();
631
+ await drain(process.stdin, process.stdout);
632
+ process.stdin.setRawMode(false);
633
+ process.stdin.pause();
630
634
  process.stdout.write(`${MAIN_SCREEN}${styleText('dim', 'Sessions keep running. To reopen:')} pd agents\n`);
631
635
  finish();
632
636
  }