Skip to content

iOS: Workspace Settings keep edits through a fold and save optimistically; cached workspace Git summaries - #928

Open
sambitcreate wants to merge 20 commits into
mainfrom
claude/ios-direction-phase0
Open

sambitcreate wants to merge 20 commits into
mainfrom
claude/ios-direction-phase0

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Problem

The new-direction iOS pass (Phase 0) found a set of rough edges across iOS, the server and Android:

  • Workspace Settings sometimes opened as a blank sheet.
  • An iPhone Duo fold, an iPad resize or a rename on the computer closed the sheet and dropped unsaved edits.
  • Save waited for the computer before anything changed.
  • Phones had no Git summary for a workspace without asking the computer to run Git on every list read.
  • The iOS demo had no Bot memory.
  • Android still said "Mac" where any computer is meant.
  • Some first-run and memory copy was inconsistent between clients.

Change

iOS: Workspace Settings

  • The shell owns the sheet through .sheet(item:) over an AidenWorkspaceSettingsDraft, so it always opens with its form.
  • A fold, a resize or a page rebuild keeps the sheet and its edits.
  • Fields you haven't touched follow the computer. An edited name, access level or memory switch stays, and the section footer says what the computer changed.
  • The sheet closes when:
    • the workspace is removed or archived;
    • the pairing lease changes (instanceId, deviceId or hostGeneration);
    • the default moves off its machine.
  • Save is optimistic. It closes the sheet at once and shows the edit straight away, as an overlay on what the computer last confirmed. Saves of one workspace go to the computer one at a time in the order they were made, each on the revision the one before it got back, and a list read in between never puts old values back. Only confirmed copies are saved on the phone. A refused save falls back to the confirmed copy with any newer edit still on top, and shows a quiet, dismissible note on the workspace and in its Settings, with an error haptic, instead of an alert. Remove waits for a save still on its way.

iOS: other fixes

  • The Bot composer names the Bot.
  • First-run copy uses sentence case.
  • Memory uses "Forget all".
  • The Usage cards lose their decorative hairline.
  • The demo serves Bot memory:
    • an edit changes only the entry it names;
    • a rewrite gets a new entry id;
    • a repeated idempotency key replays its answer.

Server: workspace Git summaries

  • Phones get each workspace's Git summary from a background cache, filled from cached git status.
  • The summary reader runs on its own GitService, with the cache's 15 s read deadline as its per-command budget.
  • Failures are kept per folder, so a root folder's failure never overwrites a shared repository entry.
  • A read past its deadline gives up its concurrency slot, at most eight at once. Past that, a stuck read keeps its slot until it ends.

Android

  • "Computer default", "Allowed on this computer" and the recording, task and agent notes say "computer" instead of "Mac".
  • The Simulators strings and bot_activity_computer still say "Mac" on purpose.

Docs

  • docs/aiden-remote-api-v1.md and docs/aiden-on-the-go-remote-access.md.
  • docs/plans/aiden-on-the-go-plan.md (the no-push follow-up), docs/plans/ios-iphone-duo-plan.md, and the docs/plans/README.md row, which now records iOS: iPhone Duo layout, fold continuity, ink accent and card lists #880 as shipped and this follow-up as in review.
  • ios/CHANGELOG.md and .memory/ios-new-direction-phase0.md.

Contracts: no Remote wire or protocol revision change.

Screenshots

Before: Workspace Settings could open blank.

After, iPhone: it opens with its form on the first open and on every later one.

After, iPhone Duo inner display (regular width):

After, iPad:

Bot composer placeholder and the Usage page in the demo:

No screenshot shows the "changed on your computer" footer notes, because no demo path triggers them. AidenAppShellTests covers them.

Scope

A follow-up to the iPhone Duo work in #880.

Verification

Each item below says what was run and what was seen.

iOS (own simulator and -derivedDataPath, Xcode 27.1):

  • AidenOwnerRoutingTests, AidenAppShellTests, AidenDemoHostsTests after review round 3: 234/234 passed. AidenShellUITests/testWorkspaceSettingsOpensWithItsFormEveryTime (now also checks Save closes the sheet) passed on the iPhone and the iPhone Duo simulators.
  • New tests cover:
    • queued saves landing in order, with revisions chained and a newer edit still shown while an older answer lands;
    • a stale list read not undoing a newer edit, and only confirmed copies being cached;
    • a refused save rolling back under a newer edit, keeping its notice, with no alert and an error haptic;
    • a save confirmed only by re-reading the list chaining the next save;
    • Remove waiting for a save on its way;
    • the access and memory footer notes.
  • Earlier full unit run: one failure in AidenOwnerRoutingTests.testASendCaughtBeforeItLeavesKeepsItsWords ("The send left first"). It passed on rerun. This existing test races on a single Task.yield and is not touched here; it is recorded as flaky.

Server:

  • npx tsx --test main/services/aiden-remote-workspace-git-cache.test.ts main/services/aiden-remote-workspaces.test.ts main/services/git.test.ts: 145/145 after the merge.
  • The new stuck-slot cap test fails when the cap is removed (mutation-checked).
  • Under very heavy machine load (load average about 850, from other agents' simulator builds), some existing git.test.ts push and timeout tests failed. A different one failed on each run: "freezes the reviewed push endpoint…", "reconciles a timeout after the exact branch ref…", "recognizes a candidate in branch ancestry…", "leaves the remaining-change count unknown…", "rechecks cancellation after post-push branch reads…" and "preserves an unknown push outcome…". They all pass when the file runs alone, and this PR doesn't touch those paths. They are recorded here as load-sensitive.
  • npx tsc --noEmit -p tsconfig.json: clean.
  • npm run test:ci-policy: 123/0.
  • check-ios-shipping-target: 14/0.

Android: gradle unit tests, 1397 passed. AidenModelPickerUiTest was updated for "Computer default".

Desktop E2E (Cua Space): tests/e2e/keep-going-goals.spec.ts:215 failed once and passed on rerun. It is recorded as flaky; this PR only changes copy that spec reads.

Known limits:

  • iPad resize test: testWorkspaceSettingsKeepTheirEditsWhenTheWindowChangesWidth skips after the edit, because windows don't resize on the local iPadOS 27.0 simulator. The hosted split/stack swap test in AidenAppShellTests covers the same continuity.
  • Duo closed posture: CoreSimulator has no fold API and Xcode 27.1 ships no Simulator.app, so the Duo was checked on its inner display at regular width only.

Review rounds:

  • Round 3 (this push): the save path became a serial queue per workspace with a confirmed baseline and an optimistic overlay, failures moved from an alert to an inline notice, footer attribution compares confirmed copies only, Remove waits for queued saves, and the git cache skips a folder whose read is still in flight. Both Pullfrog threads (git cache re-read, revision chaining after a reconciled save) are fixed and resolved.

Deferred follow-ups:

  • Push a fresh workspace Git summary to connected phones when it lands. Today phones see it on their next list read.
  • iPhone Duo Phase 4 poses.
  • One stuck filesystem read per folder can still hold a thread until it ends.
  • Workspace Settings Remove still waits for the computer before closing, because it is destructive and the computer may refuse a managed-worktree delete.
  • Other iOS screens outside this PR's scope still disable their controls while a change is in flight: Pairing, Scheduled Tasks, the workspace directory and the folder browser.

AI disclosure

An AI coding agent wrote this change under the owner's direction. The owner reviews it before merge.

Checklist

  • I tested these changes locally and reviewed the diff myself
  • Related docs / tests are updated where behavior, settings, or contracts changed
  • No unrelated refactors or changes are included

Workspace list, get, create and update now carry git {isRepo, branch?,
uncommitted?} for workspaces with a folder, read through the cached
GitService.info under one 1.5 s deadline. A failed or slow read leaves the
summary out and is aborted; no upstream, remote or path is projected and the
revision is unchanged. The desktop host and aiden serve are wired the same
way; the host feed stays Git-free and the API doc says so.
The cards keep their raised fill and card radius.
The button and confirm action read Forget all, the confirm title asks
"Forget everything {Bot} remembers?", a failure says "Memory wasn't
cleared. Please try again." and the unreadable-memory callout points at
Forget all. The action still clears both groups.
The sheet was driven by a Bool and a separate optional context; when the
Bool won the race the sheet rendered empty. One Identifiable value now
drives .sheet(item:), so the form always has its context. A UI test opens
the sheet twice and checks the form each time.
The demo Bot advertises bot-memory-v1, so it now answers GET
/bots/{botId}/memory with both groups (one entry near the 500-character
cap) and POST .../memory/edits with the cleared view; the demo keeps no
state. AidenDemoHostsTests loads the page and Forget all through the
real client. Android's Bot memory description and load-failure strings
no longer name a Mac.
The iOS Bot chat composer reads "Message {name}" when nothing holds it.
"Meet your first Bot", "Start chat" and "Create my own" now match the
desktop on iOS and Android. Copy only.
Workspace list, get and update now read Git summaries from a
stale-while-revalidate cache keyed by repository root. Reads run in the
background under a concurrency limit, one per root, each with its own
deadline, and back off after failures. Creating a workspace, the MCP
workspace list and chat start never touch Git. A read that fails gives
no git field rather than claiming the folder is not a repository, a
detached HEAD omits branch, and long branch names are cut between code
points. Desktop and the CLI server share the same wiring.
The Bot composer reads "Message {name}" on desktop and Android, as it
already does on iOS. Android says "your computer" wherever it meant the
paired computer, matching iOS; the Simulator strings, the shared activity
phase word and the mirrored desktop approval line keep "your Mac". The
Android memory load failure keeps a recovery hint, and the unreadable
memory callout reads "Choose Forget all to start {name}'s memory fresh."
on every client. Project memory notes now match the shipped copy.
Workspace Settings UI test launches like the rest of the shell suite and
keeps its screenshot through AidenStateMatrix.keepScreenshot, which the
Bot UX suite now uses too. The helper documents that TEST_RUNNER_AIDEN_SCREENSHOT_DIR
on xcodebuild reaches the runner as AIDEN_SCREENSHOT_DIR.
The lane stores the newest edit's Task, each edit checks cancellation
after waiting for the one before it, and an isolated deinit cancels the
lane.
Each demo Bot machine keeps its memory and applies a delete, rewrite or
Forget all with AidenBotMemory.applying, so other entries stay put, a
stale entry answers 404 memory_entry_not_found and every edit moves the
revision. Routes can now read the request body.

The demo responder is checked Sendable: one Mutex holds its routes,
holds, parked requests and logs, a parked request no longer keeps the
responder alive, and delays use Task.sleep instead of a dispatch queue.
The URL protocol's own state moves to a Mutex; it stays unchecked only
because Foundation's URLProtocol base is not Sendable.
A fold between the split and the stack rebuilds the workspace detail and
closes an open Workspace Settings sheet with its draft. The fix, shell-owned
presentation and draft, is listed in the Duo plan's remaining work. The
Phase 0 memory note now describes the stateful demo memory and the checked
Sendable responder.
The shell now owns the Workspace Settings sheet and its unsaved draft and
presents it above the split/stack switch, so folding an iPhone Duo,
resizing an iPad window, or the workspace page rebuilding on a rename no
longer closes the sheet or drops edits. A rename on the computer fills an
untouched name and keeps an edited one, showing the computer's name under
the field. The sheet closes when its workspace is removed or archived, its
machine's pairing changes, or its page leaves every tab.

Covered by shell-state unit tests, a hosted split/stack swap test, and an
iPad window-width UI test.
The Remote workspace Git summary reader runs on its own GitService with the
cache's read deadline as its per-command budget. A root folder's failure is
recorded per folder and no longer overwrites a shared repository entry. A read
past its deadline gives up its slot, at most eight at once; past that a stuck
read keeps its slot until it ends. Documents the no-push follow-up.
…o memory replay

Workspace Settings compares only the pairing lease, notes access and memory
changes made on the computer, and Save now closes the sheet at once: the edit
shows straight away, waits behind any change still on its way, and is put back
if the computer refuses it. Removes the unused onRemoved callback and the dead
memory-page deinit. The demo memory host gives a rewritten entry a new id and
replays an answer for a repeated idempotency key.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Two concurrency edge cases can discard a queued iOS edit or exceed the Git cache's stuck-read guarantee; both should be addressed before merging.

Reviewed changes — I reviewed the complete 96-file diff, with emphasis on the iOS optimistic mutation lane, shell-owned settings draft, Git summary cache, Remote projections, demo responder, native contract consumers, and behavioral coverage.

  • Workspace Settings continuity — The shell owns a lease-bound draft that survives split/stack rebuilds, follows host changes selectively, and dismisses when its workspace context disappears.
  • Optimistic workspace saves — Owner-context edits update the machine list immediately, queue behind in-flight mutations, reconcile failures, and bridge revisions across repeated saves.
  • Cached Git summaries — Desktop and CLI serve background stale-while-revalidate summaries with repository-root sharing, timeout abandonment, concurrency limits, folder-specific backoff, and MCP opt-out.
  • Demo and memory behavior — The synchronized iOS demo responder now handles request bodies and idempotency keys, serves mutable Bot memory, and the memory edit lane retains submitted work after navigation.
  • Cross-client polish — Desktop, iOS, and Android align Bot composer and memory copy; Android generalizes host wording; iOS updates the memory icon and Usage cards; docs and focused tests follow the behavior.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

…ilure notices

Workspace Settings saves now go through one serial lane per workspace:
edits show at once as an overlay on what the computer last confirmed,
are sent one at a time in the order made, chain each revision from this
phone's own answers (including a save confirmed only by a list re-read),
and a stale list never undoes a newer edit. Only confirmed copies are
persisted. A refused save falls back to the baseline under newer edits
and leaves a dismissible inline notice with an error haptic instead of
an alert. Remove waits for a save on its way. Footer attribution compares
confirmed copies only.

The git cache also skips a folder whose read is still in flight.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Removal is not fully serialized with the new save lane, so a save made while Remove is waiting can race the DELETE and surface a false failure.

Reviewed changes — I incrementally reviewed the new per-workspace save queue, confirmed-baseline overlay, failure notices, removal ordering, and the Git-cache follow-up since the prior Pullfrog review.

  • Queued workspace saves — Replaced global mutation waiting with a FIFO lane per pairing and workspace, coalesced compatible unsent edits, and chained both direct and reconciled revisions.
  • Confirmed optimistic state — Split host-confirmed workspaces from versioned optimistic edits, prevented stale list reads from restoring superseded revisions, and persisted only confirmed copies.
  • Failure and removal behavior — Added dismissible per-workspace failure notices, error haptics, rollback beneath newer edits, and a removal wait for queued saves.
  • Git-cache deduplication — Added folder-level in-flight tracking so a timed-out nested workspace cannot start a second read after its repository-root alias is removed.
  • Behavioral coverage — Added focused tests for save ordering, stale lists, ambiguous-success revision chaining, failure rollback, removal waiting, and nested Git-cache timeout deduplication.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

// A removal waits for this phone's saves of the workspace, then goes
// against the revision their answers left.
let lane = workspaceSaveLanes[Self.workspaceSaveLaneKey(context, workspaceId: workspace.id)]
_ = await lane?.tail?.value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This awaits only the tail that existed before the suspension. Because the Settings sheet remains active, a later Save can replace lane.tail; when the original task completes, that PATCH and this DELETE can both proceed against the same confirmed revision, so either user action can fail depending on request order.

Technical details
# Serialize removal with saves enqueued while it waits

## Affected sites
- `ios/AidenOnTheGo/Features/Remote/AidenRemoteCoordinator.swift:823-835` — each new save replaces `lane.tail` without consulting the removal path.
- `ios/AidenOnTheGo/Features/Remote/AidenRemoteCoordinator.swift:949-960` — removal snapshots one tail and one `ownRevisions` list before starting DELETE.
- `ios/AidenOnTheGoTests/AidenOwnerRoutingTests.swift:532-550` — coverage enqueues the save before removal, so it cannot expose a later tail replacement.

## Required outcome
- Once removal starts waiting, a save enqueued before DELETE must either be included in the serialization barrier or refused; PATCH and DELETE for one workspace must never run concurrently.
- Add coverage that enqueues another save while removal is suspended on an earlier tail and verifies request order and revision chaining.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant