Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix: keep agent gear from leaking credentials
forwardxu9430fe169b36
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/BotGearPage.kt b/apps/android/app/src/main/kotlin/com/codync/android/BotGearPage.ktindex 319defc7..20df6934 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/BotGearPage.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/BotGearPage.kt@@ -94,13 +94,13 @@ private fun JsonObject.gearItems(key: String): List<GearItem> {if (skills) {PluginToggles("From Codync", "No skills yet. Get some from Extensions, or write your own.",plugins?.skills.orEmpty().map { Triple(it.id, it.name, it.description) }, draft.skills.orEmpty(),- { change(draft.copy(skills = it)) }) { id ->+ { change(draft.copy(skills = it)) }, enabled = online) { id ->plugins?.skills?.firstOrNull { it.id == id }?.let { viewingSkill = SkillRef(it.id, it.name, it.description) }}} else {PluginToggles("From Codync", "No connectors yet. Add GitHub, Linear, Notion and more from Extensions.",plugins?.connectors.orEmpty().map { Triple(it.id, it.name, it.command ?: it.url.orEmpty()) },- draft.connectors ?: plugins?.connectors.orEmpty().map { it.id }, { change(draft.copy(connectors = it)) })+ draft.connectors ?: plugins?.connectors.orEmpty().map { it.id }, { change(draft.copy(connectors = it)) }, enabled = online)}}CodyncSheet(viewingSkill, { viewingSkill = null }) { SkillSheet(it, state, store) }diff --git a/apps/android/app/src/main/kotlin/com/codync/android/EditorControls.kt b/apps/android/app/src/main/kotlin/com/codync/android/EditorControls.ktindex afb105d0..ac3785c0 100644--- a/apps/android/app/src/main/kotlin/com/codync/android/EditorControls.kt+++ b/apps/android/app/src/main/kotlin/com/codync/android/EditorControls.kt@@ -98,15 +98,16 @@ import com.kyant.shapes.RoundedRectangle/** A card of on/off switches for the connectors or skills installed on the computer. */@Composable internal fun PluginToggles(title: String, empty: String, items: List<Triple<String, String, String>>, selection: List<String>,- change: (List<String>) -> Unit, info: ((String) -> Unit)? = null) {+ change: (List<String>) -> Unit, enabled: Boolean = true, info: ((String) -> Unit)? = null) {CardSection(title) {if (items.isEmpty()) row { Text(tr(empty), style = Type.body, color = Palette.secondary) }for ((id, name, detail) in items) row {Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {Box(Modifier.weight(1f)) {- SwitchRow(name, detail.ifEmpty { null }, id in selection, { on -> change(selection.filter { it != id } + if (on) listOf(id) else emptyList()) })+ SwitchRow(name, detail.ifEmpty { null }, id in selection,+ { on -> change(selection.filter { it != id } + if (on) listOf(id) else emptyList()) }, enabled)}- if (info != null) IconButton("About $name", "info.circle") { info(id) }+ if (info != null) IconButton("About $name", "info.circle", enabled = enabled) { info(id) }}}}diff --git a/apps/desktop/src/renderer/store/bot-store.ts b/apps/desktop/src/renderer/store/bot-store.tsindex 0dd8b35b..74b62d0b 100644--- a/apps/desktop/src/renderer/store/bot-store.ts+++ b/apps/desktop/src/renderer/store/bot-store.ts@@ -380,6 +380,14 @@ export class BotStore extends BotSync {return (await this.ready()).botConversation(botId, peerId)}+ /** Skills and connectors `backend` already has in `cwd`, not the Codync ones this bot passes on. */+ async agentGear(backend: string, cwd: string): Promise<{ skills: AgentGearItem[]; connectors: AgentGearItem[] }> {+ const client = this.client+ if (!client) throw new Error("Couldn't load what this agent brings.")+ const value = await client.call<{ skills?: AgentGearItem[]; connectors?: AgentGearItem[] }>('agentGear', { backend, cwd })+ return { skills: value.skills ?? [], connectors: value.connectors ?? [] }+ }+async save(draft: BotDraft) {const client = await this.ready()const res = draft.id@@ -461,3 +469,10 @@ function cacheAttachment(id: string, data: Uint8Array) {}export { isWorking, needsInput }++/** One skill or connector an agent keeps for itself (`agentGear`). */+export interface AgentGearItem {+ name: string+ description?: string+ detail?: string+}diff --git a/apps/desktop/src/renderer/views/bots/BotEditorView.tsx b/apps/desktop/src/renderer/views/bots/BotEditorView.tsxindex 3669c666..400601b4 100644--- a/apps/desktop/src/renderer/views/bots/BotEditorView.tsx+++ b/apps/desktop/src/renderer/views/bots/BotEditorView.tsx@@ -319,7 +319,7 @@ function BotSettingsForm({ draft, onChange, error, plugins, part = 'all' }: {}/** A card of on/off switches for the connectors or skills installed on the computer. */-export function PluginToggles({ title, empty, items, selection, onChange, onInfo }: {+export function PluginToggles({ title, empty, items, selection, onChange, onInfo, disabled }: {title: stringempty: stringitems: { id: string; name: string; detail: string }[]@@ -327,6 +327,7 @@ export function PluginToggles({ title, empty, items, selection, onChange, onInfoonChange: (ids: string[]) => void/** Shows an item's details from an info button beside its switch. */onInfo?: (item: { id: string; name: string; detail: string }) => void+ disabled?: boolean}) {const tr = useTr()return (@@ -339,6 +340,7 @@ export function PluginToggles({ title, empty, items, selection, onChange, onInfotitle={item.name}detail={item.detail || null}on={selection.includes(item.id)}+ disabled={disabled}onChange={(on) => onChange([...selection.filter((id) => id !== item.id), ...(on ? [item.id] : [])])}/>)diff --git a/apps/desktop/src/renderer/views/bots/GearPage.tsx b/apps/desktop/src/renderer/views/bots/GearPage.tsxindex 61f4462e..696e64a0 100644--- a/apps/desktop/src/renderer/views/bots/GearPage.tsx+++ b/apps/desktop/src/renderer/views/bots/GearPage.tsx@@ -4,6 +4,7 @@ import { CardSection } from '../../components/Controls'import { VStack } from '../../components/Stack'import { Text } from '../../components/Text'import { useTr } from '../../lib/use-language'+import type { AgentGearItem } from '../../store/bot-store'import { useStore } from '../../store/context'import { FormSheet } from '../marketplace/pieces'import { SkillSheet, type SkillRef } from '../marketplace/SkillSheet'@@ -11,19 +12,13 @@ import { PluginToggles } from './BotEditorView'import { errorText, isValid, normalized, useFollowSaved, usePlugins } from './drafts'import './bots.css'-interface GearItem {- name: string- description?: string- detail?: string-}-/** The agent's own skills or connectors, then the Codync ones this bot passes on. */export function GearPage({ botId, kind }: { botId: string; kind: 'skills' | 'connectors' }) {const tr = useTr()const store = useStore()const plugins = usePlugins(store)const [draft, setDraft] = useState<BotDraft | null>(null)- const [gear, setGear] = useState<{ skills: GearItem[]; connectors: GearItem[] } | null>(null)+ const [gear, setGear] = useState<{ skills: AgentGearItem[]; connectors: AgentGearItem[] } | null>(null)const [failed, setFailed] = useState(false)const [error, setError] = useState<string | null>(null)const [viewingSkill, setViewingSkill] = useState<SkillRef | null>(null)@@ -42,18 +37,17 @@ export function GearPage({ botId, kind }: { botId: string; kind: 'skills' | 'conconst online = store.connection.kind === 'online'useEffect(() => {- const client = store.client- if (!client || !backend || !online) {+ if (!backend || !online) {setFailed(!online)return}let live = truesetFailed(false)setGear(null)- void client- .call<{ skills?: GearItem[]; connectors?: GearItem[] }>('agentGear', { backend, cwd })+ void store+ .agentGear(backend, cwd).then((value) => {- if (live) setGear({ skills: value.skills ?? [], connectors: value.connectors ?? [] })+ if (live) setGear(value)}).catch(() => {if (live) setFailed(true)@@ -106,6 +100,7 @@ export function GearPage({ botId, kind }: { botId: string; kind: 'skills' | 'conempty="No skills yet. Get some from Extensions, or write your own."items={(plugins?.skills ?? []).map((s) => ({ id: s.id, name: s.name, detail: s.description }))}selection={draft.skills ?? []}+ disabled={!online}onChange={(ids) => apply({ ...draft, skills: ids })}onInfo={(s) => setViewingSkill({ id: s.id, name: s.name, description: s.detail })}/>@@ -115,6 +110,7 @@ export function GearPage({ botId, kind }: { botId: string; kind: 'skills' | 'conempty="No connectors yet. Add GitHub, Linear, Notion and more from Extensions."items={(plugins?.connectors ?? []).map((c) => ({ id: c.id, name: c.name, detail: c.command ?? c.url ?? '' }))}selection={draft.connectors ?? []}+ disabled={!online}onChange={(ids) => apply({ ...draft, connectors: ids })}/>)}diff --git a/apps/desktop/src/renderer/views/bots/parts.tsx b/apps/desktop/src/renderer/views/bots/parts.tsxindex 27b7670c..e8c16613 100644--- a/apps/desktop/src/renderer/views/bots/parts.tsx+++ b/apps/desktop/src/renderer/views/bots/parts.tsx@@ -20,9 +20,9 @@ export function Field({ label, detail, children }: { label: string; detail?: str}/** An on/off row: title and a short note, the switch on the right. */-export function SwitchRow({ title, detail, on, onChange }: { title: string; detail?: string | null; on: boolean; onChange: (on: boolean) => void }) {+export function SwitchRow({ title, detail, on, onChange, disabled }: { title: string; detail?: string | null; on: boolean; onChange: (on: boolean) => void; disabled?: boolean }) {return (- <Switch on={on} onChange={onChange}>+ <Switch on={on} onChange={onChange} disabled={disabled}><RowLabel label={title} detail={detail} /></Switch>)diff --git a/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift b/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swiftindex e0a21d78..beec0364 100644--- a/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Bots/BotDetailsView.swift@@ -145,9 +145,9 @@ struct BotDetailsView: View {BotSettingsForm(draft: draft, error: saveError, scrolls: false, part: .rarely)}case .skills:- if let draft = Binding($draft) { BotGearPage(draft: draft, kind: .skills) }+ if let draft = Binding($draft) { BotGearPage(draft: draft, kind: .skills, saveError: saveError) }case .connectors:- if let draft = Binding($draft) { BotGearPage(draft: draft, kind: .connectors) }+ if let draft = Binding($draft) { BotGearPage(draft: draft, kind: .connectors, saveError: saveError) }}}diff --git a/apps/ios/Kit/Sources/CodyncUI/Bots/BotGearView.swift b/apps/ios/Kit/Sources/CodyncUI/Bots/BotGearPage.swiftsimilarity index 82%rename from apps/ios/Kit/Sources/CodyncUI/Bots/BotGearView.swiftrename to apps/ios/Kit/Sources/CodyncUI/Bots/BotGearPage.swiftindex a08eb46b..2adbd433 100644--- a/apps/ios/Kit/Sources/CodyncUI/Bots/BotGearView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Bots/BotGearPage.swift@@ -5,9 +5,8 @@ import SwiftUIstruct BotGearPage: View {@Binding var draft: BotDraftvar kind: Kind+ var saveError: String?@Environment(BotStore.self) private var model- @State private var gear: AgentGear?- @State private var failed = false@State private var viewingSkill: SkillRef?enum Kind { case skills, connectors }@@ -21,8 +20,8 @@ struct BotGearPage: View {private var agentItems: [AgentGearItem] {switch kind {- case .skills: gear?.skills ?? []- case .connectors: gear?.connectors ?? []+ case .skills: model.agentGear?.skills ?? []+ case .connectors: model.agentGear?.connectors ?? []}}@@ -33,17 +32,20 @@ struct BotGearPage: View {.font(.footnote).foregroundStyle(Palette.secondary)agentSection- codyncSection+ codyncSection.disabled(model.isOffline)+ if let saveError {+ Text(saveError).font(.footnote).foregroundStyle(Palette.danger)+ }}- .task(id: "\(draft.backend)|\(cwd)") { await load() }+ .task(id: "\(draft.backend)|\(cwd)|\(model.connection == .online)") { await load() }.codyncSheet(item: $viewingSkill) { SkillSheet(skill: $0) }}private var agentSection: some View {CardSection(L10n.tr("From {agent}").replacingOccurrences(of: "{agent}", with: agent)) {- if gear == nil, !failed {+ if model.agentGear == nil, !model.agentGearFailed {Text(L10n.tr("Loading…")).foregroundStyle(Palette.secondary)- } else if failed {+ } else if model.agentGearFailed {Text(L10n.tr("Couldn't load what this agent brings.")).foregroundStyle(Palette.danger)} else if agentItems.isEmpty {Text(L10n.tr("None from this agent.")).foregroundStyle(Palette.secondary)@@ -83,16 +85,6 @@ struct BotGearPage: View {private func load() async {await model.refreshPlugins()- failed = false- guard let client = model.client else {- failed = true- return- }- do {- let loaded = try await client.agentGear(backend: draft.backend, cwd: cwd)- if !Task.isCancelled { gear = loaded }- } catch {- if !Task.isCancelled { failed = true }- }+ await model.loadAgentGear(backend: draft.backend, cwd: cwd)}}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Plugins.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Plugins.swiftindex f4b2a5c7..0e28c121 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Plugins.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Plugins.swift@@ -80,6 +80,28 @@ extension BotStore {try await ready().skillDetails(skill.request)}+ /// Reads the skills and connectors `backend` already has in `cwd`. A newer request wins.+ public func loadAgentGear(backend: String, cwd: String) async {+ let key = "\(backend)\n\(cwd)"+ agentGearRequest = key+ agentGear = nil+ agentGearFailed = false+ guard let client else {+ agentGearFailed = true+ return+ }+ do {+ let loaded = try await client.agentGear(backend: backend, cwd: cwd)+ guard !Task.isCancelled, agentGearRequest == key else { return }+ agentGear = loaded+ } catch is CancellationError {+ return+ } catch {+ guard !Task.isCancelled, agentGearRequest == key else { return }+ agentGearFailed = true+ }+ }+/// Re-detects agents on the computer (after an install or sign-in).public func refreshBackends() async {guard let client, let backends = try? await client.refreshBackends() else { return }diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swiftindex 235c7af6..84e186de 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore.swift@@ -70,6 +70,10 @@ public final class BotStore {/// Installed on the computer, for the Plugins screen and bot settings.public internal(set) var installedConnectors: [InstalledConnector] = []public internal(set) var installedSkills: [InstalledSkill] = []+ /// What the open bot's agent already has on disk. `nil` while that read is in flight.+ public internal(set) var agentGear: AgentGear?+ public internal(set) var agentGearFailed = false+ var agentGearRequest: String?/// Bots whose older history has been fully paged in.public internal(set) var historyComplete: Set<String> = []var composerDrafts: [String: String] = [:]diff --git a/host/src/agent/gear.rs b/host/src/agent/gear.rsindex 50424ad3..aa3eb9b9 100644--- a/host/src/agent/gear.rs+++ b/host/src/agent/gear.rs@@ -256,15 +256,12 @@ fn servers_object<'a>(path: &Path, value: &'a Value) -> Option<&'a Map<String, Vvalue.get("servers").and_then(Value::as_object).or_else(|| value.as_object())}-/// The command or URL a person can recognize. Arguments that look like a token are left out,-/// and a URL loses its user, query and fragment. A URL whose path still looks like a token is omitted.+/// The command or URL a person can recognize. A flag that looks like a token is left out+/// together with the value after it, and a URL loses its user, query and fragment. A URL+/// whose path still looks like a token is omitted.fn server_detail(server: &Map<String, Value>) -> String {if let Some(url) = server.get("url").and_then(Value::as_str).filter(|url| !url.is_empty()) {- let url = public_url(url);- if looks_secret(&url) {- return String::new();- }- return clip(&url, DETAIL_CHARS);+ return clip(&visible_url(url), DETAIL_CHARS);}clip(&command_text(server), DETAIL_CHARS)}@@ -279,8 +276,26 @@ fn command_text(server: &Map<String, Value>) -> String {if let Some(args) = server.get("args").and_then(Value::as_array) {parts.extend(args.iter().filter_map(|v| v.as_str().map(str::to_owned)));}- parts.retain(|part| !looks_secret(part));- parts.join(" ")+ let mut kept = Vec::new();+ let mut skip_value = false;+ for part in parts {+ if skip_value {+ skip_value = false;+ continue;+ }+ if looks_secret(&part) {+ skip_value = true;+ continue;+ }+ kept.push(part);+ }+ kept.join(" ")+}++/// A URL with its user, query and fragment removed. Empty when the rest still looks like a token.+fn visible_url(url: &str) -> String {+ let url = public_url(url);+ if looks_secret(&url) { String::new() } else { url }}fn public_url(url: &str) -> String {@@ -328,9 +343,10 @@ fn mcp_toml(text: &str) -> Vec<Item> {continue;}if let Some(url) = toml_value(trimmed, "url") {- detail = url;+ detail = visible_url(&url);} else if detail.is_empty()&& let Some(command) = toml_value(trimmed, "command")+ && !looks_secret(&command){detail = command;}@@ -360,7 +376,7 @@ fn toml_value(line: &str, key: &str) -> Option<String> {let rest = line.strip_prefix(key)?.trim_start();let rest = rest.strip_prefix('=')?.trim();let value = bare(rest);- (!value.is_empty() && !looks_secret(value)).then(|| value.to_owned())+ (!value.is_empty()).then(|| value.to_owned())}fn dedupe(items: &mut Vec<Item>) {@@ -462,6 +478,31 @@ mod tests {let _ = std::fs::remove_dir_all(root);}+ #[test]+ fn a_token_flag_and_a_toml_url_leave_the_credential_out() {+ let root = scratch();+ let home = root.join("home");+ std::fs::create_dir_all(home.join(".cursor")).expect("cursor");+ std::fs::create_dir_all(home.join(".codex")).expect("codex");+ std::fs::write(+ home.join(".cursor/mcp.json"),+ r#"{"mcpServers":{"github":{"command":"npx","args":["--token","abc123","-y","server"]}}}"#,+ )+ .expect("mcp");+ let (_, connectors) = collect("cursor", &home, None);+ assert_eq!(connectors[0].detail, "npx -y server");+ assert!(!connectors[0].detail.contains("abc123"));+ std::fs::write(+ home.join(".codex/config.toml"),+ "[mcp_servers.github]\nurl = \"https://alice:[email protected]/mcp?key=xyz\"\n",+ )+ .expect("toml");+ let (_, connectors) = collect("codex", &home, None);+ assert_eq!(connectors[0].detail, "https://example.test/mcp");+ assert!(!connectors[0].detail.contains("abc123") && !connectors[0].detail.contains("alice"));+ let _ = std::fs::remove_dir_all(root);+ }+#[test]fn a_missing_config_is_an_empty_list() {let root = scratch();diff --git a/host/src/tui/manage/gear.rs b/host/src/tui/manage/gear.rsindex 07cef6ce..d68b0d45 100644--- a/host/src/tui/manage/gear.rs+++ b/host/src/tui/manage/gear.rs@@ -54,6 +54,33 @@ impl Gear {GearKind::Connectors => self.agent_connectors.as_deref(),}}++ /// One scrollable list: the agent's rows, then Codync's switches. Headings scroll with them.+ pub fn rows(&self, toggles: usize) -> Vec<GearRow> {+ let mut rows = vec![GearRow::AgentHeading];+ match self.agent() {+ Some(items) if !self.failed && !items.is_empty() => rows.extend((0..items.len()).map(GearRow::Agent)),+ _ => rows.push(GearRow::AgentNote),+ }+ rows.push(GearRow::CodyncHeading);+ if toggles == 0 {+ rows.push(GearRow::CodyncNote);+ } else {+ rows.extend((0..toggles).map(GearRow::Toggle));+ }+ rows+ }+}++/// A line on the Skills or Connectors page. `Toggle` is an index into the installed Codync list.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum GearRow {+ AgentHeading,+ AgentNote,+ Agent(usize),+ CodyncHeading,+ CodyncNote,+ Toggle(usize),}pub(super) fn items(value: &Value) -> Vec<GearItem> {@@ -97,7 +124,7 @@ impl App {agent_skills: None,agent_connectors: None,failed: false,- cursor: 0,+ cursor: 1,}));}@@ -106,13 +133,18 @@ impl App {self.open_page(page);return None;}- let count = self.gear_toggles(&gear).len();- gear.cursor = gear.cursor.min(count.saturating_sub(1));+ let rows = gear.rows(self.gear_toggles(&gear).len());+ let last = rows.len().saturating_sub(1);+ gear.cursor = gear.cursor.min(last);match key.code {KeyCode::Esc | KeyCode::Char('q') => return None,- KeyCode::Down | KeyCode::Char('j') => gear.cursor = (gear.cursor + 1).min(count.saturating_sub(1)),+ KeyCode::Down | KeyCode::Char('j') => gear.cursor = (gear.cursor + 1).min(last),KeyCode::Up | KeyCode::Char('k') => gear.cursor = gear.cursor.saturating_sub(1),- KeyCode::Char(' ') | KeyCode::Enter => self.toggle_gear(&gear),+ KeyCode::Char(' ') | KeyCode::Enter => {+ if let Some(GearRow::Toggle(index)) = rows.get(gear.cursor) {+ self.toggle_gear(&gear, *index);+ }+ }_ => {}}Some(Overlay::Gear(gear))@@ -131,14 +163,14 @@ impl App {.collect()}- fn toggle_gear(&mut self, gear: &Gear) {+ fn toggle_gear(&mut self, gear: &Gear, index: usize) {let (bot_id, field, ids) = {let Some(bot) = self.bots.get(&gear.bot) else { return };let installed = match gear.kind {GearKind::Skills => &self.market.1,GearKind::Connectors => &self.market.0,};- let Some(item) = installed.get(gear.cursor) else { return };+ let Some(item) = installed.get(index) else { return };let id = item.id.clone();let mut ids = match gear.kind {GearKind::Skills => bot.skills.clone(),diff --git a/host/src/tui/manage/mod.rs b/host/src/tui/manage/mod.rsindex f3bf905d..03b76311 100644--- a/host/src/tui/manage/mod.rs+++ b/host/src/tui/manage/mod.rs@@ -24,7 +24,7 @@ mod when;pub use analytics::AnalyticsSheet;pub use fields::handoff_fields;-pub use gear::{Gear, GearKind};+pub use gear::{Gear, GearKind, GearRow};pub use library::{ArtifactTitles, LibraryItem};pub use memory::{MemoryMode, MemorySheet, Scroll, Section};pub use network::{NetReply, NetworkSheet, Recovery, Step};diff --git a/host/src/tui/sheets/gear_view.rs b/host/src/tui/sheets/gear_view.rsindex b5dd69d9..e9460f31 100644--- a/host/src/tui/sheets/gear_view.rs+++ b/host/src/tui/sheets/gear_view.rs@@ -1,8 +1,9 @@//! The Skills and Connectors pages: the agent's own rows, then Codync's switches.+//! Both groups are one list, so the cursor scrolls agent rows that do not fit.use super::{App, Buffer, Rect, centered, footer, frame_box, name_of, page_tabs, put, row, theme, truncate, window};use crate::tui::l10n::tr;-use crate::tui::manage::{Gear, GearKind};+use crate::tui::manage::{Gear, GearKind, GearRow};pub fn draw(buf: &mut Buffer, area: Rect, app: &App, gear: &Gear) {let t = theme();@@ -19,72 +20,52 @@ pub fn draw(buf: &mut Buffer, area: Rect, app: &App, gear: &Gear) {put(buf, inner.x, y, inner.width, &intro, t.secondary.patch(t.panel));y += 2;}- let from_agent = tr("From {agent}").replace("{agent}", &agent);- if y < bottom {- put(buf, inner.x, y, inner.width, &from_agent, t.bold.patch(t.panel));- y += 1;- }- y = agent_rows(buf, inner, y, bottom, gear);- if y < bottom {- y += 1;- put(buf, inner.x, y, inner.width, &tr("From Codync"), t.bold.patch(t.panel));- y += 1;- }let toggles = app.gear_toggles(gear);+ let rows = gear.rows(toggles.len());let room = usize::from(bottom.saturating_sub(y));- if toggles.is_empty() {- if y < bottom {- let empty = match gear.kind {- GearKind::Skills => "No skills yet. Get some from Extensions, or write your own.",- GearKind::Connectors => "No connectors yet. Add GitHub, Linear, Notion and more from Extensions.",- };- put(buf, inner.x, y, inner.width, &tr(empty), t.dim.patch(t.panel));+ let cursor = gear.cursor.min(rows.len().saturating_sub(1));+ for (offset, line) in rows.iter().enumerate().skip(window(cursor, room)).take(room) {+ if y >= bottom {+ break;}- } else {- let cursor = gear.cursor.min(toggles.len().saturating_sub(1));- for (offset, (_id, name, on)) in toggles.iter().enumerate().skip(window(cursor, room)).take(room) {- let base = row(buf, inner, y, offset == cursor);- let mark = if *on { "☑" } else { "☐" };- put(buf, inner.x, y, inner.width, &format!("{mark} {name}"), t.text.patch(base));- y += 1;- }- }- footer(buf, inner, None, "space on / off · ⇧←→ page · esc");-}--fn agent_rows(buf: &mut Buffer, inner: Rect, mut y: u16, bottom: u16, gear: &Gear) -> u16 {- let t = theme();- match gear.agent() {- None => {- if y < bottom {- put(buf, inner.x, y, inner.width, &tr("Loading…"), t.dim.patch(t.panel));- y += 1;+ let base = row(buf, inner, y, offset == cursor);+ let (text, style) = match line {+ GearRow::AgentHeading => (tr("From {agent}").replace("{agent}", &agent), t.bold.patch(base)),+ GearRow::AgentNote => {+ let failed = gear.agent().is_some() && gear.failed;+ (agent_note(gear), if failed { t.red.patch(base) } else { t.dim.patch(base) })}- }- Some(_) if gear.failed => {- if y < bottom {- put(buf, inner.x, y, inner.width, &tr("Couldn't load what this agent brings."), t.red.patch(t.panel));- y += 1;+ GearRow::Agent(index) => {+ let Some(item) = gear.agent().and_then(|items| items.get(*index)) else { continue };+ let text =+ if item.detail.is_empty() { item.name.clone() } else { format!("{} {}", item.name, item.detail) };+ (text, t.text.patch(base))}- }- Some([]) => {- if y < bottom {- put(buf, inner.x, y, inner.width, &tr("None from this agent."), t.dim.patch(t.panel));- y += 1;+ GearRow::CodyncHeading => (tr("From Codync").into(), t.bold.patch(base)),+ GearRow::CodyncNote => {+ let empty = match gear.kind {+ GearKind::Skills => "No skills yet. Get some from Extensions, or write your own.",+ GearKind::Connectors => "No connectors yet. Add GitHub, Linear, Notion and more from Extensions.",+ };+ (tr(empty).into(), t.dim.patch(base))}- }- Some(items) => {- let room = usize::from(bottom.saturating_sub(y).saturating_sub(3));- for item in items.iter().take(room.max(1)) {- if y >= bottom {- break;- }- let line =- if item.detail.is_empty() { item.name.clone() } else { format!("{} {}", item.name, item.detail) };- put(buf, inner.x, y, inner.width, &truncate(&line, usize::from(inner.width)), t.text.patch(t.panel));- y += 1;+ GearRow::Toggle(index) => {+ let Some((_, name, on)) = toggles.get(*index) else { continue };+ (format!("{} {name}", if *on { "☑" } else { "☐" }), t.text.patch(base))}- }+ };+ put(buf, inner.x, y, inner.width, &truncate(&text, usize::from(inner.width)), style);+ y += 1;+ }+ footer(buf, inner, None, "space on / off · ⇧←→ page · esc");+}++fn agent_note(gear: &Gear) -> String {+ if gear.agent().is_none() {+ tr("Loading…").into()+ } else if gear.failed {+ tr("Couldn't load what this agent brings.").into()+ } else {+ tr("None from this agent.").into()}- y}