Skip to content

fix: sanitize SessionStart session summaries (#642)#710

Merged
affaan-m merged 1 commit into
mainfrom
fix/sanitize-session-start
Mar 20, 2026
Merged

fix: sanitize SessionStart session summaries (#642)#710
affaan-m merged 1 commit into
mainfrom
fix/sanitize-session-start

Conversation

@affaan-m

@affaan-m affaan-m commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Strip ANSI escape codes from session.tmp when injecting into SessionStart hook. Fixes #642.


Summary by cubic

Strip ANSI escape codes from session summaries before injecting them in the SessionStart hook to keep the context clean. Adds a test to verify sanitization and fixes #642.

Written for commit 11e9f25. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed an issue where terminal formatting codes from previous session files were leaking into the injected session summary, causing unwanted formatting artifacts in the output.
  • Tests

    • Added test coverage to verify that terminal formatting codes are properly removed from session content and do not appear in console output.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

affaan-m has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@affaan-m affaan-m merged commit 3507115 into main Mar 20, 2026
38 checks passed
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d23c6a14-8d3b-4358-9e93-a1ba7b21b657

📥 Commits

Reviewing files that changed from the base of the PR and between 40f1888 and 11e9f25.

📒 Files selected for processing (2)
  • scripts/hooks/session-start.js
  • tests/hooks/hooks.test.js

📝 Walkthrough

Walkthrough

The session-start hook now sanitizes ANSI escape codes from loaded session files at the point of file reading, moving the stripAnsi() call to the file read operation instead of the template injection point. A corresponding test case verifies that injected session content contains no ANSI escape sequences.

Changes

Cohort / File(s) Summary
Session Start Hook Sanitization
scripts/hooks/session-start.js
Refactored ANSI escape code stripping to occur during file read (stripAnsi(readFile(latest.path))) rather than during template injection, eliminating redundant sanitization and simplifying the injection logic.
Test Coverage for ANSI Stripping
tests/hooks/hooks.test.js
Added new test case verifying that the session-start hook successfully strips ANSI escape sequences from injected session content and confirms no escape codes (\x1b[) appear in output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through ANSI streams,
Stripping codes from terminal dreams,
Windows whispers no more strange art,
Clean sessions from the very start!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sanitize-session-start
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@affaan-m affaan-m deleted the fix/sanitize-session-start branch March 20, 2026 13:51
FrancescoRosciano pushed a commit to FRosciano-Mambo/everything-claude-code that referenced this pull request Jun 1, 2026
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.

SessionStart hook injects ANSI escape codes from session.tmp on Windows

1 participant