Skip to content

refactor(shared): move the repository diff types into their own file - #1710

Merged
devswha merged 1 commit into
mainfrom
refactor/types-repo-diff
Oct 23, 2026
Merged

devswha merged 1 commit into
mainfrom
refactor/types-repo-diff

Conversation

@devswha

@devswha devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner

A type-only slice of phase 2 (plan .omo/plans/feature-slices-plan.md, section 7, item 8), after CLIProxy (#1699), Portal (#1700), directories (#1701), terminal find (#1703), web push (#1707) and usage (#1708); session history (item 7) waits while the open PR #1598 rewrites those types: the repository diff types move out of shared/protocol.ts into shared/repo-diff.ts. Their routes were already split out (server/workspace-routes.ts and server/repo-diff.ts), so only the contract types were left in protocol.ts.

What changes

  • Moved: RepoDiffScope, RepoDiffStatus, RepoDiffRepository, RepoDiffFile, RepoDiffFileList, RepoDiffFilePatch, verbatim with their doc comments, into the new shared/repo-diff.ts. The file holds types only, with no values.
  • Stays in protocol.ts: export type { RepoDiffScope, RepoDiffStatus, RepoDiffRepository, RepoDiffFile, RepoDiffFileList, RepoDiffFilePatch } from "./repo-diff.ts"; at the old place, so every importer compiles unchanged.
  • No other protocol.ts declaration uses these names, so nothing else had to stay behind.

There is no behaviour to pin: types are erased at runtime, and the routes and their tests are untouched.

Checks

  • --color-moved: git diff --color-moved=plain origin/main...HEAD -- shared shows the declarations and their comments as moved (140 lines). The only other line is the re-export in protocol.ts.
  • Client imports: bun run typecheck passes on both tsconfigs, so every importer still compiles through the re-export. No file in src/ or site/ imports shared/repo-diff.ts.
  • HERDR_TEST_MODE=unit bun test server/repo-diff.test.ts src/lib/repoDiff.test.ts src/lib/diff.test.ts: 36 pass, 0 fail.
  • bun run check fast: passes (unit 6161 pass, 0 fail, 12 skip in 440 files, 8 at a time, 57.3s).

Overlapping open PRs

Open PRs that touch shared/protocol.ts: #1706, #1652, #1598, #1442, #1427. I checked each diff for RepoDiffScope, RepoDiffStatus, RepoDiffRepository, RepoDiffFile, RepoDiffFileList, RepoDiffFilePatch:

Move-only: moved declarations plus one re-export line. No changelog fragment: users see no change.

A type-only slice (plan: .omo/plans/feature-slices-plan.md, section 7):
RepoDiffScope, RepoDiffStatus, RepoDiffRepository, RepoDiffFile,
RepoDiffFileList and RepoDiffFilePatch move verbatim from shared/protocol.ts
into shared/repo-diff.ts (types only). Their routes were already split out
(server/workspace-routes.ts, server/repo-diff.ts); protocol.ts re-exports the
six names, so every importer compiles unchanged.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 5253f3b and c36a3e8.

📒 Files selected for processing: 2
  • shared/protocol.ts
  • shared/repo-diff.ts

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

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added shared data definitions for repository comparisons, including file-change details, comparison metadata, and patch availability.
  • Other
    • No changes to existing exported type names.

The change adds shared types for repository comparisons, file details, file lists, and patches. The protocol module re-exports these types, preserving their existing exported names.

Changes: Repository diff contract

Layer / File(s) Summary
Define and export repository-diff types
shared/repo-diff.ts, shared/protocol.ts
shared/repo-diff.ts defines comparison scopes, file statuses, repository metadata, file details, and file-list and patch response shapes. shared/protocol.ts re-exports these types.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

  • devswha/herdr-web-ui#1524: The issue requires shared protocol types for the repository diff API. This change provides those types; the issue’s history routes remain unimplemented here.

Suggested reviewers: diegolhambi

Merge Risk: ⚪ Minimal · up to c36a3

No actionable merge-blocking issue is identified; the change appears ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: moving the repository diff types into a dedicated shared file.
Description check Passed The description explains the change, resulting import behavior, scope, runtime impact, validation results, and overlapping pull requests. It uses “What changes” and “Checks” instead of the template he…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, resulting import behavior, scope, runtime impact, validation results, and overlapping pull requests. It uses “What changes” and “Checks” instead of the template headings “Change” and “Validation,” but it provides the required information.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 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.

❤️ Share

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

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Merging as a move-only PR (AGENTS.md), without waiting for CodeRabbit. The merge pass checked head c36a3e8 with git diff --color-moved=plain origin/main...HEAD: every changed line is moved code (the six repository diff types and their doc comments) except the one type re-export in shared/protocol.ts. No open PR changes these types; the only lines naming them are imports from protocol.ts, which still resolve through the re-export. All required checks are green and no review thread is open.

@devswha
devswha merged commit 7fa42e0 into main Oct 23, 2026
17 checks passed
@devswha
devswha deleted the refactor/types-repo-diff branch October 23, 2026 05:15
devswha added a commit that referenced this pull request Oct 23, 2026
#1711)

A type-only slice of phase 2 (plan `.omo/plans/feature-slices-plan.md`,
section 7, item 9), after CLIProxy (#1699), Portal (#1700), directories
(#1701), terminal find (#1703), web push (#1707), usage (#1708) and
repository diff (#1710); session history (item 7) waits while the open
PR #1598 rewrites those types: the access and device types move out of
`shared/protocol.ts` into `shared/access.ts`. Their routes were already
split out (`server/access.ts`, `server/devices.ts` and
`server/tailscale.ts`), so only the contract types were left in
`protocol.ts`.

## What changes

- **Moved:** `AccessVia`, `AccessRefusal`, `DeviceRole`, `HealthAuth`,
`LanExposure`, `PairedDevice`, `PairingCode`, `RemoteAccess`,
`TailscaleAccess`, verbatim with their doc comments, into the new
`shared/access.ts`. The file holds types only, with no values.
- **Stays in `protocol.ts`:** `export type { AccessVia, AccessRefusal,
DeviceRole, HealthAuth, LanExposure, PairedDevice, PairingCode,
RemoteAccess, TailscaleAccess } from "./access.ts";` at the old place,
so every importer compiles unchanged, including `shared/machines.ts`,
which imports `HealthAuth` from `protocol.ts` (the plan's check for this
family).
- **No other `protocol.ts` declaration uses these names**, so nothing
else had to stay behind.

There is no behaviour to pin: types are erased at runtime, and the
routes and their tests are untouched.

## Checks

- **`--color-moved`:** `git diff --color-moved=plain origin/main...HEAD
-- shared` shows the declarations and their comments as moved (138
lines). The only other line is the re-export in `protocol.ts`.
- **Client imports:** `bun run typecheck` passes on both tsconfigs, so
every importer still compiles through the re-export. No file in `src/`
or `site/` imports `shared/access.ts`.
- `HERDR_TEST_MODE=unit bun test server/access.test.ts
server/devices.test.ts server/pairing.test.ts server/tailscale.test.ts`:
**80 pass, 0 fail**.
- `bun run check fast`: passes (unit 6161 pass, 0 fail, 12 skip in 440
files, 8 at a time, 57.6s).

## Overlapping open PRs

Open PRs that touch `shared/protocol.ts`: #1706, #1652, #1598, #1442,
#1427. I checked each diff for `AccessVia`, `AccessRefusal`,
`DeviceRole`, `HealthAuth`, `LanExposure`, `PairedDevice`,
`PairingCode`, `RemoteAccess`, `TailscaleAccess`:
- #1706, #1652, #1598, #1442 do not change them.
- #1427 edits `server/api.contract.test.ts`, which imports them from
`protocol.ts`. That import still resolves through the re-export.

Move-only: moved declarations plus one re-export line. No changelog
fragment: users see no change.
devswha added a commit that referenced this pull request Oct 23, 2026
A type-only slice of phase 2 (plan `.omo/plans/feature-slices-plan.md`,
section 7, item 10), after CLIProxy (#1699), Portal (#1700), directories
(#1701), terminal find (#1703), web push (#1707), usage (#1708),
repository diff (#1710) and access (#1711); session history (item 7)
waits while the open PR #1598 rewrites those types: the pane layout
types move out of `shared/protocol.ts` into `shared/pane-layout.ts`.
Their routes were already split out (`server/pane-routes.ts`), so only
the contract types were left in `protocol.ts`.

## What changes

- **Moved:** `SplitPaneDirection`, `PaneDirection`, `SplitPaneRequest`,
`PaneSplit`, `ZoomPaneRequest`, `PaneZoomed`, `FocusPaneRequest`,
`SwapPaneRequest`, `PaneSwapped`, `ResizePaneRequest`, `PaneResized`,
`SetSplitRatioRequest`, verbatim with their doc comments, into the new
`shared/pane-layout.ts`. The file holds types only, with no values; it
imports `PaneInfo` (for `PaneSplit`) from `./herdr-api.generated.ts`, as
`protocol.ts` does.
- **Stays in `protocol.ts`:** `export type { SplitPaneDirection,
PaneDirection, SplitPaneRequest, PaneSplit, ZoomPaneRequest, PaneZoomed,
FocusPaneRequest, SwapPaneRequest, PaneSwapped, ResizePaneRequest,
PaneResized, SetSplitRatioRequest } from "./pane-layout.ts";` at the old
place, so every importer compiles unchanged.
- **No other `protocol.ts` declaration uses these names**, so nothing
else had to stay behind.

There is no behaviour to pin: types are erased at runtime, and the
routes and their tests are untouched.

## Checks

- **`--color-moved`:** `git diff --color-moved=plain origin/main...HEAD
-- shared` shows the declarations and their comments as moved (159
lines). The other lines are the re-export in `protocol.ts` and the
`PaneInfo` type import at the top of `shared/pane-layout.ts`.
`protocol.ts` keeps its own `PaneInfo` import, which its other
declarations still use.
- **Client imports:** `bun run typecheck` passes on both tsconfigs, so
every importer still compiles through the re-export. No file in `src/`
or `site/` imports `shared/pane-layout.ts`.
- These routes are covered by contract tests against an isolated live
herdr (`server/pane-layout.contract.test.ts`,
`server/api.contract.test.ts`,
`server/route-envelope.contract.test.ts`), which CI's integration lane
runs; the unit lane has none to run here.
- `bun run check fast`: passes (unit 6161 pass, 0 fail, 12 skip in 440
files, 8 at a time, 57.4s).

## Overlapping open PRs

Open PRs that touch `shared/protocol.ts`: #1706, #1652, #1598, #1442,
#1427. I checked each diff for the twelve names:
- #1706, #1652, #1442 do not change them.
- #1598 edits `src/lib/machineContext.tsx`, which imports them from
`protocol.ts`. That import still resolves through the re-export.
- #1427 edits `site/demo/transport.ts`, which imports them from
`protocol.ts`. That import still resolves through the re-export.

Move-only apart from imports: moved declarations, one re-export line and
one type import. No changelog fragment: users see no change.
devswha added a commit that referenced this pull request Oct 23, 2026
…s into their own file (#1713)

The last type-only slice of phase 2 that can go now (plan
`.omo/plans/feature-slices-plan.md`, section 7, item 11). It follows:
- CLIProxy (#1699)
- Portal (#1700)
- directories (#1701)
- terminal find (#1703)
- web push (#1707)
- usage (#1708)
- repository diff (#1710)
- access (#1711)
- pane layout (#1712)

This slice moves the workspace, tab and worktree lifecycle types out of
`shared/protocol.ts` into `shared/workspace-lifecycle.ts`. Their routes
were already split out (`server/workspace-routes.ts`). Session history
(item 7) waits while the open PR #1598 rewrites those types.

## What changes

- **Moved, verbatim with their doc comments,** into the new
`shared/workspace-lifecycle.ts`:
  - `WorkspaceMoved`;
- `CreateWorkspaceRequest`, `CreateTabRequest`, `CreateWorktreeRequest`;
  - `MoveTabRequest`, `TabMoved`;
  - `OpenWorktreeRequest`, `WorktreeOpened`;
  - `RemoveWorktreeRequest`, `WorktreeRemoved`;
  - `WorktreeEntry`, `WorktreeListing`;
  - `WorkspaceCreated`, `TabCreated`.

  The file holds types only, with no values.
- **One import in the new file:** `TabMoved` uses `HerdrTab`, which
`protocol.ts` defines as an alias of the generated `TabInfo`. The new
file imports `TabInfo as HerdrTab` from `./herdr-api.generated.ts`, so
the moved lines stay unchanged. It does not import back from
`protocol.ts`.
- **Three places in `protocol.ts`:** the types sat in three places
there. `WorkspaceMoved` sat by the snapshot types, and the others sat in
two blocks on either side of `AgentRenameRequest`.
- `AgentRenameRequest` stays, because it belongs to the agent rename
route, not to this family.
- `WorkspaceMoved`'s old place keeps `export type { WorkspaceMoved }
from "./workspace-lifecycle.ts";`.
- The first block's old place keeps one `export type { … } from
"./workspace-lifecycle.ts";` for the other thirteen names.

  Every importer compiles unchanged.
- **No other `protocol.ts` declaration uses these names,** so nothing
else had to stay behind.

There is no behaviour to pin: types are erased at runtime, and the
routes and their tests are untouched.

## Checks

- **`--color-moved`:** `git diff --color-moved=plain origin/main...HEAD
-- shared` shows 252 lines as moved. The other lines are the two
re-export lines in `protocol.ts` and the `TabInfo as HerdrTab` type
import at the top of the new file.
- **Client imports:** `bun run typecheck` passes on both tsconfigs. No
file in `src/` or `site/` imports `shared/workspace-lifecycle.ts`.
- `HERDR_TEST_MODE=unit bun test server/order-sequence.test.ts
scripts/demo-tabs.test.ts scripts/demo-first-message.test.ts
src/lib/workspaceOrder.test.ts`: **42 pass, 0 fail**. The routes
themselves are covered by contract tests against an isolated live herdr
(`server/api.contract.test.ts`,
`server/route-envelope.contract.test.ts`,
`server/pending-input.contract.test.ts`), which CI's integration lane
runs.
- `bun run check fast`: passes (unit 6161 pass, 0 fail, 12 skip in 440
files, 8 at a time, 57.5s).

## Overlapping open PRs

Open PRs that touch `shared/protocol.ts`: #1706, #1652, #1598, #1442,
#1427. I checked each diff for the fourteen names:
- #1706, #1652, #1442 do not change them.
- #1598 edits `scripts/session-history-browser-qa.ts`,
`src/components/SessionHistory.tsx`, `src/lib/machineContext.tsx` and
`src/lib/sessionHistory.ts`, which import them from `protocol.ts`. Those
imports still resolve through the re-export.
- #1427 edits `server/api.contract.test.ts`,
`server/workspace-routes.ts` and `site/demo/transport.ts`, which import
them from `protocol.ts`. Those imports still resolve through the
re-export.

Move-only apart from imports: moved declarations, two re-export lines
and one type import. No changelog fragment: users see no change.
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