Skip to content

[BUG] Web UI session list stays empty when embedded in iframe, requires manual server/directory click to populate #36237

Closed as not planned

Description

@hithereiamaliff

Description

Description

When the OpenCode web UI is embedded in an iframe (e.g., via the opencode-chat VS Code extension), the session list in the sidebar stays empty on initial load, even though:

  • Sessions exist in the database (opencode.db)
  • The /api/session endpoint returns sessions correctly
  • The directory paths match exactly
  • session_directory_filter_enabled is set to false in kv.json

The sessions only appear after manually clicking the server icon, then clicking the project directory from the "Recent projects" list. This forces a re-bootstrap of the directory context, which triggers session loading.

Root Cause (Analysis)

This appears to be the same race condition described in #27837: the server.connected SSE event fires before the frontend's M.children (registered workspaces) is populated, so session loading never triggers automatically on initial render.

When embedded in an iframe, this race condition is more pronounced because:

  1. The iframe loads asynchronously
  2. The SSE connection may establish before the frontend state is ready
  3. There is no fallback mechanism to load sessions if the server.connected event is missed

Expected Behavior

Sessions should load automatically when the web UI initialises, regardless of whether it is running in a full browser window or embedded in an iframe.

Actual Behavior

Sessions stay hidden until the user manually re-triggers the directory bootstrap by clicking through the server and project flow.

Environment

  • OpenCode version: v1.17.18
  • OS: Debian (VPS, accessed via VS Code Remote SSH)
  • Terminal: VS Code webview iframe (via opencode-chat extension v2.11.0)
  • Database path: /root/.local/share/opencode/opencode.db

Evidence

API returns sessions correctly:

$ curl -s http://localhost:19084/api/session | python3 -m json.tool | head -20
{
    "data": [
        {
            "id": "ses_0b467cb71ffe4UAjw9AMgZwkWX",
            "title": "Find sessions command (@explore subagent)",
            "location": {
                "directory": "/root/vscodeprojects/tourwithalan"
            },
            ...
        }
    ]
}

Database query confirms sessions exist:

$ opencode db "SELECT id, title, directory FROM session ORDER BY time_created DESC LIMIT 5;"
ses_0b467cb71ffe4UAjw9AMgZwkWX  Find sessions command  /root/vscodeprojects/tourwithalan
ses_0b46fc404ffeA0NVja4RrPdD3N  Image visibility request  /root/vscodeprojects/tourwithalan
...

kv.json:

{"session_directory_filter_enabled": false}

Workaround

Manually click the server icon, then click the project from "Recent projects", and sessions appear.

Related Issues

Suggested Fix

Add a fallback mechanism: if M.children is empty when server.connected fires, retry session loading after a short delay or when the first workspace is registered. Alternatively, trigger session loading on first render regardless of SSE events.

Plugins

None

OpenCode version

v1.17.18

Steps to reproduce

  1. Install the opencode-chat VS Code extension (v2.11.0)
  2. Open a project folder in VS Code that has existing OpenCode sessions
  3. Open the OpenCode panel in the sidebar
  4. Observe: session list is empty, only "Build anything" screen is shown
  5. Click the server icon (top right, stacked rectangles)
  6. Click the project from "Recent projects"
  7. Sessions now appear in the sidebar

Screenshot and/or share link

Image Image Image

Operating System

Debian 12 (VPS, accessed via VS Code Remote SSH)

Terminal

VS Code webview iframe (via opencode-chat extension v2.11.0)

Activity

  1. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is specifically about the iframe/embedded context making the race condition more reproducible, that may be a distinct enough angle — but please comment on #27837 first to see if it covers your case.

  2. hithereiamaliff commented on Jul 10, 2026

    @hithereiamaliff
    Author

    Thanks for the duplicate check. I reviewed #27837, #10519, and #28340. My issue shares the same root cause as #27837 (SSE race condition: server.connected fires before M.children is populated), but I believe it's a distinct angle worth tracking separately because:

    1. Context: Web UI: session list empty on left panel when using web server mode #27837 reproduces in a full browser window. My issue only reproduces when the web UI is embedded in a VS Code webview iframe (via the opencode-chat extension). In a full browser on the same VPS, sessions load correctly.

    2. Trigger: The iframe embedding changes the timing characteristics enough to make the race condition always reproducible, whereas Web UI: session list empty on left panel when using web server mode #27837 in a full browser seems intermittent for some users.

    3. Workaround: Manually clicking the server icon, then clicking the project from "Recent projects" forces a re-bootstrap and sessions appear. This workaround isn't documented in Web UI: session list empty on left panel when using web server mode #27837.

    4. Environment: Debian VPS via VS Code Remote SSH (not Windows/WSL like Web UI: session list empty on left panel when using web server mode #27837), ruling out Windows path resolution as a factor.

    If the maintainers prefer to track this under #27837, I'm happy to close this as a duplicate. But I wanted to document the iframe-specific angle since it's a growing use case (VS Code extensions, desktop apps embedding the web UI, etc.) and the reproduction is 100% reliable in this context.

  3. github-actions commented on Sep 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions