Skip to content

fix: dynamic frameworkLogger import + server static file fixes#15

Closed
htafolla wants to merge 1 commit intomasterfrom
fix/plugin-import-server-static-files
Closed

fix: dynamic frameworkLogger import + server static file fixes#15
htafolla wants to merge 1 commit intomasterfrom
fix/plugin-import-server-static-files

Conversation

@htafolla
Copy link
Copy Markdown
Owner

Problem

OpenCode TUI renders a blank black screen on launch due to a broken import in the codex injection plugin.

Root cause: PR #12 replaced console.warn with frameworkLogger.log() but used a static import path ../core/framework-logger.js that only resolves correctly from dist/plugin/. When the compiled plugin is loaded from .opencode/plugins/ (where OpenCode discovers it), the relative path resolves to .opencode/core/ — which doesn't exist. Bun throws ERR_MODULE_NOT_FOUND and OpenCode silently fails to initialize.

Changes

Plugin (src/plugin/strray-codex-injection.ts)

  • Replaced static frameworkLogger import with dynamic loader + noop fallback
  • Uses the same ../../dist/core/../core/ candidate-path pattern already used by loadConfigPaths() and importSystemPromptGenerator()
  • Plugin works from both dist/plugin/ and .opencode/plugins/ without modification

Server (src/cli/server.ts)

  • Fixed PUBLIC_DIR to resolve to project-root/public/ (was dist/public/ which doesn't exist at runtime)
  • Added 404 guard on sendFile for index.html
  • Moved error handler middleware before app.listen() so Express actually registers it
  • Replaced console.error with frameworkLogger

Build (package.json)

  • Build script now copies public/* to dist/public/

Verification

  • npm test — 2399 tests passing
  • opencode debug config --print-logs --log-level DEBUG — no ERROR lines, plugin loads successfully
  • bun -e "import('./.opencode/plugins/strray-codex-injection.js')" — loads OK

…r static file fixes

Plugin: Replace static frameworkLogger import with dynamic loader
matching the existing candidate-path pattern used for config-paths
and system-prompt-generator. The static import '../core/framework-logger.js'
resolves to .opencode/core/ when the compiled plugin is loaded from
.opencode/plugins/, causing a blank screen in OpenCode TUI.

Server: Fix PUBLIC_DIR to resolve to project root public/, add 404
guard on sendFile for index.html, move error handler middleware before
app.listen() so Express registers it, replace console.error with
frameworkLogger.
@htafolla
Copy link
Copy Markdown
Owner Author

Superseded by PRs #25 (init.sh fallback), #26 (Docker import resolution), and subsequent merges. The dynamic frameworkLogger import pattern was reimplemented better in #26 with import.meta.url + Docker-aware path resolution. Server static file fixes were already applied independently.

@htafolla htafolla closed this Mar 30, 2026
@htafolla htafolla deleted the fix/plugin-import-server-static-files branch March 31, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant