Skip to content

Commit a354803

Browse files
authored
feat(tui): add Kimi WebBridge install entry to /plugins panel (#1494)
* feat(tui): add Kimi WebBridge install entry to /plugins panel Surface a hardcoded Kimi WebBridge entry at the top of the Official tab in the /plugins panel. Selecting it opens the WebBridge install page in the user's browser instead of going through the plugin install flow, since WebBridge is a browser extension plus local daemon rather than an installable plugin package. * fix(tui): restrict WebBridge open-url shortcut to the pinned row Match the hardcoded pinned WebBridge entry by object reference instead of by id. A curated or custom marketplace entry on the Third-party tab can legitimately reuse the kimi-webbridge id; routing by id hijacked Enter on those rows and opened the WebBridge page instead of installing. The Official tab still dedupes a same-id official catalog entry so the pinned row is not duplicated. * fix(tui): label WebBridge plugins row as "open in browser" The previous "webpage" status did not make it clear that selecting this row opens an external page rather than installing in-app. "open in browser" states the action directly and contrasts with the install label on regular plugin rows. * test(tui): navigate past pinned WebBridge row in marketplace install tests Two message-flow tests pressed Enter on the Official tab assuming index 0 was the Kimi Datasource entry. The hardcoded Kimi WebBridge row now leads that tab, so move down one row before installing.
1 parent 170ae44 commit a354803

5 files changed

Lines changed: 149 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@moonshot-ai/kimi-code": patch
3+
---
4+
5+
Add a Kimi WebBridge entry to the Official tab of the /plugins panel that opens the WebBridge install page in your browser.

apps/kimi-code/src/tui/commands/plugins.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { UsagePanelComponent } from '../components/messages/usage-panel';
2222
import { formatErrorMessage } from '../utils/event-payload';
2323
import { formatPluginSourceLabel, isOfficialPluginSource } from '../utils/plugin-source-label';
2424
import { loadPluginMarketplace } from '#/utils/plugin-marketplace';
25+
import { openUrl } from '#/utils/open-url';
2526
import type { SlashCommandHost } from './dispatch';
2627

2728
interface ShowPluginsPickerOptions {
@@ -411,6 +412,12 @@ async function handlePluginsPanelSelection(
411412
isOfficialPluginSource(selection.source),
412413
);
413414
return;
415+
case 'open-url':
416+
host.restoreEditor();
417+
openUrl(selection.url);
418+
host.showStatus(`Opening the ${selection.label} page in your browser…`, 'success');
419+
host.showStatus(`If it did not open, visit ${selection.url}`);
420+
return;
414421
}
415422
}
416423

apps/kimi-code/src/tui/components/dialogs/plugins-selector.ts

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ const INSTALL_TRUST_EXIT = 'exit';
2828
const INSTALL_TRUST_TRUST = 'trust';
2929
const ELLIPSIS = '…';
3030

31+
// Hardcoded Web Bridge promotion: a built-in entry that always leads the
32+
// Official tab, even when the marketplace catalog is unavailable. Selecting it
33+
// opens the install page in the browser rather than installing from a source,
34+
// because Web Bridge is a browser extension + daemon, not a plugin package.
35+
const WEB_BRIDGE_URL = 'https://www.kimi.com/features/webbridge';
36+
const WEB_BRIDGE_ENTRY: PluginMarketplaceEntry = {
37+
id: 'kimi-webbridge',
38+
displayName: 'Kimi WebBridge',
39+
source: WEB_BRIDGE_URL,
40+
tier: 'official',
41+
homepage: WEB_BRIDGE_URL,
42+
description: 'Control your real browser from Kimi Code — navigate, click, type, and screenshot',
43+
};
44+
45+
// Only the hardcoded pinned row should open the WebBridge install page. Match
46+
// by reference (not id) so a catalog entry on another tab that happens to
47+
// reuse the same id still installs normally instead of being hijacked.
48+
function isPinnedWebBridgeEntry(entry: PluginMarketplaceEntry): boolean {
49+
return entry === WEB_BRIDGE_ENTRY;
50+
}
51+
3152
interface PluginsOverviewItem {
3253
readonly value: string;
3354
readonly kind: 'plugin' | 'action';
@@ -304,7 +325,8 @@ export type PluginsPanelSelection =
304325
| { readonly kind: 'details'; readonly id: string }
305326
| { readonly kind: 'reload' }
306327
| { readonly kind: 'install'; readonly entry: PluginMarketplaceEntry }
307-
| { readonly kind: 'install-source'; readonly source: string };
328+
| { readonly kind: 'install-source'; readonly source: string }
329+
| { readonly kind: 'open-url'; readonly url: string; readonly label: string };
308330

309331
export interface PluginsPanelOptions {
310332
readonly installed: readonly PluginSummary[];
@@ -402,7 +424,19 @@ export class PluginsPanelComponent extends Container implements Focusable {
402424
}
403425

404426
private get officialEntries(): readonly PluginMarketplaceEntry[] {
405-
return this.marketplaceEntries.filter((entry) => entry.tier === 'official');
427+
// The hardcoded Web Bridge entry always leads the Official tab, even when
428+
// the catalog is loading or unreachable. Dedupe by id so a catalog that
429+
// also lists it does not render a second row.
430+
return [WEB_BRIDGE_ENTRY, ...this.officialCatalogEntries];
431+
}
432+
433+
private get officialCatalogEntries(): readonly PluginMarketplaceEntry[] {
434+
// Dedupe by id (not reference): if the official catalog also lists
435+
// kimi-webbridge, the pinned row already represents it, so suppress the
436+
// catalog copy to avoid a duplicate row on the Official tab.
437+
return this.marketplaceEntries.filter(
438+
(entry) => entry.tier === 'official' && entry.id !== WEB_BRIDGE_ENTRY.id,
439+
);
406440
}
407441

408442
private get thirdPartyEntries(): readonly PluginMarketplaceEntry[] {
@@ -516,6 +550,10 @@ export class PluginsPanelComponent extends Container implements Focusable {
516550
if (matchesKey(data, Key.enter)) {
517551
const entry = entries[this.selectedIndex];
518552
if (entry === undefined) return;
553+
if (isPinnedWebBridgeEntry(entry)) {
554+
this.opts.onSelect({ kind: 'open-url', url: WEB_BRIDGE_URL, label: entry.displayName });
555+
return;
556+
}
519557
this.opts.onSelect({ kind: 'install', entry });
520558
}
521559
}
@@ -622,6 +660,7 @@ export class PluginsPanelComponent extends Container implements Focusable {
622660
lines: string[],
623661
width: number,
624662
entries: readonly PluginMarketplaceEntry[],
663+
indexOffset = 0,
625664
): void {
626665
const colors = currentTheme.palette;
627666
if (this.market.status === 'loading' || this.market.status === 'idle') {
@@ -637,7 +676,7 @@ export class PluginsPanelComponent extends Container implements Focusable {
637676
lines.push(chalk.hex(colors.textMuted)(' No plugins found.'));
638677
} else {
639678
for (let i = 0; i < entries.length; i++) {
640-
lines.push(...this.renderMarketplaceRow(entries[i]!, i, width));
679+
lines.push(...this.renderMarketplaceRow(entries[i]!, i + indexOffset, width));
641680
}
642681
}
643682
const installedCount = entries.filter((e) => this.opts.installedIds.has(e.id)).length;
@@ -649,7 +688,11 @@ export class PluginsPanelComponent extends Container implements Focusable {
649688
}
650689

651690
private renderOfficial(lines: string[], width: number): void {
652-
this.renderMarketplaceTab(lines, width, this.officialEntries);
691+
// Web Bridge is pinned above the catalog and stays visible while the
692+
// catalog loads or errors, since it's built into the TUI rather than
693+
// fetched. Catalog rows shift down by one index to match.
694+
lines.push(...this.renderMarketplaceRow(WEB_BRIDGE_ENTRY, 0, width));
695+
this.renderMarketplaceTab(lines, width, this.officialCatalogEntries, 1);
653696
}
654697

655698
private renderThirdParty(lines: string[], width: number): void {
@@ -662,7 +705,9 @@ export class PluginsPanelComponent extends Container implements Focusable {
662705
const pointer = selected ? SELECT_POINTER : ' ';
663706
const labelStyle = selected ? chalk.hex(colors.primary).bold : chalk.hex(colors.text);
664707
const prefix = chalk.hex(selected ? colors.primary : colors.textDim)(` ${pointer} `);
665-
const status = marketplaceEntryStatus(entry, this.installedVersions);
708+
const status = isPinnedWebBridgeEntry(entry)
709+
? 'open in browser'
710+
: marketplaceEntryStatus(entry, this.installedVersions);
666711
const line =
667712
prefix + labelStyle(entry.displayName) + ' ' + marketplaceStatusStyle(status, colors)(status);
668713
const descWidth = Math.max(1, width - 4);

apps/kimi-code/test/tui/components/dialogs/plugins-selector.test.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,87 @@ describe('plugins selector dialogs', () => {
289289
expect(out).toContain('0 installed · 1 available');
290290
});
291291

292+
it('renders the hardcoded Web Bridge entry on the Official tab while loading', () => {
293+
const { panel } = makePanel({ initialTab: 'official' });
294+
// The catalog is still loading, but the built-in Web Bridge entry is shown
295+
// immediately because it is baked into the TUI, not fetched.
296+
const out = strip(renderRaw(panel));
297+
expect(out).toContain('Kimi WebBridge open in browser');
298+
expect(out).toContain('Loading marketplace');
299+
});
300+
301+
it('keeps the Web Bridge entry visible when the Official catalog errors', () => {
302+
const { panel } = makePanel({ initialTab: 'official' });
303+
panel.setMarketplaceError('fetch failed');
304+
const out = strip(renderRaw(panel));
305+
expect(out).toContain('Kimi WebBridge open in browser');
306+
expect(out).toContain('Marketplace unavailable: fetch failed');
307+
});
308+
309+
it('opens the Web Bridge webpage on Enter instead of installing', () => {
310+
const { panel, onSelect } = makePanel({ initialTab: 'official' });
311+
panel.setMarketplace(marketplaceEntries, '/tmp/marketplace.json');
312+
// Web Bridge is pinned at index 0, so Enter selects it directly.
313+
panel.handleInput('\r');
314+
expect(onSelect).toHaveBeenCalledWith({
315+
kind: 'open-url',
316+
url: 'https://www.kimi.com/features/webbridge',
317+
label: 'Kimi WebBridge',
318+
});
319+
});
320+
321+
it('installs a catalog official entry after navigating past Web Bridge', () => {
322+
const { panel, onSelect } = makePanel({ initialTab: 'official' });
323+
panel.setMarketplace(marketplaceEntries, '/tmp/marketplace.json');
324+
panel.handleInput('\u001B[B'); // ↓ → kimi-datasource
325+
panel.handleInput('\r');
326+
expect(onSelect).toHaveBeenCalledWith({
327+
kind: 'install',
328+
entry: expect.objectContaining({ id: 'kimi-datasource' }),
329+
});
330+
});
331+
332+
it('does not duplicate Web Bridge when the catalog also lists it', () => {
333+
const entries = [
334+
{
335+
id: 'kimi-webbridge',
336+
tier: 'official' as const,
337+
displayName: 'Kimi WebBridge',
338+
source: 'https://x/w.zip',
339+
},
340+
...officialEntries,
341+
];
342+
const { panel } = makePanel({ initialTab: 'official' });
343+
panel.setMarketplace(entries, '/tmp/marketplace.json');
344+
const out = strip(renderRaw(panel));
345+
// The label should appear exactly once — the hardcoded row wins, the
346+
// catalog copy is filtered out.
347+
expect(out.split('Kimi WebBridge').length - 1).toBe(1);
348+
});
349+
350+
it('installs a Third-party entry whose id matches the pinned WebBridge', () => {
351+
// A curated/custom marketplace entry can legitimately reuse the
352+
// kimi-webbridge id; on the Third-party tab it must install normally, not
353+
// open the WebBridge page (that shortcut is reserved for the pinned row).
354+
const entries = [
355+
{
356+
id: 'kimi-webbridge',
357+
tier: 'curated' as const,
358+
displayName: 'Kimi WebBridge',
359+
source: 'https://x/w.zip',
360+
},
361+
];
362+
const { panel, onSelect } = makePanel({ initialTab: 'third-party' });
363+
panel.setMarketplace(entries, '/tmp/marketplace.json');
364+
const out = strip(renderRaw(panel));
365+
expect(out).toContain('Kimi WebBridge install');
366+
panel.handleInput('\r');
367+
expect(onSelect).toHaveBeenCalledWith({
368+
kind: 'install',
369+
entry: expect.objectContaining({ id: 'kimi-webbridge', source: 'https://x/w.zip' }),
370+
});
371+
});
372+
292373
it('installs the selected Third-party entry on Enter', () => {
293374
const { panel, onSelect } = makePanel({ installed: [superpowers], initialTab: 'third-party' });
294375
panel.setMarketplace(marketplaceEntries, '/tmp/marketplace.json');

apps/kimi-code/test/tui/kimi-tui-message-flow.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3781,6 +3781,9 @@ command = "vim"
37813781
await vi.waitFor(() => {
37823782
expect(stripSgr(panel.render(120).join('\n'))).toContain('Kimi Datasource');
37833783
});
3784+
// The pinned Kimi WebBridge row leads the Official tab, so move down to
3785+
// the Kimi Datasource entry before installing.
3786+
panel.handleInput('\u001B[B');
37843787
panel.handleInput('\r');
37853788

37863789
await vi.waitFor(() => {
@@ -3987,6 +3990,9 @@ command = "vim"
39873990
await vi.waitFor(() => {
39883991
expect(stripSgr(panel.render(120).join('\n'))).toContain('Kimi Datasource');
39893992
});
3993+
// The pinned Kimi WebBridge row leads the Official tab, so move down to
3994+
// the Kimi Datasource entry before installing.
3995+
panel.handleInput('\u001B[B');
39903996
panel.handleInput('\r');
39913997

39923998
await vi.waitFor(() => {

0 commit comments

Comments
 (0)