From c187b04e82654e6ef52121068a7f521832c79db5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Fri, 15 May 2026 17:33:44 -0700 Subject: [PATCH] chore: linting --- .../main_agent/runtime/agent_cache.py | 4 +- .../subagents/connectors/jira/tools/index.py | 4 +- .../new_chat/middleware/knowledge_search.py | 2 +- .../new_chat/middleware/knowledge_tree.py | 2 +- .../app/etl_pipeline/etl_pipeline_service.py | 4 +- .../app/etl_pipeline/parsers/vision_llm.py | 4 +- .../app/etl_pipeline/picture_describer.py | 24 +++++------- .../app/services/user_tool_allowlist.py | 8 +--- .../test_hitl_bridge.py | 8 +--- .../test_parallel_heterogeneous_decisions.py | 5 +-- .../test_parallel_partial_pause_routing.py | 5 +-- .../test_parallel_reject_only_routing.py | 5 +-- .../test_parallel_resume_command_keying.py | 13 +++---- ...test_parallel_self_and_middleware_gated.py | 11 ++++-- .../test_parallel_tasks.py | 23 ++++++++++-- .../shared/permissions/test_lc_hitl_wire.py | 8 +--- .../test_subagent_owned_ruleset.py | 4 +- .../shared/hitl/wire/test_hitl_wire.py | 4 +- .../etl_pipeline/test_etl_pipeline_service.py | 14 ++----- .../etl_pipeline/test_picture_describer.py | 37 +++++++++++-------- .../streaming/test_interrupt_inspector_all.py | 3 +- .../chat/test_thinking_step_id_uniqueness.py | 4 +- .../app/(home)/blog/blog-magazine.tsx | 4 +- .../ui/sidebar/AllPrivateChatsSidebar.tsx | 5 +-- .../ui/sidebar/AllSharedChatsSidebar.tsx | 5 +-- 25 files changed, 102 insertions(+), 108 deletions(-) diff --git a/surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/agent_cache.py b/surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/agent_cache.py index 1b542ebcd..03cf7acb8 100644 --- a/surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/agent_cache.py +++ b/surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/agent_cache.py @@ -28,7 +28,9 @@ def mcp_signature(mcp_tools_by_agent: dict[str, list[BaseTool]]) -> str: """Hash the per-agent MCP tool surface so a change rotates the cache key.""" rows = [] for agent_name in sorted(mcp_tools_by_agent.keys()): - names = sorted(getattr(t, "name", "") or "" for t in mcp_tools_by_agent[agent_name]) + names = sorted( + getattr(t, "name", "") or "" for t in mcp_tools_by_agent[agent_name] + ) rows.append((agent_name, names)) return stable_hash(rows) diff --git a/surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/tools/index.py b/surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/tools/index.py index 13b2a073c..24f1bdc01 100644 --- a/surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/tools/index.py +++ b/surfsense_backend/app/agents/multi_agent_chat/subagents/connectors/jira/tools/index.py @@ -13,7 +13,9 @@ RULESET = Ruleset( Rule(permission="getVisibleJiraProjects", pattern="*", action="allow"), Rule(permission="searchJiraIssuesUsingJql", pattern="*", action="allow"), Rule(permission="getJiraIssue", pattern="*", action="allow"), - Rule(permission="getJiraProjectIssueTypesMetadata", pattern="*", action="allow"), + Rule( + permission="getJiraProjectIssueTypesMetadata", pattern="*", action="allow" + ), Rule(permission="getJiraIssueTypeMetaWithFields", pattern="*", action="allow"), Rule(permission="getTransitionsForJiraIssue", pattern="*", action="allow"), Rule(permission="lookupJiraAccountId", pattern="*", action="allow"), diff --git a/surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py b/surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py index ae5fece88..dc06f8763 100644 --- a/surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py +++ b/surfsense_backend/app/agents/new_chat/middleware/knowledge_search.py @@ -585,7 +585,7 @@ class KnowledgePriorityMiddleware(AgentMiddleware): # type: ignore[type-arg] available_document_types: list[str] | None = None, top_k: int = 10, mentioned_document_ids: list[int] | None = None, - inject_system_message: bool = True, # For backwards compatibility + inject_system_message: bool = True, # For backwards compatibility ) -> None: self.llm = llm self.search_space_id = search_space_id diff --git a/surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py b/surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py index ba45b5489..4ed1e53f4 100644 --- a/surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py +++ b/surfsense_backend/app/agents/new_chat/middleware/knowledge_tree.py @@ -105,7 +105,7 @@ class KnowledgeTreeMiddleware(AgentMiddleware): # type: ignore[type-arg] llm: BaseChatModel | None = None, max_entries: int = MAX_TREE_ENTRIES, max_tokens: int = MAX_TREE_TOKENS, - inject_system_message: bool = True, # For backwards compatibility + inject_system_message: bool = True, # For backwards compatibility ) -> None: self.search_space_id = search_space_id self.filesystem_mode = filesystem_mode diff --git a/surfsense_backend/app/etl_pipeline/etl_pipeline_service.py b/surfsense_backend/app/etl_pipeline/etl_pipeline_service.py index 7fe3c94df..87e8138fd 100644 --- a/surfsense_backend/app/etl_pipeline/etl_pipeline_service.py +++ b/surfsense_backend/app/etl_pipeline/etl_pipeline_service.py @@ -181,9 +181,7 @@ class EtlPipelineService: # Common case: the configured ETL service can't OCR # this image format (or no service is configured at # all). Don't spam warnings -- just no OCR for it. - logging.debug( - "Skipping per-image OCR for %s: %s", image_name, exc - ) + logging.debug("Skipping per-image OCR for %s: %s", image_name, exc) return "" return ocr_result.markdown_content diff --git a/surfsense_backend/app/etl_pipeline/parsers/vision_llm.py b/surfsense_backend/app/etl_pipeline/parsers/vision_llm.py index 8ae0715f3..14741d609 100644 --- a/surfsense_backend/app/etl_pipeline/parsers/vision_llm.py +++ b/surfsense_backend/app/etl_pipeline/parsers/vision_llm.py @@ -96,9 +96,7 @@ async def parse_with_vision_llm(file_path: str, filename: str, llm) -> str: return await _invoke_vision(llm, _PROMPT, data_url, filename) -async def parse_image_for_description( - file_path: str, filename: str, llm -) -> str: +async def parse_image_for_description(file_path: str, filename: str, llm) -> str: """Visual-description-only call for per-image-in-PDF use. Used by ``picture_describer`` when an image is embedded inside a diff --git a/surfsense_backend/app/etl_pipeline/picture_describer.py b/surfsense_backend/app/etl_pipeline/picture_describer.py index f6bda2d4e..263e7201a 100644 --- a/surfsense_backend/app/etl_pipeline/picture_describer.py +++ b/surfsense_backend/app/etl_pipeline/picture_describer.py @@ -99,12 +99,12 @@ class PictureDescription: when no OCR was requested or OCR found no text. """ - page_number: int # 1-indexed - ordinal_in_page: int # 0-indexed within the page - name: str # name pypdf assigned (e.g. "Im0") - sha256: str # hash of the raw image bytes - description: str # visual description (markdown) - ocr_text: str | None = None # OCR text from the ETL service, if any + page_number: int # 1-indexed + ordinal_in_page: int # 0-indexed within the page + name: str # name pypdf assigned (e.g. "Im0") + sha256: str # hash of the raw image bytes + description: str # visual description (markdown) + ocr_text: str | None = None # OCR text from the ETL service, if any @dataclass @@ -478,7 +478,7 @@ def _replace_one_match( name = captured_name or desc.name block = _format_image_block(name, desc.description, desc.ocr_text) - new_markdown = markdown[: match.start()] + block + markdown[match.end():] + new_markdown = markdown[: match.start()] + block + markdown[match.end() :] return new_markdown, desc_idx + 1 @@ -521,7 +521,7 @@ def _splice_after_figures( match = matches[i] desc = descriptions[desc_idx + i] block = _format_image_block(desc.name, desc.description, desc.ocr_text) - out = out[: match.end()] + block + out[match.end():] + out = out[: match.end()] + block + out[match.end() :] return out, desc_idx + n_to_splice @@ -583,9 +583,7 @@ def inject_descriptions_inline( ) if desc_idx > before_idx: continue - out, desc_idx = _replace_one_match( - out, _CAPTION_ONLY, descriptions, desc_idx - ) + out, desc_idx = _replace_one_match(out, _CAPTION_ONLY, descriptions, desc_idx) if desc_idx > before_idx: continue # No more positions to splice into. @@ -612,9 +610,7 @@ def render_appended_section( parts: list[str] = ["", heading, ""] for desc in descriptions: - parts.append( - _format_image_block(desc.name, desc.description, desc.ocr_text) - ) + parts.append(_format_image_block(desc.name, desc.description, desc.ocr_text)) parts.append("") if skip_notes is not None: diff --git a/surfsense_backend/app/services/user_tool_allowlist.py b/surfsense_backend/app/services/user_tool_allowlist.py index fb21a7df2..fdfa51560 100644 --- a/surfsense_backend/app/services/user_tool_allowlist.py +++ b/surfsense_backend/app/services/user_tool_allowlist.py @@ -72,9 +72,7 @@ async def add_user_trust( session, user_id=user_id, connector_id=connector_id ) if connector is None: - raise LookupError( - f"connector {connector_id} not found for user {user_id}" - ) + raise LookupError(f"connector {connector_id} not found for user {user_id}") trusted = _read_trusted(connector) if tool_name not in trusted: @@ -96,9 +94,7 @@ async def remove_user_trust( session, user_id=user_id, connector_id=connector_id ) if connector is None: - raise LookupError( - f"connector {connector_id} not found for user {user_id}" - ) + raise LookupError(f"connector {connector_id} not found for user {user_id}") trusted = _read_trusted(connector) if tool_name in trusted: diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_hitl_bridge.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_hitl_bridge.py index 48eabbd7c..72408a5d9 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_hitl_bridge.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_hitl_bridge.py @@ -362,9 +362,7 @@ async def test_full_resume_routing_glue_for_two_paused_subagents(): SimpleNamespace( id="i-approver", value={ - "action_requests": [ - {"name": "approve", "args": {}, "description": ""} - ], + "action_requests": [{"name": "approve", "args": {}, "description": ""}], "review_configs": [{}], "tool_call_id": "tcid-approver", }, @@ -403,8 +401,6 @@ async def test_full_resume_routing_glue_for_two_paused_subagents(): received_a = ast.literal_eval(result_a.update["decision_text"]) assert received_a == {"decisions": flat_decisions[0:3]} - assert result_b.update["decision_text"] == repr( - {"decisions": flat_decisions[3:4]} - ) + assert result_b.update["decision_text"] == repr({"decisions": flat_decisions[3:4]}) assert "surfsense_resume_value" not in parent_config["configurable"] diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_heterogeneous_decisions.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_heterogeneous_decisions.py index cd5000acd..d4a68939e 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_heterogeneous_decisions.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_heterogeneous_decisions.py @@ -26,6 +26,7 @@ This module pins: from __future__ import annotations +import contextlib import json from typing import Annotated @@ -227,10 +228,8 @@ async def test_heterogeneous_decisions_route_to_correct_subagents_with_metadata_ for msg in final_state.values.get("messages", []) or []: content = getattr(msg, "content", None) if isinstance(content, str): - try: + with contextlib.suppress(json.JSONDecodeError): payloads.append(json.loads(content)) - except json.JSONDecodeError: - pass expected_a = {"decisions": [a_approve, a_reject]} expected_b = {"decisions": [b_edit, b_approve, b_reject]} diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_partial_pause_routing.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_partial_pause_routing.py index 79210032b..1aba0c480 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_partial_pause_routing.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_partial_pause_routing.py @@ -33,6 +33,7 @@ exploratory probe before this test was authored. from __future__ import annotations +import contextlib import json from typing import Annotated @@ -243,10 +244,8 @@ async def test_partial_pause_routes_only_to_paused_branch_without_rerunning_comp for msg in final.values.get("messages", []) or []: content = getattr(msg, "content", None) if isinstance(content, str): - try: + with contextlib.suppress(json.JSONDecodeError): payloads.append(json.loads(content)) - except json.JSONDecodeError: - pass assert {"decisions": [{"type": "approve"}]} in payloads, ( f"REGRESSION: sub-B did not receive its single approve on resume; " diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_reject_only_routing.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_reject_only_routing.py index f4ee947c6..5810d5394 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_reject_only_routing.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_reject_only_routing.py @@ -23,6 +23,7 @@ Why a separate pin: from __future__ import annotations +import contextlib import json from typing import Annotated @@ -191,10 +192,8 @@ async def test_all_reject_decisions_route_to_each_subagent_with_messages_intact( for msg in final_state.values.get("messages", []) or []: content = getattr(msg, "content", None) if isinstance(content, str): - try: + with contextlib.suppress(json.JSONDecodeError): payloads.append(json.loads(content)) - except json.JSONDecodeError: - pass expected_a = {"decisions": [a_reject_0, a_reject_1]} expected_b = {"decisions": [b_reject_0]} diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_resume_command_keying.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_resume_command_keying.py index 458a2539b..839cb7564 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_resume_command_keying.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_resume_command_keying.py @@ -23,6 +23,7 @@ silently pass such a bug because the slices would coincide. from __future__ import annotations +import contextlib import json from typing import Annotated @@ -81,9 +82,7 @@ def _build_pausing_subagent(checkpointer: InMemorySaver, *, action_count: int): "review_configs": [{} for _ in range(action_count)], } ) - return { - "messages": [AIMessage(content=json.dumps(decision, sort_keys=True))] - } + return {"messages": [AIMessage(content=json.dumps(decision, sort_keys=True))]} g = StateGraph(_SubState) g.add_node("approve", approve_node) @@ -202,7 +201,9 @@ async def test_parallel_resume_with_per_interrupt_id_keying_completes_both_subag await parent.ainvoke({"messages": [HumanMessage(content="seed")]}, config) paused_state = await parent.aget_state(config) - assert len(paused_state.interrupts) == 2, "fixture broken: expected 2 paused subagents" + assert len(paused_state.interrupts) == 2, ( + "fixture broken: expected 2 paused subagents" + ) pending = collect_pending_tool_calls(paused_state) assert dict(pending) == {tcid_a: 2, tcid_b: 3}, ( @@ -243,10 +244,8 @@ async def test_parallel_resume_with_per_interrupt_id_keying_completes_both_subag for msg in final_state.values.get("messages", []) or []: content = getattr(msg, "content", None) if isinstance(content, str): - try: + with contextlib.suppress(json.JSONDecodeError): payloads.append(json.loads(content)) - except json.JSONDecodeError: - pass expected_a = {"decisions": [a_d0, a_d1]} expected_b = {"decisions": [b_d0, b_d1, b_d2]} diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_self_and_middleware_gated.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_self_and_middleware_gated.py index 57969e8fa..921c4a9eb 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_self_and_middleware_gated.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_self_and_middleware_gated.py @@ -21,6 +21,7 @@ their per-slice payload. from __future__ import annotations +import contextlib import json from typing import Annotated @@ -151,7 +152,11 @@ def _parent_dispatching_one_of_each( return [ Send( "call_task", - {"tcid": tcid_self, "desc": "approve email", "subtype": "self-gated-agent"}, + { + "tcid": tcid_self, + "desc": "approve email", + "subtype": "self-gated-agent", + }, ), Send( "call_task", @@ -250,10 +255,8 @@ async def test_parallel_self_gated_and_middleware_gated_route_and_resume_cleanly for msg in final.values.get("messages", []) or []: content = getattr(msg, "content", None) if isinstance(content, str): - try: + with contextlib.suppress(json.JSONDecodeError): payloads.append(json.loads(content)) - except json.JSONDecodeError: - pass self_payloads = [p for p in payloads if p.get("kind") == "self_gated"] mw_payloads = [p for p in payloads if p.get("kind") == "middleware_gated"] diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_tasks.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_tasks.py index 9c067fc57..81be7d1ac 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_tasks.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/checkpointed_subagent_middleware/test_parallel_tasks.py @@ -121,7 +121,11 @@ async def test_two_parallel_atasks_same_subagent_type_different_tool_call_ids(): shared_subagent = _build_success_subagent("ok") task_tool = build_task_tool_with_parent_config( [ - {"name": "approver", "description": "shared approver", "runnable": shared_subagent}, + { + "name": "approver", + "description": "shared approver", + "runnable": shared_subagent, + }, ] ) @@ -163,7 +167,10 @@ async def test_two_parallel_atasks_same_subagent_type_different_tool_call_ids(): state_parent = await shared_subagent.aget_state( {"configurable": {"thread_id": "shared-subagent-thread"}} ) - assert state_parent.values == {} or state_parent.values.get("messages") in (None, []) + assert state_parent.values == {} or state_parent.values.get("messages") in ( + None, + [], + ) @pytest.mark.asyncio @@ -181,8 +188,16 @@ async def test_one_atask_failure_does_not_corrupt_sibling_atask(): surviving_subagent = _build_success_subagent("still here") task_tool = build_task_tool_with_parent_config( [ - {"name": "broken", "description": "always fails", "runnable": failing_subagent}, - {"name": "healthy", "description": "always succeeds", "runnable": surviving_subagent}, + { + "name": "broken", + "description": "always fails", + "runnable": failing_subagent, + }, + { + "name": "healthy", + "description": "always succeeds", + "runnable": surviving_subagent, + }, ] ) diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_lc_hitl_wire.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_lc_hitl_wire.py index f8399c031..a331190b2 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_lc_hitl_wire.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_lc_hitl_wire.py @@ -84,9 +84,7 @@ async def test_resume_with_approve_envelope_returns_once_decision(): config = {"configurable": {"thread_id": "perm-once"}} await graph.ainvoke({"messages": [HumanMessage(content="seed")]}, config) - await graph.ainvoke( - Command(resume={"decisions": [{"type": "approve"}]}), config - ) + await graph.ainvoke(Command(resume={"decisions": [{"type": "approve"}]}), config) final = await graph.aget_state(config) assert final.values.get("final_decision") == {"decision_type": "once"} @@ -116,9 +114,7 @@ async def test_resume_with_reject_and_feedback_carries_feedback_through(): await graph.ainvoke( Command( - resume={ - "decisions": [{"type": "reject", "feedback": "use the trash bin"}] - } + resume={"decisions": [{"type": "reject", "feedback": "use the trash bin"}]} ), config, ) diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_subagent_owned_ruleset.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_subagent_owned_ruleset.py index 6406fb09a..b9ac6cd15 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_subagent_owned_ruleset.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/middleware/shared/permissions/test_subagent_owned_ruleset.py @@ -141,9 +141,7 @@ async def test_kb_ruleset_resume_with_approve_lets_rm_through(): config = {"configurable": {"thread_id": "kb-cloud-rm-approve"}} await graph.ainvoke({"messages": [HumanMessage(content="seed")]}, config) - await graph.ainvoke( - Command(resume={"decisions": [{"type": "approve"}]}), config - ) + await graph.ainvoke(Command(resume={"decisions": [{"type": "approve"}]}), config) final = await graph.aget_state(config) assert final.next == (), "graph must complete after approve" last_ai = next( diff --git a/surfsense_backend/tests/unit/agents/multi_agent_chat/subagents/shared/hitl/wire/test_hitl_wire.py b/surfsense_backend/tests/unit/agents/multi_agent_chat/subagents/shared/hitl/wire/test_hitl_wire.py index e54dbbb5a..c06f9a627 100644 --- a/surfsense_backend/tests/unit/agents/multi_agent_chat/subagents/shared/hitl/wire/test_hitl_wire.py +++ b/surfsense_backend/tests/unit/agents/multi_agent_chat/subagents/shared/hitl/wire/test_hitl_wire.py @@ -100,7 +100,9 @@ class TestBuildLcHitlPayload: interrupt_type="x", ) decisions.append(LC_DECISION_REJECT) - assert payload["review_configs"][0]["allowed_decisions"] == [LC_DECISION_APPROVE] + assert payload["review_configs"][0]["allowed_decisions"] == [ + LC_DECISION_APPROVE + ] class TestParseLcEnvelope: diff --git a/surfsense_backend/tests/unit/etl_pipeline/test_etl_pipeline_service.py b/surfsense_backend/tests/unit/etl_pipeline/test_etl_pipeline_service.py index edfe94406..bd0b485f7 100644 --- a/surfsense_backend/tests/unit/etl_pipeline/test_etl_pipeline_service.py +++ b/surfsense_backend/tests/unit/etl_pipeline/test_etl_pipeline_service.py @@ -903,9 +903,7 @@ async def test_extract_pdf_without_vision_llm_skips_picture_descriptions( describe_mock.assert_not_called() -async def test_extract_pdf_with_vision_llm_swallows_describe_failure( - tmp_path, mocker -): +async def test_extract_pdf_with_vision_llm_swallows_describe_failure(tmp_path, mocker): """A pypdf or vision LLM blow-up never fails the document upload.""" pdf_file = tmp_path / "report.pdf" pdf_file.write_bytes(b"%PDF-1.4 fake content") @@ -976,9 +974,7 @@ async def test_extract_pdf_with_vision_llm_no_images_returns_parser_text( # --------------------------------------------------------------------------- -async def test_extract_pdf_passes_ocr_runner_to_describe_pictures( - tmp_path, mocker -): +async def test_extract_pdf_passes_ocr_runner_to_describe_pictures(tmp_path, mocker): """The ETL service must wire an ocr_runner kwarg to describe_pictures.""" pdf_file = tmp_path / "report.pdf" pdf_file.write_bytes(b"%PDF-1.4 fake content") @@ -1027,9 +1023,7 @@ async def test_extract_pdf_ocr_runner_invokes_document_parser_on_image( mocker.patch("app.config.config.ETL_SERVICE", "DOCLING") fake_docling = mocker.AsyncMock() - fake_docling.process_document.return_value = { - "content": "Slice 24 / 60 L R" - } + fake_docling.process_document.return_value = {"content": "Slice 24 / 60 L R"} mocker.patch( "app.services.docling_service.create_docling_service", return_value=fake_docling, @@ -1074,7 +1068,7 @@ async def test_extract_pdf_ocr_runner_returns_empty_on_unsupported_image( pdf_file = tmp_path / "report.pdf" pdf_file.write_bytes(b"%PDF-1.4 fake content") weird_image = tmp_path / "Im0.jp2" # JPEG2000, unlikely to be supported - weird_image.write_bytes(b"\x00\x00\x00\x0CjP" + b"\x00" * 50) + weird_image.write_bytes(b"\x00\x00\x00\x0cjP" + b"\x00" * 50) mocker.patch("app.config.config.ETL_SERVICE", "DOCLING") diff --git a/surfsense_backend/tests/unit/etl_pipeline/test_picture_describer.py b/surfsense_backend/tests/unit/etl_pipeline/test_picture_describer.py index 407bc97a2..39fb087c3 100644 --- a/surfsense_backend/tests/unit/etl_pipeline/test_picture_describer.py +++ b/surfsense_backend/tests/unit/etl_pipeline/test_picture_describer.py @@ -330,11 +330,17 @@ def test_inject_handles_multiple_images_in_order(): result = PictureExtractionResult( descriptions=[ PictureDescription( - page_number=1, ordinal_in_page=0, name="Im0", sha256="aa", + page_number=1, + ordinal_in_page=0, + name="Im0", + sha256="aa", description="Desc A", ), PictureDescription( - page_number=2, ordinal_in_page=0, name="Im1", sha256="bb", + page_number=2, + ordinal_in_page=0, + name="Im1", + sha256="bb", description="Desc B", ), ] @@ -511,9 +517,7 @@ async def test_describe_pictures_calls_ocr_runner_per_image(tmp_path, mocker): assert by_name == {"Im0.jpeg": "OCR text A", "Im1.png": "OCR text B"} -async def test_describe_pictures_runs_vision_and_ocr_in_parallel( - tmp_path, mocker -): +async def test_describe_pictures_runs_vision_and_ocr_in_parallel(tmp_path, mocker): """Vision LLM and OCR run concurrently per image, not sequentially. We verify this by recording call timestamps: if both finish within @@ -656,9 +660,7 @@ async def test_describe_pictures_vision_failure_with_ocr_runner_skips_image( assert result.failed == 1 -async def test_describe_pictures_no_ocr_runner_keeps_ocr_text_none( - tmp_path, mocker -): +async def test_describe_pictures_no_ocr_runner_keeps_ocr_text_none(tmp_path, mocker): """Backward compat: omitting ocr_runner produces description-only blocks.""" pdf_file = tmp_path / "report.pdf" pdf_file.write_bytes(b"%PDF-1.4 fake") @@ -824,11 +826,17 @@ def test_inject_handles_multiple_figures_in_document_order(): result = PictureExtractionResult( descriptions=[ PictureDescription( - page_number=1, ordinal_in_page=0, name="Im0", sha256="aa", + page_number=1, + ordinal_in_page=0, + name="Im0", + sha256="aa", description="Description of chart A.", ), PictureDescription( - page_number=2, ordinal_in_page=0, name="Im1", sha256="bb", + page_number=2, + ordinal_in_page=0, + name="Im1", + sha256="bb", description="Description of chart B.", ), ] @@ -842,9 +850,7 @@ def test_inject_handles_multiple_figures_in_document_order(): assert out.count("") == 2 assert "Description of chart A." in out assert "Description of chart B." in out - assert out.index("Description of chart A.") < out.index( - "Description of chart B." - ) + assert out.index("Description of chart A.") < out.index("Description of chart B.") # Each description appears AFTER its corresponding . first_close = out.index("") assert first_close < out.index("Description of chart A.") @@ -856,7 +862,7 @@ def test_inject_figures_with_attributes_and_nested_tags(): """``
`` with attributes and nested tags is matched and preserved.""" markdown = ( '
\n' - '
Source: Pew Research
\n' + "
Source: Pew Research
\n" "
Republican57
\n" "
\n" ) @@ -899,8 +905,7 @@ def test_inject_figures_more_descriptions_than_figures_returns_remaining(): def test_inject_figures_more_figures_than_descriptions_leaves_extras_untouched(): """Two figures, one description -> first figure enriched, second left raw.""" markdown = ( - "
\nfigure 1 content\n
\n" - "
\nfigure 2 content\n
\n" + "
\nfigure 1 content\n
\n
\nfigure 2 content\n
\n" ) result = PictureExtractionResult( descriptions=[_desc(name="Im0", description="Only description.")] diff --git a/surfsense_backend/tests/unit/tasks/chat/streaming/test_interrupt_inspector_all.py b/surfsense_backend/tests/unit/tasks/chat/streaming/test_interrupt_inspector_all.py index 348e49a4a..15ab89b73 100644 --- a/surfsense_backend/tests/unit/tasks/chat/streaming/test_interrupt_inspector_all.py +++ b/surfsense_backend/tests/unit/tasks/chat/streaming/test_interrupt_inspector_all.py @@ -151,8 +151,7 @@ async def test_preserves_state_interrupts_traversal_order(): state_order = [ i.value["tool_call_id"] for i in state.interrupts - if isinstance(getattr(i, "value", None), dict) - and "tool_call_id" in i.value + if isinstance(getattr(i, "value", None), dict) and "tool_call_id" in i.value ] assert inspector_order == state_order, ( diff --git a/surfsense_backend/tests/unit/tasks/chat/test_thinking_step_id_uniqueness.py b/surfsense_backend/tests/unit/tasks/chat/test_thinking_step_id_uniqueness.py index 4ce73bc2e..50f7b8070 100644 --- a/surfsense_backend/tests/unit/tasks/chat/test_thinking_step_id_uniqueness.py +++ b/surfsense_backend/tests/unit/tasks/chat/test_thinking_step_id_uniqueness.py @@ -70,7 +70,9 @@ def _tool_start(*, name: str, run_id: str) -> dict[str, Any]: } -async def _drain_step_ids(events: list[dict[str, Any]], *, step_prefix: str) -> set[str]: +async def _drain_step_ids( + events: list[dict[str, Any]], *, step_prefix: str +) -> set[str]: """Run ``_stream_agent_events`` once and return every emitted thinking-step ID.""" agent = _FakeAgent(events) service = VercelStreamingService() diff --git a/surfsense_web/app/(home)/blog/blog-magazine.tsx b/surfsense_web/app/(home)/blog/blog-magazine.tsx index f471d6919..fd6a82e58 100644 --- a/surfsense_web/app/(home)/blog/blog-magazine.tsx +++ b/surfsense_web/app/(home)/blog/blog-magazine.tsx @@ -68,9 +68,7 @@ export function BlogWithSearchMagazine({ blogs }: { blogs: BlogEntry[] }) { - {secondaryFeatured.length > 0 ? ( - - ) : null} + {secondaryFeatured.length > 0 ? : null} diff --git a/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx index 6bd2275fc..7b561365b 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllPrivateChatsSidebar.tsx @@ -1,7 +1,6 @@ "use client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; -import { formatThreadTimestamp } from "@/lib/format-date"; import { useSetAtom } from "jotai"; import { ArchiveIcon, @@ -49,6 +48,7 @@ import { searchThreads, updateThread, } from "@/lib/chat/thread-persistence"; +import { formatThreadTimestamp } from "@/lib/format-date"; import { cn } from "@/lib/utils"; import { SidebarSlideOutPanel } from "./SidebarSlideOutPanel"; @@ -389,8 +389,7 @@ export function AllPrivateChatsSidebarContent({

- {t("updated") || "Updated"}:{" "} - {formatThreadTimestamp(thread.updatedAt)} + {t("updated") || "Updated"}: {formatThreadTimestamp(thread.updatedAt)}

diff --git a/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx b/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx index 81d173f36..f859b61c9 100644 --- a/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx +++ b/surfsense_web/components/layout/ui/sidebar/AllSharedChatsSidebar.tsx @@ -1,7 +1,6 @@ "use client"; import { useQuery, useQueryClient } from "@tanstack/react-query"; -import { formatThreadTimestamp } from "@/lib/format-date"; import { useSetAtom } from "jotai"; import { ArchiveIcon, @@ -49,6 +48,7 @@ import { searchThreads, updateThread, } from "@/lib/chat/thread-persistence"; +import { formatThreadTimestamp } from "@/lib/format-date"; import { cn } from "@/lib/utils"; import { SidebarSlideOutPanel } from "./SidebarSlideOutPanel"; @@ -388,8 +388,7 @@ export function AllSharedChatsSidebarContent({

- {t("updated") || "Updated"}:{" "} - {formatThreadTimestamp(thread.updatedAt)} + {t("updated") || "Updated"}: {formatThreadTimestamp(thread.updatedAt)}