✨ feat(context-preview): in-context review panel with segment-aware highlighting#4429
Open
✨ feat(context-preview): in-context review panel with segment-aware highlighting#4429
Conversation
… and collection Introduce SegmentMetadataMarshaller enum as single source of truth for valid metadata keys with marshall/unmarshall type conversion. Add SegmentMetadataMapper to map XLIFF trans-unit attributes to DB-ready SegmentMetadataStruct entries, and SegmentMetadataCollection as a purpose-built read-only collection with typed find() lookup. Refactor all consumers (SegmentExtractor, SegmentStorageService, SizeRestrictionChecker, QA, controllers) to use the centralized components instead of scattered constants and inline logic.
… returns collection, API serves typed values
…Type enum Add resname and restype attributes to the segment metadata pipeline, enabling XLIFF context mapping storage with validated lookup strategies.
GetSegmentsController now calls jsonSerialize() on SegmentMetadataCollection, returning typed values (int, string) instead of raw DB strings.
- Add proper error reporting: check isValid() and throw with aggregated exception messages instead of silently accepting invalid metadata - Remove unused imports (InjectableFiltersTags, HandlersSorter, JobsMetadataDao, MetadataDao)
…nstraints - XLIFF 2.0 test fixture: use matecat: namespace prefix (matecat:resname, matecat:restype) with proper xmlns:matecat declaration per spec - Feature spec Section 8: clean constraints from 16 → 13 active items, remove implemented/outdated entries, add new architecture decisions
- Section 7.2: context-url pipeline task list (7 items) — FilesMetadataMarshaller, CONTEXT_URL cases, fallback resolver, 3 APIs, GetSegmentsController - Section 11: full architecture — three-level storage, dual ingestion paths, read-time fallback resolution, FilesMetadataMarshaller Pattern B design - Section 8: three new constraints (naming convention, dual ingestion, fallback order)
…aStruct value as mixed
…lers Add 'context-url' as a new metadata key recognized at both segment level (SegmentMetadataMarshaller, 9th case) and project level (ProjectsMetadataMarshaller, 31st case). Both use simple string pass-through for marshall/unMarshall. TDD: +8 tests.
…sisFile, BasicFeatureStruct Cover 4 uncovered areas from PR #4429: - 15 RunEvent subclasses (hookName + constructor properties) - XFetchEnvelope value object (readonly, final, properties) - AnalysisFile JSON rendering (matches, metadata, accumulators) - BasicFeatureStruct (property types, PluginsLoader fallback) 64 new tests, 112 assertions.
Add setCacheConnection() static setter to DaoCacheTrait for testability. 23 tests covering XFetch probabilistic early expiration algorithm: - _shouldRecompute boundary conditions (delta=0, expired, fresh) - _getFromCacheMap (miss, raw hit, envelope unwrap, xFetch bypass) - _setInCacheMap (envelope wrapping, raw storage, fallback delta) - Round-trip set→get integration - TTL management and serialization Uses in-memory FakeRedisClient — no real Redis dependency.
🧪 Test-Guard Report✅ PASS — All changed source files have adequate test coverage. Coverage Analysis: ❌ FAILNo changed source files found in coverage report (threshold: 80%)
Test File Matching: ❌ FAILFile matching: 21 pass, 9 warning, 134 fail
Per-File Evaluation: ✅ PASSAI analysis failed (Error code: 413 - {'error': {'code': 'tokens_limit_reached', 'message': 'Request body too large for gpt-4.1-nano model. Max size: 8000 tokens.', 'details': 'Request body too large for gpt-4.1-nano model. Max size: 8000 tokens.'}}) — shortcuts resolved; remaining files deferred to L1+L2.
Result: ✅ PASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a context-preview panel to the CAT tool that displays the source document with segment-aware highlighting, screenshot support, and keyboard shortcuts. Also includes significant backend refactoring: typed event dispatch for FeatureSet hooks, superglobal replacement with Klein abstractions, parameterized queries replacing escape(), and PHPStan level 8 compliance.
Type
feat— new user-facing featurefix— bug fixrefactor— restructure without behavior changechore— build, deps, config, docsperf— performance improvementtest— test coverageChanges
lib/Controller/API/App/ContextUrlController.phppublic/js/components/context-preview/lib/Model/FeatureSet.phplib/Controller/API/App/SetTranslationController.phplib/Controller/API/(multiple)lib/Model/Search/SearchModel.phplib/Model/DataAccess/Database.phpplugins/airbnb/,plugins/translated/phpstan.neondocs/tests/unit/TestDatabase/tests/unit/Search/SearchModelTest.phpMigration Notes
migrations/directorymigrations/20260326190000_alter_table_segment_metadata_add_unique_index.php— replaces the non-unique index onsegment_metadata(id_segment, meta_key)with a unique index. No data loss; duplicate rows must not exist (enforced by application logic). Rollback safe viasql_down.Testing
vendor/bin/phpunit --exclude-group=ExternalServices --no-coveragepasses./vendor/bin/phpstanpasses (0 errors, with baseline)Manual testing of context-preview panel: segment navigation, highlight sync, tab collapse/expand animation, screenshot zoom, keyboard shortcut. New unit tests for Database buildInsertStatement and SearchModel parameterized queries.
AI Disclosure
Claude Code (claude-opus-4-6) — refactoring (controllers, hooks, FeatureSet typing), documentation, tests, PR description
Notes
lib/tolib/+plugins, andtreatPhpDocTypesAsCertainset tofalsefor stricter analysis