Skip to content

A reload after creating a graph reopens the graph opened before it #1361

Closed
logseq/logseq
#13624

Description

@yuxi-liu-wired

Steps

  1. Create a DB graph A (search "Add a DB graph", give it a name, Submit). A opens.
  2. Reload the window (Ctrl+R on desktop, the browser's reload on the web app). A opens again.
  3. Create a second DB graph B the same way. B opens.
  4. Reload the window.

Expected

B opens: it is the graph that was open.

Actual

A opens. On the desktop app the window also keeps B's route, so after the reload it shows "Page not found" in graph A when the last page was a page of B. B is still in the graph list and opens from there.

Measured on the web build: graph-a after the first reload, graph-b after creating it, graph-a after the second reload. On the desktop app (release build of the same commit): a graph that had been reopened by a reload, then a new graph created, then a reload, opened the older graph.

Cause (read in code, not verified by a change)

At start the window picks its graph in initial-state (src/main/frontend/state.cljs) and resolve-startup-repo (src/main/frontend/handler/graph.cljs) in this order: the URL's graph, then the graph remembered in the tab's sessionStorage (graph-tab/get-tab-repo), then :git/current-repo in local storage. Creating a graph sets :git/current-repo (state/set-current-repo!), but the tab entry is written only by remember-current-graph-id-in-tab!, which runs in restore-and-setup! (at start) and in graph-switch-on-persisted (a switch through the graph list). So after step 2 the tab remembers A, step 3 does not replace it, and the reload in step 4 resolves to A. On a fresh web app the first create and reload opened the new graph (measured), so the tab held no graph before step 2 there.

Found by a monkey test (gremlins.js with trusted Playwright input) of the desktop app built from master 16c4ed1a0, seed 301: the reload check after the run opened the graph of the previous run. The steps above reproduce it on the web build of 16c4ed1a0 (1 of 1) and on the desktop app (1 of 1).

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions