Skip to content

fix(ios): restart Files pagination when the folder drifts under the cursor - #193660

Merged
obviyus merged 5 commits into
openclaw:mainfrom
ccclucky:fix/ios-files-pagination-drift
Nov 8, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
ccclucky:fix/ios-files-pagination-drift

Conversation

@ccclucky

@ccclucky ccclucky commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #193500

What Problem This Solves

Fixes: the iOS Files "Load More" button keeps requesting the same final page without ever completing, when a file is created in the workspace between page loads.

User Impact

User impact: files that land before the current pagination position now show up — one reload recovers the listing, and Load More finishes or disappears instead of looping on a page that contains only already-listed entries.

Why This Change Was Made

AgentWorkspaceDirectoryList.loadMore used the deduplicated local row count (entries.count) as the next server offset. A file inserted before the cursor makes the following page overlap the local list; its rows dedupe away, the local count stops growing, and entries.count < totalEntries stays true, so every tap re-requests the same final entry.

The fix tracks server-side pagination progress separately in WorkspaceListPagination. When a consumed page reaches the reported end of the directory while local rows are still short, the view reloads the folder once so the inserted rows appear. Failed pages keep the cursor unchanged, so retry after a failed page still works, and .refreshable / .task(id:) already reset the cursor through reload().

Evidence

  • Root cause verified against current main source: the offset request at apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift:180 (offset entries.count, deduplicated append, button condition at line 71) matches the issue report.

  • The pagination state machine is a standalone type; its logic was compiled and executed against the issue's exact scenario (251-entry folder, insertion before the cursor, offset 250 returning Note 250.md + Note 251.md, then repeated offset-251 requests) plus static-folder completion and reload-recovery cases — all pass:

    offset 0   → advanced, cursor 250
    offset 250 → driftDetected (252 total, 251 local)
    reload → reset; offset 0 → advanced; offset 250 → advanced, 252 local == 252 total
    
  • Regression tests added in apps/ios/Tests/AgentWorkspaceFilesPaginationTests.swift: static folder completion, insertion-before-cursor drift, and reload recovery. swiftc -parse passes on both changed files.

  • CI note: the first CI run failed the iOS SwiftFormat (lint) build phase because AgentWorkspaceFilesScreen.swift violated the pinned swiftformat 0.63.1 rules (wrapMultilineStatementBraces ×2, andOperator); fixed in 743b206a814 by running the pinned binary with this repo's config, verified lint-green locally, and the redundant stalled-page test flagged by review was removed.

  • Native behavior proof (independent contributor run by @ellibbe, comment): on iPhone 17 Simulator / iOS 27.0 (Xcode 27.2, Light mode), a loopback WebSocket fixture serves a real synthetic 251-file directory and inserts A new note.md after the first response, exercising the real AgentWorkspaceDirectoryList.loadMore and its automatic reload. Base a54bdb3c608f fails the automatic-reload assertion (stuck at 251 of 252, RPC offsets [0, 250]); this head passes — the inserted file appears and Load More disappears after completion (offsets [0, 250, 0, 250]; the final passing run also scrolled to the visible end and confirmed Load More is absent). This covers the native behavior proof requested in review; no snapshot-lane expansion is needed for this contribution. Scope caveats from that run: the fixture does not execute the complete Gateway handler, and the app-hosted unit runner compiled but did not start (bounded retry after a simulator restart timed out), so no iOS-hosted unit-test pass is claimed. The run qualified the pre-integration tree (743b206a814); it is an independent contributor run, not a maintainer qualification.

  • Integration with main: merged main @ 6b959f4ca63 in 43003185d63, resolving the loadMore conflict with fix(ios): clear stale folder errors after Load More succeeds #193504 so its stale-error clearing (errorText = nil) runs before consume/reload — a failed reload keeps its own new error visible. Verified locally: pinned swiftformat 0.63.1 lint 0/1, swiftc -parse clean, standalone WorkspaceListPagination assertions ALL PASS; the failed-Load-More → successful-retry path is covered by the AgentWorkspacePaginationUITests fixture fix(ios): clear stale folder errors after Load More succeeds #193504 adds, now on this branch via the merge for CI.

  • Validation boundary: this machine has only the Command Line Tools (no full Xcode), so the SwiftUI target build and the XCTest run are left to CI; the standalone logic run above covers the state machine itself. The new Swift test file is not counted by the test-lines ratchet (it tracks *.test.ts/mts/js patterns only), so no allocation is needed.

…ursor

The workspace Files list used the deduplicated local row count as the
next server offset. A file inserted before the cursor turns the final
page into an overlap whose rows dedupe away, so the offset and the Load
More button stall forever (openclaw#193500).

Track server pagination progress in WorkspaceListPagination instead.
When a consumed page reaches the reported end while local rows are still
short, reload the directory once so the inserted rows appear.
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Track consumed server rows separately from displayed files and reload the directory when pagination detects inserted or deleted files.

Example: Load 250 of 251 files, create A new note.md before the pagination cursor, then tap Load More.

  • Before: The footer remains at 251 of 252 and the new file never appears.
  • After: The listing automatically reloads, includes A new note.md, and finishes pagination.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, source-supported repair with native real-Gateway validation and no actionable finding; CI readiness remains separate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): obviyus reports exercising the native Files screen against a real Gateway on iPhone 17 Simulator/iOS 27: insertion, deletion, and unchanged-directory cases pass with the follow-up. Earlier contributor evidence also records insertion recovery through the native app with RPC offsets [0, 250, 0, 250]. Attachment retrieval failed in this review environment, so screenshots were not independently inspected; this infrastructure limit creates no contributor proof requirement.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Files can repeatedly offer Load More without completing, or silently omit the last file after a deletion shifts directory offsets.
Reason: The bounded repair addresses demonstrated native failures, preserves existing retry behavior, and has explicit maintainer validation of its intended scope.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current iOS Files pagination defect and has maintainer-reported end-to-end validation; no introduced bug was found, but CI remains blocked.

Priority: P2
Reviewed head: 7b2821aaf4a31db92225e72b6bf031319e0718bd

Before merge

None.

Findings

None.

Agent review details

How this fits together

The native iOS Files screen requests sorted directory pages through agents.workspace.list and renders deduplicated workspace entries.

flowchart LR
  A[Workspace directory] --> B[Gateway sorted offset pages]
  B --> C[iOS Files screen]
  C --> D[Pagination progress]
  D --> E[Append unique entries]
  D --> F[Reload on detected drift]
  F --> B
Loading

Technical review

Best possible solution:

Retain the focused client pagination repair and land it once the existing CI gates are satisfied.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the overlapping-page failure, and obviyus independently reports reproducing insertion and deletion failures through the native app and a real Gateway; this review executed no target code.

Is this the best way to solve the issue?

The smallest complete fix keeps pagination progress separate from deduplicated rows in the existing screen and reuses reload for detected drift, without adding a server protocol or competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cf376b0d000a.

Provenance checked

  • Directory pagination changes intended behavior with a stated reason (077e35f: The original Files feature used sorted offset pages to browse agent workspaces from iOS.)
  • Successful pagination error clearing keeps the original intent (efe90b4: Successful Load More retries must retire the earlier page error while preserving loaded files.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 077e35f adds apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift:182 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 077e35f3b2a5; files: apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift)
  • Hosung Park: Raw commit efe90b4 adds apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift:184 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: efe90b42a8ca; files: apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift)

PR surface

Source +63, Tests +102. Total +165 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 64 1 +63
Tests 1 102 0 +102
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 166 1 +165

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is linked_artifact.

Label justifications:

  • P2: Directory changes can stall pagination or omit a remaining file, with recovery available through refreshing or reopening Files.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-05T18:35:04.994Z sha 780fb3d :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-05T20:09:32.697Z sha 743b206 :: needs changes before merge. :: none
  • reviewed 2026-11-05T22:08:41.823Z sha 4300318 :: needs maintainer review before merge. :: none

Reviewed November 8, 2026, 5:04 AM ET / 10:04 UTC (Revision 4).

…e test

The SwiftFormat (lint) build phase (pinned 0.63.1) failed the iOS test
build: wrap the braces of multiline statements and prefer comma over &&
in the drift condition. Remove the repeated stalled-page test; the
repaired view reloads at the first drift, so the retry path has no
user-visible behavior to cover.
@ccclucky

ccclucky commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper findings addressed in 743b206, and the open CI-attribution question in this review is now resolved:

CI root cause (previously unresolved): the iOS job failures on 780fb3d7021 were introduced by this PR. The Xcode SwiftFormat (lint) build phase pins swiftformat 0.63.1 (scripts/check-swift-tools.sh), and AgentWorkspaceFilesScreen.swift had three violations under that pinned version (wrapMultilineStatementBraces ×2, andOperator), which failed the test build and cascaded into ios-screenshots, the Periphery dead-code scans, and ci-gate. Reproduced locally with the pinned 0.63.1 binary, fixed by running it with this repo's config, verified green:

$ .build/swift-tools/swiftformat --lint --config config/swiftformat \
    --unexclude apps/ios/Sources apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift
0/1 files require formatting.

Low-value test: removed the drift repeats while the stalled page is retried case as flagged — the repaired view reloads at the first drift, so that retry path has no distinct user-visible behavior to cover. The remaining three cases were re-verified standalone against the verbatim WorkspaceListPagination source (13 assertions, all pass).

Native proof (the remaining blocker): this machine has only the Command Line Tools (no full Xcode — verified via xcodebuild/simctl being unavailable), so I cannot capture native Files-screen screenshots or a recording of AgentWorkspaceDirectoryList.loadMore locally, and I did not want to expand this bugfix with CI snapshot-lane changes unprompted. Maintainers: which path do you prefer for the native behavior proof — (a) I extend the iOS snapshot lane to seed the 251-file insertion scenario so CI produces the evidence, or (b) a manual run of the Files screen against an isolated Gateway on a machine with Xcode? I'm happy to do (a) if that direction is acceptable.

@llbohacll

Copy link
Copy Markdown
Contributor

I took the manual native route: the Files screen now recovers the insertion and completes pagination. Your new 743b206a814 has the same Git tree as the source I validated (8284f77eaad89c425dd442bd374508708ccdd360), so no additional code patch is needed.

I ran a native UI regression on iPhone 17 Simulator / iOS 27.0, Xcode 27.2, in Light mode:

Source Result Observed RPC offsets
Base a54bdb3c608f Fails the automatic-reload assertion; remains at 251 of 252 [0, 250]
Source tree matching 743b206a814 Passes; the inserted file appears and Load More disappears after completion [0, 250, 0, 250]

The same recovery test was used for the first red/green pair. The final passing run additionally scrolls to the visible end and confirms Load More is absent there; it took 101.199 seconds. The matched before/after captures and recovered-file capture accompany this comment.

The loopback fixture serves a real synthetic 251-file directory over WebSocket, inserts A new note.md after the first response, and implements the inspected sorting/offset contract. This exercises AgentWorkspaceDirectoryList.loadMore and its automatic reload in the real app; it does not execute the complete Gateway handler.

The three remaining cursor contracts also pass using the exact production type in a dependency-free Swift package. The app-hosted unit runner compiled but did not start; a bounded retry after restarting the Simulator timed out, so I am not claiming an iOS-hosted unit-test pass.

These results and captures can go into Evidence for the current head. They cover the native behavior proof requested in review; no snapshot-lane expansion is needed for this contribution.

Before: final page remains incompleteAfter: pagination completes
Before: final page remains incompleteAfter: pagination completes

Recovered file after automatic reload:

Recovered file after automatic reload

@ccclucky

ccclucky commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 5, 2026
@llbohacll

Copy link
Copy Markdown
Contributor

I checked the reported conflict against main 6d7347b2da3f while reviewing the integration. In loadMore, both changes need to survive: the successful-retry error clearing from #193504 and this PR's consumed-row/reload logic.

The combined order immediately after updating totalEntries is:

self.totalEntries = result.totalentries
self.errorText = nil
if self.pagination.consume(
    requestOffset: requestOffset,
    fetchedCount: result.entries.count,
    totalEntries: result.totalentries,
    localRowCount: self.entries.count) == .driftDetected
{
    await self.reload()
}

Clearing the old error before consume/reload matters: a failed reload must be able to leave its new error visible. Clearing after the await could erase it. Keep the deduplication and server-row cursor intact when selecting the combined conflict hunk.

This is a source-level resolution, not a new native qualification. After integrating main on your existing branch, the relevant checks are the insertion recovery already exercised here and failed Load More → successful retry, to protect both repairs together. The earlier native evidence is an independent contributor run of the pre-integration tree.

…ion-drift

# Conflicts:
#	apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift
@ccclucky

ccclucky commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Integrated main into the branch and resolved the loadMore conflict exactly as described: the stale-error clearing from #193504 now runs before consume/reload, so a failed reload can still leave its own new error visible. Deduplication and the server-row cursor are unchanged.

Merge commit: 43003185d63 (integrates main @ 6b959f4ca63).

Verification run locally:

$ .build/swift-tools/swiftformat --lint --config config/swiftformat \
    --unexclude apps/ios/Sources apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift
0/1 files require formatting.

$ swiftc -parse apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift
(no diagnostics)

$ swift /tmp/oic-verify-193660/standalone.swift   # verbatim WorkspaceListPagination state machine
ALL PASS (reload reset / page advance / final-page completion)

On the two behaviors to protect together: the failed-Load-More → successful-retry case is covered by the AgentWorkspacePaginationUITests fixture that #193504 added, which the merge brings onto this branch for CI; the insertion-recovery case remains covered by the native run above. This machine still has no full Xcode, so I have not re-qualified natively after the merge — per your note this is a source-level resolution, and the pre-integration native evidence stays as the independent contributor run.

One process note: the ClawSweeper re-review of the pre-merge head 743b206a814 completed at 20:11Z but no verdict is visible on the PR (no review or comment landed); I'll follow up once the post-merge state is reviewed rather than request again for the same content twice.


@clawsweeper re-review of the post-merge head 43003185d63 (new content: main integration + the loadMore conflict resolution above) — please pick this up.

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 5, 2026
@obviyus

obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Maintainer end-to-end check, and a small follow-up commit.

Setup: an iPhone 17 simulator on iOS 27 using the real UI, paired to a real Gateway running current main. I filled the agent's workspace folder on disk with Note 001.md … Note 251.md (the Gateway pages 250 at a time). Each run: open the folder in Files, scroll to the footer (Load More 250 of 251), change the folder on disk, then tap Load More.

Build Change on disk Result
main add A new note.md ❌ footer stuck at 251 of 252 on every tap; the new file never appears
main delete Note 010.md ❌ footer disappears, Note 251.md is never listed, and the deleted file stays
PR head 43003185d63 add A new note.md ✅ reloads automatically, then completes
PR head 43003185d63 delete Note 010.md ❌ same as main: last file missing
PR + 02b5eb94d3c delete / add / no change ✅ full, current listing in all three cases; no extra reload when nothing changed

Follow-up (02b5eb94d3c). The Gateway re-sorts the folder and slices it by offset on every request; there is no snapshot cursor. When a file before the cursor is deleted, an unseen row shifts into offsets the app already loaded and is silently skipped. WorkspaceListPagination now remembers the previous page's total, and a smaller total triggers the same automatic reload. The commit adds a regression test, and adds @discardableResult to consume, which removes the PR's new unused-result warning.

Known limit: if a deletion and an insertion happen between the same two pages, the total doesn't change, so this check can't see it. Pull to refresh recovers.

I also merged current main (7b2821aaf4a).

Tests: OpenClawTests/AgentWorkspaceFilesPaginationTests on the simulator.

  • With the PR source, the 3 PR tests pass and the new deletion test fails.
  • With the follow-up, 4/4 pass.
  • SwiftFormat and swiftlint --strict are clean.

Thanks @ccclucky for the fix and the clear write-up!

main: after adding a file, Load More stays stuck at 251 of 252

PR: reload shows the new file

main and PR head: after deleting a file, Note 251 is never listed

PR plus follow-up: list ends at Note 251

@obviyus

obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@obviyus
obviyus merged commit f362c62 into openclaw:main Nov 8, 2026
116 of 125 checks passed
@obviyus

obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
…ursor (openclaw#193660)

* fix(ios): restart Files pagination when the folder drifts under the cursor

The workspace Files list used the deduplicated local row count as the
next server offset. A file inserted before the cursor turns the final
page into an overlap whose rows dedupe away, so the offset and the Load
More button stall forever (openclaw#193500).

Track server pagination progress in WorkspaceListPagination instead.
When a consumed page reaches the reported end while local rows are still
short, reload the directory once so the inserted rows appear.

* style(ios): satisfy pinned swiftformat and drop redundant stalled-page test

The SwiftFormat (lint) build phase (pinned 0.63.1) failed the iOS test
build: wrap the braces of multiline statements and prefer comma over &&
in the drift condition. Remove the repeated stalled-page test; the
repaired view reloads at the first drift, so the retry path has no
user-visible behavior to cover.

* fix(ios): reload Files listing when a deletion shifts rows under the cursor

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: iOS Files repeats the final page after an insertion shifts pagination

3 participants