fix: ignore invalid opencode mode arguments (#302)

Co-authored-by: sanmaxdev <sanmaxdev@users.noreply.github.com>
This commit is contained in:
Sangeeth Thilakarathna 2026-07-09 06:42:14 +05:30 committed by GitHub
parent ca4dad252d
commit a3e0169c3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -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);
},

View File

@ -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({});