Repository navigation
fix(opencode): regenerate shared status plugin for OPENCODE_CONFIG_DIR - #22768
leilei3167 wants to merge 2 commits into
Conversation
When OPENCODE_CONFIG_DIR still points at userData/opencode-hooks/shared, also rewrite that copy so OpenCode does not keep loading a pre-setup() template. Fixes stablyai#22764.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Shared-dir plugin refresh —
OpenCodeHookService.buildPtyEnvnow also writes the current template into<userData>/<legacyHooksDir>/sharedin the managed branch, so an inheritedOPENCODE_CONFIG_DIRthat still points atopencode-hooks/sharedno longer loads the stale pre-setup()server:-only module. The branch still returns{}, so no newOPENCODE_CONFIG_DIRoverride is introduced. - Regression test — seeds a stale
server:-only shared plugin, callsbuildPtyEnv(id, sharedDir), and asserts both the shared and global plugin files equal the current template. This genuinely fails without the added write.
Verification: pnpm exec vitest run --config config/vitest.config.ts src/main/opencode/hook-service.test.ts → 35/35 pass. The overlay branch (user-set config dir) is untouched, and the SSH/relay path uses a separate PluginOverlayManager, so neither is affected.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughIn the no-existing-config or managed-config branch, Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The shared plugin is refreshed even if the global config write fails. No merge-blocking issue was identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change should repair stale plugins in the legacy directory without changing how the config directory is selected. The additional file write warrants review because an existing filesystem link could redirect it, and an interrupted update could leave the two copies different. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: cb553950-6bd6-48c8-9801-e6d8f50c05fa
📒 Files selected for processing (2)
src/main/opencode/hook-service.test.tssrc/main/opencode/hook-service.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Keep the managed OPENCODE_CONFIG_DIR write independent of the resolved config-dir write so a failure on one path cannot leave a stale shared plugin loaded.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Independent plugin writes — In the managed
buildPtyEnvbranch, the global~/.config/opencodewrite and the shared<userData>/<legacyHooksDir>/sharedwrite now run in separate best-efforttryblocks, so the shared copy refreshes even when the global write throws. Addresses the CodeRabbit finding onhook-service.ts:141. - Failure-path regression test — New test blocks
<resolved>/pluginswith a file so the resolved-dir write throws, then asserts the shared plugin still receives the current template.
Verified hook-service.test.ts 36/36 pass and oxlint reports 0 warnings/errors on both changed files. The prior Pullfrog review had no findings or open threads; the CodeRabbit thread is resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Closing as superseded by merged #23500 and #24610 after reproducing #22764 with installed OpenCode 2.0.16 and reviewing this PR's complete two-file scope. Both shared and global copies refresh without adding a config-directory override, and shared refresh survives a blocked global installation. A real turn using the repaired shared directory reports Working → Done. The current implementation refreshes existing legacy copies and inherited overlays; it avoids recreating an absent legacy directory. This is behavior coverage, not a claim that this branch was merged. Actual execution was on macOS; the original Ubuntu installation was not tested. Thanks @leilei3167 for the repair and regression intent, and @santiagofn for the report. Detailed reproduction is recorded on #22764. |

ELI5
Orca can still point OpenCode at an old shared config folder under its own user data. That folder kept an outdated status plugin that OpenCode 2 refuses to load. This change rewrites that shared copy whenever Orca installs the current plugin, so the folder OpenCode actually reads matches the fixed template.
What Changed
OPENCODE_CONFIG_DIRbranch,buildPtyEnvonly wroteorca-opencode-status.jsinto the user's global OpenCode config (~/.config/opencode). A leftoveruserData/opencode-hooks/sharedcopy with a pre-setup()server:-only default stayed on disk, and any shell that still exported that shared path kept failing withMissing key at ["default"]["setup"].getSharedConfigDir()(userData/opencode-hooks/shared), so the path OpenCode loads and the path Orca refreshes stay aligned. Global discovery still returns{}(no newOPENCODE_CONFIG_DIRoverride).server:-only shared plugin, callsbuildPtyEnvwith that shared dir, and asserts both the shared and global plugin files get the current template.Why
#20407 / #22234 / #22440 fixed the generated template and duplicate-id install into the global plugins dir, but they did not refresh the legacy shared directory that older installs and inherited env still hand to OpenCode via
OPENCODE_CONFIG_DIR. Rewriting that shared copy is the smallest fix that matches the load path without changing overlay behavior or re-introducing a forced config-dir override. Alternatives considered: stop exporting the shared dir and rely only on~/.config/opencode(larger spawn/env cleanup, risks breaking shells that still inherit the shared path), or migrate users off the shared dir in place (out of scope for this residual load failure).Linked Issue
Fixes #22764
Visual Proof
N/A — plugin file materialization on disk only; no UI or interaction change.
Testing
Regression:
pnpm exec vitest run --config config/vitest.config.ts src/main/opencode/hook-service.test.tsregenerates a stale shared legacy plugin when OPENCODE_CONFIG_DIR points at itleft the shared file asserver:-only.hook-service.test.tssuite 35/35.buildPtyEnvpath); no Electron UI run for this PR.AI Disclosure
Review
{}so global OpenCode discovery is not overridden.OPENCODE_CONFIG_DIRpoints at the legacy shared dir.hook-service.ts291/300, test 661/800).hook-service.ts+ its test; no overlay / spawn / shell-wrapper changes.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Linux is the reported failure site; the rewrite runs on every platform that uses
OpenCodeHookService.buildPtyEnv. Overlay mode (user-set config dir ≠ shared) is unchanged.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)