Skip to content

feat: allow creating chats without an initial message - #27111

Merged
ibetitsmike merged 3 commits into
mainfrom
mike/chat-workspace-upload/empty-create
Sep 27, 2026
Merged

ibetitsmike merged 3 commits into
mainfrom
mike/chat-workspace-upload/empty-create

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 8, 2026 •

Copy link
Copy Markdown
Collaborator

Written by Mux on behalf of Mike.

What

POST /api/v2/chats now accepts an empty content array. The chat is created idle (waiting) with system messages only: no user message is inserted, no ownership hint is published, and no chat worker picks it up. Generation starts when the first message is POSTed to /chats/{chat}/messages.

Why

The new-chat page needs to upload files into the chat's workspace before the first turn, and POST /chats/{chat}/workspace-files requires a chat ID. There was previously no way to sequence "create chat, upload files, send first message": creation required non-empty content and started generation immediately. This PR adds the enabling primitive; the UI lands in the next PR of the stack.

How

  • chatstate.CreateChat takes an explicit InitialStatus (waiting or running, validated). The existing IsRunnable() gate keeps ownership hints suppressed for waiting chats.
  • chatd.CreateChat derives the status from InitialUserContent: empty content means waiting with system messages only, and APIKeyID is only required when a user message is inserted.
  • createChatInputFromRequest returns empty blocks for empty content instead of rejecting; the /messages path still rejects empty sends.
  • Chats created this way carry the New Chat placeholder title. Title generation now treats that placeholder as replaceable. When the first message lands on such a chat, chatd.SendMessage detects the first user turn inside its transaction (under the chat row lock), writes the fallback title in the same transaction, and reports FirstUserTurn; postChatMessages then fires GenerateChatTitleForMessagesAsync to upgrade it. A failed title call therefore still leaves a meaningful title.
  • ARCHITECTURE.md carries TODO (#27111) items in the transition list and the POST /api/v2/chats section for the new N -> Create -> W transition (the doc text and the diagram edge are left for the author per the chatd guardrail).

Follow-ups

  • Automatic title generation (both the create path and the first-message path added here) writes the generated title unconditionally, so a user rename that lands while the title model call is in flight is overwritten; a compare-and-set title update would close that pre-existing window.
  • chats.last_reasoning_effort is derived from inserted messages, so an idle chat created with reasoning_effort does not persist it until its first message; the first message applies the owner's personal reasoning-effort override (when it targets the same model) if the request omits an effort, matching POST /chats with content.

Testing

  • chatstate: N -> W lands in StateW with no ownership hint; invalid initial statuses are rejected.
  • chatd: empty create produces a waiting chat with system messages only.
  • HTTP: empty create + first message (W -> R0, inserts directly, not queued), immediate archive of an idle chat, workspace file upload against an empty-created chat, and title generation on the first message.

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 7668882d2b

ℹ️ 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 coderd/exp_chats.go Resolved
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from 7668882 to d3555d9 Compare July 8, 2026 22:26
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: d3555d9023

ℹ️ 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 coderd/x/chatd/chatstate/transitions.go Resolved
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from d3555d9 to c40bd8b Compare July 8, 2026 22:38
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: c40bd8b540

ℹ️ 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".

@github-actions github-actions Bot added the stale This issue is like stale bread. label Jul 26, 2026
@github-actions github-actions Bot closed this Jul 30, 2026
@ibetitsmike ibetitsmike reopened this Sep 21, 2026
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from c40bd8b to f122e73 Compare September 21, 2026 20:12
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T23:31:27.935494Z f35a4f3 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: f122e7371c

ℹ️ 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 coderd/x/chatd/ARCHITECTURE.md Resolved
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from f122e73 to ac548d3 Compare September 21, 2026 21:03
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: ac548d37e3

ℹ️ 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 coderd/exp_chats.go Resolved
Comment thread coderd/exp_chats.go Resolved
Comment thread coderd/x/chatd/chatd.go Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 2213a9efa5

ℹ️ 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".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from 2213a9e to f35a4f3 Compare September 21, 2026 23:24
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f35a4f3127

ℹ️ 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".

@github-actions github-actions Bot removed the stale This issue is like stale bread. label Sep 22, 2026
Comment thread coderd/exp_chats.go Resolved
Comment thread coderd/exp_chats.go Resolved

@jscottmiller jscottmiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. See the summary comment on #27078 and the non-blocking inline follow-ups across the stack.

Approval posted by Coder Agents on Scott's behalf.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from f35a4f3 to 42ebc3a Compare September 23, 2026 19:01
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from 42ebc3a to cb10a9d Compare September 23, 2026 19:46

@jscottmiller jscottmiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-approved after the fix commits. Verified the addressed threads against the code (agent atomic publish, workspace status, normalized references, logging/metric, first-message fallback title, reasoning-effort override, Vitest coverage, archive-409 navigation) and ran the affected Go and Vitest suites; the remaining notes are acceptable as is. The three open follow-up threads are resolved as agreed follow-ups.

Approval posted by Coder Agents on Scott's behalf.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from cb10a9d to 77d4887 Compare September 24, 2026 00:16
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from 77d4887 to 5bdbd68 Compare September 26, 2026 20:09
@coderagents

coderagents Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/agents/tasks-to-chats-migration.md (open) - §2 "Create a chat and confirm the response": note that content is optional. An empty or omitted content creates the chat in waiting status with no initial user message, and generation starts only when the first message is POSTed to /api/v2/chats/{chat}/messages. The "new chats begin processing immediately" statement is still accurate for non-empty content, but the new idle behavior should be mentioned.
  • docs/ai-coder/agents/tasks-to-chats-migration.md (open) - A short section on the idle chat creation pattern: create the chat with an empty content, upload files via POST /api/v2/chats/{chat}/workspace-files (which requires the chat ID before the first turn), then send the first message with the file references. This is the sequencing this PR enables.

Automated review via Coder Agents

Base automatically changed from mike/chat-workspace-upload/ui to main September 27, 2026 10:25
@ibetitsmike
ibetitsmike requested a review from a team as a code owner September 27, 2026 10:25
POST /api/v2/chats now accepts an empty content array. The
chat is created idle in waiting status with system messages only and
no worker picks it up; generation starts with the first message POSTed
to /chats/{chat}/messages. This lets clients sequence work that needs
the chat ID before the first turn, such as workspace file uploads from
the new-chat page.

Chats created this way carry the "New Chat" placeholder title, which
automatic title generation now treats as replaceable when the first
message lands.
chatd.SendMessage now probes for prior user-visible messages under the
chat row lock when the chat still carries the placeholder title, and on
a direct insert persists FallbackTitle in the same transaction. It
reports FirstUserTurn so postChatMessages schedules the async title
upgrade without its out-of-band probe, and publishes a title_change
event. postChats no longer schedules title generation for empty creates.
…y chats

postChatMessages now applies the personal root override effort when the
request omits reasoning_effort and the chat has no stored effort, which
is the state after creating a chat without content. The override only
applies when its model matches the model the send targets. The override
lookup is extracted from resolveCreateChatModelConfigID into
personalRootModelOverride so both paths share it.
@ibetitsmike
ibetitsmike force-pushed the mike/chat-workspace-upload/empty-create branch from 5bdbd68 to 2d7438f Compare September 27, 2026 10:25
@ibetitsmike
ibetitsmike merged commit 0eed546 into main Sep 27, 2026
33 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chat-workspace-upload/empty-create branch September 27, 2026 14:38
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants