From bf223bc9c5f2dd63921e9b6512f729d9f4ec24d1 Mon Sep 17 00:00:00 2001 From: xprilion Date: Wed, 29 Apr 2026 22:51:32 +0530 Subject: [PATCH 1/3] Sonarqube cleanup 5 --- backend/openmlr/routes/terminal.py | 22 +++++++------ backend/tests/test_sandbox_types.py | 2 +- backend/tests/test_tools_workspace.py | 7 +++-- frontend/src/components/ConfirmDialog.tsx | 4 +++ frontend/src/components/FileTree.tsx | 2 +- frontend/src/components/ModelModal.tsx | 7 +++++ frontend/src/components/OnboardingModal.tsx | 6 ++-- .../src/components/ProjectManageModal.tsx | 5 +++ frontend/src/components/ProjectModal.tsx | 6 ++-- frontend/src/components/ReportDrawer.tsx | 7 ++++- frontend/src/components/RightPanel.tsx | 2 +- frontend/src/components/Sidebar.tsx | 9 ++++++ frontend/src/components/Terminal.tsx | 8 +++++ .../src/components/settings/AddKeyModal.tsx | 14 ++++++--- .../src/components/settings/AddNodeModal.tsx | 31 ++++++++++++------- .../src/components/settings/AgentSettings.tsx | 6 ++-- .../src/components/settings/McpSettings.tsx | 19 +++++++----- .../components/settings/ProvidersSettings.tsx | 23 ++++++++++---- .../components/settings/WritingSettings.tsx | 18 +++++++---- 19 files changed, 142 insertions(+), 56 deletions(-) diff --git a/backend/openmlr/routes/terminal.py b/backend/openmlr/routes/terminal.py index 99b3f2b..967f759 100644 --- a/backend/openmlr/routes/terminal.py +++ b/backend/openmlr/routes/terminal.py @@ -192,15 +192,19 @@ async def terminal_websocket( shell = "/bin/bash" try: - proc = subprocess.Popen( - [shell, "--norc", "--noprofile"], - stdin=slave_fd, - stdout=slave_fd, - stderr=slave_fd, - cwd=workspace_path, - env=env, - start_new_session=True, - close_fds=True, + loop = asyncio.get_event_loop() + proc = await loop.run_in_executor( + None, + lambda: subprocess.Popen( + [shell, "--norc", "--noprofile"], + stdin=slave_fd, + stdout=slave_fd, + stderr=slave_fd, + cwd=workspace_path, + env=env, + start_new_session=True, + close_fds=True, + ), ) pid = proc.pid except Exception as e: diff --git a/backend/tests/test_sandbox_types.py b/backend/tests/test_sandbox_types.py index bcc7be2..08c36a5 100644 --- a/backend/tests/test_sandbox_types.py +++ b/backend/tests/test_sandbox_types.py @@ -53,7 +53,7 @@ def test_failure(self): r = ExecutionResult(output="error", success=False, exit_code=1, duration_seconds=2.5) assert r.success is False assert r.exit_code == 1 - assert r.duration_seconds == 2.5 + assert r.duration_seconds == pytest.approx(2.5) def test_truncation_handled_by_caller(self): # Truncation is done by the tools, not the dataclass diff --git a/backend/tests/test_tools_workspace.py b/backend/tests/test_tools_workspace.py index 69edca8..4c92d9c 100644 --- a/backend/tests/test_tools_workspace.py +++ b/backend/tests/test_tools_workspace.py @@ -1,5 +1,6 @@ """Tests for workspace agent tools.""" +import asyncio import os import tempfile @@ -179,8 +180,10 @@ async def test_recent_failures_empty(self, workspace_dir): async def test_search_operation(self, workspace_dir): # Create a test file test_file = os.path.join(workspace_dir, "code", "test.py") - with open(test_file, "w") as f: - f.write("import torch\nmodel = TransformerModel()") + loop = asyncio.get_event_loop() + await loop.run_in_executor( + None, lambda: open(test_file, "w").write("import torch\nmodel = TransformerModel()") + ) result, success = await _handle_workspace( operation="search", diff --git a/frontend/src/components/ConfirmDialog.tsx b/frontend/src/components/ConfirmDialog.tsx index 30ae352..5e5adec 100644 --- a/frontend/src/components/ConfirmDialog.tsx +++ b/frontend/src/components/ConfirmDialog.tsx @@ -39,10 +39,14 @@ export function ConfirmDialog({
e.stopPropagation()} + role="dialog" + aria-modal="true" + aria-labelledby="confirm-dialog-title" >

{title}

{message}

diff --git a/frontend/src/components/FileTree.tsx b/frontend/src/components/FileTree.tsx index df49f94..7b6aa93 100644 --- a/frontend/src/components/FileTree.tsx +++ b/frontend/src/components/FileTree.tsx @@ -164,7 +164,7 @@ export function FileTree({ projectUuid, refreshKey, onFileSelect }: Props) { return (data.entries || []).map((entry: FileNode) => ({ ...entry, expanded: false, - children: entry.is_dir ? undefined : undefined, + children: undefined, })); } catch (err: any) { setError(err.message); diff --git a/frontend/src/components/ModelModal.tsx b/frontend/src/components/ModelModal.tsx index a13581b..bacaab3 100644 --- a/frontend/src/components/ModelModal.tsx +++ b/frontend/src/components/ModelModal.tsx @@ -252,16 +252,23 @@ export function ModelModal({ currentModel, onModelChange }: Props) {
setOpen(false)} + onKeyDown={(e) => e.key === 'Escape' && setOpen(false)} + role="presentation" > {/* Fixed-size modal — never changes dimensions between loading and loaded */}
e.stopPropagation()} + onKeyDown={(e) => e.stopPropagation()} + role="dialog" + aria-modal="true" + aria-labelledby="model-modal-title" > {/* Tabs */}