Private
Public Access
minimax: absolute dog shit edits
This commit is contained in:
@@ -20,3 +20,4 @@ sdm_report_refined.json
|
||||
session-ses_1eb8.md
|
||||
mock_debug_prompt.txt
|
||||
temp_old_gui.py
|
||||
.slop_cache/summary_cache.json
|
||||
|
||||
@@ -11,7 +11,7 @@ def find_definition_range(source: str, symbol_path: str) -> tuple[int, int] | No
|
||||
try:
|
||||
tree = ast.parse(source)
|
||||
except SyntaxError:
|
||||
return None
|
||||
return _find_definition_range_regex(source, symbol_path)
|
||||
parts = symbol_path.split('.')
|
||||
current_nodes = tree.body
|
||||
target_node = None
|
||||
@@ -21,8 +21,6 @@ def find_definition_range(source: str, symbol_path: str) -> tuple[int, int] | No
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)) and node.name == part:
|
||||
if i == len(parts) - 1:
|
||||
target_node = node
|
||||
found = True
|
||||
break
|
||||
else:
|
||||
if isinstance(node, ast.ClassDef):
|
||||
current_nodes = node.body
|
||||
@@ -37,6 +35,42 @@ def find_definition_range(source: str, symbol_path: str) -> tuple[int, int] | No
|
||||
return (start, target_node.end_lineno)
|
||||
return None
|
||||
|
||||
def _find_definition_range_regex(source: str, symbol_path: str) -> tuple[int, int] | None:
|
||||
import re
|
||||
parts = symbol_path.split('.')
|
||||
symbol_name = parts[-1]
|
||||
if '.' in symbol_path:
|
||||
class_name = parts[0]
|
||||
class_pattern = r'class\s+' + re.escape(class_name) + r'\s*:'
|
||||
class_match = re.search(class_pattern, source)
|
||||
if not class_match:
|
||||
return None
|
||||
class_body_start = class_match.end()
|
||||
method_pattern = r'def\s+' + re.escape(symbol_name) + r'\s*\('
|
||||
method_match = re.search(method_pattern, source[class_body_start:])
|
||||
if not method_match:
|
||||
return None
|
||||
method_line_num = source[:class_body_start + method_match.start()].count('\n') + 1
|
||||
remaining = source[class_body_start + method_match.start():]
|
||||
end_pattern = r'\n(?= def\s|\nclass\s|\Z)'
|
||||
end_match = re.search(end_pattern, remaining)
|
||||
if end_match:
|
||||
end_line = source[:class_body_start + method_match.start() + end_match.start()].count('\n') + 1
|
||||
return (method_line_num, end_line)
|
||||
return None
|
||||
else:
|
||||
func_pattern = r'def\s+' + re.escape(symbol_name) + r'\s*\('
|
||||
func_match = re.search(func_pattern, source)
|
||||
if not func_match:
|
||||
return None
|
||||
start = source[:func_match.start()].count('\n') + 1
|
||||
remaining = source[func_match.start():]
|
||||
end_match = re.search(r'\n(?=def\s|\Z)', remaining)
|
||||
if end_match:
|
||||
end = remaining[:end_match.start()].count('\n') + start
|
||||
return (start, end)
|
||||
return None
|
||||
|
||||
def shift_indentation(content: str, target_depth: int) -> str:
|
||||
"""
|
||||
Shifts and normalizes the indentation of a code block to 1-space units.
|
||||
|
||||
@@ -26,7 +26,6 @@ def test_render_ticket_queue_table_columns():
|
||||
mock_imgui.pop_style_color = MagicMock()
|
||||
mock_imgui.same_line = MagicMock()
|
||||
|
||||
# Setup imscope mocks
|
||||
mock_imscope.window.return_value.__enter__.return_value = (True, True)
|
||||
mock_imscope.child.return_value.__enter__.return_value = True
|
||||
mock_imscope.table.return_value.__enter__.return_value = True
|
||||
@@ -34,8 +33,7 @@ def test_render_ticket_queue_table_columns():
|
||||
mock_imscope.tab_item.return_value.__enter__.return_value = (True, True)
|
||||
mock_imscope.style_color.return_value.__enter__.return_value = None
|
||||
mock_imscope.style_var.return_value.__enter__.return_value = None
|
||||
|
||||
from src.gui_2 import App
|
||||
from src.gui_2 import App, render_ticket_queue
|
||||
app = App.__new__(App)
|
||||
app.active_track = MagicMock()
|
||||
app.active_tickets = [{"id": "T-001", "priority": "medium", "status": "in_progress", "description": "Test task"}]
|
||||
@@ -44,6 +42,6 @@ def test_render_ticket_queue_table_columns():
|
||||
app.controller = MagicMock()
|
||||
app._push_mma_state_update = MagicMock()
|
||||
app._cb_kill_ticket = MagicMock()
|
||||
app._render_ticket_queue()
|
||||
render_ticket_queue(app)
|
||||
columns_called = [call[0][0] for call in mock_imgui.table_setup_column.call_args_list]
|
||||
assert "Actions" in columns_called, f"Expected Actions column, got: {columns_called}"
|
||||
@@ -5,7 +5,7 @@ import inspect
|
||||
def test_context_hub_renamed_to_project_settings():
|
||||
import src.gui_2 as gui_2
|
||||
|
||||
source = inspect.getsource(gui_2.App._render_main_interface)
|
||||
source = inspect.getsource(gui_2.render_main_interface)
|
||||
assert "Project Settings" in source, (
|
||||
"Context Hub should be renamed to Project Settings"
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
import pytest
|
||||
import src.gui_2 as gui_2
|
||||
from src.gui_2 import App
|
||||
|
||||
def test_rag_panel_exists():
|
||||
"""Verify that _render_rag_panel has been added to the App class."""
|
||||
assert hasattr(App, '_render_rag_panel')
|
||||
assert callable(App._render_rag_panel)
|
||||
"""Verify that render_rag_panel exists as a module-level function."""
|
||||
assert hasattr(gui_2, 'render_rag_panel'), "gui_2 module must have render_rag_panel function"
|
||||
assert callable(gui_2.render_rag_panel)
|
||||
|
||||
def test_rag_panel_integration():
|
||||
"""Verify that _render_ai_settings_hub calls _render_rag_panel by inspecting source or via mock."""
|
||||
"""Verify that render_ai_settings_hub calls render_rag_panel by inspecting source."""
|
||||
import inspect
|
||||
source = inspect.getsource(App._render_ai_settings_hub)
|
||||
assert "self._render_rag_panel()" in source
|
||||
source = inspect.getsource(gui_2.render_ai_settings_hub)
|
||||
assert "render_rag_panel(app)" in source
|
||||
assert "imgui.collapsing_header(\"RAG Settings\")" in source
|
||||
@@ -3,47 +3,29 @@ import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Ensure project root is in path
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from src.api_hook_client import ApiHookClient
|
||||
from src.gui_2 import App
|
||||
import src.gui_2 as gui_2
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_selectable_label_stability(live_gui) -> None:
|
||||
"""
|
||||
|
||||
|
||||
Verifies that the application starts correctly with --enable-test-hooks
|
||||
and that the selectable label infrastructure is present and stable.
|
||||
"""
|
||||
client = ApiHookClient()
|
||||
assert client.wait_for_server(timeout=20), "Hook server failed to start"
|
||||
|
||||
# 1. Check initial state via diagnostics: is_viewing_prior_session should be False
|
||||
diag = client.get_gui_diagnostics()
|
||||
# Based on src/api_hooks.py: result["prior"] = _get_app_attr(app, "is_viewing_prior_session", False)
|
||||
assert diag.get("prior") is False, "Initial state should not be viewing prior session"
|
||||
|
||||
# 2. Verify _render_selectable_label exists in the App class
|
||||
# This satisfies the requirement to check if it exists in the App class.
|
||||
assert hasattr(App, '_render_selectable_label'), "App class must have _render_selectable_label method"
|
||||
assert hasattr(gui_2, 'render_selectable_label'), "gui_2 module must have render_selectable_label function"
|
||||
|
||||
# 3. Check performance to ensure stability
|
||||
perf = client.get_performance()
|
||||
metrics = perf.get("performance", {})
|
||||
# We check if FPS is reported; in some CI environments it might be low but should be > 0 if rendering
|
||||
assert "fps" in metrics, "Performance metrics should include FPS"
|
||||
|
||||
# 4. Basic smoke test: set and get a value to ensure GUI thread is responsive
|
||||
# ai_response is a known field that is often rendered using selectable labels in various contexts
|
||||
client.set_value("ai_response", "Test selectable text stability")
|
||||
# Give it a few frames to process the task
|
||||
time.sleep(1)
|
||||
val = client.get_value("ai_response")
|
||||
assert val == "Test selectable text stability", f"Expected 'Test selectable text stability', got '{val}'"
|
||||
|
||||
# 5. Verify prior session indicator specifically via the gettable field
|
||||
# prior_session_indicator is mapped to AppController.is_viewing_prior_session
|
||||
prior_val = client.get_value("prior_session_indicator")
|
||||
assert prior_val is False, "prior_session_indicator field should be False initially"
|
||||
@@ -1,14 +1,11 @@
|
||||
import pytest
|
||||
|
||||
import src.gui_2 as gui_2
|
||||
|
||||
def test_render_thinking_trace_helper_exists():
|
||||
from src.gui_2 import App
|
||||
|
||||
assert hasattr(App, "_render_thinking_trace"), (
|
||||
"_render_thinking_trace helper should exist in App class"
|
||||
assert hasattr(gui_2, 'render_thinking_trace'), (
|
||||
"gui_2 module must have render_thinking_trace function"
|
||||
)
|
||||
|
||||
|
||||
def test_discussion_entry_with_thinking_segments():
|
||||
entry = {
|
||||
"role": "AI",
|
||||
|
||||
@@ -56,8 +56,9 @@ def test_app_last_stable_md_initialized_empty(app_instance: Any) -> None:
|
||||
assert app_instance.controller._last_stable_md == ''
|
||||
|
||||
def test_app_has_render_token_budget_panel(app_instance: Any) -> None:
|
||||
"""App must have _render_token_budget_panel method."""
|
||||
assert hasattr(app_instance, "_render_token_budget_panel")
|
||||
"""App must have render_token_budget_panel function in gui_2 module."""
|
||||
import src.gui_2 as gui_2
|
||||
assert hasattr(gui_2, 'render_token_budget_panel'), "gui_2 module must have render_token_budget_panel function"
|
||||
|
||||
def test_would_trim_boundary_exact() -> None:
|
||||
"""Exact limit should trigger would_trim (cur >= lim)."""
|
||||
|
||||
Reference in New Issue
Block a user