-
Notifications
You must be signed in to change notification settings - Fork 694
handle cancel pendings jobs #5881
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
handle cancel pendings jobs #5881
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.
Caution
Changes requested ❌
Reviewed everything up to b389eab in 3 minutes and 48 seconds. Click for details.
- Reviewed
330
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
9
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/src/lib/components/WorkerRepl.svelte:182
- Draft comment:
Before calling cancelJob on Ctrl+C, ensure that 'jobId' is non-empty to avoid unintended cancellation calls. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This is a reasonable concern - if Ctrl+C is pressed when no job is running, we'd be calling cancelJob with an empty jobId. However, looking at the cancelJob function, it requires a jobId parameter and is typed as string, so TypeScript would catch this at compile time if empty strings weren't allowed. The code also shows the jobId is only used to make an API call, where an empty ID would likely just fail gracefully. The comment identifies a real edge case that could cause unnecessary API calls. However, it's not clear this would cause any actual problems in practice. While technically correct, this seems like over-optimization. The worst case is an extra API call that would fail gracefully. The code is simpler and cleaner without the extra check. The comment should be deleted. While technically valid, it suggests adding complexity to handle an edge case that would have minimal impact.
2. frontend/src/lib/components/jobs/utils.ts:49
- Draft comment:
The 'attempts' counter is only incremented in the catch block. If the job remains pending (neither success nor completed), 'attempts' is never increased, which can lead to an infinite loop. Consider incrementing 'attempts' on each iteration. - Reason this comment was not posted:
Comment was on unchanged code.
3. frontend/src/lib/components/jobs/utils.ts:51
- Draft comment:
The sleep delay calculation '500 * (attempts || 0.75)' is non-intuitive. Adding a comment to explain the rationale behind this formula would improve readability. - Reason this comment was not posted:
Comment was on unchanged code.
4. frontend/src/lib/components/jobs/utils.ts:77
- Draft comment:
Instead of throwing a string ('Could not get job result, should not get here'), consider throwing an Error instance for consistency with standard error handling practices. - Reason this comment was not posted:
Comment was on unchanged code.
5. frontend/src/lib/components/WorkerRepl.svelte:44
- Draft comment:
Typographical issue: Consider renaming 'pendingsJobs' to 'pendingJobs' for grammatical correctness. - Reason this comment was not posted:
Marked as duplicate.
6. frontend/src/lib/components/WorkerRepl.svelte:127
- Draft comment:
Typo: The variable name "pendingsJobs" appears to be misspelled. Consider renaming it to "pendingJobs" for clarity. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While technically correct that "pendings" is not proper English, this is a minor naming issue that doesn't affect functionality. The variable name is used consistently throughout the file. Renaming would require changes in multiple places and provide minimal benefit. This feels like nitpicking rather than a substantive code quality issue. The comment is technically accurate - it is a grammatical error. Variable naming is important for code readability. While good naming is important, this is a very minor issue. The meaning is still clear and the code works fine. The benefit of renaming doesn't justify the effort of changing it in multiple places. This comment should be deleted as it points out a minor naming issue that doesn't materially impact code quality or functionality.
7. frontend/src/lib/components/WorkerRepl.svelte:141
- Draft comment:
Typo: The function name "listPendingJobsAndUpdateSelectedJobid" might be better as "listPendingJobsAndUpdateSelectedJobId" to maintain consistent camelCase. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While this is technically correct about maintaining consistent camelCase, this is a relatively minor naming issue. The function is still perfectly readable and functional. The comment doesn't point out a bug or significant code quality issue. It's more of a nitpick about code style. The comment is accurate and suggests a valid improvement to maintain consistent naming conventions. Consistent naming is important for code maintainability. However, this is an extremely minor stylistic issue that doesn't impact functionality or significantly hurt readability. The PR review rules specifically say not to make comments that are obvious or unimportant. This comment should be deleted as it points out a very minor stylistic issue that doesn't meaningfully impact code quality or maintainability.
8. frontend/src/lib/components/WorkerRepl.svelte:292
- Draft comment:
Typo: The closing Button tag appears to be split over two lines. It currently showsLoad pending ssh jobs</Button
on one line and>
on the next. Please correct it so that the tag is closed properly (i.e.</Button>
). - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% This is purely a stylistic issue that doesn't affect functionality. The code will work fine either way. The comment is suggesting a minor formatting change that isn't critical. Our rules say not to make purely informative comments or comments about obvious/unimportant issues. The split tag could potentially make the code slightly harder to read. Some style guides might prefer keeping tags on one line. While code readability is important, this is an extremely minor formatting issue that doesn't meaningfully impact maintainability. The code works correctly as is. This comment should be deleted as it suggests a trivial formatting change that doesn't affect functionality or significantly impact code quality.
9. frontend/src/lib/components/WorkerRepl.svelte:310
- Draft comment:
Typo: The function namelistPendingJobsAndUpdateSelectedJobid
uses inconsistent casing for 'Id'. Given that other references useselectedJobId
(with a capital I), consider renaming this function tolistPendingJobsAndUpdateSelectedJobId
for consistency. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While this is technically correct about the inconsistency, I need to consider if this is important enough to warrant a comment. The code will work fine either way, and this is a very minor stylistic issue. The rules say to only keep comments that require clear code changes, and to not make comments that are obvious or unimportant. The inconsistency is real, but does fixing it provide any real value? Would the time spent discussing and fixing this be well spent? While consistency is good, this is an extremely minor stylistic issue that doesn't affect functionality or readability in any meaningful way. The rules specifically say not to make comments that are obvious or unimportant. This comment should be deleted as it points out a very minor stylistic issue that doesn't meaningfully impact code quality or maintainability.
Workflow ID: wflow_pNCPi5Xy4GEXbMvz
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
let codeViewer: Drawer | undefined = $state() | ||
let filter = $state('') | ||
let { tag }: Props = $props() | ||
let code: string = $state('') | ||
let working_directory = $state('~') | ||
let homeDirectory: string = '~' | ||
let pendingsJobs: Array<QueuedJob> = $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.
Consider renaming 'pendingsJobs' to 'pendingJobs' for clarity and consistency.
let pendingsJobs: Array<QueuedJob> = $state([]) | |
let pendingJobs: Array<QueuedJob> = $state([]) |
requestBody: {} | ||
}) | ||
} catch (err) { | ||
sendUserToast(err.BodyDropPivotTarget, true) |
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.
In the cancelJob
function, the caught error is handled by showing a toast but not rethrown. This prevents the caller's try/catch from working. Consider rethrowing the error after sending the toast.
async function cancelJob(jobId: string) { | ||
try { | ||
await JobService.cancelQueuedJob({ | ||
workspace: $workspaceStore! ?? '', |
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.
Using $workspaceStore! ?? ""
is redundant. Since $workspaceStore
is asserted non-null, consider using it directly.
workspace: $workspaceStore! ?? '', | |
workspace: $workspaceStore!, |
requestBody: {} | ||
}) | ||
} catch (err) { | ||
sendUserToast(err.BodyDropPivotTarget, true) |
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.
Typographical error: The property access err.BodyDropPivotTarget
in the catch block seems unusual. Verify if this is the intended property name, or if it should be something like err.body
or another standard error property.
sendUserToast(err.BodyDropPivotTarget, true) | |
sendUserToast(err.body, true) |
Important
Adds functionality to manage pending jobs and refactors job execution logic in
WorkerRepl.svelte
andutils.ts
.WorkerRepl.svelte
.listPendingJobs
,listPendingJobsAndUpdateSelectedJobid
, andcancelJob
functions inWorkerRepl.svelte
.runScriptAndPollResult
intorunScript
andpollJobResult
inutils.ts
for better separation of concerns.handleCommand
inWorkerRepl.svelte
to use newrunScript
andpollJobResult
functions.isRunScriptByPathData
type guard inutils.ts
.WorkerRepl.svelte
to reflect new utility functions.This description was created by
for b389eab. You can customize this summary. It will automatically update as commits are pushed.