Skip to content

Commit a798dc3

Browse files
types(api): use typed exclusion_rules at search and startup
1 parent eb1327a commit a798dc3

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

api/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import sqlite3
1212
from typing import Any
1313

14-
from flask import Blueprint, Response, current_app, request
14+
from flask import Blueprint, Response, request
1515

16-
from api.flask_config import json_response
16+
from api.flask_config import exclusion_rules, json_response
1717

1818
from models import ParseWarningCollector, SearchResult
1919
from services.search import (
@@ -138,7 +138,7 @@ def search() -> tuple[Response, int] | Response:
138138
if workspace_filter and not _workspace_exists(workspace_filter, workspace_path):
139139
return _search_error("Workspace not found", "workspace_not_found", 404)
140140

141-
rules = current_app.config.get("EXCLUSION_RULES") or []
141+
rules = exclusion_rules()
142142
all_history = request.args.get("all_history") in ("1", "true")
143143
since_ms = resolve_search_since_ms(
144144
all_history=all_history,

app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def create_app(exclusion_rules_path: str | None = None) -> Flask:
5353
# Exclusion rules: optional path (CLI or default ~/.cursor-chat-browser/exclusion-rules.txt).
5454
# Rules are loaded once at startup; an app restart is required to pick up changes to the file.
5555
resolved = resolve_exclusion_rules_path(exclusion_rules_path)
56+
loaded_rules = load_rules(resolved)
5657
app.config["EXCLUSION_RULES_PATH"] = resolved
57-
app.config["EXCLUSION_RULES"] = load_rules(resolved)
58+
app.config["EXCLUSION_RULES"] = loaded_rules
5859

5960
@app.context_processor
6061
def inject_year() -> dict[str, int]:
@@ -75,7 +76,7 @@ def inject_year() -> dict[str, int]:
7576

7677
start_search_index_background(
7778
resolve_workspace_path(),
78-
app.config["EXCLUSION_RULES"],
79+
loaded_rules,
7980
)
8081
except Exception:
8182
logging.getLogger(__name__).exception("Failed to start search index background worker")

0 commit comments

Comments
 (0)