From 3d195e7c108778ce9ccf1636e41afeb47e8dc017 Mon Sep 17 00:00:00 2001 From: Filip Hejmowski Date: Sat, 7 Nov 2026 04:18:40 +0100 Subject: [PATCH] feat(app): ship the media panel without the session_media flag --- .../client/src/promise/generated/types.ts | 1 - packages/core/src/plugin/media.ts | 4 +- packages/gui-plugins/src/media/renderer.tsx | 67 ++----------------- packages/protocol/openapi.json | 3 - packages/schema/src/config/flag.ts | 2 - packages/schema/src/session-media.ts | 2 +- 6 files changed, 7 insertions(+), 72 deletions(-) diff --git a/packages/client/src/promise/generated/types.ts b/packages/client/src/promise/generated/types.ts index 95c49a2f86f..34bfca3f712 100644 --- a/packages/client/src/promise/generated/types.ts +++ b/packages/client/src/promise/generated/types.ts @@ -2551,7 +2551,6 @@ export type ConfigEntry = media_blob?: boolean schedules?: boolean artifacts?: boolean - session_media?: boolean part_rows?: boolean image_generate?: boolean | { model?: string | { providerID: string; model: string; variant?: string } } subagent_depth?: number diff --git a/packages/core/src/plugin/media.ts b/packages/core/src/plugin/media.ts index b33b11e346f..470b67cfa67 100644 --- a/packages/core/src/plugin/media.ts +++ b/packages/core/src/plugin/media.ts @@ -4,7 +4,6 @@ import { define } from "@opencode/plugin/effect/plugin" import { SessionMedia } from "@opencode/schema/session-media" import { SessionMessage } from "@opencode/schema/session-message" import { DateTime, Effect } from "effect" -import { Flag } from "../flag.js" import { Session } from "../session.js" import { SessionSchema } from "../session/schema.js" import { collect } from "./media/collect.js" @@ -13,13 +12,12 @@ import { collect } from "./media/collect.js" export const DEFAULT_LIMIT = 200 /** - * The Media panel's server half, behind the `session_media` flag: it reads a session's history a page at a time and + * The Media panel's server half: it reads a session's history a page at a time and * returns the images, videos and links in it, so the app lists a whole session without loading its messages. */ export const Plugin = define({ id: "opencode.media", effect: Effect.fn(function* (ctx) { - if (!(yield* Flag.enabled("session_media"))) return const session = yield* Session.Service yield* ctx.rpc diff --git a/packages/gui-plugins/src/media/renderer.tsx b/packages/gui-plugins/src/media/renderer.tsx index 0833ab9547f..9e2da82eff4 100644 --- a/packages/gui-plugins/src/media/renderer.tsx +++ b/packages/gui-plugins/src/media/renderer.tsx @@ -1,26 +1,13 @@ import { lazy, onCleanup, Suspense } from "solid-js" import { Icon } from "@opencode/ui/icon" -import type { ConfigEntry } from "@opencode/client/promise" -import { - Command, - createKeyed, - MenuItem, - Panel, - Style, - type MountedSession, - type PanelTab, - type Plugin, -} from "@opencode/plugin/gui" +import { Command, MenuItem, Panel, Style, type PanelTab, type Plugin } from "@opencode/plugin/gui" import { onIdle } from "@opencode/plugin/gui/builtin" import type Media from "./index" import styles from "./media.css?inline" const TAB = "main" -/** - * The session's Media panel: the images, videos and links the user and the agent shared, behind the - * `session_media` feature flag of the session's directory. Turning the flag off stops listing the tab, which closes it. - */ +/** The session's Media panel: the images, videos and links the user and the agent shared. */ const setup: Plugin.Setup = (ctx) => { const layout = ctx.layout const sessions = ctx.sessions @@ -31,31 +18,12 @@ const setup: Plugin.Setup = (ctx) => { onIdle(() => { const session = sessions.current() - if (session && enabled(session)) void MediaPanel.preload() + if (session) void MediaPanel.preload() }), ) ctx.add(Style, styles) - // The flag lives in the session directory's config, which only some screens load; the panel needs it on every one. - createKeyed( - () => { - const session = sessions.current() - - return session && { server: session.server, directory: session.directory, connected: session.server.connected } - }, - (current) => { - if (current?.connected) - void current.server.data.location.config.sync({ directory: current.directory }).catch(() => {}) - }, - { - equals: (previous, next) => - previous?.server === next?.server && - previous?.directory === next?.directory && - previous?.connected === next?.connected, - }, - ) - // One tab object for every session, so a session switch never renders its trigger again. const tab: PanelTab = { id: TAB, @@ -73,7 +41,7 @@ const setup: Plugin.Setup = (ctx) => { ctx.add(Panel, { id: TAB, region: "side", - list: (input) => (input.open.includes(TAB) && enabled(input.session) ? [tab] : []), + list: (input) => (input.open.includes(TAB) ? [tab] : []), render: (props) => ( @@ -84,7 +52,7 @@ const setup: Plugin.Setup = (ctx) => { const available = () => { const session = sessions.current() - return !!session && !layout.narrow() && enabled(session) + return !!session && !layout.narrow() } const show = () => { @@ -93,7 +61,6 @@ const setup: Plugin.Setup = (ctx) => { if (session && available()) layout.open(key, session, { tab: "select" }) } - // Listed only while the flag is on, so a release build never offers it. ctx.add(Command, (): Command | undefined => available() ? { id: "open", title: ctx.t("command.open"), group: ctx.t("command.category.view"), editable: true, run: show } @@ -118,28 +85,4 @@ const setup: Plugin.Setup = (ctx) => { }) } -/** - * Whether `session_media` is on where the session lives, as Core's `Flag.resolve` decides it from config: the - * highest-priority document that sets `experimental` names it, else `all_flags`, else it is on in local and dev - * builds. `OPENCODE_FLAGS` only reaches the server, so the app cannot see it. - */ -function enabled(session: MountedSession) { - const entries = session.server.data.location.config.list({ directory: session.directory }) ?? [] - const configured = latest(entries, () => true)?.session_media - - if (configured !== undefined) return configured - - if (latest(entries, (experimental) => experimental.all_flags !== undefined)?.all_flags === true) return true - - return import.meta.env.DEV || ["local", "dev"].includes(import.meta.env.VITE_OPENCODE_CHANNEL ?? "") -} - -type Experimental = NonNullable["info"]["experimental"]> - -function latest(entries: readonly ConfigEntry[], match: (experimental: Experimental) => boolean) { - return entries - .flatMap((entry) => (entry.type === "document" && entry.info.experimental ? [entry.info.experimental] : [])) - .findLast(match) -} - export default setup diff --git a/packages/protocol/openapi.json b/packages/protocol/openapi.json index 1a1540e6811..7d743594ea1 100644 --- a/packages/protocol/openapi.json +++ b/packages/protocol/openapi.json @@ -16673,9 +16673,6 @@ "artifacts": { "type": "boolean" }, - "session_media": { - "type": "boolean" - }, "part_rows": { "type": "boolean" }, diff --git a/packages/schema/src/config/flag.ts b/packages/schema/src/config/flag.ts index 216368466a5..8bfe2f9f974 100644 --- a/packages/schema/src/config/flag.ts +++ b/packages/schema/src/config/flag.ts @@ -15,7 +15,5 @@ export const registry = { media_blob: "Store new session media once in a deduplicated blob table instead of inline in every message row.", schedules: "Enable experimental scheduled tasks that wake a session with a prompt.", artifacts: "Enable experimental artifacts backed by pluggable providers.", - session_media: - "Show a Media panel in the desktop and web app that lists the images, videos and links shared in a session, by you or the agent.", } as const satisfies Record export type Key = keyof typeof registry diff --git a/packages/schema/src/session-media.ts b/packages/schema/src/session-media.ts index 73a409cf503..b3703c1adde 100644 --- a/packages/schema/src/session-media.ts +++ b/packages/schema/src/session-media.ts @@ -80,7 +80,7 @@ export const MAX_LIMIT = 500 /** * Experimental: may change without compatibility guarantees. * - * The Media panel's RPC, behind the `session_media` flag. `list` reads up to `limit` of a session's messages, newest + * The Media panel's RPC. `list` reads up to `limit` of a session's messages, newest * first, from the newest or from `cursor` (a page's `next`), and returns the images, videos and links they carry. The * schemas are Standard Schemas too, so Promise clients can call it. */