Repository navigation
iPhone First: an open iPhone sets the shared terminal size by default #27195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
azooz2003-bit
wants to merge
5
commits into
main
Choose a base branch
from
ios-phone-first-sizing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,079
−145
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2faf7a8
test(sizing): an open phone sets the shared grid by default
azooz2003-bit 11883e8
feat(sizing): iPhone First is the default terminal size policy
azooz2003-bit 5a55130
test(ios): a backgrounded phone hands terminal sizing back by default
azooz2003-bit 23395b7
fix(ios): hand terminal sizing back to the Mac when the app goes inac…
azooz2003-bit 0d482c6
style(cmux-tui): rustfmt the sizing policy decoder
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...d/CmuxTerminalSizing/Tests/CmuxTerminalSizingTests/TerminalSizingHandheldFirstTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import CmuxTerminalSizing | ||
| import Foundation | ||
| import Testing | ||
|
|
||
| /// "iPhone First" is the default policy. A policy stored or sent before the | ||
| /// key existed is an explicit choice and keeps its old behavior. | ||
| struct TerminalSizingHandheldFirstTests { | ||
| @Test func defaultPolicyIsHandheldFirstOverFitEveryone() { | ||
| #expect(TerminalSizingPolicy.standard.handheldFirst) | ||
| #expect(TerminalSizingPolicy.standard.mode == .smallest) | ||
| #expect(TerminalSizingEngine(initialSize: TerminalGridSize(cols: 80, rows: 24)).state.policy == .standard) | ||
| } | ||
|
|
||
| @Test func policyWithoutTheKeyDecodesWithHandheldFirstOff() throws { | ||
| let data = Data(#"{"mode":"latest","priority":[],"fixed":null}"#.utf8) | ||
| let policy = try JSONDecoder().decode(TerminalSizingPolicy.self, from: data) | ||
| #expect(policy == .latest) | ||
| #expect(!policy.handheldFirst) | ||
| } | ||
|
|
||
| @Test func policyRoundTripsHandheldFirst() throws { | ||
| let data = try JSONEncoder().encode(TerminalSizingPolicy.standard) | ||
| let object = try #require(JSONSerialization.jsonObject(with: data) as? [String: Any]) | ||
| #expect(object["handheld_first"] as? Bool == true) | ||
| #expect(try JSONDecoder().decode(TerminalSizingPolicy.self, from: data) == .standard) | ||
| } | ||
|
|
||
| @Test func pickingAModeTurnsHandheldFirstOffAndPickingItBackFitsEveryone() { | ||
| let grid = TerminalGridSize(cols: 90, rows: 30) | ||
| let latest = TerminalSizingPolicy.standard.withChoice(.mode(.latest), fallbackFixed: grid) | ||
| #expect(latest == .latest) | ||
| #expect(latest.choice == .mode(.latest)) | ||
| let fixed = TerminalSizingPolicy.standard.withChoice(.mode(.fixed), fallbackFixed: grid) | ||
| #expect(fixed.fixed == grid) | ||
| #expect(!fixed.handheldFirst) | ||
| let back = TerminalSizingPolicy(mode: .priority, priority: ["k"]).withChoice(.handheldFirst, fallbackFixed: grid) | ||
| #expect(back == TerminalSizingPolicy(mode: .smallest, priority: ["k"], handheldFirst: true)) | ||
| #expect(back.choice == .handheldFirst) | ||
| } | ||
|
|
||
| @Test func pickerListsHandheldFirstThenEveryMode() { | ||
| #expect(TerminalSizingChoice.allCases.first == .handheldFirst) | ||
| #expect(TerminalSizingChoice.allCases.count == TerminalSizingMode.allCases.count + 1) | ||
| } | ||
|
|
||
| @Test func legacyKeyMigrationKeepsHandheldFirst() { | ||
| let policy = TerminalSizingPolicy(mode: .priority, priority: ["u1/mac"], handheldFirst: true) | ||
| let mac = TerminalSizingParticipant(id: "m", userID: "u1", deviceKind: .mac, deviceID: "d") | ||
| #expect(policy.migratingLegacyPriorityKeys([mac]).handheldFirst) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: manaflow-ai/cmux
Length of output: 1925
Script executed:
Repository: manaflow-ai/cmux
Length of output: 33163
Script executed:
Repository: manaflow-ai/cmux
Length of output: 5580
Check the applied policy after
terminal.size_policy.setforiphone-first.When the CLI sends
handheld_first, the command reports success even if the running app ignores the field. The app then appliesmode=smallestwithout iPhone First, and the command output showsmode=smallest. Checksize_state.policy.handheld_firstin the response, and throw if it is nottrue.🐛 Suggested fix