Skip to content

Commit 5d4e054

Browse files
committed
chore(scheduled-tasks): convert added inline comments to TSDoc
1 parent edc8618 commit 5d4e054

6 files changed

Lines changed: 10 additions & 16 deletions

File tree

apps/sim/app/api/mothership/execute/route.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ export const POST = withRouteHandler(async (req: NextRequest) => {
154154
workspaceId,
155155
effectiveChatId
156156
).catch((error) => {
157-
// Degrade to a context-less run rather than failing the whole execution,
158-
// but surface the failure so a broken mention is diagnosable.
159157
reqLogger.warn('Failed to resolve agent contexts for execution', {
160158
error: toError(error).message,
161159
})

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/use-prompt-editor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,6 @@ export function usePromptEditor({
573573
}
574574

575575
const caret = e.target.selectionStart ?? finalValue.length
576-
// Keep the ref in lockstep with state so synchronous readers (getValue /
577-
// getPlainValue) never see pre-keystroke text before the next render.
578576
valueRef.current = finalValue
579577
setValueState(finalValue)
580578
syncMentionState(e.target, finalValue, caret)

apps/sim/app/workspace/[workspaceId]/scheduled-tasks/components/task-modal/task-modal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,15 @@ function TaskModalContent({
140140
}: Omit<TaskModalProps, 'open'>) {
141141
const { workspaceId } = useParams<{ workspaceId: string }>()
142142
const editor = usePromptEditor({ workspaceId, initialValue: edit?.prompt })
143-
144-
// Re-register the stored mentions once on open so saving an edit preserves
145-
// them — the editor seeds from `initialValue` text only, not its contexts.
146143
const setContexts = editor.setContexts
144+
145+
/**
146+
* Re-registers an edited task's stored `@`-mentions once on open: the editor
147+
* seeds from `initialValue` text only, never its contexts. Runs once per open
148+
* since the dialog's content remounts each time it opens.
149+
*/
147150
useEffect(() => {
148151
if (edit?.contexts && edit.contexts.length > 0) setContexts(edit.contexts)
149-
// Runs once per open; content remounts each time the dialog opens.
150152
// eslint-disable-next-line react-hooks/exhaustive-deps
151153
}, [])
152154
const seed = edit ? { date: edit.launchDate, time: edit.launchTime } : defaultLaunch(slot)

apps/sim/app/workspace/[workspaceId]/scheduled-tasks/utils/recurrence.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export function cronToRecurrence(params: {
170170
* Materializes a recurring schedule's run instants inside `[rangeStart, rangeEnd]`
171171
* that are still upcoming (after `from`), skipping individually deleted
172172
* occurrences and stopping at the recurrence end. Pure given its inputs.
173+
*
174+
* The lower bound is inclusive: croner's `nextRun(date)` returns the first
175+
* occurrence strictly after `date`, so the search starts one millisecond before
176+
* the bound to admit an occurrence landing exactly on it.
173177
*/
174178
export function expandOccurrences(params: {
175179
cronExpression: string
@@ -195,8 +199,6 @@ export function expandOccurrences(params: {
195199
const lowerBound = rangeStart.getTime() > from.getTime() ? rangeStart : from
196200

197201
const occurrences: Date[] = []
198-
// nextRun(date) returns the first occurrence strictly after `date`; subtract a
199-
// millisecond so an occurrence landing exactly on the lower bound is included.
200202
let cursor = new Date(lowerBound.getTime() - 1)
201203
for (let i = 0; i < MAX_OCCURRENCES_PER_VIEW; i++) {
202204
const next = cron.nextRun(cursor)

apps/sim/background/schedule-execution.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,8 +1352,6 @@ export async function executeJobInline(payload: JobExecutionPayload) {
13521352
})
13531353
}
13541354

1355-
// A recurring job with no remaining occurrence (past its end date or out of
1356-
// non-excluded runs) is finished, just like a one-time or maxRuns-capped job.
13571355
const isComplete = isOneTime || maxRunsReached || !nextRunAt
13581356

13591357
await applyScheduleUpdate(
@@ -1397,9 +1395,6 @@ export async function executeJobInline(payload: JobExecutionPayload) {
13971395
}
13981396

13991397
const maxRunsReached = Boolean(jobRecord.maxRuns && newRunCount >= jobRecord.maxRuns)
1400-
// A one-time job, a maxRuns-capped job, or a recurring job out of remaining
1401-
// occurrences (past endsAt / all excluded) is finished even when this run
1402-
// failed — mirror the success path so it never re-fires past its bounds.
14031398
const isComplete = !jobRecord.cronExpression || maxRunsReached || !nextRunAt
14041399

14051400
await applyScheduleUpdate(

apps/sim/lib/workflows/schedules/orchestration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ export async function performExcludeOccurrence(
427427
updatedAt: new Date(),
428428
}
429429

430-
// Advancing past the just-removed run only matters when it was the one queued next.
431430
if (job.nextRunAt && job.nextRunAt.getTime() === occurrence.getTime()) {
432431
const nextRunAt = computeNextRunAt({
433432
cronExpression: job.cronExpression,

0 commit comments

Comments
 (0)