fix: remove duplicate workspace plugin route and improve logging

This commit is contained in:
Chris Scott committed 2026-04-20 23:29:10 -04:00
1 parent d07eb7f523
commit 4407ad15fb
3 files changed
+10 -12

No files matched your search

-7
View File
@@ -432,11 +432,4 @@ attachWorkspacePluginWs(server, {
pathPrefix: '/api/opencode',
})
attachWorkspacePluginWs(server, {
upstreamBaseUrl: OPENCODE_SERVER_URL,
verifyAuth: verifyPluginBearerAuth,
projectService,
pathPrefix: '/api/workspace-plugin/opencode',
})
logger.info(`🚀 OpenCode WebUI API running on http://${HOST}:${PORT}`)
+7 -4
View File
@@ -73,8 +73,14 @@ export function createWorkspacePluginRoutes(db: Database) {
})
app.all('/opencode/:slug/*', async (c) => {
const slug = c.req.param('slug')
const inbound = c.req.raw
const inboundUrl = new URL(inbound.url)
logger.info(`workspace-plugin proxy inbound: ${inbound.method} ${inboundUrl.pathname}${inboundUrl.search} slug=${slug}`)
const session = c.get('session')
if (!session) {
logger.warn(`workspace-plugin proxy: unauthorized (no session) slug=${slug} path=${inboundUrl.pathname}`)
return c.json({ error: 'Unauthorized' }, 401)
}
@@ -84,10 +90,6 @@ export function createWorkspacePluginRoutes(db: Database) {
return c.json({ error: 'Forbidden: insufficient token scope' }, 403)
}
const slug = c.req.param('slug')
const inbound = c.req.raw
const inboundUrl = new URL(inbound.url)
const rewritten = new URL(inbound.url)
const prefix = `/api/workspace-plugin/opencode/${slug}`
const rest = inboundUrl.pathname.slice(prefix.length) || '/'
@@ -102,6 +104,7 @@ export function createWorkspacePluginRoutes(db: Database) {
duplex: 'half',
})
logger.info(`workspace-plugin proxy forward: ${forwarded.method} ${rewritten.pathname}${rewritten.search} -> upstream opencode (slug=${slug})`)
return proxyRequest(forwarded, projectService)
})
+3 -1
View File
@@ -50,7 +50,9 @@ export function makeAdaptor(cfg: { url: string; token: string }, project: Manage
export const OpencodeManagerWorkspacePlugin: Plugin = async ({ experimental_workspace }, options) => {
try {
const cfg = resolveConfig(options)
pluginLogger.info(`plugin.init url=${cfg.url}`)
pluginLogger.info(
`plugin.init url=${cfg.url} env.OPENCODE_EXPERIMENTAL_WORKSPACES=${process.env.OPENCODE_EXPERIMENTAL_WORKSPACES ?? "unset"} env.OPENCODE_EXPERIMENTAL=${process.env.OPENCODE_EXPERIMENTAL ?? "unset"}`,
)
const client = new ManagerClient(cfg.url, cfg.token)
const projects = await client.listProjects()
pluginLogger.info(`plugin.init loaded ${projects.length} project(s)`)