From b24b2b7e8a2f9445f28e432c6d052fd390ccd178 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sun, 8 Nov 2026 23:30:29 -0500 Subject: [PATCH 1/4] fix(mobile): toggling a persona keeps the list on screen while it rereads Every reread after a toggle swapped the list for "Loading personas" and back. The loading row now shows only before the first load; library sources follow the same rule. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index 1d6d194a59902..592e50072e786 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -506,7 +506,7 @@ function OwnerAgentLibrarySettingsScreen() { > {effectiveEnvironmentId === null ? ( - ) : catalog.isPending ? ( + ) : catalog.isPending && catalog.data == null ? ( ) : catalog.error ? ( @@ -554,7 +554,7 @@ function OwnerAgentLibrarySettingsScreen() { : "Folders this environment reads YAML definitions from, on its machine; relative paths resolve from its state directory. Files are read on every catalog request, so edits and git pulls apply without a restart." } > - {librarySources.isPending ? ( + {librarySources.isPending && librarySources.data == null ? ( ) : librarySources.error ? ( From a16c3d7860de618c0520aa58854bd6b0f5052699 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sun, 8 Nov 2026 23:45:29 -0500 Subject: [PATCH 2/4] fix(mobile): a persona switch holds its new value until the list shows it With the list kept on screen, the controlled Switch visibly snapped back to the old value while the toggle saved and the list reread. The row now holds the tapped value until the catalog matches, and drops it if the toggle fails, so the switch reverts and the error toast explains why. Co-Authored-By: Claude Opus 5.5 --- .../j5/agents/AgentLibrarySettingsScreen.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index 592e50072e786..e5b508fcfb853 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -237,8 +237,9 @@ function OwnerAgentLibrarySettingsScreen() { const setAgentEnabled = useAtomCommand(agentPersonaEnvironment.setAgentPersonaEnabled, { reportFailure: false, }); - async function toggleAgent(personaId: string, enabled: boolean) { - if (effectiveEnvironmentId === null || busy) return; + /** Resolves whether the server took the change, so the row can drop its pending value. */ + async function toggleAgent(personaId: string, enabled: boolean): Promise { + if (effectiveEnvironmentId === null || busy) return false; setBusy(true); const result = await setAgentEnabled({ environmentId: effectiveEnvironmentId, @@ -247,9 +248,10 @@ function OwnerAgentLibrarySettingsScreen() { setBusy(false); if (result._tag === "Failure") { setNotification(failureNotice("Persona action failed", result)); - return; + return false; } catalog.refresh(); + return true; } async function removePersona(personaId: string) { if (effectiveEnvironmentId === null || busy) return; @@ -520,7 +522,7 @@ function OwnerAgentLibrarySettingsScreen() { borderTop={index > 0} locked={locked} busy={busy} - onToggle={(enabled) => void toggleAgent(persona.personaId, enabled)} + onToggle={(enabled) => toggleAgent(persona.personaId, enabled)} onOpen={() => setViewing(persona.personaId)} /> )) @@ -679,10 +681,15 @@ function PersonaRow(props: { readonly borderTop: boolean; readonly locked: boolean; readonly busy: boolean; - readonly onToggle: (enabled: boolean) => void; + readonly onToggle: (enabled: boolean) => Promise; readonly onOpen: () => void; }) { const { persona } = props; + // The tapped value holds until the reread catalog shows it; a controlled Switch otherwise snaps + // back to the old value while the toggle saves. A failed toggle drops it, so the row reverts. + const [pending, setPending] = useState(null); + const enabled = pending ?? persona.enabled; + if (pending !== null && pending === persona.enabled) setPending(null); const marker = personaRowMarker({ removed: persona.removed, blocked: @@ -708,9 +715,7 @@ function PersonaRow(props: { > {persona.displayName} @@ -731,10 +736,15 @@ function PersonaRow(props: { { + setPending(next); + void props.onToggle(next).then((saved) => { + if (!saved) setPending(null); + }); + }} /> )} From 9171c7aa3b68ff906927deb7112e3239528b2cf9 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Sun, 8 Nov 2026 23:49:03 -0500 Subject: [PATCH 3/4] fix(mobile): a persona switch waits for its change to land before taking another A second tap before the reread arrived could clear the pending value and let the first reread snap the switch back. The row's switch stays disabled while it holds a pending value. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index e5b508fcfb853..fd9f80057a7a3 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -737,7 +737,8 @@ function PersonaRow(props: { // React Native's Switch sets alignSelf: flex-start, which ignores the row's centring. style={{ alignSelf: "center" }} value={enabled} - disabled={props.locked} + // One change at a time: a second tap before the reread lands would race it. + disabled={props.locked || pending !== null} accessibilityLabel={`Enable ${persona.displayName}`} onValueChange={(next) => { setPending(next); From e6e39622e3cb6d836b6e87cb7ef9d1409cb3e561 Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Mon, 9 Nov 2026 01:23:53 -0500 Subject: [PATCH 4/4] fix(mobile): a persona row's pending switch value stays with its environment Rows were keyed by persona ID alone, so switching environments mid-toggle could reuse a row and carry the other environment's pending value. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx index fd9f80057a7a3..2bf02bcc28e57 100644 --- a/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx +++ b/apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx @@ -517,7 +517,8 @@ function OwnerAgentLibrarySettingsScreen() { ) : ( personas.map((persona, index) => ( 0} locked={locked}