Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/lib/components/dialogs/ToolboxManagerDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
TOOLBOX_CATALOG,
performInstall,
discoverToolbox,
registerToolbox,
commitToolbox,
uninstallToolbox,
upsertToolbox,
removeToolbox,
toolboxes,
toolboxSourceKey,
Expand Down Expand Up @@ -318,13 +317,10 @@
blocks: blockSelections,
events: eventSelections
};
registerToolbox(config, {
blocks: discoveredBlocks,
events: discoveredEvents,
commitToolbox(config, { blocks: discoveredBlocks, events: discoveredEvents }, {
defaultCategory,
categoryByClass
});
upsertToolbox(config);
onSaved?.(config);
onClose();
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/toolbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
performInstall,
discoverToolbox,
registerToolbox,
commitToolbox,
uninstallToolbox
} from './register';

Expand Down
9 changes: 3 additions & 6 deletions src/lib/toolbox/installFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/

import { get } from 'svelte/store';
import { toolboxes, upsertToolbox } from './store';
import { performInstall, discoverToolbox, registerToolbox } from './register';
import { toolboxes } from './store';
import { performInstall, discoverToolbox, commitToolbox } from './register';
import { getCatalogEntry } from './catalog';
import type { ToolboxConfig, ToolboxSource } from './types';

Expand Down Expand Up @@ -65,13 +65,10 @@ export async function installAndRegisterToolbox(spec: InstallSpec): Promise<Tool
};

const catalog = getCatalogEntry(spec.id);
registerToolbox(config, {
blocks: discovered.blocks,
events: discovered.events,
commitToolbox(config, discovered, {
defaultCategory: catalog?.defaultCategory,
categoryByClass: catalog?.categoryByClass
});
upsertToolbox(config);

return config;
})();
Expand Down
21 changes: 21 additions & 0 deletions src/lib/toolbox/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
type IntrospectedBlock,
type IntrospectedEvent
} from './installer';
import { upsertToolbox } from './store';
import type { BlockSelection, EventSelection, ToolboxConfig } from './types';

/**
Expand Down Expand Up @@ -247,6 +248,26 @@ export function registerToolbox(
}
}

/**
* Commit a discovered toolbox: register its selected blocks/events and persist
* the config. The shared tail of both install paths — the startup/required
* orchestrator (`installFlow`) and the manager dialog — which run their own
* install + discover + selection beforehand and then call this to land it.
*/
export function commitToolbox(
config: ToolboxConfig,
discovered: { blocks: IntrospectedBlock[]; events: IntrospectedEvent[] },
hints: { defaultCategory?: string; categoryByClass?: Record<string, string> } = {}
): void {
registerToolbox(config, {
blocks: discovered.blocks,
events: discovered.events,
defaultCategory: hints.defaultCategory,
categoryByClass: hints.categoryByClass
});
upsertToolbox(config);
}

/** Clean up a toolbox: drop registry entries and the Python module. */
export async function uninstallToolbox(config: ToolboxConfig): Promise<void> {
nodeRegistry.unregisterSource(config.id);
Expand Down
Loading