Skip to content

Go implementation of DeepSeek Harness and self-hosted personal agent.

Go

fix(plugins): show automatic installation progress

xyc0762c731333a
diff --git a/frontend/src/extensions/Plugins.tsx b/frontend/src/extensions/Plugins.tsx
index 5638911..b8618be 100644
--- a/frontend/src/extensions/Plugins.tsx
+++ b/frontend/src/extensions/Plugins.tsx
@@ -33,6 +33,7 @@ export function Plugins({ userId, cache, selected, onSelect }: { userId: string;
const release = view?.catalog.find(row => row.package === selected)
const info = view?.status.packages.find(row => row.name === selected)
const actual = view?.status.instances.find(row => row.package === selected)
+ const preparing = ['installing', 'loading'].includes(actual?.state ?? '')
const title = release ? release.name : info?.title || selected
const install = async (entry: CatalogEntry) => {
await run('install:' + entry.package, () => installPackage(userId, entry.pluginId), 'Plugin and dependencies installed. Enable it to use its capabilities.')
@@ -44,7 +45,7 @@ export function Plugins({ userId, cache, selected, onSelect }: { userId: string;
}
}
const more = (name: string, entry?: CatalogEntry) => <div className="plugin-more" ref={menu === name ? menuRef : undefined}>
- <button type="button" className="plugin-icon-button" aria-label={t('More options')} aria-haspopup="menu" aria-expanded={menu === name} disabled={!!busy} onClick={event => { menuTrigger.current = event.currentTarget; setMenu(menu === name ? undefined : name) }}><MoreHorizontal size={20} /></button>
+ <button type="button" className="plugin-icon-button" aria-label={t('More options')} aria-haspopup="menu" aria-expanded={menu === name} disabled={!!busy || view?.status.instances.some(row => row.package === name && ['installing', 'loading'].includes(row.state))} onClick={event => { menuTrigger.current = event.currentTarget; setMenu(menu === name ? undefined : name) }}><MoreHorizontal size={20} /></button>
{menu === name && <div className="plugin-action-menu" role="menu">
{!selected && <button role="menuitem" onClick={() => open(name)}><ChevronRight size={16} />{t('Plugin details')}</button>}
{view?.status.packages.find(row => row.name === name)?.availableVersion && entry && <button role="menuitem" onClick={() => { setMenu(undefined); void run('install:' + name, () => updatePackage(userId, name, entry.pluginId)) }}><RefreshCw size={16} />{t('Update plugin')}</button>}
@@ -63,7 +64,7 @@ export function Plugins({ userId, cache, selected, onSelect }: { userId: string;
{info?.availableVersion && release && <div className="plugin-update-banner"><div><strong>{t('Update available')}</strong><small>{info.version} → {info.availableVersion}</small></div><button className="model-secondary" disabled={!!busy} onClick={() => { void run('install:' + selected, () => updatePackage(userId, selected!, release.pluginId)) }}>{t('Update plugin')}</button></div>}
{!selection && release ? <button className="account-submit plugin-primary" disabled={!!busy} onClick={() => { void install(release) }}>{selectedBusy ? <LoaderCircle size={16} /> : <Plus size={16} />}{t('Install plugin')}</button> : selection && <div className="plugin-activation">
<div><strong>{t('Enable plugin')}</strong>{!selectedBusy && <ExtensionState state={actual?.state ?? (selection.enabled ? 'unavailable' : 'disabled')} />}</div>
- <button type="button" className="plugin-switch" role="switch" aria-label={t('Enable plugin')} aria-checked={selection.enabled} disabled={!!busy} onClick={() => { void run('settings:' + selected, () => setPluginEnabled(userId, selected, !selection.enabled)) }}><span /></button>
+ <button type="button" className="plugin-switch" role="switch" aria-label={t('Enable plugin')} aria-checked={selection.enabled} disabled={!!busy || preparing} onClick={() => { void run('settings:' + selected, () => setPluginEnabled(userId, selected, !selection.enabled)) }}><span /></button>
</div>}
{!selectedBusy && (actual?.error || view?.status.error) && <p className="extension-diagnostic" role="alert">{actual?.error || view?.status.error}</p>}
{release && <>
@@ -83,8 +84,8 @@ export function Plugins({ userId, cache, selected, onSelect }: { userId: string;
const entry = view.catalog.find(row => row.package === name), saved = view.settings.packages[name], state = view.status.instances.find(row => row.package === name)
const label = entry ? entry.name : view.status.packages.find(row => row.name === name)?.title || name
return <article className="plugin-tile" key={name}>
- <button type="button" className="plugin-tile-main" onClick={() => open(name)}><PluginIcon icon={entry?.icon} /><span className="plugin-tile-copy"><strong>{label}</strong><small>{entry ? localize(entry.description, language).split('\n')[0] : name}</small>{view.status.packages.find(row => row.name === name)?.availableVersion && <span className="plugin-update-tag">{t('Update available')}</span>}{tab === 'installed' && <ExtensionState state={state?.state ?? (saved?.enabled ? 'unavailable' : 'disabled')} />}</span></button>
- {busy === 'install:' + name ? <span className="plugin-icon-button plugin-progress" role="status" aria-label={t('Installing…')}><LoaderCircle size={19} /></span> : saved ? more(name, entry) : <button type="button" className="plugin-icon-button" disabled={!!busy} aria-label={t('Install plugin') + ': ' + label} onClick={() => { if (entry) void install(entry) }}><Plus size={22} /></button>}
+ <button type="button" className="plugin-tile-main" onClick={() => open(name)}><PluginIcon icon={entry?.icon} /><span className="plugin-tile-copy"><strong>{label}</strong><small>{entry ? localize(entry.description, language).split('\n')[0] : name}</small>{view.status.packages.find(row => row.name === name)?.availableVersion && <span className="plugin-update-tag">{t('Update available')}</span>}{(tab === 'installed' || ['installing', 'installation-failed'].includes(state?.state ?? '')) && <ExtensionState state={state?.state ?? (saved?.enabled ? 'unavailable' : 'disabled')} />}</span></button>
+ {busy === 'install:' + name || state?.state === 'installing' ? <span className="plugin-icon-button plugin-progress" role="status" aria-label={t('Installing…')}><LoaderCircle size={19} /></span> : saved ? more(name, entry) : <button type="button" className="plugin-icon-button" disabled={!!busy} aria-label={t('Install plugin') + ': ' + label} onClick={() => { if (entry) void install(entry) }}><Plus size={22} /></button>}
</article>
})}</div>
{tab === 'installed' && <details className="plugin-runtime-details"><summary>{t('Plugin runtime')}</summary><div className="extension-runtime"><ExtensionState state={view.status.runtime} /><button className="extension-text" disabled={!!busy} onClick={() => { void run('restart', () => restartPlugins(userId)) }}>{t('Restart')}</button></div>{view.status.error && <p className="extension-diagnostic">{view.status.error}</p>}</details>}
diff --git a/frontend/src/extensions/extensions.css b/frontend/src/extensions/extensions.css
index 4b11342..f36dbce 100644
--- a/frontend/src/extensions/extensions.css
+++ b/frontend/src/extensions/extensions.css
@@ -42,6 +42,7 @@
.extension-runtime .extension-text { margin-left: auto; }
.extension-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 550; white-space: nowrap; }
.extension-state i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
+.extension-state-spinner { animation: extension-auth-spin 1.2s linear infinite; flex: none; }
.extension-state-good { color: var(--success, #51846d); }
.extension-state-bad { color: var(--danger); }
.extension-list { display: grid; border-top: 1px solid var(--line); }
diff --git a/frontend/src/extensions/messages.ts b/frontend/src/extensions/messages.ts
index d09f465..93dfae0 100644
--- a/frontend/src/extensions/messages.ts
+++ b/frontend/src/extensions/messages.ts
@@ -81,7 +81,7 @@ export const extensionChinese: Readonly<Record<string, string>> = {
'This directory must exist inside the Host. A path on your phone or computer is not a Host path.': '该目录必须存在于 Host 内。手机或电脑上的路径不等于 Host 内的路径。',
'Private source authentication': '私有来源认证', 'Registry URL (optional)': 'Registry 地址(可选)', 'Credential reference (optional)': '凭证引用名(可选)', 'Username (optional)': '用户名(可选)', 'Pinned source': '固定来源', 'Enable bundle after installation': '安装完成后启用组合',
'Install packages you trust. Plugins run code inside your Host.': '请安装可信任的插件包。插件会在 Host 内执行代码。',
- 'Check package': '检查插件包', 'Checking…': '检查中…', 'Applying plugin changes…': '正在应用插件变更…', 'Installing…': '安装中…', 'Confirm installation': '确认安装', 'Package checked. Review its details before installing.': '检查已完成,请核对插件包信息后安装。', 'Package installed. Review its instances below.': '插件包已安装,请查看下方实例状态。',
+ 'Check package': '检查插件包', 'Checking…': '检查中…', 'Applying plugin changes…': '正在应用插件变更…', 'Installing': '安装中', 'Installation failed': '安装失败', 'Installing…': '安装中…', 'Confirm installation': '确认安装', 'Package checked. Review its details before installing.': '检查已完成,请核对插件包信息后安装。', 'Package installed. Review its instances below.': '插件包已安装,请查看下方实例状态。',
'Instance configuration': '实例配置', 'Instance ID': '实例 ID', 'This instance ID is already in use.': '该实例 ID 已被使用。', 'Configuration override (JSON)': '配置覆盖项(JSON)',
'Only overrides are shown. Bundle defaults remain in the package. Use credential references for secrets.': '这里只显示覆盖项,组合默认值仍由插件包提供。私密值请使用凭证引用。',
'Save configuration': '保存配置', 'Could not save configuration.': '无法保存配置。', 'Enter a JSON object.': '请输入 JSON 对象。',
diff --git a/frontend/src/extensions/shared.tsx b/frontend/src/extensions/shared.tsx
index f4b45b6..2a183ca 100644
--- a/frontend/src/extensions/shared.tsx
+++ b/frontend/src/extensions/shared.tsx
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState, useSyncExternalStore, type ReactNode } from 'react'
-import { AlertCircle, RefreshCw } from 'lucide-react'
+import { AlertCircle, LoaderCircle, RefreshCw } from 'lucide-react'
import { APIError, settingsApplyFailed } from '../api/controller'
import { useLocale } from '../locale'
import type { TranscriptCache } from '../chat/transcriptCache'
@@ -7,11 +7,11 @@ import './extensions.css'
import { extensionOperations } from './operations'
import { useExtensionConfirm } from './Dialogs'
-const states: Record<string, string> = { installed: 'Installed', active: 'Active', running: 'Running', connected: 'Connected', ready: 'Ready', loading: 'Starting', connecting: 'Connecting', pending: 'Pending', failed: 'Failed', error: 'Failed', unavailable: 'Unavailable', stopped: 'Stopped', disabled: 'Disabled', stopping: 'Stopping', disconnected: 'Disconnected', 'waiting-credentials': 'Needs credentials', 'waiting-authorization': 'Authorization needed' }
+const states: Record<string, string> = { installed: 'Installed', active: 'Active', running: 'Running', connected: 'Connected', ready: 'Ready', installing: 'Installing', 'installation-failed': 'Installation failed', loading: 'Starting', connecting: 'Connecting', pending: 'Pending', failed: 'Failed', error: 'Failed', unavailable: 'Unavailable', stopped: 'Stopped', disabled: 'Disabled', stopping: 'Stopping', disconnected: 'Disconnected', 'waiting-credentials': 'Needs credentials', 'waiting-authorization': 'Authorization needed' }
export function ExtensionState({ state }: { state: string }) {
const { t } = useLocale()
- const tone = ['active', 'running', 'connected', 'ready'].includes(state) ? 'good' : ['failed', 'error'].includes(state) ? 'bad' : 'quiet'
- return <span className={'extension-state extension-state-' + tone}><i aria-hidden="true" />{t(states[state] ?? state)}</span>
+ const tone = ['active', 'running', 'connected', 'ready'].includes(state) ? 'good' : ['failed', 'error', 'installation-failed'].includes(state) ? 'bad' : 'quiet'
+ return <span className={'extension-state extension-state-' + tone}>{['installing', 'loading'].includes(state) ? <LoaderCircle size={12} className="extension-state-spinner" aria-hidden="true" /> : <i aria-hidden="true" />}{t(states[state] ?? state)}</span>
}
export function extensionFailure(error: unknown) {
diff --git a/internal/plugins/install_concurrency_test.go b/internal/plugins/install_concurrency_test.go
index 8d901c5..a69210f 100644
--- a/internal/plugins/install_concurrency_test.go
+++ b/internal/plugins/install_concurrency_test.go
@@ -77,6 +77,17 @@ process.stdout.write(JSON.stringify({result}));`
case <-tick.C:
}
}
+ status, err := m.Status(t.Context())
+ if err != nil {
+ t.Fatal(err)
+ }
+ states := map[string]string{}
+ for _, row := range status.Instances {
+ states[row.Package] = row.State
+ }
+ if states["extra"] != "installing" || states["fixture"] != "ready" {
+ t.Fatalf("wrong progress while sibling stays active: %+v", status.Instances)
+ }
tools, err := m.Tools(t.Context(), "session")
if err != nil || len(tools) != 1 || tools[0].Spec().Name != "fixture__echo" {
t.Fatalf("existing tools unavailable during download: %v %v", tools, err)
diff --git a/internal/plugins/manager.go b/internal/plugins/manager.go
index b671331..4a8f745 100644
--- a/internal/plugins/manager.go
+++ b/internal/plugins/manager.go
@@ -38,6 +38,8 @@ type Manager struct {
runtime *hostBridge
desired plugin.RuntimeSettings
lastError string
+ applying bool
+ preparation map[string]plugin.Instance
changes chan struct{}
surface *authorization.Surface
ownsCredentials bool
@@ -166,8 +168,20 @@ func (m *Manager) Apply(ctx context.Context, settings plugin.RuntimeSettings) (S
func (m *Manager) apply(ctx context.Context, s plugin.RuntimeSettings, restart bool, reinstall string) (status Status, err error) {
m.mu.Lock()
m.desired = s.Clone()
+ m.applying = true
+ m.lastError = ""
+ m.preparation = make(map[string]plugin.Instance)
m.mu.Unlock()
+ m.changed()
defer func() {
+ m.mu.Lock()
+ m.applying = false
+ for name, row := range m.preparation {
+ if row.State != "installation-failed" {
+ delete(m.preparation, name)
+ }
+ }
+ m.mu.Unlock()
m.report(err)
read, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
defer cancel()
@@ -204,6 +218,15 @@ func (m *Manager) apply(ctx context.Context, s plugin.RuntimeSettings, restart b
missing = append(missing, name)
}
}
+ // Defaults install sequentially. Publish the entire queue so a package
+ // waiting for its turn is not mistaken for an unavailable plugin.
+ m.mu.Lock()
+ for _, name := range missing {
+ m.preparation[name] = plugin.Instance{Package: name, State: "installing"}
+ }
+ m.mu.Unlock()
+ m.changed()
+
reloadRuntime := restart
var installErrors []error
failed := map[string]bool{}
@@ -226,6 +249,14 @@ func (m *Manager) apply(ctx context.Context, s plugin.RuntimeSettings, restart b
_, e = m.packages().Install(ctx, name, s.Packages[name].Source, values, s.Packages[name].Builds...)
return e
}()
+ row := plugin.Instance{Package: name, State: "loading"}
+ if installErr != nil {
+ row.State, row.Error = "installation-failed", m.redact(installErr.Error())
+ }
+ m.mu.Lock()
+ m.preparation[name] = row
+ m.mu.Unlock()
+ m.changed()
if installErr != nil {
failed[name] = true
installErrors = append(installErrors, fmt.Errorf("%s: %w", name, installErr))
@@ -319,8 +350,16 @@ func stringField(row map[string]any, key string) string { value, _ := row[key].(
func (m *Manager) Status(ctx context.Context) (Status, error) {
m.mu.RLock()
runtime, last, desired := m.runtime, m.lastError, m.desired.Clone()
+ applying := m.applying
+ preparation := make(map[string]plugin.Instance, len(m.preparation))
+ for name, row := range m.preparation {
+ preparation[name] = row
+ }
m.mu.RUnlock()
status := Status{Runtime: "stopped", Packages: []plugin.PackageInfo{}, Instances: []plugin.Instance{}, Error: last}
+ if runtime == nil && applying {
+ status.Runtime = "loading"
+ }
if runtime != nil {
status.Runtime = "running"
if !runtime.Alive() {
@@ -338,13 +377,36 @@ func (m *Manager) Status(ctx context.Context) (Status, error) {
}
}
}
- } else {
- for _, row := range desired.Instances {
- state := "disabled"
- if row.Enabled {
- state = "unavailable"
+ }
+ // Cordis has no instance row until a package has been installed and applied.
+ // Merge installation progress with its actual rows, including while sibling
+ // plugins remain active in the existing runtime.
+ for _, wanted := range desired.Instances {
+ index := -1
+ for i, row := range status.Instances {
+ if row.ID == wanted.ID {
+ index = i
+ break
+ }
+ }
+ row, preparing := preparation[wanted.Package]
+ if preparing && (row.State != "loading" || index < 0) {
+ row.ID = wanted.ID
+ } else if index < 0 {
+ row = plugin.Instance{ID: wanted.ID, Package: wanted.Package, State: "disabled"}
+ if wanted.Enabled {
+ row.State = "unavailable"
+ if applying {
+ row.State = "loading"
+ }
}
- status.Instances = append(status.Instances, plugin.Instance{ID: row.ID, Package: row.Package, State: state})
+ } else {
+ continue
+ }
+ if index < 0 {
+ status.Instances = append(status.Instances, row)
+ } else {
+ status.Instances[index] = row
}
}
installed, err := m.packages().List(ctx)
diff --git a/internal/plugins/prepare_partial_test.go b/internal/plugins/prepare_partial_test.go
index ca0949f..e96f634 100644
--- a/internal/plugins/prepare_partial_test.go
+++ b/internal/plugins/prepare_partial_test.go
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"testing"
+ "time"
)
func TestPreparationActivatesSuccessfulPackageAndSkipsItsReinstallation(t *testing.T) {
@@ -27,12 +28,15 @@ func TestPreparationActivatesSuccessfulPackageAndSkipsItsReinstallation(t *testi
}
state := filepath.Join(directory, "installed.json")
count := filepath.Join(directory, "installs")
+ started, release := filepath.Join(directory, "started"), filepath.Join(directory, "release")
_ = os.WriteFile(state, []byte("[]"), 0600)
- paths, _ := json.Marshal([]string{state, count})
+ paths, _ := json.Marshal([]string{state, count, started, release})
main := filepath.Join(directory, "packages.mjs")
- script := `import{readFile,writeFile,appendFile}from'node:fs/promises';const[state,count]=` + string(paths) + `;
+ script := `import{readFile,writeFile,appendFile,access}from'node:fs/promises';const[state,count,started,release]=` + string(paths) + `;
let text='';for await(const chunk of process.stdin)text+=chunk;const req=JSON.parse(text);let installed=JSON.parse(await readFile(state,'utf8'));let result=installed;
if(req.method==='install'){
+ await writeFile(started,'');
+ while(true){try{await access(release);break}catch{await new Promise(resolve=>setTimeout(resolve,10))}}
if(req.name==='bad'){process.stdout.write(JSON.stringify({error:{code:'INSTALL_FAILED',message:'intentional download failure'}}));process.exit(0)}
result={name:req.name,version:'0.1.0',api:'1',present:true,source:req.source};installed.push(result);await writeFile(state,JSON.stringify(installed));await appendFile(count,'installed\n')
}process.stdout.write(JSON.stringify({result}));`
@@ -47,10 +51,50 @@ if(req.method==='install'){
s := plugin.RuntimeSettings{Packages: map[string]plugin.RuntimePackage{
"fixture": {Source: plugin.Source{Type: "directory", Spec: root}}, "bad": {Source: plugin.Source{Type: "directory", Spec: root}},
}, Instances: []plugin.InstanceConfig{{ID: "fixture", Package: "fixture", Enabled: true}, {ID: "bad", Package: "bad", Enabled: true}}}
- for range 2 {
- if _, err := m.Apply(t.Context(), s); err == nil || !strings.Contains(err.Error(), "intentional download failure") {
+ for attempt := range 2 {
+ done := make(chan error, 1)
+ go func() { _, err := m.Apply(t.Context(), s); done <- err }()
+ if attempt == 0 {
+ deadline := time.Now().Add(5 * time.Second)
+ for {
+ if _, err := os.Stat(started); err == nil {
+ break
+ }
+ if time.Now().After(deadline) {
+ t.Fatal("default installation did not start")
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+ // Both defaults must show installing, including the queued sibling,
+ // before any Cordis instance exists. Status is the HTTP projection.
+ status, err := m.Status(t.Context())
+ if err != nil || len(status.Instances) != 2 {
+ t.Fatalf("missing initial progress: %+v %v", status, err)
+ }
+ for _, row := range status.Instances {
+ if row.State != "installing" || row.Error != "" {
+ t.Fatalf("default misreported before installation finished: %+v", row)
+ }
+ }
+ if err := os.WriteFile(release, nil, 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := <-done; err == nil || !strings.Contains(err.Error(), "intentional download failure") {
t.Fatalf("missing failure: %v", err)
}
+ status, err := m.Status(t.Context())
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, row := range status.Instances {
+ if row.Package == "bad" && (row.State != "installation-failed" || !strings.Contains(row.Error, "intentional download failure")) {
+ t.Fatalf("installation error not reported: %+v", row)
+ }
+ if row.Package == "fixture" && row.State != "ready" {
+ t.Fatalf("successful default not ready: %+v", row)
+ }
+ }
tools, err := m.Tools(t.Context(), "session")
if err != nil || len(tools) != 1 || tools[0].Spec().Name != "fixture__echo" {
t.Fatalf("successful package not usable: %v %v", tools, err)
diff --git a/mobile/src/extensions/Plugins.tsx b/mobile/src/extensions/Plugins.tsx
index eead3fc..b35a5ff 100644
--- a/mobile/src/extensions/Plugins.tsx
+++ b/mobile/src/extensions/Plugins.tsx
@@ -19,6 +19,7 @@ export function Plugins(props: ScreenProps) {
const busyName = m.view?.catalog.find(row => m.busy.endsWith(':' + row.package))?.name
const view = m.view, info = view?.status.packages.find(pkg => pkg.name === selected), saved = selected ? view?.settings.packages[selected] : undefined
const entry = view?.catalog.find(item => item.package === selected), actual = view?.status.instances.find(row => row.package === selected)
+ const preparing = ['installing', 'loading'].includes(actual?.state ?? '')
const connections = usePluginAuthorizations(props, actual?.state === 'ready' && saved?.enabled ? [actual.id] : [])
const names = Object.keys(view?.settings.packages ?? {}).sort(), title = entry ? entry.name : info?.title || selected || ''
const install = async (name: string) => {
@@ -29,14 +30,14 @@ export function Plugins(props: ScreenProps) {
<SheetScroll key={authorization ? 'authorization' : selected ?? tab}>
{authorization ? <Authorizations connections={connections} onBusyChange={props.onBusyChange} onBack={() => setAuthorization(false)} />
: selected && view ? <>
- <Toolbar title="Plugin details" onBack={() => { setSelected(undefined); setTab('market') }}>{saved && <IconButton label={t('More options')} disabled={!!m.busy} onPress={() => setMenu(selected)}><MoreHorizontal size={20} color={muted} /></IconButton>}</Toolbar>
+ <Toolbar title="Plugin details" onBack={() => { setSelected(undefined); setTab('market') }}>{saved && <IconButton label={t('More options')} disabled={!!m.busy || ['installing', 'loading'].includes(actual?.state ?? '')} onPress={() => setMenu(selected)}><MoreHorizontal size={20} color={muted} /></IconButton>}</Toolbar>
<View style={market.detailHead}><PluginIcon api={api} icon={entry?.icon} large /><View style={{flex:1,gap:8}}><Text style={market.detailTitle}>{title}</Text><Text style={s.hint}>{entry ? localize(entry.description, language).split('\n')[0] : info?.description}</Text></View></View>
{entry && localize(entry.description,language).includes('\n') && <Panel style={{paddingVertical:16}}><Fold label="Connection setup"><Markdown style={{body:{fontSize:14,lineHeight:23,color:muted},link:{color:accent},paragraph:{marginTop:10,marginBottom:6}}} onLinkPress={url=>{if(/^https?:\/\//i.test(url))void Linking.openURL(url).catch(()=>{});return false}}>{localize(entry.description,language).split('\n').slice(1).join('\n').trim()}</Markdown></Fold></Panel>}
{entry && <PluginTutorial api={api} tutorials={entry.tutorials} />}
<Feedback error={m.error} notice={m.notice} />
{m.busy && <View style={s.row}><ActivityIndicator size="small" color={accent} /><Text style={s.meta}>{busyName ? busyName + ' · ' : ''}{t(m.busy.startsWith('install:') ? 'Installing…' : 'Applying plugin changes…')}</Text></View>}
{info?.availableVersion && entry && <Panel><View style={s.row}><View style={{flex:1,gap:6}}><Text style={s.caption}>{t('Update available')}</Text><Text style={s.meta}>{info.version} → {info.availableVersion}</Text></View><Button label={t('Update plugin')} busy={!!m.busy} onPress={() => { void m.run('install:' + selected, () => updatePackage(api, selected, entry.pluginId)) }} /></View></Panel>}
- {!saved ? <Button primary busy={selectedBusy} disabled={!!m.busy} label={t('Install plugin')} onPress={() => { void install(selected) }}><Plus size={18} color="#fff" /></Button> : <Panel style={{paddingVertical:20}}><View style={[s.row,{justifyContent:'space-between'}]}><Text style={s.meta}>{t('Plugin status')}</Text>{!selectedBusy && <State value={actual?.state ?? (saved.enabled ? 'unavailable' : 'disabled')} />}</View><Toggle label="Enable plugin" checked={saved.enabled} disabled={!!m.busy} onChange={enabled => { void m.run('settings:' + selected, () => setPluginEnabled(api, selected, enabled)) }} />{!selectedBusy && <Hint error>{actual?.error || view.status.error}</Hint>}</Panel>}
+ {!saved ? <Button primary busy={selectedBusy} disabled={!!m.busy} label={t('Install plugin')} onPress={() => { void install(selected) }}><Plus size={18} color="#fff" /></Button> : <Panel style={{paddingVertical:20}}><View style={[s.row,{justifyContent:'space-between'}]}><Text style={s.meta}>{t('Plugin status')}</Text>{!selectedBusy && <State value={actual?.state ?? (saved.enabled ? 'unavailable' : 'disabled')} />}</View><Toggle label="Enable plugin" checked={saved.enabled} disabled={!!m.busy || preparing} onChange={enabled => { void m.run('settings:' + selected, () => setPluginEnabled(api, selected, enabled)) }} />{!selectedBusy && <Hint error>{actual?.error || view.status.error}</Hint>}</Panel>}
{entry && <>
<View style={{gap:15,paddingVertical:8}}><Fact label="Version" value={info?.present ? info.version : entry.version} /><Fact label="Maintainer" value={entry.maintainer} /><Fact label="License" value={entry.license} /></View>
@@ -55,8 +56,8 @@ export function Plugins(props: ScreenProps) {
const release = view.catalog.find(row => row.package === name), saved = view.settings.packages[name], state = view.status.instances.find(row => row.package === name)
const label = release ? release.name : view.status.packages.find(pkg => pkg.name === name)?.title || name
return <View key={name} style={market.tile}>
- <Pressable accessibilityRole="button" accessibilityLabel={label} onPress={() => setSelected(name)} style={({pressed}) => [market.tileMain,pressed && s.pressed]}><PluginIcon api={api} icon={release?.icon} /><View style={{flex:1,gap:7}}><Text style={market.title}>{label}</Text><Text numberOfLines={2} style={market.summary}>{release ? localize(release.description,language).split('\n')[0] : name}</Text>{view.status.packages.find(row => row.name === name)?.availableVersion && <Text style={market.update}>{t('Update available')}</Text>}{tab === 'installed' && <State value={state?.state ?? (saved?.enabled ? 'unavailable' : 'disabled')} />}</View></Pressable>
- {m.busy === 'install:' + name ? <ActivityIndicator style={{width:44}} color={accent} /> : <IconButton label={t(saved ? 'More options' : 'Install plugin') + ': ' + label} disabled={!!m.busy} onPress={() => { if (saved) setMenu(name); else void install(name) }}>{saved ? <MoreHorizontal size={20} color={muted} /> : <Plus size={22} color={muted} />}</IconButton>}
+ <Pressable accessibilityRole="button" accessibilityLabel={label} onPress={() => setSelected(name)} style={({pressed}) => [market.tileMain,pressed && s.pressed]}><PluginIcon api={api} icon={release?.icon} /><View style={{flex:1,gap:7}}><Text style={market.title}>{label}</Text><Text numberOfLines={2} style={market.summary}>{release ? localize(release.description,language).split('\n')[0] : name}</Text>{view.status.packages.find(row => row.name === name)?.availableVersion && <Text style={market.update}>{t('Update available')}</Text>}{(tab === 'installed' || ['installing', 'installation-failed'].includes(state?.state ?? '')) && <State value={state?.state ?? (saved?.enabled ? 'unavailable' : 'disabled')} />}</View></Pressable>
+ {m.busy === 'install:' + name || state?.state === 'installing' ? <ActivityIndicator style={{width:44}} color={accent} /> : <IconButton label={t(saved ? 'More options' : 'Install plugin') + ': ' + label} disabled={!!m.busy || state?.state === 'loading'} onPress={() => { if (saved) setMenu(name); else void install(name) }}>{saved ? <MoreHorizontal size={20} color={muted} /> : <Plus size={22} color={muted} />}</IconButton>}
</View>
})}</View>
{tab === 'installed' && <Fold label="Plugin runtime"><View style={s.row}><State value={view.status.runtime} /><TextAction label="Restart" disabled={!!m.busy} onPress={() => { void m.run('restart',() => restartPlugins(api)) }} /></View><Hint error>{view.status.error}</Hint></Fold>}
diff --git a/mobile/src/extensions/shared.tsx b/mobile/src/extensions/shared.tsx
index ab2d19a..a9be151 100644
--- a/mobile/src/extensions/shared.tsx
+++ b/mobile/src/extensions/shared.tsx
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState, useSyncExternalStore, type ReactNode } from 'react'
-import { AppState, Alert, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
+import { ActivityIndicator, AppState, Alert, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
import { ArrowLeft, ChevronDown, RefreshCw } from 'lucide-react-native'
import { extensionOperations } from '../../../frontend/src/extensions/operations'
import type { TranscriptCache } from '../../../frontend/src/chat/transcriptCache'
@@ -31,11 +31,11 @@ export function useManagement<T>({ api, cache }: ScreenProps, load: (api: Contro
}
export type Runner = ReturnType<typeof useManagement>['run']
-const stateLabels: Record<string, string> = { installed: 'Installed', active: 'Active', running: 'Running', connected: 'Connected', ready: 'Ready', loading: 'Starting', applying: 'Starting', connecting: 'Connecting', pending: 'Pending', failed: 'Failed', unavailable: 'Unavailable', stopped: 'Stopped', disabled: 'Disabled', stopping: 'Stopping', 'waiting-credentials': 'Needs credentials', 'waiting-authorization': 'Authorization needed' }
+const stateLabels: Record<string, string> = { installed: 'Installed', active: 'Active', running: 'Running', connected: 'Connected', ready: 'Ready', installing: 'Installing', 'installation-failed': 'Installation failed', loading: 'Starting', applying: 'Starting', connecting: 'Connecting', pending: 'Pending', failed: 'Failed', unavailable: 'Unavailable', stopped: 'Stopped', disabled: 'Disabled', stopping: 'Stopping', 'waiting-credentials': 'Needs credentials', 'waiting-authorization': 'Authorization needed' }
export function State({ value }: { value: string }) {
const { t } = useLocale()
- const color = ['active', 'connected', 'running', 'ready'].includes(value) ? '#3d7967' : value === 'failed' ? danger : muted
- return <View style={x.state}><View style={[x.dot, { backgroundColor: color }]} /><Text style={[x.stateLabel, { color }]}>{t(stateLabels[value] ?? value)}</Text></View>
+ const color = ['active', 'connected', 'running', 'ready'].includes(value) ? '#3d7967' : ['failed', 'installation-failed'].includes(value) ? danger : muted
+ return <View style={x.state}>{['installing', 'loading'].includes(value) ? <ActivityIndicator size={12} color={color} /> : <View style={[x.dot, { backgroundColor: color }]} />}<Text style={[x.stateLabel, { color }]}>{t(stateLabels[value] ?? value)}</Text></View>
}
export function Toolbar({ title, busy, onBack, onRefresh, children }: { title: string; busy?: boolean; onBack?: () => void; onRefresh?: () => void; children?: ReactNode }) {
const { t } = useLocale()