Repository navigation
Add phrase commands with parity tests - #516
Conversation
Host commands for the phrase family, each copying its reducer step for step and staging through ChangeBuffer: - createPhrase, updatePhrase, deletePhrase, mergePhrases, writePhraseGloss and approvePhrase - splitPhrase, porting splitPhraseAtBoundary's update/create/delete sequence as one change set; its staging function is exported so a boundary command can break phrases on a shared buffer Phrase links are read by id through a new getPhraseAnalysisLinks on the repository seam and ChangeBuffer. runParity takes a sequence of actions so the split runs against the reducer actions the WebView dispatches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
createPhrase and mergePhrases over no tokens stage a link the analysis index can't file, so apply threw a TypeError. They now refuse the run with a clear error. mergePhrases also takes a null absorbedPhraseId as absent while keeping an empty-string id, as the reducer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| Layer / File(s) | Summary |
|---|---|
Phrase-link lookup src/types/analysis-repository.ts, src/services/analysisIndex.ts, src/services/indexedRepository.ts, src/services/projectStorage.ts, src/services/commands/changeBuffer.ts, related tests |
Adds getPhraseAnalysisLinks to repository contracts and implementations. The lookup returns requested stored links and skips missing IDs. |
Reducer behavior and shared phrase utilities src/store/analysisSlice.ts, src/utils/phrase-text.ts, src/utils/phrase-arc.ts, src/__tests__/store/analysisSlice.test.ts |
An unknown merge target and clearing an absent gloss now leave the analysis unchanged. Phrase surface text is provided by a shared utility, and sliceAtBoundary is exported. |
Phrase operations and parity src/services/commands/phraseCommands.ts, src/services/commands/approvalRule.ts, src/types/interlinearizer.d.ts, src/__tests__/services/commands/* |
Adds phrase occurrence operations with shared-payload handling, gloss updates, approval checks, and document-order splitting. Tests compare command results with reducer behavior and cover payload reuse, no-op cases, and approval constraints. |
Session command wiring src/main.ts, src/__tests__/main.test.ts |
Registers seven phrase commands with session handlers and parameter schemas. Tests cover returned changes, empty-token rejection, and approval-rule errors. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Main as main.ts
participant Commands as phraseCommands.ts
participant Buffer as ChangeBuffer
participant Repository as AnalysisRepository
Main->>Commands: Invoke phrase operation with request
Commands->>Buffer: Read phrase links and stage edits
Buffer->>Repository: Retrieve requested phrase links
Possibly related PRs
- sillsdev/interlinearizer-extension#514: Both changes preserve sense references when writing or clearing glosses.
- sillsdev/interlinearizer-extension#487: This pull request extends the indexed repository lookup seam introduced there.
- sillsdev/interlinearizer-extension#485: This pull request routes phrase commands through the session edit flow added there.
Suggested reviewers: alex-rawlings-yyc
Merge Risk: 
Minimal · previous review bb267
-
This change adds phrase commands that are not yet called by any consumer, with parity tests against the reducer. No concrete merge-blocking risk was found in the supplied context.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
#445requires phrase commands with parity tests. The PR adds create, update, delete, merge, gloss, approve, and split commands insrc/services/commands/phraseCommands.ts. The commands stage edits throughChangeBuffer, including shared-payload fork and fold behavior.src/main.tsregisters all seven commands and returns the applied edit result. The PR adds parity coverage for phrase operations and PAPI session-command tests. The repository seam andgetPhraseAnalysisLinkssupport the command implementations.
Full details: Out of Scope Changes check
-
Explanation
The changes remain connected to
#445. The repository lookup,phraseSurfaceTextrefactor, exportedsliceAtBoundary, reducer fixes, approval-rule extension, command registrations, and tests support phrase command behavior or parity. The approval-rule extension prevents overlapping approved phrases during phrase edits. No unrelated change is demonstrated.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 81.40% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 43 functions across 23 files.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
Open decisions for whoever takes this over. The current branch takes the first option in each.
|
|
Decisions on the open questions above:
|
jasonleenaylor
left a comment
There was a problem hiding this comment.
Looking good. One gap in the main.ts tests below.
This review was assisted by Claude Opus 5.5.
jasonleenaylor
left a comment
There was a problem hiding this comment.
LGTM
This review was assisted by Claude Opus 5.5.
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed 25 files and all commit messages.
Reviewable status: 0 of 25 files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).
alex-rawlings-yyc
left a comment
There was a problem hiding this comment.
@alex-rawlings-yyc reviewed 25 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).
Part of #426; closes #445 and #520.
Summary
The phrase commands, with parity tests.
splitPhraseportssplitPhraseAtBoundary, which the WebView composes from update, create and delete. It stages all three on one buffer, so a split is oneChangeSet. 3g's segment split and move reuse its staging function to break the phrases a new boundary cuts.getPhraseAnalysisLinks(ids)onAnalysisRepository, both implementations,ChangeBuffer, and the conformance suite. Delete, gloss, approve and split get only a link id.phraseSurfaceTextmoves toutils/phrase-text.tsandsliceAtBoundaryis exported, so the reducer and the command share one implementation.senseRef, blank writes included (#514's rule, noted on #445).Evidence
splitPhraseAtBoundarydispatches.main.test.tsruns each PAPI command over a session and checks its reply;writePhraseGlossruns over a stored draft in the session's language.tscclean.Decisions with a strong alternative
splitPhraseAtBoundaryoutsideasOneStep, so a split that keeps two phrases records two steps today, and the first undo leaves the second half's tokens in no phrase. One command gives oneChangeSet, as the boundary path's split already does. Users see this from [4a] Wire the WebView to the host behind a feature flag #453/[4b] Flip the host write path on by default #454.createPhraseandmergePhrases. The reducer keeps a zero-token phrase, which the analysis index can't file (it keys on the first token), soapplythrew aTypeError. The WebView can't send one.splitPhrasetakes the caller'stokenDocOrder, copyingsplitPhraseAtBoundary's signature. The 3g PR (stacked on this one) builds the order in the host and drops the argument.mergePhraseswith an unknown target leaves the absorbed occurrence alone instead of deleting it and its gloss.createPhrase,updatePhraseandmergePhrasescan't overlap one. The WebView could send one: a link click whose far neighbor was another fragment of the focused phrase absorbed the token beside the slot, even when another approved phrase held it.TokenLinkIconnow merges that phrase whole instead.main.test.tsrefuses each of the three.Merge Danger
Door: two-way
Nothing calls the new commands. Linking across a phrase that sits in the focused phrase's gap now merges it into the focused phrase, where the token beside the slot used to land in both. The
writePhraseGlossandmergePhrasesreducers change only for a blank write with nothing to clear and a merge into an unknown target. The approval rule also checks phrase links now; an edit that touches none can't breach it.Blast Radius: the repository seam gains one method. #497 (3e) and #507 (3j) touch the same
main.ts,interlinearizer.d.tsandmain.test.tsblocks, so whichever lands later takes a small merge.🤖 Generated with Claude Code
This change is
Summary by CodeRabbit