From 2d95a4be89d88082f94657bcd27fdef9a54dd713 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sun, 1 Nov 2026 16:12:52 -0500 Subject: [PATCH 1/2] =?UTF-8?q?feat(mobile):=20Settings=20=E2=80=BA=20Pers?= =?UTF-8?q?onas=20uses=20compact=20settings=20rows,=20and=20its=20dark-mod?= =?UTF-8?q?e=20text=20reads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Personas page used tall cards with stacked badges and a row of four controls per persona, far less dense than upstream's other settings pages. It now uses upstream's SettingsScreen header (title, and Create as its action) and grouped settings rows: each persona is one row with its name, a one-line status, its switch and an ellipsis menu (Edit, Duplicate, Export, Copy to environment, Remove or Restore); each source folder is one row with a menu; Import and Add folder are action rows; the explanations are section footers. Tapping an editable persona edits it. The Playbooks section used web-only colour classes (text-muted-foreground, text-destructive) that mobile's theme doesn't define, so its empty state read black on the dark background; they are mobile's text-foreground-muted and text-danger-foreground now. Closes #867 Co-Authored-By: Claude Opus 5.5 --- .../j5/agents/AgentLibrarySettingsScreen.tsx | 883 +++++++++--------- .../PlaybookLibrarySettingsScreen.tsx | 22 +- 2 files changed, 436 insertions(+), 469 deletions(-) diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index 5d22ed78ebdb..877acbd4dbed 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -24,10 +24,10 @@ import { type AgentPersonaEditInput, type AgentPersonaImportConflict, type AgentPersonaImportConflictError, + type AgentPersonaLibraryFolder, type EnvironmentId, } from "@t3tools/contracts"; -import { useNavigation } from "@react-navigation/native"; -import { Platform, Pressable, ScrollView, Share, Switch, View } from "react-native"; +import { Platform, Pressable, Share, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useAtomValue } from "@effect/atom-react"; import { Atom } from "effect/reactivity"; @@ -36,34 +36,35 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; import { pickAgentDefinitions } from "./pickAgentDefinitions"; import { useAtomCommand } from "../../state/use-atom-command"; -import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader"; import { AppText as Text } from "../../components/ui/AppText"; import { ScreenScrollView } from "../../components/ui/ScreenScrollView"; import { cn } from "../../lib/cn"; -import { NativeStackScreenOptions } from "../../native/StackHeader"; import { agentPersonaEnvironment } from "./agentPersonaAtoms"; import { useEnvironmentQuery } from "../../state/query"; import { useRemoteConnectionStatus } from "../../state/use-remote-environment-registry"; import { SettingsSection } from "../../features/settings/components/SettingsSection"; +import { SettingsScreen } from "../../features/settings/components/SettingsScreen"; +import { SettingsActionRow } from "../../features/settings/components/SettingsActionRow"; +import { ThemedSwitch } from "../../components/ui/ThemedSwitch"; import { PlaybookLibrarySettingsSection } from "../playbooks/PlaybookLibrarySettingsScreen"; export function AgentLibrarySettingsScreen() { // Personas and Playbooks are managed by a server's Owners (People and access AC27). return useOwnerSomewhere() === false ? ( - - - + + + {LIBRARY_FOR_OWNERS} + + ) : ( ); } function OwnerAgentLibrarySettingsScreen() { - const navigation = useNavigation(); const insets = useSafeAreaInsets(); const { connectedEnvironments: connected } = useRemoteConnectionStatus(); const ownedEnvironmentIds = useOwnedEnvironmentIds(); @@ -312,8 +313,24 @@ function OwnerAgentLibrarySettingsScreen() { ? [] : presentAgentPersonaCatalog(catalog.data); + const folders = librarySources.data?.folders ?? []; + const environmentLabel = + connectedEnvironments.find( + (environment) => environment.environmentId === effectiveEnvironmentId, + )?.environmentLabel ?? "this environment"; + return ( - + setCreating({}), + }, + ]} + > {confirmation ? ( ) : null} - {Platform.OS === "android" ? ( - <> - - navigation.goBack()} /> - - ) : null} - {catalog.data?.diagnostics?.map((diagnostic) => ( - - ))} - - - - In a Codex or Claude conversation, type @persona:id, or @ and the start of a persona’s - name, to run a persona as a subagent. Edit imported personas here. - - - + {catalog.data?.diagnostics?.length ? ( + + {catalog.data.diagnostics.map((diagnostic, index) => ( + 0} + tone="danger" + text={`Invalid persona file: ${diagnostic.path}: ${diagnostic.message}`} + /> + ))} + + ) : null} {connectedEnvironments.length > 1 ? ( - - - {connectedEnvironments.map((environment) => { - const selected = environment.environmentId === effectiveEnvironmentId; - return ( - setSelectedEnvironmentId(environment.environmentId)} - > - - {environment.environmentLabel} - - - ); - })} - - + ({ + id: environment.environmentId, + title: environment.environmentLabel, + state: + environment.environmentId === effectiveEnvironmentId + ? ("on" as const) + : undefined, + }))} + onPressAction={({ nativeEvent }) => { + const next = connectedEnvironments.find( + (environment) => environment.environmentId === nativeEvent.event, + ); + if (next && !busy) setSelectedEnvironmentId(next.environmentId); + }} + > + + + Environment + + + {environmentLabel} + + + + ) : null} - - Scoped personas - - setCreating({})} - > - + {effectiveEnvironmentId === null ? ( + + ) : catalog.isPending ? ( + + ) : catalog.error ? ( + + ) : personas.length === 0 ? ( + + ) : ( + personas.map((persona, index) => ( + { + const entry = usageById.get(persona.personaId); + return entry === undefined ? null : presentAgentPersonaUsage(entry).line; + })()} + borderTop={index > 0} + locked={locked} + busy={busy} + otherEnvironments={otherEnvironments} + onToggle={(enabled) => void toggleAgent(persona.personaId, enabled)} + onEdit={ + persona.edit && effectiveEnvironmentId + ? () => { + if (persona.edit && effectiveEnvironmentId) + setEditing({ + environmentId: effectiveEnvironmentId, + initial: persona.edit, + }); + } + : null + } + onDuplicate={() => void duplicatePersona(persona.personaId)} + onExport={() => void exportPersona(persona.personaId)} + onCopy={(target) => void copyPersona(persona.personaId, target)} + onRemove={() => void removePersona(persona.personaId)} + onRestore={() => void restorePersona(persona.personaId)} /> - Create - - {Platform.OS === "web" ? ( - - Use Settings → Personas in the web app to import files. - - ) : ( - - { - if (nativeEvent.event === "agent" || nativeEvent.event === "folder") - void importSelection(nativeEvent.event); - }} - > - - Import - - - - - )} - - - - - {effectiveEnvironmentId === null ? ( - - ) : catalog.isPending ? ( - - ) : catalog.error ? ( - - ) : personas.length === 0 ? ( - - ) : ( - personas.map((persona) => { - const available = persona.availability === "available"; - return ( - - - - - {persona.displayName} - - - - {persona.availabilityLabel} - - - {persona.unsandboxed ? ( - - - Full access - - - ) : null} - {persona.originLabel ? ( - - - {persona.originLabel} - - - ) : null} - - - {persona.removed ? ( - void restorePersona(persona.personaId)} - > - - Restore - - ) : ( - <> - - void toggleAgent(persona.personaId, enabled) - } - /> - { - if (persona.edit && effectiveEnvironmentId) - setEditing({ - environmentId: effectiveEnvironmentId, - initial: persona.edit, - }); - }} - > - - - - )} - ({ - id: `copy:${environment.environmentId}`, - title: environment.environmentLabel, - })), - }, - ]), - ]} - onPressAction={({ nativeEvent }) => { - if (nativeEvent.event === "duplicate") - void duplicatePersona(persona.personaId); - else if (nativeEvent.event === "export") - void exportPersona(persona.personaId); - else if (nativeEvent.event.startsWith("copy:")) { - const target = otherEnvironments.find( - (environment) => - `copy:${environment.environmentId}` === nativeEvent.event, - ); - if (target) - void copyPersona(persona.personaId, { - environmentId: target.environmentId, - label: target.environmentLabel, - }); - } - }} - > - - - - - {persona.removed ? null : ( - void removePersona(persona.personaId)} - > - - - )} - - - {persona.description} - {persona.blockedReasons.map((reason) => ( - - {reason} - - ))} - {(() => { - const entry = usageById.get(persona.personaId); - if (entry === undefined) return null; - const summary = presentAgentPersonaUsage(entry); - return ( - - {summary.line} - - ); - })()} - - ); - }) - )} - + )) + )} + {Platform.OS === "web" || effectiveEnvironmentId === null ? null : ( + <> + + void importSelection("agent")} + /> + + void importSelection("folder")} + /> + + )} {effectiveEnvironmentId !== null ? ( - - - - - Folders this environment reads YAML definitions from. Paths are on the - environment’s machine; relative paths resolve from its state directory. - - - {librarySources.isPending ? ( - - ) : librarySources.error ? ( - - ) : librarySources.data ? ( - <> - {librarySources.data.folders.length === 0 ? ( - - ) : null} - {librarySources.data.folders.map((folder) => { - const nudges = agentPersonaFolderNudges(folder.git); - return ( - - - {/* Paths get the row's full width and truncate in the middle, keeping the folder name. */} - - - {folder.configuredPath} - - {folder.path !== folder.configuredPath ? ( - - {folder.path} - - ) : null} - - - {agentPersonaFolderStatusLabel( - folder, - librarySources.data?.configured, - )} - - - - - void saveFolders( - (librarySources.data?.folders ?? []) - .map(({ configuredPath }) => configuredPath) - .filter((candidate) => candidate !== folder.configuredPath), - ) - } - > - - - - {nudges.map((nudge) => ( - - {nudge} - - ))} - - ); - })} - - - {librarySources.data.configured - ? "Files are read on every catalog request, so edits and git pulls apply without a restart." - : "Bundled examples appear until a folder is configured or the default folder exists. Adding a folder writes agent-personas.json."} - - setPickingFolder(true)} - > - - Add folder - - - - ) : null} - + + {librarySources.isPending ? ( + + ) : librarySources.error ? ( + + ) : folders.length === 0 ? ( + + ) : ( + folders.map((folder, index) => ( + 0} + locked={locked} + onRemove={() => + void saveFolders( + folders + .map(({ configuredPath }) => configuredPath) + .filter((candidate) => candidate !== folder.configuredPath), + ) + } + /> + )) + )} + + setPickingFolder(true)} + /> ) : null} @@ -783,18 +526,11 @@ function OwnerAgentLibrarySettingsScreen() { {pickingFolder && effectiveEnvironmentId ? ( environment.environmentId === effectiveEnvironmentId, - )?.environmentLabel ?? "this environment" - } + environmentLabel={environmentLabel} onClose={() => setPickingFolder(false)} onSelect={(path) => { setPickingFolder(false); - void saveFolders([ - ...(librarySources.data?.folders ?? []).map(({ configuredPath }) => configuredPath), - path, - ]); + void saveFolders([...folders.map(({ configuredPath }) => configuredPath), path]); }} /> ) : null} @@ -824,7 +560,7 @@ function OwnerAgentLibrarySettingsScreen() { }} /> ) : null} - + ); } @@ -858,10 +594,241 @@ async function shareAgentDefinition(fileName: string, yaml: string) { await Sharing.shareAsync(uri, { mimeType: "application/yaml", dialogTitle: fileName }); } -function AgentMessage(props: { readonly title: string }) { +function InfoRow(props: { + readonly text: string; + readonly tone?: "danger"; + readonly borderTop?: boolean; +}) { + return ( + + + {props.text} + + + ); +} + +type PresentedPersona = ReturnType[number]; + +/** One persona as a settings row: name and status, its switch, and the rest in a menu. */ +function PersonaRow(props: { + readonly persona: PresentedPersona; + readonly usageLine: string | null; + readonly borderTop: boolean; + readonly locked: boolean; + readonly busy: boolean; + readonly otherEnvironments: ReadonlyArray<{ + readonly environmentId: EnvironmentId; + readonly environmentLabel: string; + }>; + readonly onToggle: (enabled: boolean) => void; + readonly onEdit: (() => void) | null; + readonly onDuplicate: () => void; + readonly onExport: () => void; + readonly onCopy: (target: { environmentId: EnvironmentId; label: string }) => void; + readonly onRemove: () => void; + readonly onRestore: () => void; +}) { + const { persona } = props; + const status = [ + persona.removed ? "Removed" : persona.availabilityLabel, + persona.originLabel, + persona.unsandboxed ? "Full access" : null, + props.usageLine, + ] + .filter(Boolean) + .join(" · "); + const unavailable = !persona.removed && persona.availability !== "available"; + const content = ( + <> + + {persona.displayName} + + + {status} + + {unavailable && persona.blockedReasons[0] ? ( + + {persona.blockedReasons[0]} + + ) : null} + + ); + return ( + + {props.onEdit ? ( + + {content} + + ) : ( + + {content} + + )} + {persona.removed ? null : ( + + )} + ({ + id: `copy:${environment.environmentId}`, + title: environment.environmentLabel, + })), + }, + ]), + persona.removed + ? { id: "restore", title: "Restore", attributes: { disabled: props.locked } } + : { + id: "remove", + title: "Remove", + attributes: { destructive: true, disabled: props.locked }, + }, + ]} + onPressAction={({ nativeEvent }) => { + const action = nativeEvent.event; + if (action === "edit") props.onEdit?.(); + else if (action === "duplicate") props.onDuplicate(); + else if (action === "export") props.onExport(); + else if (action === "remove") props.onRemove(); + else if (action === "restore") props.onRestore(); + else if (action.startsWith("copy:")) { + const target = props.otherEnvironments.find( + (environment) => `copy:${environment.environmentId}` === action, + ); + if (target) + props.onCopy({ environmentId: target.environmentId, label: target.environmentLabel }); + } + }} + > + + + + + + ); +} + +/** One source folder: its path on one line, its status, git nudges, and a menu to stop reading it. */ +function FolderRow(props: { + readonly folder: AgentPersonaLibraryFolder; + readonly configured: boolean | undefined; + readonly borderTop: boolean; + readonly locked: boolean; + readonly onRemove: () => void; +}) { + const { folder } = props; + const nudges = agentPersonaFolderNudges(folder.git); + const missing = !folder.exists && props.configured !== false; return ( - - {props.title} + + + + {folder.configuredPath} + + {folder.path !== folder.configuredPath ? ( + + {folder.path} + + ) : null} + + {agentPersonaFolderStatusLabel(folder, props.configured)} + + {nudges.map((nudge) => ( + + {nudge} + + ))} + + { + if (nativeEvent.event === "remove") props.onRemove(); + }} + > + + + + ); } diff --git a/apps/mobile/src/j5/playbooks/PlaybookLibrarySettingsScreen.tsx b/apps/mobile/src/j5/playbooks/PlaybookLibrarySettingsScreen.tsx index c247f0053282..038318e15fc2 100644 --- a/apps/mobile/src/j5/playbooks/PlaybookLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/playbooks/PlaybookLibrarySettingsScreen.tsx @@ -39,7 +39,7 @@ export function PlaybookLibrarySettingsSection({ }))} /> ) : ( - No environment connected. + No environment connected. ); } @@ -152,7 +152,7 @@ function PlaybookLibrary({ ) : ( - Available in every project. + Available in every project. )} {project ? ( - + Includes {project.title}'s .j5/playbooks folder. Those override a library playbook with the same name in that project. ) : null} {error || sources.error || query.error ? ( - + {error ?? sources.error ?? query.error} ) : null} @@ -202,7 +202,7 @@ function PlaybookLibrary({ {query.data?.playbooks.length === 0 ? ( No playbooks yet - + Create a repeatable workflow with your agent, or import YAML. @@ -312,19 +312,19 @@ function PlaybookLibrary({ accessibilityRole="button" accessibilityLabel={`More actions for ${playbook.title}`} > - ••• + ••• - {playbook.description} - + {playbook.description} + {playbook.stepCount} {playbook.stepCount === 1 ? "step" : "steps"} {source.kind === "folder" ? " · From source folder" : ""} {source.kind === "workspace" ? ` · From ${project?.title ?? "project"}` : ""} {playbook.overridesLibrary ? " · Overrides library copy" : ""} {playbook.issue ? ( - + {playbook.issue.message} ) : null} @@ -344,11 +344,11 @@ function PlaybookLibrary({ .filter((entry) => entry.source.kind === "folder" || entry.issue) .map((entry) => ( - + {entry.source.kind === "folder" ? entry.path : "Environment library"} {entry.issue ? ( - + {entry.issue.message} ) : null} From ec60a2413ea38ecdfa66d2bdbec88acaf81a8495 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sun, 1 Nov 2026 16:18:36 -0500 Subject: [PATCH 2/2] fix(mobile): a removed persona's row offers only Restore The compact row let a removed persona be edited by tapping it or from its menu, and offered Duplicate, Export and Copy beside Restore; the old row offered only Restore. The row's actions now come from personaRowActions, which gives a removed persona Restore alone, and tapping the row edits only when Edit is offered. Refs #867 Co-Authored-By: Claude Opus 5.5 --- .../j5/agents/AgentLibrarySettingsScreen.tsx | 71 ++++++++++--------- .../src/j5/agents/personaRowActions.test.ts | 24 +++++++ .../mobile/src/j5/agents/personaRowActions.ts | 16 +++++ 3 files changed, 79 insertions(+), 32 deletions(-) create mode 100644 apps/mobile/src/j5/agents/personaRowActions.test.ts create mode 100644 apps/mobile/src/j5/agents/personaRowActions.ts diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index 877acbd4dbed..b7f531c72bc5 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -10,6 +10,7 @@ import { import { AgentEditorModal } from "./AgentEditorModal"; import { AgentFolderPickerModal } from "./AgentFolderPickerModal"; import { sendWhenReconnected } from "./watchEnvironmentSessions"; +import { personaRowActions } from "./personaRowActions"; import { Menu } from "../../components/ui/Menu"; import { SymbolView } from "../../components/ui/AppSymbol"; import { @@ -644,6 +645,11 @@ function PersonaRow(props: { .filter(Boolean) .join(" · "); const unavailable = !persona.removed && persona.availability !== "available"; + const actions = personaRowActions( + { removed: persona.removed, editable: props.onEdit !== null }, + props.otherEnvironments.length > 0, + ); + const onEdit = actions.includes("edit") ? props.onEdit : null; const content = ( <> - {props.onEdit ? ( + {onEdit ? ( {content} @@ -702,40 +708,41 @@ function PersonaRow(props: { /> )} ({ - id: `copy:${environment.environmentId}`, - title: environment.environmentLabel, - })), - }, - ]), - persona.removed - ? { id: "restore", title: "Restore", attributes: { disabled: props.locked } } - : { - id: "remove", + actions={actions.map((action) => { + switch (action) { + case "edit": + return { id: action, title: "Edit", attributes: { disabled: props.locked } }; + case "duplicate": + return { + id: action, + title: "Duplicate as personal persona", + attributes: { disabled: props.locked || persona.availability === "unsupported" }, + }; + case "export": + return { id: action, title: "Export YAML", attributes: { disabled: props.busy } }; + case "copy": + return { + id: action, + title: "Copy to environment", + attributes: { disabled: props.busy }, + subactions: props.otherEnvironments.map((environment) => ({ + id: `copy:${environment.environmentId}`, + title: environment.environmentLabel, + })), + }; + case "remove": + return { + id: action, title: "Remove", attributes: { destructive: true, disabled: props.locked }, - }, - ]} + }; + case "restore": + return { id: action, title: "Restore", attributes: { disabled: props.locked } }; + } + })} onPressAction={({ nativeEvent }) => { const action = nativeEvent.event; - if (action === "edit") props.onEdit?.(); + if (action === "edit") onEdit?.(); else if (action === "duplicate") props.onDuplicate(); else if (action === "export") props.onExport(); else if (action === "remove") props.onRemove(); diff --git a/apps/mobile/src/j5/agents/personaRowActions.test.ts b/apps/mobile/src/j5/agents/personaRowActions.test.ts new file mode 100644 index 000000000000..43c5cce82826 --- /dev/null +++ b/apps/mobile/src/j5/agents/personaRowActions.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { personaRowActions } from "./personaRowActions"; + +describe("personaRowActions", () => { + it("offers only Restore for a removed persona, even an editable one", () => { + expect(personaRowActions({ removed: true, editable: true }, true)).toEqual(["restore"]); + }); + + it("offers Edit only for an editable persona, and Copy only with another environment", () => { + expect(personaRowActions({ removed: false, editable: true }, true)).toEqual([ + "edit", + "duplicate", + "export", + "copy", + "remove", + ]); + expect(personaRowActions({ removed: false, editable: false }, false)).toEqual([ + "duplicate", + "export", + "remove", + ]); + }); +}); diff --git a/apps/mobile/src/j5/agents/personaRowActions.ts b/apps/mobile/src/j5/agents/personaRowActions.ts new file mode 100644 index 000000000000..821178aab62f --- /dev/null +++ b/apps/mobile/src/j5/agents/personaRowActions.ts @@ -0,0 +1,16 @@ +export type PersonaRowAction = "edit" | "duplicate" | "export" | "copy" | "remove" | "restore"; + +/** What a Personas settings row offers, in menu order. A removed persona offers only Restore. */ +export function personaRowActions( + persona: { readonly removed: boolean; readonly editable: boolean }, + hasOtherEnvironments: boolean, +): ReadonlyArray { + if (persona.removed) return ["restore"]; + return [ + ...(persona.editable ? (["edit"] as const) : []), + "duplicate", + "export", + ...(hasOtherEnvironments ? (["copy"] as const) : []), + "remove", + ]; +}