Files
opencode-mobile/.tasks/10/design.md
Den 32f7af4e11 fix(sessions): recover home-scoped list after fresh connect
* fix(sessions): use active connection client directly, remove roots filter

Root cause A: loadSessions was calling clientForDirectory(serverHome) which
scoped the session list to /home/azureuser — a different project than the
server's active CWD. Sessions in the current project (e.g. opencode-mobile)
were never returned.

Root cause B: roots:true filtered out sessions that have a parentID (sub-task /
AUTO-REVIEW sessions), hiding valid sessions from the list.

Fix: use connState.client directly (the connection's active directory) and drop
the roots filter so all sessions for that project are visible.

Also adds a verify_session_list CUA smoke scenario that navigates back to the
sessions tab after creating a session and asserts the list is non-empty —
covering the regression path that was previously untested.

* fix(sessions): fetch serverHome in addConnection so loadSessions shows correct sessions

Root cause: addConnection() built the HTTP client but never fetched serverHome
(only loadConnections and setActiveConnection did). When the user adds a new
connection (fresh install / first sign-in), serverHome = null, so loadSessions
fell through to connState.client (the server's CWD). On this dev server the CWD
is the deploy directory — 11 old May-19 sessions that are not the user's recent
work sessions.

Fix: addConnection now fetches currentProject + serverHome via the same
Promise.all as setActiveConnection, before calling set(). This ensures
loadSessions immediately uses clientForDirectory(serverHome) → the global
project → the user's actual recent parent sessions.

Also adds --opencode-url flag to the CUA smoke script, which appends a
connect_and_verify_sessions scenario that reproduces the regression:
  python scripts/android-cua-smoke.py --opencode-url http://100.108.64.76:4096

* fix(sessions): recover home scope after fresh connect

Resolve stale deploy-only session list by recovering server home during first load and keeping regression coverage in default Android CUA smoke and CI.

* chore(release): bump version to 0.4.0
2026-05-26 19:50:17 -07:00

3.2 KiB

Problem

After fresh server connect, Sessions tab can render empty or wrong session scope. Users lose ability to resume real conversations.

Goal

Sessions tab reliably lists sessions for active connection scope right after connect, and smoke coverage catches regressions.

Success Metric

Android end-to-end flow "connect then open Sessions tab" passes on real emulator against real server, and Sessions list renders at least one entry when server has sessions.

Out of Scope

  • Cross-project global session aggregation on server
  • Session ranking/search UX changes
  • New server API endpoints

Current State

  • Sessions list fetch path is useSessions.loadSessions in src/stores/sessions.ts:75.
  • Current logic selects list client with home-directory fallback when connection directory is unset (src/stores/sessions.ts:84).
  • Session list call currently uses roots: true and limit: 50 (src/stores/sessions.ts:89).
  • Connection bootstrap now fetches both project and server paths in addConnection before state update (src/stores/connections.ts:155).
  • Sessions tab triggers loadSessions() in focus effect after connect/navigation (app/(tabs)/index.tsx:141).
  • CUA script contains explicit session-list scenario and connect+verify scenario (scripts/android-cua-smoke.py:480, scripts/android-cua-smoke.py:535).

Proposed Design

  1. Keep connection bootstrap metadata fetch in addConnection so serverHome is available for the first sessions-tab render.
  2. Keep sessions list call scoped through home-directory fallback when no explicit directory is configured, preserving expected global/root view for this app's UX.
  3. Preserve roots: true filter so child/sub-task sessions do not flood primary list.
  4. Add durable regression guard via real emulator smoke execution for connect-then-sessions flow, recorded in task test artifacts.
  5. If runtime validation shows wrong scope, adjust client selection strategy and re-run same smoke protocol before merge.

Alternatives Considered

  1. Use active connection client directly for all list calls.
    • Rejected: in this environment it returns stale deploy-project sessions when connection has no directory.
  2. Remove roots: true.
    • Rejected: increases noise from nested agent sub-sessions; not aligned with main session UX.
  3. Add new backend endpoint for cross-project session aggregation.
    • Rejected: out-of-scope for mobile client bugfix and requires upstream server contract change.

Risks & Open Questions

  • Risk: server-side project resolution may vary across environments.
    • Mitigation: validate against real target server (100.108.64.76:4096) with deterministic emulator flow.
  • Risk: CUA automation can return false negatives due transient UI load timing.
    • Mitigation: capture screenshots/UI dumps and use explicit wait windows in protocol.
  • Open question: keep issue linked to existing PR #9 or open a dedicated PR branch.
    • Decision: create dedicated ownership branch from latest main-compatible fix state and link issue #10.

Touched Surface

  • src/stores/connections.ts
  • src/stores/sessions.ts
  • app/(tabs)/index.tsx
  • scripts/android-cua-smoke.py
  • .github/workflows/cua-smoke.yml (if CI scenario coverage adjustment needed)