diff --git a/conductor/tracks/rag_support_20260308/plan.md b/conductor/tracks/rag_support_20260308/plan.md index 4018b34..f0ed41d 100644 --- a/conductor/tracks/rag_support_20260308/plan.md +++ b/conductor/tracks/rag_support_20260308/plan.md @@ -31,7 +31,7 @@ - [x] Task: Implement the RAG Settings panel in `src/gui_2.py`. f57e2fe - [x] Add UI controls for choosing the RAG source, embedding model, and retrieval parameters. f57e2fe - [x] Add a "Rebuild Index" button and status progress bar. f57e2fe -- [ ] Task: Implement retrieval visualization in the Discussion history. +- [~] Task: Implement retrieval visualization in the Discussion history. - [ ] Display "Retrieved Context" blocks with expandable summaries. - [ ] Add "Source" buttons to each block that open the file at the specific chunk's location. - [ ] Task: Implement auto-start/indexing status indicators in the GUI. diff --git a/src/gui_2.py b/src/gui_2.py index 5f32bdc..34ca5e0 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -2710,6 +2710,26 @@ def hello(): if read_mode: content = entry["content"] if content.strip(): + if '## Retrieved Context' in content: + rag_match = re.search(r'## Retrieved Context\n\n([\s\S]*?)(?=\n\n#|\Z)', content) + if rag_match: + rag_section = rag_match.group(1) + if imgui.collapsing_header('Retrieved Context'): + chunks = re.finditer(r'### Chunk (\d+) \(Source: (.*?)\)\n([\s\S]*?)(?=\n### Chunk|\Z)', rag_section) + for chunk_match in chunks: + idx = chunk_match.group(1) + path = chunk_match.group(2) + chunk_content = chunk_match.group(3) + if imgui.collapsing_header(f'Chunk {idx}: {path}'): + if imgui.button(f'[Source]##rag_{i}_{idx}'): + res = mcp_client.read_file(path) + if res: + self.text_viewer_title = path + self.text_viewer_content = res + self.text_viewer_type = Path(path).suffix.lstrip('.') if Path(path).suffix else 'text' + self.show_text_viewer = True + imgui.text_unformatted(chunk_content) + content = content[:rag_match.start()] + content[rag_match.end():] pattern = re.compile(r"\[Definition: (.*?) from (.*?) \(line (\d+)\)\](\s+```[\s\S]*?```)?") matches = list(pattern.finditer(content)) is_nerv = theme.is_nerv_active()