diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx
index 5d22ed78ebdb..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 {
@@ -24,10 +25,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 +37,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 +314,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}
-
-
- );
- })}
-
-
+
) : 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.
-
- ) : (
-
-
-
- )}
-
-
-
-
- {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,
- });
- }}
- >
-
-
- >
- )}
-
- {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 +527,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 +561,7 @@ function OwnerAgentLibrarySettingsScreen() {
}}
/>
) : null}
-
+
);
}
@@ -858,10 +595,247 @@ 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.title}
+
+
+ {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 actions = personaRowActions(
+ { removed: persona.removed, editable: props.onEdit !== null },
+ props.otherEnvironments.length > 0,
+ );
+ const onEdit = actions.includes("edit") ? props.onEdit : null;
+ const content = (
+ <>
+
+ {persona.displayName}
+
+
+ {status}
+
+ {unavailable && persona.blockedReasons[0] ? (
+
+ {persona.blockedReasons[0]}
+
+ ) : null}
+ >
+ );
+ return (
+
+ {onEdit ? (
+
+ {content}
+
+ ) : (
+
+ {content}
+
+ )}
+ {persona.removed ? null : (
+
+ )}
+
+
+ );
+}
+
+/** 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 (
+
+
+
+ {folder.configuredPath}
+
+ {folder.path !== folder.configuredPath ? (
+
+ {folder.path}
+
+ ) : null}
+
+ {agentPersonaFolderStatusLabel(folder, props.configured)}
+
+ {nudges.map((nudge) => (
+
+ {nudge}
+
+ ))}
+
+
);
}
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",
+ ];
+}
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}