Docs native S2a: DocsModel.access is documentAccess
It shadowed Observation's access(keyPath:), which S1a calls by hand (Fable on #169, finding 8).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+19
−19
native/apple/Sources/DocsKit/DocsDocumentHeader.swift+4 −4native/apple/Sources/DocsKit/DocsDocumentMenu.swift+3 −3native/apple/Sources/DocsKit/DocsEditorCommands.swift+1 −1native/apple/Sources/DocsKit/DocsModel.swift+1 −1native/apple/Sources/DocsKit/DocsSubtitle.swift+1 −1native/apple/Sources/DocsKit/DocsWorkspace.swift+1 −1native/apple/Tests/DocsKitTests/DocsAccessTests.swift+8 −8
diff --git a/native/apple/Sources/DocsKit/DocsDocumentHeader.swift b/native/apple/Sources/DocsKit/DocsDocumentHeader.swift| index 4acbf3b..9274b4e 100644 |
| --- a/native/apple/Sources/DocsKit/DocsDocumentHeader.swift |
| +++ b/native/apple/Sources/DocsKit/DocsDocumentHeader.swift |
| @@ -86,8 +86,8 @@ enum DocsInspectorState { |
| let share: () -> Void |
| var body: some View { |
| - let canWrite = model.access == .writable |
| - let canShare = model.detail?.can_share == true && !model.isDraft && model.access != .unavailable |
| + let canWrite = model.documentAccess == .writable |
| + let canShare = model.detail?.can_share == true && !model.isDraft && model.documentAccess != .unavailable |
| switch part { |
| case .history: |
| if canWrite { DocsUndoRedoPill(model: model).fixedSize() } |
| @@ -194,13 +194,13 @@ struct DocsPillStyle: ButtonStyle { |
| VStack(spacing: DocsSpacing.sp2) { |
| // §6 rows 5 and 6: the session ended. Typing still reaches the |
| // outbox; signing in sends it. |
| - if model.access != .unavailable, case .needsSignIn(let pending) = model.syncStatus { |
| + if model.documentAccess != .unavailable, case .needsSignIn(let pending) = model.syncStatus { |
| let sync = NativeSyncStrings.kit |
| callout(Text(verbatim: pending > 0 ? sync.needsSignIn(pending) : DocsStrings(locale: locale)("native.subtitle.signedOut")), negative: true) { |
| Button { signIn() } label: { Text(verbatim: sync.signIn) } |
| } |
| } |
| - if model.access == .unavailable { |
| + if model.documentAccess == .unavailable { |
| callout(Text("native.unavailable.body", bundle: DocsResources.bundle), negative: true) { |
| Button { close() } label: { Text("native.close", bundle: DocsResources.bundle) } |
| if model.hasUnsavedChanges { |
diff --git a/native/apple/Sources/DocsKit/DocsDocumentMenu.swift b/native/apple/Sources/DocsKit/DocsDocumentMenu.swift| index d024f14..939e546 100644 |
| --- a/native/apple/Sources/DocsKit/DocsDocumentMenu.swift |
| +++ b/native/apple/Sources/DocsKit/DocsDocumentMenu.swift |
| @@ -20,9 +20,9 @@ public struct DocsDocumentMenu: View { |
| public var body: some View { |
| Group { |
| // Absent, not disabled, for a reader (spec §1, reader mode). |
| - if editor == nil || editor?.model.access == .writable { |
| + if editor == nil || editor?.model.documentAccess == .writable { |
| Button { editor?.rename() } label: { Text("docs.document.rename", bundle: DocsResources.bundle) } |
| - .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.access != .writable) |
| + .keyboardShortcut("r", modifiers: [.command, .shift]).disabled(editor?.model.documentAccess != .writable) |
| } |
| Button(docsMacString("Save")) { if let editor { Task { _ = await editor.model.saveAll() } } } |
| .keyboardShortcut("s").disabled(editor == nil) |
| @@ -32,7 +32,7 @@ public struct DocsDocumentMenu: View { |
| }.disabled(editor == nil || editor?.model.isDraft == true) |
| Button { if let editor { Task { if await editor.model.saveAll() { editor.sharing.wrappedValue = true } } } } label: { |
| Text("docs.share.action", bundle: DocsResources.bundle) |
| - }.disabled(editor?.model.detail?.can_share != true || editor?.model.isDraft == true || editor?.model.access == .unavailable) |
| + }.disabled(editor?.model.detail?.can_share != true || editor?.model.isDraft == true || editor?.model.documentAccess == .unavailable) |
| Divider() |
diff --git a/native/apple/Sources/DocsKit/DocsEditorCommands.swift b/native/apple/Sources/DocsKit/DocsEditorCommands.swift| index 418e73b..0693b6a 100644 |
| --- a/native/apple/Sources/DocsKit/DocsEditorCommands.swift |
| +++ b/native/apple/Sources/DocsKit/DocsEditorCommands.swift |
| @@ -63,7 +63,7 @@ public struct DocsEditorCommands: Commands { |
| // editor), where there is no inspector to show. |
| Button { inspectorOpen.toggle() } label: { text(inspectorOpen ? "native.format.hide" : "native.format.show") } |
| .keyboardShortcut("i", modifiers: [.command, .option]) |
| - .disabled(editor?.model.access != .writable) |
| + .disabled(editor?.model.documentAccess != .writable) |
| Divider() |
| if let editor { |
| Picker(selection: editor.paged) { |
diff --git a/native/apple/Sources/DocsKit/DocsModel.swift b/native/apple/Sources/DocsKit/DocsModel.swift| index c1f914d..416aa88 100644 |
| --- a/native/apple/Sources/DocsKit/DocsModel.swift |
| +++ b/native/apple/Sources/DocsKit/DocsModel.swift |
| @@ -22,7 +22,7 @@ import RastrilloNative |
| /// Input paused by a 401 while the session is re-minted (§6 notes). |
| @ObservationIgnored private var pausedForSession = false |
| /// What the window may do with the document (§6 rows 1 and 10). |
| - var access: DocsAccess { unavailable ? .unavailable : detail?.can_write == true ? .writable : .readOnly } |
| + var documentAccess: DocsAccess { unavailable ? .unavailable : detail?.can_write == true ? .writable : .readOnly } |
| var explicitCommandRevision: UInt64 = 0 |
| var loading = false |
| var creatingDocument = false |
diff --git a/native/apple/Sources/DocsKit/DocsSubtitle.swift b/native/apple/Sources/DocsKit/DocsSubtitle.swift| index 6e5b603..585643f 100644 |
| --- a/native/apple/Sources/DocsKit/DocsSubtitle.swift |
| +++ b/native/apple/Sources/DocsKit/DocsSubtitle.swift |
| @@ -138,7 +138,7 @@ struct DocsStrings { |
| let model: DocsModel |
| let team: String? |
| var body: some View { |
| - DocsSubtitleBody(status: model.syncStatus, access: model.access, loading: model.loading, draft: model.isDraft, team: team) |
| + DocsSubtitleBody(status: model.syncStatus, access: model.documentAccess, loading: model.loading, draft: model.isDraft, team: team) |
| } |
| } |
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift| index c10120f..46f6be5 100644 |
| --- a/native/apple/Sources/DocsKit/DocsWorkspace.swift |
| +++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift |
| @@ -249,7 +249,7 @@ import SwiftUI |
| } |
| /// A writer's window shows the inspector when the app-wide state says |
| /// open; a reader's never does, and never writes the state (spec §1). |
| - private var showsInspector: Bool { inspectorOpen && model.access == .writable } |
| + private var showsInspector: Bool { inspectorOpen && model.documentAccess == .writable } |
| #endif |
| private var editor: some View { |
| VStack(spacing: 0) { |
diff --git a/native/apple/Tests/DocsKitTests/DocsAccessTests.swift b/native/apple/Tests/DocsKitTests/DocsAccessTests.swift| index 88d3209..f25c7c9 100644 |
| --- a/native/apple/Tests/DocsKitTests/DocsAccessTests.swift |
| +++ b/native/apple/Tests/DocsKitTests/DocsAccessTests.swift |
| @@ -19,7 +19,7 @@ import XCTest |
| let model = DocsModel(transport: { server }, connectivity: connectivity, offlineAccount: account) |
| await model.open("doc") |
| XCTAssertNotNil(model.projection, "the document opened") |
| - XCTAssertEqual(model.access, .writable) |
| + XCTAssertEqual(model.documentAccess, .writable) |
| return (model, server) |
| } |
| @@ -30,21 +30,21 @@ import XCTest |
| } |
| private func row(_ model: DocsModel) -> DocsSubtitleRow { |
| - DocsSubtitleRow(access: model.access, status: .saved, savingShown: false, loading: model.loading) |
| + DocsSubtitleRow(access: model.documentAccess, status: .saved, savingShown: false, loading: model.loading) |
| } |
| func testA403IsNoLongerAvailableAndALater200LeavesIt() async throws { |
| let (model, server) = try await open() |
| await server.answer(403) |
| await revalidate(model) |
| - XCTAssertEqual(model.access, .unavailable) |
| + XCTAssertEqual(model.documentAccess, .unavailable) |
| XCTAssertEqual(row(model), .unavailable) |
| XCTAssertTrue(model.inputPaused, "the editor becomes read-only") |
| XCTAssertFalse(model.enqueue(["op": .string("display_edit"), "at": .number(0), "length": .number(0), "text": .string("x")])) |
| await server.answer(200, canWrite: true) |
| await revalidate(model) |
| - XCTAssertEqual(model.access, .writable, "re-shared or restored: row 1 is left") |
| + XCTAssertEqual(model.documentAccess, .writable, "re-shared or restored: row 1 is left") |
| XCTAssertEqual(row(model), .saved) |
| XCTAssertFalse(model.inputPaused) |
| await model.stop() |
| @@ -54,7 +54,7 @@ import XCTest |
| let (model, server) = try await open() |
| await server.answer(404) |
| await revalidate(model) |
| - XCTAssertEqual(model.access, .unavailable) |
| + XCTAssertEqual(model.documentAccess, .unavailable) |
| XCTAssertEqual(model.detail?.can_write, false) |
| await model.stop() |
| } |
| @@ -64,14 +64,14 @@ import XCTest |
| await server.answer(401) |
| await revalidate(model) |
| XCTAssertEqual(model.detail?.can_write, true, "a 401 never touches can_write") |
| - XCTAssertEqual(model.access, .writable, "and so no reader chrome") |
| + XCTAssertEqual(model.documentAccess, .writable, "and so no reader chrome") |
| XCTAssertTrue(model.inputPaused, "input pauses while the session is re-minted") |
| // The re-minted session's 200 resumes input, can_write unchanged. |
| await server.answer(200, canWrite: true) |
| await revalidate(model) |
| XCTAssertFalse(model.inputPaused) |
| - XCTAssertEqual(model.access, .writable) |
| + XCTAssertEqual(model.documentAccess, .writable) |
| await model.stop() |
| } |
| @@ -81,7 +81,7 @@ import XCTest |
| let identity = model.editorIdentity |
| await server.answer(200, canWrite: false) |
| await revalidate(model) |
| - XCTAssertEqual(model.access, .readOnly) |
| + XCTAssertEqual(model.documentAccess, .readOnly) |
| XCTAssertEqual(row(model), .viewOnly) |
| XCTAssertTrue(model.inputPaused) |
| XCTAssertEqual(model.editorIdentity, identity, "applied in place: the same text view") |