You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by zh...@apache.org on 2026/09/09 12:21:22 UTC

(maka) branch main updated: fix(desktop): keep inactive Graph panels hidden on read failure (#5089)

This is an automated email from the ASF dual-hosted git repository.

me2seeks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new 6de29ee2e9 fix(desktop): keep inactive Graph panels hidden on read failure (#5089)
6de29ee2e9 is described below

commit 6de29ee2e9831b70560f51533ed948f397627f7d
Author: Zhang <96...@users.noreply.github.com>
AuthorDate: Wed Sep 9 20:21:16 2026 +0800

    fix(desktop): keep inactive Graph panels hidden on read failure (#5089)
    
    Fixes #5088
    
    Generated-by: OpenAI Codex
---
 .../__tests__/agent-graph-panel-visibility.test.ts |  6 ---
 .../src/main/__tests__/agent-graph-panel.test.ts   | 58 ++++++++++++++++++++--
 .../src/renderer/agent-graph-panel-visibility.ts   |  3 +-
 apps/desktop/src/renderer/agent-graph-panel.tsx    |  1 -
 4 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/apps/desktop/src/main/__tests__/agent-graph-panel-visibility.test.ts b/apps/desktop/src/main/__tests__/agent-graph-panel-visibility.test.ts
index 23d81784ee..d41edf8ed4 100644
--- a/apps/desktop/src/main/__tests__/agent-graph-panel-visibility.test.ts
+++ b/apps/desktop/src/main/__tests__/agent-graph-panel-visibility.test.ts
@@ -60,7 +60,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: true,
         hasGraphActivity: true,
-        error: false,
         sessionId: 'session-1',
         graphId: 'graph-1',
         status: 'completed',
@@ -75,7 +74,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: true,
         hasGraphActivity: true,
-        error: false,
         sessionId: 'session-1',
         graphId: 'graph-2',
         status: 'active',
@@ -90,7 +88,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: true,
         hasGraphActivity: true,
-        error: false,
         sessionId: 'session-1',
         graphId: 'graph-1',
         status: 'active',
@@ -105,7 +102,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: true,
         hasGraphActivity: true,
-        error: false,
         sessionId: 'session-2',
         graphId: 'graph-1',
         status: 'completed',
@@ -120,7 +116,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: false,
         hasGraphActivity: false,
-        error: false,
         sessionId: 'session-1',
         dismissedBySession: {},
       }),
@@ -133,7 +128,6 @@ describe('shouldShowAgentGraphPanel', () => {
       shouldShowAgentGraphPanel({
         enabled: true,
         hasGraphActivity: false,
-        error: false,
         sessionId: 'session-1',
         dismissedBySession: {},
       }),
diff --git a/apps/desktop/src/main/__tests__/agent-graph-panel.test.ts b/apps/desktop/src/main/__tests__/agent-graph-panel.test.ts
index 6cbfb66ed8..64afdd4112 100644
--- a/apps/desktop/src/main/__tests__/agent-graph-panel.test.ts
+++ b/apps/desktop/src/main/__tests__/agent-graph-panel.test.ts
@@ -109,7 +109,8 @@ function installGraphRenderer(
   root: Root;
   setSnapshot(next: AgentGraphClientSnapshot): Promise<void>;
   evict(graphId: string): void;
-  renderSession(sessionId: string): Promise<void>;
+  renderSession(sessionId: string, enabled?: boolean): Promise<void>;
+  failReads(fail: boolean): void;
   holdNextEpochList(sessionId: string): DeferredRead;
   holdNextSnapshot(graphId: string): DeferredRead;
   holdNextStop(sessionId: string): DeferredRead;
@@ -155,9 +156,11 @@ function installGraphRenderer(
   const snapshotGates = new Map<string, DeferredReadGate>();
   const stopGates = new Map<string, DeferredReadGate>();
   const stopCalls: Array<{ sessionId: string; expectedGraphId: string }> = [];
+  let readsFail = false;
   let fullEpochReads = 0;
   let currentEpochReads = 0;
   const epochDirectory = (sessionId: string) => {
+    if (readsFail) throw new Error('Runtime Host unavailable');
     const currentGraphId = currentGraphIds.get(sessionId);
     const entries = [...snapshots.values()]
       .filter((entry) => entry.rootSessionId === sessionId)
@@ -257,12 +260,15 @@ function installGraphRenderer(
     epochReadCounts() {
       return { full: fullEpochReads, current: currentEpochReads };
     },
-    async renderSession(sessionId) {
+    failReads(fail) {
+      readsFail = fail;
+    },
+    async renderSession(sessionId, enabled = true) {
       await act(async () => {
         root.render(
           createElement(AgentGraphPanel, {
             rootSessionId: sessionId,
-            enabled: true,
+            enabled,
             locale: 'en',
             onOpenSession: () => undefined,
           }),
@@ -307,6 +313,52 @@ async function renderPanel(
   return harness;
 }
 
+describe('AgentGraphPanel read failures', () => {
+  for (const initiallyUnavailable of [true, false]) {
+    it(`keeps an inactive ordinary session hidden when ${initiallyUnavailable ? 'the initial read' : 'a refresh'} fails and discovers later activity`, async () => {
+      const empty = snapshot({ graphId: 'graph-1', status: 'empty', scheduleRevision: 0 });
+      const harness = installGraphRenderer(empty);
+      harness.failReads(initiallyUnavailable);
+      await harness.renderSession('session-1', false);
+      if (!initiallyUnavailable) {
+        assert.equal(harness.container.textContent, '');
+        harness.failReads(true);
+        await harness.setSnapshot(empty);
+      }
+      assert.equal(harness.container.textContent, '');
+      harness.failReads(false);
+      await harness.setSnapshot({ ...empty, status: 'active', scheduleRevision: 1 });
+      assert.match(harness.container.textContent ?? '', /Agent Graph/);
+      assert.doesNotMatch(harness.container.textContent ?? '', /Could not refresh graph state/);
+      await act(async () => harness.root.unmount());
+    });
+  }
+
+  it('shows initial read errors for enabled Graph sessions', async () => {
+    const harness = installGraphRenderer(snapshot({ graphId: 'graph-1', status: 'empty' }));
+    harness.failReads(true);
+    await harness.renderSession('session-1');
+    assert.match(harness.container.textContent ?? '', /Could not refresh graph state/);
+    await act(async () => harness.root.unmount());
+  });
+
+  for (const historyOnly of [false, true]) {
+    it(`keeps refresh errors visible for ordinary sessions with known ${historyOnly ? 'history' : 'activity'}`, async () => {
+      const current = snapshot({
+        graphId: 'graph-2', status: 'empty', scheduleRevision: historyOnly ? 0 : 1,
+      });
+      const harness = installGraphRenderer(current, historyOnly
+        ? [snapshot({ graphId: 'graph-1', status: 'completed' })] : []);
+      await harness.renderSession('session-1', false);
+      assert.match(harness.container.textContent ?? '', /Agent Graph/);
+      harness.failReads(true);
+      await harness.setSnapshot(current);
+      assert.match(harness.container.textContent ?? '', /Could not refresh graph state/);
+      await act(async () => harness.root.unmount());
+    });
+  }
+});
+
 describe('AgentGraphPanel dismiss', () => {
   it('keeps the new session loading when a disposed read settles later', async () => {
     const sessionA = snapshot({ graphId: 'graph-a', status: 'active' });
diff --git a/apps/desktop/src/renderer/agent-graph-panel-visibility.ts b/apps/desktop/src/renderer/agent-graph-panel-visibility.ts
index c80584c94b..05723c6a97 100644
--- a/apps/desktop/src/renderer/agent-graph-panel-visibility.ts
+++ b/apps/desktop/src/renderer/agent-graph-panel-visibility.ts
@@ -82,7 +82,6 @@ export function reconcileAgentGraphPanelDismissals(
 export function shouldShowAgentGraphPanel(input: {
   enabled: boolean;
   hasGraphActivity: boolean;
-  error: boolean;
   sessionId: string;
   graphId?: string;
   status?: AgentGraphPanelStatus;
@@ -95,5 +94,5 @@ export function shouldShowAgentGraphPanel(input: {
   ) {
     return false;
   }
-  return input.enabled || input.hasGraphActivity || input.error;
+  return input.enabled || input.hasGraphActivity;
 }
diff --git a/apps/desktop/src/renderer/agent-graph-panel.tsx b/apps/desktop/src/renderer/agent-graph-panel.tsx
index 7858b401d7..063a13763a 100644
--- a/apps/desktop/src/renderer/agent-graph-panel.tsx
+++ b/apps/desktop/src/renderer/agent-graph-panel.tsx
@@ -193,7 +193,6 @@ export function AgentGraphPanel(props: {
     !shouldShowAgentGraphPanel({
       enabled: props.enabled,
       hasGraphActivity: hasGraphActivity || hasGraphHistory,
-      error,
       sessionId: props.rootSessionId,
       graphId: snapshot?.graphId,
       status: snapshot?.status,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org