Skip to content

fix(app-conversation): list the /workspace root in the Files endpoint - #684

Open
jpshackelford wants to merge 1 commit into
mainfrom
feat/files-list-workspace-root
Open

jpshackelford wants to merge 1 commit into
mainfrom
feat/files-list-workspace-root

Conversation

@jpshackelford

@jpshackelford jpshackelford commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

  • A human has tested these changes.

Tested by an AI agent working for me, on a Replicated fleet VM (shared-6) running a preview build of this PR (ghcr.io/openhands/enterprise-server:sha-485d6ab). Results are under "Tested on a fleet VM" in How to Test

AGENT:

Merge order: merge this PR first and deploy it, then merge the companion UI PR OpenHands/OpenHands#18109.
The UI PR is what asks for the /workspace listing. This change alone is backward compatible: today's UI keeps sending /workspace/project and gets exactly what it gets now. Deploying the UI PR before this one makes the Files tab list the project dir but try to read files from /workspace/<path>, so file contents fail to load for conversations with no repo.


Why

The Files tab lists a cloud conversation's files through GET /api/v1/app-conversations/{id}/files, and that endpoint only ever lists {sandbox spec working_dir}[/{repo}], which is /workspace/project by default. When no repo is selected the agent often clones or writes straight into /workspace, so those files never show up and the UI says "No files in workspace".

The endpoint now also accepts the exact path /workspace as the directory to list, but only when the sandbox's project dir is under /workspace, so no other path outside the project dir is ever accepted. When /workspace is listed, the agent server's own conversations/, bash_events/ and worktrees/ directories are skipped. Requests for /workspace/project (what the current UI sends) behave as before.

Summary

  • _resolve_workspace_dir accepts /workspace as an extra root; _build_workspace_list_command can prune named top-level directories, used for the agent-server state dirs.
  • _resolve_file_path re-anchors /workspace/... under the project dir only for sandbox specs whose project dir is not under /workspace. For the default spec, /workspace/foo/a.py is read where it is.
  • Unit tests for the new root, the safety checks (siblings, /, .., specs outside /workspace) and the read-path rules.

Issue Number

Companion to OpenHands/OpenHands#18108, which tracks the user-visible bug (there is no separate issue in this repo).

How to Test

Unit tests (the root conftest.py starts a Postgres container that these tests do not use, hence --noconftest):

uv sync --frozen
uv run --frozen pytest --noconftest tests/unit/app_server/test_app_conversation_router.py
# 98 passed

Against a real sandbox on a staging Enterprise instance (conversation with no repo, deployed backend without this change):

# in the conversation's sandbox
mkdir -p /workspace/repro-demo/src && echo hi > /workspace/repro-demo/src/hello.txt

# before: the deployed endpoint ignores /workspace and lists only the project dir (which holds just .git)
GET /api/v1/app-conversations/{id}/files?path=/workspace/project  -> []
GET /api/v1/app-conversations/{id}/files?path=/workspace          -> []

The new find command, built by _build_workspace_list_command(_WORKSPACE_ROOT_STATE_DIRS) and sent through the sandbox agent server's POST /api/bash/execute_bash_command with cwd=/workspace (the call the endpoint makes), returned exit_code: 0 and ./repro-demo/src/hello.txt, with conversations/, bash_events/ and the project dir's .git left out.

After deploying, repeat the two GET calls above: path=/workspace should now return ["repro-demo/src/hello.txt"], and path=/workspace/project should be unchanged.

Video/Screenshots

Backend-only change, so there is nothing to screenshot here. The UI before/after is on the companion PR.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • Not changed here, and tracked in the next comment on this PR: conversations started with a sandbox grouping strategy other than NO_GROUPING are not resolved by this endpoint, and a failed listing (for example a missing directory) still returns [].
  • With a repository selected the UI keeps asking for the repo clone, so files the agent writes elsewhere under /workspace stay hidden in that case.
  • Paths returned for /workspace are relative to /workspace, so the project dir's files appear as project/....

This PR was drafted by an AI agent on behalf of the user.


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-d0da885

@jpshackelford

jpshackelford commented Oct 7, 2026 •

Copy link
Copy Markdown
Member Author

Intentionally not fixed in this PR

Two problems exist in the files endpoint today and are not fixed here. Neither is made worse by this PR; the table says what this PR changes for each case, and the sections below have what is wrong, a way to reproduce it, and what a fix should do, so they can be filed as follow-on issues.

Case Before this PR With this PR and OpenHands/OpenHands#18109 Worse?
Grouping on, repo selected []: the endpoint lists /workspace/project/<repo>, which does not exist Same. The UI still asks for the repo clone and the endpoint resolves it the same way No, unchanged
Grouping on, no repo Lists /workspace/project: one <hex>/ directory per conversation in the sandbox Lists /workspace: project/<hex>/... plus anything else the agents wrote under /workspace No, but the listing is wider (see below)
Any listing that fails (missing directory, failed command) [] with HTTP 200 Same for the same requests. The new /workspace root always exists, so it cannot hit this path No, unchanged

What "wider" means for grouping on, no repo. The old listing already showed the other conversations' <hex>/ directories. The new one also shows files outside /workspace/project, which is the point of the change, and it makes the grouped layout look less broken because the tree is no longer empty. It does not fix the mismatch: the tab shows every conversation's files in that sandbox, not just the current one. Grouping is a per-user setting (sandbox_grouping_strategy). I did not check whether any strategy puts different users in one sandbox; if one does, the /workspace root would show more of it than the project dir did.

What the testing on shared-6 says about these findings (details in the "Tested on a fleet VM" comment on this PR):

  • Problem 2 is confirmed live on this PR's build. A missing directory inside the project dir returned [] with HTTP 200, with and without a repo selected. This is the same behaviour as the earlier check on the staging instance.
  • Problem 1 is neither confirmed nor ruled out. shared-6 runs NO_GROUPING and I did not run a conversation with grouping on. What the test does show is that the ungrouped layout is what the offline script assumes: a repo conversation cloned into /workspace/project/Hello-World, the conversation has archiveworkspacepath=/workspace/project, and the endpoint listed the clone correctly. That matches the two OK rows in the script output below and does not touch the two MISMATCH rows.
  • "Repo selected, grouping on, returns []" combines two pieces. The grouped path mismatch is from the offline script, and a missing directory returning [] is live-verified. The combination has not been run end to end.
  • Correction to an earlier check. path=/workspace/nonexistent does not test problem 2, because paths outside the project dir fall back to the project dir listing instead of being listed. Use a path under the project dir, as in the reproduction below.

1. Conversations with sandbox grouping enabled resolve to the wrong directory

What is wrong. When the user's sandbox_grouping_strategy is anything other than NO_GROUPING, a conversation's workspace is nested under its id: /workspace/project/<conversation-id-hex>[/<repo>] (grouped_workspace_dir in openhands/app_server/settings/settings_models.py, used by live_status_app_conversation_service.py when the conversation starts). list_conversation_files and _resolve_workspace_dir in app_conversation_router.py never call it. They always compute get_project_dir(sandbox_spec.working_dir, selected_repository), which is the ungrouped layout.

Effect.

  • Repo selected: the endpoint lists /workspace/project/<repo>, which does not exist. The listing command fails and the endpoint returns [], so the tab says "No files in workspace" (see problem 2 for why it is silent).
  • No repo selected: the endpoint lists /workspace/project, which contains one <hex>/ directory per conversation sharing the sandbox, so the tab shows other conversations' files too.
  • Both effects exist before this PR. This PR changes only the no-repo listing, to the wider one described above.

Reproduce offline (no instance needed). Run from an OpenHands/enterprise checkout as uv run python grouping_repro.py. The output below was produced on 7cfd35b; the current head 485d6ab differs from it only by a ruff format rewrap. It compares the directory the conversation really uses with the directory the endpoint resolves:

from types import SimpleNamespace
from uuid import uuid4

from openhands.app_server.app_conversation.app_conversation_router import _resolve_workspace_dir
from openhands.app_server.app_conversation.app_conversation_service_base import get_project_dir
from openhands.app_server.settings.settings_models import SandboxGroupingStrategy, grouped_workspace_dir

SPEC_WORKING_DIR = '/workspace/project'
conv_id = uuid4()
for strategy in (SandboxGroupingStrategy.NO_GROUPING, SandboxGroupingStrategy.GROUP_BY_NEWEST):
    for repo in (None, 'OpenHands/software-agent-sdk'):
        actual = get_project_dir(grouped_workspace_dir(SPEC_WORKING_DIR, strategy, conv_id.hex), repo)
        ctx = SimpleNamespace(
            sandbox_spec=SimpleNamespace(working_dir=SPEC_WORKING_DIR),
            conversation=SimpleNamespace(selected_repository=repo),
        )
        listed = _resolve_workspace_dir(None, ctx)
        flag = 'OK      ' if actual == listed else 'MISMATCH'
        print(f'{flag} {strategy.value:15} repo={str(repo):30} actual={actual}  listed={listed}')

Output:

OK       NO_GROUPING     repo=None                           actual=/workspace/project  listed=/workspace/project
OK       NO_GROUPING     repo=OpenHands/software-agent-sdk   actual=/workspace/project/software-agent-sdk  listed=/workspace/project/software-agent-sdk
MISMATCH GROUP_BY_NEWEST repo=None                           actual=/workspace/project/3e7a98df43e74d428f805899c7b9f902  listed=/workspace/project
MISMATCH GROUP_BY_NEWEST repo=OpenHands/software-agent-sdk   actual=/workspace/project/3e7a98df43e74d428f805899c7b9f902/software-agent-sdk  listed=/workspace/project/software-agent-sdk

Not reproduced on a live instance. The live steps are: set sandbox_grouping_strategy to GROUP_BY_NEWEST on the user's settings, start a conversation with a repository selected, run ls /workspace/project/* in the sandbox (the clone is under a 32-character hex directory), then call GET /api/v1/app-conversations/{id}/files and expect []. For the no-repo case, start two conversations in the same sandbox and expect each one's listing to include the other's <hex>/ directory.

What a fix should do. Stop re-deriving the directory. Either use the conversation's real working dir (the agent server returns it as workspace.working_dir on GET /api/conversations/{id}), or recompute it with grouped_workspace_dir(...) using the user's strategy at conversation start. The archiveworkspacepath tag (ARCHIVE_WORKSPACE_PATH_TAG_KEY in app_conversation_models.py) already pins the path used at archive time and is a third option. Acceptance: with grouping on and a repo selected, GET .../files returns the clone's files; with grouping on and no repo, it returns only that conversation's files.

2. A failed listing is returned as an empty list

What is wrong. list_conversation_files runs find through the agent server's POST /api/bash/execute_bash_command, and when exit_code != 0 it returns [] with HTTP 200 (around line 1844 of app_conversation_router.py, commented "nothing to list rather than an error"). A directory that does not exist makes the agent server return exit_code: -1, so a missing directory, a failed command and an empty directory are indistinguishable to the UI, which renders all three as "No files in workspace".

Reproduce on a live instance (verified twice). First on a staging Enterprise instance running agent-server 1.50.1, without this PR, on a conversation whose /workspace/project contains only .git (the listing prunes .git). Then on a fleet VM running this PR's build (sha-485d6ab), where /workspace/project/does-not-exist returned [] with HTTP 200 for a no-repo conversation, and /workspace/project/Hello-World/does-not-exist returned the same for a repo conversation:

# $CLOUD = backend host, $ID = conversation id, $KEY = API key
curl -s -w ' (HTTP %{http_code})\n' -H "Authorization: Bearer $KEY" "$CLOUD/api/v1/app-conversations/$ID/files?path=/workspace/project"
curl -s -w ' (HTTP %{http_code})\n' -H "Authorization: Bearer $KEY" "$CLOUD/api/v1/app-conversations/$ID/files?path=/workspace/project/does-not-exist"

Both print [] (HTTP 200). Renaming /workspace/project away inside the sandbox before the first call gives the same result. The path must be under the project dir: other paths fall back to the project dir listing and do not fail.

What a fix should do. Return a distinguishable result when the command fails, for example a 404 for a missing directory and a 5xx (or an explicit error field) for any other non-zero exit, and have the Files tab show an error or "workspace not found" state instead of the empty state. Acceptance: the two requests above return different responses, and the UI shows different text for them.


The user-facing bug, the UI change and the merge order are in OpenHands/OpenHands#18108 and OpenHands/OpenHands#18109.

This comment was drafted by an AI agent on behalf of the user.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  openhands/app_server/app_conversation
  app_conversation_router.py
Project Total  

This report was generated by python-coverage-comment-action

@jpshackelford
jpshackelford marked this pull request as ready for review October 7, 2026 15:57
@jpshackelford

Copy link
Copy Markdown
Member Author

Tested on a fleet VM

This PR's image (ghcr.io/openhands/enterprise-server:sha-485d6ab, head of this PR) was deployed to Replicated fleet instance shared-6 through a throwaway branch channel of OpenHands-Cloud (image.tag: sha-485d6ab, installed with the infra replicated_fleet.yaml clean-install). /server_info reports app_version 1.69.0 and sdk_version 1.50.1, and the user setting sandbox_grouping_strategy is NO_GROUPING. I did not read the image tag on the VM; that the new code is running follows from path=/workspace returning files, which the unpatched staging instance answered with [].

All calls below use GET /api/v1/app-conversations/{id}/files or .../file with a user API key.

No repo selected

An agent in a no-repo conversation ran mkdir -p /workspace/repro-demo/src && echo hello > /workspace/repro-demo/src/hello.txt && echo top > /workspace/top.txt.

Request Result
files?path=/workspace ["repro-demo/src/hello.txt","top.txt"] (was [] before this change)
files?path=/workspace/project [], unchanged
file?file_path=/workspace/repro-demo/src/hello.txt "hello\n"
file?file_path=/workspace/top.txt "top\n"

The /workspace listing does not include the agent server's conversations/, bash_events/ or worktrees/ directories.

Repo selected (octocat/Hello-World, a public repo)

An agent in that conversation ran echo outside > /workspace/outside-repo.txt.

Request Result
files?path=/workspace/project ["README"]
files?path=/workspace/project/Hello-World ["README"]
files?path=/workspace ["outside-repo.txt","project/Hello-World/README"]

The clone is at /workspace/project/Hello-World and the conversation carries archiveworkspacepath=/workspace/project, which is the ungrouped layout this endpoint assumes. I did not compare the repo-selected requests against an unpatched backend. The statement that they are unchanged rests on the code path: the paths the current UI sends resolve to the same directory as before.

Failed listings

Conversation Request Result
no repo files?path=/workspace/project/does-not-exist [] (HTTP 200)
repo selected files?path=/workspace/project/Hello-World/does-not-exist [] (HTTP 200)

A missing directory inside the project dir returns the same [] as an empty one, as described in the second item of the deferred-items comment. Paths outside the project dir are not errors either: files?path=/workspace/nonexistent falls back to the project dir ([] with no repo, ["README"] with a repo), so it does not exercise the failure path.

UI

OpenHands/OpenHands#18109 (c13d47a) was run locally against this backend. With no repo the Files tab lists repro-demo and top.txt and opens hello.txt; with the repo it shows only the clone's README, which opens. Screenshots are on that PR.

Not tested

  • The merge-order failure described at the top of this PR (new UI against an old backend). I did not reproduce it.
  • Any sandbox_grouping_strategy other than NO_GROUPING. See the deferred-items comment.
  • A repo-selected conversation on an unpatched backend, for a direct before/after comparison.

This comment was drafted by an AI agent on behalf of the user.

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Thank you for the thorough write-up and for testing this on shared-6. The results made the change easy to follow. The overall approach looks good to me: a single, explicit /workspace exception, pruning the agent-server state dirs only at the top level, and no change for the paths today's UI sends. I also ran the new find command against a scratch tree, and it prunes conversations/, bash_events/ and worktrees/ only at the top level while keeping a nested src/conversations/, as intended.

I've marked two items as blocking, though I'm happy to discuss either of them:

  1. Limiting the /workspace exception to conversations without a repo, since reads don't round-trip when a repo is selected.
  2. Normalizing path so .. can't get past the guard or the new pruning, with test cases to match.

The remaining comments are non-blocking suggestions, so please feel free to address them here or in a follow-up, whichever you prefer.

On the open question in your deferred-items comment: grouped sandboxes are only reused across the same user's conversations (_find_running_sandbox_for_user filters on sandbox.created_by_user_id == user_id), so the wider /workspace listing shouldn't expose another user's files.

Thank you very much 🙏

# ancestor of the project dir, so agents that write outside the project dir
# (e.g. clone straight into ``/workspace``) still show up. Only the root
# itself is accepted, never an arbitrary sibling.
if path.rstrip('/') == _WORKSPACE_ROOT and _is_within(project_dir, _WORKSPACE_ROOT):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Blocking: I noticed this also accepts /workspace when a repository is selected, and the shared-6 run shows the listing working (["outside-repo.txt","project/Hello-World/README"]). Reading some of those entries back may not work as expected, though. _resolve_file_path still treats working_dir (/workspace/project) as a stale root, so a listed file under /workspace/project but outside the clone gets re-anchored into the clone:

  • /workspace/project/notes.md is read as /workspace/project/Hello-World/notes.md, so the result is empty.
  • /workspace/project/README is read as /workspace/project/Hello-World/README, so the tab would show the repo's README for a different file.

The second case concerns me a bit more, since it returns different content with no error. The companion UI only sends /workspace when there's no repo, so nothing should hit this today. Since the endpoint allows it, though, would it make sense to limit the exception to conversations without a selected repository? That way the listing never returns paths the read endpoint can't serve:

if (
    path.rstrip('/') == _WORKSPACE_ROOT
    and not ctx.conversation.selected_repository
    and _is_within(project_dir, _WORKSPACE_ROOT)
):
    return _WORKSPACE_ROOT

A test for the repo case (expecting the clone dir) would help keep it that way. If you'd prefer to keep /workspace open for repo conversations, I think _resolve_file_path would first need a way to tell a real /workspace/project/... path apart from the stale frontend root. Happy to talk through either option.

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d0da885. /workspace is now only honored when the conversation has no selected repository (and no repository override), using your suggested condition. With a repo it falls back to the clone dir. Added test_workspace_root_is_not_accepted_when_repository_is_selected.

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

base = project_dir.rstrip('/')
normalized = path.rstrip('/')
if normalized == base or normalized.startswith(base.rstrip('/') + '/'):
if _is_within(path, project_dir):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Blocking: would it be possible to normalize path before this check? It's currently a plain string-prefix match, so anything that starts with the project dir is returned as-is and becomes the agent server's cwd, which isn't normalized on that side either:

  • /workspace/project/.. is accepted and lists /workspace. Because cwd isn't literally /workspace, the new conversations/ / bash_events/ / worktrees/ pruning is skipped.
  • /workspace/project/../../etc is accepted and lists /etc.

Since it's the caller's own sandbox, I don't think this is a cross-user issue. It does, however, weaken the "never lists outside the workspace" guarantee in the docstring and lets requests skip the pruning this PR adds. A single line at the top should address both, and it keeps the cwd.rstrip('/') == _WORKSPACE_ROOT check in list_conversation_files reliable:

if not path:
    return project_dir
path = posixpath.normpath(path)  # sandbox paths are always POSIX

With that change, /workspace/project/.. resolves to /workspace (pruned), /workspace/project/../../etc falls back to the project dir, and trailing slashes are dropped. As far as I can tell, none of the existing tests rely on the raw string being echoed back.

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. path is now passed through posixpath.normpath right after the empty check. /workspace/project/.. resolves to /workspace (pruned), /workspace/project/../../etc falls back to the project dir, and /workspace/ is accepted via the normalized form.

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

uuid4(), working_dir='/workspace/project', selected_repository=None
)

for bad in ('/workspace/other', '/', '/workspace/../etc'):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Blocking (pairs with the normalization fix): it looks like /workspace/../etc is rejected only because it doesn't start with /workspace/project/, so this loop doesn't quite exercise the .. handling. Could we add /workspace/project/../../etc here? It's currently accepted and lists /etc. A separate assertion for /workspace/project/.. would also be useful: once the path is normalized, it should resolve to /workspace with the state dirs pruned. Today it lists the workspace root without pruning (I've added more detail in my comment on _resolve_workspace_dir).

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added /workspace/project/../../etc to the rejected paths, plus test_dotdot_to_workspace_root_is_normalized_and_pruned (/workspace/project/.. -> cwd /workspace with conversations pruned) and a trailing-slash case.

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

stale_roots.append(f'{working_dir}/project/{repo_name}')
stale_roots.append(f'{working_dir}/project')
stale_roots.append(working_dir)
if not _is_within(project_dir, _WORKSPACE_ROOT):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Non-blocking: this nicely fixes the no-repo case for specs outside /workspace, though I think the repo case on those specs still doesn't resolve correctly. The UI requests /workspace/project/<repo>, which falls back to the clone, so the listing is relative to the clone. The read of /workspace/project/<repo>/a.py then matches /workspace here and becomes {project_dir}/project/<repo>/a.py, for example /home/openhands/workspace/r/project/r/a.py for repo o/r.

Adding /workspace/project[/<repo>] as stale roots would fix that case, but it would break a no-repo project that really has a project/ dir, since /workspace/project/x.py would then be stripped to {project_dir}/x.py. The stale-root list has to guess which root the listing used, and I couldn't find a combination that is always right. I suspect the same guessing is behind the merge-order caveat in the description. Longer term, it might be cleaner for list_conversation_files to report the directory it actually listed, for example in an X-Workspace-Root response header, which keeps the list[str] body unchanged. The UI could then build read paths from it. This read also failed before this PR, so a follow-up issue next to the two you already listed seems perfectly fine.

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and thanks for working through the stale-root options. Leaving this out of this PR: it is the same root-guessing problem as the merge-order caveat, and the read failed before this change too. Reporting the listed directory (e.g. an X-Workspace-Root header) looks like the right follow-up issue.

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

# Agent-server bookkeeping that lives beside the project dir (see the sandbox
# ``/api/init`` bodies). It is runtime state, not user files, so it is pruned
# when the whole workspace root is listed.
_WORKSPACE_ROOT_STATE_DIRS = ('conversations', 'bash_events', 'worktrees')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Non-blocking: these three names duplicate the paths the sandbox services set up. In E2B and K8s they come from {workspace_dir}/conversations|bash_events|worktrees in _build_init_request. In the Docker and remote default specs they are OH_CONVERSATIONS_PATH / OH_BASH_EVENTS_DIR (the comment currently points only at the /api/init bodies). If either side renames a dir later, the Files tab could quietly start listing agent-server state, including persisted conversation events, without any test failing. What do you think about sharing the names through one constant used in both places? Alternatively, a test that builds an init body and checks every state path is covered by _WORKSPACE_ROOT_STATE_DIRS would catch it.

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Leaving it for a follow-up so this PR does not touch the sandbox services: either a shared constant, or a test that builds each init body and checks its state paths are covered by _WORKSPACE_ROOT_STATE_DIRS.

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

if normalized == base or normalized.startswith(base.rstrip('/') + '/'):
if _is_within(path, project_dir):
return path
# The sandbox workspace root is the one deliberate exception: it is an

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jpshackelford,

Non-blocking (nit): the docstring above still says path is honored only when it is the project dir or a descendant of it, and the path query description on list_conversation_files says much the same. Now that the UI relies on the /workspace exception, and results for it are relative to /workspace (so project files come back as project/...), would you mind mentioning it in both places? That way the contract is also visible in the OpenAPI docs.

Thank you very much 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The _resolve_workspace_dir docstring and the path query description now describe the /workspace exception (no-repo conversations only, results relative to /workspace, project files as project/...).

This reply was written by an AI agent (OpenHands) on behalf of @jpshackelford.

… endpoint

The endpoint only ever listed {spec.working_dir}[/{repo}], so files agents
write elsewhere under /workspace were invisible. Accept the exact /workspace
root (pruning agent-server state dirs) and keep file reads rooted correctly.

Co-authored-by: openhands <openhands@all-hands.dev>
@jpshackelford
jpshackelford force-pushed the feat/files-list-workspace-root branch from 4e8cffa to d0da885 Compare November 5, 2026 20:37
@jpshackelford

Copy link
Copy Markdown
Member Author

Rebased onto current main; the old merge commit and the separate ruff-format commit are folded into one commit, and the new guard respects the repository parameter added on main. Addressed both blocking items from @hieptl's review and the docstring nit: /workspace is now limited to conversations without a selected repository, and path is normalized before the guard, with tests for both. The other two non-blocking items are left for follow-ups. tests/unit/app_server/test_app_conversation_router.py: 101 passed (run with --noconftest, since this sandbox has no Docker for the postgres fixture).

This comment was written by an AI agent (OpenHands) on behalf of @jpshackelford.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants