Skip to content

fix(graph): a reload after creating a graph opens the new graph - #13624

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/new-graph-tab-memory
Oct 7, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/new-graph-tab-memory

Conversation

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1361.

Create a DB graph A, reload, create a second graph B, reload: A opens, not B. On the desktop app the window also keeps B's route, so it shows "Page not found" in A.

At start the window picks its graph from the URL, then the graph the tab remembers (sessionStorage, graph-tab/get-tab-repo), then :git/current-repo. Creating a graph sets :git/current-repo, but the tab's entry is written only at start (restore-and-setup!) and by a switch through the graph list (graph-switch-on-persisted, which calls <upsert-current-graph-registry! and remember-current-graph-id-in-tab!). After the first reload the tab remembers A, creating B does not replace it, and the next reload resolves to A.

create-db in src/main/frontend/handler/repo.cljs now does what a switch does once the new graph is set up: it adds the graph to the registry and remembers it in the tab. A file-graph import is left as it was; its own flow decides which graph the tab ends on.

create-db-does-not-start-renderer-db-conn-test in src/test/frontend/handler/repo_test.cljs now also checks that a new graph is remembered in the tab and registered, and that an import does neither. On master the new checks fail; with the change they pass. frontend.handler.repo-test, frontend.handler.graph-test, frontend.handler.events-test and frontend.components.repo-test pass.

At start the window opens the graph its tab remembers before the last
current graph; creating a graph never updated the tab, so a reload
reopened the graph opened before it (db-test logseq#1361). create-db now
registers the new graph and remembers it in the tab, as a switch does.
@tiensonqin
tiensonqin force-pushed the fix/new-graph-tab-memory branch from baa92fe to 18493c6 Compare October 7, 2026 11:27
@tiensonqin
tiensonqin merged commit 84c1b90 into logseq:master Oct 7, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
At start the window opens the graph its tab remembers before the last
current graph; creating a graph never updated the tab, so a reload
reopened the graph opened before it (db-test #1361). create-db now
registers the new graph and remembers it in the tab, as a switch does.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired
yuxi-liu-wired deleted the fix/new-graph-tab-memory branch October 21, 2026 18:01
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.

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

2 participants