Repository navigation
fix: align Apple clients with the current server contract - #13
Merged
Merged
Conversation
The server dropped inline base64 attachments. Messages now carry `files`, IDs from a file library that clients upload raw bytes into first, and transcripts list file metadata, including markers for deleted files, instead of `attachments`. The group attachment route by entry and index is gone, and so is push presence. Update the contract copy to server main. `contract.py` now points the event schemas' `$defs` at the shared OpenAPI components after checking they match, and Generated is regenerated from it. Bot and group sends upload each attachment before sending its file ID, keeping optimistic rows, drafts, reply targets, and local image previews. Each pending send keeps the IDs it uploaded, so a retry under the same request ID uploads only what an earlier attempt missed. A server rejection for a deleted or missing library file drops those IDs, and the next retry uploads again from the retained bytes. Uploads stop when the connection changes and never move between chats or connections. Transcript file IDs drive downloads and the image cache, scoped by chat and cleared on a new connection. Previews follow the MIME type. A file deleted from its library shows a placeholder in every message that lists it, is never fetched, and a download that finishes after the deletion is dropped. Desktop screenshots still load by entry and index. To compile against the new contract, `pushPresence` and its iOS call are removed, leaving presence unreported until chat attention replaces it, and job history reads the transcript page inside the new history response. Test fixtures gain the newly required `replyReferences`, `working`, `items`, and schedule label fields.
…projections The server now projects what the apps used to compute locally, and the Android client already reads these projections. Read them here too and delete the local logic they replace. Automations: `Schedule` carries the server's `description`, `timing`, and `nextRunLabel`, which the list, the bot details, and the rows show. The local cron phrases, next-run labels, cron parser, and next-run calculation are gone. The editor asks `POST /v1/schedules/preview` for the draft's trigger. A request waits 250 ms for the trigger to settle, and SwiftUI cancels it when the trigger changes. An answer for an older trigger, another draft, or another connection is dropped. A preview problem disables Save. If no preview is available, because it is still loading or the request failed, saving still works and the server checks the trigger. The draft therefore no longer checks the trigger or the time zone itself. The recurrence builder stays because it writes the cron. Optimistic rows read "Saving…" until the server answers, and a paused row says so at once. The list rereads every minute while it is shown, as on Android, so the relative next-run labels stay current. Reasoning: the composer control and the bot form use `POST /v1/reasoning/preview` for the offered levels, their labels, and the level a turn runs at. These replace the local clamping and the reads of the model list. Previews are cached per connection. They load after the same short wait, and a cancelled or failed request shows no control. A level that the server already offered for the same model shows as itself until its own preview arrives, so picking a level doesn't hide the control. Chat: replies show the server's `presentation` text and citations. The local citation parsing and per-turn source collection are gone, and so are group `sources`. `ChatSnapshot.working` replaces inferring the work state from the transcript. `isRunning` follows it, as on Android. `Message.blocks` is the generated `TranscriptBlock` array, which HTTP and the event stream share. Jobs: history pages carry the server's task, reply, and step items. They replace deriving steps from the transcript, and their labels and icons come from the server. The server attaches a step's result to the page that holds its call. So a refresh rereads older pages for loaded steps that are still unfinished, as Android does. Transcript downloads still use the raw messages.
The server now suppresses a push account-wide when any fresh view shows
the reply's chat, and skips one the owner has already seen. Pass 1
removed the installation-linked presence endpoint, so neither app told
the server anything. Port the Android design to both apps.
apfelkern gains ChatAttention, a testable controller independent of
push registration and notification permission. It reports one view's
bot or group chat through PUT /v1/chat-attention/views/{viewId} only
while the app or window is active, the route shows that chat, and the
chat's view is mounted. Reports go out one at a time with the newest
state, so a pending heartbeat refresh collapses and can't land after a
clear; it refreshes every 30 seconds. Each connection gets a new view
ID and the old view clears through the old session, and disconnect
clears within two seconds before sign-out revokes the session.
Seen acknowledgements use the server's replyReferences, now kept on
Message from HTTP and both event streams. A surface counts only when it
is the exact one referenced, ready, and inside the uncovered part of
the chat's scroll view while the chat has attention: nonempty reply
text without its citations, or a held action, bot request, call
request, or credential or login card whose board has the server's
state. Fetched or streamed history never counts on its own. Batches of
up to 100 per chat keep their chat across navigation, retry with
bounded backoff while the connection lasts, split a refused batch so
only refused events are dropped, and stop when the session ends.
A live reply for the chat on screen reloads its newest page, so
references that trail the event arrive. The reload is dropped when a
snapshot, a newer reload, a new selection, or a new connection lands
first, and the merge keeps drafts and sends in flight.
Both apps report: macOS while the main window appears active, since a
Mac showing the chat should stop the iPhone's push, and iOS while its
scene is active, with a short background grace so the clear can land.
Each app has a single chat window or scene, so one view per process.
The iOS push controller keeps its foreground registration retry as
setForeground(_:); push registration, notification settings, local
delivery, payloads, and tap routing are unchanged.
Overlapping history loads (the watch poll, a status change, opening the job) applied in the order they finished, and mergeJobItems keeps existing items only up to the arriving page's first ID, so an older load that landed late cut items a newer one had added and could put back an unfinished copy of a finished step. Only the newest load now applies. A failed request for an older page while re-reading unfinished steps also threw away the newest page and showed an error. The search now stops there and keeps the steps it found.
Allow saving an existing automation when its trigger is unchanged, keeping its original timestamp so completed runs stay completed. Share the preview gate with both apps. Skip redundant polling history loads while the latest load is pending, without blocking job status refreshes or explicit newer loads. Add regression coverage for both failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align the macOS and iOS clients with the current
botcontract (servermainat 49f32d1), matching crumble-project/android#17. Copybot/openapiintoapfelkern/Contractand regenerate the client.Why
The server no longer accepts inline attachments and has removed the group attachment route and installation-linked push presence. It suppresses pushes account-wide when a matching chat is active or its reply has been seen. The native clients need to report that attention and consume the server projections instead of duplicating their interpretation.
Evidence
python3 apfelkern/scripts/contract.py --check: generated output matches byte-for-byte.swift buildandswift test --no-parallel: 329 shared tests and 5 BotAvatar tests passed.swift test: 114 tests passed.scripts/check-app-bundle.shpassed.ef59bdb. The existingaRefreshInFlightCollapsesBehindTheClearAndTheHeartbeatStopsWithIttest failed once in the push run and passed on one rerun; the simultaneous pull-request run and a focused local run also passed. Its timing sensitivity remains unresolved.The standard iOS build and unit-test scripts failed locally with missing-type diagnostics despite those types being present in source. Equivalent Xcode commands passed using fresh derived data at
ios/build/verify-pr13; existing build data was not deleted. The cause of the default-output failures remains unverified.Not verified against a live server or interactively: viewport geometry under real toolbars, keyboard, and covering sheets; macOS
appearsActive; and account-wide suppression of an iPhone push while a Mac shows the chat. A potential sheet-occlusion issue remains unconfirmed. UI tests were not run.Risk & Rollback
Reversibility: Reversible, with no persisted-data migration. Reverting restores behavior that does not work with the current file and attention APIs. Accepted seen acknowledgements are not undone.
Blast Radius: Shared transport and models, both apps' bot and group chats, automation editors, reasoning controls, job history, iOS push presence, and macOS window lifecycle. Push registration, notification settings, payloads, and tap routing are unchanged.
Intentional differences from Android:
Clearing a view is best-effort and bounded to two seconds. A lost clear expires after the server's 120-second presence TTL. Uploads from failed sends can remain in the server Library.