Skip to content

Fix Pure prompt duplication in Ghostty zsh integration - #1316

Merged
lawrencecchen merged 3 commits into
mainfrom
task-theo-pure-prompt-duplication
Mar 13, 2026
Merged

lawrencecchen merged 3 commits into
mainfrom
task-theo-pure-prompt-duplication

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a regression for Pure and Prezto prompts that redraw through \n%{\r%} under the Ghostty zsh integration
  • stop injecting an explicit OSC 133;P;k=s continuation marker after Pure's hidden carriage return, which was creating a second prompt boundary during redraws
  • document the new fork behavior in docs/ghostty-fork.md

Testing

  • ssh cmux-macmini "cd /Users/cmux/fun/cmuxterm-hq/worktrees/task-theo-pure-prompt-duplication && python3 tests/test_ghostty_zsh_pure_hidden_cr_omits_continuation_marker.py"
  • ssh cmux-macmini "cd /Users/cmux/fun/cmuxterm-hq/worktrees/task-theo-pure-prompt-duplication && python3 tests/test_ghostty_zsh_pure_preprompt_redraw.py"
  • ssh cmux-macmini "cd /Users/cmux/fun/cmuxterm-hq/worktrees/task-theo-pure-prompt-duplication && python3 tests/test_ghostty_zsh_prompt_redraw_uses_prompt_start.py"
  • ./scripts/reload.sh --tag theo-pure-fix

Issues

  • Task reference: Theo debug bundle at /Users/lawrencechen/Library/Messages/Attachments/ee/14/F8F69012-5FF5-4D02-A528-E132B13F9CE8/debug-cmux-bundle.zip

Summary by cubic

Fix Pure-style zsh prompt duplication in ghostty by removing the extra continuation marker after Pure’s hidden carriage return. Bundles and prefers the patched Ghostty zsh integration so tagged builds load the fix; adds small tools to launch tagged apps and probe duplication.

  • Bug Fixes

    • Stop inserting OSC 133;P;k=s after Pure’s hidden \r in \n%{\r%} prompts.
    • Add a regression test to ensure hidden-CR prompts omit continuation markers.
  • New Features

    • Update the ghostty subproject and bundle ghostty-integration.zsh into app resources; .zshenv now prefers CMUX_SHELL_INTEGRATION_DIR over GHOSTTY_RESOURCES_DIR (with a regression test).
    • Add scripts/launch-tagged-automation.sh and scripts/probe-pure-prompt-duplication.py for tagged-app automation and prompt-duplication checks.

Written for commit e051331. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Shell integration now prefers a bundled Ghostty zsh integration when present and can be toggled via env var; build adds conditional copy of that bundled file.
    • New automation tool to launch tagged macOS apps in debug/automated mode.
    • New probe utility to check Pure-style prompt duplication behavior.
  • Documentation

    • Clarified Pure-style prompt redraw guidance regarding hidden carriage returns and continuation markers.
  • Tests

    • Added regression tests for integration preference and hidden-CR prompt behavior.
  • Chores

    • Updated Ghostty submodule reference and checksum mapping.

@vercel

vercel Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Mar 13, 2026 9:39am

@coderabbitai

coderabbitai Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 103bb7d8-7d9a-437c-a449-90d0320a2f86

📥 Commits

Reviewing files that changed from the base of the PR and between 095a571 and e051331.

📒 Files selected for processing (6)
  • GhosttyTabs.xcodeproj/project.pbxproj
  • Resources/shell-integration/.zshenv
  • scripts/ghosttykit-checksums.txt
  • scripts/launch-tagged-automation.sh
  • scripts/probe-pure-prompt-duplication.py
  • tests/test_shell_zsh_prefers_bundled_ghostty_integration.py

📝 Walkthrough

Walkthrough

Adds an opt-in bundled Ghostty Zsh integration (build copies a CMUX_GHOSTTY_ZSH_SRC into shell-integration), updates .zshenv to prefer a CMUX_SHELL_INTEGRATION_DIR and gate loading with CMUX_LOAD_GHOSTTY_ZSH_INTEGRATION, bumps Ghostty submodule, and adds automation/diagnostic scripts and tests for Pure-style prompt behavior.

Changes

Cohort / File(s) Summary
Build config
GhosttyTabs.xcodeproj/project.pbxproj
Adds CMUX_GHOSTTY_ZSH_SRC variable and conditional copy step in the "Copy Ghostty Resources" shell script to include a bundled ghostty-integration.zsh.
Shell integration loader
Resources/shell-integration/.zshenv
Adds CMUX_LOAD_GHOSTTY_ZSH_INTEGRATION gate; prefers CMUX_SHELL_INTEGRATION_DIR/.../ghostty-integration.zsh and falls back to GHOSTTY_RESOURCES_DIR/... only if unreadable.
Documentation & submodule
docs/ghostty-fork.md, ghostty
Updates Pure-style redraw behavior text and advances ghostty submodule commit to 312c7b23a....
Launch automation
scripts/launch-tagged-automation.sh
New script to sanitize tags, compose CMUX/GHOSTTY env, quit/launch app, optionally wait for socket, and report runtime status.
Diagnostics & probes
scripts/probe-pure-prompt-duplication.py, scripts/ghosttykit-checksums.txt
Adds a cmux-surface probe for Pure prompt duplication; updates ghosttykit checksum mapping.
Tests
tests/test_ghostty_zsh_pure_hidden_cr_omits_continuation_marker.py, tests/test_shell_zsh_prefers_bundled_ghostty_integration.py
Adds integration tests: one verifying no explicit continuation marker for Pure hidden-CR redraws, one asserting bundled integration is preferred when CMUX_SHELL_INTEGRATION_DIR is set.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related issues

Possibly related PRs

Suggested labels

codex

Poem

🐰 I copy a script into a hidden den,
I hop through zsh lines again and again,
Prefer the bundled path, gate the load,
Pure prompts stay tidy on the road,
Hooray — a tiny rabbit's build-time grin! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix Pure prompt duplication in Ghostty zsh integration' directly and clearly describes the main change—fixing a prompt duplication issue in the Ghostty zsh integration for Pure-style prompts.
Description check ✅ Passed The description covers the required sections: Summary explains what changed and why, Testing documents the test commands executed, and Issues references relevant task context. All critical information is present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task-theo-pure-prompt-duplication
📝 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.

@lawrencecchen
lawrencecchen marked this pull request as ready for review March 13, 2026 09:35

@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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@lawrencecchen
lawrencecchen force-pushed the task-theo-pure-prompt-duplication branch from 095a571 to e051331 Compare March 13, 2026 09:38
@lawrencecchen
lawrencecchen merged commit c69342a into main Mar 13, 2026
9 of 10 checks passed
@lawrencecchen
lawrencecchen deleted the task-theo-pure-prompt-duplication branch March 13, 2026 09:39

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/probe-pure-prompt-duplication.py">

<violation number="1" location="scripts/probe-pure-prompt-duplication.py:131">
P2: Workspace restoration is not guaranteed on early failures because the readiness loop runs outside the cleanup `try/finally`.</violation>
</file>

<file name="scripts/launch-tagged-automation.sh">

<violation number="1" location="scripts/launch-tagged-automation.sh:20">
P2: `sanitize_bundle` over-escapes dot trimming regexes, so invalid dot-only bundle suffixes can be produced.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

probe_text = ""

start = time.time()
while True:

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Workspace restoration is not guaranteed on early failures because the readiness loop runs outside the cleanup try/finally.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/probe-pure-prompt-duplication.py, line 131:

<comment>Workspace restoration is not guaranteed on early failures because the readiness loop runs outside the cleanup `try/finally`.</comment>

<file context>
@@ -0,0 +1,207 @@
+        probe_text = ""
+
+        start = time.time()
+        while True:
+            try:
+                listed = client._call("surface.list", {"workspace_id": workspace_id}) or {}
</file context>
Fix with Cubic

sanitize_bundle() {
local raw="$1"
local cleaned
cleaned="$(echo "$raw" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/./g; s/^\\.+//; s/\\.+$//; s/\\.+/./g')"

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: sanitize_bundle over-escapes dot trimming regexes, so invalid dot-only bundle suffixes can be produced.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/launch-tagged-automation.sh, line 20:

<comment>`sanitize_bundle` over-escapes dot trimming regexes, so invalid dot-only bundle suffixes can be produced.</comment>

<file context>
@@ -0,0 +1,189 @@
+sanitize_bundle() {
+  local raw="$1"
+  local cleaned
+  cleaned="$(echo "$raw" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/./g; s/^\\.+//; s/\\.+$//; s/\\.+/./g')"
+  if [[ -z "$cleaned" ]]; then
+    cleaned="agent"
</file context>
Suggested change
cleaned="$(echo "$raw" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/./g; s/^\\.+//; s/\\.+$//; s/\\.+/./g')"
cleaned="$(echo "$raw" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/./g; s/^\.+//; s/\.+$//; s/\.+/./g')"
Fix with Cubic

bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
)

* Add Pure hidden-CR redraw regression

* Fix Pure hidden-CR prompt redraws

* Bundle Ghostty zsh integration in cmux
@coderabbitai coderabbitai Bot mentioned this pull request Apr 7, 2026
4 of 6 tasks

This branch was successfully deployed

1 active deployment
Preview — e051331d Deployed Mar 13, 2026 by vercel[bot]
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