@phenx-inc/ctlsurf 0.3.8 → 0.3.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.
@@ -5471,7 +5471,7 @@ var require_package = __commonJS({
5471
5471
  "package.json"(exports, module) {
5472
5472
  module.exports = {
5473
5473
  name: "@phenx-inc/ctlsurf",
5474
- version: "0.3.8",
5474
+ version: "0.3.9",
5475
5475
  description: "Agent-agnostic terminal and desktop app for ctlsurf \u2014 run Claude Code, Codex, or any coding agent with live session logging and remote control",
5476
5476
  main: "out/main/index.js",
5477
5477
  bin: {
@@ -6619,6 +6619,7 @@ var DEFAULT_PROFILES = {
6619
6619
  }
6620
6620
  };
6621
6621
  var TERM_STREAM_INTERVAL_MS = 50;
6622
+ var NO_PROJECT_POLL_MS = 5e3;
6622
6623
  var Orchestrator = class {
6623
6624
  settingsDir;
6624
6625
  events;
@@ -6637,6 +6638,8 @@ var Orchestrator = class {
6637
6638
  profiles: { ...DEFAULT_PROFILES },
6638
6639
  logChat: false
6639
6640
  };
6641
+ noProjectPollTimer = null;
6642
+ noProjectPollCwd = null;
6640
6643
  constructor(settingsDir, events) {
6641
6644
  this.settingsDir = settingsDir;
6642
6645
  this.events = events;
@@ -6662,6 +6665,11 @@ var Orchestrator = class {
6662
6665
  events.onWorkerRegistered(data);
6663
6666
  if (!data.folder_id) {
6664
6667
  events.onWorkerStatus("no_project");
6668
+ if (this.currentCwd && data.status !== "pending_approval") {
6669
+ this.startNoProjectPolling(this.currentCwd);
6670
+ }
6671
+ } else {
6672
+ this.stopNoProjectPolling();
6665
6673
  }
6666
6674
  },
6667
6675
  onTerminalInput: (data) => {
@@ -6901,6 +6909,7 @@ var Orchestrator = class {
6901
6909
  if (isCodingAgent(agent)) {
6902
6910
  this.connectWorkerWs(agent, cwd);
6903
6911
  } else {
6912
+ this.stopNoProjectPolling();
6904
6913
  this.workerWs.disconnect();
6905
6914
  this.checkProjectStatus(cwd);
6906
6915
  }
@@ -6975,12 +6984,47 @@ var Orchestrator = class {
6975
6984
  log3("[worker-ws] No API key, skipping WS connect");
6976
6985
  return;
6977
6986
  }
6987
+ this.stopNoProjectPolling();
6978
6988
  this.workerWs.connect({
6979
6989
  machine: os3.hostname(),
6980
6990
  cwd,
6981
6991
  agent: agent.name
6982
6992
  });
6983
6993
  }
6994
+ startNoProjectPolling(cwd) {
6995
+ if (this.noProjectPollTimer && this.noProjectPollCwd === cwd) return;
6996
+ this.stopNoProjectPolling();
6997
+ this.noProjectPollCwd = cwd;
6998
+ log3(`[worker-ws] Polling for project folder at ${cwd}`);
6999
+ this.noProjectPollTimer = setInterval(() => {
7000
+ void this.checkForProjectFolder(cwd);
7001
+ }, NO_PROJECT_POLL_MS);
7002
+ }
7003
+ stopNoProjectPolling() {
7004
+ if (this.noProjectPollTimer) {
7005
+ clearInterval(this.noProjectPollTimer);
7006
+ this.noProjectPollTimer = null;
7007
+ this.noProjectPollCwd = null;
7008
+ }
7009
+ }
7010
+ async checkForProjectFolder(cwd) {
7011
+ if (this.currentCwd !== cwd || !this.currentAgent) {
7012
+ this.stopNoProjectPolling();
7013
+ return;
7014
+ }
7015
+ if (!this.ctlsurfApi.getApiKey()) return;
7016
+ try {
7017
+ const folder = await this.ctlsurfApi.findFolderByPath(cwd);
7018
+ if (folder?.id && this.currentCwd === cwd && this.currentAgent) {
7019
+ log3(`[worker-ws] Project folder appeared (${folder.id}); reconnecting`);
7020
+ const agent = this.currentAgent;
7021
+ this.stopNoProjectPolling();
7022
+ this.workerWs.disconnect();
7023
+ this.connectWorkerWs(agent, cwd);
7024
+ }
7025
+ } catch {
7026
+ }
7027
+ }
6984
7028
  async checkProjectStatus(cwd) {
6985
7029
  if (!this.ctlsurfApi.getApiKey()) {
6986
7030
  this.events.onWorkerStatus("no_project");
@@ -7011,6 +7055,7 @@ var Orchestrator = class {
7011
7055
  }
7012
7056
  // ─── Shutdown ───────────────────────────────────
7013
7057
  async shutdown() {
7058
+ this.stopNoProjectPolling();
7014
7059
  this.bridge.endSession();
7015
7060
  await this.timeTracker.endAll();
7016
7061
  for (const [, tab] of this.tabs) {