an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(settings): integrations UI rework against Pam mockup (Ryan 18cc365)
Chaitanya Giri10d25b6ae640
diff --git a/src/renderer/src/components/IntegrationsRegistry.tsx b/src/renderer/src/components/IntegrationsRegistry.tsxindex 5d2b264f..46e28b3c 100644--- a/src/renderer/src/components/IntegrationsRegistry.tsx+++ b/src/renderer/src/components/IntegrationsRegistry.tsx@@ -4,157 +4,117 @@ import {integrationsClient,type IntegrationDraft,type IntegrationEntry,+ type IntegrationGlyph,type IntegrationStatus,type IntegrationTemplate,- type IntegrationWorker+ type IntegrationWorker,+ type TestResult} from '@/integrations/registryClient';-// Connected-services registry UI. Goal (per dispatch): CLEAN + EASY TO-// UNDERSTAND. You see your integrations at a glance, add/edit one in a small-// inline form, test the connection, and pick which workers may use it.+// Integrations configuration UI. Goal (per dispatch): CLEAN + EASY TO+// UNDERSTAND. Built against Pam's reference mockup+// (hive/docs/integrations-ui-mockup.html): a configured-integrations list, a+// two-step Add flow (pick a template -> configure & test), a write-only masked+// secret field, and per-row test-connection. The dispatch also requires showing+// which workers can use an integration, so a worker picker lives in the+// configure step (the mockup omits it; we adapt).//// All data flows through integrationsClient — this component never touches IPC// directly, so it is unaffected when that client is wired to Jim's registry.-const labelStyle: CSSProperties = {- fontFamily: 'var(--cth-font-display)',- fontSize: 8,- lineHeight: '12px',- color: 'var(--cth-ink-500)',- textTransform: 'uppercase'-};+type View = 'list' | 'gallery' | 'configure';+const dispLabel: CSSProperties = {+ fontFamily: 'var(--cth-font-display)', fontSize: 8, lineHeight: '12px',+ color: 'var(--cth-ink-500)', textTransform: 'uppercase'+};+const fieldLabel: CSSProperties = { ...dispLabel, color: 'var(--cth-ink-700)' };+const subText: CSSProperties = { fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' };+const hint: CSSProperties = { fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' };const inputStyle: CSSProperties = {- padding: '6px 8px',- background: 'var(--cth-paper-100)',- border: 'none',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',- fontSize: 13,- lineHeight: '18px',- color: 'var(--cth-ink-900)'+ width: '100%', padding: '6px 8px', background: 'var(--cth-paper-100)', border: 'none',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)', fontSize: 13, lineHeight: '18px', color: 'var(--cth-ink-900)'};const STATUS_META: Record<IntegrationStatus, { dot: string; color: string; text: string }> = {ok: { dot: '●', color: 'var(--cth-mint-700, #1f7a4d)', text: 'Connected' },- error: { dot: '●', color: '#6E1423', text: 'Error' },+ error: { dot: '▲', color: 'var(--cth-danger, #6E1423)', text: 'Auth failed' },untested: { dot: '○', color: 'var(--cth-ink-500)', text: 'Not tested' }};-/** Blank draft for the Add form, seeded to the first template. */-function blankDraft(templates: IntegrationTemplate[]): IntegrationDraft {- return {- label: '',- templateId: templates[0]?.id ?? '',- fields: {},- secret: '',- workers: []- };+function Glyph({ glyph, lg }: { glyph: IntegrationGlyph; lg?: boolean }) {+ const size = lg ? 48 : 40;+ return (+ <div style={{+ width: size, height: size, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',+ background: glyph.bg, color: '#fff', boxShadow: 'inset 0 0 0 2px var(--cth-ink-900)',+ fontFamily: 'var(--cth-font-display)', fontSize: lg ? 13 : 11+ }}>{glyph.mono}</div>+ );}-/** Draft for editing an existing entry — note: no secret is ever pulled back. */+function blankDraft(templateId: string): IntegrationDraft {+ return { label: '', templateId, fields: {}, secret: '', workers: [] };+}function draftFromEntry(entry: IntegrationEntry): IntegrationDraft {- return {- id: entry.id,- label: entry.label,- templateId: entry.templateId,- fields: { ...entry.fields },- secret: '', // write-only: starts empty, blank-on-save keeps the stored secret- workers: [...entry.workers]- };+ // Write-only: secret starts empty and is never pulled back.+ return { id: entry.id, label: entry.label, templateId: entry.templateId, fields: { ...entry.fields }, secret: '', workers: [...entry.workers] };}export function IntegrationsRegistry() {const [templates, setTemplates] = useState<IntegrationTemplate[]>([]);const [workers, setWorkers] = useState<IntegrationWorker[]>([]);const [entries, setEntries] = useState<IntegrationEntry[]>([]);++ const [view, setView] = useState<View>('list');+ const [picked, setPicked] = useState<string>(''); // selected template id in the galleryconst [draft, setDraft] = useState<IntegrationDraft | null>(null);- const [busy, setBusy] = useState(false);+ const [replacing, setReplacing] = useState(false); // edit: user chose to swap the saved secret+ const [showSecret, setShowSecret] = useState(false);+ const [draftTest, setDraftTest] = useState<TestResult | null>(null);+ const [testingDraft, setTestingDraft] = useState(false);const [testingId, setTestingId] = useState<string | null>(null);+ const [busy, setBusy] = useState(false);const [note, setNote] = useState('');- const flash = (msg: string) => {- setNote(msg);- setTimeout(() => setNote(''), 2200);- };-- const refresh = async () => {- setEntries(await integrationsClient.list());- };+ const flash = (msg: string) => { setNote(msg); setTimeout(() => setNote(''), 2400); };+ const refresh = async () => setEntries(await integrationsClient.list());+ const templateOf = (id: string) => templates.find((t) => t.id === id);useEffect(() => {let alive = true;(async () => {const [tpls, wkrs, list] = await Promise.all([- integrationsClient.listTemplates(),- integrationsClient.listWorkers(),- integrationsClient.list()+ integrationsClient.listTemplates(), integrationsClient.listWorkers(), integrationsClient.list()]);if (!alive) return;- setTemplates(tpls);- setWorkers(wkrs);- setEntries(list);+ setTemplates(tpls); setWorkers(wkrs); setEntries(list);})();return () => { alive = false; };}, []);- const templateOf = (id: string) => templates.find((t) => t.id === id);const editing = draft?.id != null;const editEntry = editing ? entries.find((e) => e.id === draft?.id) : undefined;const activeTemplate = draft ? templateOf(draft.templateId) : undefined;+ // Show the masked "saved" state only while editing an entry that has a secret+ // and the user hasn't chosen to replace it.+ const showSavedPill = !!(editing && editEntry?.hasSecret && !replacing);- const onSave = async () => {- if (!draft) return;- if (!draft.label.trim()) { flash('Give it a label first.'); return; }- if (!draft.templateId) { flash('Pick a kind first.'); return; }- setBusy(true);- try {- // Write-only secret: only send it when the user actually typed one.- const payload: IntegrationDraft = {- ...draft,- label: draft.label.trim(),- secret: draft.secret && draft.secret.length > 0 ? draft.secret : undefined- };- await integrationsClient.save(payload);- setDraft(null);- await refresh();- flash(editing ? 'Integration updated.' : 'Integration added.');- } catch {- flash('Could not save.');- } finally {- setBusy(false);- }+ const goList = () => {+ setView('list'); setDraft(null); setPicked(''); setReplacing(false);+ setShowSecret(false); setDraftTest(null);};-- const onRemove = async (entry: IntegrationEntry) => {- setBusy(true);- try {- await integrationsClient.remove(entry.id);- if (draft?.id === entry.id) setDraft(null);- await refresh();- flash(`Removed “${entry.label}”.`);- } catch {- flash('Could not remove.');- } finally {- setBusy(false);- }+ const startAdd = () => { setPicked(''); setView('gallery'); };+ const continueFromGallery = () => {+ if (!picked) return;+ setDraft(blankDraft(picked)); setReplacing(false); setShowSecret(false); setDraftTest(null); setView('configure');};-- const onTest = async (entry: IntegrationEntry) => {- setTestingId(entry.id);- try {- const res = await integrationsClient.test(entry.id);- await refresh();- flash(res.message);- } catch {- flash('Test failed to run.');- } finally {- setTestingId(null);- }+ const startEdit = (entry: IntegrationEntry) => {+ setDraft(draftFromEntry(entry)); setReplacing(false); setShowSecret(false); setDraftTest(null); setView('configure');};const setField = (key: string, value: string) =>setDraft((d) => (d ? { ...d, fields: { ...d.fields, [key]: value } } : d));-const toggleWorker = (id: string) =>setDraft((d) => {if (!d) return d;@@ -162,221 +122,250 @@ export function IntegrationsRegistry() {return { ...d, workers: has ? d.workers.filter((w) => w !== id) : [...d.workers, id] };});- return (- <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>- <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>- <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>- <div style={{ ...labelStyle, marginBottom: 2 }}>Connected services</div>- <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>- Add a service once, store its secret securely, and choose which workers may use it.- </span>- </div>- {!draft && (- <PixelButton- variant="primary"- size="sm"- onClick={() => setDraft(blankDraft(templates))}- disabled={busy || templates.length === 0}- >- + add integration- </PixelButton>- )}- </div>+ /** Secret to send: only when the user actually typed one (write-only). */+ const draftPayload = (d: IntegrationDraft): IntegrationDraft => ({+ ...d, label: d.label.trim(),+ secret: d.secret && d.secret.length > 0 ? d.secret : undefined+ });- {/* List of configured integrations */}- {entries.length === 0 && !draft && (- <div style={{- padding: '14px 12px', textAlign: 'center',- background: 'var(--cth-paper-100)',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',- fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)'- }}>- No integrations yet. Press “add integration” to connect your first service.- </div>- )}+ const onTestDraft = async () => {+ if (!draft) return;+ setTestingDraft(true); setDraftTest(null);+ try { setDraftTest(await integrationsClient.testDraft(draftPayload(draft))); }+ catch { setDraftTest({ ok: false, message: 'Test failed to run.' }); }+ finally { setTestingDraft(false); }+ };+ const onSave = async () => {+ if (!draft) return;+ if (!draft.label.trim()) { flash('Give it a label first.'); return; }+ setBusy(true);+ try {+ await integrationsClient.save(draftPayload(draft));+ await refresh();+ flash(editing ? 'Integration updated.' : 'Integration added.');+ goList();+ } catch { flash('Could not save.'); }+ finally { setBusy(false); }+ };+ const onRemove = async (entry: IntegrationEntry) => {+ setBusy(true);+ try { await integrationsClient.remove(entry.id); await refresh(); flash(`Removed “${entry.label}”.`); }+ catch { flash('Could not remove.'); }+ finally { setBusy(false); }+ };+ const onTestRow = async (entry: IntegrationEntry) => {+ setTestingId(entry.id);+ try { const r = await integrationsClient.test(entry.id); await refresh(); flash(r.message); }+ catch { flash('Test failed to run.'); }+ finally { setTestingId(null); }+ };- {entries.length > 0 && (- <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>- {entries.map((entry) => {- const tpl = templateOf(entry.templateId);- const st = STATUS_META[entry.status];- const assigned = workers.filter((w) => entry.workers.includes(w.id));+ // ───────────────────────── GALLERY ─────────────────────────+ if (view === 'gallery') {+ return (+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>+ <button type="button" onClick={goList} style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0, alignSelf: 'flex-start', fontSize: 12, color: 'var(--cth-ink-500)' }}>← Integrations</button>+ <div>+ <div style={{ ...dispLabel, marginBottom: 4 }}>Pick a template</div>+ <span style={subText}>Choose what you’re connecting. The template decides which fields and scopes are requested. Pick <b>Custom REST</b> for anything not listed.</span>+ </div>+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>+ {templates.map((t) => {+ const on = picked === t.id;return (- <div- key={entry.id}- style={{- display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px',- background: 'var(--cth-paper-100)',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'- }}- >- <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>- <div style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 }}>- <span style={{ fontSize: 13, lineHeight: '18px', color: 'var(--cth-ink-900)', fontWeight: 600 }}>- {entry.label}- <code style={{ marginLeft: 6, fontFamily: 'var(--cth-font-mono)', fontSize: 11, color: 'var(--cth-ink-500)', fontWeight: 400 }}>- {tpl?.label ?? entry.templateId}- </code>- </span>- <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>- {entry.hasSecret ? 'secret set' : 'no secret'}- {' · '}- <span style={{ color: st.color }}>{st.dot} {st.text}</span>- </span>- </div>- <div style={{ display: 'flex', gap: 6, flexShrink: 0 }}>- <PixelButton- variant="secondary" size="sm"- onClick={() => { void onTest(entry); }}- disabled={busy || testingId === entry.id}- >- {testingId === entry.id ? '…' : 'test'}- </PixelButton>- <PixelButton variant="ghost" size="sm" onClick={() => setDraft(draftFromEntry(entry))} disabled={busy}>- edit- </PixelButton>- <PixelButton variant="ghost" size="sm" onClick={() => { void onRemove(entry); }} disabled={busy}>- remove- </PixelButton>- </div>+ <button key={t.id} type="button" onClick={() => setPicked(t.id)} style={{+ display: 'flex', alignItems: 'center', gap: 10, padding: 10, textAlign: 'left', cursor: 'pointer', border: 'none',+ background: on ? 'var(--cth-lemon-light, #FFEC99)' : 'var(--cth-paper-100)',+ boxShadow: `inset 0 0 0 ${on ? 2 : 1}px ${on ? 'var(--cth-ink-900)' : 'var(--cth-ink-300)'}`+ }}>+ <Glyph glyph={t.glyph} />+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 }}>+ <span style={{ fontSize: 13, lineHeight: '17px', color: 'var(--cth-ink-900)', fontWeight: 600 }}>{t.label}</span>+ <span style={hint}>{t.description}</span></div>-- {/* Which workers can use it */}- <div style={{ display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' }}>- <span style={{ ...labelStyle }}>Workers</span>- {assigned.length === 0 ? (- <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>none assigned</span>- ) : (- assigned.map((w) => (- <span key={w.id} style={{- fontSize: 11, lineHeight: '16px', padding: '1px 6px',- background: 'var(--cth-cream-200)',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',- color: 'var(--cth-ink-900)'- }}>{w.label}</span>- ))- )}- </div>- </div>+ </button>);})}</div>- )}-- {/* Add / edit form */}- {draft && (- <div style={{- display: 'flex', flexDirection: 'column', gap: 10, padding: '12px',- background: 'var(--cth-paper-100)',- boxShadow: 'inset 0 0 0 2px var(--cth-ink-700)'- }}>- <div style={{ ...labelStyle, color: 'var(--cth-ink-700)' }}>- {editing ? 'Edit integration' : 'New integration'}- </div>+ <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end' }}>+ <PixelButton variant="secondary" size="sm" onClick={goList}>cancel</PixelButton>+ <PixelButton variant="primary" size="sm" onClick={continueFromGallery} disabled={!picked}>continue →</PixelButton>+ </div>+ </div>+ );+ }- <label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>- <span style={labelStyle}>Label</span>- <input- value={draft.label}- onChange={(e) => setDraft({ ...draft, label: e.target.value })}- placeholder="e.g. Prod GitHub"- style={inputStyle}- />- </label>+ // ───────────────────────── CONFIGURE ─────────────────────────+ if (view === 'configure' && draft && activeTemplate) {+ return (+ <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>+ <button type="button" onClick={editing ? goList : startAdd} style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0, alignSelf: 'flex-start', fontSize: 12, color: 'var(--cth-ink-500)' }}>+ {editing ? '← Integrations' : '← Templates'}+ </button>- <label style={{ display: 'flex', flexDirection: 'column', gap: 4, width: 280 }}>- <span style={labelStyle}>Kind</span>- <select- value={draft.templateId}- onChange={(e) => setDraft({ ...draft, templateId: e.target.value, fields: {} })}- disabled={editing /* kind is fixed once created */}- style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}- >- {templates.map((t) => (- <option key={t.id} value={t.id}>{t.label}</option>- ))}- </select>- {activeTemplate?.description && (- <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>- {activeTemplate.description}- </span>- )}- </label>+ <div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: 12, background: 'var(--cth-cream-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)' }}>+ <Glyph glyph={activeTemplate.glyph} lg />+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>+ <span style={{ fontSize: 14, lineHeight: '18px', fontWeight: 600, color: 'var(--cth-ink-900)' }}>{activeTemplate.label}</span>+ <span style={hint}>{activeTemplate.description} · needs a {activeTemplate.secretLabel.toLowerCase()}</span>+ </div>+ </div>- {/* Non-secret fields the chosen kind needs */}- {activeTemplate?.fields.map((f) => (- <label key={f.key} style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>- <span style={labelStyle}>{f.label}{f.optional ? ' (optional)' : ''}</span>- <input- value={draft.fields[f.key] ?? ''}- onChange={(e) => setField(f.key, e.target.value)}- placeholder={f.placeholder}- style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}- />- </label>- ))}+ {/* Label */}+ <label style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>+ <span style={fieldLabel}>Label</span>+ <input value={draft.label} onChange={(e) => setDraft({ ...draft, label: e.target.value })} placeholder={`e.g. ${activeTemplate.label} (prod)`} style={inputStyle} />+ <span style={hint}>A friendly name shown in your integrations list. You can have more than one {activeTemplate.label} connection.</span>+ </label>- {/* Secret — WRITE-ONLY. Never pre-filled, never echoed back. */}- <label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>- <span style={labelStyle}>{activeTemplate?.secretLabel ?? 'Secret'}</span>- <input- type="password"- value={draft.secret ?? ''}- onChange={(e) => setDraft({ ...draft, secret: e.target.value })}- placeholder={- editing && editEntry?.hasSecret- ? '•••••••• stored — leave blank to keep'- : `Paste your ${(activeTemplate?.secretLabel ?? 'secret').toLowerCase()}`- }- autoComplete="off"- style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}- />- <span style={{ fontSize: 11, lineHeight: '15px', color: 'var(--cth-ink-500)' }}>- Stored securely and never shown again.- {editing && editEntry?.hasSecret ? ' Leave blank to keep the current secret.' : ''}- </span>+ {/* Non-secret fields */}+ {activeTemplate.fields.map((f) => (+ <label key={f.key} style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>+ <span style={fieldLabel}>{f.label}{f.optional ? ' (optional)' : ''}</span>+ <input value={draft.fields[f.key] ?? ''} onChange={(e) => setField(f.key, e.target.value)} placeholder={f.placeholder} style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }} /></label>+ ))}- {/* Which workers can use it */}- <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>- <span style={labelStyle}>Workers that can use it</span>- <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>- {workers.length === 0 && (- <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>no workers available</span>- )}- {workers.map((w) => {- const on = draft.workers.includes(w.id);- return (- <button- key={w.id}- type="button"- onClick={() => toggleWorker(w.id)}- style={{- padding: '2px 8px', border: 'none', cursor: 'pointer',- fontSize: 11, lineHeight: '16px', color: 'var(--cth-ink-900)',- background: on ? 'var(--cth-lemon)' : 'var(--cth-cream-200)',- boxShadow: `inset 0 0 0 1px ${on ? 'var(--cth-ink-900)' : 'var(--cth-ink-300)'}`- }}- >- {on ? '✓ ' : ''}{w.label}- </button>- );- })}+ {/* Secret — WRITE-ONLY */}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>+ <span style={fieldLabel}>{activeTemplate.secretLabel}</span>+ {showSavedPill ? (+ <div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>+ <span style={{ fontFamily: 'var(--cth-font-mono)', fontSize: 13, color: 'var(--cth-ink-500)', background: 'var(--cth-paper-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)', padding: '6px 10px', letterSpacing: 2 }}>•••••••• saved</span>+ <PixelButton variant="secondary" size="sm" onClick={() => { setReplacing(true); setShowSecret(false); setDraft({ ...draft, secret: '' }); }}>Replace key</PixelButton></div>+ ) : (+ <>+ <div style={{ display: 'flex', gap: 6 }}>+ <input+ type={showSecret ? 'text' : 'password'}+ value={draft.secret ?? ''}+ onChange={(e) => setDraft({ ...draft, secret: e.target.value })}+ placeholder={`Paste your ${activeTemplate.secretLabel.toLowerCase()}`}+ autoComplete="off"+ style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}+ />+ <PixelButton variant="secondary" size="sm" onClick={() => setShowSecret((v) => !v)} disabled={!draft.secret}>+ {showSecret ? 'hide' : 'show'}+ </PixelButton>+ </div>+ <div style={{ display: 'flex', gap: 6, alignItems: 'flex-start', padding: '7px 9px', background: 'var(--cth-cream-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-100, var(--cth-ink-300))', ...hint }}>+ 🔒 <span><b style={{ color: 'var(--cth-ink-700)' }}>Write-only.</b> Stored encrypted in the main process and never displayed again after you save. To change it later, paste a new key — there’s no way to read the old one back.{editing && editEntry?.hasSecret ? ' Leave blank to keep the saved key.' : ''}</span>+ </div>+ </>+ )}+ </div>++ {/* Workers (dispatch requirement) */}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>+ <span style={fieldLabel}>Workers that can use it</span>+ <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>+ {workers.length === 0 && <span style={hint}>no workers available</span>}+ {workers.map((w) => {+ const on = draft.workers.includes(w.id);+ return (+ <button key={w.id} type="button" onClick={() => toggleWorker(w.id)} style={{+ padding: '2px 8px', border: 'none', cursor: 'pointer', fontSize: 11, lineHeight: '16px', color: 'var(--cth-ink-900)',+ background: on ? 'var(--cth-lemon)' : 'var(--cth-cream-200)',+ boxShadow: `inset 0 0 0 1px ${on ? 'var(--cth-ink-900)' : 'var(--cth-ink-300)'}`+ }}>{on ? '✓ ' : ''}{w.label}</button>+ );+ })}</div>+ <span style={hint}>Only the selected workers may use this integration. Leave empty to keep it unused for now.</span>+ </div>- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>- <PixelButton variant="primary" size="sm" onClick={() => { void onSave(); }} disabled={busy}>- {busy ? '…' : editing ? 'save changes' : 'add'}- </PixelButton>- <PixelButton variant="secondary" size="sm" onClick={() => setDraft(null)} disabled={busy}>- cancel+ {/* Test connection */}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>+ <span style={fieldLabel}>Test connection</span>+ <div style={{ display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' }}>+ <PixelButton variant="secondary" size="sm" onClick={() => { void onTestDraft(); }} disabled={testingDraft}>+ {testingDraft ? 'testing…' : 'Test connection'}</PixelButton>+ {draftTest && (+ <span style={{ fontSize: 13, lineHeight: '18px', color: draftTest.ok ? 'var(--cth-mint-700, #1f7a4d)' : 'var(--cth-danger, #6E1423)' }}>+ {draftTest.ok ? '✓ ' : '✕ '}{draftTest.message}+ </span>+ )}</div>+ <span style={hint}>Runs a live read-only call with the key above before you save. On failure it shows the API error inline.</span>+ </div>++ <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', alignItems: 'center' }}>+ {note && <span style={{ marginRight: 'auto', ...subText }}>{note}</span>}+ <PixelButton variant="secondary" size="sm" onClick={goList} disabled={busy}>cancel</PixelButton>+ <PixelButton variant="primary" size="sm" onClick={() => { void onSave(); }} disabled={busy}>+ {busy ? '…' : editing ? 'Save changes' : 'Save integration'}+ </PixelButton>+ </div>+ </div>+ );+ }++ // ───────────────────────── LIST (default) ─────────────────────────+ const connected = entries.filter((e) => e.status === 'ok').length;+ return (+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>+ <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16 }}>+ <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>+ <div style={dispLabel}>Integrations</div>+ <span style={{ ...subText, maxWidth: 440 }}>Connect outside tools so your agents can read and act on them. Secrets are stored in the main process, encrypted, and never shown again.</span>+ </div>+ {entries.length > 0 && (+ <PixelButton variant="primary" size="sm" onClick={startAdd} disabled={busy || templates.length === 0}>+ add integration</PixelButton>+ )}+ </div>++ {entries.length === 0 ? (+ <div style={{ padding: 24, textAlign: 'center', background: 'var(--cth-paper-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)' }}>+ <p style={{ margin: '0 0 12px', fontSize: 13, lineHeight: '18px', color: 'var(--cth-ink-500)' }}>+ No integrations yet. Connect Linear, Stripe, Notion, GitHub and more — or a custom REST API.+ </p>+ <PixelButton variant="primary" size="sm" onClick={startAdd} disabled={templates.length === 0}>+ add your first integration</PixelButton></div>+ ) : (+ <>+ <span style={hint}>{entries.length} integration{entries.length === 1 ? '' : 's'} · {connected} connected</span>+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>+ {entries.map((entry) => {+ const tpl = templateOf(entry.templateId);+ const st = STATUS_META[entry.status];+ const assigned = workers.filter((w) => entry.workers.includes(w.id));+ return (+ <div key={entry.id} style={{ display: 'flex', flexDirection: 'column', gap: 8, padding: 10, background: 'var(--cth-paper-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)' }}>+ <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>+ {tpl && <Glyph glyph={tpl.glyph} />}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 1, minWidth: 0 }}>+ <span style={{ fontSize: 13, lineHeight: '18px', color: 'var(--cth-ink-900)', fontWeight: 600 }}>{entry.label}</span>+ <span style={hint}>{tpl ? `${tpl.label} · ${tpl.description}` : entry.templateId}{entry.hasSecret ? '' : ' · no secret'}</span>+ </div>+ <span style={{ display: 'inline-flex', alignItems: 'center', gap: 5, fontSize: 12, color: st.color, whiteSpace: 'nowrap' }}>+ <span style={{ fontSize: 10 }}>{st.dot}</span> {st.text}+ </span>+ <div style={{ display: 'flex', gap: 6, flexShrink: 0 }}>+ <PixelButton variant="secondary" size="sm" onClick={() => { void onTestRow(entry); }} disabled={busy || testingId === entry.id}>+ {testingId === entry.id ? '…' : 'test'}+ </PixelButton>+ <PixelButton variant="ghost" size="sm" onClick={() => startEdit(entry)} disabled={busy}>edit</PixelButton>+ <PixelButton variant="ghost" size="sm" onClick={() => { void onRemove(entry); }} disabled={busy}>✕</PixelButton>+ </div>+ </div>+ <div style={{ display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' }}>+ <span style={dispLabel}>Workers</span>+ {assigned.length === 0 ? (+ <span style={hint}>none assigned</span>+ ) : assigned.map((w) => (+ <span key={w.id} style={{ fontSize: 11, lineHeight: '16px', padding: '1px 6px', background: 'var(--cth-cream-200)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)', color: 'var(--cth-ink-900)' }}>{w.label}</span>+ ))}+ </div>+ </div>+ );+ })}+ </div>+ </>)}- {note && <span style={{ fontSize: 12, color: 'var(--cth-ink-700)' }}>{note}</span>}+ {note && <span style={subText}>{note}</span>}</div>);}diff --git a/src/renderer/src/integrations/registryClient.ts b/src/renderer/src/integrations/registryClient.tsindex 5baa83b9..800d283c 100644--- a/src/renderer/src/integrations/registryClient.ts+++ b/src/renderer/src/integrations/registryClient.ts@@ -8,10 +8,22 @@// the types with the spec. The UI (IntegrationsRegistry.tsx) talks ONLY to this// module, never to IPC directly, so nothing downstream changes when we wire up.//+// The template set + glyphs mirror Pam's reference mockup+// (hive/docs/integrations-ui-mockup.html). The REAL catalog is Dwight's; these+// stand in until the registry serves templates.+//// SECURITY INVARIANT (must survive conformance): a secret value flows ONE WAY —-// from the form into save()/test() and onward to the broker. It is NEVER read-// back. `IntegrationEntry` carries `hasSecret: boolean` (presence only); there-// is no field that could carry the secret value back to the renderer.+// from the form into save()/testDraft() and onward to the broker. It is NEVER+// read back. `IntegrationEntry` carries `hasSecret: boolean` (presence only);+// there is no field that could carry the secret value back to the renderer.++/** A small brand monogram tile (stands in for a logo). */+export interface IntegrationGlyph {+ /** 1–2 char monogram, e.g. 'Li', 'Gh', '{}'. */+ mono: string;+ /** Background hex, e.g. '#5E6AD2'. */+ bg: string;+}/** A non-secret field a template asks the user to fill in. */export interface IntegrationFieldSpec {@@ -23,11 +35,13 @@ export interface IntegrationFieldSpec {/** A kind/template of integration (authored by Dwight; served by the registry). */export interface IntegrationTemplate {- /** Stable kind id, e.g. 'slack', 'github', 'generic-http'. */+ /** Stable kind id, e.g. 'linear', 'github', 'custom-rest'. */id: string;label: string;- description?: string;- /** Human label for the one secret this kind needs, e.g. 'Bot token'. */+ /** Short one-liner, e.g. 'Issues & projects'. */+ description: string;+ glyph: IntegrationGlyph;+ /** Human label for the one secret this kind needs, e.g. 'API secret key'. */secretLabel: string;/** Non-secret config fields. */fields: IntegrationFieldSpec[];@@ -85,41 +99,33 @@ export interface IntegrationsClient {/** Add (draft.id absent) or edit (draft.id present). Returns the saved entry (no secret). */save(draft: IntegrationDraft): Promise<IntegrationEntry>;remove(id: string): Promise<void>;+ /** Test a saved integration by id (used by the list rows). */test(id: string): Promise<TestResult>;+ /** Test the in-progress draft (with its typed secret) before saving — the configure step. */+ testDraft(draft: IntegrationDraft): Promise<TestResult>;}// ----------------------------------------------------------------------------// PROVISIONAL in-memory mock. Replaced wholesale when Jim's IPC lands:-// listTemplates() -> window.cth.integrationsTemplates()-// listWorkers() -> derive from the agent roster / window.cth.hiveRegistry()-// list() -> window.cth.integrationsList()-// save(draft) -> window.cth.integrationsSave(draft) (secret -> broker)-// remove(id) -> window.cth.integrationsRemove(id)-// test(id) -> window.cth.integrationsTest(id)+// PROVISIONAL template catalog — mirrors Pam's mockup gallery (11 templates).// ---------------------------------------------------------------------------+const CUSTOM_REST_FIELDS: IntegrationFieldSpec[] = [+ { key: 'baseUrl', label: 'Base URL', placeholder: 'https://api.example.com' },+ { key: 'authHeader', label: 'Auth header', placeholder: 'Authorization: Bearer …', optional: true }+];+const MOCK_TEMPLATES: IntegrationTemplate[] = [- {- id: 'generic-http',- label: 'HTTP API',- description: 'A generic bearer-token HTTP endpoint.',- secretLabel: 'API token',- fields: [{ key: 'baseUrl', label: 'Base URL', placeholder: 'https://api.example.com' }]- },- {- id: 'github',- label: 'GitHub',- description: 'Read/write GitHub via a personal access token.',- secretLabel: 'Personal access token',- fields: [{ key: 'org', label: 'Org / owner', placeholder: 'acme', optional: true }]- },- {- id: 'slack',- label: 'Slack',- description: 'Post and read messages with a bot token.',- secretLabel: 'Bot token',- fields: [{ key: 'defaultChannel', label: 'Default channel id', placeholder: 'C0123…', optional: true }]- }+ { id: 'linear', label: 'Linear', description: 'Issues & projects', glyph: { mono: 'Li', bg: '#5E6AD2' }, secretLabel: 'API key', fields: [] },+ { id: 'jira', label: 'Jira', description: 'Tickets & boards', glyph: { mono: 'Ji', bg: '#2684FF' }, secretLabel: 'API token', fields: [{ key: 'site', label: 'Site URL', placeholder: 'https://acme.atlassian.net' }, { key: 'email', label: 'Account email', placeholder: '[email protected]' }] },+ { id: 'notion', label: 'Notion', description: 'Pages & databases', glyph: { mono: 'No', bg: '#1A1320' }, secretLabel: 'Integration token', fields: [] },+ { id: 'stripe', label: 'Stripe', description: 'Payments & billing', glyph: { mono: 'St', bg: '#635BFF' }, secretLabel: 'API secret key', fields: [] },+ { id: 'confluence', label: 'Confluence', description: 'Wiki & docs', glyph: { mono: 'Cf', bg: '#1868DB' }, secretLabel: 'API token', fields: [{ key: 'site', label: 'Site URL', placeholder: 'https://acme.atlassian.net/wiki' }] },+ { id: 'sentry', label: 'Sentry', description: 'Error monitoring', glyph: { mono: 'Sy', bg: '#C84B4B' }, secretLabel: 'Auth token', fields: [{ key: 'org', label: 'Org slug', placeholder: 'acme', optional: true }] },+ { id: 'hubspot', label: 'HubSpot', description: 'CRM & contacts', glyph: { mono: 'Hs', bg: '#FF7A59' }, secretLabel: 'Private app token', fields: [] },+ { id: 'github', label: 'GitHub', description: 'Repos & pull requests', glyph: { mono: 'Gh', bg: '#1A1320' }, secretLabel: 'Personal access token', fields: [{ key: 'org', label: 'Org / owner', placeholder: 'acme', optional: true }] },+ { id: 'google-workspace', label: 'Gmail + Calendar', description: 'Mail & events', glyph: { mono: 'GC', bg: '#EA4335' }, secretLabel: 'OAuth client secret', fields: [{ key: 'clientId', label: 'Client ID', placeholder: '…apps.googleusercontent.com' }] },+ { id: 'salesforce', label: 'Salesforce', description: 'CRM & pipeline', glyph: { mono: 'Sf', bg: '#00A1E0' }, secretLabel: 'Access token', fields: [{ key: 'instanceUrl', label: 'Instance URL', placeholder: 'https://acme.my.salesforce.com' }] },+ { id: 'custom-rest', label: 'Custom REST', description: 'Any HTTP API', glyph: { mono: '{}', bg: '#2E9E5B' }, secretLabel: 'Auth token / API key', fields: CUSTOM_REST_FIELDS }];const MOCK_WORKERS: IntegrationWorker[] = [@@ -139,6 +145,13 @@ function delay<T>(value: T): Promise<T> {return Promise.resolve(value);}+/** Provisional probe: a secret that looks plausible "connects". */+function mockProbe(hasSecret: boolean): TestResult {+ return hasSecret+ ? { ok: true, message: 'Connected — authenticated (mock).' }+ : { ok: false, message: '401 — no secret set.' };+}+export const integrationsClient: IntegrationsClient = {listTemplates: () => delay(MOCK_TEMPLATES.map((t) => ({ ...t }))),listWorkers: () => delay(MOCK_WORKERS.map((w) => ({ ...w }))),@@ -169,12 +182,16 @@ export const integrationsClient: IntegrationsClient = {test: (id) => {const entry = mockEntries.find((e) => e.id === id);if (!entry) return delay({ ok: false, message: 'No such integration.' });- const ok = mockHasSecret.has(id);- entry.status = ok ? 'ok' : 'error';+ const res = mockProbe(mockHasSecret.has(id));+ entry.status = res.ok ? 'ok' : 'error';entry.lastTestedAt = 0; // stamped by the real broker; mock leaves 0- return delay({- ok,- message: ok ? 'Connection OK (mock).' : 'No secret set — add one to connect.'- });+ return delay(res);+ },+ testDraft: (draft) => {+ // A draft "connects" if it already has a stored secret (edit) or the user+ // just typed one (add). The real broker runs a live read-only call.+ const had = draft.id ? mockHasSecret.has(draft.id) : false;+ const typed = !!(draft.secret && draft.secret.length > 0);+ return delay(mockProbe(had || typed));}};