GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — fix(core): preserve legacy variant in markdown commands by neriousy · Pull Request #65118 · anomalyco/opencode Conversation
|
| return | ||
| } | ||
| const info = decodeCommand({ ...markdown.data, template: markdown.content.trim() }) | ||
| // Join legacy model + variant before decoding. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This block is identical to the one in packages/core/src/config/plugin/agent.ts (and ConfigMigrateV1.modelSelection implements the same precedence). Could it be one shared helper, e.g. next to ConfigMarkdown, so agents and commands can't drift apart?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done: the join now lives in ConfigMarkdown.joinLegacyVariant (packages/core/src/config/markdown.ts), and both the agent and command decoders call it. I didn't reuse ConfigMigrateV1.modelSelection: it returns a structured selection, renames retired provider IDs and drops a model it can't parse. Here an invalid model should still fail decoding and skip the file with a warning.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The refactor looks right, and I agree with not reusing ConfigMigrateV1.modelSelection.
ConfigMarkdown.joinLegacyVariant (packages/core/src/config/markdown.ts:24-30) uses the same checks as the inline block it replaced in agent.ts. A string model without # gets joined with a variant that has no #. Everything else is passed through as it was.agent.ts:168-173 only the native path calls the helper. Legacy agents still go through ConfigMigrateV1.migrateAgent, which joins the variant itself, so nothing gets joined twice.modelSelection doesn't fit: v1/config/migrate.ts:68 returns undefined for a model it can't parse. Decoding never sees that model, so the file loads with no model instead of being skipped with a warning. It also renames retired provider IDs and returns a structured value, neither of which belongs in the native decode path. Keeping the two separate is the right call.What I checked: I ran bun run test test/config against pr/head in a temporary worktree: 294 pass, 1 skip, 0 fail. I couldn't run bun typecheck there; it stopped with Script not found "check", which is a problem with my setup, not the PR. CI or your local run covers that.
Changes: none. The shared checkout is on an older detached commit (101008fd3) with bun.lock modified by someone else. I left both as they were and removed my temporary worktree.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const decode = Schema.decodeUnknownSync(Info) | ||
|
|
||
| describe("ConfigCommandPlugin.Plugin", () => { | ||
| for (const item of [ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The table has nine cases plus a ~50-line harness for an 11-line fix. Could you cut it down to the core cases: a separate legacy variant gets merged, and an embedded #low wins over a separate variant: high? The structured and standalone cases mostly retest existing decoding.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done: it's down to the two core cases (a separate legacy variant gets merged, and an embedded #low wins over variant: high), and the harness only records switchModel. I checked that the merge case fails when the join is removed. The agent tests already cover the full precedence matrix for the shared helper.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good, this resolves the thread.
command.test.ts (lines 77–94) is down to the two core cases. runMarkdownCommand only records switchModel and stubs out the rest.ConfigMarkdown.joinLegacyVariant (src/config/markdown.ts) was the right call: agent.ts and command.ts now run the same code. That means the agent test matrix in test/config/agent.test.ts:67-90 (separate, embedded, structured, standalone, plus the embedded and structured cases with an ignored separate variant) covers the helper, so the command tests don't need to repeat it.What I checked on pr/head (76c4822): test/config/command.test.ts gives 41 pass, 0 fail, and test/config/agent.test.ts gives 37 pass, 0 fail. I didn't re-run your mutation check (removing the join), because that would mean editing source in the shared checkout.
I made no changes. bun.lock was already modified in the worktree and I left it as it was.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Both earlier points are addressed: the join is now one shared ConfigMarkdown.joinLegacyVariant helper used by both the agent and command loaders, and the tests are cut down to the two core cases. I re-ran the #65089 repro from source with a mock provider: a command with a separate variant: high now switches the session to high. The command, agent and markdown config tests pass, and so does typecheck:tsc. The public API is unchanged. Nothing else to raise.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
core: Markdown commands discard separate legacy variants
There was an error while loading. Please reload this page.