fix(android): resolve session loading failure on Android#524
Open
magiclaw wants to merge 2 commits into
Open
Conversation
- Make workspaceDirectory and projectRootPath optional in schema to prevent Zod validation failure when old servers omit these fields - Add fallback in normalizeWorkspaceDescriptor (workspaceDirectory ?? projectRootPath ?? "") - Add comprehensive [PD] diagnostic logging across E2EE handshake, hello handshake, connection state machine, workspace hydration, and crypto polyfill paths - Fix white screen on agent route by adding loading state with ActivityIndicator and timeout fallback - Add LogCollector utility and Export Logs button in Settings / Diagnostics for in-app diagnostics Fixes: sessions fail to load on Android due to strict Zod schema requiring workspaceDirectory as mandatory string
7ec394c to
5c90449
Compare
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.
Problem
Android clients fail to load sessions after connecting to the server. The WebSocket connection succeeds and hello handshake completes, but workspaces/sessions never appear.
Root Cause
The Zod schema on the client strictly requires
workspaceDirectory: z.string()inWorkspaceDescriptorPayloadSchema. Older server versions may return workspace entries whereworkspaceDirectoryisundefined(whencwdis missing from the workspace record).When server returns
fetch_workspaces_responseorworkspace_updatemessages with missingworkspaceDirectory, Zod validation fails and the entire message is silently discarded. This means workspaces are never populated, and the agent directory bootstrap produces empty results.Fix
1. Relax schema validation
packages/server/src/shared/messages.tsprojectRootPath: z.string()→projectRootPath: z.string().nullable().optional()workspaceDirectory: z.string()→workspaceDirectory: z.string().nullable().optional()2. Add fallback in normalization
packages/app/src/stores/session-store.tsworkspaceDirectory: payload.workspaceDirectory ?? payload.projectRootPath ?? ""3. Additional changes included in this PR
ActivityIndicatorand timeout fallback in agent route[PD]prefixed logs across E2EE handshake, hello handshake, connection state machine, workspace hydration, and crypto polyfillLogCollectorutility + Export Logs button in Settings → Diagnostics