Skip to content

refactor(shared): move the workspace, tab and worktree lifecycle types into their own file - #1713

Merged
devswha merged 1 commit into
mainfrom
refactor/types-workspace-lifecycle
Oct 23, 2026
Merged

devswha merged 1 commit into
mainfrom
refactor/types-workspace-lifecycle

Conversation

@devswha

@devswha devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner

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:

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:

Move-only apart from imports: moved declarations, two re-export lines and one type import. No changelog fragment: users see no change.

…s into their own file

A type-only slice (plan: .omo/plans/feature-slices-plan.md, section 7): the
create, move, open and remove request and answer types of workspaces, tabs and
worktrees, and WorkspaceMoved, move verbatim from shared/protocol.ts into
shared/workspace-lifecycle.ts, which imports TabInfo as HerdrTab from the
generated herdr types (the alias protocol.ts defines), so TabMoved reads as
before. They sat in three places: WorkspaceMoved by the snapshot types, and two
blocks around AgentRenameRequest, which belongs to the agent rename route and
stays. protocol.ts re-exports the names at their old places, so every importer
compiles unchanged. Their routes were already split out
(server/workspace-routes.ts).
@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 9231f3c and 205d0db.

📒 Files selected for processing: 2
  • shared/protocol.ts
  • shared/workspace-lifecycle.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

  • Refactor
    • Updated internal workspace and tab lifecycle definitions. There are no changes to the app’s user-facing behavior.

Workspace, tab, and worktree request and response types now reside in shared/workspace-lifecycle.ts. shared/protocol.ts re-exports these types instead of declaring them locally.

Changes: Lifecycle contracts

Layer / File(s) Summary
Lifecycle type definitions
shared/workspace-lifecycle.ts
Adds request and response types for workspace and tab creation and movement, worktree creation, opening, removal, and listing. TabCreated aliases WorkspaceCreated.
Protocol re-exports
shared/protocol.ts
Re-exports lifecycle types from workspace-lifecycle.ts and removes their local declarations and endpoint documentation for WorkspaceMoved.

Priority: ⬇️ Low

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

Change: Refactor

Suggested reviewers: diegolhambi

Merge Risk: ⚪ Minimal · up to 205d0

No behavior change or merge-blocking issue is established; the PR is ready for normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: moving workspace, tab, and worktree lifecycle types into a separate file.
Description check Passed The description explains the change and resulting behavior. It also lists validation checks and results, including type checking and tests.
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: 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 205d0db with git diff --color-moved=plain origin/main...HEAD. The fourteen workspace, tab and worktree types and their doc comments are moved code. The only other lines are the two type re-exports in shared/protocol.ts and the TabInfo as HerdrTab type import in shared/workspace-lifecycle.ts. Nothing outside comments in protocol.ts uses those names. All required checks are green, and no review thread is open.

@devswha
devswha merged commit 464fda5 into main Oct 23, 2026
17 checks passed
@devswha
devswha deleted the refactor/types-workspace-lifecycle branch October 23, 2026 06:01
devswha added a commit that referenced this pull request Oct 23, 2026
…1753)

The last type-only slice of phase 2 (plan
`.omo/plans/feature-slices-plan.md`, section 7, item 7). It follows the
other type-only slices (#1699 to #1713) and waited for the session
resume PR (#1598), which added `SessionResumeSource`,
`SessionResumeRequest` and `SessionResumeResponse` beside the history
types. The session history types move out of `shared/protocol.ts` into
`shared/session-history.ts`. Their routes were already split out
(`server/session-history-routes.ts`), so only the contract types were
left in `protocol.ts`.

## What changes

- **Moved:** `SessionHistoryAgent`, `SessionResumeSource`,
`SessionHistoryRow`, `SessionResumeRequest`, `SessionResumeResponse`,
`SessionHistoryResponse`, verbatim with their doc comments, into the new
`shared/session-history.ts`. The file holds types only, with no imports
and no values.
- **Stays in `protocol.ts`:** `export type { SessionHistoryAgent,
SessionResumeSource, SessionHistoryRow, SessionResumeRequest,
SessionResumeResponse, SessionHistoryResponse } from
"./session-history.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 (96
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/session-history.ts`.
- `HERDR_TEST_MODE=unit bun test server/session-history.test.ts
server/machine-proxy.test.ts src/lib/sessionHistory.test.ts
server/claude-store.test.ts`: **190 pass, 0 fail**. The routes' contract
tests (`server/api.contract.test.ts`,
`server/device-access.contract.test.ts`) run in CI's integration lane.
- `bun run check fast`: passes (unit 6244 pass, 0 fail, 13 skip in 442
files, 8 at a time, 57.6s)

## Outside PRs that touch the same files

No other maintainer PR touches these files. Outside contributors' PRs
that touch `shared/protocol.ts`: #1714, #1706, #1652, #1442 and #1427.
- None of them changes the moved types, so none needs code changes, at
most a rebase.
- I tested each against this branch with `git merge-tree`:
  - #1714, #1706 and #1652 still merge cleanly in `shared/`.
- #1442 and #1427 already conflict with main in `shared/protocol.ts`.
This move adds no new conflict there.
- Their imports from `protocol.ts` keep resolving through the re-export.

Move-only: moved declarations plus one re-export line. 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