fix: only deactivate on a standalone "stop ponytail" / "normal mode" (#162)

The deactivation check matched the phrase anywhere in the prompt, so an
ordinary request like "add a normal mode toggle" silently turned ponytail
off for the rest of the session. Match the whole message instead (trimmed,
case-insensitive, trailing punctuation ignored) through a shared helper used
by both the Claude/Codex hook and the pi extension.

Fixes #161
This commit is contained in:
Lakshya77089
2026-06-18 22:50:03 +02:00
committed by GitHub
parent 955fff537c
commit 53fd1e850e
5 changed files with 43 additions and 3 deletions
+10
View File
@@ -33,6 +33,15 @@ function normalizePersistedMode(mode) {
return normalizeMode(mode) || normalizeConfigMode(mode);
}
// "stop ponytail" / "normal mode" turn ponytail off, but only as a standalone
// command. Matching the phrase anywhere in the message turned it off mid-task
// for ordinary requests like "add a normal mode toggle" — so require the whole
// message to be the command, ignoring case and trailing punctuation.
function isDeactivationCommand(text) {
const t = String(text || '').trim().toLowerCase().replace(/[.!?\s]+$/, '');
return t === 'stop ponytail' || t === 'normal mode';
}
function getConfigDir() {
if (process.env.XDG_CONFIG_HOME) {
return path.join(process.env.XDG_CONFIG_HOME, 'ponytail');
@@ -98,5 +107,6 @@ module.exports = {
normalizeMode,
normalizeConfigMode,
normalizePersistedMode,
isDeactivationCommand,
writeDefaultMode,
};