Skip to content

Add Claude Code prompt trimming#19

Open
evoleinik wants to merge 1 commit intosteipete:mainfrom
evoleinik:main
Open

Add Claude Code prompt trimming#19
evoleinik wants to merge 1 commit intosteipete:mainfrom
evoleinik:main

Conversation

@evoleinik
Copy link
Copy Markdown

Summary

  • Detect and flatten Claude Code terminal prompts that include decoration (❯ prefix, ─── rules, duplicate content) or terminal line wrapping
  • Strip outer quotes and unescape \" when the terminal wraps copied slash commands in quotes
  • Configurable via Settings > General toggle ("Flatten Claude Code prompts", default on)
  • Also fixes quotePathWithSpaces not recognizing --long-flags or slash commands

Five copy scenarios handled

Scenario Input Output
A. Full decoration ❯ /cmd "args"\n───\n/cmd "args"\n --flag /cmd "args" --flag
B. ❯ prefix only ❯ /commit /commit
C. Raw slash command /skill:cmd "args\n wrapped" --flag /skill:cmd "args wrapped" --flag
D. Terminal-wrapped text Long prompt that got\n wrapped by terminal single line
E. Outer-quoted command "/cmd \"args\" --flag" /cmd "args" --flag

Test plan

  • 15 new tests in ClaudeCodePromptTests.swift — all scenarios + negatives + pipeline integration
  • Full suite: 131/131 tests pass, zero regressions
  • Manual: copy Claude Code prompts with Trimmy running, verify clipboard is flattened
  • Manual: toggle off in Settings > General, verify no transformation

🤖 Generated with Claude Code

Detect and flatten Claude Code terminal prompts that include decoration
(❯ prefix, ─── rules, duplicate content) or terminal line wrapping.
Four scenarios handled: full decoration, raw slash commands, ❯-only
prefix, and terminal-wrapped text. Configurable via Settings > General.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84bc1d7b74

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +573 to +577
if self.isLikelySourceCode(text) { return nil }
// Not a list
if self.isLikelyList(lines) { return nil }

let result = self.flattenWrappedLines(nonEmptyLines.map { String($0) })
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid flattening Python-style code as wrapped text

In stripClaudeCodeDecoration's terminal-wrap fallback, any multi-line text with indented continuation lines is flattened unless isLikelySourceCode rejects it, but that helper only recognizes code when braces/begin are present. As a result, common brace-less snippets such as if ready:\n run() (or YAML-like blocks) satisfy this branch and are collapsed into a single line, silently corrupting copied code when flattenClaudeCodePrompts is enabled (default-on).

Useful? React with 👍 / 👎.

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.

1 participant