GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(app): read local images with the session location by anmol0b · Pull Request #58804 · anomalyco/opencode

Conversation

@anmol0b

@anmol0b anmol0b commented Oct 24, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
@anmol0b
fix(app): read local images with the session location
a0e68e2
@anmol0b
anmol0b requested review from Brendonovich and Hona as code owners October 24, 2026 21:34
@github-actions github-actions Bot added the contributor label Oct 24, 2026
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
Comment thread packages/app/src/runtime/server/image.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@anmol0b
fix(app): note the server read needed for outside image previews
109e189
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@lsequeiraa

lsequeiraa commented Oct 25, 2026

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anmol0b

anmol0b commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@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:

  1. 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.
  2. Keep the guard as it is: no stray locations, but outside images show no preview.
  3. 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tarquinen

Tarquinen commented Oct 27, 2026

Copy link
Copy Markdown
Member

Outside images definitely need to still be previewable, I think kits solution is the way to go

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tarquinen Tarquinen closed this Oct 27, 2026
@lsequeiraa lsequeiraa mentioned this pull request Oct 27, 2026
perf(app): open sessions without downloading read-tool images #58586
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments
@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

app: showing a local image registers its folder as a project

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@anmol0b @lsequeiraa @Tarquinen
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.