Skip to content

Add bonsplitUIScale environment key for UI scaling#24

Open
DreaminDani wants to merge 1 commit intomanaflow-ai:mainfrom
DreaminDani:feat/ui-scale-environment
Open

Add bonsplitUIScale environment key for UI scaling#24
DreaminDani wants to merge 1 commit intomanaflow-ai:mainfrom
DreaminDani:feat/ui-scale-environment

Conversation

@DreaminDani
Copy link

@DreaminDani DreaminDani commented Mar 13, 2026

Summary

  • Adds a public bonsplitUIScale SwiftUI environment key that host apps can inject to scale tab bar font sizes
  • Tab titles, icons, close buttons, zoom indicators, split action buttons, and drag previews all multiply their font size by this factor
  • Defaults to 1.0 (no change) when not injected
image image

Dependency for: manaflow-ai/cmux#1387

Test plan

  • Verify tab bar renders normally when bonsplitUIScale is not injected (default 1.0)
  • Inject .environment(\.bonsplitUIScale, 1.5) on a BonsplitView — verify tab titles, icons, and close buttons scale up

🤖 Generated with Claude Code


Summary by cubic

Adds a public SwiftUI environment key bonsplitUIScale so host apps can scale tab bar typography and icons. Defaults to 1.0, so there’s no change unless injected.

  • New Features

    • EnvironmentValues.bonsplitUIScale (default 1.0) to multiply Bonsplit font sizes.
    • Applied to tab titles, icons, close buttons, zoom icon, split action buttons, and drag preview text.
  • Migration

    • Optional: inject .environment(\.bonsplitUIScale, 1.5) on BonsplitView (or root) to scale up.

Written for commit 2a7565b. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Introduced UI scaling support for Bonsplit views. Host applications can now configure a scale factor to dynamically adjust all visual elements throughout the interface, including icon sizes and font sizing across tab views, drag previews, tab items, and split action buttons.

Allows host apps to inject a scale factor that Bonsplit tab bar views
use to multiply font sizes, enabling configurable UI scaling.

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

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a UI scale environment mechanism for Bonsplit SwiftUI views. A new environment key with a default scale of 1.0 is added, allowing host applications to inject custom scaling factors that automatically scale font and icon sizes across TabBarView, TabDragPreview, and TabItemView.

Changes

Cohort / File(s) Summary
UI Scale Environment Infrastructure
Sources/Bonsplit/Public/UIScaleEnvironment.swift
Introduces BonsplitUIScaleKey environment key with default value 1.0 and extends EnvironmentValues with public bonsplitUIScale property for read/write access.
View Scaling Implementation
Sources/Bonsplit/Internal/Views/TabBarView.swift, Sources/Bonsplit/Internal/Views/TabDragPreview.swift, Sources/Bonsplit/Internal/Views/TabItemView.swift
Injects bonsplitUIScale environment value and applies multiplication to font sizes (button labels, icon sizes, title text) enabling proportional scaling across tab UI components.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A scale factor hops through the views,
Multiplying sizes with SwiftUI clues,
Environments dance in the habitat's glow,
Each icon and font now flexibly grow! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: adding a bonsplitUIScale environment key for UI scaling functionality across multiple UI components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 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.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

@DreaminDani DreaminDani marked this pull request as ready for review March 13, 2026 17:16
Copy link

@greptile-apps greptile-apps bot left a comment

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.

Copy link

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

1 issue found across 4 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="Sources/Bonsplit/Internal/Views/TabItemView.swift">

<violation number="1" location="Sources/Bonsplit/Internal/Views/TabItemView.swift:238">
P2: Scaled shortcut hint text uses an unscaled width measurement, so larger `bonsplitUIScale` values can clip the hint label.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

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

if let shortcutHintLabel {
Text(shortcutHintLabel)
.font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold, design: .rounded))
.font(.system(size: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold, design: .rounded))
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 13, 2026

Choose a reason for hiding this comment

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

P2: Scaled shortcut hint text uses an unscaled width measurement, so larger bonsplitUIScale values can clip the hint label.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sources/Bonsplit/Internal/Views/TabItemView.swift, line 238:

<comment>Scaled shortcut hint text uses an unscaled width measurement, so larger `bonsplitUIScale` values can clip the hint label.</comment>

<file context>
@@ -234,7 +235,7 @@ struct TabItemView: View {
             if let shortcutHintLabel {
                 Text(shortcutHintLabel)
-                    .font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold, design: .rounded))
+                    .font(.system(size: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold, design: .rounded))
                     .monospacedDigit()
                     .lineLimit(1)
</file context>
Fix with Cubic

Copy link

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/Bonsplit/Internal/Views/TabItemView.swift (1)

227-231: ⚠️ Potential issue | 🟡 Minor

Potential layout mismatch: shortcutHintWidth uses unscaled font size.

The shortcutHintWidth function calculates width using the base font size without uiScale, but the actual rendered text at line 238 uses the scaled font size. This mismatch could cause the hint label to be clipped or have excess padding when uiScale != 1.0.

🔧 Proposed fix to scale the width calculation
 private func shortcutHintWidth(for label: String) -> CGFloat {
-    let font = NSFont.systemFont(ofSize: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold)
+    let font = NSFont.systemFont(ofSize: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold)
     let textWidth = (label as NSString).size(withAttributes: [.font: font]).width
     return ceil(textWidth) + 8
 }

Also applies to: 238-238

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/Bonsplit/Internal/Views/TabItemView.swift` around lines 227 - 231,
shortcutHintWidth currently measures text using an unscaled NSFont which
mismatches the rendered, scaled font; update shortcutHintWidth(for:) to compute
a scaled font size using uiScale (e.g. let size = max(8,
(TabBarMetrics.titleFontSize - 2) * uiScale)) when creating the NSFont for
measurement, and also scale the extra padding (the +8) by uiScale so the
measured width matches the actual rendered label; reference: shortcutHintWidth,
TabBarMetrics.titleFontSize, and uiScale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@Sources/Bonsplit/Internal/Views/TabItemView.swift`:
- Around line 227-231: shortcutHintWidth currently measures text using an
unscaled NSFont which mismatches the rendered, scaled font; update
shortcutHintWidth(for:) to compute a scaled font size using uiScale (e.g. let
size = max(8, (TabBarMetrics.titleFontSize - 2) * uiScale)) when creating the
NSFont for measurement, and also scale the extra padding (the +8) by uiScale so
the measured width matches the actual rendered label; reference:
shortcutHintWidth, TabBarMetrics.titleFontSize, and uiScale.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a82f55ca-544f-49ff-bcd2-8c69610df537

📥 Commits

Reviewing files that changed from the base of the PR and between 505181f and 2a7565b.

📒 Files selected for processing (4)
  • Sources/Bonsplit/Internal/Views/TabBarView.swift
  • Sources/Bonsplit/Internal/Views/TabDragPreview.swift
  • Sources/Bonsplit/Internal/Views/TabItemView.swift
  • Sources/Bonsplit/Public/UIScaleEnvironment.swift

@DreaminDani
Copy link
Author

I don't see a "contributing" guide anywhere. Should I address these AI comments before this is ready to merge?

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