fix: inconsistient behavior with pull and redeploy button via project table#1953
Merged
fix: inconsistient behavior with pull and redeploy button via project table#1953
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🔍 Deadcode AnalysisFound 3 unreachable functions in the backend. View detailsOnly remove deadcode that you know is 100% no longer used.
|
Contributor
|
Container images for this PR have been built successfully!
Built from commit 30e6580 |
053d83d to
5763c13
Compare
Member
Author
5763c13 to
6afcff5
Compare
Member
Author
6afcff5 to
7a29200
Compare
7a29200 to
30e6580
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What This PR Implements
Related issue
Related Issue
Fixes # #1794
Changes Made
Testing Done
./scripts/development/dev.sh startjust lint all)just test backendChecklist
mainbranchAI Tool Used (if applicable)
AI Tool:
Assistance Level:
What AI helped with:
I reviewed and edited all AI-generated output:
I ran all required tests and manually verified changes:
Additional Context
Disclaimer Greptiles Reviews use AI, make sure to check over its work.
To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike
Greptile Summary
This PR fixes the inconsistent loading/disabled-button behavior in the project table by replacing the shared
isLoadingstate object (which applied a single spinner and disabled state across all rows when any one action was running) with a per-projectactionStatusrecord keyed by project ID. Action logic has been extracted into a newcreateProjectActionsfactory (projects-table.actions.ts) and a shared type file (projects-table.helpers.ts), keeping the Svelte component focused on presentation.Key changes:
projects-table.svelte: Swapslet isLoading = $state({...})forlet actionStatus = $state<Record<string, ActionStatus>>({}), so spinners and disabled states are now scoped to the specific row being acted on. Bulk loading state is unchanged.projects-table.actions.ts: New file housingperformProjectAction,handleDestroyProject,handleSyncFromGit, and the three bulk-action handlers. The bulk-actionrunBulkActionnow correctly uses atry/finallyblock, ensuringisBulkLoadingis always cleared — an improvement over the original code.performProjectAction(line 86) andhandleSyncFromGit(line 152),handleApiResultWithCallbacksis anasyncfunction but is called withoutawait. This makes the surroundingtry/catchdead code and leaves async errors unguarded.cli/go.mod: Promotesgithub.com/mattn/go-runewidthfrom indirect to direct — appears unrelated to the frontend change.Confidence Score: 3/5
awaitonhandleApiResultWithCallbacksin two places creates dead error-handling code that should be addressed before merging.finallycleanup is an improvement. The missingawaiton the async utility inperformProjectActionandhandleSyncFromGitmeans thecatchblocks are unreachable — errors from those async flows would not surface the intended error toast, and the intendedactionStatusreset in thecatchwould never fire. In practicehandleApiResultWithCallbacksguards its own errors internally, so there is no observable regression today, but the pattern is fragile and misleading.frontend/src/routes/(app)/projects/projects-table.actions.ts— the two missingawaitcalls onhandleApiResultWithCallbacks.Important Files Changed
handleApiResultWithCallbacks(an async function) is called withoutawait, making the surroundingtry/catchunreachable dead code and risking unhandled promise rejections.ActionStatusunion type; correct and safe.actionStatuskeyed by project ID instead of a shared global loading state, correctly fixing the inconsistent spinner/disabled-button behavior across rows; delegates action logic to the newcreateProjectActionsfactory.github.com/mattn/go-runewidthfrom an indirect to a direct dependency; unrelated to the frontend fix (discussed in a previous review thread).Sequence Diagram
sequenceDiagram participant User participant Svelte as projects-table.svelte participant Actions as createProjectActions participant API as projectService / gitOpsSyncService participant UI as Toast / Dialog User->>Svelte: Click action button (e.g. Redeploy) Svelte->>Actions: performProjectAction('redeploy', id) Actions->>Actions: actionStatus[id] = 'redeploying' Actions->>API: tryCatch(config.run(id)) API-->>Actions: Result<T, Error> Actions->>Actions: handleApiResultWithCallbacks(result) [NOT awaited] Actions-->>Svelte: returns (loading still shown via actionStatus) Note over Actions: async continues in background Actions->>UI: setLoadingState(true) → actionStatus[id] = 'redeploying' alt Success Actions->>UI: toast.success(...) Actions->>Svelte: refreshProjects() else Error Actions->>UI: toast.error(message) end Actions->>Actions: finally: setLoadingState(false) → actionStatus[id] = '' Svelte->>Svelte: isAnyLoading re-derived → buttons re-enabled User->>Svelte: Click Bulk Up (multiple projects) Svelte->>Actions: handleBulkUp(ids) Actions->>UI: openConfirmDialog(...) User->>UI: Confirm UI->>Actions: action callback Actions->>Actions: isBulkLoading.up = true Actions->>API: Promise.allSettled(ids.map deployProject) API-->>Actions: results[] Actions->>UI: toast (success / partial / error) Actions->>Svelte: refreshProjects() Actions->>Svelte: setSelectedIds([]) Actions->>Actions: finally: isBulkLoading.up = falseLast reviewed commit: 6afcff5
Context used:
dashboard- JavaScript/TypeScript Best PracticesUse const/let instead of var for variable declarations
Prefer ... (source)