feat(ipad): W1-W3 — adaptive split-view layout + finding fixes
T-iPad-2: AdaptiveRootView/LayoutPolicy (sole size-class decision), SplitRootView (NavigationSplitView sidebar+detail), StackRootView (iPhone path verbatim, zero regression); privacy shade hoisted to shared ZStack top for both branches T-iPad-3: KeyBarVisibility predicate (hide when hardware keyboard present), pointer context menu (copy/new-in-cwd/kill, all via existing channels) T-iPad-4: Projects multi-column grid on iPad (idiom-gated), adaptive sheet detents T-iPad-5 findings (4/4 fixed): kill onKillSession thread-through + AppCoordinator.killCurrentSession; split route-gated to .sessions (iPad first-run pairing); continue-last banner in split sidebar; iPad XCUITest deferred (covered by SidebarSelectionTests) Verified: iPhone 16 277 + iPad Pro 11 278 tests green; packages 261 + integration 10; zero changes under ios/Packages, src/, public/
This commit is contained in:
@@ -170,6 +170,62 @@ final class AppCoordinator {
|
||||
terminalController = nil
|
||||
}
|
||||
|
||||
/// T-iPad-3 · 终端指针上下文菜单「结束会话」→ 复用既有 kill 通道
|
||||
/// (`SessionListViewModel.kill` → `APIClient.killSession`,带 Origin,无新
|
||||
/// 网络路径),随后 detach detail。无 adopted 会话 → no-op。
|
||||
func killCurrentSession() {
|
||||
guard let sessionId = terminalController?.terminalViewModel.sessionId else { return }
|
||||
Task { await sessionList.kill(sessionId: sessionId) }
|
||||
closeTerminal()
|
||||
}
|
||||
|
||||
// MARK: - Split-view sidebar bridge (T-iPad-2)
|
||||
|
||||
/// Detail 面板当前显示的会话 → sidebar 选中态(二向绑定的 getter)。只反映
|
||||
/// **adopted** 会话;未 adopted / 无打开的 detail → nil(占位「选择或新建
|
||||
/// 会话」)。分栏与 stack 共享同一 `terminalController`(归 coordinator
|
||||
/// 所有,与布局分支正交)。
|
||||
var selectedSidebarItem: SidebarItem? {
|
||||
terminalController?.terminalViewModel.sessionId.map(SidebarItem.session)
|
||||
}
|
||||
|
||||
/// `NavigationSplitView` 的选中绑定。getter 反映 detail 会话;setter 复用
|
||||
/// 既有路由(`open` / `presentProjects`)—— 分栏只是又一个触发面,绝不新开
|
||||
/// 一条会话生命周期。取消选中(set nil)不主动关闭 detail。
|
||||
var sidebarSelection: Binding<SidebarItem?> {
|
||||
Binding(
|
||||
get: { self.selectedSidebarItem },
|
||||
set: { item in
|
||||
guard let item else { return }
|
||||
self.selectSidebarItem(item)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/// sidebar 触发面:把选中项映射到**同一** open(id) / open(nil) /
|
||||
/// presentProjects API。切会话沿用单活 WS 不变式的 close→open(与
|
||||
/// new-in-cwd / deep-link 切换同一套原语),`.projects` 走既有 sheet 呈现。
|
||||
func selectSidebarItem(_ item: SidebarItem) {
|
||||
switch item {
|
||||
case .session(let sessionId):
|
||||
switchTerminal(sessionId: sessionId)
|
||||
case .newSession:
|
||||
switchTerminal(sessionId: nil)
|
||||
case .projects:
|
||||
presentProjects()
|
||||
}
|
||||
}
|
||||
|
||||
/// 单活 WS 不变式下的会话切换:已在显示同一会话 → no-op(免无谓 churn);
|
||||
/// 否则先 `closeTerminal()`(旧会话记 last-seen 水位、engine detach)再
|
||||
/// `open()`。复用既有原语,**非**平行生命周期。无 activeHost → no-op。
|
||||
private func switchTerminal(sessionId: UUID?) {
|
||||
guard let host = sessionList.activeHost else { return }
|
||||
if let sessionId, selectedSidebarItem == .session(sessionId) { return }
|
||||
if terminalController != nil { closeTerminal() }
|
||||
open(SessionListViewModel.OpenRequest(id: UUID(), host: host, sessionId: sessionId))
|
||||
}
|
||||
|
||||
// MARK: - "在当前目录开新会话" (T-iOS-29)
|
||||
|
||||
/// 当前终端会话的 cwd。解析次序:/live-sessions 行数据(server-adopted
|
||||
@@ -235,3 +291,12 @@ final class AppCoordinator {
|
||||
PairingViewModel(store: environment.hostStore, probe: environment.probe)
|
||||
}
|
||||
}
|
||||
|
||||
/// T-iPad-2 · split 模式下 sidebar 的选中项。与现有 `AppCoordinator` 路由
|
||||
/// 一一等价映射:`.session(id)` == `open(id)`、`.newSession` == `open(nil)`、
|
||||
/// `.projects` == `presentProjects()`。
|
||||
enum SidebarItem: Hashable {
|
||||
case session(UUID)
|
||||
case newSession
|
||||
case projects
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user