Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ migrations after upstream migrations.

102. Mobile's thread list has an Inbox bell with the open count ([#830](https://github.com/Jacksondr5/j5code/issues/830)), as web's rail does. J5-owned `apps/mobile/src/j5/inbox/InboxBell.tsx` reads every connected server's open count (`inboxCountSourcesAtom`, case 101), says it through `inboxBellPresentation` (`packages/client-runtime/src/j5/inbox.ts`, shared with web's bell), and opens the `Inbox` screen. It counts open asks only; web's also counts Crew requests and seat approvals, which come to mobile with Crews. Two headers mount it, each with one import and one or two lines: `apps/mobile/src/features/home/ThreadListToolbar.tsx` (Android) adds it beside `filterButton` in the toolbar row's `filter` slot when a server is saved, and `apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx` adds it as a `Toolbar.Custom` in the right toolbar of the thread list on iPhone and iPad alike (iOS draws its sidebar's header natively, through this toolbar). Android's split view draws its sidebar header with the same `ThreadListToolbar`, so it gets the bell there; no other header holds the thread list's filter. Upstream's symbol set has no plain bell on Android, so J5's `BellGlyph` draws Tabler's there and the SF Symbol on iOS. On a pin advance: if upstream moves the thread list's filter, move the bell with it.

103. Mobile's persona forms are pushed settings pages ([#894](https://github.com/Jacksondr5/j5code/issues/894)), since Android's `Menu` draws in the app's root window and can't appear over an RN `Modal` or upstream's `Sheet`. `apps/mobile/src/Stack.tsx` imports J5-owned `j5PersonaFormRoutes` (`apps/mobile/src/j5/agents/routes.ts`) and spreads it into `SETTINGS_SCREENS` after `SettingsAgents`, adding `SettingsPersonaNew` and `SettingsPersonaEdit`. They follow upstream's `SettingsScheduledTaskNew` and `SettingsScheduledTaskEdit`, including the guard against losing unsaved changes. On a pin advance: if upstream reshapes `SETTINGS_SCREENS`, spread the routes among them again.
103. Mobile's persona forms and Playbook conversation form are pushed settings pages ([#894](https://github.com/Jacksondr5/j5code/issues/894), [#902](https://github.com/Jacksondr5/j5code/issues/902)), since Android's `Menu` draws in the app's root window and can't appear over an RN `Modal` or upstream's `Sheet`. `apps/mobile/src/Stack.tsx` imports J5-owned `j5SettingsFormRoutes` (`apps/mobile/src/j5/agents/routes.ts`) and spreads it into `SETTINGS_SCREENS` after `SettingsAgents`, adding `SettingsPersonaNew`, `SettingsPersonaEdit` and `SettingsPlaybookConversation`. They follow upstream's `SettingsScheduledTaskNew` and `SettingsScheduledTaskEdit`, including the guard against losing unsaved changes. On a pin advance: if upstream reshapes `SETTINGS_SCREENS`, spread the routes among them again.

## Pin and upstream advance runbook

Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { useConnectOnboardingNavigation } from "./features/cloud/connectOnboardi
import { AttachmentFileScreen } from "./features/files/AttachmentFileScreen";
import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
import { j5ThreadArtifactRoutes } from "./j5/artifacts/routes";
import { j5PersonaFormRoutes } from "./j5/agents/routes";
import { j5SettingsFormRoutes } from "./j5/agents/routes";
import { j5InboxRoutes } from "./j5/inbox/routes";
import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
import { selectedPullRequestKey } from "./features/pull-requests/pullRequestSelection";
Expand Down Expand Up @@ -355,7 +355,7 @@ const SETTINGS_SCREENS = {
title: "Personas",
},
}),
...j5PersonaFormRoutes(SETTINGS_PAGE_OPTIONS),
...j5SettingsFormRoutes(SETTINGS_PAGE_OPTIONS),
SettingsProjectGrouping: createNativeStackScreen({
screen: SettingsProjectGroupingRouteScreen,
linking: "settings/project-grouping",
Expand Down
14 changes: 9 additions & 5 deletions apps/mobile/src/j5/agents/AgentCreateScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
import { AgentRoutePolicyFields } from "./AgentDefinitionFields";
import { agentPersonaEnvironment } from "./agentPersonaAtoms";
import { PersonaFormScreen, usePersonaFormExit, usePersonaFormParams } from "./PersonaFormScreen";
import {
SettingsFormScreen,
useSettingsFormExit,
useSettingsFormParams,
} from "./SettingsFormScreen";

type PersonaDraft = {
displayName: string;
Expand All @@ -30,7 +34,7 @@ type PersonaDraft = {

/** Author a personal agent; it is stored as an imported definition of this environment. */
export function AgentCreateScreen() {
const props = usePersonaFormParams<"SettingsPersonaNew">();
const props = useSettingsFormParams<"SettingsPersonaNew">();
const providers = useAtomValue(serverEnvironment.providersValueAtom(props.environmentId));
const catalog = useEnvironmentQuery(
agentPersonaEnvironment.catalog({ environmentId: props.environmentId, input: {} }),
Expand All @@ -56,7 +60,7 @@ export function AgentCreateScreen() {
const [draft, setDraft] = useState(startingDraft);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
const exit = usePersonaFormExit({
const exit = useSettingsFormExit({
hasChanges: JSON.stringify(draft) !== JSON.stringify(startingDraft),
saving,
});
Expand Down Expand Up @@ -102,7 +106,7 @@ export function AgentCreateScreen() {
exit.leaveAfterSave();
}
return (
<PersonaFormScreen
<SettingsFormScreen
title={props.initial ? "Duplicate persona" : "Create persona"}
guarded={exit.guarded}
>
Expand Down Expand Up @@ -197,6 +201,6 @@ export function AgentCreateScreen() {
{saving ? "Creating…" : "Create persona"}
</Text>
</Pressable>
</PersonaFormScreen>
</SettingsFormScreen>
);
}
14 changes: 9 additions & 5 deletions apps/mobile/src/j5/agents/AgentEditorScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import { useEnvironmentQuery } from "../../state/query";
import { useAtomCommand } from "../../state/use-atom-command";
import { AgentRoutePolicyFields } from "./AgentDefinitionFields";
import { agentPersonaEnvironment } from "./agentPersonaAtoms";
import { PersonaFormScreen, usePersonaFormExit, usePersonaFormParams } from "./PersonaFormScreen";
import {
SettingsFormScreen,
useSettingsFormExit,
useSettingsFormParams,
} from "./SettingsFormScreen";

export function AgentEditorScreen() {
const props = usePersonaFormParams<"SettingsPersonaEdit">();
const props = useSettingsFormParams<"SettingsPersonaEdit">();
const [draft, setDraft] = useState(props.initial);
// Instructions are not in the catalog; load them once the page opens.
const [instructions, setInstructions] = useState<string | null>(null);
Expand All @@ -21,7 +25,7 @@ export function AgentEditorScreen() {
const catalog = useEnvironmentQuery(
agentPersonaEnvironment.catalog({ environmentId: props.environmentId, input: {} }),
);
const exit = usePersonaFormExit({
const exit = useSettingsFormExit({
hasChanges:
instructions !== loadedInstructions ||
JSON.stringify(draft) !== JSON.stringify(props.initial),
Expand Down Expand Up @@ -77,7 +81,7 @@ export function AgentEditorScreen() {
exit.leaveAfterSave();
}
return (
<PersonaFormScreen title={"Edit persona"} guarded={exit.guarded}>
<SettingsFormScreen title={"Edit persona"} guarded={exit.guarded}>
<Text className="text-sm text-foreground-muted">
Changes apply to this imported copy and future launches. The original file and existing
tasks stay unchanged.
Expand Down Expand Up @@ -147,6 +151,6 @@ export function AgentEditorScreen() {
{saving ? "Saving…" : "Save changes"}
</Text>
</Pressable>
</PersonaFormScreen>
</SettingsFormScreen>
);
}
4 changes: 2 additions & 2 deletions apps/mobile/src/j5/agents/AgentLibrarySettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AgentImportConflictModal } from "./AgentImportConflictModal";
import { agentPersonaDuplicateDraft } from "@t3tools/client-runtime/j5/agent-personas";
import { AgentDetailsModal } from "./AgentDetailsModal";
import { AgentFolderPickerModal } from "./AgentFolderPickerModal";
import { usePersonaFormNavigation } from "./PersonaFormScreen";
import { useSettingsFormNavigation } from "./SettingsFormScreen";
import { sendWhenReconnected } from "./watchEnvironmentSessions";
import { personaRowActions } from "./personaRowActions";
import { Menu } from "../../components/ui/Menu";
Expand Down Expand Up @@ -131,7 +131,7 @@ function OwnerAgentLibrarySettingsScreen() {
} | null>(null);
// oxlint-disable-next-line t3code/react-effect-budget -- a replaced or unmounted confirmation resolves its waiting import as cancelled.
useEffect(() => () => confirmation?.resolve(null), [confirmation]);
const navigation = usePersonaFormNavigation();
const navigation = useSettingsFormNavigation();
const [notification, setNotification] = useState<AgentLibraryNotification | null>(null);
const [viewing, setViewing] = useState<string | null>(null);
const dismissNotification = useCallback(() => setNotification(null), []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@react-navigation/native";
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
import type { AgentPersonaCreateDraft } from "@t3tools/client-runtime/j5/agent-personas";
import type { AgentPersonaEditInput, EnvironmentId } from "@t3tools/contracts";
import type { AgentPersonaEditInput, EnvironmentId, ProjectId } from "@t3tools/contracts";
import { useRef, type ReactNode } from "react";
import { KeyboardAvoidingView, Platform } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
Expand All @@ -17,7 +17,7 @@ import { withNativeGlassHeaderItem } from "../../features/layout/native-glass-he
import { SettingsScreen } from "../../features/settings/components/SettingsScreen";
import { NativeStackScreenOptions } from "../../native/StackHeader";

export type PersonaFormRoutes = {
export type SettingsFormRoutes = {
SettingsPersonaNew: {
readonly environmentId: EnvironmentId;
/** Prefill from an existing persona (Duplicate); the ID is treated as user-chosen. */
Expand All @@ -27,18 +27,24 @@ export type PersonaFormRoutes = {
readonly environmentId: EnvironmentId;
readonly initial: Omit<AgentPersonaEditInput, "instructions">;
};
SettingsPlaybookConversation: {
readonly environmentId: EnvironmentId;
readonly name: string | null;
/** The project Settings is showing, so a project playbook's chat opens where it lives. */
readonly projectId: ProjectId | null;
};
};

export function usePersonaFormNavigation() {
return useNavigation<NativeStackNavigationProp<PersonaFormRoutes>>();
export function useSettingsFormNavigation() {
return useNavigation<NativeStackNavigationProp<SettingsFormRoutes>>();
}

export function usePersonaFormParams<Name extends keyof PersonaFormRoutes>() {
return useRoute<RouteProp<PersonaFormRoutes, Name>>().params as PersonaFormRoutes[Name];
export function useSettingsFormParams<Name extends keyof SettingsFormRoutes>() {
return useRoute<RouteProp<SettingsFormRoutes, Name>>().params as SettingsFormRoutes[Name];
}

/** Asks before unsaved changes are lost, and returns how to leave once they are saved. */
export function usePersonaFormExit(options: {
/** Asks before unsaved changes are lost, and returns how to leave once the work is done. */
export function useSettingsFormExit(options: {
readonly hasChanges: boolean;
readonly saving: boolean;
}) {
Expand All @@ -52,7 +58,7 @@ export function usePersonaFormExit(options: {
return;
}
if (options.saving) {
Dialog.alert("Saving persona", "Wait for the persona to finish saving before leaving.");
Dialog.alert("Still working", "Wait for this to finish before leaving.");
return;
}
Dialog.alert("Discard changes?", "Your unsaved changes will be lost.", [
Expand All @@ -66,6 +72,10 @@ export function usePersonaFormExit(options: {
});
return {
guarded,
/** For a form that leaves by its own navigation action. */
allowLeaving: () => {
saved.current = true;
},
leaveAfterSave: () => {
saved.current = true;
if (navigation.isFocused()) navigation.goBack();
Expand All @@ -74,7 +84,7 @@ export function usePersonaFormExit(options: {
}

/** A pushed settings page, because Android's Menu can't draw over an RN Modal or Sheet. */
export function PersonaFormScreen(props: {
export function SettingsFormScreen(props: {
readonly title: string;
readonly guarded: boolean;
readonly children: ReactNode;
Expand Down
9 changes: 7 additions & 2 deletions apps/mobile/src/j5/agents/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { createNativeStackScreen } from "@react-navigation/native-stack";

import { AgentCreateScreen } from "./AgentCreateScreen";
import { AgentEditorScreen } from "./AgentEditorScreen";
import { PlaybookConversationScreen } from "../playbooks/PlaybookConversationScreen";

/** The persona forms, beside upstream's settings pages (FORK.md case 103). */
export const j5PersonaFormRoutes = <Options extends object>(options: Options) => ({
/** The Personas page's forms, beside upstream's settings pages (FORK.md case 103). */
export const j5SettingsFormRoutes = <Options extends object>(options: Options) => ({
SettingsPersonaNew: createNativeStackScreen({
screen: AgentCreateScreen,
options: { ...options, title: "Create persona" },
Expand All @@ -13,4 +14,8 @@ export const j5PersonaFormRoutes = <Options extends object>(options: Options) =>
screen: AgentEditorScreen,
options: { ...options, title: "Edit persona" },
}),
SettingsPlaybookConversation: createNativeStackScreen({
screen: PlaybookConversationScreen,
options: { ...options, title: "Prepare chat" },
}),
});
Loading
Loading