From a3e0169c3d75dfbc384d54680801c2c00fdd9787 Mon Sep 17 00:00:00 2001 From: Sangeeth Thilakarathna <46221775+sanmaxdev@users.noreply.github.com> Date: Thu, 9 Jul 2026 06:42:14 +0530 Subject: [PATCH] fix: ignore invalid opencode mode arguments (#302) Co-authored-by: sanmaxdev --- .opencode/plugins/ponytail.mjs | 4 +++- tests/opencode-plugin.test.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.opencode/plugins/ponytail.mjs b/.opencode/plugins/ponytail.mjs index 2d452e2..4db6f4a 100644 --- a/.opencode/plugins/ponytail.mjs +++ b/.opencode/plugins/ponytail.mjs @@ -92,7 +92,9 @@ export default async ({ client } = {}) => { 'command.execute.before': async (input) => { if (!input || input.command !== 'ponytail') return; // `off` is persisted like any mode; the transform reads it and stays silent. - const mode = normalizePersistedMode((input.arguments || '').trim()) || getDefaultMode(); + const args = (input.arguments || '').trim(); + const mode = args ? normalizePersistedMode(args) : getDefaultMode(); + if (!mode) return; writeMode(mode); log('info', 'ponytail ' + mode); }, diff --git a/tests/opencode-plugin.test.js b/tests/opencode-plugin.test.js index a2fad93..bb5b8ca 100644 --- a/tests/opencode-plugin.test.js +++ b/tests/opencode-plugin.test.js @@ -56,6 +56,13 @@ test('/ponytail off persists off and transform injects nothing', async () => { assert.deepEqual(system, []); }); +test('unsupported /ponytail arguments do not reset the current mode', async () => { + const hooks = await loadPlugin({}); + fs.writeFileSync(statePath, 'ultra'); + await hooks['command.execute.before']({ command: 'ponytail', arguments: 'status', sessionID: 's' }); + assert.equal(fs.readFileSync(statePath, 'utf8'), 'ultra'); +}); + test('unrelated commands do not touch the flag', async () => { try { fs.unlinkSync(statePath); } catch (e) {} const hooks = await loadPlugin({});