Repository navigation
Description
In plain words
OSS: The file tree lets you choose which folders to skip, and says when the list is cut short or fails.
OHE: The file tree has a fixed skip list, stops at 2000 files without saying so, and shows an empty folder on errors.
Outcome and scope
Inventory: G14, G15. Feature IDs: F08.files-discovery-settings, F08.files-tree, F08.files-empty-workspace, F08.files-load-error.
Make directory discovery report failures/truncation honestly and accept safe persisted exclusion/cap preferences. Current fixed exclusions/max 2000 and [] on nonzero command exit prevent parity. SDK owns typed options/results; Enterprise owns authorization/persistence/bounded execution. No browser bash or unbounded find.
Pinned source evidence
enterprise/openhands/app_server/app_conversation/app_conversation_router.py
Lines 1598 to 1630 in 0a67aa4
# Directory names we never descend into when listing workspace files — kept in # sync with the Agent Canvas frontend's local `find` listing so cloud and local # backends exclude the same heavy/build dirs. _WORKSPACE_LIST_EXCLUDED_DIRS = ( '.git', 'node_modules', '.venv', 'venv', '__pycache__', 'dist', 'build', '.next', '.cache', '.pytest_cache', '.mypy_cache', '.turbo', '.parcel-cache', 'target', ) # Cap the number of files returned so a giant repo doesn't overwhelm the UI. _WORKSPACE_LIST_MAX_FILES = 2000 def _build_workspace_list_command() -> str: """`find` invocation that lists regular files relative to the cwd, pruning heavy/build directories and bounding the result.""" prune_expr = ' -o '.join( f"-name '{name}' -prune" for name in _WORKSPACE_LIST_EXCLUDED_DIRS ) return ( f'find . \\( {prune_expr} \\) -o -type f -print 2>/dev/null ' f'| sort | head -n {_WORKSPACE_LIST_MAX_FILES}' enterprise/openhands/app_server/app_conversation/app_conversation_router.py
Lines 1738 to 1846 in 0a67aa4
async def list_conversation_files( conversation_id: UUID, path: Annotated[ str | None, Query( description=( 'Optional absolute path to the workspace directory to list. ' 'When omitted, or when it does not match the conversation ' 'workspace, the directory is resolved from the sandbox spec ' "and the conversation's selected repository." ), ), ] = None, app_conversation_service: AppConversationService = ( app_conversation_service_dependency ), sandbox_service: SandboxService = sandbox_service_dependency, sandbox_spec_service: SandboxSpecService = sandbox_spec_service_dependency, httpx_client: httpx.AsyncClient = httpx_client_dependency, ) -> list[str]: """List every regular file under a conversation workspace directory. Mirrors the git-proxy endpoints: browsers can't reach runtime sandboxes directly (no CORS for non-localhost origins), so the frontend hits this on the cloud API host and we make the runtime hop server-side using the sandbox's session API key. Unlike `/git/changes` (which only reports modified/untracked files), this enumerates the full tree so the Files tab matches the local-backend experience. Paths are returned relative to the listed directory (e.g. ``src/index.html``). """ ctx = await _get_agent_server_context( conversation_id, app_conversation_service, sandbox_service, sandbox_spec_service, ) if isinstance(ctx, JSONResponse): raise HTTPException( status_code=ctx.status_code, detail=f'Conversation {conversation_id} is not reachable', ) if ctx is None: raise HTTPException( status_code=status.HTTP_409_CONFLICT, detail='Sandbox is paused; resume it before listing files.', ) cwd = _resolve_workspace_dir(path, ctx) headers = {'X-Session-API-Key': ctx.session_api_key} if ctx.session_api_key else {} try: upstream = await httpx_client.post( f'{ctx.agent_server_url}/api/bash/execute_bash_command', json={ 'command': _build_workspace_list_command(), 'cwd': cwd, 'timeout': 30, }, headers=headers, timeout=40.0, ) upstream.raise_for_status() data = upstream.json() except httpx.HTTPStatusError as e: logger.exception( 'Agent server returned error listing files: %s - %s', e.response.status_code, e.response.text, stack_info=True, ) raise HTTPException( status_code=status.HTTP_502_BAD_GATEWAY, detail=f'Agent server error: {e.response.status_code}', ) from e except (json.JSONDecodeError, httpx.DecodingError) as e: logger.exception( 'Agent server returned non-JSON listing files: %s', e, stack_info=True ) raise HTTPException( status_code=status.HTTP_502_BAD_GATEWAY, detail='Agent server returned unexpected response.', ) from e except httpx.RequestError as e: logger.exception( 'Failed to reach agent server listing files: %s', e, stack_info=True ) raise HTTPException( status_code=status.HTTP_502_BAD_GATEWAY, detail='Failed to reach agent server.', ) from e if not isinstance(data, dict) or data.get('exit_code') != 0: # A non-zero exit (e.g. the directory doesn't exist yet) means there is # nothing to list rather than an error worth surfacing to the UI. return [] stdout = data.get('stdout') or '' seen: set[str] = set() files: list[str] = [] for line in stdout.splitlines(): rel = line.strip() if rel.startswith('./'): rel = rel[2:] if not rel or rel in seen: continue seen.add(rel) files.append(rel) if len(files) >= _WORKSPACE_LIST_MAX_FILES: break return files - https://github.com/OpenHands/OpenHands/blob/852132d38dbc15e03d6825bbacbeb971c72575be/src/hooks/query/use-workspace-file-discovery.ts#L15-L78
Source audit only, not a deployed-OHE test result. Canvas pins Agent Server 1.55.1 (minimum 1.51.0); Enterprise Python dependencies pin 1.50.1. Record actual app/runtime images and client versions before interpreting capability failures; Python dependencies do not establish deployed sandbox version.
Dependencies and delivery order
OpenHands/software-agent-sdk#6079 and #849. #18108 includes UI error handling but explicitly excludes backend missing-directory semantics.
Acceptance
- Distinguish successful empty, missing, permission denial, invalid response, command/timeout and transport failures with safe useful statuses.
- Define exclusion syntax and cap with server ceilings/truncation metadata; prove no shell injection and bounded large-directory execution.
- Define user/org/workspace preference scope and concurrency, persistence across reload/resume without cross-tenant/sibling effects.
- Keep mandatory security/bookkeeping exclusions from #18108/fix(app-conversation): list the /workspace root in the Files endpoint #684 independent of preferences; use authoritative roots.
- Publish shared SDK contract then minimally wire existing Canvas discovery dialog and empty/error UI; test actual producer/client with missing/forbidden/empty/truncated and option refresh.
Duplicate reconciliation and non-goals
All-state Enterprise file/discovery searches found no equivalent. #135 base listing/#684 root expansion exclude these semantics. Closed local Canvas #17863/#17869 is not Cloud support.
No profile/configuration/Apps/automation expansion. Do not duplicate SDK primitives or put backend/version compatibility into Canvas. Live validation needs authorized disposable OHE user/org/repository/runtime fixtures and redacted evidence, never credentials/customer data. Filing does not authorize deployment or production testing.
Created by OpenHands (AI agent) on behalf of Graham Neubig.
Activity
juanmichelini commentedon Nov 4, 2026
@OpenHands please fix this. once you are done please label the PR with verify-this label
openhands-ai commentedon Nov 4, 2026
I'm on it! juanmichelini can track my progress at all-hands.dev
openhands-ai commentedon Nov 4, 2026
Fixed issue #853 ([OSS→OHE parity] Bounded tenant file discovery options and truthful listing results) and opened PR #1169, labeled
verify-thisas requested.What changed
New typed contract module
openhands/app_server/app_conversation/workspace_file_discovery.py(Enterprise producer side of the SDK contract, software-agent-sdk#6079):WorkspaceFileDiscoveryOptions,WorkspaceFileListing,FileDiscoveryStatus(ok/empty/missing/forbidden/command_error/timeout/invalid_response/transport_error).build_workspace_list_commandalways applies mandatory security/bookkeeping exclusions, sanitizes caller exclusion patterns (shell metacharacters,;, backticks,|,&, glob*/?rejected; quoted withshlex.quote→ no shell injection), clampsmax_filesto a server ceiling (2000), and overfetches by one so truncation is detectable and execution stays bounded.normalize_optionsis the single chokepoint that clamps corrupt/oversized stored values to the ceiling.Rewrote
list_conversation_filesto return the typed payload with discriminated statuses and HTTP codes (200 ok/empty, 404 missing, 403 forbidden, 502 command/invalid/transport, 504 timeout) plusis_truncated,max_files,excluded_dirs— instead of folding every nonzerofindexit into[]. Options come from query params and, when absent, from a user-persisted workspace-scoped preference.Persistence (tenant-safe): new nullable JSON
user_settings.workspace_file_discoverycolumn (migration 213), keyed by absolute working dir, loaded/stored only on the user's row (never the org) inSaasSettingsStore— so preferences cannot leak across tenants/org members. Stored values are normalized at read time.Acceptance criteria met
Tests
test_workspace_file_discovery.py(43 tests): normalization, injection safety, mandatory-exclusion independence, status classification, truncation.TestListConversationFiles(19 tests) for every status path, option override/sanitization, persisted-preference application + no cross-workspace leak, and the original regression.test_app_conversation_repository_selector.pyupdated for the new signature.SaasSettingsStoreround-trip + cross-tenant isolation tests.tests/unit/app_server,tests/unit/storage,tests/unit/test_saas_settings_store.py;pre-commit(ruff + mypy) clean.PR: #1169 (open, base
main, labelverify-this).juanmichelini commentedon Nov 17, 2026
In plain words
OSS: The file tree lets you choose which folders to skip, and says when the list is cut short or fails.
OHE: The file tree has a fixed skip list, stops at 2000 files without saying so, and shows an empty folder on errors.
This comment was posted by an AI agent (OpenHands) on behalf of juanmichelini, for the dev-coordinator status table on enterprise#1333.