mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
fix(mobile): retire launch drafts on literal marker turns
(cherry picked from commit 794e07c8dc)
This commit is contained in:
@@ -123,6 +123,40 @@ describe('useMobileNativeChatDrafts launch draft', () => {
|
||||
expect(state?.composerText).toBe('')
|
||||
})
|
||||
|
||||
it('declines a launch draft when the only user turn is a literal image marker', async () => {
|
||||
await mount('a')
|
||||
await act(async () =>
|
||||
renderer?.update(
|
||||
createElement(Harness, {
|
||||
tabId: 'a',
|
||||
messages: [userTextMessage('m1', '[Image #1]')],
|
||||
launchDraft: 'issue link'
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(state?.composerText).toBe('')
|
||||
})
|
||||
|
||||
it('retires an adopted launch draft when a literal marker turn lands', async () => {
|
||||
await mount('a')
|
||||
await act(async () =>
|
||||
renderer?.update(createElement(Harness, { tabId: 'a', launchDraft: 'issue link' }))
|
||||
)
|
||||
expect(state?.composerText).toBe('issue link')
|
||||
|
||||
await act(async () =>
|
||||
renderer?.update(
|
||||
createElement(Harness, {
|
||||
tabId: 'a',
|
||||
messages: [userTextMessage('m1', '[Image #1]')],
|
||||
launchDraft: 'issue link'
|
||||
})
|
||||
)
|
||||
)
|
||||
expect(state?.composerText).toBe('')
|
||||
})
|
||||
|
||||
it('clears an untouched prefill once a user turn lands, keeping user edits', async () => {
|
||||
await mount('a')
|
||||
await act(async () =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useRef, type Dispatch, type SetStateAction } from 'react'
|
||||
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
|
||||
import { normalizedUserText } from './mobile-native-chat-draft-reconcile'
|
||||
import { nativeChatUserMessageMatchText } from './mobile-native-chat-image-transcript-markers'
|
||||
|
||||
export type MobileNativeChatLaunchDraftSeed = {
|
||||
text: string
|
||||
@@ -63,7 +63,7 @@ export function useMobileNativeChatLaunchDraftSeed(args: {
|
||||
}
|
||||
// A user turn already in the transcript means the TUI prefill was submitted
|
||||
// or deliberately cleared; decline instead of resurrecting it.
|
||||
if (messages.some((message) => normalizedUserText(message) !== null)) {
|
||||
if (messages.some((message) => nativeChatUserMessageMatchText(message) !== null)) {
|
||||
seededLaunchDraftByKeyRef.current.set(draftKey, null)
|
||||
return
|
||||
}
|
||||
@@ -98,7 +98,7 @@ export function useMobileNativeChatLaunchDraftSeed(args: {
|
||||
if (!seeded) {
|
||||
return
|
||||
}
|
||||
const hasUserTurn = messages.some((message) => normalizedUserText(message) !== null)
|
||||
const hasUserTurn = messages.some((message) => nativeChatUserMessageMatchText(message) !== null)
|
||||
if (!hasUserTurn && launchDraft?.trim()) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user