@agimon-ai/po-core 0.0.0-alpha.101 → 0.0.0-alpha.103

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.
@@ -76,7 +76,20 @@ function scopeOf(session) {
76
76
  }
77
77
  /** Owns direct, same-process session and channel state for presentation adapters. */
78
78
  function createHeadlessHub(options) {
79
- const readGitStatus = options.readGitStatus ?? ((cwd) => require_index$2.readSessionGitStatus(options.platform.env(cwd), cwd));
79
+ const gitReads = /* @__PURE__ */ new Set();
80
+ const readGitStatus = (cwd, shell, environment) => {
81
+ for (const read of gitReads) if (read.cwd === cwd && read.shell === shell && read.environment === environment) return read.promise;
82
+ const promise = Promise.resolve().then(() => options.readGitStatus ? options.readGitStatus(cwd) : require_index$2.readSessionGitStatus(shell, cwd));
83
+ const read = {
84
+ cwd,
85
+ shell,
86
+ environment,
87
+ promise
88
+ };
89
+ gitReads.add(read);
90
+ promise.finally(() => gitReads.delete(read)).catch(() => {});
91
+ return promise;
92
+ };
80
93
  const sessions = /* @__PURE__ */ new Map();
81
94
  const pendingSetups = /* @__PURE__ */ new Map();
82
95
  const activities = /* @__PURE__ */ new Map();
@@ -746,9 +759,10 @@ function createHeadlessHub(options) {
746
759
  sessions.set(session.id, current);
747
760
  announceCommunicationReady(session.id);
748
761
  const sandboxed = session.workspaceId !== void 0 && workspaces.get(session.workspaceId)?.sandbox !== void 0;
762
+ const gitShell = sandboxed ? void 0 : options.platform.env(session.cwd);
749
763
  const refreshGit = () => {
750
- if (sandboxed) return;
751
- readGitStatus(session.cwd).then((git) => {
764
+ if (gitShell === void 0) return;
765
+ readGitStatus(session.cwd, gitShell, session.environment).then((git) => {
752
766
  if (closed || sessions.get(session.id)?.host !== session.host) return;
753
767
  if (git?.branch === current.git?.branch && git?.dirty === current.git?.dirty) return;
754
768
  const { git: _previous, ...rest } = current;