Skip to content

npm run build fix - #2

Merged
mokoker merged 1 commit into
masterfrom
sprint9-26/Ui
May 8, 2026
Merged

npm run build fix#2
mokoker merged 1 commit into
masterfrom
sprint9-26/Ui

Conversation

@tsimsekburgan

@tsimsekburgan tsimsekburgan commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Adjust type assertions and response handling to fix TypeScript build issues in admin and advisor pages.

Bug Fixes:

  • Correct type casting for reservation state metadata in the admin dashboard to satisfy TypeScript checks.
  • Harden instance list extraction in advisor chat management against missing data for safer build-time typing.
  • Extend advisor absence instance metadata to include a status field for compatibility with existing usage.

@tsimsekburgan
tsimsekburgan requested review from a team May 8, 2026 11:15
@sourcery-ai

sourcery-ai Bot commented May 8, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes TypeScript build errors by tightening type assertions around workflow instance responses, removing unused helper functions, and extending metadata typing for advisor absences.

Class diagram for updated workflow instance typing and advisor metadata

classDiagram
  class ApiData_T_ {
    <<interface>>
    +Record_string_unknown__index
  }

  class VnextInstance {
    <<interface>>
    +string _source
    +string key
    +string id
    +Record_string_unknown_ attributes
    +VnextMetadata metadata
  }

  class VnextMetadata {
    <<interface>>
    +string currentState
    +string createdAt
    +string updatedAt
    +string status
  }

  class AdvisorInst {
    <<type>>
    +string key
    +Record_string_unknown_ attributes
  }

  class Dashboard {
    <<component>>
    +extractReservations_T_(res)
  }

  class ChatManagement {
    <<component>>
    +loadAdvisorInstances()
  }

  class Absence {
    <<component>>
    +uses_VnextInstance
  }

  ApiData_T_ --> VnextInstance : data
  VnextInstance *-- VnextMetadata : metadata
  ChatManagement --> AdvisorInst : uses
  Absence --> VnextInstance : uses
  Dashboard --> ApiData_T_ : consumes
  Dashboard --> VnextInstance : reads_metadata
Loading

File-Level Changes

Change Details Files
Harden type handling for workflow metadata access to satisfy TypeScript and avoid unsafe property access.
  • Adjust the currentState extraction to cast through unknown before Record<string, unknown> to comply with TypeScript's stricter type checks.
  • Maintain filtering logic for active/valid reservations while ensuring type safety.
src/pages/admin/Dashboard.tsx
Make advisor workflow instance list handling type-safe in chat management to avoid build-time type errors.
  • Introduce a dedicated AdvisorInst type for workflow instances used in chat management.
  • Replace loose inline casts with guarded checks on ok and data before reading .items, defaulting to an empty array when unavailable.
src/pages/advisor/ChatManagement.tsx
Remove unused helper functions and extend VnextInstance metadata to include status for absence flows.
  • Delete the unused extractItems and fullAdvisorRef helper functions to clean up dead code detected by the build.
  • Augment the VnextInstance.metadata type with an optional status field used by absence-related logic.
src/pages/admin/Dashboard.tsx
src/pages/admin/AbsenceManagement.tsx
src/pages/advisor/Absence.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@mokoker
mokoker merged commit c54f235 into master May 8, 2026
6 checks passed
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@tsimsekburgan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 54 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a4cc6fd-a92f-4c7c-b906-c9508fb92500

📥 Commits

Reviewing files that changed from the base of the PR and between 77b2e1f and 079a0f5.

📒 Files selected for processing (5)
  • src/App.tsx
  • src/pages/admin/AbsenceManagement.tsx
  • src/pages/admin/Dashboard.tsx
  • src/pages/advisor/Absence.tsx
  • src/pages/advisor/ChatManagement.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sprint9-26/Ui

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 and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The double cast in Dashboard (a as unknown as Record<string, unknown>) suggests the type for reservation items is too loose; consider refining the underlying type or adding a type guard so you don't need to bypass the type system this way.
  • In ChatManagement, the nearly identical blocks building pmItems and iaItems could be DRYed up via a small helper that takes a response and returns AdvisorInst[], reducing duplication and the chance of inconsistent behavior between the two.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The double cast in `Dashboard` (`a as unknown as Record<string, unknown>`) suggests the type for `reservation` items is too loose; consider refining the underlying type or adding a type guard so you don't need to bypass the type system this way.
- In `ChatManagement`, the nearly identical blocks building `pmItems` and `iaItems` could be DRYed up via a small helper that takes a response and returns `AdvisorInst[]`, reducing duplication and the chance of inconsistent behavior between the two.

## Individual Comments

### Comment 1
<location path="src/pages/admin/Dashboard.tsx" line_range="238-239" />
<code_context>
     if (isNaN(endMs)) return false;
     if (startMs > now || endMs < now) return false;
-    const st = (a.metadata?.currentState ?? (a as Record<string, unknown>).currentState) as string | undefined;
+    const st = (a.metadata?.currentState ??
+      (a as unknown as Record<string, unknown>).currentState) as string | undefined;
     const validStates = ['active', 'approved', 'complete', 'complete-with-transfer'];
     return !st || validStates.includes(st);
</code_context>
<issue_to_address>
**suggestion:** The double cast through `unknown` could hide real type issues and might be better expressed via a type guard or more specific typing.

This double cast makes `a` effectively `any`, weakening type safety and hiding regressions. Instead, either narrow the declared type of `a` so it includes `currentState` (e.g. `{ metadata?: { currentState?: string }; currentState?: string }`) or add a type guard to safely access `currentState` without bypassing the type system.

Suggested implementation:

```typescript
    const { metadata, currentState } = a as {
      metadata?: { currentState?: string };
      currentState?: string;
    };
    const st = (metadata?.currentState ?? currentState) as string | undefined;

```

If possible in your codebase, consider tightening the type of `a` (or the generic `T`) where it is declared so it structurally includes `metadata?: { currentState?: string }` and `currentState?: string`. That would allow you to avoid the cast entirely and have the compiler enforce the presence and shape of these fields.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +238 to +239
const st = (a.metadata?.currentState ??
(a as unknown as Record<string, unknown>).currentState) as string | undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: The double cast through unknown could hide real type issues and might be better expressed via a type guard or more specific typing.

This double cast makes a effectively any, weakening type safety and hiding regressions. Instead, either narrow the declared type of a so it includes currentState (e.g. { metadata?: { currentState?: string }; currentState?: string }) or add a type guard to safely access currentState without bypassing the type system.

Suggested implementation:

    const { metadata, currentState } = a as {
      metadata?: { currentState?: string };
      currentState?: string;
    };
    const st = (metadata?.currentState ?? currentState) as string | undefined;

If possible in your codebase, consider tightening the type of a (or the generic T) where it is declared so it structurally includes metadata?: { currentState?: string } and currentState?: string. That would allow you to avoid the cast entirely and have the compiler enforce the presence and shape of these fields.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request cleans up unused functions, updates the VnextInstance interface, and refactors logic in ChatManagement.tsx to ensure empty arrays are returned instead of booleans. Feedback suggests improving the type casting in Dashboard.tsx by refining the VnextInstance interface or using type guards to avoid verbose double casting.

Comment on lines +238 to +239
const st = (a.metadata?.currentState ??
(a as unknown as Record<string, unknown>).currentState) as string | undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The type casting (a as unknown as Record<string, unknown>) is a bit verbose. While it fixes the TypeScript error, consider if a could be more accurately typed in the interface VnextInstance or if a type guard could be used to avoid this double casting.

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.

2 participants