From 21aa3c2247b006da2aeca349771298c2e200cd08 Mon Sep 17 00:00:00 2001 From: yilsem Date: Fri, 9 Oct 2026 12:09:50 +0300 Subject: [PATCH] fix(test): separate browser preview from Playwright compiler project --- .../e2e/fixtures/codex-link-settings.tsx | 19 ------------ .../scripts/check-codex-link-layout.mjs | 4 +-- .../visual-fixtures/codex-link-settings.tsx | 29 +++++++++++++++++++ .../codex-link-settings.html | 2 +- 4 files changed, 32 insertions(+), 22 deletions(-) delete mode 100644 apps/desktop/e2e/fixtures/codex-link-settings.tsx create mode 100644 apps/desktop/src/visual-fixtures/codex-link-settings.tsx rename apps/desktop/{e2e/fixtures => visual-fixtures}/codex-link-settings.html (66%) diff --git a/apps/desktop/e2e/fixtures/codex-link-settings.tsx b/apps/desktop/e2e/fixtures/codex-link-settings.tsx deleted file mode 100644 index b54166a..0000000 --- a/apps/desktop/e2e/fixtures/codex-link-settings.tsx +++ /dev/null @@ -1,19 +0,0 @@ -// Synthetic, isolated visual acceptance fixture. Never contacts the installed manager. -import '../../src/styles.css' -import { createRoot } from 'react-dom/client' -import { CodexLinkSettings } from '../../src/app/settings/codex-link-settings' -import { I18nProvider } from '../../src/i18n/context' -import { ThemeProvider } from '../../src/themes/context' -import type { CodexLinkControlRequest, CodexLinkControlResponse, CodexLinkSettings as Settings } from '../../codex-link-control.types' - -let saved: Settings = { settings_revision: 1, enabled: true, compression_enabled: true, threshold_tokens: 250000, source_binding_handle: 'source-demo', compact_route_id: 'Compact', legacy_intent_imported: false, ownership_manifest_revision: 1, activation_state: 'ready' } -const budget = { target_id: 'target-demo', canonical_leaf_id: 'leaf-demo', limits_source: 'verified_adapter' as const, limits_revision: 'limits-1', tokenizer_id: 'tokenizer-demo', tokenizer_revision: '1', count_method: 'exact_tokenizer' as const, serialization_revision: '1', input_tokens: 85000, context_window_tokens: 100000, output_cap_tokens: 8000, safety_margin_tokens: 1000, max_input_tokens: null, max_output_tokens: 8000, request_bytes: 400000, max_request_bytes: 4000000, output_cap_enforcement: { method: 'request_field' as const, field: 'max_output_tokens' as const, value: 8000, proof_revision: '1', verified: true as const } } -window.hermesDesktop = { codexLink: { control: async (request: CodexLinkControlRequest): Promise => { - const base = { contract_version: 'codex-link/1' as const, request_id: request.request_id, operation_id: request.operation_id } - if (request.kind === 'status_get') return { ...base, kind: 'status_result', status: { settings_revision: saved.settings_revision, runtime_mode: 'managed', native_available: true, external_admission: 'open', needs_restart: false, catalog_state: 'fresh', active_turns: 0, uncertain_operations: 0, last_operation_id: null, error: null } } - if (request.kind === 'context_views_get') return { ...base, kind: 'context_views_result', settings_revision: saved.settings_revision, views: [{ view_handle: 'view-demo', can_compact: true, label: 'Proje sohbeti · örnek kayıt', checkpoint_revision: 4, current_model_label: '100 bin bağlamlı model', limiting_target_id: budget.target_id, target_budgets: [budget], active_summary_count: 3, summary_tokens: 20000, summary_token_measurement: { target_id: budget.target_id, tokenizer_id: budget.tokenizer_id, tokenizer_revision: budget.tokenizer_revision, count_method: budget.count_method }, last_operation_id: null, last_operation_state: null, last_operation_error: null, compact_attempts: [] }] } - if (request.kind === 'settings_update') saved = { ...saved, ...request.patch, settings_revision: saved.settings_revision + 1 } - if (request.kind === 'catalog_sync' || request.kind === 'context_compact_view') return { ...base, kind: 'control_accepted', settings_revision: saved.settings_revision, operation_state: 'accepted', error: null } - return { ...base, kind: 'settings_result', settings: saved, available_sources: [{ source_binding_handle: 'source-demo', label: 'AITURK hesabı', authorized: true }] } -} } } as typeof window.hermesDesktop -createRoot(document.getElementById('root')!).render(
) diff --git a/apps/desktop/scripts/check-codex-link-layout.mjs b/apps/desktop/scripts/check-codex-link-layout.mjs index 6b7ed79..cb20b4a 100644 --- a/apps/desktop/scripts/check-codex-link-layout.mjs +++ b/apps/desktop/scripts/check-codex-link-layout.mjs @@ -18,7 +18,7 @@ try { let ready = false for (let i = 0; i < 100; i++) { if (server.exitCode !== null) throw new Error('Preview server exited: ' + log) - try { ready = (await fetch(`http://127.0.0.1:${port}/e2e/fixtures/codex-link-settings.html`)).ok } catch {} + try { ready = (await fetch(`http://127.0.0.1:${port}/visual-fixtures/codex-link-settings.html`)).ok } catch {} if (ready) break await new Promise(resolve => setTimeout(resolve, 300)) } @@ -29,7 +29,7 @@ try { const page = await browser.newPage({ viewport: { width, height: 900 }, reducedMotion: 'reduce' }) const errors = [] page.on('pageerror', error => errors.push(error.message)) - await page.goto(`http://127.0.0.1:${port}/e2e/fixtures/codex-link-settings.html`, { waitUntil: 'domcontentloaded', timeout: 90000 }) + await page.goto(`http://127.0.0.1:${port}/visual-fixtures/codex-link-settings.html`, { waitUntil: 'domcontentloaded', timeout: 90000 }) await page.getByText('Proje sohbeti · örnek kayıt').waitFor({ timeout: 90000 }) await page.evaluate(() => document.fonts.ready) const layout = await page.evaluate(() => ({ width: innerWidth, scroll: document.documentElement.scrollWidth, buttons: [...document.querySelectorAll('button:not([role=switch]), input, select, label[for="codex-link-enabled"], label[for="codex-link-compression"]')].map(element => ({ text: element.textContent || element.id, height: element.getBoundingClientRect().height })) })) diff --git a/apps/desktop/src/visual-fixtures/codex-link-settings.tsx b/apps/desktop/src/visual-fixtures/codex-link-settings.tsx new file mode 100644 index 0000000..3b58c20 --- /dev/null +++ b/apps/desktop/src/visual-fixtures/codex-link-settings.tsx @@ -0,0 +1,29 @@ +// Synthetic, isolated visual acceptance fixture. Never contacts the installed manager. +import '../styles.css' + +import { createRoot } from 'react-dom/client' + +import type { CodexLinkControlRequest, CodexLinkControlResponse, CodexLinkSettings as Settings } from '../../codex-link-control.types' +import { CodexLinkSettings } from '../app/settings/codex-link-settings' +import { I18nProvider } from '../i18n/context' +import { ThemeProvider } from '../themes/context' + +let saved: Settings = { settings_revision: 1, enabled: true, compression_enabled: true, threshold_tokens: 250000, source_binding_handle: 'source-demo', compact_route_id: 'Compact', legacy_intent_imported: false, ownership_manifest_revision: 1, activation_state: 'ready' } +const budget = { target_id: 'target-demo', canonical_leaf_id: 'leaf-demo', limits_source: 'verified_adapter' as const, limits_revision: 'limits-1', tokenizer_id: 'tokenizer-demo', tokenizer_revision: '1', count_method: 'exact_tokenizer' as const, serialization_revision: '1', input_tokens: 85000, context_window_tokens: 100000, output_cap_tokens: 8000, safety_margin_tokens: 1000, max_input_tokens: null, max_output_tokens: 8000, request_bytes: 400000, max_request_bytes: 4000000, output_cap_enforcement: { method: 'request_field' as const, field: 'max_output_tokens' as const, value: 8000, proof_revision: '1', verified: true as const } } + +const bridge: Pick, 'codexLink'> = { codexLink: { control: async (request: CodexLinkControlRequest): Promise => { + const base = { contract_version: 'codex-link/1' as const, request_id: request.request_id, operation_id: request.operation_id } + + if (request.kind === 'status_get') {return { ...base, kind: 'status_result', status: { settings_revision: saved.settings_revision, runtime_mode: 'managed', native_available: true, external_admission: 'open', needs_restart: false, catalog_state: 'fresh', active_turns: 0, uncertain_operations: 0, last_operation_id: null, error: null } }} + + if (request.kind === 'context_views_get') {return { ...base, kind: 'context_views_result', settings_revision: saved.settings_revision, views: [{ view_handle: 'view-demo', can_compact: true, label: 'Proje sohbeti · örnek kayıt', checkpoint_revision: 4, current_model_label: '100 bin bağlamlı model', limiting_target_id: budget.target_id, target_budgets: [budget], active_summary_count: 3, summary_tokens: 20000, summary_token_measurement: { target_id: budget.target_id, tokenizer_id: budget.tokenizer_id, tokenizer_revision: budget.tokenizer_revision, count_method: budget.count_method }, last_operation_id: null, last_operation_state: null, last_operation_error: null, compact_attempts: [] }] }} + + if (request.kind === 'settings_update') {saved = { ...saved, ...request.patch, settings_revision: saved.settings_revision + 1 }} + + if (request.kind === 'catalog_sync' || request.kind === 'context_compact_view') {return { ...base, kind: 'control_accepted', settings_revision: saved.settings_revision, operation_state: 'accepted', error: null }} + + return { ...base, kind: 'settings_result', settings: saved, available_sources: [{ source_binding_handle: 'source-demo', label: 'AITURK hesabı', authorized: true }] } +} } } + +Object.assign(window, { hermesDesktop: bridge }) +createRoot(document.getElementById('root')!).render(
) diff --git a/apps/desktop/e2e/fixtures/codex-link-settings.html b/apps/desktop/visual-fixtures/codex-link-settings.html similarity index 66% rename from apps/desktop/e2e/fixtures/codex-link-settings.html rename to apps/desktop/visual-fixtures/codex-link-settings.html index f26a382..e5a7279 100644 --- a/apps/desktop/e2e/fixtures/codex-link-settings.html +++ b/apps/desktop/visual-fixtures/codex-link-settings.html @@ -1,2 +1,2 @@ -Codex Bağlama kabul görünümü
+Codex Bağlama kabul görünümü