From 88c90d08add7dd899a0caefc15609fdbb1d4b2ed Mon Sep 17 00:00:00 2001 From: Filip Hejmowski <34747899+neriousy@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:38:35 +0100 Subject: [PATCH 001/108] feat(app): add previous and next match buttons to conversation search (#64865) --- .../app/src/session/timeline/search-bar.tsx | 18 ++++++++++++++++-- .../src/session/timeline/search-controller.ts | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/app/src/session/timeline/search-bar.tsx b/packages/app/src/session/timeline/search-bar.tsx index 0d78393dc1b1..b1b6a71e7af2 100644 --- a/packages/app/src/session/timeline/search-bar.tsx +++ b/packages/app/src/session/timeline/search-bar.tsx @@ -1,6 +1,6 @@ import { Icon } from "@opencode/ui/icon" import "@opencode/ui/text-input.css" -import { Show } from "solid-js" +import { For, Show } from "solid-js" import type { TimelineSearchController } from "./search-controller" import "./search-bar.css" @@ -9,7 +9,7 @@ export function TimelineSearchBar(props: { controller: TimelineSearchController return ( -
+
@@ -64,6 +64,20 @@ export function TimelineSearchBar(props: { controller: TimelineSearchController {c.result.activeDisplay()}/{c.result.count()} + + {(delta) => ( + + )} + @@ -111,7 +111,7 @@ export const DialogManageModels: Component = () => { } value={list.filter()} onInput={(event) => list.onInput(event.currentTarget.value)} diff --git a/packages/app/src/shell/search-list.css b/packages/app/src/shell/search-list.css index 1992733eddbc..89018c091710 100644 --- a/packages/app/src/shell/search-list.css +++ b/packages/app/src/shell/search-list.css @@ -279,10 +279,8 @@ /* A list dialog with a compact header and a bare search, as in the integration and manage models dialogs. */ [data-component="dialog-v2"] [data-slot="dialog-container"] [data-slot="dialog-content"].search-dialog { - /* Trailing controls sit 10px from both the top and the end edge. */ [data-slot="dialog-header"] { - padding-block: 10px 6px; - padding-inline: 14px 10px; + padding: 14px 16px 8px; [data-slot="dialog-close-button"] { margin-top: 0; @@ -308,8 +306,9 @@ } [data-slot="dialog-description"] { - font-size: 12px; + font-size: 13px; line-height: var(--line-height-base); + letter-spacing: -0.04px; } } diff --git a/packages/ui/src/overlays/dialog/dialog.css b/packages/ui/src/overlays/dialog/dialog.css index a5105d1b5cdd..fe17a1aa93f4 100644 --- a/packages/ui/src/overlays/dialog/dialog.css +++ b/packages/ui/src/overlays/dialog/dialog.css @@ -160,7 +160,7 @@ } } - &:is([data-anchored], [data-size="large"], [data-size="x-large"]) { + &:is([data-size="large"], [data-size="x-large"]) { align-items: flex-start; [data-slot="dialog-container"] { @@ -171,7 +171,7 @@ &:is([data-size="large"], [data-size="x-large"]) [data-slot="dialog-container"] { --dialog-height: min(calc(100vh - 96px), 600px); - width: min(calc(100vw - 32px), 720px); + width: min(calc(100vw - 32px), 680px); background: var(--v2-background-bg-base); } diff --git a/packages/ui/src/overlays/dialog/dialog.tsx b/packages/ui/src/overlays/dialog/dialog.tsx index 8b6df1932869..2d577364c7a7 100644 --- a/packages/ui/src/overlays/dialog/dialog.tsx +++ b/packages/ui/src/overlays/dialog/dialog.tsx @@ -21,14 +21,12 @@ const TEXT_FIELD = [ export interface DialogProps extends ParentProps { /** - * normal: 480px wide, for confirmations and small forms. large: 720×600, for palettes, pickers and lists. + * normal: 480px wide, for confirmations and small forms. large: 680×600, for palettes, pickers and lists. * x-large: 880×680, for long documents and settings-like panels. Each clamps to the window. */ size?: "normal" | "large" | "x-large" /** Height follows the content, up to the size's height. Large sizes grow down from a fixed top edge. */ fit?: boolean - /** Fit within the preset's height and keep its top edge as content changes. */ - anchored?: boolean variant?: "default" | "settings" class?: ComponentProps<"div">["class"] containerClass?: ComponentProps<"div">["class"] @@ -115,7 +113,6 @@ export function Dialog(props: DialogProps) { "containerClass", "classList", "fit", - "anchored", "children", "onCloseAutoFocus", "preventBackdropDismiss", @@ -131,7 +128,6 @@ export function Dialog(props: DialogProps) { data-component="dialog-v2" data-variant={local.variant === "settings" ? "settings" : undefined} data-fit={local.fit ? true : undefined} - data-anchored={local.anchored ? true : undefined} data-size={local.size || "normal"} >
From b8928b93605e925b189bb26b480586b8d9d8df38 Mon Sep 17 00:00:00 2001 From: Filip Hejmowski <34747899+neriousy@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:07:16 +0100 Subject: [PATCH 008/108] test: fix Windows timeouts in server and sdk contract tests (#64879) --- packages/httpapi-codegen/src/index.ts | 61 +++++++++++++------------ packages/server/test/artifact.test.ts | 4 ++ packages/server/test/automation.test.ts | 3 ++ 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/packages/httpapi-codegen/src/index.ts b/packages/httpapi-codegen/src/index.ts index 8afd612de1d9..fa74dcf218ee 100644 --- a/packages/httpapi-codegen/src/index.ts +++ b/packages/httpapi-codegen/src/index.ts @@ -1408,17 +1408,7 @@ function structuralTypes(schemas: ReadonlyArray, mutable: boolean, r .filter((reference) => anonymous.has(reference.$ref)) .map((reference) => [reference.$ref, reference.code.Type]), ) - const inlineAnonymous = (type: string, seen = new Set()): string => { - for (const [reference, value] of anonymousTypes) { - const pattern = `(?() const usedNames = new Set(reservedNames) const references = document.references.nonRecursives.filter((reference) => !anonymous.has(reference.$ref)) @@ -1429,12 +1419,12 @@ function structuralTypes(schemas: ReadonlyArray, mutable: boolean, r names.set(reference.$ref, name) usedNames.add(name) } + const namePattern = referencePattern(names.keys()) const render = (type: string) => { - for (const [reference, name] of names) { - const pattern = `(? names.get(reference) ?? reference) + .replaceAll("Schema.Json", "JsonValue") + .replaceAll(/(?() @@ -1464,6 +1454,30 @@ function structuralTypes(schemas: ReadonlyArray, mutable: boolean, r } } +// Replaces every reference to a named type with its parenthesized definition, recursively. +function expandReferences(references: ReadonlyMap) { + const pattern = referencePattern(references.keys()) + const expand = (type: string, seen: ReadonlySet = new Set()): string => + type.replace(pattern, (reference) => { + if (seen.has(reference)) { + throw new GenerationError({ reason: `Recursive Promise types are not implemented: ${reference}` }) + } + return `(${expand(references.get(reference) ?? reference, new Set([...seen, reference]))})` + }) + return expand +} + +// Matches any of the references as a whole token in one pass. Building a RegExp per reference for every type made +// emitting the Server contract cost types x references regexes, hundreds of milliseconds. +function referencePattern(references: Iterable) { + const alternatives = Array.from(references, (reference) => reference.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) + if (alternatives.length === 0) return /(?!)/g + return new RegExp( + `(? b.length - a.length).join("|")})(?![A-Za-z0-9_$.'"])`, + "g", + ) +} + function uniqueTypeName(seed: string, used: ReadonlySet, suffix = 1): string { const name = suffix === 1 ? seed : `${seed}${suffix}` return used.has(name) ? uniqueTypeName(seed, used, suffix + 1) : name @@ -1474,20 +1488,9 @@ function structuralType(schema: Schema.Top) { if (document.artifacts.length > 0 || Object.keys(document.references.recursives).length > 0) { throw new GenerationError({ reason: "Referenced Promise types are not implemented" }) } - const references = new Map( - document.references.nonRecursives.map((reference) => [reference.$ref, reference.code.Type]), + const expand = expandReferences( + new Map(document.references.nonRecursives.map((reference) => [reference.$ref, reference.code.Type])), ) - const expand = (type: string, seen = new Set()): string => { - for (const [reference, value] of references) { - const pattern = `(? From 0a297bf15de78acc4dce99b837b7e5879c1ff20b Mon Sep 17 00:00:00 2001 From: Filip Hejmowski <34747899+neriousy@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:08:21 +0100 Subject: [PATCH 009/108] fix(core): respect repository line endings and symlinks in git diffs (#64884) --- packages/core/src/plugin/vcs/git.ts | 6 ++--- packages/core/test/vcs.test.ts | 39 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/packages/core/src/plugin/vcs/git.ts b/packages/core/src/plugin/vcs/git.ts index a2ededa7ecce..195390add917 100644 --- a/packages/core/src/plugin/vcs/git.ts +++ b/packages/core/src/plugin/vcs/git.ts @@ -165,17 +165,15 @@ interface Ctx { type GitOps = ReturnType +// Unlike the snapshot repository, this is the user's checkout: line endings and symlinks follow its own config, as +// `git status` does, or every CRLF checkout and symlink placeholder reads as changed. const cfg = [ "--no-optional-locks", "-c", - "core.autocrlf=false", - "-c", "core.fsmonitor=false", "-c", "core.longpaths=true", "-c", - "core.symlinks=true", - "-c", "core.quotepath=false", ] as const diff --git a/packages/core/test/vcs.test.ts b/packages/core/test/vcs.test.ts index 91ea01497d96..a65e97cf2543 100644 --- a/packages/core/test/vcs.test.ts +++ b/packages/core/test/vcs.test.ts @@ -833,6 +833,45 @@ describe("Vcs", () => { ), ) + it.live("respects the repository's line-ending conversion", () => + withGit((directory) => + Effect.gen(function* () { + const body = Array.from({ length: 20 }, (_, index) => `line-${index}`).join("\r\n") + "\r\n" + yield* Effect.promise(async () => { + await fs.appendFile(path.join(directory, ".git", "config"), "[core]\n\tautocrlf = true\n") + await fs.writeFile(path.join(directory, "file.txt"), body) + await fs.writeFile(path.join(directory, "same.txt"), body) + await commitAll(directory, "initial") + await fs.writeFile(path.join(directory, "file.txt"), body.replace("line-10", "changed")) + }) + const vcs = yield* Vcs.Service + expect(yield* vcs.status()).toEqual([{ file: "file.txt", additions: 1, deletions: 1, status: "modified" }]) + const diff = yield* vcs.diff("working") + expect(diff.map((item) => [item.file, item.additions, item.deletions])).toEqual([["file.txt", 1, 1]]) + expect(diff[0].patch).toContain("-line-10") + expect(diff[0].patch).toContain("+changed") + }), + ), + ) + + it.live("respects the repository's symlink setting", () => + withGit((directory) => + Effect.gen(function* () { + yield* Effect.promise(async () => { + // Git checks a symlink out as a plain file holding its target when the checkout cannot create symlinks. + await fs.appendFile(path.join(directory, ".git", "config"), "[core]\n\tsymlinks = false\n") + await fs.writeFile(path.join(directory, "link"), "target.txt") + const hash = (await $`git hash-object -w link`.cwd(directory).text()).trim() + await $`git update-index --add --cacheinfo 120000,${hash},link`.cwd(directory).quiet() + await $`git commit -m initial`.cwd(directory).quiet() + }) + const vcs = yield* Vcs.Service + expect(yield* vcs.status()).toEqual([]) + expect(yield* vcs.diff("working")).toEqual([]) + }), + ), + ) + it.live("respects the context option", () => withGit((directory) => Effect.gen(function* () { From c740f6dcb2805d6d627df1169c03ca792b181190 Mon Sep 17 00:00:00 2001 From: Filip Hejmowski <34747899+neriousy@users.noreply.github.com> Date: Thu, 19 Nov 2026 15:40:06 +0100 Subject: [PATCH 010/108] fix(core): keep shell commands working after their output directory is removed (#64889) --- packages/core/src/shell.ts | 10 ++++- packages/core/test/shell-daemon.test.ts | 49 ++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/packages/core/src/shell.ts b/packages/core/src/shell.ts index c33a3784c99f..8198411ae6f6 100644 --- a/packages/core/src/shell.ts +++ b/packages/core/src/shell.ts @@ -598,6 +598,7 @@ const layer = () => const bus = yield* Bus.Service const location = yield* Location.Service const global = yield* Global.Service + const fs = yield* FSUtil.Service const shell = yield* ShellSelect.Service const environment = yield* Environment.Service const hooks = yield* PluginHooks.Service @@ -614,9 +615,8 @@ const layer = () => location.workspaceID === undefined && PersistentPty.available ? yield* daemon.at(location) : undefined const outputDir = path.join(global.data, DIRECTORY, location.project.id) - const { mkdir, unlink, stat } = yield* Effect.promise(() => import("fs/promises")) + const { unlink, stat } = yield* Effect.promise(() => import("fs/promises")) const { createWriteStream, createReadStream } = yield* Effect.promise(() => import("fs")) - yield* Effect.promise(() => mkdir(outputDir, { recursive: true })) yield* Effect.addFinalizer(() => Effect.gen(function* () { @@ -906,6 +906,11 @@ const layer = () => // Absolute for local commands, so the command reports the same cwd wherever it runs. if (location.workspaceID === undefined) invocation.cwd = path.resolve(location.directory, invocation.cwd) + // Created per command: the directory can be removed while the Location stays open. + yield* fs + .ensureDir(outputDir) + .pipe(Effect.mapError((cause) => new AppProcess.AppProcessError({ command: invocation.command, cause }))) + const id = Shell.ID.ascending() const args = ShellSelect.args(invocation.shell, invocation.command) const file = path.join(outputDir, `${id}.out`) @@ -1173,6 +1178,7 @@ export const node = makeLocationNode({ Bus.node, Location.node, Global.node, + FSUtil.node, ShellSelect.node, Environment.node, PluginHooks.node, diff --git a/packages/core/test/shell-daemon.test.ts b/packages/core/test/shell-daemon.test.ts index 641e5a6e690e..01f1326da781 100644 --- a/packages/core/test/shell-daemon.test.ts +++ b/packages/core/test/shell-daemon.test.ts @@ -17,7 +17,9 @@ import { FSUtil } from "@opencode/util/fs-util" import { LayerNode } from "@opencode/util/effect/layer-node" import { AppProcess } from "@opencode/util/process" import { hostEnvironmentLayer } from "./fixture/environment" -import { location } from "./fixture/location" +import { tempGlobalLayer } from "./fixture/global" +import { location, tempLocationLayer } from "./fixture/location" +import { disabledPersistentPtyLayer } from "./fixture/persistent-pty" import { daemonShells, until } from "./fixture/shell-daemon" import { tmpdirScoped } from "./fixture/tmpdir" import { binaryPath } from "@opencode/pty" @@ -269,6 +271,26 @@ describe("Shell on the process daemon", () => { }), ) + it.live("recreates the output directory removed while the Location is open", () => + Effect.gen(function* () { + const env = yield* daemonShells() + yield* env.withShell(env.directory, (shell) => + Effect.gen(function* () { + yield* shell.create({ shell: "/bin/sh", command: "echo first" }) + yield* Effect.promise(() => rm(path.join(env.data, Shell.DIRECTORY), { recursive: true })) + const info = yield* shell.create({ shell: "/bin/sh", command: "echo second" }) + expect(env.created().map((request) => request.output_path)).toContain(info.file) + env.daemon.output(2, "second") + env.daemon.exit(2, 0) + expect(yield* shell.result(info)).toMatchObject({ + info: { status: "exited", exit: 0 }, + capture: { output: "second" }, + }) + }), + ) + }), + ) + it.live("fails a command the daemon rejected instead of spawning it", () => Effect.gen(function* () { const env = yield* daemonShells() @@ -553,6 +575,31 @@ describe("Shell on the process daemon", () => { ) }) +it.live("the spawner recreates the output directory removed while the Location is open", () => + Effect.gen(function* () { + const shell = yield* Shell.Service + const global = yield* Global.Service + const program = windows ? (Bun.which("pwsh") ?? "powershell.exe") : "/bin/sh" + const run = (output: string) => + shell + .create({ shell: program, command: windows ? `[Console]::Out.Write('${output}')` : `printf '${output}'` }) + .pipe(Effect.flatMap((info) => shell.result(info))) + yield* run("first") + yield* Effect.promise(() => rm(path.join(global.data, Shell.DIRECTORY), { recursive: true })) + expect(yield* run("second")).toMatchObject({ info: { status: "exited", exit: 0 }, capture: { output: "second" } }) + }).pipe( + Effect.provide( + AppNodeBuilder.build(LayerNode.group([Shell.node, Global.node]), [ + Location.node.replace(tempLocationLayer), + Global.node.replace(tempGlobalLayer), + Config.node.replace(Config.testLayer()), + Environment.node.replace(hostEnvironmentLayer), + PersistentPty.node.replace(disabledPersistentPtyLayer), + ]), + ), + ), +) + // Against the real opencode-pty, like server/test/persistent-pty.test.ts. const binary = process.env.OPENCODE_PTY_BIN ?? binaryPath const real = binary !== undefined && existsSync(binary) ? it.live : it.live.skip From d9463aaa148d504a26862b9141e3db9d0877d7e6 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:19:45 -0600 Subject: [PATCH 011/108] fix(data): keep custom models out of free-tier stats (#64894) --- packages/data/core/src/domain/inference.test.ts | 2 +- packages/data/core/src/domain/inference.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/data/core/src/domain/inference.test.ts b/packages/data/core/src/domain/inference.test.ts index 8a4a1213b93c..2ad9fac1a345 100644 --- a/packages/data/core/src/domain/inference.test.ts +++ b/packages/data/core/src/domain/inference.test.ts @@ -324,7 +324,7 @@ describe("inference stat normalization", () => { expect(queries[0]).toContain('FROM "inference"."generation"') expect(queries[0]).toContain("event_type = 'generation.completed'") expect(queries[0]).toContain( - "AND (product IN ('go', 'go-plus', 'go-teams') OR (lower(COALESCE(model_tier, '')) = 'free'", + "AND (product IN ('go', 'go-plus', 'go-teams') OR (COALESCE(product, '') <> 'custom' AND (lower(COALESCE(model_tier, '')) = 'free'", ) expect(queries[0]).toContain("COALESCE(NULLIF(lower(model_tier), ''), '') AS raw_tier") expect(queries[0]).toContain("WHEN lower(COALESCE(raw_tier, '')) = 'free'") diff --git a/packages/data/core/src/domain/inference.ts b/packages/data/core/src/domain/inference.ts index fd36c42a1577..f1c19a5f18f0 100644 --- a/packages/data/core/src/domain/inference.ts +++ b/packages/data/core/src/domain/inference.ts @@ -225,6 +225,7 @@ function buildStatsQuery( const periodEndValue = sqlString(period.end.toISOString()) const ingestEndValue = sqlString(new Date(period.end.getTime() + DAY_MS).toISOString()) const sourceTable = [source.namespace, source.table].map(sqlIdentifier).join(".") + // The free branch skips custom (BYOK) requests: their model names are the caller's own and can end in -free. const sourceFreeTier = freeTierSql("model_tier", "model_requested") const dimensions = family === "usage" @@ -312,7 +313,7 @@ WITH normalized AS ( (source = 'inference-legacy' AND started_at < ${sqlString(LIVE_SOURCE_START)}) OR (source = 'inference' AND started_at >= ${sqlString(LIVE_SOURCE_START)}) ) - AND (product IN (${GO_PRODUCTS.map(sqlString).join(", ")}) OR (${sourceFreeTier})) + AND (product IN (${GO_PRODUCTS.map(sqlString).join(", ")}) OR (COALESCE(product, '') <> 'custom' AND (${sourceFreeTier}))) AND ${ROUTED_ONLY} AND model_requested IS NOT NULL AND model_requested <> '' From e090ace2885541286202160d3efca8365bb02bf8 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:19:50 -0600 Subject: [PATCH 012/108] feat(core): let a console watch keep waking an unattended session (#64895) --- .../src/plugin/provider/opencode-watches.ts | 19 ++++++-- .../plugin/provider-opencode-watches.test.ts | 46 ++++++++++++++++++- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/packages/core/src/plugin/provider/opencode-watches.ts b/packages/core/src/plugin/provider/opencode-watches.ts index 610284a2e91a..9d79c5f4e234 100644 --- a/packages/core/src/plugin/provider/opencode-watches.ts +++ b/packages/core/src/plugin/provider/opencode-watches.ts @@ -116,6 +116,7 @@ export const make = Effect.fnUntraced(function* (ctx: Context, http: HttpClient. let current: { readonly member: Member; readonly lease: Scope.Closeable } | undefined const streakKey = (sessionID: string) => `watch-streak:${sessionID}` const deletedKey = (sessionID: string) => `watch-deleted:${sessionID}` + const unattendedKey = (watchID: string) => `watch-unattended:${watchID}` const wake = Effect.fnUntraced(function* (member: Member, sessionID: Session.ID, events: ReadonlyArray) { const ids = events.map((event) => event.id) @@ -136,10 +137,14 @@ export const make = Effect.fnUntraced(function* (ctx: Context, http: HttpClient. const kept = own || now - (stored?.last ?? now) >= Duration.toMillis(Duration.minutes(30)) ? undefined : stored const recent = (kept?.at ?? []).filter((at) => now - at < Duration.toMillis(Duration.minutes(10))) const count = kept?.count ?? 0 + // Updates from watches made unattended, such as a router's, skip the 20 since the prompt but never the window. + const unattended = (yield* Effect.forEach(new Set(events.map((event) => event.watchID)), (id) => + ctx.storage.get(unattendedKey(id)), + )).every((value) => value === true) // CI runs pace themselves, so their updates count toward 20 since the prompt but not the 10-minute window. - const ci = events.every((event) => event.kind === "workflow_run" || event.kind === "workflow_job") - const resume = (ci || recent.length < WINDOW_LIMIT) && count < PROMPT_LIMIT - const paused = !resume || (!ci && recent.length + 1 >= WINDOW_LIMIT) || count + 1 >= PROMPT_LIMIT + const ci = !unattended && events.every((event) => event.kind === "workflow_run" || event.kind === "workflow_job") + const resume = (ci || recent.length < WINDOW_LIMIT) && (unattended || count < PROMPT_LIMIT) + const paused = !resume || (!ci && recent.length + 1 >= WINDOW_LIMIT) || (!unattended && count + 1 >= PROMPT_LIMIT) // The same events delivered again, after a lost acknowledgement, conflict with the message they already made: // they were delivered, so they're acknowledged without another wake. const delivered = yield* ctx.session @@ -288,6 +293,12 @@ export const make = Effect.fnUntraced(function* (ctx: Context, http: HttpClient. description: "How long to watch from now, in minutes; the event type's own default otherwise", }), ), + unattended: Schema.optional( + Schema.Boolean.annotate({ + description: + "For a session whose job is to keep handling a stream unattended, such as a router: its updates keep waking the session past 20 since the user's last prompt, though never more than 5 in 10 minutes", + }), + ), }), output: Watch, options: { namespace, codemode: { pinned: true } }, @@ -308,6 +319,8 @@ export const make = Effect.fnUntraced(function* (ctx: Context, http: HttpClient. ...body, ...(input.minutes === undefined ? {} : { minutes: input.minutes }), }) + // Wake policy is the client's, so Console never hears of it; the mark goes quiet with the watch. + if (input.unattended) yield* ctx.storage.set(unattendedKey(watch.id), true) return { output: watch, content: `Watching ${label(watch)} until ${watch.expiresAt} (${watch.id}). This session wakes when it changes.`, diff --git a/packages/core/test/plugin/provider-opencode-watches.test.ts b/packages/core/test/plugin/provider-opencode-watches.test.ts index a88c3ac67619..f582ae639636 100644 --- a/packages/core/test/plugin/provider-opencode-watches.test.ts +++ b/packages/core/test/plugin/provider-opencode-watches.test.ts @@ -38,10 +38,11 @@ const watchEvent = ( readonly body?: string readonly status?: string | null readonly routingKey?: string + readonly watchID?: string } = {}, ) => ({ id, - watchID: "ew_1", + watchID: overrides.watchID ?? "ew_1", sessionID, source: overrides.source ?? "github", routingKey: overrides.routingKey ?? "github:acme/app#1", @@ -590,6 +591,49 @@ describe("OpencodePlugin event watches", () => { ), ) + it.effect("keeps resuming an unattended watch past 20 since the prompt, while other watches still wait", () => + withConsole({}, (console) => + Effect.gen(function* () { + const { host, wakes } = yield* start(console) + const session = yield* host.session.create({}) + yield* (yield* watchTool("watch")).execute( + { server: "slack", event: "slack.mention", unattended: true }, + context(session.id), + ) + expect(console.state.requests.find((request) => request.method === "POST")?.body).toEqual({ + sessionID: session.id, + server: "slack", + event: "slack.mention", + arguments: {}, + }) + yield* waitUntil(Effect.sync(() => console.state.opens === 1)) + for (const index of Array.from({ length: 25 }, (_, index) => index)) { + yield* deliver(console, watchEvent(session.id, `evt_${index}`, { watchID: "ew_new" })) + yield* TestClock.adjust("7 minutes") + } + yield* deliver(console, watchEvent(session.id, "evt_other")) + expect(wakes.map((wake) => wake.resume)).toEqual([...Array.from({ length: 25 }, () => true), false]) + }), + ), + ) + + it.effect("holds an unattended watch's sixth update in 10 minutes, CI included", () => + withConsole({}, (console) => + Effect.gen(function* () { + const { host, wakes } = yield* start(console) + const session = yield* host.session.create({}) + yield* (yield* watchTool("watch")).execute({ target: "acme/app#1", unattended: true }, context(session.id)) + yield* waitUntil(Effect.sync(() => console.state.opens === 1)) + for (const index of [1, 2, 3, 4, 5, 6]) + yield* deliver( + console, + watchEvent(session.id, `evt_${index}`, { watchID: "ew_new", kind: "workflow_run", status: "success" }), + ) + expect(wakes.map((wake) => wake.resume)).toEqual([true, true, true, true, true, false]) + }), + ), + ) + it.effect("resumes a held session with a new update after 30 quiet minutes, but not with the held one replayed", () => withConsole({}, (console) => Effect.gen(function* () { From fb40f64d0ced75cc7cb79c77840a5c34dcfc91ca Mon Sep 17 00:00:00 2001 From: James Long Date: Thu, 19 Nov 2026 11:20:07 -0500 Subject: [PATCH 013/108] fix(core): hide glob, grep, and webfetch for every model under full_codemode (#64906) --- packages/core/src/session/context.ts | 7 ++- packages/core/src/tool.ts | 5 +- packages/core/src/tool/model-policy.ts | 55 ++++++++++---------- packages/core/test/tool-model-policy.test.ts | 28 ++++++++-- 4 files changed, 62 insertions(+), 33 deletions(-) diff --git a/packages/core/src/session/context.ts b/packages/core/src/session/context.ts index 7ea4ba50fe98..acba63227a60 100644 --- a/packages/core/src/session/context.ts +++ b/packages/core/src/session/context.ts @@ -166,7 +166,12 @@ const layer = Layer.effect( const policyModel = selected?.info ?? (fallbackRef && Model.Info.default(fallbackRef.providerID, fallbackRef.id)) const tools = yield* registry.snapshot(permissions, { services, - tools: modelTools({ model: policyModel, websearch: hasWebSearch, fullCodeMode }), + // An agent that can't run `execute` (such as explore) keeps every tool direct, so give it the flag-off policy. + tools: modelTools({ + model: policyModel, + websearch: hasWebSearch, + fullCodeMode: fullCodeMode && Tool.codeModeAvailable(permissions), + }), }) const loaded = yield* Effect.all( { diff --git a/packages/core/src/tool.ts b/packages/core/src/tool.ts index e31f047ed0be..28111f4bc123 100644 --- a/packages/core/src/tool.ts +++ b/packages/core/src/tool.ts @@ -306,7 +306,7 @@ const layer = Layer.effect( Effect.gen(function* () { const rules = permissions ?? [] // Without Code Mode its tools would be unreachable, so expose them as direct tools instead. - const codeModeEnabled = !whollyDisabled("execute", rules) + const codeModeEnabled = codeModeAvailable(rules) const full = codeModeEnabled && options?.services !== undefined && (yield* flags.enabled("full_codemode")) const data = state.get() if (catalogData !== data) { @@ -474,6 +474,9 @@ const whollyDisabled = (action: string, rules: Permission.Ruleset) => { return rule?.resource === "*" && rule.effect === "deny" } +/** Whether the rules leave Code Mode's `execute` reachable, as `snapshot` decides it. */ +export const codeModeAvailable = (rules: Permission.Ruleset) => !whollyDisabled("execute", rules) + const CATALOG_CACHE_LIMIT = 5 const formatSchemaIssue = SchemaIssue.makeFormatterDefault() diff --git a/packages/core/src/tool/model-policy.ts b/packages/core/src/tool/model-policy.ts index 262948ea651e..c231865dcf51 100644 --- a/packages/core/src/tool/model-policy.ts +++ b/packages/core/src/tool/model-policy.ts @@ -1,6 +1,7 @@ import type { Model } from "@opencode/schema/model" const codeModeBuiltIns = ["read", "write", "edit", "patch", "shell", "websearch"] as const +const fullCodeModeHidden = ["glob", "grep", "webfetch"] as const export interface ModelTools { readonly hidden: Set @@ -13,40 +14,40 @@ export function modelTools(input: { readonly fullCodeMode: boolean }): ModelTools { const hidden = new Set() - const direct = new Set() if (!input.websearch) hidden.add("websearch") - if (!input.model) { - if (input.fullCodeMode) { - for (const name of codeModeBuiltIns) { - if (!hidden.has(name)) direct.add(name) - } + // Code Mode programs search and fetch through shell and their `fetch` global, so these tools only add noise. + if (input.fullCodeMode) for (const name of fullCodeModeHidden) hidden.add(name) + + // GPT-5+ edits with patch; every other model edits with edit and write. + if (input.model) { + if (editMode(input.model) === "patch") { + hidden.add("edit") + hidden.add("write") + } else { + hidden.add("patch") } - return { hidden, direct } } - const id = input.model.id.toLowerCase() - const modelID = input.model.modelID.toLowerCase() - const gpt = gptMode(id, modelID) - if (gpt === "patch") { - hidden.add("edit") - hidden.add("write") - } else { - hidden.add("patch") + // With full_codemode, strong models (GPT and Claude) use the built-ins from inside Code Mode; + // every other model, or an unresolved one, keeps them as direct tools. + const direct = new Set() + if (input.fullCodeMode && !strongModel(input.model)) { + for (const name of codeModeBuiltIns) { + if (!hidden.has(name)) direct.add(name) + } } + return { hidden, direct } +} - if (!input.fullCodeMode) return { hidden, direct } - - if (gpt !== undefined || isAnthropic(input.model, id, modelID)) { - hidden.add("glob") - hidden.add("grep") - hidden.add("webfetch") - return { hidden, direct } - } +function editMode(model: Model.Info) { + return gptMode(model.id.toLowerCase(), model.modelID.toLowerCase()) +} - for (const name of codeModeBuiltIns) { - if (!hidden.has(name)) direct.add(name) - } - return { hidden, direct } +function strongModel(model: Model.Info | undefined) { + if (!model) return false + const id = model.id.toLowerCase() + const modelID = model.modelID.toLowerCase() + return gptMode(id, modelID) !== undefined || isAnthropic(model, id, modelID) } function gptMode(id: string, modelID: string): "patch" | "edit" | undefined { diff --git a/packages/core/test/tool-model-policy.test.ts b/packages/core/test/tool-model-policy.test.ts index 31505d591ea8..178d83020a46 100644 --- a/packages/core/test/tool-model-policy.test.ts +++ b/packages/core/test/tool-model-policy.test.ts @@ -83,6 +83,20 @@ describe("modelTools", () => { }) }) + test("hides glob, grep, and webfetch for every model when fullCodeMode is on", () => { + for (const model of [ + makeModel("openai", "gpt-5"), + makeModel("anthropic", "claude-sonnet-4-5"), + makeModel("deepseek", "deepseek-reasoner"), + makeModel("zhipu", "glm-5.3"), + makeModel("google", "gemini-4-neon"), + undefined, + ]) { + const { hidden } = policy(model) + for (const name of ["glob", "grep", "webfetch"]) expect(hidden).toContain(name) + } + }) + test("needs no demotion when fullCodeMode is off while still applying patch and websearch rules", () => { expect(policy(makeModel("openai", "gpt-5"), true, false)).toEqual({ direct: [], hidden: ["edit", "write"] }) expect(policy(makeModel("claude-agent", "opus"), false, false)).toEqual({ @@ -94,15 +108,15 @@ describe("modelTools", () => { test("keeps non-strong and absent models direct when fullCodeMode is on, hiding websearch when unavailable", () => { expect(policy(makeModel("deepseek", "deepseek-reasoner"))).toEqual({ direct: ["edit", "read", "shell", "websearch", "write"], - hidden: ["patch"], + hidden: ["glob", "grep", "patch", "webfetch"], }) expect(policy(undefined, true, true)).toEqual({ direct: ["edit", "patch", "read", "shell", "websearch", "write"], - hidden: [], + hidden: ["glob", "grep", "webfetch"], }) expect(policy(undefined, false, true)).toEqual({ direct: ["edit", "patch", "read", "shell", "write"], - hidden: ["websearch"], + hidden: ["glob", "grep", "webfetch", "websearch"], }) }) }) @@ -267,13 +281,19 @@ describe("SessionContext.select model tool policy", () => { const directInstructions = (yield* readInitial(gptDirect.instructions)).text expect(directInstructions).toContain("Alpha docs") expect(directInstructions).not.toContain("through `execute`") + // Without `execute`, as for the explore agent, the search and fetch tools stay direct. + for (const name of ["glob", "grep", "webfetch"]) expect(names(gptDirect)).toContain(name) + const deepseekDirect = yield* select("deepseek", "deepseek-reasoner", [ + { action: "execute", resource: "*", effect: "deny" }, + ]) + for (const name of ["glob", "grep", "webfetch"]) expect(names(deepseekDirect)).toContain(name) const claude = yield* select("anthropic", "claude-sonnet-4-5") expect(names(claude)).toEqual(["execute"]) expect(paths(claude).join(",")).toBe("alpha.search,edit,opencode.session_move,read,shell,websearch,write") const deepseek = yield* select("deepseek", "deepseek-reasoner") - expect(names(deepseek).join(",")).toBe("edit,glob,grep,read,shell,webfetch,websearch,write,execute") + expect(names(deepseek).join(",")).toBe("edit,read,shell,websearch,write,execute") expect(paths(deepseek)).toEqual(["alpha.search", "opencode.session_move"]) yield* websearch.select(false) From a8dbca1065cf3b5e35e4edc1e821335ca0ca5356 Mon Sep 17 00:00:00 2001 From: Filip Hejmowski <34747899+neriousy@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:24:13 +0100 Subject: [PATCH 014/108] fix(ai): classify Gemini terms-of-use refusals as content policy (#64910) --- packages/ai/src/provider-error.ts | 2 +- packages/ai/test/provider-error.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/provider-error.ts b/packages/ai/src/provider-error.ts index 609980b72b8b..21a765d71e7e 100644 --- a/packages/ai/src/provider-error.ts +++ b/packages/ai/src/provider-error.ts @@ -154,7 +154,7 @@ const QUOTA_TEXT = // Bedrock Mantle reuses it for schema validation; Anthropic reports blocked output // under `invalid_request_error`. The Vercel AI Gateway drops OpenAI's `moderation_blocked` code. const CONTENT_POLICY_TEXT = - /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected (?:as a result of our|by the) safety system|detected potentially unsafe or sensitive content/i + /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected (?:as a result of our|by the) safety system|detected potentially unsafe or sensitive content|rejected in accordance with our terms of use/i const SERVER_ERROR_TEXT = /\b(?:try again|(?:please |you can )?retry (?:the |this |your )?request|try (?:the |this |your )?request again|(?:currently |temporarily )?at capacity|overloaded|temporarily unavailable|service[-_\s]?unavailable|(?:server|internal)[-_\s]?error|server (?:is )?busy|provider returned (?:an )?error|resource[-_\s]?exhausted|upstream (?:connect|connection|request)|request buffer limit while retrying upstream)\b/i diff --git a/packages/ai/test/provider-error.test.ts b/packages/ai/test/provider-error.test.ts index 788d4706064c..cb0e877bf192 100644 --- a/packages/ai/test/provider-error.test.ts +++ b/packages/ai/test/provider-error.test.ts @@ -261,6 +261,19 @@ describe("provider error classification", () => { ).toBe("ContentPolicy") }) + test("classifies Gemini terms-of-use refusals as policy rejections, not authentication failures", () => { + const message = "Request rejected in accordance with our terms of use and policies." + const gemini = { error: { code: 403, message, status: "PERMISSION_DENIED" } } + const zen = { error: { type: "server_error", message: `Upstream request failed: [403] ${message}` } } + + expect( + [gemini, zen].map( + (body) => + classifyProviderFailure({ message: body.error.message, status: 403, rawBody: JSON.stringify(body) })._tag, + ), + ).toEqual(["ContentPolicy", "ContentPolicy"]) + }) + test("keeps invalid_prompt schema validation failures as invalid requests", () => { // Bedrock Mantle reports request validation failures under `invalid_prompt` // with a pydantic dump that lists every input union member's fields. From 193ced8f5c230b1c539ca1a08ef7b6de21a4cf8c Mon Sep 17 00:00:00 2001 From: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Date: Thu, 19 Nov 2026 21:59:58 +0530 Subject: [PATCH 015/108] feat(app): show the provider connect hint on Home (#64885) --- packages/app/src/home/route.tsx | 95 ++++++++++----- packages/app/src/new-session/view.tsx | 91 +-------------- packages/app/src/providers/connect/tip.tsx | 110 ++++++++++++++++++ .../src/runtime/persistence/consumers.test.ts | 3 +- 4 files changed, 183 insertions(+), 116 deletions(-) create mode 100644 packages/app/src/providers/connect/tip.tsx diff --git a/packages/app/src/home/route.tsx b/packages/app/src/home/route.tsx index 8a6c228c2d3f..6d291aaa487a 100644 --- a/packages/app/src/home/route.tsx +++ b/packages/app/src/home/route.tsx @@ -1,9 +1,12 @@ import { ScrollView } from "@opencode/ui/scroll-view" import { createMediaQuery } from "@solid-primitives/media" -import { onMount, Show } from "solid-js" +import { createMemo, onMount, Show } from "solid-js" import { useLayout } from "@/shell/state/layout" import { useSettings } from "@/settings/model" import { useProjectNavigation } from "@/shell/project-navigation" +import { createProviderTip, ProviderTip } from "@/providers/connect/tip" +import { ServerProvider } from "@/runtime/server/current" +import { useServers } from "@/runtime/server/registry" import { ProjectLanding } from "./projects/landing" import { createHomeController } from "./model" import { createHomeProjectsController } from "./projects/controller" @@ -50,6 +53,7 @@ function HomeOverview() { // The sidebar already lists sessions in side tabs and List, so Home drops its project column there and picks // the project from the search field instead. Top tabs have no sidebar and keep Home's column. projectScope={settings.appearance.navigationPrototype() && settings.appearance.tabLayout() === "vertical"} + providerTip /> ) } @@ -62,6 +66,7 @@ export function HomeView(props: { projectScope?: boolean /** Search filters the list in place rather than opening a results panel. */ searchInline?: boolean + providerTip?: boolean }) { const mobile = createMediaQuery("(max-width: 767px)") @@ -80,35 +85,40 @@ export function HomeView(props: {
- scroll.viewport.update(event.currentTarget.scrollTop)} - > -
+ scroll.viewport.update(event.currentTarget.scrollTop)} + > +
- - - - : undefined} - searchInline={props.searchInline} - /> -
-
+ } + > + + + + : undefined} + searchInline={props.searchInline} + /> +
+
+ + + +