Skip to content

fix: Enrich attachment-only task descriptions for title generation#1980

Merged
charlesvien merged 11 commits intomainfrom
05-02-enrich_attachment-only_task_descriptions_for_title_generation
May 4, 2026
Merged

fix: Enrich attachment-only task descriptions for title generation#1980
charlesvien merged 11 commits intomainfrom
05-02-enrich_attachment-only_task_descriptions_for_title_generation

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented May 2, 2026

Problem

Tasks created with only file attachments (pasted text or images) produce generic titles because the LLM has no meaningful text to work with.

Changes

  1. Add enrichDescriptionWithFileContent to read attached file contents and build a meaningful description for the title generator
  2. Fire onEmptyChange when attachments change so the editor correctly tracks emptiness
  3. Move title generation from the creation saga to useChatTitleGenerator hook, generating on the first prompt instead
  4. Pass a plain-text fallback as title on task creation so titles are never blank
  5. Cap generated titles to 255 chars and skip the manual-set check on first generation
  6. Add comprehensive tests for enrichDescriptionWithFileContent

How did you test this?

Manually

@charlesvien charlesvien changed the title Enrich attachment-only task descriptions for title generation fix: Enrich attachment-only task descriptions for title generation May 2, 2026
@charlesvien charlesvien marked this pull request as ready for review May 3, 2026 17:55
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 3, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/utils/generateTitle.test.ts:75-94
**Prefer parameterised tests for fallback cases**

These three tests all verify that the `[Attached: <filename>]` hint is returned, and differ only in the setup (binary extension, read throws, read returns null). Per the project's testing conventions, these should be collapsed into a single `it.each` table.

```ts
it.each([
  {
    label: "binary file",
    description: '1. <file path="/tmp/screenshot.png" />',
    setup: () => {},
    expected: "[Attached: screenshot.png]",
  },
  {
    label: "read throws",
    description: '1. <file path="/tmp/missing.ts" />',
    setup: () => mockReadAbsoluteFile.mockRejectedValue(new Error("ENOENT")),
    expected: "[Attached: missing.ts]",
  },
  {
    label: "read returns null",
    description: '1. <file path="/tmp/empty.ts" />',
    setup: () => mockReadAbsoluteFile.mockResolvedValue(null),
    expected: "[Attached: empty.ts]",
  },
])(
  "falls back to filename hint — $label",
  async ({ description, setup, expected }) => {
    setup();
    expect(await enrichDescriptionWithFileContent(description)).toBe(expected);
  },
);
```

Reviews (1): Last reviewed commit: "Add tests for enrichDescriptionWithFileC..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/utils/generateTitle.test.ts Outdated
Copy link
Copy Markdown
Member Author

charlesvien commented May 4, 2026

Merge activity

  • May 4, 6:05 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 4, 6:05 PM UTC: @charlesvien merged this pull request with Graphite.

@charlesvien charlesvien merged commit b4404cc into main May 4, 2026
16 checks passed
@charlesvien charlesvien deleted the 05-02-enrich_attachment-only_task_descriptions_for_title_generation branch May 4, 2026 18:05
posthog Bot pushed a commit that referenced this pull request May 4, 2026
Resolve conflicts in task-creation.ts and task-creation.test.ts.
PR #1980 (now in main) implemented this PR's intent — enriching
attachment-only descriptions for title generation — via
enrichDescriptionWithFileContent in generateTitle.ts and moved
auto-title generation to useChatTitleGenerator. The inline
expandClipboardTextTags / generateTaskTitle from this PR are
redundant and have been dropped, along with the now-unused
readClipboardText route.

Generated-By: PostHog Code
Task-Id: 2a27dd7f-c22d-4ca3-abe8-06ad4b66cfc9
posthog Bot pushed a commit that referenced this pull request May 4, 2026
Resolve conflicts in task-creation.ts and task-creation.test.ts.
PR #1980 (now in main) implemented this PR's intent — enriching
attachment-only descriptions for title generation — via
enrichDescriptionWithFileContent in generateTitle.ts and moved
auto-title generation to useChatTitleGenerator. The inline
expandClipboardTextTags / generateTaskTitle from this PR are
redundant and have been dropped, along with the now-unused
readClipboardText route.

Generated-By: PostHog Code
Task-Id: 2a27dd7f-c22d-4ca3-abe8-06ad4b66cfc9
posthog Bot pushed a commit that referenced this pull request May 4, 2026
Resolve conflicts in task-creation.ts and task-creation.test.ts.
PR #1980 (now in main) implemented this PR's intent — enriching
attachment-only descriptions for title generation — via
enrichDescriptionWithFileContent in generateTitle.ts and moved
auto-title generation to useChatTitleGenerator. The inline
expandClipboardTextTags / generateTaskTitle from this PR are
redundant and have been dropped, along with the now-unused
readClipboardText route.

Generated-By: PostHog Code
Task-Id: 2a27dd7f-c22d-4ca3-abe8-06ad4b66cfc9
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.

2 participants