Skip to content

The agent that grows with you

fix(desktop): label large pastes and fill file-only bubbles with their chips

Brooklyn Nicholsone98be8a32805
diff --git a/apps/desktop/src/app/chat/composer/large-paste.ts b/apps/desktop/src/app/chat/composer/large-paste.ts
index e9b01ebf14f..b4bf3e058da 100644
--- a/apps/desktop/src/app/chat/composer/large-paste.ts
+++ b/apps/desktop/src/app/chat/composer/large-paste.ts
@@ -26,6 +26,15 @@ export function shouldConvertPasteToAttachment(
return typeof text === 'string' && threshold > 0 && text.length > threshold
}
+// `electron/composer-paste.ts` names every saved paste `pasted_content_<stamp>_<hex>.txt`;
+// staging into the session may append `-N`. Anything else is a real file.
+const PASTED_CONTENT_FILE_RE = /(?:^|[\\/])pasted_content_[\w-]+\.txt$/
+
+/** True for a large-paste file, whose chip reads "Pasted content" instead of its path. */
+export function isPastedContentPath(path: string): boolean {
+ return PASTED_CONTENT_FILE_RE.test(path)
+}
+
/** Human-readable size of a paste's UTF-8 bytes, for the attachment chip. */
export function pasteSizeLabel(text: string): string {
const bytes = new TextEncoder().encode(text).length
diff --git a/apps/desktop/src/components/assistant-ui/directive-text.tsx b/apps/desktop/src/components/assistant-ui/directive-text.tsx
index c0b7554ee5d..87ce68841bb 100644
--- a/apps/desktop/src/components/assistant-ui/directive-text.tsx
+++ b/apps/desktop/src/components/assistant-ui/directive-text.tsx
@@ -5,8 +5,9 @@ import type { TextMessagePartComponent, TextMessagePartProps } from '@assistant-
import type { FC } from 'react'
import { Fragment, useEffect, useMemo, useState } from 'react'
+import { isPastedContentPath } from '@/app/chat/composer/large-paste'
import { ZoomableImage } from '@/components/chat/zoomable-image'
-import type { I18nContextValue } from '@/i18n'
+import { type I18nContextValue, useI18n } from '@/i18n'
import { extractEmbeddedImages } from '@/lib/embedded-images'
import { ExternalLink, openLink } from '@/lib/external-link'
import { triggerHaptic } from '@/lib/haptics'
@@ -598,6 +599,7 @@ const DirectiveChip: FC<{
id: string
onClick?: () => void
}> = ({ type, label, id, onClick }) => {
+ const { t } = useI18n()
// An `onClick` override is a bespoke activation, not the kind's link action —
// an override must not turn its carrier into a link.
const action = onClick ? undefined : DIRECTIVE_ACTIONS[type]
@@ -607,7 +609,7 @@ const DirectiveChip: FC<{
const body = (
<>
<DirectiveIcon type={type} />
- {label}
+ {type === 'file' && isPastedContentPath(id) ? t.desktop.pastedContent : label}
</>
)
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message-text.test.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message-text.test.tsx
index e8c76f2d904..309afcc7656 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-message-text.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-message-text.test.tsx
@@ -30,6 +30,14 @@ describe('a sent reference renders as the chip the composer showed', () => {
expect(document.body.textContent).not.toContain('@file:')
})
+ it('labels a large-paste file as pasted content, keeping its path on hover', () => {
+ const path = '/home/u/.hermes/attachments/pasted_content_2026-09-27_21-33-42-827_55e028-2.txt'
+
+ render(<UserMessageText text={`@file:${path}`} />)
+
+ expect(screen.getByTitle(path).textContent).toBe('Pasted content')
+ })
+
it('chips every kind that travels in message text', () => {
// The guard against WIRE_REFERENCE_KINDS and the pattern's own alternation
// drifting apart: add a kind to one and this fails until both agree.
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message.tsx
index a919f3994e4..710b4a39456 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-message.tsx
@@ -2,6 +2,7 @@ import { ActionBarPrimitive, BranchPickerPrimitive, MessagePrimitive, useAuiStat
import { type FC, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
import { DirectiveContent } from '@/components/assistant-ui/directive-text'
+import { isAttachmentRef } from '@/components/assistant-ui/reference-kinds'
import {
messageAttachmentRefs,
messageContentText,
@@ -376,6 +377,7 @@ export const UserMessage: FC<{
}
const hasBody = messageText.trim().length > 0
+ const chipOnlyTurn = !hasBody && attachmentRefs.length > 0 && attachmentRefs.every(isAttachmentRef)
const isLatestUser = messageId === latestUserId
const showStop = !readOnly && isLatestUser && threadRunning && Boolean(onCancel)
// Restore (re-run this exact prompt) is available everywhere the Stop button
@@ -389,7 +391,7 @@ export const UserMessage: FC<{
'border-(--ui-stroke-tertiary) hover:border-(--ui-stroke-secondary)'
)
- const bubbleContent = hasBody && (
+ const bubbleContent = hasBody ? (
// Render the user's text through a minimal markdown pipeline:
// backtick `code` and ``` fenced ``` blocks, with directive chips
// (`@file:` etc.) still resolved inside the plain-text spans.
@@ -404,6 +406,15 @@ export const UserMessage: FC<{
<UserMessageText className="wrap-anywhere" text={messageText} />
</div>
</div>
+ ) : (
+ // A file-only turn (a bare large paste, a dropped file) has no prose, so
+ // its chips ARE the prompt: they fill the bubble rather than leaving it
+ // empty above a detached row. Images keep their thumbnail row below.
+ chipOnlyTurn && (
+ <div className="flex min-h-[1.25rem] flex-wrap gap-1">
+ <DirectiveContent text={attachmentRefs.join(' ')} />
+ </div>
+ )
)
return (
@@ -415,7 +426,7 @@ export const UserMessage: FC<{
// it. No negative margin: -mt-* pulls the row up into the sticky box,
// where the sticky-prompt clip hides its top even at rest. Image refs
// render as thumbnails, file refs as chips; no border.
- attachmentRefs.length > 0 ? (
+ attachmentRefs.length > 0 && !chipOnlyTurn ? (
<div className="mb-2 flex flex-wrap gap-1">
<DirectiveContent text={attachmentRefs.join(' ')} />
</div>