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
1 change: 1 addition & 0 deletions apps/server/src/orchestration-v2/ProjectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ type ShellThreadState = {
readonly activityRunStartedAt: DateTime.Utc | null;
readonly lastError: string | null;
readonly lastErrorClass: OrchestrationV2ThreadShell["lastErrorClass"];
// Coder: no `lastErrorCode` (#23361's managed-Codex error codes are not carried).
readonly usageLimitResetAt: OrchestrationV2ThreadShell["usageLimitResetAt"];
readonly pendingRuntimeRequest: OrchestrationV2PendingRuntimeRequestSummary | null;
readonly latestUserMessageAt: DateTime.Utc | null;
Expand Down
23 changes: 17 additions & 6 deletions apps/server/src/orchestration-v2/RuntimePolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const layer: Layer.Layer<RuntimePolicyV2> = Layer.succeed(RuntimePolicyV2
});

// Coder: a mode the provider does not offer (a workspace policy can disable modes) steps down to
// the broadest offered mode below it, as `delegatedTaskModes.resolveRuntimeMode` does, instead of
// upstream's approval-required.
// the broadest offered mode below it, as `delegatedTaskModes.resolveRuntimeMode` does, or else
// runs in the narrowest offered mode, as the composer shows; upstream runs approval-required.
function providerRuntimeMode(
runtimeMode: RuntimeMode,
supportedRuntimeModes: ReadonlyArray<RuntimeMode> | undefined,
Expand All @@ -72,10 +72,21 @@ function providerRuntimeMode(
supportedRuntimeModes.length === 0 ||
supportedRuntimeModes.includes(runtimeMode)
? runtimeMode
: (supportedRuntimeModes
.filter((mode) => runtimeModeRank(mode) <= runtimeModeRank(runtimeMode))
.toSorted((left, right) => runtimeModeRank(right) - runtimeModeRank(left))[0] ??
"approval-required");
: stepDownRuntimeMode(runtimeMode, supportedRuntimeModes);
}

function stepDownRuntimeMode(
runtimeMode: RuntimeMode,
supportedRuntimeModes: ReadonlyArray<RuntimeMode>,
): RuntimeMode {
const ranked = supportedRuntimeModes.toSorted(
(left, right) => runtimeModeRank(left) - runtimeModeRank(right),
);
return (
ranked.findLast((mode) => runtimeModeRank(mode) <= runtimeModeRank(runtimeMode)) ??
ranked[0] ??
"approval-required"
);
}

export const layerFromProjectStore: Layer.Layer<
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/provider/ClaudeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
resolveClaudeModelsForVersion,
resolveClaudeUpdateRequiredModels,
} from "./ClaudeModelCatalog.ts";
import { buildSupportedRuntimeModes } from "./runtimeModeCapabilities.ts";
import { buildSupportedRuntimeModes, SAFE_RUNTIME_MODES } from "./runtimeModeCapabilities.ts";

const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
optionDescriptors: [],
Expand All @@ -63,6 +63,8 @@ const CLAUDE_PRESENTATION = {
displayName: "Claude",
showInteractionModeToggle: true,
reportsContextWindow: true,
// Coder: only the safe modes until the probe reads the workspace's runtime-mode policy.
supportedRuntimeModes: SAFE_RUNTIME_MODES,
} as const;
function toTitleCaseWords(value: string): string {
const parts: Array<string> = [];
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/provider/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
decodeCodexRuntimeRequirementsResponse,
resolveCodexSupportedRuntimeModes,
} from "./CodexRuntimeModes.ts";
import { SAFE_RUNTIME_MODES } from "./runtimeModeCapabilities.ts";
import {
buildServerProvider,
COMPACT_SLASH_COMMAND,
Expand Down Expand Up @@ -85,6 +86,8 @@ const CODEX_PRESENTATION = {
displayName: "Codex",
showInteractionModeToggle: true,
reportsContextWindow: true,
// Coder: only the safe modes until the probe reads the workspace's runtime-mode policy.
supportedRuntimeModes: SAFE_RUNTIME_MODES,
} as const;

export interface CodexAppServerProviderSnapshot {
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/scheduledTasks/ScheduledTaskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ export const layer = Layer.effect(
deliveryId: string,
prompt: string,
) {
// Coder: webhook metrics are not carried; outcomes and delays stay span annotations only.
const runOutcome = (outcome: "started" | "skipped" | "failed") =>
Effect.annotateCurrentSpan({ "scheduled_task.webhook.run_outcome": outcome });
const dispatched = yield* Ref.make(false);
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/secrets/SecretRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const make = Effect.gen(function* () {

// Serialize get/remove so concurrent consumers cannot read the same one-use ref.
const consumeLock = yield* Semaphore.make(1);
// Coder: no `secretRefsConsumedTotal` metric.
const consume: SecretRequests["Service"]["consume"] = (input) =>
consumeRef(input).pipe(consumeLock.withPermits(1), Effect.withSpan("SecretRequests.consume"));

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/BranchToolbar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface EnvironmentOption {
machine: EnvironmentMachineKind;
}

// Coder: no "Add to another machine" (#22180), so no `ADD_TO_MACHINE_LABEL_CLASS`.
export const EnvMode = Schema.Literals(["local", "worktree"]);
export type EnvMode = typeof EnvMode.Type;

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
canSnoozeNow: canSnooze(thread, { now: new Date().toISOString() }),
isRegeneratingTitle,
isRunning: !threadRuntimeCanArchive(thread.runtime),
// Coder: no guest sharing, so no "Share with guest" item.
canTurnIntoProject: canTurnThreadIntoProject(threadRef),
supports: {
settlement: configLoaded,
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/chat/ComposerFooterControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const ComposerFooterModeControls = memo(function ComposerFooterModeContro
showInteractionModeToggle: boolean;
interactionMode: ProviderInteractionMode;
runtimeMode: RuntimeMode;
/** Coder: only safe modes are offered until the provider is ready. */
runtimeModeOptions: ReadonlyArray<RuntimeModeOption>;
size?: "sm" | "xs";
hidden?: boolean;
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/threadActionMenu.logic.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Coder: the browser-only context menu type; no guest sharing, so no "share-guest" action.
import type { ContextMenuItem } from "../localApiTypes";
import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled";

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/contextMenuFallback.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Coder: the browser-only context menu type; no "user-plus" icon, since guest sharing is cut.
import type { ContextMenuItem } from "./localApiTypes";

const SVG_NS = "http://www.w3.org/2000/svg";
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/hooks/useThreadActionMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function useThreadActionMenu(input: {
readonly threadRef: ScopedThreadRef | null;
readonly projectCwd: string | null;
readonly onStartRename: () => void;
// Coder: no guest sharing, so no `canShareWithGuest` input or "share-guest" action.
}) {
const { threadRef, projectCwd, onStartRename } = input;
const router = useRouter();
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/state/sourceControlActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export function useSourceControlPublishRepositoryAction(scope: SourceControlActi
),
);
}
// Coder: no forge app sign-in (#26245), so publishing suggests no app access.
return publishRepository({
environmentId: target.environmentId,
input: {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/themePalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,7 @@ export function resolveThemeAppearance(
return getThemePreferenceMode(theme) ?? "light";
}

// Coder: no `resolveDesktopTheme`; the desktop app is not carried.
export function isKnownThemePreference(theme: string): boolean {
if (theme === "light" || theme === "dark" || theme === "system") return true;
return getThemeDefinition(theme) !== null;
Expand Down
42 changes: 29 additions & 13 deletions docs/internals/coder-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ listed here is drift to remove rather than fork behavior to keep.
browser. `WorkspaceEntries` has no `listIgnoredFiles`, `ws.ts` serves no
`projects.listIgnoredFiles` (`ignoredFileListing` is in `CODER_OMITTED_CAPABILITIES`),
client-runtime's `projectCommands.ts` has no matching command, `BranchToolbar.tsx` has no
menu entry, and `ChatView.tsx` shows no file-copy banner or send block.
menu entry (`BranchToolbar.logic.ts` has no `ADD_TO_MACHINE_LABEL_CLASS`), and `ChatView.tsx`
shows no file-copy banner or send block.
- Coder-only methods live in `coderWs.ts` (`CODER_WS_METHODS`): local ref status, managed
branch/worktree rename with `moveWorktree`, chunked review files, the gateway's asset
stream (`coder.serveAsset`), fixed project-config reads, merge-request diffs, and upstream's HTTP bounded thread snapshot,
Expand All @@ -502,7 +503,9 @@ listed here is drift to remove rather than fork behavior to keep.
- Guest thread sharing (#24104) is not carried: guests reach a share over upstream's server HTTP
routes and T3 Connect, neither of which exists here. `apps/server/src/guest/**`, its HTTP
route, the share RPC handler, web `components/guest/**`, `routes/guest.tsx`, `guestPage.ts`,
the share controls, menu and palette entries, the guest-message footer and bubbles
the share controls, menu and palette entries (the "share-guest" thread action in
`threadActionMenu.logic.ts`, `useThreadActionMenu.ts`, `Sidebar.tsx`, and its `user-plus` icon
in `contextMenuFallback.ts`), the guest-message footer and bubbles
(`ChatView.tsx`'s timeline footer, `TimelineUserMessageRow.tsx`, and `QueuedRunsControl.tsx`,
which has no guest names or per-item `editable` flag), the sidebar's guest-request pill and
badge (`Sidebar.logic.ts`, `SidebarThreadRow.tsx`), Labs' Beta section with its guest-links row
Expand Down Expand Up @@ -603,7 +606,9 @@ listed here is drift to remove rather than fork behavior to keep.
`coderServer.ts` provides `DocumentText.layer` at the bottom of the runtime services, where
upstream's `layerPlatformServices` provides it; `ProviderHostLive` carries upstream's
`resolveExtractedTextPath`.
- `Orchestrator.ts` and `ProjectService.ts` have no `withCommandMetrics` wrapper (#23966), and
- `Orchestrator.ts` and `ProjectService.ts` have no `withCommandMetrics` wrapper (#23966),
`ScheduledTaskService.ts` records no webhook metrics, `SecretRequests.ts` counts no consumed
secret refs, and
`RunExecutionService.ts` reports no browser-preview agent activity (`PreviewAgentActivity`,
#25184), since metrics and the browser preview are not carried.
- A thread dropped on the composer from another workspace attaches upstream's saved transcript
Expand Down Expand Up @@ -809,8 +814,8 @@ listed here is drift to remove rather than fork behavior to keep.
`CodexManagedTokenBroker` (which renews the managed runtime's ChatGPT sign-in token,
#21786/#21787) and the `__managed-chatgpt-token` CLI entry are not carried. `CodexAdapterV2` does not
rewrite failures through `CodexManagedErrors` (ChatGPT Business admin request, #23361), and
the server's `threadErrorSummary` and client-runtime's `ThreadRuntimeSummary` carry no
`lastErrorCode`; the contract field stays.
the server's `threadErrorSummary`, `ProjectionStore.ts`'s shell state, and client-runtime's
`ThreadRuntimeSummary` carry no `lastErrorCode`; the contract field stays.
- Provider drivers, snapshots, and the registry are upstream's. Coder deltas: `CodexDriver`
offers no T3-managed Codex install (`setupMode: "managed"`), neither driver redeems
rate-limit reset credits, and `ClaudeDriver` does not read the Claude organization id that
Expand All @@ -820,7 +825,9 @@ listed here is drift to remove rather than fork behavior to keep.
upstream's provider-level `supportedRuntimeModes` from workspace policy: Claude's effective
`disableAutoMode`/`disableBypassPermissionsMode` settings (read through `ClaudeCli`, failing
closed to the safe modes) and Codex's `configRequirements/read`, which runs in upstream's
parallel probe step (safe modes when it cannot be read). At session start,
parallel probe step (safe modes when it cannot be read); before the first probe finishes,
both report the safe modes. The fork-only `provider/runtimeModeCapabilities.ts` builds the
mode lists and `provider/CodexRuntimeModes.ts` maps Codex's requirements. At session start,
`ClaudeAdapterV2.resolveBypassAvailability` reads the settings files (cached remote, user,
project, local, and managed) where upstream calls the SDK's runtime `resolveSettings`
(#21806); a mode any source disables is off, so `Drivers/ClaudeSkills.ts` keeps
Expand All @@ -836,7 +843,8 @@ listed here is drift to remove rather than fork behavior to keep.
- Absent: client-origin attribution, orchestration and provider metrics (including the run
outcome metrics of `RunMetrics.ts`, #22094, so `EventSink.ts` records none), turn analytics, NDJSON
event logs (`EventNdjsonLogger` and `ProviderEventLoggers` keep only the no-op service),
provider sign-in commands and credential-change guards, Codex feedback upload, SnapShot
provider sign-in commands and credential-change guards, Codex feedback upload (client-runtime
`threadCommands.ts` has no `uploadFeedback`), SnapShot
sources, data-URL uploads, preview-tool metadata, and the agent device shim.
- **Authorization scopes.** Coder owns authentication, so upstream's per-session scopes always
grant: web `useEnvironmentScope`, `readEnvironmentScope`, and `useFilesystemReadAccess`
Expand Down Expand Up @@ -948,7 +956,8 @@ listed here is drift to remove rather than fork behavior to keep.
- **Composer, timeline, and work log.** Upstream's context records, upload queue, chips, and
work-log module (`client-runtime/work-log/toolPresentation.ts`), minus preview annotations,
element captures, SnapShot (with its open question-draft tracker in `questionAttachments.ts`),
upstream's large-paste-to-file folding, and remote icons. `work-log/presentation.ts` formats
and remote icons. Upstream's large-paste folding (#11442) is carried: a paste at or over the
limit becomes a `text/plain` file attachment (`useComposerAttachmentIntake.ts`). `work-log/presentation.ts` formats
token counts inline, since upstream's `@t3tools/shared/usageFormat` belongs to the omitted usage
dashboard. Draft file and video attachments
preview as on main. A context fragment pasted from another workspace downloads its attachments from the
Expand Down Expand Up @@ -989,7 +998,7 @@ listed here is drift to remove rather than fork behavior to keep.
reporting, favorite-editor command (OpenInPicker is not carried), or desktop paste-as-text.
The keybindings reload toast (`KeybindingsUpdateToast.tsx`) shows the reload's message without
upstream's config-warning actions, which open the desktop editor. `shortcuts/chatRouteCommands.ts`
has no preview commands or legacy-sidebar check, `state/entities.ts` keeps only
has no preview commands (its legacy-sidebar check is upstream's), `state/entities.ts` keeps only
`initializeActiveEnvironmentId` (the first welcome sets the primary), and client-runtime's
`state/presentation.ts` shows an available placeholder as connecting without upstream's
`entry.enabled` and `unsupportedReason`, which Coder entries lack. The "failed to start" screen
Expand Down Expand Up @@ -1157,7 +1166,8 @@ listed here is drift to remove rather than fork behavior to keep.
field, and the `sourceControl.signIn*` and `sourceControl.appAccess` RPCs in upstream's
dormant `WsRpcGroup` only; `CoderWsRpcGroup` omits them. In the clients, web
`SourceControlAppAccessNotice.tsx`, `T3AppIcon.tsx`, `settings/SourceControlAppSignInSettings.tsx`
and `sourceControlAppAccessToast.ts` are cut, and client-runtime `state/sourceControl.ts` and
and `sourceControlAppAccessToast.ts` are cut (`state/sourceControlActions.ts` suggests no app
access after publishing), and client-runtime `state/sourceControl.ts` and
`sourceControlClients.ts` have no app-access or sign-in atoms and no `appSignInTargetForRemote`.
- GitLab's definition (`source-control-gitlab/src/shared/definition.ts`) has three deltas:
`isChangeRequestReference` accepts a merge request URL on any HTTP(S) host, because
Expand Down Expand Up @@ -1327,8 +1337,10 @@ listed here is drift to remove rather than fork behavior to keep.
`state/shell.ts` treats every workspace as remote (no primary local target).
- `lib/runtime.ts` has no primary-environment HTTP client, relay, DPoP, or tracer, and
`branding.ts` fixes the "T3 Coder" name without a desktop bridge or hosted channel.
- Upstream's desktop IPC contract (`contracts/ipc.ts`) is not carried; `localApiTypes.ts` keeps
its context-menu and confirm-dialog types, and `localApi.ts` opens only HTTP(S) links.
- Upstream's desktop IPC contract (`contracts/ipc.ts`) is not carried, nor `themePalette.ts`'s
desktop-only `resolveDesktopTheme`; `localApiTypes.ts` keeps
its context-menu and confirm-dialog types (web modules that import `ContextMenuItem` from
`contracts` upstream import it from there), and `localApi.ts` opens only HTTP(S) links.
`ThreadNotificationCoordinator.tsx` focuses the tab on a notification click without
upstream's desktop window reveal.
- client-runtime `errors/diagnostics.ts` is the `[t3-error]` DevTools reporting described in
Expand Down Expand Up @@ -1429,10 +1441,14 @@ listed here is drift to remove rather than fork behavior to keep.
`storageCleanup.test.ts` its saved-usage-cache test, and `PullRequestService.test.ts` its
GitHub-credential branch deletion, GitHub Enterprise listing, Bitbucket paging, routing,
Forgejo, replacement-read retry, Azure environment viewed-file, and repository-identity
resolution tests; upstream's OTLP `config.test.ts` is not carried.
resolution tests; client-runtime's `pullRequests.test.ts` uses one connection target without
upstream's cross-environment routing tests (shared probes, alternates, routed viewed marks and
writes); upstream's OTLP `config.test.ts` is not carried.
`presentation.test.ts` omits upstream's disabled and unsupported connection tests, since Coder
catalog entries have neither state. `GitManager.test.ts`'s pull request draft-status test and
`SourceControlRepositoryService.test.ts`'s HTTPS clone-retry tests run on GitLab.
The fork-only `hooks/useThreadActionMenu.test.tsx` keeps upstream's deleted hook test beside
upstream's `useThreadActionMenu.test.ts`.
Replay fixtures (`orchestration-v2/testkit/fixtures`) carry only the Claude, Codex, Pi, and ACP
Registry providers; `ProviderReplayFixtures.ts` lists only those drivers.
client-runtime's `threadShell.test.ts` omits upstream's switched-off environment test, because
Expand Down
5 changes: 3 additions & 2 deletions docs/internals/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ mobile's `microphonePriority.ts` into `packages/shared`) arrives as an added fil
- Auth and pairing (`apps/server/src/auth`, web `components/auth`, client-runtime `authorization`).
- Preview and browser (`apps/server/src/preview`, web `browser`, `components/preview`).
- Device (`apps/server/src/device`, web `components/device`, client-runtime `device`).
- HTTP routes and assets (`apps/server/src/assets`, `http.ts` route files).
- HTTP routes (`http.ts` route files other than the server's signed asset route in
`apps/server/src/http.ts`, and the uncarried `assets/` modules).
- Forgejo, GitHub, Azure DevOps, Bitbucket, and GitCafe (`packages/source-control-*` except core,
gitlab, and testing).
- Other provider packages (`packages/provider-{cursor,fx,grok,muse,opencode}`,
Expand Down Expand Up @@ -200,7 +201,7 @@ git -c diff.renameLimit=0 diff --no-renames --name-status "$MB" origin/coder-onl
## 4. Conflict magnets

- `apps/server/src/server.ts`: upstream's file minus the cut surfaces. Upstream's edits to the
carried declarations merge; keep their three `Coder:` changes and the export block. Conflicts
carried declarations merge; keep their `Coder:` changes and the export block. Conflicts
sit in regions the fork deletes (`layerMakeServer`, `layerRuntimeCoreDependencies*`, HTTP,
auth, preview, and telemetry layers): keep the deletion, and port a new service or provide the
helper needs into `coderServer.ts`'s matching composition (`CoderRuntimeCoreLive`,
Expand Down
Loading