fix(plugins): refresh workbench tabs after install and rollback
This commit is contained in:
6 files changed
+159
-5
No files matched your search
@@ -34,6 +34,7 @@ describe("useTauriEvents", () => {
|
||||
openDbFilePath: vi.fn(),
|
||||
openConnectionDeepLink: vi.fn(),
|
||||
closeActiveSurface,
|
||||
refreshPluginWorkbenches: vi.fn(),
|
||||
});
|
||||
|
||||
events.setupTauriListeners();
|
||||
@@ -44,4 +45,23 @@ describe("useTauriEvents", () => {
|
||||
events.cleanupTauriListeners();
|
||||
expect(unlisten).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("forwards replaced plugin runtimes to the workbench refresh hook", async () => {
|
||||
const refreshPluginWorkbenches = vi.fn();
|
||||
const events = useTauriEvents({
|
||||
openTableTarget: vi.fn(),
|
||||
openSqlFilePath: vi.fn(),
|
||||
openDbFilePath: vi.fn(),
|
||||
openConnectionDeepLink: vi.fn(),
|
||||
closeActiveSurface: vi.fn(),
|
||||
refreshPluginWorkbenches,
|
||||
});
|
||||
|
||||
events.setupTauriListeners();
|
||||
await vi.waitFor(() => expect(listeners.has("plugin-runtime-replaced")).toBe(true));
|
||||
listeners.get("plugin-runtime-replaced")!({ payload: { pluginId: "io.example.plugin", version: "0.2.0" } });
|
||||
|
||||
expect(refreshPluginWorkbenches).toHaveBeenCalledExactlyOnceWith("io.example.plugin");
|
||||
events.cleanupTauriListeners();
|
||||
});
|
||||
});
|
||||
@@ -11,6 +11,7 @@ export function useTauriEvents(deps: {
|
||||
openAiConfigDeepLink: (url: string) => Promise<void>;
|
||||
openPluginInstallDeepLink: (url: string) => Promise<void>;
|
||||
closeActiveSurface: () => void;
|
||||
refreshPluginWorkbenches: (pluginId: string) => void;
|
||||
}) {
|
||||
const connectionStore = useConnectionStore();
|
||||
const queryStore = useQueryStore();
|
||||
@@ -168,6 +169,13 @@ export function useTauriEvents(deps: {
|
||||
listen("dbx-close-active-tab", () => {
|
||||
deps.closeActiveSurface();
|
||||
}).then((unlisten) => unlistenHandles.push(unlisten));
|
||||
|
||||
// A plugin was installed/rolled back from its already-replaced runtime:
|
||||
// open workbench tabs still render the previous UI bundle until they
|
||||
// reload, so hand them the new identity to pick up.
|
||||
listen<{ pluginId: string; version: string }>("plugin-runtime-replaced", (event) => {
|
||||
if (event.payload?.pluginId) deps.refreshPluginWorkbenches(event.payload.pluginId);
|
||||
}).then((unlisten) => unlistenHandles.push(unlisten));
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user