Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix[split]: accessing undefined split content (#2640)

Peter Chinmand7be43b11a25
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index 53520c3e58..0a7d52d90e 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -750,7 +750,15 @@ export function createSplitLayout(
const s = () => findSplitById(id);
const currentSplit = s();
if (!currentSplit) return;
- const content = () => s()!.content;
+ // s() can return undefined if this split is removed from state.splits before
+ // all reactive consumers have stopped reading it. lastKnownContent prevents
+ // this error and ensures consumers see the most recent content, not the initial one.
+ let lastKnownContent: SplitContent = currentSplit.content;
+ const content = () => {
+ const current = s()?.content;
+ if (current !== undefined) lastKnownContent = current;
+ return lastKnownContent;
+ };
return {
id: currentSplit.id,