mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
fix(workbench): Reset project state when a window switches projects
Opening another project in the same window left the previous project's state in module-level stores: Amend and the commit message carried over, debug sessions kept running, and Git Log, usages, hierarchy, inspection, HTTP client, recent locations, navigation history and notifications still showed the old project. Reset each of them on a project root change, stop the old debug sessions, ask about unsaved changes before leaving a project, close the settings window (it would apply to the new project) and end the indexing task when a scan is cancelled.
This commit is contained in:
1 parent
9a2025b76e
commit
5f6e2a9c85
30 files changed
+216
-26
No files matched your search
@@ -9,7 +9,7 @@ import { registerOverlay, registerToolWindow } from "@/workbench/contributions";
|
||||
import { GithubDialogHost } from "./dialogs";
|
||||
import { checkoutAction, createPullRequest, openInBrowser, showPullRequests, WINDOW } from "./ops";
|
||||
import { PullRequestsHeader, PullRequestsView } from "./PullRequestsView";
|
||||
import { DEFAULT_QUERY, refreshAll, useGithub } from "./store";
|
||||
import { refreshAll, resetGithub } from "./store";
|
||||
|
||||
const WHEN = "projectOpen";
|
||||
|
||||
@@ -65,10 +65,8 @@ export function activate(): () => void {
|
||||
},
|
||||
{ id: "github.refresh", title: "Refresh Pull Requests", category: "GitHub", icon: "refresh", when: WHEN, run: () => refreshAll() },
|
||||
]),
|
||||
// Another project: start over.
|
||||
useProject.subscribe((s, prev) => {
|
||||
if (s.project?.root === prev.project?.root) return;
|
||||
useGithub.setState({ availability: null, list: [], selected: null, details: null, reviewComments: [], query: DEFAULT_QUERY });
|
||||
if (s.project?.root !== prev.project?.root) resetGithub();
|
||||
}),
|
||||
];
|
||||
return () => disposers.reverse().forEach((d) => d());
|
||||
|
||||
@@ -163,6 +163,12 @@ export function cancelBusy() {
|
||||
|
||||
const diffCache = new Map<string, PrDiffRevisions>();
|
||||
|
||||
/** Another project: start over. */
|
||||
export function resetGithub() {
|
||||
diffCache.clear();
|
||||
useGithub.setState({ availability: null, list: [], selected: null, details: null, reviewComments: [], query: DEFAULT_QUERY });
|
||||
}
|
||||
|
||||
/** Fetches what the local repository lacks to diff `pr`, once per head commit. */
|
||||
export async function diffRevisions(pr: PullRequestDetails): Promise<PrDiffRevisions | null> {
|
||||
const key = `${pr.summary.number}:${pr.headOid}:${pr.baseOid}`;
|
||||
|
||||
Reference in new issue
Block a user