Skip to content

Take session command arguments as one object - #563

Merged
alex-rawlings-yyc merged 2 commits into
mainfrom
560-session-command-args
Oct 29, 2026
Merged

alex-rawlings-yyc merged 2 commits into
mainfrom
560-session-command-args

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #560. Stacked on #529.

Summary

Every session command now takes one object of named fields, in place of positional arguments that end in optional ones. A caller no longer passes null placeholders to reach changeId, and handlers no longer convert null back with ?? undefined.

sendCommand('interlinearizer.writeGloss', { sessionId, tokenRef, surfaceText, value, changeId });
sendCommand('interlinearizer.openSession', { sourceProjectId, interlinearProjectId });
sendCommand('interlinearizer.previewRemovals', { sessionId, request });
  • SessionCommandArgs and SessionEditArgs in interlinearizer.d.ts hold sessionId and, for an edit, the optional changeId. Each command's declaration adds its own fields to one of them. Optional fields such as absorbedPhraseId and adoptStaleAnalysisId drop | null.
  • Handlers in main.ts take their argument type from the command's declaration through ArgsOf<'interlinearizer.X'>, so each signature is declared once.
  • The command docs describe one args object. The new argsParam and sessionArgs helpers fold the per-field descriptors into an object schema. confirmAnalysisMorphemes now lists the tokenRef field that its handler already took.
  • AGENTS.md states the convention.
  • A session page leaves out stale free-translation links placed on other pages. It picked them by payload id, so a payload shared by stale links in two verses brought both links onto a page that showed only one. It now picks them by link id.

Evidence

  • No WebView or perf caller sends a session command yet, so the callers that change are main.test.ts. A codemod rewrote its 182 call sites. The tests that sent null placeholders now leave the field out.
  • The full suite passes at 100% coverage; lint and tsc are clean.

Decisions with a strong alternative

  • openSession takes an object too, though it names no session. It belongs to the session family, and it has a trailing optional of its own.
  • The text reads stay positional. getBookOutline, getSegments and getTextReadStatus serve a source project as well as a session, and their { sessionId } address is already an object.
  • previewRemovals nests its request as { sessionId, request } rather than spreading the RemovalPreviewRequest union into the object, so the union stays one value.

Merge Danger

Door: two-way

Nothing outside the tests sends the session commands or reads session pages yet, so neither change alters what a user sees. 4a writes the WebView's callers against the object form.

Blast Radius: the session command declarations, their handlers and docs in main.ts, and main.test.ts.

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Documentation
    • Updated host-command guidance to describe the single-object argument format for session commands, including the required sessionId and optional changeId.
    • Clarified that getBookOutline, getSegments, and getTextReadStatus continue to use a { sessionId } address among positional arguments.
  • Updates
    • Session command arguments now use named fields in one object. Optional values can be omitted instead of passed as null.
    • Updated command type definitions and examples to reflect the revised format.

@alex-rawlings-yyc alex-rawlings-yyc self-assigned this Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c572cf0b-0785-462a-9acc-f419721a672e

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3c6c868-88b1-4bac-8081-a2f2a435d910
Commits

Reviewing files that changed from the base of the PR and between 52eeeb9 and 6c63c91.

Files selected for processing: 4
  • AGENTS.md
  • src/__tests__/main.test.ts
  • src/main.ts
  • src/types/interlinearizer.d.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Session commands now accept one object with named arguments. Their declarations, handlers, registrations, and tests use this shape. Documentation identifies three read commands that retain a separate address form.

Changes: Session command arguments

Layer / File(s) Summary
Define session argument contracts
src/types/interlinearizer.d.ts
Session command declarations use shared argument types and place session IDs and command-specific fields in one object. Optional nullable fields become optional strings in the updated signatures.
Update command handlers and schemas
src/main.ts
Handlers destructure fields from one argument object. Registrations describe the object shape, with required fields derived from documentation.
Update tests and command documentation
src/__tests__/main.test.ts, AGENTS.md
Tests call session commands with named argument objects and omit optional values when not provided. Documentation identifies three read commands that retain a separate address form.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor · Severity of issue fixed: Low

Possibly related issues

Possibly related PRs

Suggested reviewers: imnasnainaec

Merge Risk: Minimal · previous review 6c63c

The session-command argument change has no identified issue requiring resolution before merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: session command arguments now use one object.
Linked Issues check Passed [#560] Requirement: session commands take one args object, including optional changeId and command-specific fields, and the decision is made before 4a writes WebView callers.

Evidence:
- The reviewed…
Out of Scope Changes check Passed Every changed area connects to the session-command args convention from #560:
- interlinearizer.d.ts: SessionCommandArgs, SessionEditArgs, and the session command signatures. It also drops `| nu…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

[#560] Requirement: session commands take one args object, including optional changeId and command-specific fields, and the decision is made before 4a writes WebView callers.

Evidence:

  • The reviewed head's src/types/interlinearizer.d.ts defines the command handlers. Its readable portion shows the text-read exceptions, getBookOutline and getSegments, keeping address: string | { sessionId: string } among positional arguments. This matches the PR's stated exception.
  • The raw summary of interlinearizer.d.ts lists the changed session signatures. These include openSession({ sourceProjectId, interlinearProjectId? }), closeSession({ sessionId }), and edit commands built on SessionEditArgs (sessionId plus optional changeId). Command-specific fields stay in the same object. previewRemovals takes { sessionId, request }.
  • AGENTS.md at the reviewed head states the convention: "Session commands take one object of named fields, such as sessionId and an edit's optional changeId." It also names the three text-read exceptions. The file also says "The WebView doesn't use sessions yet."
  • The raw summary says main.ts handlers take ArgsOf&lt;'interlinearizer.X'&gt; and pass optional fields through without null to undefined conversion. The summary also says EditTarget.changeId and the optional adoptStaleAnalysisId and tokenRef fields no longer accept null.
  • The PR states that no WebView or performance caller sends session commands yet. This satisfies the timing criterion.

Limits: the blob diff tool was unavailable, and the readable part of interlinearizer.d.ts was truncated before the session command declarations. The signature evidence therefore comes from the raw summary and PR description, not from a direct read of those declarations. The summary is specific and consistent with the AGENTS.md text that was read directly. No automated test result was inspected.

Full details: Out of Scope Changes check

Explanation

Every changed area connects to the session-command args convention from #560:

  • interlinearizer.d.ts: SessionCommandArgs, SessionEditArgs, and the session command signatures. It also drops | null from changeId, adoptStaleAnalysisId, and tokenRef. These are the requested changes.
  • main.ts: handler types from ArgsOf, pass-through of optional fields, and the command docs and sessionArgs/argsParam schema helpers. These implement the object form and document it. confirmAnalysisMorphemes documents its existing tokenRef field, which keeps the schema aligned with the new object shape.
  • main.test.ts: the 182 call sites use the object form, and tests that sent null placeholders omit the field. This is a supporting test migration. The removal of the unused MergedContent import is a small cleanup in the same file.
  • AGENTS.md: documents the convention and the text-read exceptions. This supports the decision record required by #560.

The PR's design choices stay within the issue. openSession is a session-family command, so it takes the object form. The text reads stay positional, as the issue's "session commands" wording does not cover them. previewRemovals nests its request in the object. None of these choices adds unrelated behavior.

Limits: the blob diff tool was unavailable, so this assessment relies on the raw summary and PR description for the changed hunks. The readable part of the declaration file showed no unrelated content.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 3 files. (1 skipped: 1 unsupported.)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@imnasnainaec imnasnainaec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imnasnainaec reviewed 7 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

@alex-rawlings-yyc
alex-rawlings-yyc merged commit 49ab36e into main Oct 29, 2026
13 checks passed
@alex-rawlings-yyc
alex-rawlings-yyc deleted the 560-session-command-args branch October 29, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Take session command arguments as one object

2 participants