feat(ios): W3 UI layer + integration CI + ntfy docs
T-iOS-11: TerminalScreen/KeyBar/TerminalViewModel + KeyByteMap (byte-for-byte keybar.ts, arrows excluded from UIKeyCommand to preserve DECCKM) T-iOS-12: PairingScreen/VM — confirm-before-network (zero-call assertions), §5.4 four-tier warnings, Host construction per contract ruling T-iOS-13: SessionListScreen/VM — Tunables-paced polling with leak-free teardown, optimistic kill+rollback, pending via overlay (LiveSessionInfo has no pending field) T-iOS-14: GateBanner/PlanGateSheet/AwayDigestView/GateViewModel — three-way mapping from SessionCore Affordance single source, tap-epoch guard, per-epoch haptics T-iOS-16: IntegrationTests vs real Node server (10 tests: origin guards, mirror, kill-close vs exit-frame differential, 16MiB+ESC/C0 replay) + ios.yml own-sources coverage gate (red-once demoed) T-iOS-17: ios/README.md ntfy chapter (read-only verification, file:line cites) Verified: 224 unit + 10 integration tests green; 5/5 semantic spot-checks; zero Owns violations
This commit is contained in:
86
ios/App/WebTerm/Components/GateBanner.swift
Normal file
86
ios/App/WebTerm/Components/GateBanner.swift
Normal file
@@ -0,0 +1,86 @@
|
||||
import SessionCore
|
||||
import SwiftUI
|
||||
|
||||
/// Copy + wire pairing for one gate button — the SINGLE label source for both
|
||||
/// gate surfaces (`GateBanner`, `PlanGateSheet`). Labels mirror
|
||||
/// public/tabs.ts:334-350 byte-for-byte; the affordance→ClientMessage mapping
|
||||
/// itself is frozen in SessionCore (`GateState.Affordance.clientMessage`).
|
||||
struct GateChoiceSpec: Equatable {
|
||||
let label: String
|
||||
let affordance: GateState.Affordance
|
||||
|
||||
/// Ordered button set for `gate` (tool → two, plan → three), driven by the
|
||||
/// frozen `GateState.affordances` list.
|
||||
static func specs(for gate: GateState) -> [GateChoiceSpec] {
|
||||
gate.affordances.map { GateChoiceSpec(label: label(for: $0), affordance: $0) }
|
||||
}
|
||||
|
||||
static func label(for affordance: GateState.Affordance) -> String {
|
||||
switch affordance {
|
||||
case .approveAuto: return "✓ Approve + Auto"
|
||||
case .approveReview: return "✓ Approve + Review"
|
||||
case .keepPlanning: return "✎ Keep Planning"
|
||||
case .approve: return "✓ Approve"
|
||||
case .reject: return "✗ Reject"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// T-iOS-14 · Two-button banner for an ordinary TOOL gate (plan gates get the
|
||||
/// three-way `PlanGateSheet`). Render-only: state lives in `GateViewModel`.
|
||||
/// Every tap reports the affordance PLUS the epoch of the gate THIS banner
|
||||
/// rendered — the VM drops stale taps (first-line guard); wiring into
|
||||
/// TerminalScreen is T-iOS-15.
|
||||
struct GateBanner: View {
|
||||
let gate: GateState
|
||||
let onDecide: (GateState.Affordance, Int) -> Void
|
||||
|
||||
private enum Metrics {
|
||||
static let spacing: CGFloat = 8
|
||||
static let horizontalPadding: CGFloat = 14
|
||||
static let verticalPadding: CGFloat = 10
|
||||
static let cornerRadius: CGFloat = 12
|
||||
static let messageLineLimit = 2
|
||||
}
|
||||
|
||||
/// Banner headline, mirror of public/tabs.ts:329:
|
||||
/// `Claude wants to use ${pendingTool ?? 'a tool'}`. `detail` is
|
||||
/// server-supplied display text (untrusted) — rendered as plain Text only.
|
||||
static func message(for gate: GateState) -> String {
|
||||
"Claude wants to use \(gate.detail ?? "a tool")"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: Metrics.spacing) {
|
||||
Text(Self.message(for: gate))
|
||||
.font(.footnote.weight(.semibold))
|
||||
.lineLimit(Metrics.messageLineLimit)
|
||||
HStack(spacing: Metrics.spacing) {
|
||||
ForEach(GateChoiceSpec.specs(for: gate), id: \.affordance) { spec in
|
||||
decisionButton(spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, Metrics.horizontalPadding)
|
||||
.padding(.vertical, Metrics.verticalPadding)
|
||||
.background(.thinMaterial, in: RoundedRectangle(cornerRadius: Metrics.cornerRadius))
|
||||
.accessibilityElement(children: .contain)
|
||||
}
|
||||
|
||||
private func decisionButton(_ spec: GateChoiceSpec) -> some View {
|
||||
Button(spec.label) {
|
||||
onDecide(spec.affordance, gate.epoch) // epoch of the RENDERED gate
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.controlSize(.small)
|
||||
.tint(tint(for: spec.affordance))
|
||||
}
|
||||
|
||||
private func tint(for affordance: GateState.Affordance) -> Color {
|
||||
switch affordance {
|
||||
case .approve, .approveAuto, .approveReview: return .green
|
||||
case .reject: return .red
|
||||
case .keepPlanning: return .indigo
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user