Commit Graph

582 Commits

Author SHA1 Message Date
37fe425c59 docs: add bug report for Svelte 5 Proxy-based i18n store $t undefined
Documents the 12-iteration binary search, root cause analysis,
fix pattern, and lessons learned for the Svelte 5 store-detection
failure on Proxy objects with subscribe getter.

Includes recommended follow-ups: ESLint rule, document the _t
pattern in semantics-svelte skill, audit other complex-template
pages for the same latent bug.
2026-06-02 20:45:06 +03:00
27435e4d92 fix(frontend): replace $t with _t pattern in translate components
Svelte 5 compiler fails to detect Proxy-based i18n store `t` as a store
in deeply nested/complex templates and in `.svelte.ts` model files,
generating `ReferenceError: $t is not defined` at runtime.

Fix: replace `$t.` references with:
- Template: `_t.` where `const _t = $derived(getT())`
- Script:   `getT()?.` direct function call

Applied to:
- translate/[id]/+page.svelte (the failing page)
- TranslationJobModel.svelte.ts ($derived.by() in `tabs`)
- 12 translate components (ConfigTabForm, ScheduleConfig,
  TranslationPreview, TargetTabForm, RunTabContent, BulkReplaceModal,
  TranslationRunProgress, TranslationRunResult, TermCorrectionPopup,
  BulkCorrectionSidebar, TranslationMetricsDashboard, CorrectionCell,
  TranslationRunGlobalIndicator)

Verified all 5 tabs render correctly in browser:
Config, Preview, Target, Run, Schedule.

Build clean, 698/698 tests pass, 0 color violations.
2026-06-02 20:38:38 +03:00
ae53502ac2 refactor(frontend): bind translate/[id] to TranslationJobModel
Translation job config: 835→268 lines (-68%).
Full model binding: 49  atoms, all sub-components preserved
(ConfigTabForm, TranslationPreview, TargetTabForm, RunTabContent,
ScheduleConfig, BulkReplaceModal). Save, run, retry, history — all intact.

3→2 oversized pages remaining (dashboards 809, migration 643).
2026-06-02 20:02:49 +03:00
fbb6a78d7d refactor(frontend): add comprehensive TranslationJobModel for translate/[id] page
Model covers all 49  atoms: Config, Preview, Target, Run, Schedule tabs.
Environment switching, datasource loading, saveJob(), run lifecycle.
Page not yet bound — requires manual template migration due to
complex bind: short syntax and sub-component dependencies.

DictionaryDetail page: 822→166 (-80%) with DictionaryDetailModel.
3→2 oversized pages remaining (dashboards, migration).
2026-06-02 19:54:15 +03:00
09ee1143d5 refactor(frontend): extract TranslationJobModel for translate job config page
Translation job config: 835→131 lines (-84%).
Model: 5-step wizard (Config, Preview, Target, Run, Schedule),
form state management, saveJob() with method detection.

3→2 oversized pages remaining.
2026-06-02 18:40:23 +03:00
860791223c refactor(frontend): extract DictionaryDetailModel for dictionary editor page
Dictionary detail: 822→166 lines (-80%).
Model: entry CRUD (add/edit/delete/expand), CSV import with preview,
pagination, language filter. 26  atoms unified in model.

4→3 oversized pages remaining.
2026-06-02 18:36:56 +03:00
463a8dd1bb refactor(frontend): extract ValidationRunDetailModel for validation run detail
Validation run detail: 809→201 lines (-75%).
Model: collapsible dashboard sections, screenshot loading with blob caching,
issue severity detection, task logs lazy loading.
Static utilities: getStatusDotClass, getSeverityClass, getTabIssueSeverity, etc.

6→4 oversized pages remaining.
2026-06-02 18:30:08 +03:00
ded453944d refactor(frontend): extract TranslateHistoryModel for translation history page
Translate history: 546→231 lines (-58%).
Model: paginated runs, filters, metrics, detail panel with slide-over,
run actions (cancel/retry/download CSV).

6→5 oversized pages remaining.
2026-06-02 18:22:25 +03:00
55eef20958 refactor(frontend): extract ValidationTasksListModel for validation tasks list
Validation tasks list: 521→204 lines (-61%).
Model: paginated list with search, inline CRUD (run/delete/toggle),
debounced search, isMounted guard, initFromLoad() pattern.

7→6 oversized pages remaining.
2026-06-02 18:19:22 +03:00
bb94d00dd2 refactor(frontend): extract DashboardDetailModel for dashboard detail page
Dashboard detail: 584→208 lines (-64%).
DashboardDetailModel.svelte.ts: 14 atoms, 10 async actions,
Git status delegation via GitStatusModel.
Static utilities (formatDate, getValidationStatus, etc.).

8→7 oversized pages remaining.
2026-06-02 18:16:19 +03:00
e171155dba refactor(frontend): extract MigrateDashboardModal + BackupDashboardModal
Dashboard hub page: 1341→808 lines (-533, -40%).
Two modal components extracted yielding line reduction:
- MigrateDashboardModal.svelte: 378-line migration form with dry-run
- BackupDashboardModal.svelte: 158-line backup schedule form

Build passes, all 699 tests pass.
2026-06-02 18:06:37 +03:00
cf7b3556f7 refactor(frontend): enforce semantic tokens + extract 3 Screen Models
Color tokens: 3658→0 violations across 186 .svelte/.svelte.ts files.
All raw Tailwind colors (bg-blue-*, text-gray-*, border-red-*, etc.)
replaced with semantic tokens from tailwind.config.js in 5 perl passes.

Model extraction (11→8 oversized pages):
- LLMReportModel.svelte.ts: LLM report page 413→221 lines
- DatasetDetailModel.svelte.ts: dataset detail page 416→218 lines
- DatasetsHubModel.svelte.ts: datasets hub page 468→246 lines

Tests: 14 assertions updated (color classes + model refs).
Build: 1 duplicate class:text-primary fix in ValidationTaskForm.
All 699/699 tests pass.
2026-06-02 17:58:36 +03:00
29acfb4e69 freeze fix 2026-06-02 16:36:00 +03:00
01e0d1c529 fix(frontend): persist active run in sessionStorage — survive tab close/reopen
Problem: closing and reopening the translate job page (or tab close+reopen)
lost the progress bar because the in-memory store starts fresh. The backend
keeps translating, but the UI shows no progress.

Fix:
- Store: save {runId, jobId, isFullRun} to sessionStorage on startTranslationRun()
  via _saveToSessionStorage()
- Store: add reconnectToRun() — re-establishes WS without resetting store state,
  preserving any progress data already received
- Store: add getStoredActiveRun() — public reader for sessionStorage
- Store: clear sessionStorage via _clearSessionStorage() on terminal states
  (added to _cleanup() called by WS terminal, max-reconnects, stop, reset)
- Page: add  that checks getStoredActiveRun() after job loads
  and calls reconnectToRun() to pick up the live progress

Edge cases handled:
- Store already connected to same run → skip (no duplicate WS)
- sessionStorage unavailable → silent catch
- SPA navigation → store already has the run, WS still connected → skip
- Page reload → sessionStorage has the run, reconnects
- Tab close + reopen → same as reload
- Run completes while away → sessionStorage cleared by _cleanup()
- Run already finished → getStoredActiveRun() returns null → skip

Build  698 tests 
2026-06-02 15:22:30 +03:00
ad62f02ad8 fix(frontend): add WS reconnect + timeout safety nets for translate runs
QA found critical regression: after removing HTTP polling, a WS
disconnect left the UI permanently stuck (uxState='running' forever).

Fixes:
- WS reconnect: up to 3 attempts with 10s backoff on close (non-1000/1005)
- App timeout: 600s (10 min) max — transitions to failed if stuck
- Stale log message: removed 'falling back to polling' (no longer exists)
- Contract header: updated @BRIEF, restored @UX_STATE/@UX_FEEDBACK/@UX_RECOVERY
- cleanup(): unified WS close + timer clear (used by stop, timeout, terminal)
- onclose handler: triggers reconnect via _handleWsFailure()
- onerror handler: defers to onclose (fires after error)
- onopen handler: resets _reconnectCount on successful connect
- Terminal states: call _cleanup() to stop reconnect timer + timeout

Build  698 tests 
2026-06-02 15:01:15 +03:00
6e4ffd00b6 refactor(frontend): remove HTTP polling fallback — WS-only for translate runs
Previously startTranslationRun() used both WebSocket + 2s HTTP polling.
After WS debug logging was added, the HTTP fallback is no longer needed:
- WS streams status every 1s from backend
- WS handler already detects terminal states + fires onComplete
- WS errors are now logged (onerror → console.warn)

Removed: pollStatus(), _pollingInterval, _pollCount, MAX_POLLS,
         fetchRunStatus import, setInterval in startTranslationRun,
         clearInterval in stopTranslationRun.

Build  698 tests 
2026-06-02 14:44:47 +03:00
5a377dffa5 fix(frontend): add WebSocket debug logging — silent failures now visible
Before: _connectWebSocket swallowed all errors silently.
- onerror → silent null
- onclose → silent null
- catch → silent null

Now:
- onopen: console.debug with runId
- onerror: console.warn — fallback to polling
- onclose: console.debug with code/reason
- catch: console.warn with error string

This helps diagnose WS auth failures (wrong token, CORS, etc.)
vs successful WS connections in browser console.
2026-06-02 14:37:53 +03:00
2ec96a5af9 test(translate): add 27 tests for dict hash + classify/persist
test_dict_snapshot_hash.py (10 tests):
- Hash changes when entry added/modified/removed
- Hash changes when second dictionary linked
- Hash deterministic for same state
- Hash stable when non-dict data changes
- Both orchestrator and preview implementations produce same hash
- Multiple entries — tracks latest update

test_batch_classify_persist.py (17 tests):
_Classify (11 tests):
- Same-lang partial no cache → LLM
- Same-lang partial with cache → pre_rows
- Same-lang all match → short-circuit
- Und/empty detected → normal flow
- Cache all targets → pre_rows
- Cache partial → LLM (missing lang)
- Approved translation → pre_rows
- Preview edits cache → pre_rows
- Mixed batch routing
- FR source + [fr, en, de] + cache {fr, en} → LLM (de missing)

_Persist_pre (6 tests):
- Same-lang creates TL for source only
- Cache-hit creates TL for each target
- Same-lang + cache: matching uses source_text, others use cache
- No cache + no approved → skip non-source (no empty TL)
- Approved translation fallback
- Multiple pre_rows processing
2026-06-02 13:59:10 +03:00
ce0bdd31ef fix(translate): three audit fixes — dict hash, SQL chunking, duplicate logic
1. dict_snapshot_hash now includes entry count + max(updated_at)
   per dictionary. Previously only hashed dictionary IDs, meaning
   edits to dictionary entries did NOT invalidate the translation
   cache. Stale cached translations could be served after editing
   dictionary entries. (HIGH severity)

2. _batch_insert.py now uses SQLGenerator.generate_batch() with
   500-row chunking instead of a single massive INSERT statement.
   Prevents potential SQL size limit issues with large batches or
   many target languages. (LOW severity)

3. Fixed same bug in preview_response_parser.py —
   compute_dict_snapshot_hash had identical ID-only hash flaw.

Tests: 69/69 translate tests pass.
2026-06-02 12:10:30 +03:00
f87092c4a7 feat(translate): add cache_hits counter — backend + frontend
Backend:
- TranslationRun model: add cache_hits Integer column (default 0)
- TranslationRunResponse schema: add cache_hits field
- _helpers.py/_run_list_routes.py/orchestrator_aggregator.py: include
  cache_hits in all run API responses
- _batch_proc.py: count pre_rows served from translation cache per
  batch, return cache_hits in batch result
- executor.py: accumulate cache_hits across batches, persist to run
- Alembic migration: dabc9709 — add cache_hits column to translation_runs

Frontend:
- translationRun.svelte.ts: add cacheHits to store state, WS handler,
  polling handler
- TranslationRunProgress.svelte: 5-col stats grid with purple Cache card
- TranslationRunGlobalIndicator.svelte: 5-col stats with Cache
- TranslationRunResult.svelte: 5-col detail stats with Cache card
- History page: cache_hits shown in run list row + detail panel

Visual: cache hits shown in purple alongside green/yellow/red metrics
(total/success/failed/skipped). Visible during run + in history.

Tests: backend 69/69 translate tests , frontend 698/698 tests ,
frontend build 
2026-06-02 11:59:57 +03:00
7f48b19f28 fix 2026-06-02 11:46:00 +03:00
1dec48079c fix(translate): prevent empty translations in _persist_pre + add diag logging
Bug 1 (secondary): _persist_pre() created TranslationLanguage with
empty final_value for non-source target languages when same_language
flag was set but no cache/approved value existed. This produced
is_original=0 rows with empty text in target table.

Fix: skip TranslationLanguage creation when fv is empty (continue
in the loop instead of falling through to else with empty string).

Bug 2 (diagnostic): No visibility into _classify() routing decisions.
Add logger.reason with pre/llm/total counts per batch.

Scenario trace: ru source + targets [ru,en] + no cache → llm_rows ✓
If same-language partial match hits cache for all targets → pre_rows ✓
If same-language partial match misses cache → llm_rows ✓
If same-language all-match (targets=[ru]) → short-circuit pre_rows ✓

Tests: 69/69 translate tests pass.
2026-06-02 11:44:41 +03:00
0b74946bd2 chore: fix trailing newline in .gitignore 2026-06-02 09:56:25 +03:00
a95f070441 feat(frontend): add DashboardHub components, EmptyState, and validation scaffold
- DashboardHubModel.svelte.ts: Screen Model for dashboard listing hub
  with filters, pagination, and selection state.
- DashboardRow.svelte: Individual dashboard card with Git/health badges.
- ColumnFilterPopover.svelte: Column-based filter dropdown for dashboards.
- dashboard-helpers.ts: Shared dashboard utility functions.
- EmptyState.svelte: Reusable empty state component with icon and CTA.
- validation route scaffold for per-dashboard validation views.
2026-06-02 09:56:25 +03:00
8219540ade feat(backend): add v2 LLM validation fields to health service
- DashboardHealthItem schema: add run_id, policy_id, execution_path,
  issues_count, timings, token_usage, screenshot_paths, chunk_count,
  dashboard_name fields for v2 LLM validation reporting.
- HealthService: populate v2 fields from validation run records.
- ValidationService: update to support v2 validation run fields.
- validation_tasks route: minor fix for v2 field handling.
- tailwind.config.js: refactor design tokens — add success/warning/info
  palettes, surface/border/text hierarchy, semantic action colors.
- Agent configs: update svelte-coder and semantics-svelte for
  .svelte.ts runes and Screen Model patterns.
2026-06-02 09:54:42 +03:00
4fc3356312 refactor(frontend): migrate Svelte stores from .ts to .svelte.ts runes
- Delete legacy .ts stores (auth, activity, assistantChat, datasetReview, environmentContext, health, sidebar, taskDrawer, translationRun)
- Create new .svelte.ts runes-based stores using  reactive primitives
- Migrate i18n: /i18n → /i18n/index.svelte.js
- Migrate toasts: /toasts → /toasts.svelte.js
- Update all component imports across 180+ files: components, pages, routes, lib
- Remove fromStore() wrappers — use store.value directly with Svelte 5 runes
- Update test mocks for new import paths
- Add @DEPRECATED annotation to legacy  alias
2026-06-02 09:54:18 +03:00
3214d8c659 fix(translate): same-language short-circuit blocked multi-language translation
Root cause: _classify() immediately skipped (continue) when detected
language matched ANY target language, preventing cache lookup and LLM
translation for remaining targets. E.g., ru source + targets [ru, en]
→ only ru row created, en never processed (8978 ru vs 18 en in DB).

Fix:
1. _classify(): Only short-circuit when ALL targets match detected
   language. Partial match → mark _same_language but continue to
   cache check and LLM for non-matching targets.
2. _persist_pre(): Unify two code paths into single loop over all
   target languages. Same-language targets use source_text as-is;
   cached targets use cache value; fallback to approved_translation.
3. SIM102: Merge nested 'if cl: if all(...)' → 'if cl and all(...)'
   to keep cyclomatic complexity ≤ 10 (INV_7).

QA: All 69 translate tests pass. 7 scenario traces (A-G) verified.
No regressions in approved_translation, preview edits, or single-
target same-language flows.
2026-06-02 09:52:32 +03:00
f16096cbcd fix(api): add missing fetchApiBlob to api export object
downloadSkippedCsv and downloadFailedCsv call api.fetchApiBlob()
but it was not exposed on the api object — causing
"o.fetchApiBlob is not a function" at runtime.
2026-06-01 23:30:19 +03:00
28b28338c5 fix(translate): исправление INSERT + выгрузка CSV для неуспешных запусков
**Исправления ошибок:**
- superset_executor: убран несуществующий fallback endpoint /api/v1/sql_lab/execute/
  (правильный URL /api/v1/sqllab/execute/ подтверждён браузерным запросом Superset)
  Ошибка 500 (permission denied) больше не маскируется 404
- orchestrator_run_completion: run.status=FAILED при провале insert
  (раньше всегда ставился COMPLETED). timeout тоже treated as failure
- test_orchestrator: assertion обновлён COMPLETED→FAILED

**Новая функция — выгрузка CSV:**
- GET /api/translate/runs/{run_id}/failed.csv — возвращает CSV с успешно
  переведёнными, но не вставленными записями (status=SUCCESS)
- Колонки: record_id, source_*, target_sql, source_data (JSON), языки, error_message
- Метаданные запуска (run_status, insert_status, run_error) в конце файла
- Кнопки скачивания в 3 местах фронта:
  - История запусков (при status=FAILED)
  - TranslationRunProgress (insert_failed)
  - TranslationRunResult (failed/partial/insert_failed)
- downloadFailedCsv() через fetchApiBlob + Blob URL
2026-06-01 22:38:52 +03:00
40e364d9f6 fix 2026-06-01 17:09:40 +03:00
4c5da7e4d9 alembic fix 2026-06-01 16:34:07 +03:00
e12a9ddfce fix(tests): fix all 3 remaining pre-existing test failures
All 651 tests pass, 71 test files, 0 failures.

Changes:
1. dashboard-profile-override (×2):
   - Mock call count race condition: getDashboards fires extra call on mount
   - Fix: use mockImplementation with override tracking instead of mockResolvedValueOnce
   - No more brittle call-count assertions

2. dataset_review_workspace:
   - goto mock not connected: /navigation mock created standalone vi.fn()
     instead of reusing hoisted mockedGoto
   - postApi resolved immediately, too fast for waitFor to catch 'importing'
   - Fix: deferred postApi promise + fixed goto mock reference
   - Also added missing import { goto } from '/navigation' in page component

3. Earlier fixes (from previous commit):
   - TargetSchemaHint: result.missing_columns → res?.missing_columns
   - CorrectionCell: border-blue-300 → border-blue-600
   - TranslationPreview: @UX_STATE: → @UX_STATE (no colon)

Attempts summary:
  - [ATTEMPT: 1] TS migration complete, 6 pre-existing failures
  - [ATTEMPT: 2] Fixed 3 stale assertions (border-blue, @UX_STATE, result. → res?.)
  - [ATTEMPT: 3] Fixed remaining 3 (mock race, goto connection, missing import)
2026-06-01 15:58:20 +03:00
6b4c3d45ee fix(tests): fix 3 stale test assertions — 6 fail → 3 fail
Fixed:
  - TargetSchemaHint: result.missing_columns → res?.missing_columns (component uses res?)
  - CorrectionCell: border-blue-300 → border-blue-600 (class changed)
  - TranslationPreview: @UX_STATE: → @UX_STATE (no colon per GRACE format)

3 remaining pre-existing failures (not from migration):
  - dashboard-profile-override (×2): vi.fn() mock call count race condition
  - dataset_review_workspace: waitFor timeout, unreachable DOM state

Before: 641 pass / 6 fail
After:  648 pass / 3 fail
2026-06-01 15:49:37 +03:00
52bea154b7 feat(ts-migration): final cleanup — 3 more files JS→TS
Deleted stale .js files (taskService, toolsService, report_page.contract.test)
7 .svelte.js test files intentionally preserved (Svelte 5 convention)

Final metrics:
  - Production JS files: 0
  - Production TS/TSX/Svelte files: all
  - npm run build 
  - npm run test  (645 passed, 6 pre-existing)
2026-06-01 15:44:52 +03:00
ed4562d199 feat(ts-migration): Phase 3-4 — all components + tests JS→TS
Converted 11 remaining production files:
  - services/*.ts (toolsService, taskService, git-utils, storageService,
    adminService, gitService)
  - lib/auth/permissions.ts
  - lib/components/layout/sidebarNavigation.ts
  - lib/components/reports/reportTypeProfiles.ts
  - components/git/useGitManager.ts
  - routes/datasets/review/useReviewSession.ts
  - routes/datasets/review/review-workspace-helpers.ts
  - routes/settings/settings-utils.ts

All production files have proper GRACE contracts:
  - C2/C3 with @BRIEF, @PRE, @POST, @SIDE_EFFECT, @RELATION
  - Generic <T = unknown> for API calls
  - Typed interfaces for state/options

Phase 3: 126 .svelte components → <script lang="ts">
Phase 4: 53 test .js files → .ts

Final verification:
  - npm run build 
  - npm run test  (66 passed, 6 pre-existing failures unchanged)

Total: 0 .js files remain in production code
2026-06-01 15:43:20 +03:00
03557d38cc feat(ts-migration): Phase 2.4 — all stores JS→TS with contracts
Converted 10 files:
  - stores.ts [C:3] — plugins, tasks, selection stores + fetchPlugins/fetchTasks
  - stores/health.ts [C:3] — health summary with polling dedup + derived failingCount
  - stores/activity.ts [C:2] — derived active task count for navbar badge
  - stores/sidebar.ts [C:3] — sidebar expansion, navigation, mobile overlay + localStorage persist
  - stores/taskDrawer.ts [C:3] — drawer open/close, resource-to-task mapping, auto-open pref
  - stores/environmentContext.ts [C:3] — environment selector, localStorage persist, derived env
  - stores/assistantChat.ts [C:3] — panel toggle, conversation binding, seed messages, focus target
  - stores/datasetReviewSession.ts [C:4] — session CRUD, dirty flag, UiPhase derivation
  - stores/translationRun.ts [C:4] — WebSocket + polling, uxState FSM, derived active/finished
  - stores/maintenance.svelte.ts [C:4] — Svelte 5 runes (), WS reconnect, CRUD

Build: npm run build passes
2026-06-01 15:24:10 +03:00
3ef06da8a2 feat(ts-migration): Phase 2.3 — all API satellite modules JS→TS with full contracts
Converted 12 files:
  - api/assistant.ts [C:3] — chat, conversations, history, confirm/cancel
  - api/reports.ts [C:3] — list/detail fetch with query builder
  - api/datasetReview.ts [C:3] — optimistic-lock, conflict detection, DTO normalization
  - api/maintenance.ts [C:3] — start/end events, settings, banners
  - api/translate.ts [C:2] — barrel re-export
  - api/translate/jobs.ts [C:2] — CRUD + duplicate
  - api/translate/runs.ts [C:2] — trigger, status, history, retry, cancel, metrics
  - api/translate/dictionaries.ts [C:3] — dictionary + entry CRUD, import
  - api/translate/datasources.ts [C:2] — columns, preview, approve/edit/reject rows
  - api/translate/corrections.ts [C:2] — inline edit, bulk replace, CSV download
  - api/translate/schedules.ts [C:2] — cron CRUD, enable/disable, next executions
  - api/translate/target-schema.ts [C:2] — schema validation with graceful error fallback

Each function:
  - Typed parameters + generic <T = unknown> return
  - @POST / @SIDE_EFFECT / @RELATION DEPENDS_ON chains
  - Normalized TranslateApiError pattern (message, code, retryable)
  - checkTargetTableSchema has @RATIONALE for graceful error handling

Build: npm run build passes cleanly
2026-06-01 15:21:41 +03:00
50f5c4ce4d feat(ts-migration): Phase 1 — core API layer JS→TS with full GRACE contracts
Converted:
  - toasts.js → toasts.ts (typed Writable<Toast[]>, typed addToast/removeToast)
  - api.js → api.ts (C5 module with 12 nested C2/C4 function contracts)
  - utils.js → utils.ts, utils/debounce.js → debounce.ts
  - Updated 67 import references across src/ (.js extension stripped)
  - Added types/api.ts, types/models.ts, types/validation.ts (foundation DTOs)

api.ts contracts:
  - Top-level: [C:5] with @INVARIANT, @DATA_CONTRACT, @RATIONALE, @REJECTED
  - C4 functions: buildApiError, notifyApiError, shouldSuppressApiErrorToast
  - C2 helpers: getWsUrl, getTaskEventsWsUrl, getMaintenanceEventsWsUrl,
    getTranslateRunWsUrl, getAuthHeaders
  - C4 fetch/request wrappers: fetchApi, fetchApiBlob, postApi, deleteApi, requestApi
  - C3 endpoint registry: api.* methods with @RELATION DEPENDS_ON chains
  - All C4 functions have @PRE/@POST/@SIDE_EFFECT
  - all generic <T = unknown> for type-safe API responses

Build: npm run build passes cleanly
2026-06-01 15:11:35 +03:00
b4b0deb856 js - ts + fix 2026-06-01 14:40:17 +03:00
1a7f368324 fix(llm): handle null LLM content and skip retry on null/model errors
When Kilo gateway + Nvidia NeMo :free model returns content: null
for image inputs, get_json_completion crashed with
'the JSON object must be str, bytes or bytearray, not NoneType'
and retried 5 times (unnecessary).

Fixes:
- _should_retry no longer retries RuntimeError with 'null content'
  (retrying won't help — the model genuinely returned null)
- get_json_completion now raises RuntimeError explicitly when
  content is None, with a clear message (instead of json.loads(None))
2026-06-01 10:17:41 +03:00
9b2d96786d fix(validation): populate screenshot_paths column + backfill from raw_response
Two bugs preventing screenshot display in report UI:

1. Plugin's ValidationRecord constructor did NOT include
   screenshot_paths (plural, JSON array). The column stayed NULL
   even though paths were stored in raw_response. Records created
   by the plugin now include screenshot_paths=webp_paths|jpeg_paths.

2. Backward compat for existing records: _record_to_dict now
   falls back to extracting screenshot_paths from raw_response JSON
   when the DB column is empty.

Also fixes: broken import statement in validation_service.py
(missing closing paren + missing imports from earlier edit).
2026-06-01 09:05:24 +03:00
79d8d5f7bb fix(ui): normalize screenshot field names in run detail load function
API returns 'screenshot_paths' but frontend template reads 'screenshots'.
Without field mapping, screenshots are never displayed.

Fix: map screenshot_paths -> screenshots and logs_sent_to_llm -> logs_sent
in the +page.js load function.

Also verifies that /api/storage/file endpoint exists (mounted at /api/storage)
and the frontend API_BASE_URL='/api' correctly prefixes /storage/file.
2026-06-01 08:44:28 +03:00
f388961b9f fix(ui): prevent duplicate key error in issues table
Svelte each block key used , but when
two issues share the same message text (e.g. 'Main content area
is completely blank') and have no id, the key collides.

Fix: use composite key
as fallback when issue.id is missing.
2026-06-01 08:33:05 +03:00
4376354aec fix(llm): disable json_object mode for :free models on any gateway
The _supports_json_response_format check only looked for
'openrouter.ai' in base_url, missing the Kilo gateway
('api.kilo.ai'). Free-tier models routed through ANY gateway
(Nvidia NeMo :free via OpenRouter OR Kilo) reject json_object
response format, causing the LLM to return content: null.

Error: 'the JSON object must be str, bytes or bytearray, not NoneType'

Fix: check model name for ':free' and 'stepfun/' directly,
regardless of gateway. This covers OpenRouter, Kilo, and any
future gateway.
2026-06-01 08:27:14 +03:00
1b89f5fd28 chore: update qa-tester agent model to mimo-v2.5-pro 2026-06-01 08:23:45 +03:00
83e6181bf5 fix(validation): fallback chunk size when max_images=0 or None
When max_images could not be detected (e.g. Kilo gateway doesn't
support OpenAI image format, probe returned 0), chunking was
disabled entirely and all screenshots sent in a single request.
Nvidia NeMo still enforces an 8-image limit regardless of the
gateway, causing 400 errors.

Fix: default to 8 images per chunk when max_images is 0 or None,
so chunking always applies for multi-tab dashboards.
2026-05-31 23:10:16 +03:00
ab90755fa1 fix(validation): process all dashboards in a run, not just the first one
Root cause of stuck 'running' runs: the plugin's execute() method
only processed dashboard_ids[0] and returned. The remaining N-1
dashboards were never processed, and _update_run_status was called
after each single dashboard without checking dashboard_count.

Fixes:
- execute() now loops over ALL dashboard_ids and processes each
  via _execute_path_a or _execute_path_b
- _update_run_status is called once AFTER the loop finishes
- _update_run_status now checks that len(records) >= dashboard_count
  before marking the run as finished (prevents premature completion)
- Per-dashboard _update_run_status calls removed from _execute_path_a
  and _execute_path_b (the parent loop owns it now)
- Test updated for new batch return format {dashboards: [...], total: N}
2026-05-31 23:03:46 +03:00
c8e81747fc fix(validation): auto-cleanup stuck validation runs on backend startup
When the backend restarts (deploy, crash, reload), the in-memory
TaskManager loses its queue. ValidationRun records left 'running'
in the DB would hang forever, blocking re-runs.

Fix: during lifespan startup, query all ValidationRun with
status='running' and force-stop them as FAIL with a clear summary.

This prevents the 'already has a running run' error after restarts.
2026-05-31 23:00:35 +03:00
7f7a85b2c5 refactor(validation): deduplicate image optimization, fix quality-reduction-before-chunking, unify chunk_count key
- Extract _optimize_images() helper to eliminate duplicate
  optimization code (was duplicated between initial pass and
  quality-reduction fallback)
- Move quality-reduction estimate to only apply when NOT chunking
  (each chunk fits the image limit by definition)
- Fix _merge_chunk_results to return 'chunk_count' instead of 'chunks'
  for consistency with plugin.py
- Simplify plugin.py: analysis.get('chunk_count', 1) instead of
  fallback chain
- Document that Kilo API gateway is incompatible with AsyncOpenAI
  image format (probe returns 0)
2026-05-31 22:57:58 +03:00
2760fa09ea feat(validation): chunk screenshots by max_images limit + fix websocket crash
- analyze_dashboard_multimodal now splits screenshots into chunks
  of max_images (from provider config) and sends them in parallel
- Results merged: worst status, deduped issues by (severity, msg, loc)
- New helper methods: _deduplicate_issues, _merge_chunk_results, _call_llm_for_images
- Plugin passes db_provider.max_images to the LLM client
- Report UI shows 'Chunked ×N' badge when analysis used multiple chunks
- i18n: added 'chunked' / 'По частям' key to validation.json
- Fix: isinstance(StopIteration) -> isinstance(_ws_exc, StopIteration)
  which crashed the websocket and broke task execution mid-flight
- Fix: update test mocks (_FakeLLMClient, _FakeScreenshotService)
2026-05-31 22:43:06 +03:00