Skip to content

fix(coderd): use pasted-text attachments as chat title input - #27067

Merged
ibetitsmike merged 7 commits into
mainfrom
mike/codagt-268-paste-title-input
Jul 8, 2026
Merged

fix(coderd): use pasted-text attachments as chat title input#27067
ibetitsmike merged 7 commits into
mainfrom
mike/codagt-268-paste-title-input

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Closes https://linear.app/codercom/issue/CODAGT-268

Problem

The chat UI collapses large pastes (>=10 lines or >=1000 chars) into a synthetic pasted-text-*.txt attachment. A chat created with only such an attachment had no title input anywhere: the create path derived titleSource only from text and file-reference parts (so the chat was named "New Chat"), async auto-titling extracted text the same way and silently skipped generation, and the manual propose/regenerate paths returned an empty title for the same reason. The regular prompt path already inlines these files for the model; only the title paths were blind.

Fix

Add a single title-input derivation in chatprompt and use it everywhere:

  • chatprompt.TitleText joins text and file-reference parts (unchanged formatting), and falls back to synthetic pasted-text attachment content (truncated to a 16 KiB title budget) when they yield nothing.
  • chatprompt.SyntheticPasteFileIDs identifies paste attachments; chatprompt.FallbackTitle consolidates the previously duplicated chatTitleFromMessage / fallbackChatTitle.
  • Chat creation captures paste blob references while validating file parts (the file row was already loaded there) and derives titleSource via TitleText. Only the create path derives titles; message send and edit reuse the same validation without copying any blob data.
  • GenerateChatTitleAsync and the manual propose/regenerate paths resolve paste content via titlePasteText, which only queries when a visible user message has no other title text, so chats with typed text never incur a file fetch.
  • Title-path paste fetches are bounded: a new GetChatFileDataPrefixesByIDs query returns only a substr prefix (chatprompt.TitlePasteBytePrefix, 64 KiB = 4 bytes x the 16 Ki-rune title budget) so full blobs (up to 10 MiB each) never leave the database for titling, and chatprompt.TitlePasteText applies the same bound to the create path which already holds the loaded row.

Deliberate side effect: because generation-time extraction now matches create-time titleSource exactly, file-reference-only chats also become eligible for AI titles. They were previously skipped by the same derivation mismatch.

Non-goals: no frontend changes (attachment chip UX stays as is), and non-synthetic user-uploaded .txt files still yield "New Chat".

Testing

  • Unit tests for TitleText, TitlePasteText, SyntheticPasteFileIDs, FallbackTitle, titleInput, titlePasteText, and paste-aware extractManualTitleTurns.
  • Real-database test for GetChatFileDataPrefixesByIDs (prefix shorter and longer than stored data) plus dbauthz coverage for the new query.
  • Integration tests: paste-only create gets a fallback title from the paste content, async title generation fires with the paste content as input, and RegenerateChatTitle works on a paste-only chat.

This PR was written by Mux on Mike's behalf.

@linear-code

linear-code Bot commented Jul 7, 2026

Copy link
Copy Markdown

CODAGT-268

@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: 7d1ee8cc4b

ℹ️ 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 Outdated
@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: da178eb6b5

ℹ️ 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 marked this pull request as ready for review July 7, 2026 20:16
A chat created with only a pasted-text attachment (the chat UI
collapses large pastes into synthetic .txt files) had no title input:
the create path, async auto-titling, and manual title generation all
derived text only from text and file-reference parts, leaving such
chats permanently named "New Chat" with generation silently skipped.

Add chatprompt.TitleText as the single title-input derivation, with
synthetic paste content as a fallback when text parts yield nothing,
plus chatprompt.SyntheticPasteFileIDs and chatprompt.FallbackTitle to
consolidate the duplicated fallback-title logic. Wire it through chat
creation, GenerateChatTitleAsync, and the manual propose/regenerate
paths, which resolve paste file content only when a user message has
no other title text.
…t parsing

Mixed messages with text parts and synthetic pasted-text attachments
copied every paste blob to a string that TitleText then ignored.
Retain blob references during part validation and materialize strings
only when text and file-reference parts yield no title input.
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-268-paste-title-input branch from da178eb to ae3d9f3 Compare July 7, 2026 20:20

@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: da178eb6b5

ℹ️ 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/chatprompt/title.go
@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: ae3d9f39ce

ℹ️ 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 Outdated
@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: a93b02ed91

ℹ️ 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/quickgen.go Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: e1e289501b

ℹ️ 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 merged commit 2ad5af5 into main Jul 8, 2026
28 of 29 checks passed
@ibetitsmike
ibetitsmike deleted the mike/codagt-268-paste-title-input branch July 8, 2026 19:37
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 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