diff --git a/FORK.md b/FORK.md index 8b2ece080e017..55ced1e62b4f6 100644 --- a/FORK.md +++ b/FORK.md @@ -481,7 +481,7 @@ migrations after upstream migrations. - `apps/web/src/components/BranchToolbarBranchSelector.tsx`: imports `useCanOperateThread`; `canOperateThread`, which gates only the branch change, is `useCanOperateThread(environmentId, threadId)` in place of upstream's server-wide "Operate tasks". - `apps/web/src/components/GitActionsControl.tsx`: imports `useCanOperateThread` and adds `canOperateThisThread` beside upstream's `canOperateThread`; `canChangeThreadBranch` ("Commit on new branch" and "Check out feature branch & continue") reads it in place of `canOperateThread`. Upstream's `canOperateThread` still gates the commit dialog's Open in editor buttons. Upstream's `GitActionsControl.browser.test.tsx` needs no J5 mock: it mocks `useEnvironmentScope`, which the hook reads, and access that has not loaded withholds nothing. - Folder actions (commit, push, pull, Open in editor) are left to upstream's permissions: the server allows them to anyone who holds Collaborator at any scope (case 69, Jackson 2026-10-17), and a Viewer everywhere does not hold them. Mobile is not covered, with the rest of sharing on mobile ([#609](https://github.com/Jacksondr5/j5code/issues/609)). Proof: `packages/client-runtime/src/j5/sharing.test.ts`, "what a connection may start"; `apps/web/src/j5/sharing/sharingMenu.test.ts`, "a new thread from the thread menu"; and `apps/web/src/j5/sharing/startableProjects.test.ts`. On a pin advance: if upstream adds a door to a new thread, a fork or a project, add the call beside it; if upstream starts gating a new thread on its own permission, keep J5's call beside upstream's; if upstream renames `newThreadDisabled`, `handleNewThreadClick`, `handleCreateThreadClick`, `startNewThreadFromContext`, `openProjectFromSearch`, `projectSearchItems`, `scratchEnvironmentId`, `canCreateProject`, `canSubmitNewProject`, `canChangeThreadBranch`, `AssistantForkButton` or `canMerge`, or changes how `buildSidebarProjectPickerEntries` picks a group's checkout, move the call with it. + Folder actions (commit, push, pull, Open in editor) are left to upstream's permissions: the server allows them to anyone who holds Collaborator at any scope (case 69, Jackson 2026-10-17), and a Viewer everywhere does not hold them. On mobile ([#831](https://github.com/Jacksondr5/j5code/issues/831)) the same rule reaches upstream's doors through J5-owned `apps/mobile/src/j5/sharing/startAccess.ts`, each edit one import and one or two lines: `features/threads/new-task-flow-provider.tsx` builds `startableProjects = useStartableProjects(projects)` and uses it for the picker's scopes, the fresh default server and project, and the servers offered when switching, while an explicit or stamped selection still resolves against every project, so a draft stamped with a project the person cannot start in opens there, read-only, instead of moving to another project; `features/layout/AdaptiveWorkspaceLayout.tsx`, whose `handleStartNewTask` every New thread door and the keyboard command go through, and `ThreadRouteScreen.tsx`'s `UnavailableThreadDraftRedirect` pass `newTaskDestination` the startable projects only, so a new task never lands in a project the person cannot start in; `features/threads/NewTaskRouteScreen.tsx` shows `noStartableProjectState` ("Nothing to start a thread in") in place of upstream's "No projects found" when the server reports projects but none of them; `features/threads/NewTaskDraftScreen.tsx` reads `useCanStartTaskIn` for `canOperate` and `readCanStartTaskIn` in `handleStart`'s guard, each in place of upstream's "Operate tasks" check, which both include; `features/threads/ThreadFeed.tsx`'s `AssistantForkButton` also asks `useCanForkThread`; and `features/projects/AddProjectScreen.tsx` reads `useCanAddProject` for its three `canCreateProject` values in place of upstream's "Operate tasks", which it includes, disables the New project row on it too, and `AddProjectNewScreen` reads it for its Create button and `submit` guard. `src/lib/filePreview.test.ts`, which renders `ThreadFeed` with its state mocked, and `features/projects/AddProjectScreen.test.ts`, which tests upstream's permission gating, mock `startAccess` too (the latter as upstream's "Operate tasks" alone). Proof: `packages/client-runtime/src/j5/sharing.test.ts`, "what a connection may start"; `apps/web/src/j5/sharing/sharingMenu.test.ts`, "a new thread from the thread menu"; and `apps/web/src/j5/sharing/startableProjects.test.ts`. On a pin advance: if upstream adds a door to a new thread, a fork or a project, add the call beside it; if upstream starts gating a new thread on its own permission, keep J5's call beside upstream's; if upstream renames `newThreadDisabled`, `handleNewThreadClick`, `handleCreateThreadClick`, `startNewThreadFromContext`, `openProjectFromSearch`, `projectSearchItems`, `scratchEnvironmentId`, `canCreateProject`, `canSubmitNewProject`, `canChangeThreadBranch`, `AssistantForkButton` or `canMerge`, or changes how `buildSidebarProjectPickerEntries` picks a group's checkout, move the call with it. 91. A shared conversation's lines stay off upstream's surfaces that read a stored message ([#612](https://github.com/Jacksondr5/j5code/issues/612), Jackson's 2026-10-26 decision: keep storing the lines, which the agent reads, and take them off where upstream shows or reuses the text). Each surface takes off exactly a message's recorded `j5_a2a_message_author.stored_prefix` (case 80), never text guessed from its format; a message with no record, or whose text does not begin with it, is read as stored. What the agent receives is unchanged. @@ -724,15 +724,21 @@ explicitly marked. | `apps/desktop/src/wsl/DesktopWslServerTree.test.ts` | R | B | | `apps/mobile/app.config.ts` | A | B | | `apps/mobile/package.json` | A | B, 45 | -| `apps/mobile/src/features/threads/NewTaskDraftScreen.tsx` | A | 45, Saved-agent mentions | +| `apps/mobile/src/features/threads/NewTaskDraftScreen.tsx` | A | 45, 90, Saved-agent mentions | | `apps/mobile/src/features/threads/ThreadDetailScreen.tsx` | A | 45, 49 | -| `apps/mobile/src/features/threads/ThreadRouteScreen.tsx` | A | 69, 99 | +| `apps/mobile/src/features/threads/ThreadRouteScreen.tsx` | A | 69, 90, 99 | | `apps/mobile/src/features/settings/SettingsRouteScreen.tsx` | A | 72, Role library | | `apps/mobile/src/features/settings/components/SettingsScreen.tsx` | N | 72 | | `apps/mobile/src/features/settings/settings-environment-filter.tsx` | N | 72 | | `apps/mobile/src/Stack.tsx` | A | 72, 98, Role library | | `apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx` | N | 72 | -| `apps/mobile/src/features/threads/new-task-flow-provider.tsx` | A | 45 | +| `apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx` | N | 90 | +| `apps/mobile/src/features/threads/ThreadFeed.tsx` | N | 90 | +| `apps/mobile/src/features/threads/NewTaskRouteScreen.tsx` | N | 90 | +| `apps/mobile/src/features/projects/AddProjectScreen.tsx` | N | 90 | +| `apps/mobile/src/lib/filePreview.test.ts` | N | 90 | +| `apps/mobile/src/features/projects/AddProjectScreen.test.ts` | N | 90 | +| `apps/mobile/src/features/threads/new-task-flow-provider.tsx` | A | 45, 90 | | `apps/mobile/src/features/threads/use-composer-command-menu.ts` | A | 45, 49 | | `apps/mobile/src/features/threads/use-composer-command-menu.test.ts` | A | 45, 49 | | `apps/mobile/src/state/use-thread-composer-state.ts` | A | 45 | diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx index 8ecbdce270938..7a49587b246e6 100644 --- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx @@ -70,6 +70,7 @@ import { startOpeningDetail } from "../workspace/useSelectWorkspaceDetail"; import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext"; import { HomeListOptionsProvider } from "../home/home-list-options"; import { newTaskDestination } from "../threads/new-task-project-selection"; +import { useStartableProjects } from "../../j5/sharing/startAccess"; import { usePendingTaskListActions } from "../home/usePendingTaskListActions"; import { ThreadNavigationSidebar } from "../threads/ThreadNavigationSidebar"; import { useOpenThreadPullRequests } from "../threads/use-open-thread-pull-requests"; @@ -508,7 +509,8 @@ function AdaptiveWorkspaceLayoutContent( const handleSelectThreadRoute = (params: ReactNavigation.RootParamList["Thread"]) => handleSelectDetail({ name: "Thread", params }); - const projects = useProjects(); + // J5: a new task opens in a project the person may start a thread in (FORK.md case 90). + const projects = useStartableProjects(useProjects()); const compactAndroidSettings = Platform.OS === "android" && androidSettingsOpen && !layout.usesSplitView; // Reads the open page when pressed, so the layout context doesn't change on every navigation. diff --git a/apps/mobile/src/features/projects/AddProjectScreen.test.ts b/apps/mobile/src/features/projects/AddProjectScreen.test.ts index 3331f8e644084..dc3a34b49c70a 100644 --- a/apps/mobile/src/features/projects/AddProjectScreen.test.ts +++ b/apps/mobile/src/features/projects/AddProjectScreen.test.ts @@ -106,6 +106,10 @@ vi.mock("../../state/session", () => ({ useEnvironmentScope: (_environmentId: string, scope: string) => state.scopes.has(scope), readEnvironmentScope: (_environmentId: string, scope: string) => state.scopes.has(scope), })); +// J5: a person's level is not what this tests, so adding a project needs only "Operate tasks". +vi.mock("../../j5/sharing/startAccess", () => ({ + useCanAddProject: () => state.scopes.has(AuthOrchestrationOperateScope), +})); vi.mock("../../state/entities", () => ({ useProjects: () => state.existingProjects, waitForProject: state.waitForProject, diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx index 49de8d219ba2b..070ebaef1de06 100644 --- a/apps/mobile/src/features/projects/AddProjectScreen.tsx +++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx @@ -94,6 +94,7 @@ import { useSavedRemoteConnections, } from "../../state/use-remote-environment-registry"; import { resolveAddProjectEnvironment } from "./AddProjectScreen.logic"; +import { useCanAddProject } from "../../j5/sharing/startAccess"; import { createNewTaskDraft, setComposerDraftText, @@ -517,10 +518,7 @@ export function AddProjectSourceScreen(props: { readonly environmentId?: string selectedEnvironment?.environmentId ?? null, AuthSourceControlWriteScope, ); - const canCreateProject = useEnvironmentScope( - selectedEnvironment?.environmentId ?? null, - AuthOrchestrationOperateScope, - ); + const canCreateProject = useCanAddProject(selectedEnvironment?.environmentId ?? null); const isConnected = canCreateProjectInEnvironment(selectedEnvironment?.connectionState); const canCloneProject = isConnected && canWriteSourceControl && canCreateProject; const discoveryState = useEnvironmentQuery( @@ -588,7 +586,7 @@ export function AddProjectSourceScreen(props: { readonly environmentId?: string { - if (!environment || trimmedName.length === 0 || submittingRef.current) return; + if (!environment || !canCreateProject || trimmedName.length === 0 || submittingRef.current) + return; const originRoute = getActiveRoute(navigation); submittingRef.current = true; setError(null); @@ -1204,7 +1205,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s ) : null} void submit()} loading={isSubmitting} /> @@ -1240,10 +1241,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s export function AddProjectLocalFolderScreen(props: { readonly environmentId?: string | string[] }) { const environment = useEnvironmentFromParam(props.environmentId); - const canCreateProject = useEnvironmentScope( - environment?.environmentId ?? null, - AuthOrchestrationOperateScope, - ); + const canCreateProject = useCanAddProject(environment?.environmentId ?? null); const createProject = useCreateProject(environment); const { isBrowseNavigating, navigateToBrowsePath, pathInput, setPathInput } = useBrowsePathInput(environment); @@ -1320,10 +1318,7 @@ export function AddProjectDestinationScreen(props: { environment?.environmentId ?? null, AuthSourceControlWriteScope, ); - const canCreateProject = useEnvironmentScope( - environment?.environmentId ?? null, - AuthOrchestrationOperateScope, - ); + const canCreateProject = useCanAddProject(environment?.environmentId ?? null); const canCloneProject = canWriteSourceControl && canCreateProject; const createProject = useCreateProject(environment); const remoteUrl = stringParam(props.remoteUrl); diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index c3fd1f06e0ecb..d5cf9a337065f 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -31,7 +31,6 @@ import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScroll import { KeyboardController } from "react-native-keyboard-controller"; import { - AuthOrchestrationOperateScope, PROVIDER_SEND_TURN_MAX_ATTACHMENTS, resolveEnvironmentMachineKind, } from "@t3tools/contracts"; @@ -96,7 +95,7 @@ import { selectIncomingShareAttachmentsForServer } from "../sharing/incoming-sha import { appAtomRegistry } from "../../state/atom-registry"; import { serverEnvironment } from "../../state/server"; -import { readEnvironmentScope, useEnvironmentScope } from "../../state/session"; +import { readCanStartTaskIn, useCanStartTaskIn } from "../../j5/sharing/startAccess"; import { AgentDraftPicker } from "../../j5/agents/AgentDraftPicker"; import { clearDraftAgent } from "../../j5/agents/agentDraftState"; import { useDraftAgentAssignment } from "../../j5/agents/useDraftAgentAssignment"; @@ -189,9 +188,10 @@ export function NewTaskDraftScreen(props: { selectedProject?.environmentId ?? null, ); const environmentConnected = connectionState === "connected"; - const canOperate = useEnvironmentScope( + // J5: starting needs the person's level over the project too (FORK.md case 90). + const canOperate = useCanStartTaskIn( selectedProject?.environmentId ?? null, - AuthOrchestrationOperateScope, + selectedProject?.id ?? null, ); const projectCloneState = useProjectClone( selectedProject @@ -801,7 +801,7 @@ export function NewTaskDraftScreen(props: { } if ( environmentConnected && - !readEnvironmentScope(selectedProject.environmentId, AuthOrchestrationOperateScope) + !readCanStartTaskIn(selectedProject.environmentId, selectedProject.id) ) { return null; } diff --git a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx index 01b3ed0c0f49f..de78fb0ee362c 100644 --- a/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskRouteScreen.tsx @@ -38,6 +38,7 @@ import { useIncomingShare } from "../sharing/IncomingShareProvider"; import { useNewTaskFlow } from "./new-task-flow-provider"; import { filterProjectScopes, getProjectScopeSelectionTarget } from "./new-task-project-selection"; import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail"; +import { noStartableProjectState } from "../../j5/sharing/startAccess"; type NewTaskRouteParams = { readonly incomingShareId?: string | string[]; @@ -172,7 +173,12 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps attachment.type === "image") ? "images" : "files"} you shared` : null; const screenTitle = incomingShare ? "Start a task" : "Choose project"; - const projectEmptyState = deriveProjectEmptyState(catalogState); + // J5: projects the person may not start a thread in are left out (FORK.md case 90). + const projectEmptyState = + noStartableProjectState({ + projectCount: projects.length, + startableScopeCount: projectScopes.length, + }) ?? deriveProjectEmptyState(catalogState); const serverConfigs = useServerConfigs(); const listScopes = projectScopes.filter( (scope) => diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index 21947e59d246e..9728cdba47e4d 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -260,6 +260,7 @@ import { onArtifactLinkMenuAction, openArtifactLink, } from "../../j5/artifacts/artifactLinks"; +import { useCanForkThread } from "../../j5/sharing/startAccess"; import { resolveUserMessageIntentBadge } from "./userMessageIntentBadge"; import { fileChipClipboardPath, fileChipMenu, resolveFileChipTarget } from "./fileChipMenu"; import { useFileChipShare } from "./useFileChipShare"; @@ -438,8 +439,10 @@ function AssistantForkButton(props: { capabilities: support.providerSession?.capabilities, }); const runId = props.projectedItem.item.runId; + // J5: a fork is a new thread in the project, which the person's level there decides (case 90). + const levelAllowsFork = useCanForkThread(props.environmentId, props.projectedItem.sourceThreadId); - if (!canFork || runId === null) return null; + if (!canFork || !levelAllowsFork || runId === null) return null; return ( { const project = projects.find((candidate) => candidate.environmentId === props.environmentId); diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsx index d9c22462ff0ee..95de0574c62b2 100644 --- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx +++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx @@ -94,6 +94,7 @@ import { resolveEnvironmentProjectMatch } from "./new-task-project-selection"; import { useNewTaskProjectDefaults } from "./use-new-task-project-defaults"; import { resolveProjectThreadCreationBranch } from "./projectThreadCreationValidation"; import { readDraftAgentPersonaId } from "../../j5/agents/agentDraftState"; +import { useStartableProjects } from "../../j5/sharing/startAccess"; type WorkspaceMode = "local" | "worktree"; @@ -203,6 +204,9 @@ export function NewTaskFlowProvider( }>, ) { const projects = useProjects(); + // J5: the picker and a fresh default offer only the projects the person may start a thread in; + // an explicit or stamped selection still resolves against every project, read-only (case 90). + const startableProjects = useStartableProjects(projects); const threads = useThreadShells(); const { savedConnectionsById } = useSavedRemoteConnections(); const groupingSettings = useMobileProjectGroupingSettings(); @@ -210,7 +214,7 @@ export function NewTaskFlowProvider( const projectScopes = sortHomeProjectScopes({ scopes: buildHomeProjectScopes({ - projects, + projects: startableProjects, environmentId: null, projectGroupingMode: groupingSettings.sidebarProjectGroupingMode, }), @@ -226,7 +230,7 @@ export function NewTaskFlowProvider( selectedEnvironmentIdOverride !== null && projects.some((project) => project.environmentId === selectedEnvironmentIdOverride) ? selectedEnvironmentIdOverride - : (projects[0]?.environmentId ?? null); + : (startableProjects[0]?.environmentId ?? null); const [selectedProjectKey, setSelectedProjectKey] = useState(null); const [activeDraftKey, setActiveDraftKey] = useState(null); const [submitting, setSubmitting] = useState(false); @@ -249,7 +253,7 @@ export function NewTaskFlowProvider( projectsForEnvironment.find( (project) => scopedProjectKey(project.environmentId, project.id) === selectedProjectKey, ) ?? - projectsForEnvironment[0] ?? + startableProjects.find((project) => project.environmentId === selectedEnvironmentId) ?? null; const projectDefaults = useNewTaskProjectDefaults(selectedProject); @@ -298,7 +302,7 @@ export function NewTaskFlowProvider( (selectedProjectTitle !== null && project.title === selectedProjectTitle) ); }; - for (const project of projects) { + for (const project of startableProjects) { if (!hostsSelectedRepository(project)) { continue; } @@ -566,7 +570,7 @@ export function NewTaskFlowProvider( const selectEnvironment = (environmentId: EnvironmentId) => { const match = resolveEnvironmentProjectMatch( - projects.filter((project) => project.environmentId === environmentId), + startableProjects.filter((project) => project.environmentId === environmentId), selectedProject, ); if (match) { diff --git a/apps/mobile/src/j5/sharing/startAccess.ts b/apps/mobile/src/j5/sharing/startAccess.ts new file mode 100644 index 0000000000000..fad6e84e75a11 --- /dev/null +++ b/apps/mobile/src/j5/sharing/startAccess.ts @@ -0,0 +1,96 @@ +import { useAtomValue } from "@effect/atom-react"; +import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { type KnownConnectionAccess, sharingAllowsStart } from "@t3tools/client-runtime/j5/sharing"; +import { + AuthOrchestrationOperateScope, + type EnvironmentId, + type ProjectId, + type ThreadId, +} from "@t3tools/contracts"; +import { Atom } from "effect/reactivity"; +import { useMemo } from "react"; + +import { environmentCatalog } from "../../connection/catalog"; +import { appAtomRegistry } from "../../state/atom-registry"; +import { useThreadShell } from "../../state/entities"; +import { readEnvironmentScope, useEnvironmentScope } from "../../state/session"; +import { j5Sharing } from "./guestAccess"; + +// Where this connection may start something, read across every saved server at once. A server +// not yet in the catalog, or not yet answered, withholds nothing; the server checks every start. +const startsAtom = Atom.make((get) => { + const accessById = new Map(); + for (const id of get(environmentCatalog.catalogValueAtom).entries.keys()) { + accessById.set(id, get(j5Sharing.connectionAccess(id))); + } + return (environmentId: EnvironmentId, projectId: ProjectId | null) => + sharingAllowsStart(accessById.get(environmentId) ?? null, projectId); +}).pipe(Atom.withLabel("mobile-j5:access:starts")); + +/** + * Whether this connection may start a thread in a project: upstream's "Operate tasks", and a + * Collaborator's or Owner's level over the project or the server (People and access AC14). A + * Viewer, or a Collaborator on one thread, is not offered a thread the server would refuse. + */ +export function useCanStartTaskIn( + environmentId: EnvironmentId | null, + projectId: ProjectId | null, +): boolean { + const permitted = useEnvironmentScope(environmentId, AuthOrchestrationOperateScope); + const starts = useAtomValue(startsAtom); + return permitted && (environmentId === null || starts(environmentId, projectId)); +} + +/** `useCanStartTaskIn` read when called, for a send that runs outside render. */ +export function readCanStartTaskIn(environmentId: EnvironmentId, projectId: ProjectId): boolean { + return ( + readEnvironmentScope(environmentId, AuthOrchestrationOperateScope) && + appAtomRegistry.get(startsAtom)(environmentId, projectId) + ); +} + +/** Keeps the projects this connection may start a thread in, for the New thread project picker. */ +export function useStartableProjects< + Project extends { readonly environmentId: EnvironmentId; readonly id: ProjectId }, +>(projects: ReadonlyArray): ReadonlyArray { + const starts = useAtomValue(startsAtom); + return useMemo( + () => projects.filter((project) => starts(project.environmentId, project.id)), + [projects, starts], + ); +} + +/** + * Whether this connection may add a project to a server: upstream's "Operate tasks", and a + * Collaborator's or Owner's level at server scope (AC19). + */ +export function useCanAddProject(environmentId: EnvironmentId | null): boolean { + return useCanStartTaskIn(environmentId, null); +} + +/** + * Whether this connection may fork a thread. A fork is a new thread in the thread's project, so + * the project's level decides, not the thread's. + */ +export function useCanForkThread(environmentId: EnvironmentId, threadId: ThreadId): boolean { + const projectId = useThreadShell(scopeThreadRef(environmentId, threadId))?.projectId ?? null; + const starts = useAtomValue(startsAtom); + return starts(environmentId, projectId); +} + +/** + * What New thread's project picker says when the server reports projects but the person may start + * a thread in none of them, in place of upstream's "No projects found". + */ +export function noStartableProjectState(input: { + readonly projectCount: number; + readonly startableScopeCount: number; +}): { readonly title: string; readonly detail: string; readonly loading: false } | null { + if (input.projectCount === 0 || input.startableScopeCount > 0) return null; + return { + title: "Nothing to start a thread in", + detail: + "You can write only in the threads shared with you. To start one, ask an Owner to share a project with you.", + loading: false, + }; +} diff --git a/apps/mobile/src/j5/upstreamSeams.test.ts b/apps/mobile/src/j5/upstreamSeams.test.ts index 138b38a59b350..267a29f986919 100644 --- a/apps/mobile/src/j5/upstreamSeams.test.ts +++ b/apps/mobile/src/j5/upstreamSeams.test.ts @@ -244,6 +244,59 @@ const SEAMS: ReadonlyArray = [ from: "../../j5/sharing/settingsAccess", reaches: ["useOwnedSettingsTargets(connectedSettingsTargets(environments))"], }, + { + file: "features/threads/new-task-flow-provider.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: [ + "useStartableProjects(projects)", + "projects: startableProjects", + "startableProjects.find((project) => project.environmentId === selectedEnvironmentId)", + ], + }, + { + file: "features/threads/NewTaskRouteScreen.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: ["noStartableProjectState({"], + }, + { + file: "features/threads/NewTaskDraftScreen.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: [ + "useCanStartTaskIn(", + "readCanStartTaskIn(selectedProject.environmentId, selectedProject.id)", + ], + }, + { + file: "features/threads/ThreadFeed.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: ["useCanForkThread(props.environmentId, props.projectedItem.sourceThreadId)"], + }, + { + file: "features/projects/AddProjectScreen.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: [ + "useCanAddProject(selectedEnvironment?.environmentId ?? null)", + "disabled={!isConnected || !canCreateProject}", + "disabled={isSubmitting || !canCreateProject || trimmedName.length === 0}", + ], + }, + { + file: "features/layout/AdaptiveWorkspaceLayout.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: ["const projects = useStartableProjects(useProjects());"], + }, + { + file: "features/threads/ThreadRouteScreen.tsx", + record: "case 90: starting follows the person's level", + from: "../../j5/sharing/startAccess", + reaches: ["const projects = useStartableProjects(useProjects());"], + }, { file: "App.tsx", record: "BRANDING.md: mobile OS identity and links", diff --git a/apps/mobile/src/lib/filePreview.test.ts b/apps/mobile/src/lib/filePreview.test.ts index af9f547e2fd14..d3a31181c16d7 100644 --- a/apps/mobile/src/lib/filePreview.test.ts +++ b/apps/mobile/src/lib/filePreview.test.ts @@ -180,6 +180,7 @@ vi.mock("../j5/a2a/timelineState", () => ({ }), })); vi.mock("../j5/sharing/sharedConversation", () => ({ PromptAnsweredBy: () => null })); +vi.mock("../j5/sharing/startAccess", () => ({ useCanForkThread: () => true })); vi.mock("../state/threads", () => ({ environmentThreadShells: {}, threadEnvironment: {} })); vi.mock("../state/entities", () => ({ useLiveThreadLinkLabels: (text: string) => text,