Repository: giselles-ai/giselle
Pull request #968: Improve node type guards with provider filtering and GitHub badge conditions
Author: login: toyamarinyon
Labels: name: codex
Created: 2025-05-28T01:06:46Z | Merged: 2025-05-28T02:35:47Z

## Summary

This PR enhances the node type system by adding provider filtering capabilities and simplifying GitHub badge conditions in the UI.

## Key Changes

### Enhanced Type Guards with Provider Filtering
- **`isTriggerNode`**: Add generic type parameter and provider filtering support
- **`isActionNode`**: Add generic type parameter and provider filtering support  
- **`isVectorStoreNode`**: Add provider filtering support for GitHub provider

### Simplified GitHub Badge Conditions
- Replace verbose condition checks with concise type guard functions
- Use `isTriggerNode(node, "github")` instead of manual property checking
- Use `isActionNode(node, "github")` for action nodes
- Use `isVectorStoreNode(node, "github")` for vector store nodes

### Type Safety Improvements
- Generic type parameters provide better type inference when provider is specified
- Return types are narrowed to include the specific provider type
- Improved IntelliSense and compile-time type checking

## Files Changed
- `packages/data-type/src/node/operations/index.ts`: Enhanced `isTriggerNode` and `isActionNode` with generics
- `packages/data-type/src/node/variables/index.ts`: Enhanced `isVectorStoreNode` with provider filtering
- `internal-packages/workflow-designer-ui/src/editor/node/node.tsx`: Simplified GitHub badge conditions

## Testing
- ✅ `pnpm format`
- ✅ `pnpm check-types`  
- ✅ `pnpm test`

## Benefits
- **Improved Readability**: Cleaner, more maintainable condition checks
- **Better Type Safety**: Generic parameters provide precise type inference
- **Consistent API**: Unified approach for provider filtering across node types
- **DRY Principle**: Eliminated code duplication in condition checking

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved internal logic for identifying node types and providers, resulting in more streamlined and maintainable code.
- **New Features**
  - Enhanced support for filtering nodes by provider, allowing for more precise handling of node types.
- **Bug Fixes**
  - Improved type checking for nodes to ensure more accurate recognition and handling of node providers.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/internal-packages/workflow-designer-ui/src/editor/node/node.tsx b/internal-packages/workflow-designer-ui/src/editor/node/node.tsx
index fdfdf24568..24a3f4c109 100644
--- a/internal-packages/workflow-designer-ui/src/editor/node/node.tsx
+++ b/internal-packages/workflow-designer-ui/src/editor/node/node.tsx
@@ -10,8 +10,11 @@ import {
 	TextNode,
 	TriggerNode,
 	VectorStoreNode,
+	isActionNode,
 	isImageGenerationNode,
 	isTextGenerationNode,
+	isTriggerNode,
+	isVectorStoreNode,
 } from "@giselle-sdk/data-type";
 import {
 	Handle,
@@ -333,9 +336,7 @@ export function NodeComponent({
 					</div>
 				</div>
 			</div>
-			{node.type === "operation" &&
-				node.content.type === "trigger" &&
-				node.content.provider === "github" &&
+			{isTriggerNode(node, "github") &&
 				node.content.state.status === "configured" && (
 					<div className="px-[16px] relative">
 						<GitHubRepositoryBadgeFromTrigger
@@ -343,9 +344,7 @@ export function NodeComponent({
 						/>
 					</div>
 				)}
-			{node.type === "operation" &&
-				node.content.type === "action" &&
-				node.content.command.provider === "github" &&
+			{isActionNode(node, "github") &&
 				node.content.command.state.status === "configured" && (
 					<div className="px-[16px] relative">
 						<GitHubRepositoryBadgeFromRepo
@@ -354,9 +353,7 @@ export function NodeComponent({
 						/>
 					</div>
 				)}
-			{node.type === "variable" &&
-				node.content.type === "vectorStore" &&
-				node.content.source.provider === "github" &&
+			{isVectorStoreNode(node, "github") &&
 				node.content.source.state.status === "configured" && (
 					<div className="px-[16px] relative">
 						<GitHubRepositoryBadge
diff --git a/internal-packages/workflow-designer-ui/src/icons/node/index.tsx b/internal-packages/workflow-designer-ui/src/icons/node/index.tsx
index a9b7b70494..08d15f44f4 100644
--- a/internal-packages/workflow-designer-ui/src/icons/node/index.tsx
+++ b/internal-packages/workflow-designer-ui/src/icons/node/index.tsx
@@ -113,7 +113,7 @@ export function NodeIcon({
 						case "manual":
 							return <TriggerIcon {...props} data-content-type-icon />;
 						default: {
-							const _exhaustiveCheck: never = node.content.provider;
+							const _exhaustiveCheck: never = node.content;
 							throw new Error(
 								`Unhandled TriggerProviderType: ${_exhaustiveCheck}`,
 							);
diff --git a/packages/data-type/src/node/operations/index.ts b/packages/data-type/src/node/operations/index.ts
index 61e3ec3f09..4a4e2b28e0 100644
--- a/packages/data-type/src/node/operations/index.ts
+++ b/packages/data-type/src/node/operations/index.ts
@@ -1,3 +1,4 @@
+import type { ActionProvider, TriggerProvider } from "@giselle-sdk/flow";
 import { z } from "zod/v4";
 import { NodeBase, NodeReferenceBase, OverrideNodeBase } from "../base";
 import { ActionContent, ActionContentReference } from "./action";
@@ -78,18 +79,39 @@ export const TriggerNode = OperationNode.extend({
 });
 export type TriggerNode = z.infer<typeof TriggerNode>;
 
-export function isTriggerNode(args?: unknown): args is TriggerNode {
+export function isTriggerNode<
+	TTriggerProvider extends TriggerProvider = TriggerProvider,
+>(
+	args?: unknown,
+	provider?: TTriggerProvider,
+): args is TTriggerProvider extends TriggerProvider
+	? TriggerNode & { content: { provider: TTriggerProvider } }
+	: TriggerNode {
 	const result = TriggerNode.safeParse(args);
-	return result.success;
+	return (
+		result.success &&
+		(provider === undefined || result.data.content.provider === provider)
+	);
 }
 
 export const ActionNode = OperationNode.extend({
 	content: ActionContent,
 });
 export type ActionNode = z.infer<typeof ActionNode>;
-export function isActionNode(args?: unknown): args is ActionNode {
+export function isActionNode<
+	TActionProvider extends ActionProvider = ActionProvider,
+>(
+	args?: unknown,
+	provider?: TActionProvider,
+): args is TActionProvider extends ActionProvider
+	? ActionNode & { content: { command: { provider: TActionProvider } } }
+	: ActionNode {
 	const result = ActionNode.safeParse(args);
-	return result.success;
+	return (
+		result.success &&
+		(provider === undefined ||
+			result.data.content.command.provider === provider)
+	);
 }
 
 const OverrideOperationNodeContent = z.discriminatedUnion("type", [
diff --git a/packages/data-type/src/node/variables/index.ts b/packages/data-type/src/node/variables/index.ts
index a3e0739411..28a80acc06 100644
--- a/packages/data-type/src/node/variables/index.ts
+++ b/packages/data-type/src/node/variables/index.ts
@@ -77,9 +77,24 @@ export const VectorStoreNode = VariableNode.extend({
 });
 export type VectorStoreNode = z.infer<typeof VectorStoreNode>;
 
-export function isVectorStoreNode(args: unknown): args is VectorStoreNode {
+type VectorStoreSourceProvider = VectorStoreContent["source"]["provider"];
+
+export function isVectorStoreNode<
+	TVectorStoreSourceProvider extends
+		VectorStoreSourceProvider = VectorStoreSourceProvider,
+>(
+	args: unknown,
+	provider?: TVectorStoreSourceProvider,
+): args is TVectorStoreSourceProvider extends VectorStoreSourceProvider
+	? VectorStoreNode & {
+			content: { source: { provider: TVectorStoreSourceProvider } };
+		}
+	: VectorStoreNode {
 	const result = VectorStoreNode.safeParse(args);
-	return result.success;
+	return (
+		result.success &&
+		(provider === undefined || result.data.content.source.provider === provider)
+	);
 }
 
 const OverrideVariableNodeContent = z.discriminatedUnion("type", [


Reviews:
user: login: shige
body: Thank you! 🛡️ 
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-28T02:32:12Z
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR enhances existing node type guards by adding optional provider filtering and refactors UI badge rendering to use these concise guards instead of verbose property checks.

- Extended `isTriggerNode`, `isActionNode`, and `isVectorStoreNode` with generic provider parameters for precise type narrowing.
- Refactored UI code to replace manual GitHub badge conditions with the new type guards.
- Adjusted exhaustive switch-case in icon rendering to use a broader content check.

### Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

| File                                                             | Description                                                         |
|------------------------------------------------------------------|---------------------------------------------------------------------|
| packages/data-type/src/node/variables/index.ts                   | Extended `isVectorStoreNode` to accept an optional provider filter  |
| packages/data-type/src/node/operations/index.ts                  | Added generics and provider filtering to `isTriggerNode` and `isActionNode` |
| internal-packages/workflow-designer-ui/src/icons/node/index.tsx  | Updated exhaustive check assignment and error message in icon switch |
| internal-packages/workflow-designer-ui/src/editor/node/node.tsx  | Replaced manual GitHub badge conditions with calls to type guards   |


<details>
<summary>Comments suppressed due to low confidence (3)</summary>

**internal-packages/workflow-designer-ui/src/icons/node/index.tsx:117**
* The error message interpolates the entire content object rather than the provider string. Consider using the provider value (`${_exhaustiveCheck.provider}`) for clearer diagnostics.
```
throw new Error(`Unhandled TriggerProviderType: ${_exhaustiveCheck}`)
```
**packages/data-type/src/node/variables/index.ts:80**
* [nitpick] The alias `VectorStoreSourceProvider` is verbose; consider renaming it to `VectorStoreProvider` for consistency with existing `ActionProvider` and `TriggerProvider` types.
```
type VectorStoreSourceProvider = VectorStoreContent["source"]["provider"];
```
**packages/data-type/src/node/operations/index.ts:82**
* Add unit tests for the new generic `isTriggerNode`, `isActionNode`, and `isVectorStoreNode` guards to verify behavior when providers match or differ.
```
export function isTriggerNode<
```
</details>


state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-28T02:32:34Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>internal-packages/workflow-designer-ui/src/icons/node/index.tsx (1)</summary><blockquote>

`116-116`: **Consider reverting to provider-specific exhaustive check for better error messages.**

The change from `node.content.provider` to `node.content` in the exhaustive check reduces the specificity of error reporting. When an unhandled trigger provider is encountered, the error message will now show the entire content object instead of just the problematic provider value.


For better debugging experience, consider reverting to the more specific check:

```diff
-const _exhaustiveCheck: never = node.content;
+const _exhaustiveCheck: never = node.content.provider;
```

This would provide clearer error messages that specifically identify the unhandled provider type rather than dumping the entire content object.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between fc0e55d5d6ff4ca7e4edbde0db4430d8a15624d3 and d978350cf4e8b1acc20cd996084f317372ed9e64.

</details>

<details>
<summary>📒 Files selected for processing (4)</summary>

* `internal-packages/workflow-designer-ui/src/editor/node/node.tsx` (3 hunks)
* `internal-packages/workflow-designer-ui/src/icons/node/index.tsx` (1 hunks)
* `packages/data-type/src/node/operations/index.ts` (2 hunks)
* `packages/data-type/src/node/variables/index.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (3)</summary>

<details>
<summary>internal-packages/workflow-designer-ui/src/editor/node/node.tsx (3)</summary><blockquote>

<details>
<summary>packages/data-type/src/node/operations/index.ts (2)</summary>

* `isTriggerNode` (82-95)
* `isActionNode` (101-115)

</details>
<details>
<summary>internal-packages/workflow-designer-ui/src/editor/node/ui/github-repository-badge-from-trigger.tsx (1)</summary>

* `GitHubRepositoryBadgeFromTrigger` (13-31)

</details>
<details>
<summary>packages/data-type/src/node/variables/index.ts (1)</summary>

* `isVectorStoreNode` (82-98)

</details>

</blockquote></details>
<details>
<summary>packages/data-type/src/node/operations/index.ts (3)</summary><blockquote>

<details>
<summary>packages/flow/src/trigger/index.ts (1)</summary>

* `TriggerProvider` (17-17)

</details>
<details>
<summary>packages/flow/src/action/index.ts (2)</summary>

* `provider` (5-5)
* `ActionProvider` (11-11)

</details>
<details>
<summary>packages/data-type/src/node/operations/action.ts (2)</summary>

* `ActionContent` (30-33)
* `ActionContent` (34-34)

</details>

</blockquote></details>
<details>
<summary>packages/data-type/src/node/variables/index.ts (2)</summary><blockquote>

<details>
<summary>packages/vector-store/src/types.ts (1)</summary>

* `VectorStoreSourceProvider` (2-2)

</details>
<details>
<summary>packages/data-type/src/node/variables/vector-store.ts (2)</summary>

* `VectorStoreContent` (23-25)
* `VectorStoreContent` (26-26)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: check

</details>

<details>
<summary>🔇 Additional comments (9)</summary><blockquote>

<details>
<summary>packages/data-type/src/node/variables/index.ts (2)</summary>

`80-81`: **LGTM! Type declaration correctly extracts provider type.**

The type declaration `VectorStoreSourceProvider` properly extracts the provider type from the nested `VectorStoreContent["source"]["provider"]` structure, which aligns with the schema definition shown in the relevant code snippets.

---

`82-98`: **Excellent enhancement with proper type narrowing and runtime validation.**

The enhanced `isVectorStoreNode` function provides several improvements:

1. **Generic Type Parameters**: The `TVectorStoreSourceProvider` generic enables precise type narrowing
2. **Conditional Return Type**: The return type correctly narrows the node type when a provider is specified
3. **Runtime Validation**: The logic properly validates both schema compliance and provider matching
4. **Consistency**: The pattern matches the enhancements made to `isTriggerNode` and `isActionNode` in the operations file

The implementation correctly handles the nested provider path (`result.data.content.source.provider`) which differs from the operations nodes that have simpler provider paths.

</details>
<details>
<summary>internal-packages/workflow-designer-ui/src/editor/node/node.tsx (4)</summary>

`13-17`: **LGTM! Clean import additions for enhanced type guards.**

The import additions for `isActionNode`, `isTriggerNode`, and `isVectorStoreNode` are correctly positioned and align with the refactoring to use provider-aware type guards throughout the component.

---

`339-346`: **Excellent refactoring using enhanced type guard with provider filtering.**

The replacement of explicit type and provider checks with `isTriggerNode(node, "github")` provides several benefits:

1. **Improved Readability**: More concise and semantic condition
2. **Type Safety**: The enhanced type guard provides proper type narrowing
3. **Consistency**: Aligns with the DRY principle by using centralized type checking logic
4. **Maintainability**: Changes to type guard logic only need to be made in one place

The conditional rendering logic for the GitHub repository badge is correctly preserved.

---

`347-355`: **Clean refactoring for action node GitHub provider checks.**

The use of `isActionNode(node, "github")` successfully replaces the verbose manual condition checking. The type guard correctly accesses the nested provider path (`node.content.command.provider`) and provides proper type narrowing for the subsequent property access (`node.content.command.state.status`).

---

`356-364`: **Consistent application of enhanced vector store type guard.**

The `isVectorStoreNode(node, "github")` call correctly handles the nested provider path (`node.content.source.provider`) and maintains the existing badge rendering logic. This completes the consistent application of provider-aware type guards across all GitHub node types in this component.

</details>
<details>
<summary>packages/data-type/src/node/operations/index.ts (3)</summary>

`1-1`: **LGTM! Correct import addition for provider types.**

The import statement correctly brings in the `ActionProvider` and `TriggerProvider` types from the flow package, which are needed for the generic type constraints in the enhanced type guard functions.

---

`82-95`: **Excellent enhancement with proper generic type narrowing.**

The enhanced `isTriggerNode` function provides significant improvements:

1. **Generic Type Parameters**: `TTriggerProvider` extends `TriggerProvider` for precise type constraint
2. **Conditional Return Type**: Correctly narrows the type when a provider is specified
3. **Runtime Validation**: Properly validates both schema compliance and provider matching
4. **Type Safety**: The conditional type `TTriggerProvider extends TriggerProvider ? TriggerNode & { content: { provider: TTriggerProvider } } : TriggerNode` provides accurate type inference

The provider path (`result.data.content.provider`) is correctly accessed for trigger nodes.

---

`101-115`: **Consistent implementation with proper nested provider path handling.**

The enhanced `isActionNode` function mirrors the pattern of `isTriggerNode` with appropriate adaptations:

1. **Generic Parameters**: Correctly uses `TActionProvider extends ActionProvider`
2. **Return Type**: Properly narrows to include `{ content: { command: { provider: TActionProvider } } }`
3. **Runtime Logic**: Correctly accesses the nested provider path `result.data.content.command.provider`
4. **Consistency**: Maintains the same validation pattern as other enhanced type guards

The nested provider path handling aligns with the ActionContent schema structure where the provider is located within the command object.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-28T02:33:36Z

Review comments:
diff_hunk: @@ -113,7 +113,7 @@ export function NodeIcon({
 						case "manual":
 							return <TriggerIcon {...props} data-content-type-icon />;
 						default: {
-							const _exhaustiveCheck: never = node.content.provider;
+							const _exhaustiveCheck: never = node.content;
path: internal-packages/workflow-designer-ui/src/icons/node/index.tsx
user: login: Copilot
body: Assigning the full `node.content` to a `never` type loses the specific provider information. It should target `node.content.provider` to correctly catch unhandled `TriggerProviderType` cases.
```suggestion
							const _exhaustiveCheck: never = node.content.provider;
```
created_at: 2025-05-28T02:32:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -78,18 +79,39 @@ export const TriggerNode = OperationNode.extend({
 });
 export type TriggerNode = z.infer<typeof TriggerNode>;
 
-export function isTriggerNode(args?: unknown): args is TriggerNode {
+export function isTriggerNode<
+	TTriggerProvider extends TriggerProvider = TriggerProvider,
+>(
+	args?: unknown,
+	provider?: TTriggerProvider,
+): args is TTriggerProvider extends TriggerProvider
+	? TriggerNode & { content: { provider: TTriggerProvider } }
+	: TriggerNode {
 	const result = TriggerNode.safeParse(args);
-	return result.success;
+	return (
+		result.success &&
+		(provider === undefined || result.data.content.provider === provider)
+	);
 }
 
 export const ActionNode = OperationNode.extend({
 	content: ActionContent,
 });
 export type ActionNode = z.infer<typeof ActionNode>;
-export function isActionNode(args?: unknown): args is ActionNode {
+export function isActionNode<
path: packages/data-type/src/node/operations/index.ts
user: login: Copilot
body: [nitpick] The provider-checking logic in each guard is nearly identical. Consider extracting a shared helper to reduce duplication and simplify future updates.
created_at: 2025-05-28T02:32:34Z
author_association: CONTRIBUTOR

PR comments:
user: login: vercel[bot]
created_at: 2025-05-28T01:06:48Z
body: [vc]: #d0yJVLBX1gDqqGweVNBGKuN9DY+BK+6PlraLqvKqYKg=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJnaXNlbGxlLXBsYXlncm91bmQiLCJyb290RGlyZWN0b3J5IjoiYXBwcy9wbGF5Z3JvdW5kIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3IwNi1lZGdlL2dpc2VsbGUtcGxheWdyb3VuZC9HUHhVNlI5RktlV3dpQ0RkaXhxV3RuYVFOcVFBIiwicHJldmlld1VybCI6Imdpc2VsbGUtcGxheWdyb3VuZC1naXQtY29kZXgtcmVmYWN0b3ItY29kZS1mb3ItMTk4ZDk1LXIwNi1lZGdlLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoiZ2lzZWxsZS1wbGF5Z3JvdW5kLWdpdC1jb2RleC1yZWZhY3Rvci1jb2RlLWZvci0xOThkOTUtcjA2LWVkZ2UudmVyY2VsLmFwcCJ9fSx7Im5hbWUiOiJnaXNlbGxlIiwicm9vdERpcmVjdG9yeSI6ImFwcHMvc3R1ZGlvLmdpc2VsbGVzLmFpIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3IwNi1lZGdlL2dpc2VsbGUvNjVNQTFlcHYyeEtNaWtXZnJNdzhlVkNocDgzayIsInByZXZpZXdVcmwiOiJnaXNlbGxlLWdpdC1jb2RleC1yZWZhY3Rvci1jb2RlLWZvci1yZWFkYWJpbGl0eS03Njc4ZDAtcjA2LWVkZ2UudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJnaXNlbGxlLWdpdC1jb2RleC1yZWZhY3Rvci1jb2RlLWZvci1yZWFkYWJpbGl0eS03Njc4ZDAtcjA2LWVkZ2UudmVyY2VsLmFwcCJ9fV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **giselle** | ✅ Ready ([Inspect](https://vercel.com/r06-edge/giselle/65MA1epv2xKMikWfrMw8eVChp83k)) | [Visit Preview](https://giselle-git-codex-refactor-code-for-readability-7678d0-r06-edge.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/giselle-git-codex-refactor-code-for-readability-7678d0-r06-edge.vercel.app?via=pr-comment-feedback-link) | May 28, 2025 2:33am |
| **giselle-playground** | ✅ Ready ([Inspect](https://vercel.com/r06-edge/giselle-playground/GPxU6R9FKeWwiCDdixqWtnaQNqQA)) | [Visit Preview](https://giselle-playground-git-codex-refactor-code-for-198d95-r06-edge.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/giselle-playground-git-codex-refactor-code-for-198d95-r06-edge.vercel.app?via=pr-comment-feedback-link) | May 28, 2025 2:33am |



author_association: NONE
user: login: changeset-bot[bot]
created_at: 2025-05-28T01:06:51Z
body: ###  ⚠️  No Changeset found

Latest commit: d978350cf4e8b1acc20cd996084f317372ed9e64

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**



[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/giselles-ai/giselle/new/codex/refactor-code-for-readability-and-simplify-conditions?filename=.changeset/sweet-bulldogs-fetch.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0AImprove%20node%20type%20guards%20with%20provider%20filtering%20and%20GitHub%20badge%20conditions%0A)

<details><summary>💥 An error occurred when fetching the changed packages and changesets in this PR</summary>

```
Some errors occurred when validating the changesets config:
The package "playground" depends on the ignored package "giselle-sdk", but "playground" is not being ignored. Please add "playground" to the `ignore` option.
The package "studio.giselles.ai" depends on the ignored package "giselle-sdk", but "studio.giselles.ai" is not being ignored. Please add "studio.giselles.ai" to the `ignore` option.
The package "@giselle-internal/workflow-designer-ui" depends on the ignored package "giselle-sdk", but "@giselle-internal/workflow-designer-ui" is not being ignored. Please add "@giselle-internal/workflow-designer-ui" to the `ignore` option.
```

</details>

author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-05-28T01:06:52Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This update refactors node type and provider checks across multiple modules to utilize new, more precise type guard functions from the data-type package. These functions now support optional provider arguments and improved type narrowing, centralizing and simplifying node verification logic throughout the codebase.

## Changes

| File(s)                                                                                      | Change Summary                                                                                           |
|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| internal-packages/workflow-designer-ui/src/editor/node/node.tsx                             | Replaced explicit node type/provider checks with new type guard functions (`isTriggerNode`, etc.).        |
| internal-packages/workflow-designer-ui/src/icons/node/index.tsx                             | Adjusted exhaustive type check in "trigger" case to use the whole content object for error context.       |
| packages/data-type/src/node/operations/index.ts                                             | Enhanced `isTriggerNode` and `isActionNode` with generic provider parameters and refined type predicates. |
| packages/data-type/src/node/variables/index.ts                                              | Updated `isVectorStoreNode` to accept optional provider, improving type narrowing and runtime checks.     |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant UI as Node UI
    participant DataType as data-type Type Guards

    UI->>DataType: isTriggerNode(node, "github")
    DataType-->>UI: true/false (with narrowed type if provider matches)

    UI->>DataType: isActionNode(node, "github")
    DataType-->>UI: true/false (with narrowed type if provider matches)

    UI->>DataType: isVectorStoreNode(node, "github")
    DataType-->>UI: true/false (with narrowed type if provider matches)
```

## Possibly related PRs

- [giselles-ai/giselle#955](https://github.com/giselles-ai/giselle/pull/955): Refactors node type checks to use type guard functions, directly relating to this PR’s improvements in type safety and validation.

## Suggested reviewers

- shige

## Poem

> In the warren of code, a refactor hops,
> Type guards now guide where the logic stops.
> With providers in tow, the checks are precise,
> Each node now sorted, neat and nice.
> 🐇✨ Code carrots abound—what a delight!
> For every node, the type is just right.

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcSHFcLzpIACIASWZefClIDEUSMNludKJsZ1pkAHd1WB4KJPglPgAzeC8aCngMInQMegBxdQAJbAFIATRaUgVW9Xh8DERovvlsREow/Fk0ZmdG2XHIAApbSDMATgA2AA4ASkgyWEwGaTDYdNSlDKz7WUQaZmmUDFwy2mwGRrNRISCrzGp1SiAxhobgqWqjG6YeiIeAJLzwKqyKEdXDdXr9QbpJgjcQbBh3BgAa2QjVu6Vm80a9SqaGuGiMAGkSPJyZhSDSMAwvNglBwjFAAFQSgCiGEugqi0Ey6TauQo+UgRVwJSsZRBlUgADFavVAVKuHB0rhlZAcnlIFVsILSRNIAADJDQBpEUgUAByaTdLXoHsQAEExGMM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Mme9XbAwBIg7N9MbE7ZwM7K7aJQOUzDsfmVlZSOQoHe0LnDYOZGceUU3LjeOPlTHLAT7HHK6MvIMfHGKDqAZXPIqDTZ7fwKnQ1QvXVEvfo/3YcCvGDCYUEE8GTMbN0PTDQKccqa4AzdhMQJnJorAFHcuOYYsW0WRJ7JpKKAnPgN0aAeSbsEVEgHsEZD6EgYwoMYkb1bQRjfrCuDYbuCsROeAbI0I2KB0ALN0Z4gWZSX8Mab4AAbWiF2M+OiAAF1UT2osSW4dcXJypKpC5ekvsQtidDIJibRUwzp6orRWwNcdwh1X5fdxgpdw5wNtc9pddvhUR/0tpNQw5y5ExsFUwQ1MQ+h8BIVGo44E4k5vAeBnA8NFcwMY8eYhTplYSajXi5CkQOJfdNSOMJFGSTpaBulapGp64Biw9cAI9Go2SvhQslSogGlyMhkxhqNul0gTj+AMBrdV5Jlbc1S75iRI5o5+stThVBZUZXc7h3dsYRluj5AwsJYP4iByt/Em9qsW8os29x0QVO93ZRtWs+9JteTptLoABVEU4oxxSfQeLvWtapMfMcIVF46M2MR0+uPde6NI16DI76LI5mLbUGW2YcWpMUBfN0ac/qS/UbWNdCaoqMuooQqQkQsQiQhA6QuE2o0VNIfg6cy/AgSc90GcttBfecn0pc9slc2/S/BfJ47U/sd4vYr49A5wjUHc14l8z44wyAH/L858j464YwtiS/QA+8rc9ciwyCqAi0QC5SH8kCsvMChfeA/fVAR85c/wJCt8pwkGV/ZABCnC4CvCz/SC3A4ilSR4Hw8gkI9E64EI9qeCp8xC0iv86IugyCrgKiwcA8t0fIubfRQxChMuahWhQ7ORBQVgRRPwNAFREozVHkNIKgbRARPRYRchaSgyXAAAfQqEQF0vdJIGKloF0oNXmmEq0toD2AAHYjgABmAAVgAAYGAqgAAWEgI4AQAARjRwACY3KbLDgXKjgPKqgHLfLbKHLbKAq6A9gSADgPKhFSEtKmF1B9L8gjLKMtdTLdLKFUqgA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=giselles-ai/giselle&utm_content=968):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR