Skip to content

fix: deliver ruleset on mid-session /ponytail switch (#663) - #667

Open
SomSamantray wants to merge 1 commit into
DietrichGebert:mainfrom
SomSamantray:fix/mid-session-ruleset-injection
Open

fix: deliver ruleset on mid-session /ponytail switch (#663)#667
SomSamantray wants to merge 1 commit into
DietrichGebert:mainfrom
SomSamantray:fix/mid-session-ruleset-injection

Conversation

@SomSamantray

Copy link
Copy Markdown

Summary

Fixes #663.

The mid-session mode-switch write in ponytail-mode-tracker.js only emitted the confirmation string for non-Qoder platforms (native Claude Code, Codex); the actual ruleset injection (getPonytailInstructions(mode)) was gated behind isQoder && !deactivated. So switching mode mid-session (/ponytail full) updated the flag and printed PONYTAIL MODE CHANGED — level: full, but the main thread never got the rules until the next SessionStart — while subagents spawned in the meantime already saw them (ponytail-subagent.js reads the flag independently), producing the split state reported in the issue.

The fix folds getPonytailInstructions(mode) into the existing !isQoder confirmation write, mirroring the pattern already used on the Qoder branch below it (Qoder has no SessionStart to fall back on, so it always folded the ruleset into every UserPromptSubmit).

Root cause

  • hooks/ponytail-mode-tracker.js:70-76 (before fix): mode-switch write for non-Qoder platforms only sent the confirmation string.
  • hooks/ponytail-mode-tracker.js:96-113: ruleset injection was gated behind isQoder, so it never ran for native Claude Code / Codex.
  • Reproduced directly: piping {"prompt":"/ponytail full"} into the hook showed the flag file updated to full, but stdout contained only the confirmation line — no ruleset. Toggling QODER_SESSION_ID on the identical input confirmed the same code path emits header + full ruleset when isQoder is true, isolating the gate as the exact cause.

Testing notes

  • Strengthened the existing native-Claude mid-session-switch test (tests/hooks.test.js, the defEnv / /ponytail ultra case) to assert the ruleset now appears in stdout, not just the flag file — this test already exercised the buggy path but never checked the payload.
  • Strengthened the existing Codex mid-session-switch test (@ponytail lite case) the same way, closing a gap a 4-persona review (correctness, project-standards, testing, agent-native) surfaced: the fix is gated by the same !isQoder boolean for Codex, but the pre-existing test only asserted systemMessage, not hookSpecificOutput.additionalContext.
  • Full suite: node --test tests/*.test.js — 82/82 passing.
  • Review found no correctness or project-standards issues. One cosmetic/advisory item noted below.

Known Residuals (accepted, non-blocking)

Post-Deploy Monitoring & Validation

No runtime/production monitoring applies — this is a local Node hook script with full unit-test coverage (node --test tests/*.test.js) and no deployed service. Validation is the test suite itself; a regression here would show as a failing assertion in tests/hooks.test.js, not a runtime signal.

🤖 Generated with Claude Code

)

The mid-session mode-switch write in ponytail-mode-tracker.js only
emitted the confirmation string for non-Qoder platforms (native
Claude Code, Codex); ruleset injection was gated behind isQoder, so
the main thread stayed rule-less until the next SessionStart even
though subagents spawned meanwhile already saw it. Fold the ruleset
into the same write, mirroring the pattern Qoder already used.

Strengthens the existing native-Claude and Codex mid-session-switch
tests, which exercised this exact branch but only asserted the flag
file / systemMessage, not the delivered ruleset content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code: mid-session /ponytail <level> sets the flag and confirms, but the main thread never receives the ruleset

1 participant