longtable 0.1.31 → 0.1.32

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/bin/longtable.mjs CHANGED
@@ -120,11 +120,16 @@ async function connect() {
120
120
 
121
121
  const auto = has("no-autostart") ? { started: false } : enableAutostart(process.execPath, binPath);
122
122
  if (!has("no-run") && !auto.started) {
123
- spawn(process.execPath, [binPath, "run"], { detached: true, stdio: "ignore", windowsHide: true }).unref();
123
+ // A stand-in until the start-up task runs it: it never ends a connection the task started.
124
+ spawn(process.execPath, [binPath, "run", "--backup"], { detached: true, stdio: "ignore", windowsHide: true }).unref();
124
125
  }
125
126
  const word = ai === "codex" ? "Codex" : "Claude";
126
127
  log(`connected to "${paired.table_name}" for ${paired.member_name} (${ai === "codex" ? codexVersion(codex) : claudeVersion(claude)})`);
127
- say(`Connected. ${paired.member_name}'s ${word} is now at "${paired.table_name}". It answers in the background whenever this computer is on.`);
128
+ say(auto.started || has("no-autostart")
129
+ ? `Connected. ${paired.member_name}'s ${word} is now at "${paired.table_name}". It answers in the background whenever this computer is on.`
130
+ // Said plainly when it could not be set to run by itself: today it runs from here, and from the next sign-in on
131
+ // Windows starts it, so closing this window takes it away until then.
132
+ : `Connected. ${paired.member_name}'s ${word} is now at "${paired.table_name}". It could not start in the background just now, so it is running from this window: leave it open for now. From the next time you sign in to this computer it starts by itself.`);
128
133
  const git = gitCanJoin();
129
134
  if (!git.ok) {
130
135
  log(`git cannot join two parts of work (${git.version})`);
@@ -186,7 +191,7 @@ try {
186
191
  // Started from an older copy (a cache, or an old start-up entry) while ~/.longtable/app holds a newer one: run that.
187
192
  const newerCopy = handOffTo();
188
193
  if (newerCopy) { log(`run: handing over to the newer copy in ${newerCopy}`); await import(pathToFileURL(newerCopy).href); }
189
- else await runLoop();
194
+ else await runLoop({ backup: args.includes("--backup") });
190
195
  }
191
196
  else if (command === "status") await status();
192
197
  else if (command === "disconnect") await disconnect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "longtable",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "description": "Brings your own Claude Code or Codex to your team's table on longtable.chat, quietly, on your own plan.",
5
5
  "homepage": "https://longtable.chat",
6
6
  "repository": {
package/src/autostart.mjs CHANGED
@@ -102,8 +102,11 @@ export function enableAutostart(nodePath, binPath) {
102
102
  rmSync(legacyStartup(), { force: true });
103
103
  const asked = Date.now();
104
104
  startTask(TASK);
105
- // Said started only when the connection really wrote its note; otherwise `connect` runs it itself.
106
- return { started: wroteNoteSince(asked, 20000), where: `Task Scheduler: ${TASK}` };
105
+ // Said started only when the connection really wrote its note; otherwise `connect` runs a stand-in itself. A
106
+ // first start can be slow (Windows looking over a new program), so it is asked once more and given a minute.
107
+ if (wroteNoteSince(asked, 20000)) return { started: true, where: `Task Scheduler: ${TASK}` };
108
+ try { startTask(TASK); } catch {}
109
+ return { started: wroteNoteSince(asked, 40000), where: `Task Scheduler: ${TASK}` };
107
110
  }
108
111
  // Every system runs the copy in ~/.longtable/app, which the connection keeps up to date itself, never the copy
109
112
  // that ran `connect` (on Mac and Linux that was a cache folder npm may clear).
package/src/run.mjs CHANGED
@@ -1060,7 +1060,7 @@ async function tellCommands(rpc, seat) {
1060
1060
  } catch (e) { log(`commands not sent: ${e.message}`); }
1061
1061
  }
1062
1062
 
1063
- export async function runLoop({ pollMs = 2000 } = {}) {
1063
+ export async function runLoop({ pollMs = 2000, backup = false } = {}) {
1064
1064
  const config = readConfig();
1065
1065
  if (!config.connections?.length) throw new Error("Not connected to any table yet.");
1066
1066
  const engines = { claude: findClaude(), codex: findCodex() };
@@ -1072,6 +1072,9 @@ export async function runLoop({ pollMs = 2000 } = {}) {
1072
1072
  // Only one connection runs on a computer. A second one would wipe the first one's work folder under it.
1073
1073
  const lock = join(home, "runner.pid");
1074
1074
  const old = runningConnection();
1075
+ // The stand-in `connect` starts when the start-up task was slow never ends the real one: it would leave a
1076
+ // connection tied to the window that ran `connect`, gone when that window closes. It steps aside instead.
1077
+ if (old && old !== process.pid && backup) { log(`a connection is already running (${old}); this stand-in steps aside`); process.exit(0); }
1075
1078
  if (old && old !== process.pid) { endConnection(old); log(`ended the connection that was already running (${old})`); }
1076
1079
  writeFileSync(lock, `${process.pid} ${Date.now()}`);
1077
1080
  const unlock = () => { try { if (runningConnection() === process.pid) rmSync(lock, { force: true }); } catch {} };