@stevezhou/sisu 0.3.12 → 0.3.14

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 (2) hide show
  1. package/dist/tui.js +25 -13
  2. package/package.json +1 -1
package/dist/tui.js CHANGED
@@ -36,6 +36,10 @@ function shouldUsePager(deps, env = process.env) {
36
36
  return false;
37
37
  return Boolean(process.stdout.isTTY);
38
38
  }
39
+ /** Pager may leave the alt screen / hide the cursor when it exits 10. */
40
+ function restoreInteractiveTerminal(io) {
41
+ io.write('\x1b[?1049l\x1b[?25h\x1b[?2004l\x1b[0m');
42
+ }
39
43
  async function playMobiusIntro(io, options = {}) {
40
44
  const columns = options.columns ?? process.stdout.columns ?? 80;
41
45
  const frames = options.frames ?? 32;
@@ -207,7 +211,9 @@ async function runTui(io, deps = {}) {
207
211
  const columns = deps.columns ?? process.stdout.columns ?? 80;
208
212
  const animate = deps.animate ?? shouldAnimateSplash();
209
213
  try {
214
+ let openedBrowserLogin = false;
210
215
  const startWebLogin = async (notify) => {
216
+ openedBrowserLogin = true;
211
217
  return webLogin({
212
218
  onStart: (info) => {
213
219
  notify(`Open ${info.verification_uri_complete}`);
@@ -299,27 +305,33 @@ async function runTui(io, deps = {}) {
299
305
  });
300
306
  });
301
307
  if (deps.spawnGrokPager || ((0, launch_1.findGrokBuildBinary)() && process.stdout.isTTY)) {
302
- // Login handoff: pager exits 10 → host web login → respawn.
303
- // If a session is already on disk, do not mint another device code.
308
+ // Login handoff: pager exits 10 → host web login at most once → respawn
309
+ // grok-pager. Never fall through to the Node TUI while the grok binary ran.
310
+ let retriedWithSession = false;
304
311
  while (true) {
305
312
  const code = await spawnOnce();
306
313
  if (code === null)
307
314
  break;
308
315
  if (code !== exports.SISU_LOGIN_EXIT_CODE)
309
316
  return code;
310
- if (auth()) {
311
- io.write('sisu: session already saved; not opening another login page.\n');
312
- break;
313
- }
314
- try {
315
- const email = await startWebLogin((line) => io.write(`${line}\n`));
316
- io.write(`logged in as ${email}\n`);
317
+ restoreInteractiveTerminal(io);
318
+ if (!auth() && !openedBrowserLogin) {
319
+ try {
320
+ const email = await startWebLogin((line) => io.write(`${line}\n`));
321
+ io.write(`logged in as ${email}\n`);
322
+ }
323
+ catch (error) {
324
+ io.write(`${error instanceof Error ? error.message : String(error)}\n`);
325
+ io.write('login failed — run `sisu login`\n');
326
+ return 1;
327
+ }
328
+ continue;
317
329
  }
318
- catch (error) {
319
- io.write(`${error instanceof Error ? error.message : String(error)}\n`);
320
- io.write('login failed — run `sisu login`\n');
321
- return 1;
330
+ if (retriedWithSession) {
331
+ io.write('sisu: grok pager still requesting login after a saved session.\n');
332
+ return exports.SISU_LOGIN_EXIT_CODE;
322
333
  }
334
+ retriedWithSession = true;
323
335
  }
324
336
  }
325
337
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevezhou/sisu",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "SiSu CLI — 思溯 / SiSu · 思有所溯",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://www.sisu.chat",