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
14 changes: 10 additions & 4 deletions FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/src/features/projects/AddProjectScreen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 10 additions & 15 deletions apps/mobile/src/features/projects/AddProjectScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -588,7 +586,7 @@ export function AddProjectSourceScreen(props: { readonly environmentId?: string
<ListRow
title="New project"
subtitle="Start a new Git repository from a name"
disabled={!isConnected}
disabled={!isConnected || !canCreateProject}
icon={
<SymbolView
name="plus"
Expand Down Expand Up @@ -993,6 +991,8 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
);
const environment = resolveAddProjectEnvironment(environmentOptions, selectedEnvironmentId);
const createNew = useAtomCommand(projectEnvironment.createNew, { reportFailure: false });
// J5: adding a project needs a server-scope level (FORK.md case 90).
const canCreateProject = useCanAddProject(environment?.environmentId ?? null);
const publishRepository = useAtomCommand(sourceControlEnvironment.publishRepository, {
reportFailure: false,
});
Expand Down Expand Up @@ -1057,7 +1057,8 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
// State lags a render behind, so a double tap could start a second create.
const submittingRef = useRef(false);
const submit = async () => {
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);
Expand Down Expand Up @@ -1204,7 +1205,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
) : null}
<PrimaryActionButton
label="Create project"
disabled={isSubmitting || trimmedName.length === 0}
disabled={isSubmitting || !canCreateProject || trimmedName.length === 0}
onPress={() => void submit()}
loading={isSubmitting}
/>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -801,7 +801,7 @@ export function NewTaskDraftScreen(props: {
}
if (
environmentConnected &&
!readEnvironmentScope(selectedProject.environmentId, AuthOrchestrationOperateScope)
!readCanStartTaskIn(selectedProject.environmentId, selectedProject.id)
) {
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion apps/mobile/src/features/threads/NewTaskRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -172,7 +173,12 @@ export function NewTaskRouteScreen({ route }: StaticScreenProps<NewTaskRoutePara
: `Choose a project for the ${incomingShare.attachments.length} ${incomingShare.attachments.every((attachment) => 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) =>
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/src/features/threads/ThreadFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 (
<Pressable
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/features/threads/ThreadRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { uuidv4 } from "../../lib/uuid";
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
import { useCanOperateThread } from "../../j5/sharing/guestAccess";
import { useSharedConversationFeed } from "../../j5/sharing/sharedConversation";
import { useStartableProjects } from "../../j5/sharing/startAccess";
import { useSelectedThreadDetailState } from "../../state/use-thread-detail";
import { useThreadSelection } from "../../state/use-thread-selection";
import { GitActionProgressOverlay } from "./GitActionProgressOverlay";
Expand Down Expand Up @@ -199,7 +200,8 @@ function ThreadUnavailableScreen(props: {
/** A thread that can't load opens a new task in its environment instead of a dead end. */
function UnavailableThreadDraftRedirect(props: { readonly environmentId: EnvironmentId }) {
const navigation = useNavigation();
const projects = useProjects();
// J5: only a project the person may start a thread in (FORK.md case 90).
const projects = useStartableProjects(useProjects());
const { layout } = useAdaptiveWorkspaceLayout();
const openDraft = useEffectEvent(() => {
const project = projects.find((candidate) => candidate.environmentId === props.environmentId);
Expand Down
Loading
Loading