Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0c5a8f1
Add native iOS mobile diff viewer
lawrencecchen Jul 12, 2026
15cde9a
Include mobile diff host loader in app target
lawrencecchen Jul 12, 2026
af85615
Export mobile diff model from shell API
lawrencecchen Jul 12, 2026
d513385
Merge remote-tracking branch 'origin/main' into feat-ios-mobile-diff-…
lawrencecchen Jul 12, 2026
a776492
Use actor-backed mobile diff payloads
lawrencecchen Jul 12, 2026
63ca18c
Address mobile diff review findings
lawrencecchen Jul 12, 2026
a65dc92
Preserve native mobile diff selection
lawrencecchen Jul 12, 2026
bb2e596
Fix Swift 6 diff selection capture
lawrencecchen Jul 12, 2026
03f48a7
Fix bounded pipe buffer exclusivity
lawrencecchen Jul 12, 2026
55d4e16
Bound mobile diff generation work
lawrencecchen Jul 12, 2026
3c17509
test: cover bounded mobile diff updates
lawrencecchen Jul 12, 2026
32fd7c4
fix: bound mobile diff bridge and git work
lawrencecchen Jul 12, 2026
fb02179
fix: bound total mobile diff load time
lawrencecchen Jul 12, 2026
7fa2c43
test: cover prelaunch diff cancellation
lawrencecchen Jul 12, 2026
0bb8cda
test: cover mobile diff scheme cancellation
lawrencecchen Jul 12, 2026
a1b885c
fix: close mobile diff cancellation races
lawrencecchen Jul 12, 2026
2d78eba
test: cover unborn sha256 mobile diffs
lawrencecchen Jul 12, 2026
5e587f7
fix: harden mobile diff repository loading
lawrencecchen Jul 12, 2026
1f5dd8c
refactor: align mobile diff package boundaries
lawrencecchen Jul 12, 2026
943222c
chore: document diff helper lint carveouts
lawrencecchen Jul 12, 2026
54fae40
fix: expose coordinator framework imports
lawrencecchen Jul 12, 2026
ebba145
fix: correct active surface initializer
lawrencecchen Jul 12, 2026
8fc9773
fix: import mobile shell error surface
lawrencecchen Jul 12, 2026
d652cd5
fix: depend on mobile rpc error types directly
lawrencecchen Jul 12, 2026
ea531f4
fix: classify diff errors at shell boundary
lawrencecchen Jul 12, 2026
c5635a8
test: preserve streamed mobile diff selection
lawrencecchen Jul 12, 2026
868bf80
fix: preserve mobile diff surface transitions
lawrencecchen Jul 12, 2026
aded6a9
test: cover mobile diff wire expansion
lawrencecchen Jul 12, 2026
88d1708
fix: bound mobile diff load requests and frames
lawrencecchen Jul 12, 2026
957d7d4
test: cover inherited git environment in mobile diff
lawrencecchen Jul 12, 2026
d7e4def
fix: isolate mobile diff repository and list state
lawrencecchen Jul 12, 2026
93645dd
test: cover inherited git discovery ceiling
lawrencecchen Jul 12, 2026
729bbcc
fix: clear inherited git process controls
lawrencecchen Jul 12, 2026
f46f794
test: require mobile diff render acknowledgement
lawrencecchen Jul 12, 2026
e17656a
fix: bound mobile diff web rendering
lawrencecchen Jul 12, 2026
2801d10
test: cover reentrant scheme task cancellation
lawrencecchen Jul 12, 2026
422188e
fix: serialize mobile diff scheme cancellation
lawrencecchen Jul 12, 2026
6bcf11d
test: cover coalesced mobile diff loads
lawrencecchen Jul 12, 2026
924dd57
fix: coordinate mobile diff loading lifecycles
lawrencecchen Jul 12, 2026
e978e14
refactor: make mobile diff scheme responses synchronous
lawrencecchen Jul 12, 2026
f9e2461
fix: expose mobile diff scheme across actors
lawrencecchen Jul 12, 2026
a76a14e
perf: preload mobile diff assets off main actor
lawrencecchen Jul 12, 2026
b0c72bd
test: cover non-UTF-8 mobile diff paths
lawrencecchen Jul 12, 2026
ba956a4
fix: lazily cache mobile diff assets
lawrencecchen Jul 12, 2026
daff0a4
fix: include mobile diff coordinator in app target
lawrencecchen Jul 12, 2026
2aa24fb
chore: preserve terminal controller line budget
lawrencecchen Jul 12, 2026
498c0e1
fix: type mobile diff slot continuation
lawrencecchen Jul 12, 2026
4c1fb1a
test: cover external untracked diff helpers
lawrencecchen Jul 12, 2026
7a1c6c8
fix: disable external untracked diff helpers
lawrencecchen Jul 12, 2026
664b10f
fix: materialize unborn repository empty tree
lawrencecchen Jul 12, 2026
9d68f4c
test: keep unborn mobile diff reads immutable
lawrencecchen Jul 12, 2026
c118f89
fix: keep unborn mobile diff reads immutable
lawrencecchen Jul 12, 2026
61a63a3
test: keep empty mobile diffs nonfatal
lawrencecchen Jul 12, 2026
5f8562f
fix: preserve empty mobile diff state
lawrencecchen Jul 12, 2026
fa9ca3e
fix: disambiguate mobile diff path bytes
lawrencecchen Jul 12, 2026
31706d9
fix: create invalid-path fixture without variadics
lawrencecchen Jul 12, 2026
4e1eecb
test: cover mobile diff refresh races
lawrencecchen Jul 12, 2026
1a8c720
fix: bound and preserve mobile diff refreshes
lawrencecchen Jul 12, 2026
ed65834
fix: cancel diff processes through Foundation
lawrencecchen Jul 12, 2026
764e637
test: cover safe untracked symlinks
lawrencecchen Jul 12, 2026
8d6c955
fix: render safe symlinks without dereferencing
lawrencecchen Jul 12, 2026
2485dd9
refactor: keep diff file classification local
lawrencecchen Jul 12, 2026
4abffbf
Fix mobile diff file sheet presentation
lawrencecchen Jul 12, 2026
36687ad
refactor: isolate diff sheet context
lawrencecchen Jul 12, 2026
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: 4 additions & 5 deletions Packages/iOS/CmuxMobileBrowser/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ let package = Package(
),
],
dependencies: [
// Localized-string helpers (`L10n`). `CmuxMobileSupport` is a leaf with
// no dependencies, so the browser package stays low in the DAG.
.package(path: "../CmuxMobileShellModel"),
// Shared shell DTOs for the mobile diff document and localized strings.
.package(path: "../CmuxMobileSupport"),
],
targets: [
// A self-contained, phone-local browser surface. P1 browser state never
// touches the Mac, so this package sits low in the DAG: it depends only
// on the leaf `CmuxMobileSupport` and links Foundation/WebKit/SwiftUI.
// Phone-local WebKit surfaces and their native chrome.
.target(
name: "CmuxMobileBrowser",
dependencies: [
"CmuxMobileShellModel",
"CmuxMobileSupport",
],
swiftSettings: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#if canImport(UIKit)
public import SwiftUI
import CmuxMobileSupport
import Foundation

/// Native iOS chrome around the shared web diff renderer.
public struct MobileDiffPane: View {
@State private var state: MobileDiffState
@State private var showsFiles = false
private let onClose: () -> Void
private let onReload: () -> Void

public init(
state: MobileDiffState,
onClose: @escaping () -> Void,
onReload: @escaping () -> Void
) {
_state = State(initialValue: state)
self.onClose = onClose
self.onReload = onReload
}

public var body: some View {
VStack(spacing: 0) {
MobileDiffNavigationBar(
selectedFile: state.selectedFile,
fileCount: state.files.count,
canSelectPrevious: state.canSelectPrevious,
canSelectNext: state.canSelectNext,
showFiles: { showsFiles = true },
selectPrevious: state.selectPrevious,
selectNext: state.selectNext,
reload: onReload,
close: onClose
)
Divider()
MobileDiffContent(state: state, reload: onReload)
}
.background(Color(.systemBackground))
.sheet(isPresented: $showsFiles) {
MobileDiffFileList(state: state, dismiss: { showsFiles = false })
}
}
}

private struct MobileDiffNavigationBar: View {
let selectedFile: MobileDiffFile?
let fileCount: Int
let canSelectPrevious: Bool
let canSelectNext: Bool
let showFiles: () -> Void
let selectPrevious: () -> Void
let selectNext: () -> Void
let reload: () -> Void
let close: () -> Void

var body: some View {
HStack(spacing: 10) {
Button(action: showFiles) {
HStack(spacing: 7) {
Image(systemName: "list.bullet")
VStack(alignment: .leading, spacing: 1) {
Text(selectedFile?.name ?? L10n.string("mobile.diff.files", defaultValue: "Changed Files"))
.font(.subheadline.weight(.semibold))
.lineLimit(1)
Text(String(
format: L10n.string("mobile.diff.fileCount", defaultValue: "%lld files"),
locale: Locale.current,
fileCount
))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
.font(.caption2)
.foregroundStyle(.secondary)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(.rect)
}
.buttonStyle(.plain)
.accessibilityIdentifier("MobileDiffFileListButton")

Button(action: selectPrevious) { Image(systemName: "chevron.up") }
.disabled(!canSelectPrevious)
.accessibilityLabel(L10n.string("mobile.diff.previousFile", defaultValue: "Previous File"))
Button(action: selectNext) { Image(systemName: "chevron.down") }
.disabled(!canSelectNext)
.accessibilityLabel(L10n.string("mobile.diff.nextFile", defaultValue: "Next File"))
Button(action: reload) { Image(systemName: "arrow.clockwise") }
.accessibilityLabel(L10n.string("mobile.diff.refresh", defaultValue: "Refresh Diff"))
Button(action: close) { Image(systemName: "xmark") }
.accessibilityLabel(L10n.string("mobile.diff.close", defaultValue: "Close Diff"))
}
.padding(.horizontal, 12)
.padding(.vertical, 8)
.background(.bar)
}
}

private struct MobileDiffContent: View {
let state: MobileDiffState
let reload: () -> Void

var body: some View {
if state.isLoading, state.document == nil {
ProgressView(L10n.string("mobile.diff.loading", defaultValue: "Loading changes…"))
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else if let errorMessage = state.errorMessage, state.document == nil {

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 Badge Show refresh failures over stale diffs

When a refresh fails after a previous successful load (or WebKit reports an asset/navigation error after state.load), MobileDiffState.fail leaves document non-nil, so this state.document == nil guard prevents the error view from rendering and the user keeps seeing the stale diff as if the refresh succeeded. Please either clear the document on failure or surface the error while a stale document is present.

Useful? React with 👍 / 👎.

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.

Fixed in 63ca18c: error UI takes precedence even when a prior document exists, with localized Retry.

— Claude Code

ContentUnavailableView {
Label(L10n.string("mobile.diff.loadFailed", defaultValue: "Couldn’t Load Diff"), systemImage: "exclamationmark.triangle")
} description: {
Text(errorMessage)
} actions: {
Button(L10n.string("mobile.common.retry", defaultValue: "Retry"), action: reload)
}
} else if state.document != nil {

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.

P1 Refresh Errors Leave Stale Content

fail preserves the previous document, but this error branch only runs when document == nil. A failed refresh or WebView navigation therefore keeps showing the old patch without the error or retry action, making stale data look current.

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.

Fixed in 63ca18c: refresh errors replace stale content with a localized retry screen.

— Claude Code

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.

Fixed in 63ca18c: refresh errors replace stale content with a localized retry screen.

— Claude Code

MobileDiffWebView(state: state)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay(alignment: .top) {
if state.isLoading {
ProgressView().controlSize(.small).padding(8)
}
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
} else {
Color.clear
}
}
}

private struct MobileDiffFileList: View {
let state: MobileDiffState

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.

P1 Badge Pass snapshots into the diff file list

AGENTS.md's “Snapshot boundary for list subtrees” rule says a view with List/ForEach rows must not hold an @Observable store; this new sheet keeps MobileDiffState and its rows call state.selectFile. When the renderer posts file/selection updates or refresh toggles loading/error state while the sheet is open, every store mutation can invalidate the whole row subtree and reintroduce the Lazy/List cache churn the guideline is meant to prevent. Pass immutable files/selectedFileID snapshots plus a select closure into this sheet instead.

Useful? React with 👍 / 👎.

let dismiss: () -> Void

var body: some View {
NavigationStack {
List(state.files) { file in
Button {
state.selectFile(id: file.id)
dismiss()
} label: {
HStack(spacing: 10) {
Image(systemName: file.id == state.selectedFileID ? "checkmark.circle.fill" : "doc.text")
.foregroundStyle(file.id == state.selectedFileID ? Color.accentColor : Color.secondary)
VStack(alignment: .leading, spacing: 3) {
Text(file.name).foregroundStyle(.primary)
Text(file.path).font(.caption).foregroundStyle(.secondary).lineLimit(1)
}
Spacer(minLength: 8)
HStack(spacing: 5) {
Text(verbatim: "+\(file.added)").foregroundStyle(.green)
Text(verbatim: "−\(file.deleted)").foregroundStyle(.red)
}
.font(.caption.monospacedDigit())
}
}
.accessibilityIdentifier("MobileDiffFile-\(file.id)")
}
.navigationTitle(L10n.string("mobile.diff.files", defaultValue: "Changed Files"))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button(L10n.string("mobile.common.done", defaultValue: "Done"), action: dismiss)
}
}
}
.presentationDetents([.medium, .large])
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import Foundation
public import CmuxMobileShellModel
public import Observation

/// Native metadata for one file rendered by the shared web diff viewer.
public struct MobileDiffFile: Decodable, Equatable, Identifiable, Sendable {
public let id: String
public let path: String
public let added: Int
public let deleted: Int

public init(id: String, path: String, added: Int, deleted: Int) {
self.id = id
self.path = path
self.added = added
self.deleted = deleted
}

public var name: String {
URL(fileURLWithPath: path).lastPathComponent
}
}

/// Main-actor state shared by the native diff chrome and its `WKWebView`.
@MainActor
@Observable
public final class MobileDiffState {
public private(set) var document: MobileDiffDocument?
public private(set) var files: [MobileDiffFile] = []
public private(set) var selectedFileID: String?
public private(set) var errorMessage: String?
public private(set) var isLoading = false
public private(set) var generation = 0

public init() {}

public var selectedFile: MobileDiffFile? {
guard let selectedFileID else { return files.first }
return files.first { $0.id == selectedFileID }
}

public var selectedFileIndex: Int? {
guard let selectedFile else { return nil }
return files.firstIndex { $0.id == selectedFile.id }
}

public var canSelectPrevious: Bool {
guard let selectedFileIndex else { return false }
return selectedFileIndex > files.startIndex
}

public var canSelectNext: Bool {
guard let selectedFileIndex else { return false }
return selectedFileIndex + 1 < files.endIndex
}

public func beginLoading() {
isLoading = true
errorMessage = nil
}

public func load(_ document: MobileDiffDocument) {
self.document = document
files = []
selectedFileID = nil
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
errorMessage = nil
isLoading = false
generation &+= 1
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

public func fail(message: String) {
isLoading = false
errorMessage = message
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

public func updateFiles(_ files: [MobileDiffFile], selectedFileID: String?) {
self.files = files
if let selectedFileID, files.contains(where: { $0.id == selectedFileID }) {
self.selectedFileID = selectedFileID
} else if !files.contains(where: { $0.id == self.selectedFileID }) {
self.selectedFileID = files.first?.id
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
}

public func selectFile(id: String) {
guard files.contains(where: { $0.id == id }) else { return }
selectedFileID = id
}

public func selectPrevious() {
guard let selectedFileIndex, selectedFileIndex > files.startIndex else { return }
selectedFileID = files[files.index(before: selectedFileIndex)].id
}

public func selectNext() {
guard let selectedFileIndex, selectedFileIndex + 1 < files.endIndex else { return }
selectedFileID = files[files.index(after: selectedFileIndex)].id
}
}
Loading
Loading