Skip to content

fix(explorer): gate temporal requests on graph load - #1003

Merged
ZohaibHassan16 merged 2 commits into
semantica-agi:mainfrom
lakshayxi:fix/issue-982-duplicate-graph-requests
Aug 15, 2026
Merged

fix(explorer): gate temporal requests on graph load#1003
ZohaibHassan16 merged 2 commits into
semantica-agi:mainfrom
lakshayxi:fix/issue-982-duplicate-graph-requests

Conversation

@lakshayxi

Copy link
Copy Markdown
Contributor

Addresses #982.

Summary

Prevents temporal API requests from running before the initial graph load has succeeded.

With the backend unavailable, GraphWorkspace previously still requested:

  • /api/temporal/bounds on mount
  • /api/temporal/snapshot once the timeline initialized and graph loading failed

Both requests are now gated on a successful graph summary. Empty graphs (nodeCount: 0) still count as a successful load.

Investigation

I reproduced the backend-down path through the real Vite proxy on both current main and pre-#980.

In both cases I observed:

  • /api/graph/nodes: 1 request
  • /api/graph/edges: 0 requests
  • /api/temporal/bounds: 1 premature request
  • /api/temporal/snapshot: 1 premature request

I could not reproduce an autonomous repeated /api/graph/nodes loop during the idle period, so this patch does not change the existing TanStack Query configuration.

After the fix, with the backend unavailable:

  • /api/graph/nodes: 1 request
  • /api/temporal/bounds: 0 requests
  • /api/temporal/snapshot: 0 requests

Testing

  • npm --prefix explorer run test:graph-workspace
  • npm --prefix explorer run test:graph-store
  • npm --prefix explorer run test:plugin-registry
  • npm --prefix explorer run build
  • git diff --check upstream/main...HEAD

Also verified the runtime behavior with:

  • backend unavailable
  • successful empty graph
  • successful populated graph

Copilot AI lite review requested due to automatic review settings August 15, 2026 11:52
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

fix(explorer): gate temporal API requests on successful graph load

🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent temporal bounds/snapshot requests until the initial graph summary load succeeds.
• Treat empty graphs (nodeCount: 0) as a successful load for temporal features.
• Add focused predicate unit tests and wire them into the existing test script.
Diagram

graph TD
  G["Graph load summary"] --> W["GraphWorkspace"] --> P{"Temporal gated?"} --> B["GET /api/temporal/bounds"]
  T["Timeline time"] --> W --> P --> S["GET /api/temporal/snapshot"]
  L["isLoading flag"] --> P

  subgraph Legend
    direction LR
    _c["Component"] ~~~ _d{"Predicate / gate"} ~~~ _a["API request"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use query-level `enabled` gating (TanStack Query)
2. Extract a dedicated temporal lifecycle hook
  • ➕ Encapsulates temporal orchestration and gating in one reusable unit
  • ➕ Keeps GraphWorkspace slimmer and easier to reason about
  • ➖ More structural churn for a narrowly-scoped bug fix
  • ➖ Still needs explicit predicates/tests to cover edge cases (empty graph, backend down)

Recommendation: The chosen approach (explicit predicate gating + unit tests) is appropriate for a targeted fix: it blocks premature requests without altering existing query configuration and makes the gating rules testable and explicit. A query-level enabled refactor could be revisited later if temporal fetching is migrated into a standard query/hook layer.

Files changed (4) +175 / -4

Enhancement (1) +31 / -0
temporalLifecyclePredicates.tsAdd shared predicates for temporal request eligibility +31/-0

Add shared predicates for temporal request eligibility

• Adds small, explicit predicate helpers that define when temporal bounds and snapshot requests are allowed. Encodes the core rule that temporal requests must wait for a successful graph summary, with additional snapshot constraints on scrubber time and loading state.

explorer/src/workspaces/GraphWorkspace/temporalLifecyclePredicates.ts

Bug fix (1) +29 / -3
GraphWorkspace.tsxGate temporal bounds/snapshot effects on successful graph summary +29/-3

Gate temporal bounds/snapshot effects on successful graph summary

• Introduces 'canFetchTemporalBounds'/'canFetchTemporalSnapshot' computed via shared predicates and adds early returns in the temporal bounds and snapshot effects. Updates effect dependency arrays to include the new gating booleans, preventing temporal requests when the graph load fails (summary undefined) while still allowing empty-graph summaries.

explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx

Tests (1) +114 / -0
temporalLifecycle.test.tsUnit tests for temporal request gating predicates +114/-0

Unit tests for temporal request gating predicates

• Adds node:test coverage for both temporal gating predicates, including backend-down/failed-load behavior (summary undefined) and the empty-graph success case (nodeCount: 0). Validates snapshot gating across loading state and scrubber time presence.

explorer/tests/temporalLifecycle.test.ts

Other (1) +1 / -1
package.jsonInclude temporal lifecycle tests in graph workspace test script +1/-1

Include temporal lifecycle tests in graph workspace test script

• Extends the 'test:graph-workspace' script to also run the new 'temporalLifecycle.test.ts' file so temporal gating behavior is covered in CI/local runs.

explorer/package.json

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request prevents GraphWorkspace from issuing temporal API requests (/api/temporal/bounds and /api/temporal/snapshot) until the initial graph load has successfully produced a graph summary, avoiding premature requests when the backend is unavailable.

Changes:

  • Introduces explicit predicate helpers to decide when temporal bounds and snapshot requests are allowed.
  • Gates temporal bounds and snapshot effects in GraphWorkspace on a successful graph summary (while still allowing empty graphs with nodeCount: 0).
  • Adds focused unit tests for the temporal lifecycle gating predicates and wires them into the existing graph workspace test script.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
explorer/tests/temporalLifecycle.test.ts Adds unit tests validating the new temporal request gating rules.
explorer/src/workspaces/GraphWorkspace/temporalLifecyclePredicates.ts Introduces reusable predicates that encode when temporal bounds/snapshot requests may run.
explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx Applies the new gating predicates to the temporal bounds and snapshot effects.
explorer/package.json Extends the graph workspace test script to include the new temporal lifecycle test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 15, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@ZohaibHassan16
ZohaibHassan16 self-requested a review August 15, 2026 12:38

@ZohaibHassan16 ZohaibHassan16 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for raising the PR. Tested and confirmed. LGTM.

@ZohaibHassan16
ZohaibHassan16 merged commit 115e796 into semantica-agi:main Aug 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants