Skip to content

🤖 feat: add scheduled prompt queue#3422

Open
LeonidasZhak wants to merge 1 commit into
coder:mainfrom
LeonidasZhak:codex/scheduled-prompt-queue
Open

🤖 feat: add scheduled prompt queue#3422
LeonidasZhak wants to merge 1 commit into
coder:mainfrom
LeonidasZhak:codex/scheduled-prompt-queue

Conversation

@LeonidasZhak
Copy link
Copy Markdown

Summary

Adds a workspace-scoped scheduled prompt queue in the right sidebar. Users can schedule a text prompt for a future local time, choose whether it should dispatch after the current step or after the current turn, run it immediately, delete it, and see sent/failed/sending status directly in the Schedule tab.

Background

Part of #3417. This covers the explicit scheduling workflow for quota-reset or overnight continuation scenarios. Automatic rate-limit reset detection is left as a follow-up because that likely needs backend/provider-specific signal plumbing rather than a purely local UI queue.

Implementation

  • Adds a Schedule right-sidebar tab with prompt text, datetime-local scheduling, dispatch-mode selection, run-now/delete controls, and lifecycle badges.
  • Stores scheduled prompts per workspace in localStorage and normalizes stale or malformed entries before rendering or dispatching.
  • Mounts an active-workspace dispatcher from ChatPane so due prompts are sent through the existing workspace.sendMessage API using the current send options, without mutating the visible composer draft.
  • Cleans scheduled prompts when a workspace is deleted, but does not copy them when a workspace is forked to avoid duplicating future automated sends.

Validation

  • npx bun@1.3.5 test src/browser/features/ScheduledPrompts/scheduledPrompts.test.ts src/common/constants/storage.test.ts
  • npx bun@1.3.5 run node_modules/@typescript/native-preview/bin/tsgo.js --noEmit -p tsconfig.main.json
  • npx bun@1.3.5 run node_modules/@typescript/native-preview/bin/tsgo.js --noEmit
  • git diff --check

Risks

The dispatcher is renderer-local and runs while the workspace UI is mounted; it is not yet a background daemon that can wake a closed app. Scheduled prompts are text-only in this first pass, so attachment scheduling and command parsing can be layered on later if maintainers want them. Automatic rate-limit reset detection is intentionally out of scope for this PR.

Pains

A targeted ESLint invocation for the changed files hung locally for more than two minutes with no output, matching the same local lint behavior observed on the companion PR, so it was terminated and the other validation checks above were used.


Generated with mux • Model: GPT-5 • Thinking: unknown • Cost: ``

@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Please review the scheduled prompt queue implementation. In particular, please look at the active-workspace dispatcher behavior, localStorage lifecycle handling, and the choice not to copy scheduled sends on workspace fork.

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from 8302189 to 5dd4327 Compare May 29, 2026 14:12
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Connector is now set up. Please review the scheduled prompt queue implementation for #3417, especially the active-workspace dispatcher behavior and scheduled-send storage lifecycle.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5dd4327309

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/components/ChatPane/ChatPane.tsx Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from 5dd4327 to 4e54e11 Compare May 30, 2026 02:27
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed your dispatcher lifetime feedback by moving the active-workspace scheduled prompt dispatcher out of ChatPane and into an App-level active workspace host, while disabling it for transcript-only, incompatible, and queued agent-task workspaces.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e54e1183b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/App.tsx Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch 2 times, most recently from c6fa89e to eab35fb Compare May 30, 2026 02:38
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the provider side-effect feedback by letting the App-level scheduled prompt dispatcher mount AgentProvider/ThinkingProvider with global listeners disabled. This preserves the shared send-option path while preventing duplicate agent/thinking shortcut handling; added tests for disabled agent/thinking keybind listeners.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eab35fbeb2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.ts Outdated
Comment thread src/browser/features/ScheduledPrompts/scheduledPrompts.ts Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from eab35fb to f6de8f7 Compare May 30, 2026 02:43
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Rebased this PR onto latest main and resolved the ThinkingContext conflict by preserving the new minimum-thinking-level policy together with the disabled-global-listeners dispatcher host fix. Re-ran the focused tests and tsgo --noEmit after the rebase.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from f6de8f7 to 30d7932 Compare May 30, 2026 02:48
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the scheduled dispatcher feedback: due scheduled prompts are now dispatched sequentially, sending prompts no longer auto-recover to scheduled on normalization, and a dispatcher test verifies multiple due prompts do not call sendMessage in parallel. Re-ran focused tests and tsgo --noEmit.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30d7932cb2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from 30d7932 to 686dc26 Compare May 30, 2026 02:54
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the live Chat Instructions feedback: the App-level scheduled prompt dispatcher now reads the hydrated additional-system-context snapshot for the active workspace and includes it in scheduled send options, matching the normal ChatInput send path. Re-ran focused tests and tsgo --noEmit.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 686dc2681d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ScheduledPrompts/scheduledPrompts.ts
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from 686dc26 to 29a3388 Compare May 30, 2026 03:00
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the latest scheduler edge cases: clamped long-delay timers now reschedule after the clamp expires, and sending prompts remain protected from automatic duplicate sends while becoming manually recoverable via Run now after they have been stuck for a recovery window. Re-ran focused tests and tsgo --noEmit.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29a3388193

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.ts Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from 29a3388 to 7a1bb83 Compare May 31, 2026 06:19
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the queued prompt snapshot feedback: before dispatching each prompt from a due batch, the dispatcher now re-reads the current scheduled prompt state and only sends entries that still exist and are still due/scheduled. Added a dispatcher test for removing a queued due prompt while an earlier prompt is still sending, and re-ran focused tests plus tsgo --noEmit.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a1bb83ccc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/App.tsx Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch 2 times, most recently from ce64b11 to c3458c7 Compare June 5, 2026 09:24
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Rebased onto latest main and addressed the Schedule-tab availability feedback. The scheduled prompt dispatcher guard is now shared with the right sidebar and command palette: Schedule is removed/hidden for transcript-only, incompatible-runtime, and queued delegated-task workspaces, so users cannot create scheduled prompts in contexts where no dispatcher can run them.

Validation:

  • bun test src/browser/features/ScheduledPrompts/scheduledPrompts.test.ts src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.test.tsx src/browser/features/ScheduledPrompts/scheduledPromptAvailability.test.ts src/browser/utils/commands/sources.test.ts src/common/constants/storage.test.ts
  • node_modules/.bin/tsgo --noEmit
  • git diff --check
  • PATH="/tmp/mux-bun-tools/node_modules/.bin:$PATH" make static-check

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3458c7197

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/App.tsx Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from c3458c7 to d1b29bb Compare June 5, 2026 09:32
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the manual useMemo feedback. The App-level dispatcher now passes the hydrated additional-system-context value as a primitive to useScheduledPromptDispatcher, and the hook merges it into sendMessage options at the send site. I also added a dispatcher test that verifies scheduled sends still include additional system context.

Validation:

  • bun test src/browser/features/ScheduledPrompts/scheduledPrompts.test.ts src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.test.tsx src/browser/features/ScheduledPrompts/scheduledPromptAvailability.test.ts src/browser/utils/commands/sources.test.ts src/common/constants/storage.test.ts
  • node_modules/.bin/tsgo --noEmit
  • git diff --check
  • PATH="/tmp/mux-bun-tools/node_modules/.bin:$PATH" make static-check

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1b29bb935

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.ts Outdated
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from d1b29bb to b10ebbe Compare June 5, 2026 09:39
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the normalized-prompts memoization feedback. useScheduledPromptDispatcher now computes normalized prompts inside the effect from storedPrompts, so the scheduled prompt path no longer introduces manual useMemo solely for object identity.

Validation:

  • bun test src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.test.tsx src/browser/features/ScheduledPrompts/scheduledPrompts.test.ts src/browser/features/ScheduledPrompts/scheduledPromptAvailability.test.ts src/browser/utils/commands/sources.test.ts src/common/constants/storage.test.ts
  • node_modules/.bin/tsgo --noEmit
  • git diff --check
  • PATH="/tmp/mux-bun-tools/node_modules/.bin:$PATH" make static-check

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b10ebbefe2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ScheduledPrompts/ScheduledPromptsTab.tsx Outdated
Adds a right sidebar Schedule tab for workspace-scoped scheduled prompts, including local lifecycle state, run-now/delete controls, and an active-workspace dispatcher that submits due prompts with the current send options.\n\nLinks coder#3417.\n\n---\n\n_Generated with `mux` • Model: `GPT-5` • Thinking: `unknown` • Cost: ``_\n\n<!-- mux-attribution: model=GPT-5 thinking=unknown costs=unknown -->
@LeonidasZhak LeonidasZhak force-pushed the codex/scheduled-prompt-queue branch from b10ebbe to 7f6b1d8 Compare June 5, 2026 09:45
@LeonidasZhak
Copy link
Copy Markdown
Author

@codex review

Addressed the remaining Schedule tab memoization feedback. ScheduledPromptsTab now computes normalized prompts directly during render, and rg -n "useMemo" src/browser/features/ScheduledPrompts src/browser/App.tsx returns no matches.

Validation:

  • bun test src/browser/features/ScheduledPrompts/useScheduledPromptDispatcher.test.tsx src/browser/features/ScheduledPrompts/scheduledPrompts.test.ts src/browser/features/ScheduledPrompts/scheduledPromptAvailability.test.ts src/browser/utils/commands/sources.test.ts src/common/constants/storage.test.ts
  • node_modules/.bin/tsgo --noEmit
  • git diff --check
  • PATH="/tmp/mux-bun-tools/node_modules/.bin:$PATH" make static-check

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f6b1d8eb3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +116 to +119
inFlightIdsRef.current.add(prompt.id);
setStoredPrompts((current) =>
markScheduledPromptSending(normalizeScheduledPrompts(current), prompt.id)
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard scheduled dispatch with a shared lock

When the same workspace is open in more than one renderer window/tab, this check-and-set is only protected by inFlightIdsRef, which is local to one component instance. Both dispatchers can read the prompt as still scheduled before either observes the other's localStorage update, then both mark it sending and call sendMessage, so one scheduled prompt can be sent twice. Use a storage/backend-level claim that is atomic across renderers before sending.

Useful? React with 👍 / 👎.

Comment on lines +141 to +144
if (!result?.success) {
const error = result?.error ? getErrorMessage(result.error) : "API not connected";
setStoredPrompts((current) =>
markScheduledPromptFailed(normalizeScheduledPrompts(current), prompt.id, error)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface structured send errors

For scheduled sends that fail with normal SendMessageError variants such as api_key_not_found, oauth_not_connected, model_not_available, or unknown with raw, result.error does not have a top-level message, so this stores the generic "Failed to send scheduled prompt" instead of the actionable provider/model/runtime error that normal sends show. In those scenarios the Schedule tab leaves the user without enough information to fix the failed prompt; format the structured send error before marking it failed.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant