GeezerVison is showing github.com — fix(app): read local images with the session location by anmol0b · Pull Request #58804 · anomalyco/opencode
Conversation
anmol0b
commented
Oct 24, 2026
•
edited by opencode-agent
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #58762
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
readLocalImage read absolute-path images with the image's parent folder as location[directory]. The server boots and persists any location it is given, so previewing /outside/eval/views.png added …/outside/eval as a project and started its watchers and every configured MCP server there. It also happened inside the project: /project/assets/x.png booted project/assets/ as a second location with its own MCP launch.
Now an absolute image under the session directory is read with the session's location and a path relative to it. An image outside the session directory is not requested, so it shows no preview and falls back to alt text, as an unreadable image already does. fs.read is confined to its location, so the app can't read an outside file without naming another location. Doing that without booting it would need a server-side change.
The session-ui component tests read C:/tmp/ and Z:/charts/ images with a C:/project session, so their paths now sit under the session.
Out of scope: the file viewer (workspaces/files/model.tsx) still uses the parent folder when a file outside the workspace is opened explicitly. #58795 covers evicted locations being booted again.
How did you verify your code works?
- The updated
image.test.ts cases fail on dev (6 of 42) and pass here. App unit tests, the session-ui read-image and markdown component tests, and bun run check pass.
- Ran the real
readLocalImage against opencode serve with a stub MCP server, one image outside the project and one absolute image inside it. On dev: 2 projects, 4 location boots, 4 MCP launches. With this change: 1 project, only the project location booted, 2 MCP launches, and the inside image still loads.
Screenshots / recordings
Not a UI change.
`` before: outside/eval/views.png -> image/png 67 bytes projects: outside/eval, project location services booted: project, outside/eval/, project/assets/ after: outside/eval/views.png -> not requested project/assets/inside.png -> image/png 67 bytes projects: project location services booted: project ``
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Related: #51003
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I ran the issue's reproduction against opencode serve from source on both checkouts, calling the real readLocalImage. On the base, previewing an outside image and an absolute image under project/assets/ booted both folders as locations and launched the MCP server 3 times. With this change only the project location boots (1 MCP launch), and the inside images still load through the project location with a relative path. image.test.ts passes (42/42), and its updated cases fail on the base. tsc -b in packages/app passes.
Public API: unchanged (client-side only).
The one trade-off worth a maintainer's call is that absolute images outside the session directory no longer preview at all (see inline). The path handling looks right: drive letters compare case-insensitively while the sent path keeps the file's casing, and trailing slashes, /, C:/ and sibling prefixes are handled.
Related: #51003
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new commit adds the follow-up note on the outside-image guard: these images are skipped until the server can read a file without booting a location. That covers my earlier point. The code is otherwise unchanged since my last review, so the earlier reproduction and test results still apply.
Public API: unchanged (client-side only).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
For me this guard would hide every read-image preview: across my last 80 sessions, 0 of 590 image reads were inside the session's directory (renders on another drive, agents writing to /tmp). And not persisting the project wouldn't be enough either: fs.read goes through the location's FileSystem, so any folder it names boots its plugins, watchers and MCP servers.
For read previews, could the image come from the stored tool result instead? The bytes are already in the message (the data #58586 drops from the timeline), so a route serving one tool file by URL would need no location at all, show what the model actually saw, and cover MCP images too (#21227). In-session reads through the session location, as here, still make sense for markdown images.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Hona @kitlangton could you advise on the direction here?
As @lsequeiraa points out, almost no read-image previews are inside the session directory, so the guard in this PR hides nearly all of them. Any folder fs.read names boots a full location, so there's no client-only fix that keeps outside previews without the boot. Options I see:
- Keep only the in-session part: images under the session directory use the session location (this stops subfolders like
project/assets/ booting as extra locations), and outside images use their parent folder again, as on dev. No preview regression, but the outside-folder boot from app: showing a local image registers its folder as a project #58762 stays.
- Keep the guard as it is: no stray locations, but outside images show no preview.
- Close this in favour of serving read previews from the stored tool result, which needs no location. That overlaps the timeline-image work in perf(app): open sessions without downloading read-tool images #58586.
Happy to update the PR to whichever you prefer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Outside images definitely need to still be previewable, I think kits solution is the way to go
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
Hona
Awaiting requested review from Hona
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|