Skip to content

refactor(cli): split session command dispatch - #857

Merged
benvinegar merged 2 commits into
mainfrom
refactor/simplify-session-cli-dispatch
Aug 26, 2026
Merged

refactor(cli): split session command dispatch#857
benvinegar merged 2 commits into
mainfrom
refactor/simplify-session-cli-dispatch

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Problem

parseSessionCommand owned top-level dispatch, nested comment/highlight dispatch, Commander setup, validation, and result projection for every live-session command. Its cyclomatic complexity had reached 91, making small command changes difficult to review safely.

Approach

  • extract focused parsers for each session command;
  • keep comment and highlight namespace dispatch explicit;
  • reuse the existing declarative command catalog and validation helpers;
  • preserve reload token isolation around -- and comment-apply stdin timing;
  • add direct context/help coverage and lock reload help behavior around the nested-command separator.

This is a behavior-preserving maintenance refactor. parseSessionCommand complexity drops from 91 to 12.

Open PR #845 also changes session navigation. This PR does not implement or depend on that feature, but src/app/cli.ts will require a manual conflict resolution if #845 lands first.

Validation

Tested on Linux:

  • bun test src/app/cli.test.ts — 130 passed;
  • bun run typecheck;
  • bun run lint;
  • bun run deps:check;
  • bunx oxfmt --check src/app/cli.ts src/app/cli.test.ts;
  • git diff --check main...HEAD.

No visual evidence is included because this does not change terminal output or interaction behavior.

This PR description was generated by Pi using OpenAI GPT-5.6 Sol

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Aug 26, 2026 1:25pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors live-session CLI parsing into focused command parsers while preserving the existing command catalog, validation, and result projection.

  • Separates top-level, comment, and highlight namespace dispatch.
  • Keeps reload tokens after -- isolated from outer command parsing.
  • Adds direct context parsing and expanded help/reload boundary coverage.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable behavioral or security regressions identified.

The extracted parsers preserve the previous token routing, validation sequence, help behavior, and parsed-result projections, while the added tests cover the most sensitive reload and namespace-help boundaries.

Important Files Changed

Filename Overview
src/app/cli.ts Splits the monolithic session-command parser into focused parsers and explicit namespace dispatch without an identified behavioral regression.
src/app/cli.test.ts Adds coverage for direct context selection, command help, highlight namespace help, and reload help isolation around the nested-command separator.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  CLI[parseCli] --> Session[parseSessionCommand]
  Session --> List[List parser]
  Session --> Read[Get or context parser]
  Session --> Review[Review parser]
  Session --> Navigate[Navigate parser]
  Session --> Reload[Reload parser]
  Session --> Comment[Comment namespace]
  Session --> Highlight[Highlight namespace]
  Comment --> CommentActions[Add / apply / list / rm / clear]
  Highlight --> HighlightActions[Add / clear]
  Reload --> Separator{Nested separator present?}
  Separator -->|Yes| Nested[Parse replacement Hunk command]
  Separator -->|No| Error[Report separator error]
Loading

Reviews (1): Last reviewed commit: "refactor(cli): tighten session command t..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit 9406d6d into main Aug 26, 2026
13 checks passed
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.

1 participant