Skip to content

feat(tui): mermaid flowchart side panel (F key) via local LLM#142

Open
RonTuretzky wants to merge 2 commits into
mainfrom
RonTuretzky/mermaid-flowchart-mode
Open

feat(tui): mermaid flowchart side panel (F key) via local LLM#142
RonTuretzky wants to merge 2 commits into
mainfrom
RonTuretzky/mermaid-flowchart-mode

Conversation

@RonTuretzky

Copy link
Copy Markdown
Collaborator

Summary

  • New togglable side panel (F key) that renders the live conversation as a mermaid flowchart, refreshed every ~15s while recording.
  • Reuses the existing summarizer engine (summarization_model config — MLX on Apple Silicon or Ollama everywhere), so the same backend powers both the U-key summary and the F-key flowchart with no new dependencies.
  • Generated mermaid source displays as text in the terminal and is copy-pastable into any real mermaid renderer for a graphical view.

Test plan

  • With summarization_model unset on Apple Silicon: press F, confirm MLX default loads and flowchart populates.
  • With summarization_model=ollama:qwen3:0.6b: press F, confirm status line shows the model and panel updates after a few transcribed turns.
  • With Ollama unreachable: confirm panel shows the error message instead of crashing.
  • Toggle F off/on repeatedly — panel hides/shows and re-runs immediately on re-enable.

Adds a togglable side panel that periodically asks the configured local
LLM to render the live transcript as a mermaid flowchart. Reuses the
summarizer engine (MLX on Apple Silicon, Ollama via summarization_model
setting) so the same backend serves both U-key summaries and F-key
flowcharts. The panel renders mermaid source as text — readable in the
terminal, and copy-pastable into a real renderer for a graphical view.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional “Flowchart” side panel to the Textual TUI that renders the current conversation as LLM-generated Mermaid source, leveraging the existing local summarizer backend configuration.

Changes:

  • Introduces a new FlowchartPanel widget (hidden by default) to display Mermaid text + status.
  • Adds a local-LLM flowchart generator (generate_flowchart) built on the existing summarizer engine/templates.
  • Wires an F keybinding and a periodic refresh loop into tui/app.py, plus layout updates to host transcript + side panel.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

File Description
tui/widgets/flowchart.py New side panel widget for showing Mermaid source and status/error text.
tui/widgets/cyberpunk.tcss Adds a horizontal “transcript row” layout so the transcript can share space with the flowchart panel.
tui/llm/flowchart_gen.py New prompt/template + cleanup utilities for generating Mermaid flowchart source via the summarizer backend.
tui/app.py Adds F binding, panel composition, refresh timer, and background worker to generate/update flowcharts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tui/app.py Outdated
Comment on lines +2466 to +2469
@work(exclusive=True, thread=True, group="flowchart")
def _run_flowchart_worker(self, transcript_text: str, model_name: str) -> None:
try:
mermaid = generate_flowchart(transcript_text, model_name=model_name)
Comment thread tui/app.py
Comment on lines +2437 to +2442
def _maybe_refresh_flowchart(self):
if not self._flowchart_enabled or self._flowchart_inflight:
return
now = time.time()
if now - self._flowchart_last_run < self._flowchart_min_interval_sec:
return
Comment thread tui/widgets/flowchart.py Outdated

_PLACEHOLDER = (
"[#607080]waiting for transcript…[/]\n"
"[#445566]flowchart will refresh every few seconds[/]"
Comment thread tui/app.py Outdated
Comment on lines +2419 to +2422
if self._flowchart_enabled:
model = self._flowchart_model_name() or "MLX default"
panel.set_status(f"[#607080]idle · {model}[/]")
tp.system_message(f"flowchart mode ON ({model})", Log.SYS)
- Route MLX flowchart generation through _mlx_executor under
  _transcribe_lock (same as _run_summarize_and_export) so it can't
  overlap a transcribe or model-load on the GPU; skip the lock for
  Ollama since HTTP doesn't share the GPU.
- Show an honest backend label: "MLX default" only on Apple Silicon,
  otherwise prompt the user to set summarization_model to ollama:<model>.
- Update placeholder copy to mention the actual ~15s cadence.
- Document why _maybe_refresh_flowchart deliberately doesn't gate on
  _recording (P2P parties deliver turns while the local mic is paused).
@RonTuretzky

Copy link
Copy Markdown
Collaborator Author

Thanks @copilot-pull-request-reviewer — addressed all 4 in 0835a4d:

  1. MLX threading: _run_flowchart_worker now routes MLX work through self._mlx_executor.submit(...) under self._transcribe_lock, mirroring _run_summarize_and_export. Ollama (HTTP) skips the GPU lock so a slow Ollama call doesn't stall transcription every 15s.
  2. Refresh-while-recording wording: the signature check (transcript content changed?) is the real gate, not _recording — P2P parties deliver turns while the local mic is paused, and we want the flowchart to update for those. Added an inline comment in _maybe_refresh_flowchart explaining the choice.
  3. Placeholder copy: now says "refreshes roughly every 15 seconds", matching _flowchart_min_interval_sec.
  4. Backend label: new _flowchart_backend_label only says "MLX default" on Apple Silicon arm64; on other platforms with no summarization_model set, it shows "no LLM configured (set summarization_model to ollama:)".

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