oficina / base Public

Offer the web's set-up when Equipo doesn't know the person

Review finding 8 (P2): Ask's not_linked state said what to do but gave
no way to do it. It now has a button that opens Base's Ask on the web,
where the code flow sets Ask up; the app itself never retries. The
button's text is a new catalog id for copy review,
native.ask.not_linked.button. Settings' Ask Base tab offers the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev aec152e33f851c170ca5e59ce914fe0dbee5c442 parent 22595a2
7 files changed, +64 −34
  • native/apple/Sources/BaseKit/Ask/AskView.swift +30 −10
  • native/apple/Sources/BaseKit/Home/BaseActions.swift +2 −0
  • native/apple/Sources/BaseKit/Mac/MacMainView.swift +1 −1
  • native/apple/Sources/BaseKit/Mac/MacSettings.swift +6 −22
  • native/apple/Sources/BaseKit/Mac/MenuPanel.swift +1 −1
  • native/apple/Sources/BaseKit/Resources/Localizable.xcstrings +12 −0
  • native/apple/Tests/BaseKitTests/AskViewTests.swift +12 −0
diff --git a/native/apple/Sources/BaseKit/Ask/AskView.swift b/native/apple/Sources/BaseKit/Ask/AskView.swift
index 676354a..00ba07e 100644
--- a/native/apple/Sources/BaseKit/Ask/AskView.swift
+++ b/native/apple/Sources/BaseKit/Ask/AskView.swift
@@ -4,8 +4,25 @@ import SwiftUI
/// browser, or another app), and setting Ask up (Task 12 runs Oficina ID's
/// set-up; until then the web's Settings).
public struct AskActions {
+ /// Set Ask up (Task 12: with Oficina ID, silently).
public var setUp: () -> Void
- public init(setUp: @escaping () -> Void) { self.setUp = setUp }
+ /// Set Ask up on the web, with the code flow: the way on when Equipo
+ /// doesn't know this person (not_linked, P2). Never retried by itself.
+ public var setUpOnWeb: () -> Void
+ public init(setUp: @escaping () -> Void, setUpOnWeb: @escaping () -> Void = {}) { self.setUp = setUp; self.setUpOnWeb = setUpOnWeb }
+
+ /// What each of Ask's not-ready states offers: its line, and its
+ /// button's text and whether it sets Ask up here or on the web.
+ public enum Way: Equatable, Sendable { case here(String), web(String) }
+ public static func note(_ phase: AskPhase) -> (lede: String, way: Way?) {
+ switch phase {
+ case .connect: ("ask.connect.lede", .here("ask.connect.button"))
+ case .pending: ("ask.pending.lede", .here("ask.pending.button"))
+ case .reconnect: ("ask.reconnect.lede", .here("ask.reconnect.button"))
+ case .notLinked: ("native.ask.not_linked", .web("native.ask.not_linked.button"))
+ default: ("ask.unavailable", nil)
+ }
+ }
}
/// Ask Base, drawn: the conversation, its status line and the composer, or
@@ -81,13 +98,16 @@ public struct AskView: View {
@ViewBuilder private func note(_ p: Palette) -> some View {
VStack(alignment: .leading, spacing: 14) {
- switch model.phase {
- case .connect: lede("ask.connect.lede", p); button("ask.connect.button")
- case .pending: lede("ask.pending.lede", p); button("ask.pending.button")
- case .reconnect: lede("ask.reconnect.lede", p); button("ask.reconnect.button")
- case .notLinked: lede("native.ask.not_linked", p)
- case .loading: ProgressView().controlSize(.small)
- default: lede("ask.unavailable", p)
+ if model.phase == .loading {
+ ProgressView().controlSize(.small)
+ } else {
+ let note = AskActions.note(model.phase)
+ lede(note.lede, p)
+ switch note.way {
+ case .here(let key)?: button(key, actions.setUp)
+ case .web(let key)?: button(key, actions.setUpOnWeb)
+ case nil: EmptyView()
+ }
}
}
.padding(.vertical, 22).padding(.horizontal, 20)
@@ -98,7 +118,7 @@ public struct AskView: View {
Text(BaseText.text(key)).font(BaseFont.body(16)).foregroundStyle(p[.haze]).fixedSize(horizontal: false, vertical: true)
}
- private func button(_ key: String) -> some View {
- Button(action: actions.setUp) { Text(BaseText.text(key)) }.buttonStyle(BaseButtonStyle(.primary))
+ private func button(_ key: String, _ action: @escaping () -> Void) -> some View {
+ Button(action: action) { Text(BaseText.text(key)) }.buttonStyle(BaseButtonStyle(.primary))
}
}
diff --git a/native/apple/Sources/BaseKit/Home/BaseActions.swift b/native/apple/Sources/BaseKit/Home/BaseActions.swift
index 1957bef..579b449 100644
--- a/native/apple/Sources/BaseKit/Home/BaseActions.swift
+++ b/native/apple/Sources/BaseKit/Home/BaseActions.swift
@@ -13,6 +13,8 @@ public struct BaseActions {
public var teams: () async -> [OficinaTeam]
public var switchTo: (OficinaTeam) async -> Void
public var setUpAsk: () -> Void
+ /// Ask's set-up on the web (P2): Base's /ask in the browser.
+ public var setUpAskOnWeb: () -> Void { { openWeb("/ask") } }
public init(open: @escaping (HomeData.App) -> Void = { _ in }, openWeb: @escaping (String) -> Void = { _ in },
signOut: @escaping () -> Void = {}, teams: @escaping () async -> [OficinaTeam] = { [] },
diff --git a/native/apple/Sources/BaseKit/Mac/MacMainView.swift b/native/apple/Sources/BaseKit/Mac/MacMainView.swift
index a19ebff..afac837 100644
--- a/native/apple/Sources/BaseKit/Mac/MacMainView.swift
+++ b/native/apple/Sources/BaseKit/Mac/MacMainView.swift
@@ -62,7 +62,7 @@ public struct MacMainView: View {
.frame(height: 52)
.overlay(alignment: .bottom) { Rectangle().fill(p[.rule]).frame(height: 1).padding(.horizontal, 12) }
if let ask {
- AskView(model: ask, layout: .window, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk))
+ AskView(model: ask, layout: .window, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk, setUpOnWeb: actions.setUpAskOnWeb))
.frame(maxWidth: 760)
.frame(maxWidth: .infinity)
} else {
diff --git a/native/apple/Sources/BaseKit/Mac/MacSettings.swift b/native/apple/Sources/BaseKit/Mac/MacSettings.swift
index e82bf6c..5436fa9 100644
--- a/native/apple/Sources/BaseKit/Mac/MacSettings.swift
+++ b/native/apple/Sources/BaseKit/Mac/MacSettings.swift
@@ -141,33 +141,17 @@ public struct MacSettingsView<Recorder: View>: View {
}
}
} else {
- SettingsRow(BaseText.text(Self.lede(model.askPhase)), detail: nil) {
- if let key = Self.action(model.askPhase) {
- Button(BaseText.text(key), action: actions.setUpAsk).buttonStyle(MiniButtonStyle())
+ let note = AskActions.note(model.askPhase)
+ SettingsRow(BaseText.text(note.lede), detail: nil) {
+ switch note.way {
+ case .here(let key)?: Button(BaseText.text(key), action: actions.setUpAsk).buttonStyle(MiniButtonStyle())
+ case .web(let key)?: Button(BaseText.text(key), action: actions.setUpAskOnWeb).buttonStyle(MiniButtonStyle())
+ case nil: EmptyView()
}
}
}
}
}
-
- static func lede(_ phase: AskPhase) -> String {
- switch phase {
- case .connect: "ask.connect.lede"
- case .pending: "ask.pending.lede"
- case .reconnect: "ask.reconnect.lede"
- case .notLinked: "native.ask.not_linked"
- default: "ask.unavailable"
- }
- }
-
- static func action(_ phase: AskPhase) -> String? {
- switch phase {
- case .connect: "ask.connect.button"
- case .pending: "ask.pending.button"
- case .reconnect: "ask.reconnect.button"
- default: nil
- }
- }
}
/// A group of Settings' rows on glass, ruled between rows.
diff --git a/native/apple/Sources/BaseKit/Mac/MenuPanel.swift b/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
index 57bd97f..92fee5e 100644
--- a/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
+++ b/native/apple/Sources/BaseKit/Mac/MenuPanel.swift
@@ -43,7 +43,7 @@ public struct MenuPanel: View {
if let ask {
VStack(spacing: 0) {
WaitingJobs(ask: ask, timeZone: me?.base.timeZone)
- AskView(model: ask, layout: .panel, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk), focusOnAppear: true)
+ AskView(model: ask, layout: .panel, timeZone: me?.base.timeZone, actions: AskActions(setUp: actions.setUpAsk, setUpOnWeb: actions.setUpAskOnWeb), focusOnAppear: true)
}
} else {
Spacer()
diff --git a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings
index 60b2507..5674bec 100644
--- a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings
+++ b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings
@@ -481,6 +481,18 @@
}
}
},
+ "native.ask.not_linked.button": {
+ "comment": "Not in copy review yet: the button under native.ask.not_linked (P2). It opens Base's Ask on the web, where the code flow sets Ask up; the app never retries by itself.",
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Set up Ask Base on the web"
+ }
+ }
+ }
+ },
"native.ask.send.error": {
"comment": "Under a message that failed to send.",
"extractionState": "manual",
diff --git a/native/apple/Tests/BaseKitTests/AskViewTests.swift b/native/apple/Tests/BaseKitTests/AskViewTests.swift
index c63a8b1..4ab968a 100644
--- a/native/apple/Tests/BaseKitTests/AskViewTests.swift
+++ b/native/apple/Tests/BaseKitTests/AskViewTests.swift
@@ -43,3 +43,15 @@ final class AskViewTests: XCTestCase {
"Christmas order form, One question for you")
}
}
+
+extension AskViewTests {
+ /// Review finding 8 (P2): not_linked offers the web's set-up, and only
+ /// the states Oficina ID can set up offer to set up here.
+ func testNotLinkedOffersTheWebsSetUp() {
+ XCTAssertEqual(AskActions.note(.notLinked).way, .web("native.ask.not_linked.button"))
+ XCTAssertEqual(AskActions.note(.connect).way, .here("ask.connect.button"))
+ XCTAssertEqual(AskActions.note(.reconnect).way, .here("ask.reconnect.button"))
+ XCTAssertNil(AskActions.note(.unavailable).way)
+ XCTAssertEqual(BaseText.text("native.ask.not_linked.button"), "Set up Ask Base on the web")
+ }
+}