Skip to content

Keep titlebar stable at minimum sidebar width#5089

Merged
azooz2003-bit merged 4 commits into
mainfrom
issue-sidebar-titlebar-min-width
Jun 1, 2026
Merged

Keep titlebar stable at minimum sidebar width#5089
azooz2003-bit merged 4 commits into
mainfrom
issue-sidebar-titlebar-min-width

Conversation

@azooz2003-bit
Copy link
Copy Markdown
Contributor

@azooz2003-bit azooz2003-bit commented Jun 1, 2026

Summary

  • keep the custom titlebar folder icon/title inset stable when the sidebar is hidden or at minimum width
  • continue shifting the titlebar right when the sidebar is wider than minimum
  • add focused padding coverage for hidden, minimum-width, wider, and fullscreen cases

Verification

  • ./scripts/reload.sh --tag tbmin --swift-frontend-workaround
  • attempted compile-only cmux-unit build with the Swift frontend workaround, stopped after a long swift-frontend stall

Dogfood build: http://127.0.0.1:17320/tbmin


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.


Summary by cubic

Keep the titlebar icon/title position stable when the sidebar is hidden or at minimum width, and keep shifting it right when the sidebar is wider. Also handles the fullscreen edge case for a consistent look.

  • Bug Fixes
    • Added customTitlebarLeadingPadding(...) to clamp at min width, respect titlebarLeadingInset, and absorb float drift near the clamp.
    • Applied the helper in customTitlebar; use an 8pt inset when fullscreen with a hidden sidebar.
    • Expanded tests to verify hidden vs min-width parity, wider sidebar push, and fullscreen hidden behavior.

Written for commit 6f5db4c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Improvements

    • Refined titlebar positioning to dynamically compute leading inset from fullscreen state, sidebar visibility and width constraints, and the configured titlebar inset—ensuring consistent alignment across UI states.
  • Tests

    • Added test coverage validating titlebar inset calculations across hidden and visible sidebars (minimum and larger widths) and fullscreen scenarios.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

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

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jun 1, 2026 5:03am
cmux-staging Building Building Preview, Comment Jun 1, 2026 5:03am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 61ef312f-bf49-47b2-b720-42e1bb615d22

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac6de9 and 6f5db4c.

📒 Files selected for processing (2)
  • Sources/ContentView.swift
  • cmuxTests/WindowAndDragTests.swift

📝 Walkthrough

Walkthrough

Extracted titlebar leading padding into ContentView.customTitlebarLeadingPadding(...), swapped inline padding in customTitlebar(appearance:) to use the helper, and added macro-based unit tests verifying padding across sidebar visibility, width, and fullscreen scenarios.

Changes

Titlebar Leading Padding Refactor

Layer / File(s) Summary
Helper function definition
Sources/ContentView.swift
customTitlebarLeadingPadding static helper centralizes the titlebar's leading inset calculation, with fullscreen-when-sidebar-hidden handling, a computed minimum sidebar title inset, and clamped behavior around the minimum width (epsilon to absorb drift).
Helper integration and application
Sources/ContentView.swift
customTitlebar(appearance:) computes leadingPadding by calling the new helper with isFullScreen, sidebarState.isVisible, sidebarWidth, minimumSidebarWidth, and titlebarLeadingInset, then applies it via .padding(.leading, leadingPadding).
Unit tests for helper behavior
cmuxTests/WindowAndDragTests.swift
Adds import Testing and CustomTitlebarLeadingPaddingTests with four @Test cases asserting expected padding for hidden sidebar, visible-at-minimum-width equivalence, wider visible sidebar numeric offset, and fullscreen hidden-sidebar compact inset.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • manaflow-ai/cmux#5036: Both PRs update how the titlebar's leading padding is computed with respect to sidebar visibility/width; this PR centralizes that logic into a helper.
  • manaflow-ai/cmux#5062: That change adjusts minimumSidebarWidth derivation which affects the helper's clamping behavior.
  • manaflow-ai/cmux#5017: Alters persisted minimumSidebarWidth values that feed into this helper's computations.

Poem

🐰 I hopped in to tidy the lane,
I nudged the titlebar’s gentle cane,
Sidebar left, sidebar right,
Tests check each pixel's light,
A small hop, the layout's sane.

🚥 Pre-merge checks | ✅ 16 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The description covers the main objectives and testing approach, but omits several required template sections including Demo Video, Review Trigger commands, and a complete Checklist. Add missing template sections: include a demo video link or note why it's not applicable, copy the Review Trigger block, and check off or mark all Checklist items to clarify PR readiness.
✅ Passed checks (16 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the PR: stabilizing the titlebar at minimum sidebar width, which is the core focus of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Swift Actor Isolation ✅ Passed New nonisolated static helper function uses only value-type parameters and pure computations with no implicit MainActor issues, shared mutable Sendable types, or background context access violations.
Cmux Swift Blocking Runtime ✅ Passed PR adds customTitlebarLeadingPadding() helper and tests with no blocking primitives: no semaphores, sleeps, locks, or DispatchQueue.main.sync found in new code.
Cmux No Hacky Sleeps ✅ Passed PR changes only Swift files (ContentView.swift, WindowAndDragTests.swift). Check applies only to TypeScript, JavaScript, and shell scripts; Swift is excluded per rule scope.
Cmux Algorithmic Complexity ✅ Passed The new customTitlebarLeadingPadding method contains only O(1) scalar arithmetic operations with no collection iteration, scans, or algorithmic inefficiencies. Tests are properly exempt.
Cmux Swift Concurrency ✅ Passed New code introduces only synchronous helpers with no DispatchQueue, Combine, completion handlers, or fire-and-forget Tasks—fully compliant with Swift concurrency modernization.
Cmux Swift @Concurrent ✅ Passed The added customTitlebarLeadingPadding function is a nonisolated synchronous pure helper (allowed case), with no @concurrent annotation needed. Tests are synchronous.
Cmux Swift File And Package Boundaries ✅ Passed Focused bug fix adding 32 lines of UI-only titlebar layout logic to ContentView.swift. Matches allowed case: small addition to large file with clear extraction path.
Cmux Swift Logging ✅ Passed New production code adds pure calculation function with no print, debugPrint, dump, NSLog, or logging violations.
Cmux User-Facing Error Privacy ✅ Passed PR contains only layout calculations and developer tests with no user-facing errors, sensitive information, or privacy violations.
Cmux Full Internationalization ✅ Passed PR adds pure algorithmic padding calculation method and tests; no user-facing strings added. Fully compliant with internationalization requirements.
Cmux Swiftui State Layout ✅ Passed Pure helper function for titlebar padding with no new state declarations, no GeometryReader layout changes, no render-time mutations, and parameters from safe @State/@EnvironmentObject sources.
Cmux Architecture Rethink ✅ Passed Pure correctness fix extracting padding calculation with clear owner, invariant, and comprehensive tests; no timing repairs, observers, or architectural anti-patterns.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PR adds titlebar padding helper function and tests, not window creation. customTitlebarLeadingPadding is pure calculation; customTitlebar is SwiftUI view builder; tests are fixtures.

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

✨ 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 issue-sidebar-titlebar-min-width

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR fixes titlebar icon/title jitter by extracting the leading-padding calculation into a pure nonisolated static helper (customTitlebarLeadingPadding) that floors the inset at max(titlebarLeadingInset, minimumSidebarWidth + 12) whenever the sidebar is hidden or at minimum width, and shifts right only when the sidebar is genuinely wider.

  • Sources/ContentView.swift: replaces an inline ternary with the new helper; the nonisolated annotation is correct since the function takes only plain value parameters and the tests call it from a non-@MainActor Swift Testing context.
  • cmuxTests/WindowAndDragTests.swift: adds four @Suite/@Test cases covering hidden, minimum-width, wider, and fullscreen-hidden scenarios; all expected values trace correctly through the implementation.

Confidence Score: 5/5

Safe to merge — a narrowly scoped layout helper with no state mutations and full test coverage of the new code paths.

The change extracts a pure computation into a static function, adds a minimumSidebarWidth floor to prevent jitter, and ships four targeted tests. No actor isolation, concurrency, or state-management concerns were introduced. The one untested combination (fullscreen + visible sidebar) is handled by the same guard chain already exercised by the other cases and matches the old formula's behavior.

No files require special attention.

Important Files Changed

Filename Overview
Sources/ContentView.swift Extracts titlebar leading-padding logic into a pure nonisolated static helper that floors the inset at max(titlebarLeadingInset, minimumSidebarWidth + 12) for hidden and minimum-width sidebar states; correct and narrowly scoped.
cmuxTests/WindowAndDragTests.swift Adds four Swift Testing @test cases covering hidden sidebar, minimum-width visible sidebar, wider sidebar, and fullscreen-with-hidden-sidebar; all assertions are consistent with the implementation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[customTitlebarLeadingPadding] --> B{isFullScreen AND not isSidebarVisible}
    B -- Yes --> C[return 8]
    B -- No --> D[minimumSidebarTitleInset = max of titlebarLeadingInset and minimumSidebarWidth plus 12]
    D --> E{isSidebarVisible}
    E -- No --> F[return minimumSidebarTitleInset]
    E -- Yes --> G{sidebarWidth greater than minimumSidebarWidth plus 0.5}
    G -- No --> H[return minimumSidebarTitleInset]
    G -- Yes --> I[return max of titlebarLeadingInset and sidebarWidth plus 12]
Loading

Reviews (2): Last reviewed commit: "fix: address titlebar padding review fee..." | Re-trigger Greptile

Comment thread Sources/ContentView.swift
}

let visibleSidebarTitleInset = sidebarWidth + 12
guard sidebarWidth > minimumSidebarWidth + 0.5 else {
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.

P2 The 0.5 sub-pixel tolerance that separates "at minimum width" from "wider than minimum" is not explained. Without a comment, future readers may wonder whether this is pixels, points, a render artifact, or an arbitrary guard. A brief inline note stating that it absorbs floating-point drift around the minimum clamp would make the intent clear.

Suggested change
guard sidebarWidth > minimumSidebarWidth + 0.5 else {
// Use a 0.5-point tolerance to absorb floating-point drift at the minimum-width clamp.
guard sidebarWidth > minimumSidebarWidth + 0.5 else {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an inline note explaining the 0.5-point tolerance around the minimum-width clamp.

— Claude Code

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmuxTests/WindowAndDragTests.swift`:
- Around line 1961-2026: The tests in CustomTitlebarLeadingPaddingTests should
be migrated from XCTest to the Swift Testing framework: replace the XCTestCase
class with a `@Suite` (e.g., make it a struct) and mark each test function
(testHiddenSidebarUsesMinimumSidebarTitleInset,
testMinimumWidthVisibleSidebarMatchesHiddenSidebarTitleInset,
testWiderSidebarPushesTitlebarContentRight,
testFullscreenHiddenSidebarKeepsCompactInset) with `@Test`; import Testing at the
top; convert assertions like XCTAssertEqual and XCTAssertGreaterThan to the
Swift Testing equivalents (`#expect`(...).to(equal(...)) or try `#require`(...) /
`#expect`(...).to(beGreaterThan(...)) as appropriate) while still calling
ContentView.customTitlebarLeadingPadding with the same parameters. Ensure test
names, calls to ContentView.customTitlebarLeadingPadding, and expected values
remain unchanged.

In `@Sources/ContentView.swift`:
- Line 2078: The return expression uses max(minimumSidebarTitleInset,
visibleSidebarTitleInset) but due to the guard that ensures sidebarWidth >
minimumSidebarWidth + 0.5 the minimumSidebarTitleInset (which includes
minimumSidebarWidth + 12) is always smaller than visibleSidebarTitleInset;
simplify the return in the function containing this logic by returning
max(titlebarLeadingInset, visibleSidebarTitleInset) (use
visibleSidebarTitleInset and titlebarLeadingInset names to locate the code) to
remove the redundant minimumSidebarTitleInset term while preserving behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4ea7a9c8-6467-4bbc-9db1-c1e9392ca56c

📥 Commits

Reviewing files that changed from the base of the PR and between fad8f13 and 8ac6de9.

📒 Files selected for processing (2)
  • Sources/ContentView.swift
  • cmuxTests/WindowAndDragTests.swift

Comment thread cmuxTests/WindowAndDragTests.swift Outdated
Comment thread Sources/ContentView.swift Outdated
Copy link
Copy Markdown

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

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

Re-trigger cubic

@azooz2003-bit azooz2003-bit merged commit cc540a1 into main Jun 1, 2026
29 of 30 checks passed
@azooz2003-bit azooz2003-bit deleted the issue-sidebar-titlebar-min-width branch June 1, 2026 05:37
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