🗂️ feat: Choose Conversation Checkout Mode (#16679)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions

* feat: Choose the conversation checkout mode

* fix: Preserve checkout choices across submission and recovery

* test: Match checkout policy defaults and share mode enum

* fix: Offer shared checkout and require deliberate transition modes

* fix: Retain explicit mode when changing repository selection

* test: Match repository menu accessible labels
This commit is contained in:
Danny Avila 2026-10-02 14:41:35 -04:00 • committed by GitHub
parent bb0543fd15
commit 35a2bee409
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 888 additions and 66 deletions

View file

@ -1,7 +1,44 @@
import { resolveCodeEnvironmentSelection } from './workspace';
import {
resolveCodeEnvironmentSelection,
isCodeWorkspaceSelection,
canonicalizeCodeWorkspaceSelections,
} from './workspace';
import { EModelEndpoint, tConvoUpdateSchema } from '../schemas';
import { appendAgentIdSuffix } from '../agents/identity';
import createPayload from '../createPayload';
describe('chat machine selection', () => {
it.each(['source', 'isolated'] as const)(
'validates and retains the %s checkout in the sealed identity',
(checkout) => {
const selection = { environmentId: 'vm', workspaceId: 'repo', checkout };
expect(isCodeWorkspaceSelection(selection)).toBe(true);
expect(canonicalizeCodeWorkspaceSelections([selection])).toEqual([selection]);
const conversation = {
conversationId: null,
endpoint: EModelEndpoint.agents,
endpointType: null,
codeWorkspaces: [selection],
};
expect(tConvoUpdateSchema.parse(conversation).codeWorkspaces).toEqual([selection]);
expect(
createPayload({
conversation,
endpointOption: { endpoint: EModelEndpoint.agents },
userMessage: { text: 'hello' },
codeEnvironmentMode: 'attached',
codeWorkspaces: [selection],
} as Parameters<typeof createPayload>[0]).payload.codeWorkspaces,
).toEqual([selection]);
},
);
it.each([null, 'automatic', 'invalid', {}, 1])('rejects an invalid checkout: %j', (checkout) => {
expect(isCodeWorkspaceSelection({ environmentId: 'vm', workspaceId: 'repo', checkout })).toBe(
false,
);
});
const defaultId = 'application-vm';
const selections = [{ environmentId: 'runtime-vm', workspaceId: 'primary' }];

View file

@ -30,6 +30,7 @@ export const CODE_WORKSPACE_OPERATIONS = [
'execute_command',
] as const;
export const CODE_WORKSPACE_INSTANCE_TYPES = ['git_worktree'] as const;
export const CODE_WORKSPACE_CHECKOUT_MODES = ['source', 'isolated'] as const;
/** Scheduling scopes a worker can admit beneath one registered root. */
export const CODE_WORKSPACE_SCOPES = ['git_linked_worktree'] as const;
export const CODE_WORKSPACE_SELECTION_ERROR_REASONS = [
@ -127,10 +128,27 @@ export function isCodeWorkspaceEnvironment(
export interface CodeWorkspaceSelection {
environmentId: string;
workspaceId: string;
/** Omitted preserves the worker's legacy automatic isolation policy. */
checkout?: (typeof CODE_WORKSPACE_CHECKOUT_MODES)[number];
/** Explicit graph-agent ownership of a chat machine choice; absent on legacy selections. */
agentIds?: string[];
}
/** Explicit isolation never falls back to shared files when a capability or policy disappears. */
export function isCodeWorkspaceCheckoutAvailable(
selection: Pick<CodeWorkspaceSelection, 'checkout'>,
workspace: Pick<CodeWorkspaceDescriptor, 'workspaceInstances'> | undefined,
allowSelection: boolean,
): boolean {
return (
selection.checkout == null ||
(allowSelection &&
workspace != null &&
(selection.checkout === 'source' ||
workspace.workspaceInstances?.includes('git_worktree') === true))
);
}
export function isCodeEnvironmentMode(value: unknown): value is CodeEnvironmentMode {
return CODE_ENVIRONMENT_MODES.some((mode) => mode === value);
}
@ -148,12 +166,15 @@ export function isCodeWorkspaceSelection(value: unknown): value is CodeWorkspace
const selection = value as Record<string, unknown>;
return (
Object.keys(selection).every((key) =>
['environmentId', 'workspaceId', 'agentIds'].includes(key),
['environmentId', 'workspaceId', 'agentIds', 'checkout'].includes(key),
) &&
typeof selection.environmentId === 'string' &&
CODE_WORKSPACE_ID_PATTERN.test(selection.environmentId) &&
typeof selection.workspaceId === 'string' &&
CODE_WORKSPACE_ID_PATTERN.test(selection.workspaceId) &&
(selection.checkout === undefined ||
selection.checkout === 'source' ||
selection.checkout === 'isolated') &&
(selection.agentIds === undefined ||
(Array.isArray(selection.agentIds) &&
selection.agentIds.length > 0 &&
@ -189,9 +210,10 @@ export function canonicalizeCodeWorkspaceSelections(
selections: CodeWorkspaceSelection[],
): CodeWorkspaceSelection[] {
return selections
.map(({ environmentId, workspaceId, agentIds }) => ({
.map(({ environmentId, workspaceId, agentIds, checkout }) => ({
environmentId,
workspaceId,
...(checkout == null ? {} : { checkout }),
...(agentIds == null ? {} : { agentIds: [...agentIds].sort() }),
}))
.sort((left, right) => left.environmentId.localeCompare(right.environmentId));