Repository navigation
fix(mobile): importing a persona file on Android works after the file picker - #856
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Jacksondr5
left a comment
There was a problem hiding this comment.
Combined panel review (reviewer-opus + reviewer-sol) at 4359fc174e
Verdict: no findings, and the panel approves the source provisionally. It stays provisional while the PR is a draft: the tester's logs need to confirm that the failure is EnvironmentRpcUnavailableError, and a device run needs to show an import succeeding after a long stay in the picker.
- Retrying is safe.
EnvironmentRpcUnavailableErrorcomes fromcurrentSessioninclient-runtime/src/rpc/client.tswhen there is no session. That happens before the request is built, so the import never reached the server and sending again can't repeat an accepted import. The message the tester saw ("openclaw is not connected.") is the one that path produces.squashAtomCommandFailureisCause.squash, so the tag survives intoPredicate.isTagged. - Bounded. It retries once, after at most 15 s of waiting for the environment to report connected. Otherwise it fails visibly with "didn't reconnect in time". Server refusals pass straight through, untouched (tested). The timeout clears both the timer and the registry subscription.
- Both import kinds.
importSelectionserves both file and folder import, and each send insideimportAgentPersonasWithConfirmation(first attempt and confirmed replacement) goes through the same wrapper. - Not machinery for a rare case. It's the normal Android path whenever the picker stays open past
MOBILE_BACKGROUND_RECONNECT_AFTER_MS(10 s). It's J5-owned and about 50 lines. - The new wait helper (
waitForEnvironmentConnected) has no test of its own. Its subscription and timeout are checked by reading the source only. That's acceptable for the size.
Reviewer-run checks
sendAfterReconnect.test.ts: 3 passed (reviewer-sol also ran the picker tests: 7 in 2 files)- lint: clean on the changed files
Reviewed by Claude Opus 5.5 (reviewer-opus) and Sol 6.1 (reviewer-sol) in J5 Code.
4359fc1 to
33f3c03
Compare
|
Warning Review limit reached
This review includes 7 billable files and costs up to $1.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 21 minutes for your next included review. View limit details
|
Jacksondr5
left a comment
There was a problem hiding this comment.
Combined panel re-review (reviewer-opus + reviewer-sol) at 33f3c039bf (repurposed PR)
Verdict: the product change is correct. One small test fix is requested so the regression test fails on trunk for the right reason. Live testing is pending.
Small should-fix: make the Android-id test fail on trunk because of the name (raised by reviewer-sol, reproduced by reviewer-opus)
The new test "names a chosen Android document by its file name, not the id in its URI" only configures documents.getDocumentAsync. When trunk's pickAgentDefinitions.ts is swapped in, File.pickFileAsync is an unconfigured vi.fn() that returns undefined. The test then fails with a TypeError on selection.canceled, not with the real bug ("No YAML persona definitions found"). reviewer-opus swapped trunk's file in and got 3 failures, all for that plumbing reason.
Fix: in that test, also give the old picker a realistic Android result: File.pickFileAsync → { canceled: false, result: new File("msf%3A28") }, while the new picker returns name: "scout.yaml". Trunk then fails on the extension filter, and the branch passes. That meets AGENTS.md's "fails on j5/main for that reason" without testing picker plumbing.
Checked and fine
- Cause confirmed. In expo-file-system 58,
File.nameisPaths.basename(this.uri). A Downloads pick comes back ascontent://…/document/msf%3A28, so the name ismsf:28and both the client and server.yaml/.ymlfilters drop it. - The new picker is
getDocumentAsync({ copyToCacheDirectory: true }), which upstream's attachments already use (expo-document-pickeris already a dependency). It keeps the picker's display name and a readablefile://cache copy.sizefalls back to the copy's size. Cancel, includingassets: null, returns no selection, and the foreground handoff still ends infinally. - The reconnect retry is fully removed. Its cause wasn't confirmed, so it was right to drop it.
- Mobile
vp run typecheck: exit 0.pickAgentDefinitions.test.ts: 5 passed.
Device check, not a finding: folder import from Downloads
Folder import is unchanged and still names each entry by Paths.basename(uri). For external-storage trees that decodes to the real file name (primary:Download/team/agent.yaml → agent.yaml). Children of a folder picked under the Downloads provider may instead carry ids like msf:NN, which would be dropped the same way. Please try a folder import from Downloads on Android during the device pass. If it fails, that's a follow-up issue, not this PR.
Reviewed by Claude Opus 5.5 (reviewer-opus) and Sol 6.1 (reviewer-sol) in J5 Code.
Jacksondr5
left a comment
There was a problem hiding this comment.
Combined panel re-review (reviewer-opus + reviewer-sol) at bc756540a1
Verdict: the test should-fix is resolved, and the panel approves the source. Still pending: the tester's re-test at this head.
- Test proof. The Android-id test now gives trunk's
File.pickFileAsynca realisticmsf%3A28result. reviewer-opus swapped trunk'spickAgentDefinitions.tsback in: the test fails with "No YAML persona definitions found in the selection.", the real bug, and passes on the branch. - The retry is back.
sendAfterReconnect.ts,waitForEnvironmentConnected.tsand their test are byte-identical to 4359fc174e, which the panel already reviewed: safe to retry becauseEnvironmentRpcUnavailableErroris raised before the request leaves the device, bounded at 15 s, fails visibly, and lets server refusals through untouched. The screen wrapper is the same single change. The new device evidence (trunk keeps failing with "not connected"; the retry imports after more than 20 s in the picker) settles the cause we had held open. - Scope. Both fixes close the one symptom in #855, and the description explains which file provider produces which failure. That's fine as one PR.
- Description nit (optional). The retry wraps
importSelection, which serves folder import too, so "Folder import is unaffected" holds for the picker change but not for the retry.
Reviewer-run checks
pickAgentDefinitions.test.tsandsendAfterReconnect.test.ts: 8 passed- the branch is based on current
j5/main(d30e293)
The device check on folder import from Downloads (entries may be named msf:NN) still stands for the tester. If it fails, it's a follow-up issue.
Reviewed by Claude Opus 5.5 (reviewer-opus) and Sol 6.1 (reviewer-sol) in J5 Code.
Jacksondr5
left a comment
There was a problem hiding this comment.
Combined panel re-review (reviewer-opus + reviewer-sol) at f8718bb5ee
Verdict: the delayed-import race is fixed in source, with no new findings. The panel approves the source again. Still pending: the tester's re-check of an import after more than 20 s in the picker. That path failed on device at bc756540a1.
What failed at bc756540a1: the supervisor's connected run ends with Effect.ensuring(clearLease) (connection/supervisor.ts:842), which clears the session before the phase leaves "connected". The old wait accepted that stale "connected" phase, so the single resend hit the same missing session.
What changed:
- The retry now waits on
environmentCatalog.sessionGenerationAtom(environmentId)(client-runtime/src/state/runtime.ts:613–645). That count rises only when the target environment is "connected" and has a new, non-null session object. The stale window (connected, no session) can't advance it, and other environments can't wake it. watchEnvironmentSessionssubscribes before the send, so it takes its baseline first and keeps the count mounted through the reconnect. A session that arrives before the wait begins resolves at once. The watch is disposed infinally. It's still one retry, bounded at 15 s, with the visible "didn't reconnect in time" failure.waitForEnvironmentConnectedis deleted.sendAfterReconnectonly renames its wait parameter.watchEnvironmentSessions.test.tstests the helper itself: a stale state stays pending until the count rises, an earlier session resolves at once, and it gives up at 15 s (fake timers).
Reviewer-run checks
- mobile
watchEnvironmentSessions,sendAfterReconnectandpickAgentDefinitionstests: 11 passed, 3 files (both reviewers) - mobile
vp run typecheck: exit 0 - lint: clean on
src/j5/agents
Reviewed by Claude Opus 5.5 (reviewer-opus) and Sol 6.1 (reviewer-sol) in J5 Code.
On Android, a file picked from Downloads comes back as a document URI such as content://…/document/msf%3A28, and expo-file-system names a File by its URI, so the import saw "msf%3A28", found no .yaml file and failed with "No YAML persona definitions found in the selection". The single-file pick now uses expo-document-picker, as upstream's file attachments do, whose asset carries the file's real name and a readable cache copy. Closes #855 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Returning from more than 10 seconds in the file picker reconnects the environment, and an import sent meanwhile was refused with "openclaw is not connected" before it left the device; the tester saw that repeatedly on j5/main, and an import after more than 20 seconds in the picker worked with this retry. The import now waits for the reconnect, at most 15 seconds, and sends once more; if the environment doesn't come back it says so. Server failures are reported as before. The Android-id picker test also mocks the old picker, so on trunk it fails on the YAML name check rather than on missing plumbing. Refs #855 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d phase The tester's delayed import still failed with "not connected": a resume clears the session before the phase leaves "connected", so the retry's wait saw "connected", resolved at once, and resent into the same missing session. It now watches the environment's own session count (sessionGenerationAtom) from just before the send and resends only once a newer session is up, still bounded at 15 seconds. Refs #855 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The import wrapper's try/finally sat inside AgentLibrarySettingsScreen, and the React Compiler does not lower a try without a catch, so the screen fell out of compilation (reactCompilerCoverage). The session watch and its disposal move into sendWhenReconnected beside watchEnvironmentSessions; the screen calls it in one expression. Refs #855 Co-Authored-By: Claude Opus 5.5 <[email protected]>
f8718bb to
017d3b5
Compare
Jacksondr5
left a comment
There was a problem hiding this comment.
Panel delta check (reviewer-opus + reviewer-sol) at 017d3b5
Verdict: no findings. This changes no behaviour, and the panel's source approval stands.
- Rebase only for the first three commits.
git range-diffagainst f8718bb5ee shows the same patches. The only difference is that the import hunk now lands in trunk's renamedOwnerAgentLibrarySettingsScreen. Against the updatedj5/main, the PR diff is still the 7 intended files. - 017d3b5 moves the watch-before-send,
await sendAfterReconnectandfinally disposewrapper unchanged out of the component, intosendWhenReconnected(environmentId, send)inwatchEnvironmentSessions.ts. That takes the catch-lesstry/finallythe React Compiler can't lower out of the screen. The capturedenvironmentIdandinput, the watcher and the 15 s wait are all unchanged. So the tester's Android pass at f8718bb5ee (25 s delayed import, replace prompt) still covers the runtime behaviour.
Reviewer-run checks
reactCompilerCoverage.test.ts,watchEnvironmentSessions,sendAfterReconnectandpickAgentDefinitions: 1025 passed, 4 files- mobile
vp run typecheck: exit 0
Reviewed by Claude Opus 5.5 (reviewer-opus) and Sol 6.1 (reviewer-sol) in J5 Code.
Problem
On Android, importing a persona file from Downloads fails, and nothing is imported. It fails in one of two ways, depending on the device's file provider, and both were seen on j5/main. Closes #855.
1. The file's name is lost (wave-1a tester's debug run): "No YAML persona definitions found in the selection.", with the import never reaching the server. Confirmed by the logs, then by reading expo-file-system's source: a file picked on Android comes back as a document URI such as
content://…/document/msf%3A28. expo-file-system names aFileby its URI (Paths.basename(this.uri)), so the import saw the namemsf%3A28. Both the client'sprepareAgentPersonaImportand the server'simportFilesaccept only.yaml/.ymlnames, so the file was dropped. The real display name exists only natively and isn't passed to JS. iOS returns a copy with its real name.2. The reconnect (wave-1b tester): "openclaw is not connected", repeatedly. Returning from more than 10 seconds in the picker reconnects the environment (
MOBILE_BACKGROUND_RECONNECT_AFTER_MS). The import, sent as the picker closed, was refused for having no session (EnvironmentRpcUnavailableError) before it left the device. With the retry below, the same tester's import after more than 20 seconds in the picker worked.What changed
The single-file pick uses
expo-document-picker'sgetDocumentAsync({ copyToCacheDirectory: true }), as upstream's file attachments do (lib/composerImages.ts). Its asset carries the file's real name and a readable cache copy. Folder import keeps its picker.sendAfterReconnect. Only a send refused withEnvironmentRpcUnavailableError, which never left the device, is sent again, and only once a newer session is up.watchEnvironmentSessionswatches the target environment's own session count (sessionGenerationAtom) from just before the send. It doesn't read the connection phase, because a resume clears the session before the phase leaves "connected" (supervisor.ts). The wait is bounded at 15 seconds; after that the import fails with "The environment didn't reconnect in time. Try again." Server failures (a conflicting id, a bad file) are reported as before, with no wait and no second send.Live testing
Android: PASS at f8718bb5ee (wave-1b tester, report
test-reports/j5code-mobile-wave1b-tester/f8718bb5ee.md).iOS: not verified. iOS checks are deferred to Checkpoint 1 on Jackson's iPhone.
Checklist
pickAgentDefinitions.test.ts),sendAfterReconnect.test.tscovers the retry's ordering, andwatchEnvironmentSessions.test.tscovers the wait: a stale connected state with no new session doesn't resolve, and the wait gives up at 15 sapps/mobile/src/j5/agents/).expo-document-pickeris already a mobile dependency.Built by Claude Opus 5.5 in Claude Code (J5 Code crew seat builder-composer).
🤖 Generated with Claude Code