mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
feat(plugins): status bar items plugins can update live (#37291)
* plugins: contributes.statusBarItems with worker updates (statusBar.update)
A plugin declares status bar items { id, text?, icon?, tone?, tooltip?,
command? } (declarative profile, engines >=1.4.247); pressing one runs
its own command. A trusted worker changes them with the new worker-only
host method statusBar.update; main keeps the session's changes and
pushes snapshots to desktop windows over plugins:statusBarChanged.
Regenerates schemas, references, typings and the authoring skill.
* plugins: statusBarItems ship in 1.4.248, beside contributes.hooks
* plugins: clear a plugin's status bar changes when it is disabled, removed or updated
* plugins: list status bar items in the plugin page's Adds section
* plugins: count statusBarItems' since in the host's newest readable version
* i18n: add the plugin page's status bar row label to en.json
* plugins: status bar items respect workspace commands, dev reloads and catalog summaries
- An item whose command needs a workspace is disabled with no open workspace.
- A dev code edit (new devRevision) drops the old worker's status bar changes.
- Catalog summaries list status bar items, and marketplace details show them.
* plugins: authoring skill lists status bar items as buildable; approval lists them
The skill no longer calls status bar items reserved and gains a row for them. The
dev-load/inspect approval already lists them via the contribution summary; a test pins
that and the fingerprint binding.
* chore(plugins): regenerate the testing bundle after rebasing on main
This commit is contained in:
@@ -38,6 +38,11 @@ import {
|
||||
PLUGIN_PANEL_BRIDGE_SINCE,
|
||||
PLUGIN_SCHEMA_SINCE_V1
|
||||
} from '../manifest/plugin-schema-field-docs'
|
||||
import {
|
||||
PLUGIN_STATUS_BAR_ITEM_LIMIT,
|
||||
PLUGIN_STATUS_BAR_SINCE,
|
||||
pluginStatusBarItemContributionSchema
|
||||
} from './plugin-status-bar-item-contribution'
|
||||
import {
|
||||
PLUGIN_SETTING_LIMIT,
|
||||
pluginSettingContributionSchema
|
||||
@@ -57,7 +62,8 @@ export const PLUGIN_CONTRIBUTION_POINTS = [
|
||||
'syntaxes',
|
||||
'customEditors',
|
||||
'newFiles',
|
||||
'settings'
|
||||
'settings',
|
||||
'statusBarItems'
|
||||
] as const
|
||||
|
||||
export type PluginContributionPoint = (typeof PLUGIN_CONTRIBUTION_POINTS)[number]
|
||||
@@ -73,7 +79,6 @@ export const PLUGIN_RESERVED_CONTRIBUTION_POINTS = {
|
||||
hooks: 'agent hooks',
|
||||
taskSources: 'task sources',
|
||||
connections: 'account connections',
|
||||
statusBarItems: 'status bar items',
|
||||
sidebarCards: 'sidebar cards'
|
||||
} as const
|
||||
|
||||
@@ -89,8 +94,6 @@ export const PLUGIN_PLANNED_CONTRIBUTION_POINTS: Readonly<
|
||||
'Account providers with a host-run sign-in, so a plugin never handles credentials itself.',
|
||||
agentHarnesses:
|
||||
'New coding-agent harnesses described as data: how to launch them and read their status.',
|
||||
statusBarItems:
|
||||
'Declarative status bar widgets (label, icon, tooltip) whose values a worker updates.',
|
||||
sidebarCards: 'Declarative left-sidebar cards with fixed layouts whose values a worker updates.',
|
||||
mcpServers: 'MCP server definitions that Orca offers to the agents it launches.',
|
||||
skills: 'Agent skills shipped as files that Orca installs for the agents it launches.',
|
||||
@@ -207,6 +210,12 @@ export const pluginContributesFields = {
|
||||
PLUGIN_SETTING_LIMIT,
|
||||
'Settings Orca shows under the plugin in Settings; code reads them with `settings.get` (`settings:own`).',
|
||||
PLUGIN_PANEL_BRIDGE_SINCE
|
||||
),
|
||||
statusBarItems: contributionList(
|
||||
pluginStatusBarItemContributionSchema,
|
||||
PLUGIN_STATUS_BAR_ITEM_LIMIT,
|
||||
'Items in the status bar; pressing one runs its `command`, and a worker changes them with `statusBar.update`.',
|
||||
PLUGIN_STATUS_BAR_SINCE
|
||||
)
|
||||
} satisfies Record<PluginContributionPoint, z.ZodType>
|
||||
|
||||
@@ -217,7 +226,6 @@ export const pluginReservedContributesFields = {
|
||||
hooks: reservedList(PLUGIN_RESERVED_CONTRIBUTION_POINTS.hooks),
|
||||
taskSources: reservedList(PLUGIN_RESERVED_CONTRIBUTION_POINTS.taskSources),
|
||||
connections: reservedList(PLUGIN_RESERVED_CONTRIBUTION_POINTS.connections),
|
||||
statusBarItems: reservedList(PLUGIN_RESERVED_CONTRIBUTION_POINTS.statusBarItems),
|
||||
sidebarCards: reservedList(PLUGIN_RESERVED_CONTRIBUTION_POINTS.sidebarCards)
|
||||
} satisfies Record<PluginReservedContributionPoint, z.ZodType>
|
||||
|
||||
@@ -252,5 +260,7 @@ export const PLUGIN_CONTRIBUTION_POINT_POLICY: Record<
|
||||
// whatever opens that file (a syntax, an editor) carries its own type.
|
||||
newFiles: { execution: 'data', catalogType: null, bindsContent: false },
|
||||
// Why sandboxed-ui: only code reads a setting, and panels are the least code there is.
|
||||
settings: { execution: 'sandboxed-ui', catalogType: null, bindsContent: false }
|
||||
settings: { execution: 'sandboxed-ui', catalogType: null, bindsContent: false },
|
||||
// Why declarative: a static item only names its own command; updating it needs a worker.
|
||||
statusBarItems: { execution: 'declarative', catalogType: null, bindsContent: false }
|
||||
}
|
||||
|
||||
@@ -89,7 +89,9 @@ export function pluginContributionSummary(
|
||||
c.newFiles,
|
||||
(newFile) => newFile.title,
|
||||
(newFile) => newFile.extension
|
||||
)
|
||||
),
|
||||
// Each item's text, or its id when it shows only an icon.
|
||||
...named('statusBarItems', c.statusBarItems, (item) => item.text || item.id)
|
||||
].slice(0, PLUGIN_CONTRIBUTION_SUMMARY_LIMIT)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parsePluginManifest } from '../manifest/plugin-manifest'
|
||||
import { derivePluginExecutionProfile } from './plugin-execution-profile'
|
||||
import { pluginStatusBarItemPatchSchema } from './plugin-status-bar-item-contribution'
|
||||
import { pluginContributionSummary } from './plugin-contribution-summary'
|
||||
import {
|
||||
buildPluginApprovalRequest,
|
||||
formatPluginApprovalMessage
|
||||
} from '../approval/plugin-cli-approval'
|
||||
|
||||
function manifest(statusBarItems: unknown[], engines = '>=1.4.248') {
|
||||
return {
|
||||
manifestVersion: 2,
|
||||
execution: 'declarative',
|
||||
id: 'status-demo',
|
||||
name: 'Status demo',
|
||||
version: '1.0.0',
|
||||
engines: { orca: engines },
|
||||
contributes: {
|
||||
commands: [{ id: 'demo.tasks', title: 'Open tasks', action: 'view.tasks' }],
|
||||
statusBarItems
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function issues(raw: unknown): string {
|
||||
const parsed = parsePluginManifest(raw)
|
||||
return parsed.ok ? '' : parsed.error
|
||||
}
|
||||
|
||||
describe('contributes.statusBarItems', () => {
|
||||
it('accepts a static item that runs one of the plugin commands', () => {
|
||||
const parsed = parsePluginManifest(
|
||||
manifest([
|
||||
{ id: 'tasks', text: '3 open', icon: 'check', tone: 'warning', command: 'demo.tasks' }
|
||||
])
|
||||
)
|
||||
expect(parsed.ok && parsed.manifest.contributes.statusBarItems).toEqual([
|
||||
{ id: 'tasks', text: '3 open', icon: 'check', tone: 'warning', command: 'demo.tasks' }
|
||||
])
|
||||
})
|
||||
|
||||
it('refuses duplicate ids, unknown commands, icons and fields', () => {
|
||||
expect(
|
||||
issues(
|
||||
manifest([
|
||||
{ id: 'a', text: 'x' },
|
||||
{ id: 'a', text: 'y' }
|
||||
])
|
||||
)
|
||||
).toContain('duplicate statusBarItems id: a')
|
||||
expect(issues(manifest([{ id: 'a', command: 'demo.missing' }]))).toContain(
|
||||
'unknown contributed command: demo.missing'
|
||||
)
|
||||
expect(issues(manifest([{ id: 'a', icon: 'not-an-icon' }]))).not.toBe('')
|
||||
expect(issues(manifest([{ id: 'a', onPress: 'x' }]))).not.toBe('')
|
||||
})
|
||||
|
||||
it('lists items in the catalog summary by text, or id when icon-only', () => {
|
||||
const parsed = parsePluginManifest(
|
||||
manifest([
|
||||
{ id: 'tasks', text: '3 open' },
|
||||
{ id: 'quiet', icon: 'check' }
|
||||
])
|
||||
)
|
||||
expect(parsed.ok && pluginContributionSummary(parsed.manifest)).toEqual([
|
||||
{ kind: 'commands', name: 'Open tasks' },
|
||||
{ kind: 'statusBarItems', name: '3 open' },
|
||||
{ kind: 'statusBarItems', name: 'quiet' }
|
||||
])
|
||||
})
|
||||
|
||||
it('lists items in the dev-load and inspect approval, and binds the fingerprint to them', () => {
|
||||
const subject = (items: unknown[]) => {
|
||||
const parsed = parsePluginManifest(manifest(items))
|
||||
if (!parsed.ok) {
|
||||
throw new Error(parsed.error)
|
||||
}
|
||||
return {
|
||||
pluginKey: 'dev:status-demo',
|
||||
manifest: parsed.manifest,
|
||||
consentFingerprint: 'c',
|
||||
contentIdentity: 'h',
|
||||
isDev: true
|
||||
}
|
||||
}
|
||||
const request = buildPluginApprovalRequest(
|
||||
subject([{ id: 'tasks', text: '3 open' }]),
|
||||
'dev-load'
|
||||
)
|
||||
expect(formatPluginApprovalMessage(request)).toContain('statusBarItems "3 open"')
|
||||
expect(
|
||||
buildPluginApprovalRequest(subject([{ id: 'tasks', text: '4 open' }]), 'dev-load')
|
||||
.approvalFingerprint
|
||||
).not.toBe(request.approvalFingerprint)
|
||||
})
|
||||
|
||||
it('needs an engines floor that reads the field', () => {
|
||||
expect(issues(manifest([{ id: 'a', text: 'x' }], '>=1.4.247'))).toContain('1.4.248')
|
||||
})
|
||||
|
||||
it('needs only the declarative profile', () => {
|
||||
const parsed = parsePluginManifest(manifest([{ id: 'a', text: 'x' }]))
|
||||
expect(parsed.ok && derivePluginExecutionProfile(parsed.manifest)).toBe('declarative')
|
||||
expect(issues({ ...manifest([{ id: 'a', text: 'x' }]), execution: 'data' })).not.toBe('')
|
||||
})
|
||||
|
||||
it('patches only display fields', () => {
|
||||
expect(pluginStatusBarItemPatchSchema.safeParse({ text: '4', visible: false }).success).toBe(
|
||||
true
|
||||
)
|
||||
expect(pluginStatusBarItemPatchSchema.safeParse({ command: 'demo.tasks' }).success).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,96 @@
|
||||
import { z, type RefinementCtx } from 'zod'
|
||||
import { safePluginDisplayText } from '../manifest/plugin-display-text'
|
||||
import { pluginCommandIdSchema, pluginIdSchema } from '../manifest/plugin-manifest-fields'
|
||||
import { pluginFieldDoc } from '../manifest/plugin-schema-field-docs'
|
||||
import { PLUGIN_DECLARATIVE_TONES } from '../declarative/plugin-declarative-prop-schemas'
|
||||
import { PLUGIN_PANEL_ICONS } from './plugin-panel-contribution'
|
||||
|
||||
/** First release that reads `contributes.statusBarItems` and `statusBar.update`. */
|
||||
export const PLUGIN_STATUS_BAR_SINCE = '1.4.248'
|
||||
export const PLUGIN_STATUS_BAR_ITEM_LIMIT = 8
|
||||
export const PLUGIN_STATUS_BAR_TEXT_MAX_LENGTH = 64
|
||||
export const PLUGIN_STATUS_BAR_TOOLTIP_MAX_LENGTH = 256
|
||||
|
||||
const SINCE = PLUGIN_STATUS_BAR_SINCE
|
||||
|
||||
/** The fields a worker may change at runtime; the manifest declares their first values. */
|
||||
export const pluginStatusBarItemDisplayFields = {
|
||||
text: safePluginDisplayText(z.string().max(PLUGIN_STATUS_BAR_TEXT_MAX_LENGTH))
|
||||
.optional()
|
||||
.meta(pluginFieldDoc('Short label shown in the status bar.', SINCE, ['3 blocked'])),
|
||||
icon: z
|
||||
.enum(PLUGIN_PANEL_ICONS)
|
||||
.optional()
|
||||
.meta(pluginFieldDoc('Icon shown before the text, from the panel icon set.', SINCE, ['bell'])),
|
||||
tone: z
|
||||
.enum(PLUGIN_DECLARATIVE_TONES)
|
||||
.optional()
|
||||
.meta(pluginFieldDoc('Colour of the item. Defaults to `neutral`.', SINCE, ['warning'])),
|
||||
tooltip: safePluginDisplayText(z.string().max(PLUGIN_STATUS_BAR_TOOLTIP_MAX_LENGTH))
|
||||
.optional()
|
||||
.meta(pluginFieldDoc('Shown on hover. Defaults to the plugin name.', SINCE))
|
||||
}
|
||||
|
||||
export const pluginStatusBarItemContributionSchema = z
|
||||
.object({
|
||||
id: pluginIdSchema.meta(
|
||||
pluginFieldDoc(
|
||||
"Item id, unique among this plugin's status bar items; `statusBar.update` names it.",
|
||||
SINCE,
|
||||
['blocked-count']
|
||||
)
|
||||
),
|
||||
...pluginStatusBarItemDisplayFields,
|
||||
command: pluginCommandIdSchema
|
||||
.optional()
|
||||
.meta(
|
||||
pluginFieldDoc(
|
||||
'Id of a command this plugin contributes in `contributes.commands`, run when the item is pressed.',
|
||||
SINCE,
|
||||
['guard.showLog']
|
||||
)
|
||||
)
|
||||
})
|
||||
.strict()
|
||||
.meta({
|
||||
id: 'StatusBarItemContribution',
|
||||
description:
|
||||
'An item in the status bar. Requires the `declarative` profile; a `trusted-worker` can change it with `statusBar.update`.'
|
||||
})
|
||||
|
||||
export type PluginStatusBarItemContribution = z.infer<typeof pluginStatusBarItemContributionSchema>
|
||||
|
||||
/** What `statusBar.update` sets; an absent field keeps its value, `visible: false` hides it. */
|
||||
export const pluginStatusBarItemPatchSchema = z.strictObject({
|
||||
...pluginStatusBarItemDisplayFields,
|
||||
visible: z.boolean().optional()
|
||||
})
|
||||
export type PluginStatusBarItemPatch = z.infer<typeof pluginStatusBarItemPatchSchema>
|
||||
|
||||
export function validatePluginStatusBarItems(
|
||||
contributes: {
|
||||
commands: readonly { id: string }[]
|
||||
statusBarItems: readonly { id: string; command?: string }[]
|
||||
},
|
||||
ctx: RefinementCtx
|
||||
): void {
|
||||
const ids = new Set<string>()
|
||||
const commands = new Set(contributes.commands.map((command) => command.id))
|
||||
for (const [index, item] of contributes.statusBarItems.entries()) {
|
||||
if (ids.has(item.id)) {
|
||||
ctx.addIssue({
|
||||
code: 'custom',
|
||||
path: ['contributes', 'statusBarItems', index],
|
||||
message: `duplicate statusBarItems id: ${item.id}`
|
||||
})
|
||||
}
|
||||
ids.add(item.id)
|
||||
if (item.command !== undefined && !commands.has(item.command)) {
|
||||
ctx.addIssue({
|
||||
code: 'custom',
|
||||
path: ['contributes', 'statusBarItems', index, 'command'],
|
||||
message: `unknown contributed command: ${item.command}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { PluginStatusBarItemPatch } from './plugin-status-bar-item-contribution'
|
||||
|
||||
/** Runtime changes workers made, by plugin key then item id; main pushes it to the renderer. */
|
||||
export type PluginStatusBarOverrides = Readonly<
|
||||
Record<string, Readonly<Record<string, PluginStatusBarItemPatch>>>
|
||||
>
|
||||
|
||||
/** main → renderer: a new PluginStatusBarOverrides snapshot. */
|
||||
export const PLUGIN_STATUS_BAR_CHANGED_CHANNEL = 'plugins:statusBarChanged'
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
PLUGIN_PANEL_UI_SINCE,
|
||||
PLUGIN_SCHEMA_SINCE_V1
|
||||
} from '../manifest/plugin-schema-field-docs'
|
||||
import { PLUGIN_STATUS_BAR_SINCE } from '../contributions/plugin-status-bar-item-contribution'
|
||||
|
||||
/** The newest "since" this build's schemas cite: everything up to it is readable here. */
|
||||
export const PLUGIN_SCHEMA_NEWEST_SINCE = [
|
||||
@@ -15,7 +16,8 @@ export const PLUGIN_SCHEMA_NEWEST_SINCE = [
|
||||
PLUGIN_DERIVED_PUBLISHER_SINCE,
|
||||
PLUGIN_PANEL_UI_SINCE,
|
||||
PLUGIN_COMPONENTS_CATALOG_2_SINCE,
|
||||
PLUGIN_EDITOR_FRAME_SINCE
|
||||
PLUGIN_EDITOR_FRAME_SINCE,
|
||||
PLUGIN_STATUS_BAR_SINCE
|
||||
].reduce((newest, version) => (satisfiesOrcaEngineRange(version, `>=${newest}`) ? version : newest))
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type PluginEventName
|
||||
} from '../contributions/plugin-event-contribution'
|
||||
import type { PluginFileMatch } from '../contributions/plugin-file-match'
|
||||
import { validatePluginStatusBarItems } from '../contributions/plugin-status-bar-item-contribution'
|
||||
|
||||
type IdentifiedContribution = { id: string }
|
||||
type PathContribution = { path: string }
|
||||
@@ -26,6 +27,7 @@ type ContributionValidationManifest = {
|
||||
customEditors: (IdentifiedContribution & PluginFileMatch)[]
|
||||
newFiles: IdentifiedContribution[]
|
||||
settings: { key: string }[]
|
||||
statusBarItems: { id: string; command?: string }[]
|
||||
}
|
||||
capabilities: { kind: string }[]
|
||||
}
|
||||
@@ -149,6 +151,7 @@ export function validatePluginManifestContributions(
|
||||
identities.forEach((identity) => keybindingIdentities.add(identity))
|
||||
}
|
||||
|
||||
validatePluginStatusBarItems(manifest.contributes, ctx)
|
||||
const commands = new Map(manifest.contributes.commands.map((command) => [command.id, command]))
|
||||
for (const [index, command] of manifest.contributes.commands.entries()) {
|
||||
if (command.action !== undefined && !isPluginCommandAliasActionId(command.action)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { PluginCatalogType } from './catalog/plugin-catalog-types'
|
||||
import type { PluginExecutionProfile } from './contributions/plugin-execution-profile'
|
||||
import type { PluginHostImages } from './images/plugin-image-url'
|
||||
import type { PluginStatusBarItemContribution } from './contributions/plugin-status-bar-item-contribution'
|
||||
|
||||
/** One installed plugin as main projects it for every client (preload IPC and the `plugins.list`
|
||||
* RPC). Optional fields are absent on older hosts, so paired clients must tolerate them. */
|
||||
@@ -87,6 +88,8 @@ export type PluginHostListEntry = {
|
||||
handler: { type: 'built-in'; action: string } | { type: 'worker' }
|
||||
keybindings: { key: string; when: 'global' | 'workspace' | 'worktree' }[]
|
||||
}[]
|
||||
/** The manifest's status bar items; a worker's changes arrive separately. Absent on older hosts. */
|
||||
statusBarItems?: PluginStatusBarItemContribution[]
|
||||
hasWorker: boolean
|
||||
vmRecipes?: {
|
||||
id: string
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { z } from 'zod'
|
||||
import { pluginIdSchema } from '../manifest/plugin-manifest-fields'
|
||||
import { pluginStatusBarItemPatchSchema } from '../contributions/plugin-status-bar-item-contribution'
|
||||
import { spec, WORKER_ONLY } from './plugin-host-method-spec'
|
||||
|
||||
const statusBarUpdateParams = z.strictObject({
|
||||
id: pluginIdSchema,
|
||||
...pluginStatusBarItemPatchSchema.shape
|
||||
})
|
||||
const statusBarUpdateResult = z.object({ ok: z.literal(true) })
|
||||
|
||||
/** The plugin's own status bar items; spread into PLUGIN_HOST_API. */
|
||||
export const PLUGIN_STATUS_BAR_API = {
|
||||
'statusBar.update': spec({
|
||||
summary:
|
||||
"Changes one of the plugin's `contributes.statusBarItems` (named by `id`): fields given replace their current value, `visible: false` hides it. Desktop app only; lasts until Orca restarts, and is hidden while the plugin is disabled.",
|
||||
since: 2,
|
||||
scope: 'plugin-private',
|
||||
capability: null,
|
||||
// Why not audited: it only redraws the plugin's own item, possibly many times a minute.
|
||||
mutation: false,
|
||||
surfaces: WORKER_ONLY,
|
||||
params: statusBarUpdateParams,
|
||||
result: statusBarUpdateResult
|
||||
})
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { z } from 'zod'
|
||||
import type { PluginSurface } from '../frames/plugin-protocol'
|
||||
import * as stored from './plugin-host-api-storage-schemas'
|
||||
import { PLUGIN_PANEL_BRIDGE_API } from './plugin-host-api-panel-methods'
|
||||
import { PLUGIN_STATUS_BAR_API } from './plugin-host-api-status-bar'
|
||||
import {
|
||||
ALL_SURFACES,
|
||||
FRAMES_ONLY,
|
||||
@@ -299,7 +300,8 @@ export const PLUGIN_HOST_API = {
|
||||
params: filesSaveAsParams,
|
||||
result: filesSaveAsResult
|
||||
}),
|
||||
...PLUGIN_PANEL_BRIDGE_API
|
||||
...PLUGIN_PANEL_BRIDGE_API,
|
||||
...PLUGIN_STATUS_BAR_API
|
||||
}
|
||||
|
||||
export type PluginHostApi = typeof PLUGIN_HOST_API
|
||||
|
||||
Reference in New Issue
Block a user