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:
110
ios/App/WebTerm/Wiring/AdaptiveRootView.swift
Normal file
110
ios/App/WebTerm/Wiring/AdaptiveRootView.swift
Normal file
@@ -0,0 +1,110 @@
|
||||
import SwiftUI
|
||||
|
||||
/// T-iPad-2 · size-class 驱动的单一根视图。按 `LayoutPolicy.mode` 在 compact
|
||||
/// 宽度(iPhone / iPad Slide Over)选 `StackRootView`(现有路径,字节级不变)、
|
||||
/// 在 regular 宽度(iPad 全屏 / 大分屏 / Stage Manager 大窗)选 `SplitRootView`
|
||||
/// (分栏)。
|
||||
///
|
||||
/// **横切布线只声明一次、两分支共享**(PLAN_IOS_IPAD §5 T-iPad-2):
|
||||
/// - 隐私遮罩:ZStack 的**最顶层**,覆盖整棵导航树(含 split detail 的终端
|
||||
/// 字节)——`scenePhase != .active` 即遮(安全不变式,见 `PrivacyShadePolicy`)。
|
||||
/// 上提到这里,split detail 与 stack push 同样被遮,无遗漏。
|
||||
/// - `.task` bootstrap / `.onChange(scenePhase)` / `.onOpenURL` / deep-link 提示
|
||||
/// alert / add-host sheet / Projects sheet:全部设备无关,原样从旧 `RootView`
|
||||
/// 搬到这一层,故 compact 分支拿到与适配前完全一致的横切行为。
|
||||
///
|
||||
/// size class 是**运行时可变量**(iPad 拉出 Slide Over 立刻 regular→compact),
|
||||
/// 所以这不是两套 UI 分叉,而是同一次运行内的自适应切换:`terminalController`
|
||||
/// 归 `AppCoordinator` 所有,与布局分支正交,切换时不重建(T-iOS-29 `.id`
|
||||
/// 稳定性的前提)。
|
||||
struct AdaptiveRootView: View {
|
||||
@Bindable var coordinator: AppCoordinator
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
layoutBranch
|
||||
if PrivacyShadePolicy.isShadeVisible(for: scenePhase) {
|
||||
PrivacyShadeView()
|
||||
}
|
||||
}
|
||||
.task { await coordinator.bootstrap() }
|
||||
.onChange(of: scenePhase) { _, phase in
|
||||
coordinator.handleScenePhase(phase)
|
||||
}
|
||||
.onOpenURL { coordinator.handleDeepLink(url: $0) } // T-iOS-22
|
||||
.alert(DeepLinkCopy.hintTitle, isPresented: deepLinkHintBinding) {
|
||||
Button(DeepLinkCopy.hintConfirm) { coordinator.deepLink.clearHint() }
|
||||
} message: {
|
||||
Text(coordinator.deepLink.hintMessage ?? "")
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $coordinator.isAddHostPresented,
|
||||
onDismiss: { coordinator.addHostDismissed() }
|
||||
) {
|
||||
addHostSheet
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $coordinator.isProjectsPresented,
|
||||
onDismiss: { coordinator.projectsDismissed() }
|
||||
) {
|
||||
projectsSheet
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Layout branch (the SOLE size-class consumer)
|
||||
|
||||
@ViewBuilder private var layoutBranch: some View {
|
||||
// Split only makes sense once we're in the session list. `.loading` and
|
||||
// `.pairing` (genuine iPad first-run, no paired host) get the full-screen
|
||||
// stack flow regardless of size class — a split sidebar has nothing to
|
||||
// list yet and would strand the user on the not-paired empty state
|
||||
// (T-iPad-5 finding). Route-gate the split branch.
|
||||
switch LayoutPolicy.mode(horizontalSizeClass: horizontalSizeClass) {
|
||||
case .split where coordinator.route == .sessions:
|
||||
SplitRootView(coordinator: coordinator)
|
||||
default:
|
||||
StackRootView(coordinator: coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Deep-link hint alert (T-iOS-22)
|
||||
|
||||
/// unknown host / store failure 提示(同旧 `RootView`)。
|
||||
private var deepLinkHintBinding: Binding<Bool> {
|
||||
Binding(
|
||||
get: { coordinator.deepLink.hintMessage != nil },
|
||||
set: { presented in
|
||||
guard !presented else { return }
|
||||
coordinator.deepLink.clearHint()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Add-host sheet (multi-host entry, list header)
|
||||
|
||||
@ViewBuilder private var addHostSheet: some View {
|
||||
if let viewModel = coordinator.addHostPairingViewModel {
|
||||
NavigationStack {
|
||||
PairingScreen(viewModel: viewModel) { host in
|
||||
coordinator.completeAddHost(host)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Projects sheet (T-iOS-26)
|
||||
|
||||
/// 自带 NavigationStack:列表 → 详情 → 差异都在 sheet 内 push;
|
||||
/// "在此仓库开新会话" 关掉 sheet 并在根导航开终端。
|
||||
@ViewBuilder private var projectsSheet: some View {
|
||||
if let viewModel = coordinator.projectsViewModel {
|
||||
NavigationStack {
|
||||
ProjectsScreen(viewModel: viewModel) { request in
|
||||
coordinator.openProject(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
22
ios/App/WebTerm/Wiring/LayoutMode.swift
Normal file
22
ios/App/WebTerm/Wiring/LayoutMode.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
/// T-iPad-2 · 自适应根视图的布局模式。
|
||||
public enum LayoutMode: Equatable {
|
||||
/// 现有 iPhone 路径:`NavigationStack`(列表 → push 终端)。
|
||||
case stack
|
||||
/// iPad 分栏:`NavigationSplitView`(sidebar 会话列表 + detail 终端)。
|
||||
case split
|
||||
}
|
||||
|
||||
/// T-iPad-2 · **唯一** size-class 决策点(仿 `PrivacyShadePolicy` 的纯谓词
|
||||
/// 先例)。视图内严禁散落 `if sizeClass == …`(PLAN_IOS_IPAD §4)—— 所有
|
||||
/// 分支只从这里读一次,故可 100% 单测。
|
||||
///
|
||||
/// regular 宽度(iPad 全屏 / 大分屏 / Stage Manager 大窗)→ `.split`;
|
||||
/// compact 或 nil(iPhone / iPad Slide Over / 小分屏 / size class 未定)→
|
||||
/// `.stack`。nil 走最保守回退:退到现有已测的 iPhone 路径,绝不误判成分栏。
|
||||
public enum LayoutPolicy {
|
||||
public static func mode(horizontalSizeClass: UserInterfaceSizeClass?) -> LayoutMode {
|
||||
horizontalSizeClass == .regular ? .split : .stack
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,39 @@
|
||||
import HostRegistry
|
||||
import SwiftUI
|
||||
|
||||
/// T-iOS-15 · Root of the app: route switch (Pairing / SessionList), terminal
|
||||
/// push, add-host sheet, scenePhase forwarding and the privacy shade.
|
||||
/// T-iOS-15 / T-iPad-2 · App 根入口。历史上这里是单一 `NavigationStack` +
|
||||
/// 隐私遮罩 + sheets/scenePhase/deepLink 的全部布线;iPad 自适应(T-iPad-2)
|
||||
/// 把它拆成两层:
|
||||
/// - `RootView`(本 struct)保持 `@main` 的唯一实例化点不变(WebTermApp 仍
|
||||
/// `RootView(coordinator:)`),内部只委托给 `AdaptiveRootView`。
|
||||
/// - `AdaptiveRootView` 按 `horizontalSizeClass` 选 `StackRootView`(compact,
|
||||
/// 现有路径,字节级不变)或 `SplitRootView`(regular,iPad 分栏),并把
|
||||
/// 隐私遮罩 / scenePhase / deepLink / sheets 这些**设备无关的横切布线**
|
||||
/// 上提到唯一一处,两分支共享(遮罩因此仍是两分支共同的 ZStack 顶层)。
|
||||
///
|
||||
/// The shade is the TOPMOST layer of this ZStack and appears whenever
|
||||
/// `scenePhase != .active` (exact rule — PrivacyShadePolicy + tests); it
|
||||
/// covers the whole navigation tree, terminal included. Sheets live above any
|
||||
/// overlay, but no sheet renders terminal bytes (pairing / plan gate only).
|
||||
/// `StackRootView` 是原 `RootView` 的 body **原样搬迁** —— compact 分支复用它
|
||||
/// 不改一行,故 iPhone 逐屏渲染与适配前一致(零回归硬性要求)。
|
||||
struct RootView: View {
|
||||
@Bindable var coordinator: AppCoordinator
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
NavigationStack {
|
||||
rootContent
|
||||
.navigationDestination(isPresented: terminalBinding) {
|
||||
terminalDestination
|
||||
}
|
||||
}
|
||||
if PrivacyShadePolicy.isShadeVisible(for: scenePhase) {
|
||||
PrivacyShadeView()
|
||||
}
|
||||
}
|
||||
.task { await coordinator.bootstrap() }
|
||||
.onChange(of: scenePhase) { _, phase in
|
||||
coordinator.handleScenePhase(phase)
|
||||
}
|
||||
.onOpenURL { coordinator.handleDeepLink(url: $0) } // T-iOS-22
|
||||
.alert(DeepLinkCopy.hintTitle, isPresented: deepLinkHintBinding) {
|
||||
Button(DeepLinkCopy.hintConfirm) { coordinator.deepLink.clearHint() }
|
||||
} message: {
|
||||
Text(coordinator.deepLink.hintMessage ?? "")
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $coordinator.isAddHostPresented,
|
||||
onDismiss: { coordinator.addHostDismissed() }
|
||||
) {
|
||||
addHostSheet
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $coordinator.isProjectsPresented,
|
||||
onDismiss: { coordinator.projectsDismissed() }
|
||||
) {
|
||||
projectsSheet
|
||||
}
|
||||
AdaptiveRootView(coordinator: coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
/// Deep-link hint alert (unknown host / store failure, T-iOS-22).
|
||||
private var deepLinkHintBinding: Binding<Bool> {
|
||||
Binding(
|
||||
get: { coordinator.deepLink.hintMessage != nil },
|
||||
set: { presented in
|
||||
guard !presented else { return }
|
||||
coordinator.deepLink.clearHint()
|
||||
}
|
||||
)
|
||||
/// T-iPad-2 · compact 宽度(iPhone / iPad Slide Over)的根视图 —— 原
|
||||
/// `RootView` 的 `NavigationStack` 主体原样搬迁,行为字节级不变。横切布线
|
||||
/// (遮罩/scenePhase/deepLink/sheets)不在这里,已上提到 `AdaptiveRootView`。
|
||||
struct StackRootView: View {
|
||||
@Bindable var coordinator: AppCoordinator
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
rootContent
|
||||
.navigationDestination(isPresented: terminalBinding) {
|
||||
terminalDestination
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Route switch
|
||||
@@ -140,7 +117,8 @@ struct RootView: View {
|
||||
if let controller = coordinator.terminalController {
|
||||
TerminalContainerView(
|
||||
controller: controller,
|
||||
onNewSessionInCwd: { coordinator.openNewSessionInCurrentCwd() }
|
||||
onNewSessionInCwd: { coordinator.openNewSessionInCurrentCwd() },
|
||||
onKillSession: { coordinator.killCurrentSession() } // T-iPad-3
|
||||
)
|
||||
// T-iOS-29 · identity PER CONTROLLER: an in-place session switch
|
||||
// (new-in-cwd, deep link) swaps the controller while the
|
||||
@@ -151,40 +129,15 @@ struct RootView: View {
|
||||
.id(controller.id)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Add-host sheet (multi-host entry, list header)
|
||||
|
||||
@ViewBuilder private var addHostSheet: some View {
|
||||
if let viewModel = coordinator.addHostPairingViewModel {
|
||||
NavigationStack {
|
||||
PairingScreen(viewModel: viewModel) { host in
|
||||
coordinator.completeAddHost(host)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Projects sheet (T-iOS-26)
|
||||
|
||||
/// 自带 NavigationStack:列表 → 详情 → 差异都在 sheet 内 push;
|
||||
/// "在此仓库开新会话" 关掉 sheet 并在根导航推入终端。
|
||||
@ViewBuilder private var projectsSheet: some View {
|
||||
if let viewModel = coordinator.projectsViewModel {
|
||||
NavigationStack {
|
||||
ProjectsScreen(viewModel: viewModel) { request in
|
||||
coordinator.openProject(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum RootMetrics {
|
||||
enum RootMetrics {
|
||||
static let bannerHorizontalPadding: CGFloat = 16
|
||||
static let bannerVerticalPadding: CGFloat = 8
|
||||
}
|
||||
|
||||
private enum RootCopy {
|
||||
/// 根层用户可见文案(internal —— `SplitRootView` 复用同一「项目」标签,DRY)。
|
||||
enum RootCopy {
|
||||
static let continueLast = "继续上次会话"
|
||||
static let projects = "项目"
|
||||
}
|
||||
|
||||
110
ios/App/WebTerm/Wiring/SplitRootView.swift
Normal file
110
ios/App/WebTerm/Wiring/SplitRootView.swift
Normal file
@@ -0,0 +1,110 @@
|
||||
import SwiftUI
|
||||
|
||||
/// T-iPad-2 · regular 宽度(iPad 全屏 / 大分屏 / Stage Manager 大窗)的分栏根
|
||||
/// 视图。左 sidebar = 会话列表(复用 `SessionListScreen` **不改一行** + 与
|
||||
/// stack 同款的「项目」leading 工具栏入口);右 detail = `TerminalContainerView`
|
||||
/// (终端 + gate/digest 叠层,复用不动),无打开会话时给「选择或新建会话」占位。
|
||||
///
|
||||
/// 设计要点:
|
||||
/// - **detail 复用 `TerminalContainerView`**:终端组装与它挂 push destination 还是
|
||||
/// split detail 无关,只换外层容器、内容零改(PLAN_IOS_IPAD §1)。
|
||||
/// - **选中态经 `AppCoordinator` 单一真值**:sidebar 触发面全部走
|
||||
/// `selectSidebarItem` / `open`(同 stack 的既有路由),不新开会话生命周期。
|
||||
/// - **detail 终端仍带 `.id(controller.id)`**:换会话时新 controller → 新
|
||||
/// SwiftTerm 视图(回放 ring buffer),identity 稳定复用 T-iOS-29 语义。
|
||||
/// - **隐私遮罩不在这里**:它在 `AdaptiveRootView` 的 ZStack 顶层,两分支共享,
|
||||
/// 故 detail 终端字节同样在 `scenePhase != .active` 时被遮(安全不变式)。
|
||||
struct SplitRootView: View {
|
||||
@Bindable var coordinator: AppCoordinator
|
||||
|
||||
var body: some View {
|
||||
NavigationSplitView {
|
||||
sidebar
|
||||
} detail: {
|
||||
detail
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Sidebar(会话列表 + 项目入口,复用 SessionListScreen)
|
||||
|
||||
private var sidebar: some View {
|
||||
SessionListScreen(
|
||||
viewModel: coordinator.sessionList,
|
||||
onOpen: { request in
|
||||
// 分栏只是又一个触发面:映射到同一 selectSidebarItem 路由。
|
||||
coordinator.selectSidebarItem(sidebarItem(for: request))
|
||||
},
|
||||
onAddHost: { coordinator.presentAddHost() }
|
||||
)
|
||||
.safeAreaInset(edge: .bottom) { continueLastBanner }
|
||||
.toolbar { projectsToolbarItem }
|
||||
}
|
||||
|
||||
/// 与 `StackRootView.continueLastBanner` 同款「继续上次会话」(冷启动第 5 步)
|
||||
/// —— 分栏 sidebar 也提供,iPad 用户不丢该入口(T-iPad-5 finding)。
|
||||
@ViewBuilder private var continueLastBanner: some View {
|
||||
if coordinator.continueLastSessionId != nil {
|
||||
Button {
|
||||
coordinator.openContinueLast()
|
||||
} label: {
|
||||
Label(RootCopy.continueLast, systemImage: "arrow.uturn.forward.circle.fill")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.padding(.horizontal, RootMetrics.bannerHorizontalPadding)
|
||||
.padding(.vertical, RootMetrics.bannerVerticalPadding)
|
||||
.background(.thinMaterial)
|
||||
}
|
||||
}
|
||||
|
||||
/// 列表的 `OpenRequest` → sidebar 选中项(sessionId 有无 = 采纳既有 / 新建)。
|
||||
private func sidebarItem(for request: SessionListViewModel.OpenRequest) -> SidebarItem {
|
||||
request.sessionId.map(SidebarItem.session) ?? .newSession
|
||||
}
|
||||
|
||||
/// 与 `StackRootView.projectsToolbarItem` 同款(leading 位、同 disabled 条件、
|
||||
/// 复用 `presentProjects`)—— iPad 上 Projects 本期仍走既有 sheet(大屏化留
|
||||
/// 给 T-iPad-4)。
|
||||
@ToolbarContentBuilder private var projectsToolbarItem: some ToolbarContent {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Button {
|
||||
coordinator.presentProjects()
|
||||
} label: {
|
||||
Label(RootCopy.projects, systemImage: "folder")
|
||||
}
|
||||
.disabled(coordinator.sessionList.activeHost == nil)
|
||||
.accessibilityIdentifier("sessions.projectsButton")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Detail(终端或占位)
|
||||
|
||||
@ViewBuilder private var detail: some View {
|
||||
if let controller = coordinator.terminalController {
|
||||
NavigationStack {
|
||||
TerminalContainerView(
|
||||
controller: controller,
|
||||
onNewSessionInCwd: { coordinator.openNewSessionInCurrentCwd() },
|
||||
onKillSession: { coordinator.killCurrentSession() } // T-iPad-3
|
||||
)
|
||||
.id(controller.id) // T-iOS-29 · identity per controller
|
||||
}
|
||||
} else {
|
||||
placeholder
|
||||
}
|
||||
}
|
||||
|
||||
private var placeholder: some View {
|
||||
ContentUnavailableView {
|
||||
Label(SplitCopy.placeholderTitle, systemImage: "sidebar.left")
|
||||
} description: {
|
||||
Text(SplitCopy.placeholderHint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// split 专属用户可见文案(「项目」标签复用 `RootCopy.projects`,DRY)。
|
||||
private enum SplitCopy {
|
||||
static let placeholderTitle = "选择或新建会话"
|
||||
static let placeholderHint = "从左侧选择一个运行中的会话,或新建一个开始工作。"
|
||||
}
|
||||
@@ -22,6 +22,10 @@ struct TerminalContainerView: View {
|
||||
/// T-iOS-29 · pass-through to TerminalScreen's toolbar/exit-banner
|
||||
/// "在当前目录开新会话" action (RootView supplies the coordinator hop).
|
||||
var onNewSessionInCwd: (@MainActor () -> Void)? = nil
|
||||
/// T-iPad-3 · pass-through to TerminalScreen's pointer context-menu
|
||||
/// "结束会话" action (root layers supply the coordinator hop). nil on
|
||||
/// surfaces without a kill affordance (e.g. previews).
|
||||
var onKillSession: (@MainActor () -> Void)? = nil
|
||||
/// Epoch of a plan gate the user swiped away — suppresses re-present for
|
||||
/// THAT gate only; a new epoch re-presents automatically.
|
||||
@State private var dismissedPlanGateEpoch: Int?
|
||||
@@ -48,7 +52,8 @@ struct TerminalContainerView: View {
|
||||
var body: some View {
|
||||
TerminalScreen(
|
||||
viewModel: controller.terminalViewModel,
|
||||
onNewSessionInCwd: onNewSessionInCwd
|
||||
onNewSessionInCwd: onNewSessionInCwd,
|
||||
onKillSession: onKillSession
|
||||
)
|
||||
.id(controller.generation)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
||||
Reference in New Issue
Block a user