Skip to content

perf(runtime): keep pages and background tasks responsive - #173

Merged
TNT-Likely merged 2 commits into
mainfrom
fix/nonblocking-runtime
Oct 3, 2026
Merged

TNT-Likely merged 2 commits into
mainfrom
fix/nonblocking-runtime

Conversation

@TNT-Likely

@TNT-Likely TNT-Likely commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Background

Slow market-data calls and SQLite writes in async workflows could freeze unrelated requests. Portfolio, Agent, Settings, evaluation, and paper-trading pages also waited for their slowest secondary request before displaying usable data. Premarket prompts reused a global postmarket report, allowing disabled stocks to appear in the input.

This PR is stacked on #172 (fix/dashboard-loading) so its diff contains only this follow-up. It is ready for user acceptance and must remain unmerged until accepted.

Changes

  • Move blocking provider calls, research context construction, portfolio review preparation, authentication, and health probes into workers. Run assistant task controls, event persistence, approval writes, exports, and price-alert writes with worker-owned database sessions; finish in-flight writes before cancellation cleanup.
  • Queue SQLite log writes on a bounded background writer, deduplicate and parallelize raw K-line batches, bound retry/throttle budgets, and prevent stock-list fallback timeouts from waiting for executor shutdown. Fetch add-position context concurrently and reuse quotes.
  • Publish independent page data as it arrives. Render portfolio metadata before quotes, FX, suggestions, alerts, and K-lines; show unpriced totals as unavailable. Keep paper-trade pagination independent of account, position, and metric refreshes.
  • Make premarket analysis independent of postmarket reports. Scope intraday historical context to the current stocks and markets, retaining the source report date.
  • Remove manual useful/useless feedback from UI, APIs, types, statistics, and models. Migration 134 drops suggestion_feedback and entry_candidate_feedback; automated validation outcomes remain intact.
  • Retire the unused chart_analyst and news_digest agents. Delete the chart Agent implementation, prompt, registry entry, seed, runtime special cases, active UI descriptions, and release smoke trigger. Migration 135 removes their configuration, stock bindings, and throttle state. Ignore retired Agents in old backup imports and current suggestion/candidate queries; preserve historical reports and labels. The four active analysis agents and the shared screenshot collector remain in use.
  • Align AI and notification cards with equal height; place system settings across the full row and display preferences beside MCP tokens. Keep mobile sections stacked. Avoid read-side price-alert counter resets that could autoflush over worker writes.

Validation

  • .venv/bin/python -m pytest tests -q --disable-warnings: 980 passed, 3 skipped.
  • .venv/bin/python -m pytest packages/marketdata/tests/test_http.py -q --disable-warnings: 8 passed.
  • pnpm --dir frontend exec vitest run: 212 passed across 55 files.
  • pnpm --dir frontend check:ui, check:i18n, check:market-colors, and build: passed. Build retains the existing large-chunk warning.
  • Browser QA on the actual Settings and portfolio pages at 1440 px and 390 px, in light and dark themes, with delayed secondary APIs: independent rendering, card layout, scrolling, modal focus/Escape, feedback removal, and no horizontal overflow or page errors verified. Delays were mocked; these are responsiveness checks, not production latency benchmarks.
  • git diff --check and bash -n scripts/pre_release_check.sh: passed.

Boundaries and risks

  • Upgrade permanently removes legacy manual feedback records and indexes, as requested. It does not remove automated prediction/candidate outcomes or analysis history. Historical migrations are preserved.
  • Third-party providers can still be slow. Retry and throttle budgets limit additional waits; an individual HTTP operation is still governed by its transport timeouts. Running synchronous work cannot be interrupted mid-call.
  • Assistant cancellation waits for an in-flight database transaction to finish before cleanup; the event loop remains responsive. The log queue is bounded and can discard oldest entries under sustained database failure.
  • Migration 135 also permanently removes configuration and bindings for the two retired agents. Existing reports and run history remain readable, and old configuration imports cannot re-enable them.
  • Existing page structure and trading schedules are retained; this change does not redesign the homepage.

Follow-up

Merge #172 first, then retarget this PR to main and merge only after user acceptance.

@TNT-Likely
TNT-Likely force-pushed the fix/nonblocking-runtime branch from e27e863 to 79706ef Compare October 3, 2026 11:22
@TNT-Likely
TNT-Likely changed the base branch from fix/dashboard-loading to main October 3, 2026 11:22
@TNT-Likely
TNT-Likely merged commit ee97ddc into main Oct 3, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant