Skip to content

Commit 2aa5304

Browse files
committed
fix(plugin): add codex selection context alias
Register `codex.context.selection` as the compatibility alias for `codex.attachSelection` so all context attachment commands have matching alias coverage. Extend the plugin helper test to activate the bundled plugin and verify the selection command registration path.
1 parent accfe9d commit 2aa5304

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

plugins/codex.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ function registerCommands(red: Red.RedAPI): void {
266266
registerCommandAlias(red, "codex.context.currentFile", "codex.attachCurrentFile", () =>
267267
addCurrentFileContext(red),
268268
);
269+
registerCommandAlias(red, "codex.context.selection", "codex.attachSelection", () =>
270+
addSelectionContext(red),
271+
);
269272
registerCommandAlias(red, "codex.context.gitDiff", "codex.attachGitDiff", () =>
270273
addGitDiffContext(red),
271274
);

scripts/test-codex-plugin-root-ids.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ npx -y -p typescript tsc \
1616
node <<NODE
1717
const codex = require("$OUT_DIR/codex.js");
1818
19+
(async () => {
1920
const first = codex.__testRootScopedCodexIds("/tmp/project-one");
2021
const firstWithSlash = codex.__testRootScopedCodexIds("/tmp/project-one/");
2122
const second = codex.__testRootScopedCodexIds("/tmp/project-two");
@@ -64,6 +65,25 @@ if (codex.__testPromptSubmitBlockedReason("ready") !== undefined) {
6465
if (!codex.__testDisconnectedActionHint().includes("codex.reconnect")) {
6566
throw new Error("disconnected chats must advertise the reconnect command");
6667
}
68+
69+
const registeredCommands = [];
70+
await codex.activate({
71+
addCommand: (name) => registeredCommands.push(name),
72+
on: () => {},
73+
onPluginWindowEvent: () => {},
74+
});
75+
for (const name of [
76+
"codex.attachSelection",
77+
"codex.context.selection",
78+
]) {
79+
if (!registeredCommands.includes(name)) {
80+
throw new Error(\`Codex command \${name} was not registered\`);
81+
}
82+
}
83+
})().catch((error) => {
84+
console.error(error);
85+
process.exit(1);
86+
});
6787
NODE
6888

6989
echo "Codex plugin helper test passed."

0 commit comments

Comments
 (0)