Skip to content

[DBA-94] Fix plot propagation to previous messages#68

Closed
SimonKaran13 wants to merge 4 commits intomainfrom
simon.karan/DBA-94-fix-plot-propagates-to-previous-message
Closed

[DBA-94] Fix plot propagation to previous messages#68
SimonKaran13 wants to merge 4 commits intomainfrom
simon.karan/DBA-94-fix-plot-propagates-to-previous-message

Conversation

@SimonKaran13
Copy link
Member

Problem

When a user sends multiple queries that generate plots, new plots overwrite previously rendered messages. The root cause is that thread._visualization_result is a shared mutable singleton on the Thread object — every thread.plot() call overwrites it, so non-latest messages with has_visualization=True but no per-message visualization_data fall back to this shared state and render the wrong plot.

Solution

Restrict the shared thread fallback to the latest message only. Non-latest messages now render exclusively from their own persisted visualization_data. An allow_thread_fallback guard on render_visualization_section provides defense-in-depth, and a persistence fix ensures missing parquet files don't leave spec_df absent from the dict (which caused silent render failures).

Summary

  • Restrict thread._visualization_result fallback to the latest message only
  • Add allow_thread_fallback keyword-only parameter to render_visualization_section as defense-in-depth guard
  • Fix persistence round-trip in load_chat when _has_spec_df is True but parquet file is missing
  • Add diagnostic warning log when visualization_data is None after a successful thread.plot() call

Test plan

  • make check passes (ruff, mypy, agent guidance)
  • make test passes (pre-existing test_index failure only)
  • 9 new regression tests in tests/test_plot_propagation.py
  • Manual: send two queries that generate plots → first message's plot must not change after second completes
  • Manual: click "Generate Plot" on an older message → only that message gets the new plot
  • Manual: refresh browser → all plots render correctly for their respective messages

🤖 Generated with Claude Code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants