♻️ refactor(cattool): assign over core's objects instead of patching prototypes - #124
Open
riccio82 wants to merge 1 commit into
Open
♻️ refactor(cattool): assign over core's objects instead of patching prototypes#124riccio82 wants to merge 1 commit into
riccio82 wants to merge 1 commit into
Conversation
riccio82
force-pushed
the
extension-point-registry
branch
from
August 21, 2026 09:42
54377a3 to
18dc315
Compare
…prototypes The notes tab and the character counter preset were methods on React class components, so overriding them meant patching a prototype and reading `this.props`. Core renders with function components now: those members live on plain objects it exports, and each takes an explicit context object, so they are replaced by assignment like the segment context functions already were. Register the extra footer tab on top of whatever is installed at that moment rather than on core's own implementation, so a tab added elsewhere survives alongside this one. Drop the setDefaultTabOpen override — the method it patched no longer exists.
riccio82
force-pushed
the
extension-point-registry
branch
from
August 21, 2026 13:59
18dc315 to
a71dcb4
Compare
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
Stops this plugin extending the Matecat frontend by patching React component prototypes, and assigns
over the members of core's plain helper objects instead.
The class-to-function migration in core removed the prototypes this plugin used to patch, so the
segment notes tab stopped being overridden at all. Core now keeps the overridable behaviour on
ordinary exported objects —
globalFunctions,segmentNotes,catToolInterface,useProjectTemplateInterface— and this plugin replaces the members it cares about. There is noregistry, no manifest and no extension-point vocabulary in core: the call sites read as ordinary
code.
Depends on matecat/MateCat#4768 and must land with it. Those objects do not exist on a core
without that PR, and that PR removes the prototypes this plugin used to patch.
Changes
a71dcb4What each assignment now targets:
SegmentActions.addGlossaryItemglobalFunctions.registerFooterTabsglobalFunctions.getContextBefore/getContextAfter/getIdBefore/getIdAftersegmentNotes.getNotesSegmentUtils.segmentHasNotecatToolInterface.getCharacterCounterModeuseProjectTemplateInterface.getCharacterCounterModeThe note-row builder is now taken from core (
segmentNotes.getNote) instead of being copied, so theoverride only supplies the grouping this deployment wants.
Rebased onto
masterafter #123 landed, keeping itsconfig.target_coderename inside the block thisbranch moves off
this.props.Two behaviour-neutral drops: the
setDefaultTabOpenoverride (core no longer calls it) and thethis.propsreads inside the overrides — every member is now a plain function of an explicit contextobject, so a wrapper can call the previously installed one unbound.
segmentHasNoteuses capture-then-replace rather than a reference to core's original, so a secondplugin wrapping the same member chains instead of one silently discarding the other.
One small consequence to note
Core now filters the size-restriction key out of a segment's metadata before handing it to an
override, so no override repeats that decision. This plugin's "is there any metadata" check therefore
sees the filtered list: a segment whose only metadata key is the size restriction no longer pushes an
empty metadata block into the notes tab. That block rendered nothing visible, so this should be
invisible in the UI.
Testing
Core's frontend suite passes in full on the paired branch — 427 suites / 4444 tests / 2 snapshots,
with every coverage threshold met. This repo has no frontend test suite of its own;
eslintreportsno errors on the changed files, where it previously failed to parse them at all. Every relative
import in the changed files was resolved and every assigned member checked to exist on its core
object.
Manual QA outstanding. Needs a live pass on the segment notes tab, the glossary (still read-only
here), the footer tabs and the character counter.
AI Disclosure
AI tools were used: Claude Code (Sonnet 5, Opus 5).