-
Notifications
You must be signed in to change notification settings - Fork 4
Add filter on sf nodes list
#225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds a --state filtering option to the sf nodes list command, allowing users to filter nodes by their status (pending, awaitingcapacity, running, released, failed, terminated, deleted). The implementation uses Commander.js's .choices() method for input validation and allows multiple states to be specified with repeated flags (e.g., --state pending --state running). The filtering logic is applied client-side after fetching all nodes from the API, maintaining consistency with existing patterns in the codebase. The feature integrates cleanly with the existing node listing functionality and follows established TypeScript patterns for type safety.
Important Files Changed
| Filename | Score | Overview |
|---|---|---|
| src/lib/nodes/list.tsx | 4/5 | Added --state filtering option with validation, argument parsing, and client-side filtering logic for node status |
Confidence score: 4/5
- This PR is safe to merge with minimal risk and provides a useful filtering feature for node management
- Score reflects solid implementation following established patterns, proper type safety, and good input validation, but loses one point due to the complex type casting required for Commander.js options integration
- Pay close attention to the type casting in the filtering logic to ensure it handles edge cases properly
Sequence Diagram
sequenceDiagram
participant User
participant CLI as CLI Command
participant Auth as Auth Helper
participant Client as Nodes Client
participant API as SFC API
participant Display as Display Components
User->>CLI: "sf nodes list --state pending --state running"
CLI->>Auth: "getAuthToken()"
Auth-->>CLI: "token or null"
alt token exists
CLI->>Client: "nodesClient(token)"
Client-->>CLI: "client instance"
CLI->>CLI: "ora('Fetching nodes...').start()"
CLI->>Client: "client.nodes.list()"
Client->>API: "GET /nodes"
API-->>Client: "{ data: nodes[] }"
Client-->>CLI: "{ data: nodes }"
CLI->>CLI: "spinner.stop()"
CLI->>CLI: "filter nodes by selected states"
alt json option
CLI->>User: "JSON.stringify(filteredNodes)"
else no nodes found
CLI->>User: "No nodes found. Create your first node:"
else verbose option
CLI->>Display: "render(<NodesVerboseDisplay nodes={filteredNodes} />)"
Display-->>User: "detailed node information"
else default display
CLI->>CLI: "createNodesTable(filteredNodes)"
CLI->>CLI: "collect actions from nodes"
CLI->>User: "table output + next steps"
end
else no token
CLI->>User: "Not logged in. Please run 'sf login' first."
end
Note over CLI,API: Error handling via handleNodesError() for any API failures
Context used:
- Context from
dashboard- .cursor/rules/cli.mdc (source)
1 file reviewed, 1 comment
| spinner.stop(); | ||
|
|
||
| // Apply optional state filter if provided | ||
| const selectedStates = (options as unknown as { state?: string[] }).state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Type assertion is unsafe. Consider adding proper type definition for options parameter or using type guards.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/nodes/list.tsx
Line: 470:470
Comment:
**style:** Type assertion is unsafe. Consider adding proper type definition for options parameter or using type guards.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
No description provided.