fix(plugins): stabilize plugin integration
This commit is contained in:
1 parent
b70d6da227
commit
3d1b84831f
76 files changed
+3846
-431
No files matched your search
@@ -47,6 +47,41 @@ export function useTauriEvents(deps: {
|
||||
}
|
||||
}).then((unlisten) => unlistenHandles.push(unlisten));
|
||||
|
||||
listen<{ connection_id: string }>("mcp-open-connection-workbench", async (event) => {
|
||||
try {
|
||||
const { connection_id } = event.payload;
|
||||
if (!connectionStore.connections.length) await connectionStore.initFromDisk();
|
||||
const config = connectionStore.getConfig(connection_id);
|
||||
if (!config) return;
|
||||
connectionStore.activeConnectionId = connection_id;
|
||||
// Dedup + tab switch happen inside the store; also ensures the
|
||||
// plugin workbench session (and its PTY) exists before returning.
|
||||
// Deliberately no window focus here: agent-terminal calls open
|
||||
// the tab so the command lands in a real terminal, but stealing
|
||||
// the OS focus interrupted whatever the user was doing.
|
||||
await queryStore.openPluginConnection(connection_id);
|
||||
} catch (e) {
|
||||
console.error("[DBX] mcp-open-connection-workbench error:", e);
|
||||
}
|
||||
}).then((unlisten) => unlistenHandles.push(unlisten));
|
||||
|
||||
// Plugins report live transport state through plugin events; when an
|
||||
// SSH session dies, flip the sidebar entry offline so the tree stops
|
||||
// showing a connection that no longer exists.
|
||||
listen<{ method: string; params: { state?: string; connectionId?: string } }>("dbx-plugin-event", async (event) => {
|
||||
try {
|
||||
const payload = event.payload ?? ({} as typeof event.payload);
|
||||
if (payload.method !== "ssh/session/state" || payload.params?.state !== "disconnected") return;
|
||||
const connectionId = payload.params?.connectionId;
|
||||
if (!connectionId) return;
|
||||
if (!connectionStore.connections.length) await connectionStore.initFromDisk();
|
||||
if (!connectionStore.getConfig(connectionId)) return;
|
||||
connectionStore.markConnectionOffline(connectionId);
|
||||
} catch (e) {
|
||||
console.error("[DBX] dbx-plugin-event (ssh/session/state) error:", e);
|
||||
}
|
||||
}).then((unlisten) => unlistenHandles.push(unlisten));
|
||||
|
||||
listen("mcp-reload-connections", async () => {
|
||||
try {
|
||||
await connectionStore.initFromDisk();
|
||||
|
||||
@@ -57,6 +57,11 @@ if (savedThemeMode && savedThemeMode !== themeMode.value) safeLocalStorageSet(AP
|
||||
if (savedCornerStyle && savedCornerStyle !== cornerStyle.value) safeLocalStorageSet(APP_CORNER_STYLE_STORAGE_KEY, cornerStyle.value);
|
||||
const systemPrefersDark = ref(readSystemPrefersDark());
|
||||
const isDark = computed(() => resolveAppThemeAppearance(themeMode.value, systemPrefersDark.value) === "dark");
|
||||
// Bumped at the end of every applyTheme(): theme changes are DOM mutations
|
||||
// (classes / inline vars), so watchers keyed on reactive sources like isDark
|
||||
// miss palette switches and custom-color edits. Consumers that mirror the
|
||||
// resolved token set (plugin iframe bridge) watch this revision instead.
|
||||
const themeRevision = ref(0);
|
||||
|
||||
let mediaQuery: MediaQueryList | null = null;
|
||||
let isListeningForSystemTheme = false;
|
||||
@@ -103,6 +108,7 @@ function applyTheme() {
|
||||
|
||||
// force reflow so the class toggle takes effect before re-enabling transitions
|
||||
doc.offsetHeight; // eslint-disable-line @typescript-eslint/no-unused-expressions
|
||||
themeRevision.value += 1;
|
||||
requestAnimationFrame(() => doc.classList.remove("disable-transitions"));
|
||||
if (!isTauriRuntime()) return;
|
||||
|
||||
@@ -206,5 +212,5 @@ export function useTheme() {
|
||||
setThemeMode(isDark.value ? "light" : "dark");
|
||||
}
|
||||
|
||||
return { isDark, themeMode, themePalette, customUiColors, customUiColorsDark, activeCustomUiColors, cornerStyle, applyTheme, setThemeMode, setThemePalette, previewThemePalette, clearThemePalettePreview, setCustomUiColors, resetCustomUiColors, setCornerStyle, toggleTheme };
|
||||
return { isDark, themeMode, themePalette, customUiColors, customUiColorsDark, activeCustomUiColors, themeRevision, cornerStyle, applyTheme, setThemeMode, setThemePalette, previewThemePalette, clearThemePalettePreview, setCustomUiColors, resetCustomUiColors, setCornerStyle, toggleTheme };
|
||||
}
|
||||
Reference in new issue
Block a user