Skip to content

Add read-only workspace file browser to Android app#100813

Closed
heyparth1 wants to merge 2 commits into
openclaw:mainfrom
heyparth1:brutus/issue-100705
Closed

Add read-only workspace file browser to Android app#100813
heyparth1 wants to merge 2 commits into
openclaw:mainfrom
heyparth1:brutus/issue-100705

Conversation

@heyparth1

@heyparth1 heyparth1 commented Jul 6, 2026

Copy link
Copy Markdown

Closes #100705

What Problem This Solves

Operators running agents remotely (containers, VPS, always-on gateways) have no way to inspect what an agent produced or changed in its workspace from the mobile apps. The existing gateway file APIs cover only allowlisted bootstrap files (agents.files.*) or session-transcript-touched text files (sessions.files.*), so checking a generated report, a log, or an edited config from a phone requires SSH into the gateway host.

Why This Change Was Made

Ships the read-only slice of the workspace browser end to end: one canonical agent-scoped gateway RPC pair — agents.workspace.list (bounded, deterministically ordered directory listing with offset pagination) and agents.workspace.read (size-capped, type-gated file read: UTF-8 text ≤256 KB inline, images ≤5 MB base64, other binary rejected) — plus browse/preview/share UI on iOS (Agent tab Files section, reusing the chat code renderer and ShareLink) and Android (Settings → Workspace Files, share intent via the existing FileProvider). Reads are confined to the agent workspace root by path pre-normalization (absolute paths and .. rejected before any filesystem access) and the existing fs-safe root (realpath, symlink and hardlink rejection). Strictly read-only by design: write/delete/upload stay with the broader workspace API discussion (#61368 / #62417), and the agents.workspace.* namespace matches that direction so it can extend rather than conflict. Protocol schemas are additive; Swift models regenerated.

User Impact

Mobile operators can now open Files on the agent surface (iOS) or Settings → Workspace Files (Android), drill through the agent's workspace, preview text with syntax highlighting and images inline, and export any previewed file through the platform share sheet — without SSH or a desktop. Both methods are operator.read scope; nothing can modify the workspace.

Evidence

  • Live gateway e2e (in this PR): test/agents-workspace.e2e.test.ts spawns a real gateway process and a real operator WebSocket client, then verifies dirs-first listing, drill-down parentPath, UTF-8 text read, byte-exact PNG base64 round-trip, and rejection of ../ and absolute-path escapes over the wire. Green via node scripts/run-vitest.mjs test/agents-workspace.e2e.test.ts.
  • Handler regression tests: src/gateway/server-methods/agents-workspace.test.ts (10 tests) covers listing/pagination, text/image reads, and negative cases: traversal, absolute paths, symlink escape, oversize files, binary gating, unknown agent id. Verified fail-before/pass-after by removing the handler module.
  • Android, real behavior on an emulator: debug APK built (:app:assemblePlayDebug), installed on an Android 16 ARM64 emulator, paired with a live local gateway through the app's own device/node approval flow, then exercised manually: workspace listing (directories first), live refresh picking up a file created on the host after pairing, drill-down, text preview (todo.md, 30 B · text/markdown, monospace), visible image preview (base64 → bitmap), and share-sheet export delivered to a target app. :app:testPlayDebugUnitTest green locally including the new WorkspaceFilesTest (5 parser/params tests).
  • Swift/iOS: shared WorkspaceFileBrowser views + WorkspaceFileBrowserTests (7 tests: params encoding, payload decoding through a stub requester, language-id mapping, UTF-8/base64 export byte fidelity) live in OpenClawKit; the macos-swift CI job compiles them. SwiftFormat lint clean over the full iOS filelist (0/172 files require formatting).
  • Repo gates run locally: pnpm tsgo:prod (core + extensions) clean, pnpm lint shards clean, pnpm check:docs clean after regenerating docs/docs_map.md, pnpm native:i18n:check clean after syncing the native i18n inventory, gateway-protocol package tests (250) and neighbor gateway suites (410 tests) green, full npm run build exit 0.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: ios App: ios app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: XL labels Jul 6, 2026
@heyparth1

Copy link
Copy Markdown
Author

Thanks for the review — CI should be green now. The iOS build and dead-code scan were both tripping on a SwiftFormat redundantType violation in the shared browser view (fixed), native-i18n needed the inventory synced for the new UI strings, and check-docs needed docs/docs_map.md regenerated after the docs additions; I also rewrote the PR body with the authored problem/evidence sections the context gate expects. android-test-play passes locally on the exact CI command (./gradlew --no-daemon :app:testPlayDebugUnitTest, cold and warm), as do pnpm lint and pnpm tsgo:prod, so those look transient — happy to dig further if they fail again on the next run.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main already implements the useful mobile read-only workspace browser through merged Gateway, Android, and iOS work, with a canonical agents.workspace.list/get contract and stronger file-read handling than this conflicting all-in-one branch.

Root-cause cluster
Relationship: superseded
Canonical: #100705
Summary: This PR was an all-in-one candidate for the mobile read-only workspace browser, but the canonical issue was closed after the Gateway, Android, and iOS surfaces landed through split merged PRs.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the split current-main implementation from the merged Gateway, Android, and iOS PRs, and close this stale all-in-one branch instead of rebasing it into a second workspace API.

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

Not applicable as a bug reproduction: this is a feature PR. Source inspection shows current main now has the Gateway, Android, and iOS workspace browser paths that the branch intended to add.

Is this the best way to solve the issue?

Yes for cleanup closure: the current split implementation is the better solution because it landed the Gateway contract and mobile clients in focused PRs with hardened file-read handling. This branch should not be repaired into a second API shape.

Security review:

Security review needs attention: The stale branch changes a workspace file-read security boundary and is weaker than the current merged implementation.

  • [medium] Stale preview gate can return mislabeled bytes — src/gateway/server-methods/agents-workspace.ts:198
    The PR branch uses extension-derived image MIME and non-fatal UTF-8 conversion, while current main sniffs image bytes and rejects invalid UTF-8 before returning preview content.
    Confidence: 0.9
  • [medium] Branch exposes a superseded file-read API shape — src/gateway/methods/core-descriptors.ts:118
    The PR adds agents.workspace.read for arbitrary workspace content even though current main now documents and implements agents.workspace.get, making this branch a stale parallel boundary.
    Confidence: 0.88

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: Opened the canonical mobile workspace-browser issue and authored the merged Gateway, Android, and iOS implementation commits that now cover this PR's useful behavior. (role: feature requester and implementation owner; confidence: high; commits: 30e5dfcf0295, 61a29a78364a, 077e35f3b2a5; files: src/gateway/server-methods/agents-workspace.ts, apps/android/app/src/main/java/ai/openclaw/app/ui/WorkspaceFilesScreen.kt, apps/ios/Sources/Design/AgentWorkspaceFilesScreen.swift)

Codex review notes: model internal, reasoning high; reviewed against 45d0970a7de3; fix evidence: commit 077e35f3b2a5, main fix timestamp 2026-07-06T17:47:52+01:00.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: ios App: ios app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Mobile apps: read-only workspace file browser (browse, preview, share)

1 participant