Skip to content

fix: resolve TypeScript type mismatch in SessionStats component#563

Closed
github-actions[bot] wants to merge 1 commit intodevfrom
claude-fix-pr-561-20785864568
Closed

fix: resolve TypeScript type mismatch in SessionStats component#563
github-actions[bot] wants to merge 1 commit intodevfrom
claude-fix-pr-561-20785864568

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jan 7, 2026

Summary

  • Fixed TypeScript type error where SessionStats component expected string | null for firstRequestAt/lastRequestAt but received Date | null from the aggregateSessionStats repository function
  • Changed the interface to accept Date | string | null which is compatible with both the data source and the existing TimeRow component behavior

Root Cause

The aggregateSessionStats function in src/repository/message.ts returns firstRequestAt: Date | null and lastRequestAt: Date | null, but the SessionStats component's interface expected string | null. The TimeRow helper function already handles both types correctly via new Date(date).

Changes Made

File Change Type
session-stats.tsx Changed firstRequestAt and lastRequestAt types from string | null to Date | string | null Type fix
session-stats.tsx Updated TimeRow function parameter type to match Type fix

Test Plan

  • bun run typecheck passes
  • No behavior changes - new Date() accepts both Date and string inputs

Related


Auto-generated by Claude AI

Greptile Summary

This PR resolves a TypeScript type mismatch between the database layer and UI component. The aggregateSessionStats function in src/repository/message.ts:289-290 returns firstRequestAt: Date | null and lastRequestAt: Date | null from SQL queries, but the SessionStats component interface was typed as string | null. The fix correctly updates the interface to accept Date | string | null, which is compatible with both the data source and the existing TimeRow component that already handles both types via new Date(date).

Key Changes:

  • Updated SessionStatsProps interface to accept Date | string | null for timestamp fields
  • Updated TimeRow function parameter type to match the interface
  • Minor import reordering (no functional impact)

Verification:

  • Type flow confirmed: Database → aggregateSessionStats()getSessionDetails()SessionStats component
  • TimeRow already handles both Date and string correctly via new Date() constructor
  • No runtime behavior changes, purely a type safety fix

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a straightforward type fix that aligns interface definitions with actual data types
  • The type change is minimal, correct, and backward compatible. The TimeRow component's use of new Date(date) handles both Date objects and date strings identically, so there are no runtime behavior changes. The fix resolves the TypeScript compilation error and accurately reflects the actual data flow from database to UI.
  • No files require special attention

Important Files Changed

Filename Overview
src/app/[locale]/dashboard/sessions/[sessionId]/messages/_components/session-stats.tsx Fixed TypeScript type mismatch by changing firstRequestAt and lastRequestAt from `string

Sequence Diagram

sequenceDiagram
    participant Client as SessionMessagesClient
    participant Action as getSessionDetails()
    participant Repo as aggregateSessionStats()
    participant DB as Database
    participant UI as SessionStats Component

    Client->>Action: getSessionDetails(sessionId)
    Action->>Repo: aggregateSessionStats(sessionId)
    Repo->>DB: SQL Query (min/max createdAt)
    DB-->>Repo: Returns Date | null
    Note over DB,Repo: firstRequestAt: Date | null<br/>lastRequestAt: Date | null
    Repo-->>Action: Stats with Date types
    Action-->>Client: sessionStats data
    Client->>UI: Render with stats prop
    Note over UI: Interface now accepts<br/>Date | string | null
    UI->>UI: TimeRow: new Date(date)
    Note over UI: new Date() handles<br/>both Date and string
Loading

Fixed TypeScript type mismatch where SessionStats component expected
string | null for firstRequestAt/lastRequestAt but received Date | null
from the aggregateSessionStats repository function.

Changed interface to accept Date | string | null which is compatible
with both the data source and the existing TimeRow component behavior
(new Date() accepts both Date and string inputs).

CI Run: https://github.com/ding113/claude-code-hub/actions/runs/20785864568

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

@ding113 ding113 closed this Jan 7, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Jan 7, 2026
@ding113 ding113 deleted the claude-fix-pr-561-20785864568 branch January 27, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant