fix(doctor): guard tui.json tuple plugin entries in TUI plugin check (fixes #5786)#5801
fix(doctor): guard tui.json tuple plugin entries in TUI plugin check (fixes #5786)#5801MoerAI wants to merge 1 commit into
Conversation
…ixes code-yeongyu#5786) detectTuiPluginRegistration and detectServerPluginRegistration passed the raw parsed plugin array straight into predicates that call String.startsWith. OpenCode plugin config accepts tuple entries of the form [pathOrPackage, options], so a valid tui.json such as ["oh-my-openagent", ["./local.tsx", { ... }]] made .some(isNamedTuiPluginEntry) call .startsWith on the tuple, throw a TypeError, get swallowed by the broad try/catch, and return an all-false registration. Doctor then emitted a false "TUI plugin entry missing from tui.json" warning even though the entry was present. Filter the plugin array to strings before evaluating the predicates, matching the existing pluginEntries() guard already used in add-tui-plugin-to-tui-config.ts. Reproduction (before): checkTuiPluginConfig() with tui.json ["oh-my-openagent", ["./local-tui-plugin.tsx", { label: "custom" }]] returned status "warn" (TUI plugin entry missing). Verification (after): returns status "pass" with no issues. Doctor check suite 158 pass; the single spawn-with-timeout failure is a pre-existing Windows subprocess flake reproduced on unmodified dev. tsgo -p packages/omo-opencode clean.
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f56b615c30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| const parsed = parseJsonc<OpenCodeConfigShape>(readFileSync(configPath, "utf-8")) | ||
| const plugins = parsed.plugin ?? [] | ||
| const plugins = (parsed.plugin ?? []).filter((entry): entry is string => typeof entry === "string") |
There was a problem hiding this comment.
Extract plugin names from tuple entries
When a user registers OMO itself with OpenCode's tuple form, e.g. ["oh-my-openagent", { ... }] in opencode.json, this filter drops the only server entry instead of normalizing it to the first tuple element. The rest of the repo already treats tuple entries as valid by taking plugin[0] in loadOpencodePlugins(), so checkTuiPluginConfig() will now report the server plugin missing even though OpenCode will load it; the same issue exists for the analogous tui.json filter below. Please normalize tuple entries to their first string element rather than filtering all non-strings out.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fix false positive in doctor check by filtering out non-string plugin entries. Small, safe change with regression test.
Re-trigger cubic
Summary
omo doctorfalsely reportedTUI plugin entry missing from tui.jsonwhenevertui.jsoncontained a valid"oh-my-openagent"entry alongside a tuple plugin entry such as["./plugin.tsx", { ... }]. The tuple made a doctor predicate throw aTypeError, which the broadtry/catchswallowed into an all-false registration state.Root Cause
detectTuiPluginRegistration()anddetectServerPluginRegistration()intui-plugin-config.tsfed the raw parsedpluginarray into predicates typed(entry: string)that callString.startsWith:OpenCode plugin config accepts tuple entries of the form
[pathOrPackage, options]. Whentui.jsonholds["oh-my-openagent", ["./local.tsx", { ... }]],.some(isNamedTuiPluginEntry)iterates past the string entry, reaches the tuple, callsentry.startsWith(...)on an array, and throwsTypeError: entry.startsWith is not a function. The surroundingcatchtreats that as an absent registration and returnsregistered: false, so doctor emits the misleading missing-entry warning.Changes
packages/omo-opencode/src/cli/doctor/checks/tui-plugin-config.tspluginarray to strings before evaluating predicates, in bothdetectTuiPluginRegistration()anddetectServerPluginRegistration()packages/omo-opencode/src/cli/doctor/checks/tui-plugin-config.test.tstui.jsonpairs the package entry with a tuple plugin entryThe fix reuses the exact guard already used by
pluginEntries()inadd-tui-plugin-to-tui-config.ts:.filter((entry): entry is string => typeof entry === "string").Reproduction (before fix)
Verification (after fix)
Test
packages/omo-opencode/src/cli/doctor/checks/tui-plugin-config.test.ts(1 case added)bun test packages/omo-opencode/src/cli/doctor/— 158 pass. The singlespawn-with-timeoutfailure ("returns stdout and exit code") is a pre-existing Windows subprocess flake that reproduces identically on unmodifieddev, unrelated to this change.tsgo -p packages/omo-opencode/tsconfig.json --noEmit— clean (exit 0)Fixes #5786
Summary by cubic
Fixes a false “TUI plugin entry missing from tui.json” warning in
omo doctorwhentui.jsonincludes tuple plugin entries. We now ignore tuple entries during checks so validoh-my-openagentregistrations pass.detectTuiPluginRegistration()anddetectServerPluginRegistration()to avoid calling string methods on tuples.["oh-my-openagent", ["./local-tui-plugin.tsx", { ... }]].Written for commit f56b615. Summary will update on new commits.