feat(web): auto-open install dialog from one-click deep link

Accept a deep link from LangBot Space's one-click install:
/home/add-extension?install=1&extension_type=<plugin|mcp|skill>&author=&name=&version=
On mount, populate the install info, open the confirm dialog directly, and
strip the params from the URL. Reuses the existing marketplace install flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Junyan Qin
2026-06-01 18:11:07 +08:00
parent 95c09688e6
commit 62bdd1b3df

View File

@@ -224,6 +224,50 @@ function AddExtensionContent() {
);
}, [searchParams, setSearchParams]);
// One-click install deep link from LangBot Space:
// /home/add-extension?install=1&extension_type=mcp&author=X&name=Y&version=Z
// Opens the install confirm dialog directly, then strips the params.
useEffect(() => {
if (searchParams.get('install') !== '1') return;
const author = searchParams.get('author');
const name = searchParams.get('name');
if (!author || !name) return;
const rawType =
searchParams.get('extension_type') ||
searchParams.get('type') ||
'plugin';
const extType = (
['plugin', 'mcp', 'skill'].includes(rawType) ? rawType : 'plugin'
) as 'plugin' | 'mcp' | 'skill';
const version = searchParams.get('version') || '';
setInstallInfo({
plugin_author: author,
plugin_name: name,
plugin_version: version,
});
setInstallExtensionType(extType);
setPluginInstallStatus(PluginInstallStatus.ASK_CONFIRM);
setInstallError(null);
setModalOpen(true);
setSearchParams(
(current) => {
const next = new URLSearchParams(current);
[
'install',
'extension_type',
'type',
'author',
'name',
'version',
].forEach((k) => next.delete(k));
return next;
},
{ replace: true },
);
}, [searchParams, setSearchParams]);
useEffect(() => {
const onComplete = (_taskId: number, success: boolean) => {
if (success) {