The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): Kanban attachment download through the one gated resolver
brooklyn!efafed5baf16
diff --git a/apps/desktop/src/api/file-download.ts b/apps/desktop/src/api/file-download.tsdeleted file mode 100644index 299f61f7c0c..00000000000--- a/apps/desktop/src/api/file-download.ts+++ /dev/null@@ -1,29 +0,0 @@-import { capabilityScoped } from './client'--/** Capture alongside a REST read, never at click time: cached resources belong- * to the connection/profile that returned them, not the currently focused chat.- * Paths stay on the gateway; only Electron's authenticated save bridge sees them.- * An absent connection id preserves legacy profile-pool routing; an explicit- * `local` id must not be dropped (the registry primary may be remote).- */-export function captureGatewayFileDownload() {- const scope = capabilityScoped()-- return async (path: string, suggestedName: string) => {- if (!path?.trim()) {- throw new Error('Missing gateway file path')- }-- if (!window.hermesDesktop?.saveGatewayFile) {- throw new Error('Desktop file download bridge is unavailable')- }-- const result = await window.hermesDesktop.saveGatewayFile({ ...scope, path, suggestedName })-- if (!result.saved && !result.canceled) {- throw new Error('File download failed')- }-- return result- }-}diff --git a/apps/desktop/src/api/file-download.test.ts b/apps/desktop/src/lib/media-file-download.test.tssimilarity index 50%rename from apps/desktop/src/api/file-download.test.tsrename to apps/desktop/src/lib/media-file-download.test.tsindex f455b0299cc..6e445e466e3 100644--- a/apps/desktop/src/api/file-download.test.ts+++ b/apps/desktop/src/lib/media-file-download.test.ts@@ -1,32 +1,59 @@-import { afterEach, describe, expect, it, vi } from 'vitest'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { setApiRequestConnection, setApiRequestProfile } from './client'-import { captureGatewayFileDownload } from './file-download'+import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'+import { $notifications, clearNotifications } from '@/store/notifications'+import { $connection } from '@/store/session'++import { captureGatewayFileDownload } from './media'++beforeEach(() => {+ clearNotifications()+ // The window's focused connection must never leak into a captured owner.+ $connection.set({ connectionId: 'focused-host', mode: 'remote', profile: 'focused' } as never)+})afterEach(() => {setApiRequestConnection(null)setApiRequestProfile(null)+ $connection.set(null)+ clearNotifications()vi.unstubAllGlobals()})+const lastToast = () => $notifications.get()[0]+describe('captured gateway file download', () => {it('reports an unavailable desktop bridge', async () => {vi.stubGlobal('hermesDesktop', {})- await expect(captureGatewayFileDownload()('/persisted/file.md', 'file.md')).rejects.toThrow(- 'Desktop file download bridge is unavailable'- )++ await expect(captureGatewayFileDownload()('/persisted/file.md', 'file.md')).resolves.toBeUndefined()++ expect(lastToast()).toMatchObject({ kind: 'error', title: 'Download failed' })+ expect(lastToast()?.message).toContain('Desktop file download bridge is unavailable')})it('rejects an absent stored path before invoking the bridge', async () => {const saveGatewayFile = vi.fn()vi.stubGlobal('hermesDesktop', { saveGatewayFile })- await expect(captureGatewayFileDownload()(' ', 'file.md')).rejects.toThrow('Missing gateway file path')++ await captureGatewayFileDownload()(' ', 'file.md')+expect(saveGatewayFile).not.toHaveBeenCalled()+ expect(lastToast()?.message).toContain('Missing gateway file path')})- it('rejects an unsuccessful non-canceled save', async () => {- vi.stubGlobal('hermesDesktop', { saveGatewayFile: vi.fn().mockResolvedValue({ saved: false }) })- await expect(captureGatewayFileDownload()('/persisted/file.md', 'file.md')).rejects.toThrow('File download failed')+ it('confirms a completed save and stays quiet on cancel', async () => {+ const saveGatewayFile = vi.fn().mockResolvedValueOnce({ path: '/Users/me/Downloads/file.md', saved: true })+ vi.stubGlobal('hermesDesktop', { saveGatewayFile })+ const download = captureGatewayFileDownload()++ await download('/persisted/file.md', 'file.md')+ expect(lastToast()).toMatchObject({ kind: 'info', message: 'Saved' })++ clearNotifications()+ saveGatewayFile.mockResolvedValueOnce({ canceled: true, saved: false })+ await download('/persisted/file.md', 'file.md')+ expect($notifications.get()).toEqual([])})it('preserves legacy primary routing instead of inventing a default profile', async () => {@@ -35,7 +62,9 @@ describe('captured gateway file download', () => {const download = captureGatewayFileDownload()setApiRequestConnection('remote')setApiRequestProfile('work')+await download('/persisted/file.md', 'file.md')+expect(saveGatewayFile).toHaveBeenCalledWith({ path: '/persisted/file.md', suggestedName: 'file.md' })})@@ -47,7 +76,9 @@ describe('captured gateway file download', () => {const download = captureGatewayFileDownload()setApiRequestConnection('remote')setApiRequestProfile('work')- await expect(download('/persisted/file.md', 'file.md')).resolves.toEqual({ canceled: true, saved: false })++ await download('/persisted/file.md', 'file.md')+expect(saveGatewayFile).toHaveBeenCalledWith({connectionId: 'local',profile: 'personal',diff --git a/apps/desktop/src/lib/media.ts b/apps/desktop/src/lib/media.tsindex 93804c0b95f..8fd0f6d3800 100644--- a/apps/desktop/src/lib/media.ts+++ b/apps/desktop/src/lib/media.ts@@ -1,10 +1,12 @@import { LOCAL_CONNECTION_ID } from '@hermes/shared'-import { hermesApi, type OwnerScope } from '@/api/client'+import { capabilityScoped, hermesApi, type OwnerScope } from '@/api/client'import type { HermesConnection } from '@/global'+import { translateNow } from '@/i18n'import { desktopFsCacheKey, readDesktopFileDataUrl } from '@/lib/desktop-fs'import { LruCache } from '@/lib/lru-cache'import { capitalize } from '@/lib/text'+import { notify, notifyError } from '@/store/notifications'import { $connection } from '@/store/session'export type MediaKind = 'audio' | 'image' | 'video' | 'file'@@ -302,38 +304,88 @@ export async function gatewayMediaDataUrl(path: string): Promise<string> {return readDesktopFileDataUrl(filePathFromMediaPath(path))}-// Remote-mode replacement for opening gateway-local file paths with file://.-// The file lives on the gateway, so ask the Electron main process to fetch the-// bytes through the authenticated backend connection and save them locally. This-// avoids browser/OS downloads losing OAuth cookies and avoids the data-URL cap-// used by preview endpoints.+export interface GatewayFileSaveResult {+ canceled?: boolean+ path?: string+ saved: boolean+}++export interface GatewayFileOrigin {+ /** Backend that owns `path`, fixed when the path was read (see+ * `captureGatewayFileDownload`). It replaces the window's active connection+ * outright: an absent `connectionId` keeps legacy profile-pool routing, and+ * an explicit `local` stays pinned when the registry primary is remote. */+ owner?: OwnerScope+ /** Profile of the session that produced the file (artifacts). */+ profile?: string+ sessionId?: string+ suggestedName?: string+}++// Replacement for opening gateway-local file paths with file://. The file lives+// on the gateway, so ask the Electron main process to fetch the bytes through+// the authenticated backend connection and save them locally. This avoids+// browser/OS downloads losing OAuth cookies and avoids the data-URL cap used by+// preview endpoints. Every renderer gateway-file save resolves its backend here.export async function downloadGatewayMediaFile(path: string,- origin?: { sessionId: string; profile?: string }-): Promise<{ canceled?: boolean; path?: string; saved: boolean }> {+ origin: GatewayFileOrigin = {}+): Promise<GatewayFileSaveResult> {// URI conversion belongs to the gateway OS, not the renderer's URL parser.- const file = path- const conn = $connection.get()+ if (!path?.trim()) {+ throw new Error('Missing gateway file path')+ }if (!window.hermesDesktop?.saveGatewayFile) {throw new Error('Desktop file download bridge is unavailable')}+ const conn = $connection.get()+ const owner = origin.owner ?? { connectionId: conn?.connectionId, profile: origin.profile ?? conn?.profile }+return window.hermesDesktop.saveGatewayFile({- connectionId: conn?.connectionId,- path: file,- profile: origin?.profile ?? conn?.profile,- ...(origin ? { sessionId: origin.sessionId } : {}),- suggestedName: mediaName(file).replace(/(?:%[0-9a-f]{2})+/gi, encoded => {- try {- return decodeURIComponent(encoded)- } catch {- return encoded- }- })+ ...(owner.connectionId ? { connectionId: owner.connectionId } : {}),+ path,+ ...(owner.profile ? { profile: owner.profile } : {}),+ ...(origin.sessionId ? { sessionId: origin.sessionId } : {}),+ suggestedName:+ origin.suggestedName ||+ mediaName(path).replace(/(?:%[0-9a-f]{2})+/gi, encoded => {+ try {+ return decodeURIComponent(encoded)+ } catch {+ return encoded+ }+ })})}+/** A user-initiated gateway file save with the shared feedback: a brief+ * "Saved" toast, a "Download failed" toast carrying the reason, and silence+ * when the user cancels the save dialog. Never rejects. */+export async function downloadGatewayFileWithFeedback(path: string, origin?: GatewayFileOrigin): Promise<void> {+ try {+ const result = await downloadGatewayMediaFile(path, origin)++ if (result.saved) {+ notify({ durationMs: 1500, kind: 'info', message: translateNow('fileMenu.downloadSaved') })+ }+ } catch (error) {+ notifyError(error, translateNow('fileMenu.downloadFailed'))+ }+}++/** Capture a gateway file download alongside a REST read, never at click time:+ * a cached resource belongs to the connection/profile that returned it, not+ * to whichever backend is focused when the user clicks. The path stays on the+ * gateway; only Electron's authenticated save bridge sees it. */+export function captureGatewayFileDownload() {+ const { connectionId, profile } = capabilityScoped()++ return (path: string, suggestedName: string) =>+ downloadGatewayFileWithFeedback(path, { owner: { connectionId, profile }, suggestedName })+}+export function mediaDisplayLabel(path: string): string {const escaped = mediaName(path).replace(/[[\]\\]/g, '\\$&')const kind = mediaKind(path)diff --git a/apps/desktop/src/plugins/kanban/drawer.test.tsx b/apps/desktop/src/plugins/kanban/drawer.test.tsxindex 70854217229..526b0aabe40 100644--- a/apps/desktop/src/plugins/kanban/drawer.test.tsx+++ b/apps/desktop/src/plugins/kanban/drawer.test.tsx@@ -3,9 +3,15 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+// Test harness drives the host's request scope, as a connection switch does.+// eslint-disable-next-line no-restricted-imports+import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'// Test harness supplies the host's locale registration, as plugin loading does.// eslint-disable-next-line no-restricted-importsimport { registerPluginLocales } from '@/i18n/plugin-i18n'+// Test harness reads the host's toast stack.+// eslint-disable-next-line no-restricted-imports+import { $notifications, clearNotifications } from '@/store/notifications'import { bindApi, taskKey } from './api'import { TaskDrawer } from './drawer'@@ -67,12 +73,11 @@ beforeEach(() => {)})-afterEach(async () => {- const { setApiRequestConnection, setApiRequestProfile } = await import('@/api/client')+afterEach(() => {setApiRequestConnection(null)setApiRequestProfile(null)+ clearNotifications()vi.unstubAllGlobals()- vi.restoreAllMocks()cleanup()client.clear()disposeApi()@@ -90,7 +95,6 @@ function openDrawer() {describe('task attachment compatibility', () => {it('downloads the persisted attachment through its original remote owner', async () => {- const { setApiRequestConnection, setApiRequestProfile } = await import('@/api/client')const save = vi.fn().mockResolvedValue({ saved: true })vi.stubGlobal('hermesDesktop', { saveGatewayFile: save })setApiRequestConnection('remote-owner')@@ -112,8 +116,25 @@ describe('task attachment compatibility', () => {suggestedName: 'report.md'}))- setApiRequestConnection(null)- setApiRequestProfile(null)+ await waitFor(() => expect($notifications.get()[0]).toMatchObject({ kind: 'info', message: 'Saved' }))+ })++ it('keeps a local-backend attachment on this computer after switching to a remote', async () => {+ const save = vi.fn().mockResolvedValue({ saved: true })+ vi.stubGlobal('hermesDesktop', { saveGatewayFile: save })+ setApiRequestConnection('local')+ detail = { ...legacyDetail, attachments: [{ id: 7, filename: 'notes.txt', stored_path: '/home/me/.hermes/kanban/notes.txt' }] }+ openDrawer()+ const download = await screen.findByRole('button', { name: 'Download notes.txt' })+ setApiRequestConnection('remote-host')+ fireEvent.click(download)+ await waitFor(() =>+ expect(save).toHaveBeenCalledWith({+ connectionId: 'local',+ path: '/home/me/.hermes/kanban/notes.txt',+ suggestedName: 'notes.txt'+ })+ )})it('disables downloads with no persisted path instead of guessing a workspace path', async () => {@@ -124,25 +145,22 @@ describe('task attachment compatibility', () => {})it('reports a failed download and allows retry', async () => {- const { host } = await import('@hermes/plugin-sdk')- const notify = vi.spyOn(host, 'notify')const save = vi.fn().mockRejectedValue(new Error('File not found'))vi.stubGlobal('hermesDesktop', { saveGatewayFile: save })detail = { ...legacyDetail, attachments: [{ id: 1, filename: 'gone.md', stored_path: '/persisted/gone.md' }] }openDrawer()const button = await screen.findByRole('button', { name: 'Download gone.md' })fireEvent.click(button)- await waitFor(() => expect(notify).toHaveBeenCalledWith({ kind: 'error', message: 'File not found' }))+ await waitFor(() =>+ expect($notifications.get()[0]).toMatchObject({ kind: 'error', message: 'File not found', title: 'Download failed' })+ )await waitFor(() => expect((button as HTMLButtonElement).disabled).toBe(false))save.mockResolvedValueOnce({ saved: true })fireEvent.click(button)await waitFor(() => expect(save).toHaveBeenCalledTimes(2))- notify.mockRestore()})it('disables a pending download and treats save-dialog cancellation quietly', async () => {- const { host } = await import('@hermes/plugin-sdk')- const notify = vi.spyOn(host, 'notify')let finish!: (value: { saved: boolean; canceled: boolean }) => voidconst save = vi.fn(@@ -162,8 +180,7 @@ describe('task attachment compatibility', () => {expect(save).toHaveBeenCalledOnce()await act(async () => finish({ saved: false, canceled: true }))await waitFor(() => expect((button as HTMLButtonElement).disabled).toBe(false))- expect(notify).not.toHaveBeenCalled()- notify.mockRestore()+ expect($notifications.get()).toEqual([])})it.each([{}, { attachments: null }])(diff --git a/apps/desktop/src/plugins/kanban/drawer.tsx b/apps/desktop/src/plugins/kanban/drawer.tsxindex 966ff906bb6..d540fc3c67d 100644--- a/apps/desktop/src/plugins/kanban/drawer.tsx+++ b/apps/desktop/src/plugins/kanban/drawer.tsx@@ -469,42 +469,49 @@ function DescriptionSection({ body, onSave }: { body: null | string | undefined;// administrative note into that slot; hide those (Runs still shows them).const isAdminSummary = (summary: string) => /^status changed to \w+ \(dashboard\/direct\)$/.test(summary)+// The filename is the download action. The path is the backend's own+// stored_path, saved through the connection/profile that returned this detail;+// a row without one (older backend) stays inert rather than guessing a path.function AttachmentDownload({attachment,onDownload}: {attachment: KanbanAttachment- onDownload: (path: string, suggestedName: string) => Promise<unknown>+ onDownload: (path: string, suggestedName: string) => Promise<void>}) {const { t } = useI18n()+ const path = attachment.stored_path?.trim()const download = useMutation({- mutationFn: () => onDownload(attachment.stored_path!, attachment.filename),- onError: err => host.notify({ kind: 'error', message: errText(err) })+ mutationFn: () => onDownload(path!, attachment.filename)})+ // Long names truncate in the narrow sidebar; the tip reveals the full name.return (- <Button- aria-label={`${t.fileMenu.download} ${attachment.filename}`}- disabled={!attachment.stored_path?.trim() || download.isPending}- onClick={() => download.mutate()}- size="xs"- variant="ghost"- >- <Codicon name={download.isPending ? 'sync' : 'cloud-download'} size="0.75rem" spinning={download.isPending} />- {attachment.filename}- </Button>+ <Tip label={attachment.filename} placement="row">+ <Button+ aria-label={`${t.fileMenu.download} ${attachment.filename}`}+ className="max-w-full justify-start font-normal"+ disabled={!path || download.isPending}+ onClick={() => download.mutate()}+ size="inline"+ variant="text"+ >+ <Codicon name={download.isPending ? 'sync' : 'cloud-download'} size="0.75rem" spinning={download.isPending} />+ <span className="truncate">{attachment.filename}</span>+ </Button>+ </Tip>)}function AttachmentsSection({attachments,- onUpload,onDownload,+ onUpload,pending}: {- onDownload: (path: string, suggestedName: string) => Promise<unknown>attachments: KanbanAttachment[]+ onDownload: (path: string, suggestedName: string) => Promise<void>onUpload: (file: File) => voidpending: boolean}) {diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 2045809eb3c..445347c62f2 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -22,8 +22,6 @@ import { atom, computed, type ReadableAtom } from 'nanostores'import type { ReactNode } from 'react'import { capabilityScoped } from '@/api/client'--export { captureGatewayFileDownload } from '@/api/file-download'import { PRIMARY_SESSION_VIEW } from '@/app/chat/session-view'import { openSession, type OpenSessionIntent } from '@/app/open-session'import { syncWorkspaceRoute } from '@/app/routes'@@ -1868,6 +1866,8 @@ export { formatModifierToken } from '@/lib/keybinds/combo'* a renderer that stays open for days. Only for values that can be* regenerated — eviction costs a recompute or a refetch, never correctness. */export { LruCache } from '@/lib/lru-cache'+/** Capture a gateway file download alongside a REST read (see the SDK guide). */+export { captureGatewayFileDownload } from '@/lib/media'/** The app's deterministic identity color for a name (profiles, assignees,* authors), its translucent tag fill, and the curated picker swatches — so* plugin-rendered identities read the same hue as everywhere else. Thediff --git a/apps/desktop/src/store/file-actions.test.ts b/apps/desktop/src/store/file-actions.test.tsindex 808e05c3db9..62bfde01c3d 100644--- a/apps/desktop/src/store/file-actions.test.ts+++ b/apps/desktop/src/store/file-actions.test.ts@@ -2,14 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { $notifications, clearNotifications } from '@/store/notifications'-vi.mock('@/lib/media', () => ({- downloadGatewayMediaFile: vi.fn()-}))--const media = await import('@/lib/media')-const downloadGatewayMediaFile = vi.mocked(media.downloadGatewayMediaFile)--const { downloadRemoteFile, shouldOfferLocalReveal, shouldOfferRemoteFileDownload } = await import('./file-actions')+import { downloadRemoteFile, shouldOfferLocalReveal, shouldOfferRemoteFileDownload } from './file-actions'describe('shouldOfferRemoteFileDownload', () => {it('is only for files on a remote backend', () => {@@ -35,26 +28,30 @@ describe('shouldOfferLocalReveal', () => {})describe('downloadRemoteFile', () => {+ const saveGatewayFile = vi.fn()+beforeEach(() => {clearNotifications()- downloadGatewayMediaFile.mockReset()+ saveGatewayFile.mockReset()+ vi.stubGlobal('hermesDesktop', { saveGatewayFile })})afterEach(() => {clearNotifications()+ vi.unstubAllGlobals()})it('saves a remote gateway file through the native download bridge', async () => {- downloadGatewayMediaFile.mockResolvedValue({ path: '/Users/me/Downloads/notes.md', saved: true })+ saveGatewayFile.mockResolvedValue({ path: '/Users/me/Downloads/notes.md', saved: true })await downloadRemoteFile('/home/linux/project/notes.md')- expect(downloadGatewayMediaFile).toHaveBeenCalledWith('/home/linux/project/notes.md')+ expect(saveGatewayFile).toHaveBeenCalledWith(expect.objectContaining({ path: '/home/linux/project/notes.md' }))expect($notifications.get()[0]?.message).toBe('Saved')})it('stays quiet when the save dialog is canceled', async () => {- downloadGatewayMediaFile.mockResolvedValue({ canceled: true, saved: false })+ saveGatewayFile.mockResolvedValue({ canceled: true, saved: false })await downloadRemoteFile('/home/linux/project/notes.md')@@ -62,7 +59,7 @@ describe('downloadRemoteFile', () => {})it('toasts when the gateway download fails', async () => {- downloadGatewayMediaFile.mockRejectedValue(new Error('Desktop file download bridge is unavailable'))+ vi.stubGlobal('hermesDesktop', {})await downloadRemoteFile('/home/linux/project/notes.md')diff --git a/apps/desktop/src/store/file-actions.ts b/apps/desktop/src/store/file-actions.tsindex 8361dca6a69..7e0e49c9386 100644--- a/apps/desktop/src/store/file-actions.ts+++ b/apps/desktop/src/store/file-actions.ts@@ -9,7 +9,7 @@ import {revealDesktopPath,trashDesktopPath} from '@/lib/desktop-fs'-import { downloadGatewayMediaFile } from '@/lib/media'+import { downloadGatewayFileWithFeedback } from '@/lib/media'import { notify, notifyError } from '@/store/notifications'import { notifyWorkspaceChanged } from '@/store/workspace-events'@@ -94,18 +94,8 @@ export function shouldOfferRemoteFileDownload(isDirectory: boolean, remote = isDreturn remote && !isDirectory}-export async function downloadRemoteFile(path: string): Promise<void> {- try {- const result = await downloadGatewayMediaFile(path)-- if (result.canceled || !result.saved) {- return- }-- notify({ durationMs: 1500, kind: 'info', message: translateNow('fileMenu.downloadSaved') })- } catch (error) {- notifyError(error, translateNow('fileMenu.downloadFailed'))- }+export function downloadRemoteFile(path: string): Promise<void> {+ return downloadGatewayFileWithFeedback(path)}/** Strip a `relativeTo` prefix to produce a repo/cwd-relative path. */diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.mdindex e2c5506076f..5e13137691b 100644--- a/website/docs/developer-guide/desktop-plugin-sdk.md+++ b/website/docs/developer-guide/desktop-plugin-sdk.md@@ -47,13 +47,15 @@ plugin, and fail to resolve in a disk plugin). Capability comes in tiers:cron — everything the app itself calls.- **`captureGatewayFileDownload()`** — capture a gateway file-save actionimmediately before starting a REST read, and retain it alongside the returned- data. The action `(storedPath, suggestedName) => Promise<{ saved, canceled?, path? }>`- keeps that read's connection/profile scope even if the user switches hosts- before clicking. Invoke only on an explicit user download gesture, using the+ data. The action `(storedPath, suggestedName) => Promise<void>` keeps that+ read's connection/profile scope even if the user switches hosts before+ clicking. Invoke only on an explicit user download gesture, using thebackend's persisted file path, never a guessed workspace path. Electron handlesauthenticated streaming, the native save dialog, and older-gateway fallback;- plugins never receive credentials or open remote paths with `file://`.- Cancellation resolves quietly; missing bridge/path and failed saves reject.+ plugins never receive credentials or open remote paths with `file://`. The+ host shows the same "Saved" / "Download failed" toasts as the Files panel and+ stays quiet on cancel; the promise settles when the save does and never+ rejects.- **`ctx.rest` / `ctx.socket`** — your plugin's own backend namespace(`/api/plugins/<id>`) if you ship a `plugin_api.py`.- **`ui.*`** — the design language: the app's real components, theme variables,