Private
Public Access
markdown fix but introduces a regresssion...
This commit is contained in:
+37
-43
@@ -3320,40 +3320,37 @@ def render_context_presets(app: App) -> None:
|
|||||||
app.ui_active_context_preset = ""
|
app.ui_active_context_preset = ""
|
||||||
|
|
||||||
def render_snapshot_tab(app: App) -> None:
|
def render_snapshot_tab(app: App) -> None:
|
||||||
if imgui.begin_tab_bar("snapshot_tabs"):
|
with imscope.tab_bar("snapshot_tabs"):
|
||||||
if imgui.begin_tab_item("Aggregate MD")[0]:
|
with imscope.tab_item("Aggregate MD") as (exp, _):
|
||||||
display_md = app.last_aggregate_markdown
|
if exp:
|
||||||
if app.ui_focus_agent:
|
display_md = app.last_aggregate_markdown
|
||||||
tier_usage = app.mma_tier_usage.get(app.ui_focus_agent)
|
if app.ui_focus_agent:
|
||||||
if tier_usage:
|
tier_usage = app.mma_tier_usage.get(app.ui_focus_agent)
|
||||||
persona_name = tier_usage.get("persona")
|
if tier_usage:
|
||||||
if persona_name:
|
persona_name = tier_usage.get("persona")
|
||||||
persona = app.controller.personas.get(persona_name)
|
if persona_name:
|
||||||
if persona and persona.context_preset:
|
persona = app.controller.personas.get(persona_name)
|
||||||
cp_name = persona.context_preset
|
if persona and persona.context_preset:
|
||||||
if cp_name in app._focus_md_cache:
|
cp_name = persona.context_preset
|
||||||
display_md = app._focus_md_cache[cp_name]
|
if cp_name in app._focus_md_cache:
|
||||||
else:
|
display_md = app._focus_md_cache[cp_name]
|
||||||
flat = src.project_manager.flat_config(app.controller.project, app.active_discussion)
|
else:
|
||||||
cp = app.controller.project.get('context_presets', {}).get(cp_name)
|
flat = src.project_manager.flat_config(app.controller.project, app.active_discussion)
|
||||||
if cp:
|
cp = app.controller.project.get('context_presets', {}).get(cp_name)
|
||||||
flat["files"]["paths"] = cp.get("files", [])
|
if cp:
|
||||||
flat["screenshots"]["paths"] = cp.get("screenshots", [])
|
flat["files"]["paths"] = cp.get("files", [])
|
||||||
full_md, _, _ = src.aggregate.run(flat)
|
flat["screenshots"]["paths"] = cp.get("screenshots", [])
|
||||||
app._focus_md_cache[cp_name] = full_md
|
full_md, _, _ = src.aggregate.run(flat)
|
||||||
display_md = full_md
|
app._focus_md_cache[cp_name] = full_md
|
||||||
if imgui.button("Copy"): imgui.set_clipboard_text(display_md)
|
display_md = full_md
|
||||||
imgui.begin_child("last_agg_md", imgui.ImVec2(0, 0), True)
|
if imgui.button("Copy"): imgui.set_clipboard_text(display_md)
|
||||||
markdown_helper.render(display_md, context_id="snapshot_agg")
|
with imscope.child("last_agg_md", 0, 0, True):
|
||||||
imgui.end_child()
|
markdown_helper.render(display_md, context_id="snapshot_agg")
|
||||||
imgui.end_tab_item()
|
with imscope.tab_item("System Prompt") as (exp, _):
|
||||||
if imgui.begin_tab_item("System Prompt")[0]:
|
if exp:
|
||||||
if imgui.button("Copy"): imgui.set_clipboard_text(app.last_resolved_system_prompt)
|
if imgui.button("Copy"): imgui.set_clipboard_text(app.last_resolved_system_prompt)
|
||||||
imgui.begin_child("last_sys_prompt", imgui.ImVec2(0, 0), True)
|
with imscope.child("last_sys_prompt", 0, 0, True):
|
||||||
markdown_helper.render(app.last_resolved_system_prompt, context_id="snapshot_sys")
|
markdown_helper.render(app.last_resolved_system_prompt, context_id="snapshot_sys")
|
||||||
imgui.end_child()
|
|
||||||
imgui.end_tab_item()
|
|
||||||
imgui.end_tab_bar()
|
|
||||||
|
|
||||||
#endregion: Context Management
|
#endregion: Context Management
|
||||||
|
|
||||||
@@ -3375,9 +3372,8 @@ def render_discussion_hub(app: App) -> None:
|
|||||||
if exp:
|
if exp:
|
||||||
if imgui.button("Copy to Clipboard"):
|
if imgui.button("Copy to Clipboard"):
|
||||||
imgui.set_clipboard_text(app.context_preview_text)
|
imgui.set_clipboard_text(app.context_preview_text)
|
||||||
imgui.begin_child("ctx_preview_scroll_tab", imgui.ImVec2(0, 0), True)
|
with imscope.child("ctx_preview_scroll_tab", 0, 0, True):
|
||||||
markdown_helper.render(app.context_preview_text, context_id="ctx_preview_tab")
|
markdown_helper.render(app.context_preview_text, context_id="ctx_preview_tab")
|
||||||
imgui.end_child()
|
|
||||||
with imscope.tab_item("Snapshot") as (exp, opened):
|
with imscope.tab_item("Snapshot") as (exp, opened):
|
||||||
if exp: render_snapshot_tab(app)
|
if exp: render_snapshot_tab(app)
|
||||||
with imscope.tab_item("Takes") as (exp, opened):
|
with imscope.tab_item("Takes") as (exp, opened):
|
||||||
@@ -4461,9 +4457,8 @@ def render_approve_script_modal(app: App) -> None:
|
|||||||
|
|
||||||
avail_y = imgui.get_content_region_avail().y - 40 # reserve space for buttons
|
avail_y = imgui.get_content_region_avail().y - 40 # reserve space for buttons
|
||||||
if app.ui_approve_modal_preview:
|
if app.ui_approve_modal_preview:
|
||||||
imgui.begin_child("preview_child", imgui.ImVec2(-1, avail_y), True)
|
with imscope.child("preview_child", -1, avail_y, True):
|
||||||
markdown_helper.render(f"```powershell\n{dlg._script}\n```", context_id="approve_script_preview")
|
markdown_helper.render(f"```powershell\n{dlg._script}\n```", context_id="approve_script_preview")
|
||||||
imgui.end_child()
|
|
||||||
else:
|
else:
|
||||||
ch, dlg._script = imgui.input_text_multiline("##confirm_script", dlg._script, imgui.ImVec2(-1, avail_y))
|
ch, dlg._script = imgui.input_text_multiline("##confirm_script", dlg._script, imgui.ImVec2(-1, avail_y))
|
||||||
imgui.separator()
|
imgui.separator()
|
||||||
@@ -5482,7 +5477,6 @@ def render_context_preview_window(app: App) -> None:
|
|||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
if imgui.button("Copy to Clipboard"):
|
if imgui.button("Copy to Clipboard"):
|
||||||
imgui.set_clipboard_text(app.context_preview_text)
|
imgui.set_clipboard_text(app.context_preview_text)
|
||||||
imgui.begin_child("ctx_preview_scroll", imgui.ImVec2(0, 0), True)
|
with imscope.child("ctx_preview_scroll", 0, 0, True):
|
||||||
markdown_helper.render(app.context_preview_text, context_id="ctx_preview")
|
markdown_helper.render(app.context_preview_text, context_id="ctx_preview")
|
||||||
imgui.end_child()
|
|
||||||
|
|
||||||
|
|||||||
+37
-2
@@ -134,9 +134,9 @@ class MarkdownRenderer:
|
|||||||
if md_buf:
|
if md_buf:
|
||||||
chunk = "".join(md_buf)
|
chunk = "".join(md_buf)
|
||||||
if chunk.strip():
|
if chunk.strip():
|
||||||
imgui_md.render(chunk)
|
self._render_md_no_bullet_overlap(chunk)
|
||||||
imgui.spacing()
|
|
||||||
md_buf.clear()
|
md_buf.clear()
|
||||||
|
|
||||||
def flush_code() -> None:
|
def flush_code() -> None:
|
||||||
nonlocal block_idx
|
nonlocal block_idx
|
||||||
if code_buf:
|
if code_buf:
|
||||||
@@ -182,6 +182,41 @@ class MarkdownRenderer:
|
|||||||
|
|
||||||
flush_md()
|
flush_md()
|
||||||
flush_code()
|
flush_code()
|
||||||
|
|
||||||
|
def _render_md_no_bullet_overlap(self, chunk: str) -> None:
|
||||||
|
"""Render markdown, but split out bulleted-list sections and render them
|
||||||
|
as plain text via imgui.text to avoid imgui_md's known bullet-overlap bug.
|
||||||
|
"""
|
||||||
|
import re
|
||||||
|
list_pattern = re.compile(r"^(?P<indent>[ \t]*)(?:[-*+])\s+", re.MULTILINE)
|
||||||
|
current_pos = 0
|
||||||
|
for m in list_pattern.finditer(chunk):
|
||||||
|
if m.start() > current_pos:
|
||||||
|
pre = chunk[current_pos:m.start()]
|
||||||
|
if pre.strip(): imgui_md.render(pre)
|
||||||
|
list_start = m.start()
|
||||||
|
indent_len = len(m.group("indent"))
|
||||||
|
i = list_start
|
||||||
|
while i < len(chunk):
|
||||||
|
line_end = chunk.find("\n", i)
|
||||||
|
if line_end == -1: line_end = len(chunk)
|
||||||
|
line = chunk[i:line_end]
|
||||||
|
stripped = line.lstrip(" \t")
|
||||||
|
leading_ws = len(line) - len(stripped)
|
||||||
|
if leading_ws == indent_len and (stripped.startswith(("- ", "* ", "+ ")) or stripped == ""):
|
||||||
|
i = line_end + 1
|
||||||
|
continue
|
||||||
|
if leading_ws < indent_len:
|
||||||
|
break
|
||||||
|
i = line_end + 1
|
||||||
|
list_block = chunk[list_start:i]
|
||||||
|
for line in list_block.splitlines():
|
||||||
|
imgui.text(line) if line.strip() else imgui.spacing()
|
||||||
|
current_pos = i
|
||||||
|
if current_pos < len(chunk):
|
||||||
|
tail = chunk[current_pos:]
|
||||||
|
if tail.strip(): imgui_md.render(tail)
|
||||||
|
|
||||||
def render_unindented(self, text: str) -> None:
|
def render_unindented(self, text: str) -> None:
|
||||||
"""Render Markdown text with automatic unindentation."""
|
"""Render Markdown text with automatic unindentation."""
|
||||||
imgui_md.render_unindented(text)
|
imgui_md.render_unindented(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user