Skip to content

Commit 1a8b09d

Browse files
shuvebclaude
andcommitted
Fix shared MarkdownViewer showing stale content when switching tabs
Tabs 1-3 (Spec, Prompt Plan, Notes) share a single MarkdownViewer widget. Cache each tab's content and re-apply it on tab switch so users see the correct content instead of whatever was last loaded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01f6e7a commit 1a8b09d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mfbt/tui/screens/feature_detail.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
self._sidebar_data: dict[str, Any] = {}
6262
self._active_tab = 1
6363
self._loaded_tabs: set[int] = set()
64+
self._tab_content: dict[int, str] = {}
6465

6566
def compose(self) -> ComposeResult:
6667
title = self._feature_data.get("title", "Feature Detail")
@@ -129,8 +130,10 @@ def _switch_tab(self, tab: int) -> None:
129130
impl_table.display = tab == 4
130131
conv_content.display = tab == 5
131132

132-
# Load content for the tab if not already loaded
133-
if tab not in self._loaded_tabs:
133+
# Tabs 1-3 share the MarkdownViewer, so re-apply cached content on switch
134+
if tab in (1, 2, 3) and tab in self._tab_content:
135+
viewer.content = self._tab_content[tab]
136+
elif tab not in self._loaded_tabs:
134137
self._loaded_tabs.add(tab)
135138
self.run_worker(lambda: self._load_tab_content(tab), thread=True)
136139

@@ -160,6 +163,7 @@ def _load_tab_content(self, tab: int) -> None:
160163
detail = self._data_provider.fetch_feature_detail(self._feature_id)
161164
text = detail.get("spec_text", "")
162165
content = text if text else "*No spec available*"
166+
self._tab_content[tab] = content
163167
self.app.call_from_thread(setattr, viewer, "content", content)
164168

165169
elif tab == 2: # Prompt Plan
@@ -172,6 +176,7 @@ def _load_tab_content(self, tab: int) -> None:
172176
detail = self._data_provider.fetch_feature_detail(self._feature_id)
173177
text = detail.get("prompt_plan_text", "")
174178
content = text if text else "*No prompt plan available*"
179+
self._tab_content[tab] = content
175180
self.app.call_from_thread(setattr, viewer, "content", content)
176181

177182
elif tab == 3: # Notes
@@ -181,6 +186,7 @@ def _load_tab_content(self, tab: int) -> None:
181186
self._feature_data.get("notes", ""),
182187
)
183188
content = text if text else "*No notes available*"
189+
self._tab_content[tab] = content
184190
self.app.call_from_thread(setattr, viewer, "content", content)
185191

186192
elif tab == 4: # Implementations

0 commit comments

Comments
 (0)