Skip to content

fix(typecheck): type session storage test fixtures - #1526

Merged
kevincodex1 merged 4 commits into
Twigpine:mainfrom
chioarub:fix/typecheck-session-storage-test
Jun 10, 2026
Merged

kevincodex1 merged 4 commits into
Twigpine:mainfrom
chioarub:fix/typecheck-session-storage-test

Conversation

@chioarub

@chioarub chioarub commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1486.

Summary

  • Type deterministic transcript fixture IDs as crypto.UUID so preserved-segment transcript helpers match the production session map contract.
  • Allow the user transcript fixture to model SDK tool_result content arrays directly instead of mutating the message shape after construction.
  • Replace unchecked preview-content casts with a small shape-checking helper for persisted-output assertions.

Validation

  • bun test --max-concurrency=1 src/commands.test.ts src/utils/sessionStorage.test.ts (12 pass)
  • env -u OPENAI_API_KEY -u OPENAI_BASE_URL -u OPENAI_MODEL -u CLAUDE_CODE_USE_OPENAI -u CLAUDE_CODE_USE_GEMINI -u CLAUDE_CODE_USE_MISTRAL -u CLAUDE_CODE_USE_GITHUB -u CLAUDE_CODE_USE_BEDROCK -u CLAUDE_CODE_USE_VERTEX -u CLAUDE_CODE_USE_FOUNDRY -u GEMINI_API_KEY -u GOOGLE_API_KEY -u GITHUB_TOKEN -u GH_TOKEN -u ANTHROPIC_MODEL -u ANTHROPIC_SMALL_FAST_MODEL bun run check (3433 pass, 0 fail)
  • bun run test:provider (650 pass)
  • env -u OPENAI_API_KEY -u OPENAI_BASE_URL -u OPENAI_MODEL -u CLAUDE_CODE_USE_OPENAI -u CLAUDE_CODE_USE_GEMINI -u CLAUDE_CODE_USE_MISTRAL -u CLAUDE_CODE_USE_GITHUB -u CLAUDE_CODE_USE_BEDROCK -u CLAUDE_CODE_USE_VERTEX -u CLAUDE_CODE_USE_FOUNDRY -u GEMINI_API_KEY -u GOOGLE_API_KEY -u GITHUB_TOKEN -u GH_TOKEN -u ANTHROPIC_MODEL -u ANTHROPIC_SMALL_FAST_MODEL npm run test:provider-recommendation (79 pass)
  • bun install --cwd web --frozen-lockfile && bun run web:typecheck
  • bun run typecheck still exits on the repository baseline; no diagnostics remain for src/utils/sessionStorage.test.ts (1695 baseline error lines)
  • git diff --check

Summary by CodeRabbit

  • Tests
    • Improved test coverage and reliability for session storage transcripts, including stronger typing for identifiers and more robust handling and extraction of tool-result preview content.

Note: This release contains internal test improvements only; there are no user-facing changes.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bc7b1a7e-31d2-4757-8f40-73fc1c80cf54

📥 Commits

Reviewing files that changed from the base of the PR and between 14685fd and 83bf7f9.

📒 Files selected for processing (1)
  • src/utils/sessionStorage.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: smoke-and-tests
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Add or update tests when the change affects behavior

Files:

  • src/utils/sessionStorage.test.ts
**/*.{ts,tsx,js,jsx,py}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx,js,jsx,py}: Follow the existing code style in the touched files
Keep comments useful and concise

Files:

  • src/utils/sessionStorage.test.ts
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/utils/sessionStorage.test.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}

⚙️ CodeRabbit configuration file

{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.

Files:

  • src/utils/sessionStorage.test.ts
**

⚙️ CodeRabbit configuration file

**: # Contributing to OpenClaude

Thanks for contributing.

OpenClaude is a fast-moving open-source coding-agent CLI with support for multiple providers, local backends, MCP, and a terminal-first workflow. The best contributions here are focused, well-tested, and easy to review.

Before You Start

  • Search existing issues and discussions before opening a new thread.
  • Check open pull requests for work that overlaps with your contribution. If a PR already exists that addresses the same change, open an issue or discussion first to align on direction — duplicate PRs may be closed without review.
  • Use issues for confirmed bugs and actionable feature work.
  • Use discussions for setup help, ideas, and general community conversation.
  • For larger changes, open an issue first so the scope is clear before implementation.
  • For security reports, follow SECURITY.md.

Pull Requests

Every PR needs a reason. Your PR description must include:

  • what changed and why
  • the user or developer impact
  • the exact checks you ran
  • a linked issue when one exists, using Fixes fix: skip assertMinVersion for third-party providers #123, `Closes `#123, or another clear link
  • screenshots when the PR touches UI, terminal presentation, or the VS Code extension
  • which provider path was tested when the PR changes provider behavior

The PR author is responsible for ensuring their PR is merge-ready. PRs with merge conflicts will not be reviewed or approved until the conflicts are resolved.

Issues are the recommended starting point for anything non-trivial — opening one first helps avoid wasted effort if the change is out of scope or already being worked on. Small fixes, doc corrections, and obvious improvements can stand on their own without a linked issue, as long as the PR description explains the intent.

What Gets Closed Without Review

PRs may be closed without review...

Files:

  • src/utils/sessionStorage.test.ts
🔇 Additional comments (9)
src/utils/sessionStorage.test.ts (9)

2-3: LGTM!


27-42: LGTM!


44-58: LGTM!


60-119: LGTM!


129-144: LGTM!


146-176: LGTM!


182-322: LGTM!


324-371: LGTM!


373-542: LGTM!


📝 Walkthrough

Walkthrough

Test helpers converted to use UUID-typed identifiers; user messages accept either plain strings or tool_result block arrays. Added getToolResultContent(...) to safely read tool_result preview text; tests updated to build and assert tool_result blocks using the new shapes.

Changes

sessionStorage test refactoring

Layer / File(s) Summary
Type import for tool-result blocks
src/utils/sessionStorage.test.ts
Adds a type-only import for ToolResultBlockParam used by helpers and tests.
Message factories: UUID-typed ids & tool-result support
src/utils/sessionStorage.test.ts
base(), user(), assistant(), compactBoundary(), and snipBoundary() updated so uuid/parentUuid and related fields use UUID types; user() now accepts `string
Tool-result extractor and updated assertions
src/utils/sessionStorage.test.ts
Adds `getToolResultContent(content: unknown): string

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs:

  • Gitlawb/openclaude#1407: Related sessionStorage UUID/snipped-boundary transcript fixture changes used by these test refactors.

Suggested reviewers:

  • jatmn
  • kevincodex1
🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(typecheck): type session storage test fixtures' accurately and concisely describes the main change: typing session storage test fixtures to fix typecheck errors.
Description check ✅ Passed The description covers the key changes, includes comprehensive validation results, and addresses the template structure, though it uses 'Validation' instead of 'Testing' and doesn't explicitly check the test checkboxes.
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.
Risk Surface Disclosed ✅ Passed PR modifies only test code with type safety improvements. Does not touch auth, provider routing, permissions, network behavior, background execution, startup/config, plugins, CI, or release scripts.
No Hidden Policy Change ✅ Passed Only test file modified (sessionStorage.test.ts). No production code, policy, telemetry, network, permission, or routing changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 4, 2026
jatmn
jatmn previously approved these changes Jun 4, 2026

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution. I do not see any actionable issues from my review.

@kevincodex1

…on-storage-test

# Conflicts:
#	src/utils/sessionStorage.test.ts
@chioarub
chioarub dismissed stale reviews from jatmn and coderabbitai[bot] via a85943b June 8, 2026 05:54

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/sessionStorage.test.ts`:
- Around line 96-110: The snipBoundary helper currently types its parameters as
string but must use the UUID type to match base() and other factories; change
the signature of snipBoundary to accept uuid: UUID, parentUuid: UUID | null, and
removedUuids: UUID[] (and update any local references if needed) so calls like
snipBoundary(id(45), ...) type-check with base() and the rest of the factories
(reference functions: snipBoundary, base, id).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2217e0e2-26c1-49e6-8219-861821132431

📥 Commits

Reviewing files that changed from the base of the PR and between 35d4f5b and a85943b.

📒 Files selected for processing (1)
  • src/utils/sessionStorage.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: smoke-and-tests
🧰 Additional context used
📓 Path-based instructions (3)
**/*

⚙️ CodeRabbit configuration file

**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.

Files:

  • src/utils/sessionStorage.test.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}

⚙️ CodeRabbit configuration file

{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.

Files:

  • src/utils/sessionStorage.test.ts
**

⚙️ CodeRabbit configuration file

**: # Contributing to OpenClaude

Thanks for contributing.

OpenClaude is a fast-moving open-source coding-agent CLI with support for multiple providers, local backends, MCP, and a terminal-first workflow. The best contributions here are focused, well-tested, and easy to review.

Before You Start

  • Search existing issues and discussions before opening a new thread.
  • Check open pull requests for work that overlaps with your contribution. If a PR already exists that addresses the same change, open an issue or discussion first to align on direction — duplicate PRs may be closed without review.
  • Use issues for confirmed bugs and actionable feature work.
  • Use discussions for setup help, ideas, and general community conversation.
  • For larger changes, open an issue first so the scope is clear before implementation.
  • For security reports, follow SECURITY.md.

Pull Requests

Every PR needs a reason. Your PR description must include:

  • what changed and why
  • the user or developer impact
  • the exact checks you ran
  • a linked issue when one exists, using Fixes #123, `Closes `#123, or another clear link
  • screenshots when the PR touches UI, terminal presentation, or the VS Code extension
  • which provider path was tested when the PR changes provider behavior

The PR author is responsible for ensuring their PR is merge-ready. PRs with merge conflicts will not be reviewed or approved until the conflicts are resolved.

Issues are the recommended starting point for anything non-trivial — opening one first helps avoid wasted effort if the change is out of scope or already being worked on. Small fixes, doc corrections, and obvious improvements can stand on their own without a linked issue, as long as the PR description explains the intent.

What Gets Closed Without Review

PRs may be closed without review...

Files:

  • src/utils/sessionStorage.test.ts
🔇 Additional comments (7)
src/utils/sessionStorage.test.ts (7)

3-3: LGTM!


18-20: LGTM!


22-94: LGTM!


120-135: LGTM!


141-181: LGTM!


283-305: LGTM!


307-330: LGTM!

@coderabbitai coderabbitai Bot 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/sessionStorage.test.ts`:
- Around line 96-110: The snipBoundary helper currently types its parameters as
string but must use the UUID type to match base() and other factories; change
the signature of snipBoundary to accept uuid: UUID, parentUuid: UUID | null, and
removedUuids: UUID[] (and update any local references if needed) so calls like
snipBoundary(id(45), ...) type-check with base() and the rest of the factories
(reference functions: snipBoundary, base, id).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2217e0e2-26c1-49e6-8219-861821132431

📥 Commits

Reviewing files that changed from the base of the PR and between 35d4f5b and a85943b.

📒 Files selected for processing (1)
  • src/utils/sessionStorage.test.ts
📜 Review details
🔇 Additional comments (7)
src/utils/sessionStorage.test.ts (7)

3-3: LGTM!


18-20: LGTM!


22-94: LGTM!


120-135: LGTM!


141-181: LGTM!


283-305: LGTM!


307-330: LGTM!

🛑 Comments failed to post (1)
src/utils/sessionStorage.test.ts (1)

96-110: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Type parameters as UUID, not string.

The snipBoundary helper accepts string for uuid and parentUuid, but base() (line 22) expects UUID. This will fail type checking. All other factory helpers (user, assistant, compactBoundary) use UUID consistently.

The test at line 151 calls snipBoundary(id(45), ...) where id() returns UUID, so the signature should match.

🔧 Proposed fix
 function snipBoundary(
-  uuid: string,
-  parentUuid: string | null,
-  removedUuids: string[],
+  uuid: UUID,
+  parentUuid: UUID | null,
+  removedUuids: UUID[],
 ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

function snipBoundary(
  uuid: UUID,
  parentUuid: UUID | null,
  removedUuids: UUID[],
) {
  return {
    ...base(uuid, parentUuid),
    type: 'system',
    subtype: 'snip_boundary',
    level: 'info',
    isMeta: false,
    content: 'Conversation history snipped',
    snipMetadata: { removedUuids },
  }
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/sessionStorage.test.ts` around lines 96 - 110, The snipBoundary
helper currently types its parameters as string but must use the UUID type to
match base() and other factories; change the signature of snipBoundary to accept
uuid: UUID, parentUuid: UUID | null, and removedUuids: UUID[] (and update any
local references if needed) so calls like snipBoundary(id(45), ...) type-check
with base() and the rest of the factories (reference functions: snipBoundary,
base, id).

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 8, 2026
@chioarub
chioarub requested a review from jatmn June 8, 2026 06:24
jatmn
jatmn previously approved these changes Jun 8, 2026

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution. I do not see any actionable issues from my review.

@kevincodex1 LGTM

…on-storage-test

# Conflicts:
#	src/utils/sessionStorage.test.ts
@chioarub
chioarub dismissed stale reviews from jatmn and coderabbitai[bot] via 83bf7f9 June 9, 2026 06:07

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution. I do not see any actionable issues from my review.

@kevincodex1 LGTM

@kevincodex1
kevincodex1 merged commit 491985a into Twigpine:main Jun 10, 2026
3 checks passed
@chioarub
chioarub deleted the fix/typecheck-session-storage-test branch June 10, 2026 05:58
deagwon97 pushed a commit to deagwon97/openclaude that referenced this pull request Jun 11, 2026
* fix(typecheck): type session storage test fixtures

* fix(typecheck): align snip boundary fixture ids
hotmanxp added a commit to hotmanxp/openclaude that referenced this pull request Jun 12, 2026
3way apply failed on all 3 (fork has heavily diverged from upstream
context). Per skill's 'direct overwrite via git show' escape hatch,
took upstream verbatim + re-evaluated byte-level.

src/grpc/server.ts (upstream Twigpine#1572 gRPC stream messages):
- 78 lines added (proper typing for PermissionDenyDecision, msg.event,
  block structures)
- 15 lines removed (fork's looser typing escape hatches)
- @ts-nocheck dropped

src/tasks/RemoteAgentTask/RemoteAgentTask.tsx (upstream Twigpine#1573):
- 33 lines added (typed message block structure, narrowed content types)
- 10 lines removed (fork's any[] escape hatches)
- @ts-nocheck dropped

src/utils/sessionStorage.test.ts (upstream Twigpine#1526):
- 322 lines added (proper UUID template literal types, typed test
  fixtures: SessionMessage[] instead of string)
- 42 lines removed (fork's nocheck helper functions + persisted-output
  test cases; can be re-added in a follow-up session if needed)
- @ts-nocheck dropped

VERIFICATION:
  typecheck: 47 errors → 0 from these 3 files
  tests: pre-existing acorn-module-missing failure (NOT from these
         changes — confirmed via git stash + bun test on clean HEAD
         which also fails with the same error)

REGRESSION RISK:
  sessionStorage.test.ts lost 42 lines of fork test coverage
  (helper functions id/base/user/assistant + 1 persisted-output test
  case). All TypeScript-clean, but runtime test count drops. Re-add
  in dedicated session if needed.
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.

3 participants