Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
6cdb499
feat(duckdb): connect to MotherDuck and update DuckDB to 2.0.1 (#4461)
datlechin Nov 24, 2026
3eb0d7b
docs(core): ADR 0046, a monthly self-hosted license has 7 days' grace…
datlechin Nov 24, 2026
78ec49e
fix(mcp): bind approvals to the scope they showed and harden scope ru…
datlechin Nov 24, 2026
75d2bb4
docs(core): ADR 0048, a self-hosted install signs in through OIDC or …
datlechin Nov 24, 2026
9cf15f0
perf(editor): restyle a long line without typesetting it again (#4475)
datlechin Nov 24, 2026
ddf5288
perf(dashboard): publish one board per Server Dashboard refresh (#4476)
datlechin Nov 24, 2026
32dc16b
fix(focus): keep the sidebar selection accent and the keyboard when a…
datlechin Nov 25, 2026
a1238a1
feat(ai): read models from each provider and a shared catalog (#4477)
datlechin Nov 25, 2026
8955f77
feat(core): sign in to a company server and verify its license (#4470)
datlechin Nov 25, 2026
dfaf912
docs(core): ADR 0050, a self-hosted license renewal is requested by t…
datlechin Nov 25, 2026
fe6a624
docs(core): ADR 0055, managed policies for the sync provider and tabl…
datlechin Nov 25, 2026
e2b0999
feat(filter): list the filter column picker alphabetically on request…
datlechin Nov 25, 2026
2f1d007
feat(core): require RFC 9207 iss where the server promises it, compar…
datlechin Nov 25, 2026
5f4a17f
docs(core): ADR 0051, the sync protocol and its record rules (#4488)
datlechin Nov 25, 2026
3a14cbf
test(core-sqlite): measure the linked SQLite's stored tail check inst…
datlechin Nov 25, 2026
274dcd4
docs(core): 0055's personalSync keeps the key kinds, as amended by 00…
datlechin Nov 25, 2026
54efc4f
docs(core): ADR 0051, G0 round 1 fixes (#4491)
datlechin Nov 25, 2026
cd9b322
docs(core): ADR 0052, synced records have canonical ids and saved que…
datlechin Nov 25, 2026
3b3516e
docs(core): ADR 0051, G0 round 3 security fixes (#4496)
datlechin Nov 25, 2026
43753ff
docs(core): ADR 0054, one sync engine in the core for TablePro Sync a…
datlechin Nov 25, 2026
3c7724f
docs(core): ADR 0053, end-to-end sync keys under the recovery key, an…
datlechin Nov 25, 2026
f1bd5ca
docs(core): 0044 names what 0053 amends (#4499)
datlechin Nov 25, 2026
5f9ac36
docs(core): ADR 0051, G0 round 5 fixes (#4500)
datlechin Nov 25, 2026
c9ded5a
docs(core): 0054's key versions count from the chain, reset generatio…
datlechin Nov 25, 2026
836625e
docs(core): 0054 drop rule, generations without S, head times, fork b…
datlechin Nov 25, 2026
e0c55c6
docs(core): ADR 0053 G0 round 5, equivocation-only forks, new generat…
datlechin Nov 25, 2026
6a202f5
docs(core): ADR 0051, new generations and identity-key team statement…
datlechin Nov 25, 2026
9bdaa24
docs(core): ADR 0052, identity, device and member ids carry the gener…
datlechin Nov 25, 2026
8d79637
fix(transfer): show progress and results inside the import, export an…
datlechin Nov 25, 2026
e2c9a12
docs(core): ADR 0056, end-to-end keys on the 1Password and Bitwarden …
datlechin Nov 25, 2026
0aa3828
docs(core): align 0051, 0052, 0054, 0044 and 0055 with ADR 0056 (#4507)
datlechin Nov 25, 2026
4af6f5d
docs(core): ADR 0056 r2 and 0051, 0052, 0054 amendments for G0 round …
datlechin Nov 25, 2026
c2d418a
feat(policy): apply the ADR 0055 managed policy keys on the Mac and i…
datlechin Nov 25, 2026
26f3157
docs(core): ADR 0056 r3 and 0051, 0054 amendments for G0 round 2 (#4509)
datlechin Nov 25, 2026
c8f9b84
docs(core): ADR 0056 r4 and 0051, 0054 amendments for G0 round 3 (#4511)
datlechin Nov 25, 2026
d95bf4e
chore(skills): verify.sh takes a jobs cap (#4510)
datlechin Nov 25, 2026
1f95b43
docs(core): ADR 0056 r5 and 0051, 0054 amendments for G0 round 4 (#4512)
datlechin Nov 25, 2026
d881b57
docs(core): ADR 0056 r6 and 0051, 0054 amendments for G0 round 5 (#4513)
datlechin Nov 25, 2026
9072f9e
docs(core): ADR 0056 r7 and 0051, 0054 amendments for G0 round 6 (#4514)
datlechin Nov 25, 2026
e56ddf6
docs(core): ADR 0056 r8 and 0051, 0054 amendments for G0 round 7 (#4515)
datlechin Nov 25, 2026
f8e4ec2
fix(ios): keep plugin enum labels and always identities, and name an …
mvanhorn Nov 25, 2026
5402042
docs(core): accept ADRs 0051, 0052, 0054 and 0056 after G0 (#4517)
datlechin Nov 25, 2026
f5e5ea6
refactor(core): move the generated /v2 client into tablepro-cloud-api…
datlechin Nov 25, 2026
e0f17c7
feat(onboarding): setup guide, import hand-off and shortcut presets o…
datlechin Nov 25, 2026
20eab6b
feat(ios): sign in to a TablePro account through the shared core (#4492)
datlechin Nov 25, 2026
fdc66a8
feat(core): tablepro-records crate for synced kinds (#4518)
datlechin Nov 25, 2026
79e19fc
feat(core): tablepro-keys crate for the end-to-end design (#4519)
datlechin Nov 25, 2026
3dfce83
feat(core): store models, change journal and store generation (#4560)
datlechin Nov 25, 2026
fcb8da7
docs(core): ADR 0059, key errors name the expected signer and two lib…
datlechin Nov 25, 2026
01be1a3
docs(core): ADR 0060, the change journal names the records each write…
datlechin Nov 25, 2026
052faa7
docs(core): ADR 0061, the records crate settles six record rules (#4569)
datlechin Nov 25, 2026
743a2e0
docs(core): ADR 0062, a stopped scope records why it stopped (#4574)
datlechin Nov 25, 2026
5edaa79
test(ci): iOS runs on the shortcut presets now that it links the core…
datlechin Nov 26, 2026
018f999
docs(core): ADR 0064, a team restart waits for a word comparison, and…
datlechin Nov 26, 2026
e0cbe8e
docs(core): ADR 0063, the macOS app holds its results in the core bef…
datlechin Nov 26, 2026
295f67b
perf(editor): redraw only the lines a caret move or edit changes (#4570)
datlechin Nov 26, 2026
f8cacd7
perf(editor): parse edits off the main thread without copying the doc…
datlechin Nov 26, 2026
9221796
perf(autocomplete): size the completion popup before showing it and u…
datlechin Nov 26, 2026
594d9f7
docs(core): ADR 0065 and 0066, the WAL timeline check, refused change…
datlechin Nov 26, 2026
08bdd75
fix(core-storage): copy history.db into a name that does not exist ye…
datlechin Nov 26, 2026
3968cbd
fix(core): G1 round 1 fixes for tablepro-keys vectors and hardening (…
datlechin Nov 26, 2026
b055e28
feat(core): UUID record ids for synced kinds (#4587)
datlechin Nov 26, 2026
ba7b463
feat(core): sync crate contracts, FFI sync surface and fakes (#4572)
datlechin Nov 26, 2026
25b1d50
feat(core): store parity for the Mac library (ids, icons, SSH/TLS fie…
datlechin Nov 26, 2026
68b47a8
perf(import): read transaction state only when it can move, and trans…
datlechin Nov 26, 2026
4e39c02
feat(ios): connection library on the core store models (#4608)
datlechin Nov 26, 2026
b40e760
perf(export): start an export from the catalog's row estimate, not an…
datlechin Nov 26, 2026
0ddc1f4
perf(export): read a dump's table DDL once per schema (#4592)
datlechin Nov 26, 2026
baf645f
perf(connections): read the catalog side kinds in one round trip per …
datlechin Nov 26, 2026
4643c81
perf(editor): bound the memory each document's undo history holds (#4…
datlechin Nov 26, 2026
b2791c6
perf(editor): answer attributedString() with the text storage (#4562)
datlechin Nov 26, 2026
c2524df
perf(connections): reconnect when the network returns and ping less w…
datlechin Nov 26, 2026
d1e2db4
feat(macos): saved queries and history on the core stores (#4611)
datlechin Nov 26, 2026
9c5bfa3
perf(autocomplete): run completion requests off the main thread with …
datlechin Nov 26, 2026
77cff41
perf(redis): page keys from a saved scan cursor and send cluster pipe…
datlechin Nov 26, 2026
9df1cb2
fix(core): replace_library refuses a file that changed since it was r…
datlechin Nov 26, 2026
7b91fec
perf(ssh): share one session per route, use the probe channel, keep l…
datlechin Nov 26, 2026
3552158
test(editor): queue each TreeSitter edit burst before any of it can p…
datlechin Nov 26, 2026
10857f3
chore(windows): add changelog.d and towncrier notes (#4612)
datlechin Nov 26, 2026
2e551d4
perf(export): stream gzip while writing a dump and while reading one …
datlechin Nov 26, 2026
62b1297
perf(drivers): decode ClickHouse and SQL Server cells without per-fie…
datlechin Nov 26, 2026
971456a
feat(core): re-vendor /v2 with sync and key operations, and RFC 9470 …
datlechin Nov 26, 2026
917c297
perf(editor): scan a large script's run controls off the main thread …
datlechin Nov 26, 2026
1f3363e
perf(sidebar): match ASCII names by bytes and filter each container o…
datlechin Nov 26, 2026
6400623
perf(connections): use the idle session for the first listing and rea…
datlechin Nov 26, 2026
32b4099
perf(idle): save tabs only after a change and let the app nap with a …
datlechin Nov 27, 2026
0a2120f
perf(connections): send session setup with the connect instead of in …
datlechin Nov 27, 2026
cc50546
perf(editor): keep each query tab's document when switching tabs (#4588)
datlechin Nov 27, 2026
8c47b6c
test(memory): pin that a closed tab lets go of its rows and its resul…
datlechin Nov 27, 2026
ee20f01
ci(ios): install the simulator runtime when the runner image lacks it…
datlechin Nov 27, 2026
2dc1d14
ci(linux): pull Docker Hub images through mirror.gcr.io instead of an…
datlechin Nov 27, 2026
fec5b18
test(core): let each step-up test permit release one sign-in page (#4…
datlechin Nov 27, 2026
422d6ac
test(ios): fail the sync merge save with a read-only folder, not a de…
datlechin Nov 27, 2026
22f3ad1
fix(core-postgres): read the catalogs of PostgreSQL 10 to 13 (#4613)
datlechin Nov 27, 2026
98f6883
test(windows): live-server tests for PostgreSQL (#4614)
datlechin Nov 27, 2026
4079a88
fix(plugin-oracle): follow TNS listener redirects (#4610)
datlechin Nov 27, 2026
20770d4
ci(deps): bump the actions group across 1 directory with 2 updates (#…
dependabot[bot] Nov 27, 2026
873fc11
perf(memory): build each result row at its exact size in every driver…
datlechin Nov 27, 2026
d465598
perf(results): run the adapter's side of every driver call off the ma…
datlechin Nov 27, 2026
f51edc1
perf(autocomplete): rank table names from a prebuilt index instead of…
datlechin Nov 27, 2026
e60d667
fix(ios): a library write after the core's file went missing writes i…
datlechin Nov 27, 2026
3fd812b
perf(data-grid): read large text, JSON and binary cells as a head and…
datlechin Nov 27, 2026
d42bb33
fix(results): check for Stop just before a user statement reaches the…
datlechin Nov 27, 2026
c5d735a
feat(connections): projects that keep one product's connections, quer…
datlechin Nov 27, 2026
bb6d4a3
perf(sqlite): run SQLite statements on their own thread, not Swift's …
datlechin Nov 27, 2026
7407caf
perf(postgresql): read rows in libpq chunks instead of one result per…
datlechin Nov 27, 2026
5b45237
perf(mongodb): read each document's BSON once with libbson's iterator…
datlechin Nov 27, 2026
f1dffe0
feat(core-ai): tool calling for both provider protocols (#4630)
datlechin Nov 27, 2026
0404813
feat(windows): per-shortcut rebinding with a recorder (#4627)
datlechin Nov 27, 2026
cb48f3e
feat(windows): command palette / quick switcher (#4628)
datlechin Nov 27, 2026
f0fc0b5
feat(core): query-plan model, parsers and FFI (#4622)
datlechin Nov 27, 2026
e753de7
feat(core): SSH and credential profiles go through the checked librar…
datlechin Nov 27, 2026
67d604f
fix(linux): read the assistant message text through ChatMessage::text…
datlechin Nov 27, 2026
065acfd
perf(paging): seek on the primary key for next, previous and last pag…
datlechin Nov 27, 2026
90fe85f
fix(plugin-oracle): load the sidebar, long values and CLOBs on Oracle…
datlechin Nov 27, 2026
8af8705
fix(theme): stop a themed window covering the sidebar in full screen …
datlechin Nov 27, 2026
03d311e
fix(theme): make selections visible in every built-in theme (#4636)
datlechin Nov 27, 2026
98bb0b7
feat(core): end-to-end sync engine, accounts and keys (ADR 0044, 0056…
datlechin Nov 27, 2026
dc15243
fix(windows): make the command palette's commit event args a class (#…
datlechin Nov 27, 2026
ddafb12
test(core-storage): the report test builds its profile without serde_…
datlechin Nov 27, 2026
806d4c9
fix(windows): mark ShortcutRecorderButton partial for the AOT publish…
datlechin Nov 27, 2026
8271f51
fix(core-sync): a reopened service waits for its state file, and key …
datlechin Nov 27, 2026
e50a954
docs(core): ADR 0068 moves the pending-edit tracker and undo to the c…
datlechin Nov 27, 2026
051bb76
feat(core): sync connection projects (#4642)
datlechin Nov 27, 2026
2cce543
feat(core): the host peeks and acknowledges the library writes the co…
datlechin Nov 27, 2026
f28a8b6
feat(core): Team Library connections cross as library records, and ev…
datlechin Nov 27, 2026
ec95fcc
docs(core): ADRs 0069 to 0075 settle the full-sync milestone's ruling…
datlechin Nov 28, 2026
6bedf84
fix(macos): stop typing in the connection form's Tags field from cras…
datlechin Nov 28, 2026
ea66de3
fix(macos): open row context menus from VoiceOver and the keyboard (#…
datlechin Nov 28, 2026
4d4925a
feat(core-sync): sync passwords end to end as personal envelopes (#4665)
datlechin Nov 28, 2026
bed162f
fix(windows): run the shortcuts UI test serially and scroll to its ca…
datlechin Nov 28, 2026
c89f096
feat(core): grid copy and display text into the core (C-11) (#4653)
datlechin Nov 28, 2026
eeff06a
feat(windows): agent mode for the AI assistant (1b, 1c, 2) (#4657)
datlechin Nov 28, 2026
0a7066e
fix(core): no state transaction held across a nested begin or a netwo…
datlechin Nov 28, 2026
a262573
feat(core): table structure/DDL and SQL dump/import through the FFI (…
datlechin Nov 28, 2026
d8e4772
fix(core): list and decide sync approvals per record, show them in th…
datlechin Nov 28, 2026
d970079
fix(macos): build the menu anchor test's selection without the reduce…
datlechin Nov 28, 2026
6afee86
feat(core): script runner with a batch error policy into the core (C-…
datlechin Nov 28, 2026
bb41eb8
fix(linux): drop the icu deps the app no longer uses (#4670)
datlechin Nov 28, 2026
4a57f48
feat(core): move the pending-edit tracker and undo to the core, keyed…
datlechin Nov 28, 2026
1b5d480
fix(core): route a personal approval to the engine that listed it (#4…
datlechin Nov 28, 2026
38ea5cc
fix(core-sync): a refused envelope waits for its record, never as a r…
datlechin Nov 28, 2026
bfc26fc
fix(core-sync): the app's synced secrets host takes every kind it nam…
datlechin Nov 28, 2026
5a8deb8
fix(windows): compare stored shortcut values in the shortcuts UI test…
datlechin Nov 28, 2026
3c7e87a
fix(core-sync): the engine opens with the server out of reach and kee…
datlechin Nov 28, 2026
8583a18
fix(core): settle SSH profile names by lowest id, as credential profi…
datlechin Nov 28, 2026
4b0e421
fix(core): a log sink set from any thread never turns tracing off for…
datlechin Nov 28, 2026
97e2b02
test(windows): expect the integer rendering for a toggled boolean cel…
datlechin Nov 28, 2026
ca28319
fix(core): name signed-out key devices and log a public code with eve…
datlechin Nov 28, 2026
7cb317c
test(core): name the captured log line type in the log code tests (#4…
datlechin Nov 28, 2026
dc43cf4
test(core): the project import fakes return the credential write resu…
datlechin Nov 28, 2026
f9adcff
feat(core-sync): team connection secrets as team envelopes (#4682)
datlechin Nov 28, 2026
9ebc4f0
test(ios): lock the folder a failing sync merge save writes to, since…
datlechin Nov 28, 2026
10a30d0
fix(core): a Team Library copy carries no device credential path, and…
datlechin Nov 28, 2026
b85cf95
fix(macos): a Team Library or linked-folder row asks before it uses t…
datlechin Nov 28, 2026
07a3028
feat(windows): TablePro Sync settings, status and end-to-end encrypti…
datlechin Nov 28, 2026
99b8ec6
fix(core): a run's times cross in microseconds, so a run under a mill…
datlechin Nov 28, 2026
6d09ec8
fix(core-sync): a server that never answers is out of reach in second…
datlechin Nov 28, 2026
61457a0
fix(windows): passwords sync under TablePro Sync by default (#4689)
datlechin Nov 28, 2026
ce1706f
fix(macos): start a new folder's rename and keep a rename across a re…
datlechin Nov 28, 2026
1d3292c
fix(macos): keep a rename's caret and selection across a Favorites re…
datlechin Nov 28, 2026
018bb66
test(macos): the history downgrade probe checks the stores 0.88.0 rea…
datlechin Nov 28, 2026
d02dfdb
fix(windows): settings cards set Content only when there is one (#4693)
datlechin Nov 28, 2026
c8beb2d
fix(macos): explain a feature a company license leaves out instead of…
datlechin Nov 28, 2026
6876e08
ci(ios): boot an iPhone on the selected Xcode's simulator runtime and…
datlechin Nov 28, 2026
bebe73c
fix(macos): a file row's sign-in question names the file it opens on …
datlechin Nov 28, 2026
3bb881e
build(linux): drop indexmap from the app, unused since pending edits …
datlechin Nov 28, 2026
39682c2
feat(macos): TablePro Sync on the core, with keys, approvals, passwor…
datlechin Nov 28, 2026
b25a198
fix(sync): show the Passwords switch off while the server does not sy…
datlechin Nov 28, 2026
7b99547
docs(sync): changelog fragments for the Passwords switch fix (#4700)
datlechin Nov 28, 2026
05f8078
ci(macos): give macOS Tests 150 minutes, since a cold Rust cache push…
datlechin Nov 28, 2026
e2514e4
fix(core-sync): a key rotation never keeps a key device no device row…
datlechin Nov 28, 2026
600f6c8
fix(core-sync): split the replace keep list out of complete_replace t…
datlechin Nov 28, 2026
4e98fe6
fix(sync): Keep Theirs keeps a team connection's password, and an edi…
datlechin Nov 28, 2026
5a7de60
fix(sync): a device signed in again after its removal takes over its …
datlechin Nov 28, 2026
9a5de7a
chore(release): move release/0.89 to main 5a7de60542 for v0.89.0-beta.2
datlechin Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions apple/TablePro/Core/Services/TeamLibrary/TeamLibrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,30 +336,36 @@ internal final class TeamLibrary: ObservableObject {
// MARK: - Sign Out

// The edits Sign Out lists, read from the engine whatever shows, since a lost team_library hides the library but
// keeps its edits. Nil when they could not be read.
func unsentChanges() async -> [String]? {
guard let owner else { return nil }
// keeps its edits. The failure says why they could not be read.
func unsentChanges() async -> Result<[String], TeamLibraryFailure> {
guard let owner else { return .failure(.unavailable) }
do {
return try await source.engine().unsentTeamEdits(expectedOwner: owner).map(Self.name(of:))
return .success(try await source.engine().unsentTeamEdits(expectedOwner: owner).map(Self.name(of:)))
} catch {
Self.logger.error("Listing the unsent Team Library edits failed: \(error.publicLogShape, privacy: .public)")
return nil
return .failure(TeamLibraryFailure(error))
}
}

// Upload: one pass now. What the team has still not taken comes back, with why; nil when it could not be read.
func upload() async -> (unsent: [String]?, failure: TeamLibraryFailure?) {
// Upload: one pass now. What the team has still not taken comes back, with why.
func upload() async -> (unsent: Result<[String], TeamLibraryFailure>, failure: TeamLibraryFailure?) {
var failure: TeamLibraryFailure?
do {
try await source.engine().syncNow(why: .person)
} catch {
failure = TeamLibraryFailure(error)
}
await refresh()
guard let left = await unsentChanges() else { return (nil, failure ?? .unavailable) }
guard !left.isEmpty else { return ([], nil) }
let left: [String]
switch await unsentChanges() {
case .success(let listed):
left = listed
case .failure(let listing):
return (.failure(listing), failure ?? listing)
}
guard !left.isEmpty else { return (.success([]), nil) }
let problem = lastStatuses.lazy.compactMap(\.problem).first.map(TeamLibraryFailure.init(code:))
return (left, failure ?? problem ?? .offline)
return (.success(left), failure ?? problem ?? .offline)
}

// The sign-out of `session`, then all of the account's Team Library data, verified gone: the engine's, through the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ internal enum TeamLibraryFailure: Error, Equatable, Sendable {
case refused
// The last account's Team Library data is not deleted yet, so nothing of it is read or sent.
case deletePending
// This Mac's sync state for the account can't be opened, so nothing of it can be read or sent.
case stateUnreadable
case unavailable

// The engine's code for a pass, a publish or a refused edit (core ADR 0051, Whole-request refusals).
Expand All @@ -44,6 +46,8 @@ internal enum TeamLibraryFailure: Error, Equatable, Sendable {
self = .deletePending
case "sync.unimplemented", "sync.not_allowed":
self = .unavailable
case "sync.state.wrong_identity", "sync.state.integrity":
self = .stateUnreadable
default:
self = .refused
}
Expand All @@ -68,6 +72,7 @@ internal enum TeamLibraryFailure: Error, Equatable, Sendable {
case .licenseExpired: "licenseExpired"
case .refused: "refused"
case .deletePending: "deletePending"
case .stateUnreadable: "stateUnreadable"
case .unavailable: "unavailable"
}
}
Expand All @@ -77,7 +82,8 @@ internal enum TeamLibraryFailure: Error, Equatable, Sendable {
switch self {
case .offline, .rateLimited, .server:
true
case .signedOut, .unreadable, .writeForbidden, .licenseExpired, .refused, .deletePending, .unavailable:
case .signedOut, .unreadable, .writeForbidden, .licenseExpired, .refused, .deletePending, .stateUnreadable,
.unavailable:
false
}
}
Expand Down
9 changes: 9 additions & 0 deletions apple/TablePro/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -207869,6 +207869,12 @@
},
"TablePro couldn't reach the team library." : {

},
"TablePro couldn't read this Mac's sync data for the account, so no Team Library change can be uploaded. Signing out discards any there are." : {

},
"TablePro couldn't read this Mac's sync data for the account." : {

},
"TablePro couldn't save a token for this client to the Keychain, so the client wasn't paired. Try pairing again." : {

Expand Down Expand Up @@ -229689,6 +229695,9 @@
},
"This Mac's keys can't be checked" : {

},
"this Mac's sync data couldn't be read" : {

},
"This machine is not activated for this license." : {
"localizations" : {
Expand Down
34 changes: 28 additions & 6 deletions apple/TablePro/Views/Settings/Account/AccountSettingsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,41 @@ internal struct AccountActionFailure: Equatable, Identifiable {

internal struct AccountSignOutConfirmation: Equatable {
// The Team Library edits the team has not taken yet, read just before the question; nil when they could not be
// read, so the question still offers Upload.
// read, so the question still offers Upload unless the reason rules every upload out.
let teamChanges: [String]?
var uploadFailure: TeamLibraryFailure?
let removesOfflineFile: Bool
// Sign Out erases this Mac's end-to-end keys, so it needs approval again after the next sign-in.
var erasesKeys = false
// Why `teamChanges` could not be read.
var listFailure: TeamLibraryFailure?

var asksAboutTeamChanges: Bool {
// Edits that could not be read may still be there.
private var mayHoldTeamChanges: Bool {
teamChanges.map { !$0.isEmpty } ?? true
}

// With this Mac's sync data unreadable no upload can run, so there is nothing to ask.
private var uploadIsPossible: Bool {
teamChanges != nil || listFailure != .stateUnreadable
}

var asksAboutTeamChanges: Bool {
mayHoldTeamChanges && uploadIsPossible
}

var discardsSomething: Bool {
asksAboutTeamChanges || removesOfflineFile || erasesKeys
mayHoldTeamChanges || removesOfflineFile || erasesKeys
}

var message: String {
var sentences = [String(localized: "Paid features stop on this Mac until you sign in again.")]
if let teamChanges, !teamChanges.isEmpty {
sentences.append(TeamLibraryUnsentChanges.message(teamChanges, failure: uploadFailure))
} else if teamChanges == nil, !uploadIsPossible {
sentences.append(String(
localized: "TablePro couldn't read this Mac's sync data for the account, so no Team Library change can be uploaded. Signing out discards any there are."
))
} else if teamChanges == nil {
if let uploadFailure {
sentences.append(String(
Expand Down Expand Up @@ -269,10 +285,11 @@ internal final class AccountSettingsModel: ObservableObject {
while isCurrent() {
asksSignOut = true
let answer = await askSignOut(AccountSignOutConfirmation(
teamChanges: changes,
teamChanges: try? changes.get(),
uploadFailure: failure,
removesOfflineFile: services.access.state.entitlement?.isOffline == true,
erasesKeys: erasesKeys
erasesKeys: erasesKeys,
listFailure: Self.failure(of: changes)
))
asksSignOut = false
guard isCurrent() else { return }
Expand All @@ -284,14 +301,19 @@ internal final class AccountSettingsModel: ObservableObject {
return
case .upload:
(changes, failure) = await teamLibrary.upload()
if changes?.isEmpty == true, isCurrent() {
if (try? changes.get())?.isEmpty == true, isCurrent() {
await finishSignOut(teamLibrary, session: session, isCurrent: isCurrent)
return
}
}
}
}

private static func failure(of listed: Result<[String], TeamLibraryFailure>) -> TeamLibraryFailure? {
guard case .failure(let failure) = listed else { return nil }
return failure
}

private func finishSignOut(
_ teamLibrary: TeamLibrary,
session: String?,
Expand Down
2 changes: 2 additions & 0 deletions apple/TablePro/Views/TeamLibrary/TeamLibraryPublishing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ internal enum TeamLibraryPublishing {
return String(localized: "The team library refused the change. It may be too large or hold a field the library never stores.")
case .deletePending:
return String(localized: "TablePro is still deleting the Team Library data of the last account on this Mac. Team Library stays off until it is gone.")
case .stateUnreadable:
return String(localized: "TablePro couldn't read this Mac's sync data for the account.")
case .unavailable:
return String(localized: "Team Library isn't available on this Mac right now.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ internal enum TeamLibrarySyncDescription {
switch failure {
case .offline, .rateLimited, .server:
return String(format: String(localized: "%@ TablePro tries again shortly."), TeamLibraryPublishing.failureText(failure))
case .signedOut, .unreadable, .writeForbidden, .licenseExpired, .refused, .deletePending, .unavailable:
case .signedOut, .unreadable, .writeForbidden, .licenseExpired, .refused, .deletePending, .stateUnreadable,
.unavailable:
return TeamLibraryPublishing.failureText(failure)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal enum TeamLibraryUnsentChanges {
why = String(localized: "no seat in the team")
case .offline, .rateLimited, .server:
why = String(localized: "the upload did not go through")
case .stateUnreadable:
why = String(localized: "this Mac's sync data couldn't be read")
default:
why = String(localized: "the team library refused it")
}
Expand Down
6 changes: 3 additions & 3 deletions apple/TableProTests/TeamLibrary/TeamLibraryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ struct TeamLibraryTests {
let answer = await fixture.library.upload()

#expect(engine.passes == 1)
#expect(answer.unsent == [TeamLibraryUnsentChanges.refused("Huge", because: .refused)])
#expect((try? answer.unsent.get()) == [TeamLibraryUnsentChanges.refused("Huge", because: .refused)])
#expect(answer.failure != nil)
}

Expand All @@ -398,10 +398,10 @@ struct TeamLibraryTests {
_ = await fixture.account.services.refreshEntitlement()
try await waitUntil { fixture.library.writableTeams.isEmpty }

#expect(await fixture.library.unsentChanges() == ["Orders"])
#expect((try? await fixture.library.unsentChanges().get()) == ["Orders"])

engine.failUnsentReads(with: TeamConflictFixture.failure("sync.state.io"))
#expect(await fixture.library.unsentChanges() == nil)
#expect((try? await fixture.library.unsentChanges().get()) == nil)
}

@Test("Sign Out deletes the account's Team Library data once signed out, through the service of that sign-in")
Expand Down
24 changes: 24 additions & 0 deletions apple/TableProTests/Views/Settings/AccountSettingsModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,30 @@ struct AccountSettingsModelTests {
#expect(fixture.account.services.isSignedIn)
}

@Test("Sync data this Mac can't read offers no Upload and never says an upload failed (E2E F36)")
func unreadableSyncDataOffersNoUpload() async throws {
let engine = FakeTeamLibraryEngine()
engine.failUnsentReads(with: TeamConflictFixture.failure("sync.state.wrong_identity"))
let fixture = try await TeamLibraryFixture(engine: engine)
try await fixture.start()
let prompt = ScriptedSignOutPrompt([.discard])
let model = AccountSettingsModel(services: fixture.account.services, teamLibrary: { fixture.library }, keys: .untouched, askSignOut: prompt.ask)

await model.signOut()

let asked = try #require(prompt.asked.first)
#expect(prompt.asked.count == 1)
#expect(asked.teamChanges == nil)
#expect(asked.listFailure == .stateUnreadable)
#expect(!asked.asksAboutTeamChanges)
#expect(asked.discardsSomething)
#expect(asked.message.contains(String(localized: "TablePro couldn't read this Mac's sync data for the account, so no Team Library change can be uploaded. Signing out discards any there are.")))
#expect(!asked.message.contains(String(localized: "The upload did not finish. %@").replacingOccurrences(of: " %@", with: "")))
#expect(!asked.message.contains(String(localized: "TablePro couldn't list the Team Library changes not uploaded yet. Discarding loses any there are.")))
#expect(engine.passes == 0)
#expect(!fixture.account.services.isSignedIn)
}

@Test("A delete that fails after Sign Out says the data is still on this Mac")
func failedDeleteIsReported() async throws {
let engine = FakeTeamLibraryEngine()
Expand Down
1 change: 1 addition & 0 deletions apple/changelog.d/4708.fixed.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sign Out said an upload failed when it couldn't read this Mac's Team Library changes.
1 change: 1 addition & 0 deletions apple/changelog.d/4708.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A Mac signed in again after its removal from the account could no longer sync, set up encryption or read Team Library.
10 changes: 8 additions & 2 deletions core/crates/ffi/src/sync/engines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl ServiceEngine {
// Called on the runtime: it opens the sign-in's state file, and the scheduler's task needs the runtime. A sign-in
// to another account or server than `last` named counts what that file held unsent, for the Move my data or Start
// empty prompt, and lets the file go, as iCloud does with the last account's file (0054, Another account or
// server).
// server). A new row of the same account takes over the file its last row left (0081).
pub(crate) async fn start(
hosts: &Hosts,
link: ServiceLink,
Expand All @@ -302,7 +302,13 @@ impl ServiceEngine {
account: link.account,
device_row: link.device_row.clone(),
};
let state = hosts.files.open(identity).await?;
let state = tablepro_sync::keys::open_service_state(
hosts.files.as_ref(),
identity,
&hosts.device_store,
&link.transport,
)
.await?;
let previous = last.filter(|previous| another_sign_in(previous, &link.origin, link.account));
let follows = match &previous {
Some(previous) => {
Expand Down
67 changes: 67 additions & 0 deletions core/crates/ffi/src/sync/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,73 @@ async fn a_choice_on_a_restored_wait_keeps_the_engine_s_own_file() {
assert_eq!(restored.service.service_account(), kept);
}

// E2E F36: the server removed this Mac's row, the Mac signed itself out, and its next sign-in to the same account got a
// new row. The state file still named the removed row, so every call answered `sync.state.wrong_identity`. The start
// now takes the file over: the Mac syncs again and asks for approval as a new device, and the removed row's keys are
// gone.
#[tokio::test]
async fn a_sign_in_on_a_new_row_after_a_removal_starts_as_a_new_device() {
use tablepro_sync::api::device_store::DeviceItem;

let tasks = runtime::tasks().unwrap();
let server = FakeServer::new();
let account = AccountId(Uuid::new_v4());
server.add_team(TeamId(Uuid::new_v4()), &[(account, Role::Owner)]);
let dir = tempfile::tempdir().unwrap();
let device_store = Arc::new(FakeDeviceStore::new());
let files: Arc<dyn StateFiles> = Arc::new(SqliteStateFiles::at(dir.path().join("sync"), device_store.clone()));
let removed = link(&server, account);
let removed_keys = DeviceItem::DeviceKeys {
origin: removed.origin.clone(),
account,
device_row: removed.device_row.clone(),
};
let first = open(
&tasks,
on_one_mac(&files, &device_store, removed.clone(), SyncProviderTag::Off),
)
.await;
first_upload(&first.service).await;
let kept = first.service.service_account();
drop(first);
server.remove_row(&removed.device_row);
let held_before = device_store.holds(&removed_keys);

let again = open(&tasks, |parts| OpenParts {
config: SyncConfig {
service_account: kept.clone(),
..config(SyncProviderTag::TableproSync)
},
files: Some(Arc::clone(&files)),
device_store: Some(device_store.clone() as Arc<dyn tablepro_sync::api::HostDeviceStore>),
link: Ok(second_link(&server, account)),
..parts
})
.await;
let passed = again.service.sync_now(PassReasonTag::Person).await;
let mut keys = again.service.key_state().await;
for _ in 0..100 {
if matches!(keys, Ok(KeyStateInfo::NeedsApproval { .. })) {
break;
}
tokio::time::sleep(Duration::from_millis(50)).await;
keys = again.service.key_state().await;
}
let approvals = again.service.approvals().await;

assert!(held_before);
assert!(passed.is_ok(), "{:?}", passed.map_err(|error| code(&error).to_owned()));
assert!(
approvals.is_ok(),
"{:?}",
approvals.map_err(|error| code(&error).to_owned())
);
let keys = keys.map_err(|error| code(&error).to_owned()).unwrap();
assert!(matches!(keys, KeyStateInfo::NeedsApproval { .. }), "{keys:?}");
assert!(!device_store.holds(&removed_keys));
assert_ne!(again.service.service_account(), kept);
}

// A sign-in to another account than the one whose file this device used last pushes nothing personal until the person
// picks Move my data or Start empty; a new sign-in of the same account is no switch (core ADR 0054, Another account or
// server).
Expand Down
Loading
Loading