The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): a collapsed paste resolves before the slash command runs
Brooklyn Nicholson00b2e03c8028
diff --git a/ui-tui/src/__tests__/queueSubmission.test.ts b/ui-tui/src/__tests__/queueSubmission.test.tsindex 149811fad64..62f43366b37 100644--- a/ui-tui/src/__tests__/queueSubmission.test.ts+++ b/ui-tui/src/__tests__/queueSubmission.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from 'vitest'import type { ComposerToken } from '../app/interfaces.js'-import { expandPasteTokens, queueItemFromSlash } from '../app/useSubmission.js'+import { expandPasteTokens, prepareSlashSubmission, queueItemFromSlash } from '../app/useSubmission.js'import { imageToken } from '../domain/attachments.js'describe('/queue collapsed paste submission', () => {@@ -29,3 +29,30 @@ describe('/queue collapsed paste submission', () => {expect(expandPasteTokens([paste, image])(`${paste.label} and ${image.label}`)).toBe(`one\ntwo and ${image.label}`)})})++describe('prepareSlashSubmission', () => {+ const label = '[[ Done — verified.. [412 lines] .. already on it. ]]'+ const text = 'Done — verified through the real resolver\nline two\nline three'+ const tokens: ComposerToken[] = [{ kind: 'paste', label, text }]++ // The reported bug: `/pr-triage <paste>` dispatched the LABEL, so the skill+ // received "[412 lines]" as its argument and the agent reported the paste as+ // truncated. The command has to carry the full text; only the transcript+ // stays collapsed.+ it('dispatches the full paste while the transcript keeps the collapsed label', () => {+ expect(prepareSlashSubmission(`/pr-triage ${label}`, tokens)).toEqual({+ command: `/pr-triage ${text}`,+ display: `/pr-triage ${label}`+ })+ })++ it('leaves image tokens as labels — the gateway already holds the file', () => {+ const image: ComposerToken = { kind: 'image', index: 1, label: imageToken(1), path: '/tmp/shot.png' }++ expect(prepareSlashSubmission(`/pr-triage ${image.label}`, [image]).command).toBe(`/pr-triage ${image.label}`)+ })++ it('is a no-op on a token-free command', () => {+ expect(prepareSlashSubmission('/model opus', [])).toEqual({ command: '/model opus', display: '/model opus' })+ })+})diff --git a/ui-tui/src/app/useSubmission.ts b/ui-tui/src/app/useSubmission.tsindex 0a7ef55badf..57ce9f60f9e 100644--- a/ui-tui/src/app/useSubmission.ts+++ b/ui-tui/src/app/useSubmission.ts@@ -40,6 +40,24 @@ export const prepareSubmission = (display: string, tokens: ComposerToken[]) => (text: expandTokens(tokens)(display)})+/**+ * Split a slash submission into the two things it has to be at once.+ *+ * A slash command's argument is ordinary user text, so a collapsed paste in it+ * must resolve BEFORE the command runs — otherwise `/pr-triage [[ … [412 lines]+ * … ]]` hands the skill the label and the agent faithfully reports that the+ * paste is truncated. The transcript still shows the compact form, because a+ * 412-line paste inlined into the scrollback is exactly what collapsing it was+ * for.+ *+ * Image tokens stay as labels: the gateway already holds those files in+ * `attached_images` and splices them in at submit.+ */+export const prepareSlashSubmission = (display: string, tokens: ComposerToken[]) => ({+ command: expandPasteTokens(tokens)(display),+ display+})+export const shouldInterpolateSubmission = (display: string) => hasInterpolation(display)export function useSubmission(opts: UseSubmissionOptions) {@@ -245,22 +263,23 @@ export function useSubmission(opts: UseSubmissionOptions) {const submissionTokens = [...composerRefs.tokensRef.current]const submission = prepareSubmission(full, submissionTokens)const toHistory = submission.text- const queuePayload = expandPasteTokens(submissionTokens)(full)if (looksLikeSlashCommand(full)) {- appendMessage({ kind: 'slash', role: 'system', text: full })+ const slash = prepareSlashSubmission(full, submissionTokens)++ appendMessage({ kind: 'slash', role: 'system', text: slash.display })composerActions.pushHistory(toHistory)const parsed = parseSlashCommand(full)const queued =- parsed.name === 'queue' || parsed.name === 'q' ? queueItemFromSlash(full, queuePayload) : undefined+ parsed.name === 'queue' || parsed.name === 'q' ? queueItemFromSlash(slash.display, slash.command) : undefinedif (queued) {composerActions.enqueue(queued.text, queued.display)sys(`queued: "${queued.display.slice(0, 50)}${queued.display.length > 50 ? '…' : ''}"`)} else {- slashRef.current(full)+ slashRef.current(slash.command)}composerActions.clearIn()