Skip to content

[Bug]: Rendered-markdown view for a file in the right sidebar resets to source when you switch threads #4645

Description

@kristjaningi

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open a thread and open a .md file in the right-hand file preview panel.
  2. Click the eye toggle ("Show rendered markdown"). The panel switches to the
    rendered view.
  3. Switch to a different thread.
  4. Switch back to the original thread and open the same .md file.

Expected behavior

The panel is still showing rendered markdown. The view mode should be sticky —
once I've said I want to read markdown rendered, that's my preference until I
toggle it back.

Actual behavior

The panel is back to raw markdown source, and I have to click the toggle again
every time I return to the thread.

Impact

Minor bug or occasional failure

Version or commit

main @ 5719e8a

Environment

macOS 26.5.2, desktop app

Logs or stack traces

The toggle is backed by component-local state in `FilePreviewPanel`:

  apps/web/src/components/files/FilePreviewPanel.tsx:675
    const [markdownView, setMarkdownView] = useState<{
      path: string | null;
      revealRequestId: number | null;
    }>({ path: null, revealRequestId: null });

Nothing persists it, and it's invalidated two ways:

- `renderMarkdown` requires `markdownView.path === relativePath`
  (FilePreviewPanel.tsx:681), so any change of the open file drops back to
  source.
- The panel is mounted with `key={environmentId:workspaceRoot}`
  (ChatView.tsx:5588), so switching to a thread in another project remounts it
  and resets the state entirely.

The adjacent explorer-open toggle in the same component already persists via
`FILE_EXPLORER_STORAGE_KEY` in localStorage (FilePreviewPanel.tsx:701-711),
which looks like the precedent to follow here.

Screenshots, recordings, or supporting files

No response

Workaround

Click the toggle again each time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions