Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/terminal/Terminal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2726,8 +2726,13 @@ pub fn resize(
try primary.resize(.{
.cols = cols,
.rows = rows,
.reflow = self.modes.get(.wraparound),
.prompt_redraw = self.flags.shell_redraws_prompt,
// cmux: preserve terminal content stability across aggressive pane
// resize churn (especially for SSH-driven shells). Prefer tmux-style
// no-reflow semantics over potential history loss.
.reflow = false,
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 Preserve reflow when wraparound mode is enabled

Hard-coding reflow = false in Terminal.resize removes the existing DECAWM-dependent behavior and makes primary-screen resize always use no-reflow semantics. This regresses normal terminal behavior outside the cmux scenario: when wraparound is enabled, shrinking or expanding columns no longer reflows soft-wrapped lines (the repository already encodes this expectation in test "Terminal: resize with wraparound on" in src/terminal/Terminal.zig).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This hardcoded reflow = false breaks existing behavior for all Ghostty builds, not just cmux. Previously, reflow was conditional on self.modes.get(.wraparound), respecting user configuration. The PR title mentions "for cmux builds" but there's no build-time or runtime conditional here.

Consider either:

  1. Adding a build option for cmux and conditionally disabling reflow: reflow = if (comptime build_options.cmux) false else self.modes.get(.wraparound)
  2. Adding a runtime config option that cmux users can set
  3. If this is intended for all builds, update the PR description and verify existing tests still pass (e.g., "resize with reflow" tests at lines 12043 and 12085)

// cmux: prompt redraw on resize can blank substantial history under
// repeated split-resize churn. Preserve scrollback over prompt cleanup.
.prompt_redraw = .false,
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 Badge Honor negotiated prompt redraw capability on resize

Setting prompt_redraw = .false unconditionally bypasses the OSC 133 redraw negotiation stored in self.flags.shell_redraws_prompt (set in semanticPrompt), effectively disabling prompt-redraw support for all shells. In sessions where the shell advertises redraw support, resize will no longer clear prompt/input lines before redraw, which can leave stale or duplicated prompt content instead of the intended clean repaint.

Useful? React with 👍 / 👎.

Comment on lines +2729 to +2735
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for cmux-related build options and reflow/prompt_redraw patterns
rg -n "cmux|resize_no_reflow|prompt_redraw.*reflow" src/

Repository: manaflow-ai/ghostty

Length of output: 277


🏁 Script executed:

#!/bin/bash
# Check for build options file structure
fd -t f "build" . --max-depth 3 | head -20

Repository: manaflow-ai/ghostty

Length of output: 631


🏁 Script executed:

#!/bin/bash
# Examine the full context of the resize function around lines 2729-2735
cat -n src/terminal/Terminal.zig | sed -n '2700,2750p'

Repository: manaflow-ai/ghostty

Length of output: 1955


🏁 Script executed:

#!/bin/bash
# Search for resize tests or test patterns
rg -n "test.*resize|resize.*test" src/terminal/Terminal.zig | head -10

Repository: manaflow-ai/ghostty

Length of output: 696


🏁 Script executed:

#!/bin/bash
# Check build.zig for cmux-related options
cat -n build.zig | grep -i "cmux\|option" | head -30

Repository: manaflow-ai/ghostty

Length of output: 262


🏁 Script executed:

#!/bin/bash
# Look for build_options import or usage in Terminal.zig
rg -n "build_options|@import.*build" src/terminal/Terminal.zig | head -10

Repository: manaflow-ai/ghostty

Length of output: 663


🏁 Script executed:

#!/bin/bash
# Examine the actual reflow test implementation to see if it expects reflow to work
sed -n '12043,12090p' src/terminal/Terminal.zig

Repository: manaflow-ai/ghostty

Length of output: 1582


🏁 Script executed:

#!/bin/bash
# Search for any conditional check before the resize call on the primary screen
sed -n '2710,2740p' src/terminal/Terminal.zig | rg -n "if|cmux|build_options"

Repository: manaflow-ai/ghostty

Length of output: 434


🏁 Script executed:

#!/bin/bash
# Search for any cmux-related build option definition in build.zig or terminal_options
rg -n "cmux|no_reflow" build.zig build.zig.zon src/

Repository: manaflow-ai/ghostty

Length of output: 277


🏁 Script executed:

#!/bin/bash
# Look for terminal_options definition/generation
find . -name "*terminal_options*" -o -name "*options*" | grep -v node_modules

Repository: manaflow-ai/ghostty

Length of output: 123


🏁 Script executed:

#!/bin/bash
# Search for the terminal_options import source
rg -n "pub const cmux\|pub const reflow\|pub const prompt_redraw" src/ build.zig

Repository: manaflow-ai/ghostty

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Check if the reflow test is expected to pass or skip
rg -B5 "test.*resize with reflow and saved cursor" src/terminal/Terminal.zig | head -20

Repository: manaflow-ai/ghostty

Length of output: 349


🏁 Script executed:

#!/bin/bash
# Examine the terminal build_options file
cat -n src/terminal/build_options.zig

Repository: manaflow-ai/ghostty

Length of output: 2416


🏁 Script executed:

#!/bin/bash
# Search for all available build options in the terminal module
rg -n "pub const" src/terminal/build_options.zig

Repository: manaflow-ai/ghostty

Length of output: 124


🏁 Script executed:

#!/bin/bash
# Check if there's any reference to cmux anywhere in build configuration
rg -n "cmux" build.zig build.zig.zon src/

Repository: manaflow-ai/ghostty

Length of output: 277


Scope mismatch: no-reflow is applied globally without a cmux-specific build option.

This change unconditionally hard-disables reflow and prompt redraw for all primary-screen resizes. The comments reference cmux behavior, but no cmux build option exists in the codebase to gate this. This will alter default Ghostty resize semantics globally rather than only for a cmux-specific mode.

The reflow tests ("resize with reflow and saved cursor", etc.) will now silently run with reflow disabled despite their names implying reflow should be active, making them misleading.

To align with the stated cmux-only intent, either:

  1. Create a cmux build option in src/terminal/build_options.zig and gate the resize behavior conditionally, or
  2. Clarify that the global behavior change is intentional.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/terminal/Terminal.zig` around lines 2729 - 2735, The patch
unconditionally disables reflow and prompt_redraw in Terminal.zig (the .reflow
and .prompt_redraw fields) even though the comments say this should be
cmux-specific; add a compile-time build option and gate these settings: declare
a boolean build option (e.g., enableCmux) in src/terminal/build_options.zig,
expose it as a comptime/config constant, and wrap the Terminal.zig assignment so
.reflow and .prompt_redraw are set to false only when that build option is
enabled (otherwise keep current defaults); alternatively, if the intent is
global, update the comment and the tests to reflect that reflow is globally
disabled.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue as above - prompt_redraw = .false is hardcoded for all builds. Previously this was conditional on self.flags.shell_redraws_prompt. Users who configured their terminal to redraw prompts on resize will now have that setting ignored.

});

// Alternate screen, if it exists, doesn't reflow
Expand Down
Loading