mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
feat(native-chat): bring back the New divider behind a setting
Restores the line above messages that arrived while you were away, the scroll to it on return and the screen-reader announcement, all removed in #38044. A new Chat > Behavior switch, "Mark new messages when returning to a chat" (on by default), turns it off; off tracks nothing.
This commit is contained in:
@@ -27,4 +27,4 @@ The chat root (`.native-chat-appearance`) redefines these steps as ratios of the
|
||||
- **Focus rings:** full-width transcript rows use the inset ring (`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`) so it isn't clipped by the scroll container; standalone controls use `focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`. Inside the chat `--ring` is `--chat-focus-ring`, which clears 3:1 on the canvas; don't lower its opacity.
|
||||
- **Theme overrides:** plugin themes can set `--chat-bold-foreground`, `--chat-muted-foreground`, `--chat-inline-code`, `--chat-inline-code-foreground`, `--chat-code-block`, `--chat-selection` and `--chat-selection-foreground`. They feed `text-chat-foreground-faint`, `bg-chat-inline-code-surface`, `bg-chat-code-surface` and the chat root's `::selection`, so use those rather than reading the theme tokens directly.
|
||||
- **Selection** inside the chat is the link hue mixed into the canvas (close to the system highlight), with selected text in the full foreground so every role stays 4.5:1. Don't add per-component `selection:` colors in transcript text.
|
||||
- **State colours:** warnings use `text-chat-warning`; diff lines use `text-chat-diff-added` / `text-chat-diff-removed`. They are mixed toward the foreground so they pass text contrast in light and dark. Don't use raw palette colours (`text-yellow-500`) or the git decoration tokens for text on a tinted row.
|
||||
- **State colours:** warnings use `text-chat-warning`; diff lines use `text-chat-diff-added` / `text-chat-diff-removed`; what the reader has not seen yet uses `text-chat-unread`. They are mixed toward the foreground so they pass text contrast in light and dark. Don't use raw palette colours (`text-yellow-500`) or the git decoration tokens for text on a tinted row.
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
--color-chat-foreground: var(--chat-foreground);
|
||||
--color-chat-foreground-strong: var(--chat-foreground-strong);
|
||||
--color-chat-foreground-faint: var(--chat-foreground-faint);
|
||||
--color-chat-unread: var(--chat-unread);
|
||||
--color-chat-user-surface: var(--chat-user-surface);
|
||||
--color-chat-user-border: var(--chat-user-border);
|
||||
--color-chat-code-foreground: var(--chat-code-foreground);
|
||||
@@ -741,6 +742,8 @@ body[data-modal-overlay-open]
|
||||
/* Mixed toward the foreground so each clears text contrast on the canvas in either scheme. */
|
||||
--chat-focus-ring: color-mix(in srgb, var(--chat-source-foreground) 50%, var(--chat-canvas));
|
||||
--chat-warning: color-mix(in srgb, var(--status-warning) 70%, var(--chat-source-foreground));
|
||||
/* What the reader has not seen yet: the transcript's "New" marker, in the note hue. */
|
||||
--chat-unread: color-mix(in srgb, var(--callout-note) 70%, var(--chat-source-foreground));
|
||||
--chat-diff-added: color-mix(in srgb, var(--diff-added) 70%, var(--chat-source-foreground));
|
||||
--chat-diff-removed: color-mix(in srgb, var(--diff-removed) 70%, var(--chat-source-foreground));
|
||||
--chat-link: color-mix(
|
||||
|
||||
@@ -4,13 +4,14 @@ import {
|
||||
NATIVE_CHAT_TRANSCRIPT_COLUMN_CLASS
|
||||
} from './appearance/native-chat-appearance-style'
|
||||
import { NativeChatJumpToLatest } from './viewport/scroll/NativeChatJumpToLatest'
|
||||
import { NativeChatNewRowsAnnouncement } from './viewport/new-rows/NativeChatNewRowsMarker'
|
||||
import { useNativeChatNewRowsMarker } from './viewport/new-rows/native-chat-new-rows-marker'
|
||||
import { withoutPullRequestEventRows } from '../../../../shared/native-chat/native-chat-pull-request-event'
|
||||
import { useNativeChatRowTypography } from './viewport/virtualization/use-native-chat-row-typography'
|
||||
import { useCallback, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { useAppStore } from '@/store'
|
||||
import {
|
||||
nativeChatScrollsToLatestOnSend,
|
||||
nativeChatShowsCiResultLines,
|
||||
nativeChatShowsTurnDiffSummary
|
||||
} from '../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
@@ -243,12 +244,18 @@ export function NativeChatMessageList({
|
||||
[allSlots, journalItems, stopping, journalSubmissions, latestTurn, hostWork]
|
||||
)
|
||||
const navigationRequest = useNativeChatNavigationRequest(slots, messages, subagentSections)
|
||||
const newRows = useNativeChatNewRowsMarker(
|
||||
slots,
|
||||
waitingSlots,
|
||||
isVisible && session.readCurrent === true
|
||||
)
|
||||
const transcriptWindow = useNativeChatTranscriptWindow({
|
||||
scrollRef,
|
||||
slots,
|
||||
isVisible,
|
||||
// Rail jumps, diff reveals and subagent reveals share one mutually exclusive pin.
|
||||
revealIndex: navigationRequest.revealIndex,
|
||||
newRowsMarkerIndex: newRows.index,
|
||||
typography
|
||||
})
|
||||
const transcriptScroll = useNativeChatTranscriptScroll({
|
||||
@@ -326,25 +333,15 @@ export function NativeChatMessageList({
|
||||
onLeaveEnd: readerLeavesEnd,
|
||||
onScrollGesture: transcriptScroll.forwardedGesture
|
||||
})
|
||||
// Off keeps a reader who scrolled up in place; one at the end still follows the reply.
|
||||
const revealSent = useCallback(
|
||||
(readerWasAtEnd = readerAtEnd()) => {
|
||||
if (!nativeChatScrollsToLatestOnSend(useAppStore.getState().settings) && !readerWasAtEnd) {
|
||||
return
|
||||
}
|
||||
beginNavigation()
|
||||
scrollToBottom('send')
|
||||
},
|
||||
[beginNavigation, readerAtEnd, scrollToBottom]
|
||||
)
|
||||
useNativeChatMessageListHandle(
|
||||
ref,
|
||||
revealSent,
|
||||
readerInput.revealFindMatch,
|
||||
allSlots,
|
||||
useNativeChatMessageListHandle(ref, {
|
||||
readerAtEnd,
|
||||
navigation.revealSubagent
|
||||
)
|
||||
beginNavigation,
|
||||
scrollToBottom,
|
||||
onSent: newRows.dismiss,
|
||||
revealFindMatch: readerInput.revealFindMatch,
|
||||
slots: allSlots,
|
||||
revealSubagent: navigation.revealSubagent
|
||||
})
|
||||
|
||||
const rowContext = useNativeChatTranscriptRowContext({
|
||||
agent: session.agent,
|
||||
@@ -397,6 +394,7 @@ export function NativeChatMessageList({
|
||||
loadedMessageIds={loadedMessageIds}
|
||||
context={rowContext}
|
||||
window={transcriptWindow}
|
||||
newRowsMarker={newRows.marker}
|
||||
forwardGesture={readerInput.forwardedGesture}
|
||||
/>
|
||||
{liveLine ? (
|
||||
@@ -417,6 +415,7 @@ export function NativeChatMessageList({
|
||||
pendingId={navigation.pendingRailId}
|
||||
/>
|
||||
<NativeChatJumpToLatest visible={showJump} onJump={jumpToLatest} />
|
||||
<NativeChatNewRowsAnnouncement marked={newRows.marker !== undefined} />
|
||||
</div>
|
||||
<NativeChatDockedTaskList key={session.sessionId} messages={messages} />
|
||||
</div>
|
||||
|
||||
+29
-13
@@ -1,5 +1,7 @@
|
||||
import { useCallback, useImperativeHandle, useMemo, useRef } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { hasAskAnswer } from '../../../../../../shared/native-chat/input/native-chat-ask-answer'
|
||||
import { nativeChatScrollsToLatestOnSend } from '../../../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
import { nativeChatSlotCopyText } from './native-chat-message-copy-text'
|
||||
import type { NativeChatTranscriptSlot } from '../../conversation/slots/native-chat-transcript-slots'
|
||||
import type { NativeChatInteractiveSend } from '../../session/terminal/send/use-native-chat-interactive-send'
|
||||
@@ -86,22 +88,36 @@ export function useNativeChatRevealLatest(): {
|
||||
return { messageListRef, revealLatest, captureRevealLatest }
|
||||
}
|
||||
|
||||
function ignoreFindMatch(): void {}
|
||||
|
||||
function alwaysAtEnd(): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
function ignoreSubagent(): void {}
|
||||
|
||||
/** Own sends follow the latest; with that setting off, only a reader who was at the end does. */
|
||||
export function useNativeChatMessageListHandle(
|
||||
ref: React.Ref<NativeChatMessageListHandle> | undefined,
|
||||
revealLatest: NativeChatMessageListHandle['revealLatest'],
|
||||
revealFindMatch: NativeChatMessageListHandle['revealFindMatch'] = ignoreFindMatch,
|
||||
slots: readonly NativeChatTranscriptSlot[] = [],
|
||||
readerAtEnd: NativeChatMessageListHandle['readerAtEnd'] = alwaysAtEnd,
|
||||
revealSubagent: NativeChatMessageListHandle['revealSubagent'] = ignoreSubagent
|
||||
{
|
||||
readerAtEnd,
|
||||
beginNavigation,
|
||||
scrollToBottom,
|
||||
onSent,
|
||||
revealFindMatch,
|
||||
slots,
|
||||
revealSubagent
|
||||
}: Pick<NativeChatMessageListHandle, 'readerAtEnd' | 'revealFindMatch' | 'revealSubagent'> & {
|
||||
beginNavigation: () => void
|
||||
scrollToBottom: (reason: 'send') => void
|
||||
/** The reader answered, whether or not the view moves. */
|
||||
onSent: () => void
|
||||
slots: readonly NativeChatTranscriptSlot[]
|
||||
}
|
||||
): void {
|
||||
const revealLatest = useCallback(
|
||||
(readerWasAtEnd = readerAtEnd()) => {
|
||||
onSent()
|
||||
if (!nativeChatScrollsToLatestOnSend(useAppStore.getState().settings) && !readerWasAtEnd) {
|
||||
return
|
||||
}
|
||||
beginNavigation()
|
||||
scrollToBottom('send')
|
||||
},
|
||||
[beginNavigation, onSent, readerAtEnd, scrollToBottom]
|
||||
)
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
|
||||
@@ -20,6 +20,8 @@ import { nativeChatRowOffersRewind } from '../../../../../../shared/native-chat/
|
||||
import { NativeChatForkContext } from '../actions/native-chat-fork-context'
|
||||
import { nativeChatSlotOffersFork } from '../actions/native-chat-side-chat-fork-point'
|
||||
import { isActionableStructuredAgentSessionPrompt } from '../../../../../../shared/agent-session/view/structured-agent-session-live-turn'
|
||||
import { NativeChatNewRowsMarker } from '../../viewport/new-rows/NativeChatNewRowsMarker'
|
||||
import type { NativeChatNewRowsMarkerState } from '../../viewport/new-rows/native-chat-new-rows-marker'
|
||||
|
||||
/** Memoize shared context so unchanged rows keep their props during transcript updates. */
|
||||
export type NativeChatTranscriptRowContext = {
|
||||
@@ -45,10 +47,13 @@ export type NativeChatTranscriptRowContext = {
|
||||
/** Wrap message, status and rollup for one virtualized measurement; internal spacing is the row’s, inter-row gaps the window’s. */
|
||||
export const NativeChatTranscriptRow = memo(function NativeChatTranscriptRow({
|
||||
slot,
|
||||
context
|
||||
context,
|
||||
newRowsMarker
|
||||
}: {
|
||||
slot: NativeChatTranscriptSlot
|
||||
context: NativeChatTranscriptRowContext
|
||||
/** The "New" marker, when it draws in this row. */
|
||||
newRowsMarker?: NativeChatNewRowsMarkerState
|
||||
}): React.JSX.Element {
|
||||
// Offered only on the conversation's own turn-opening prompts (`nativeChatRowOffersRewind`).
|
||||
const rewind = useContext(NativeChatRewindContext)
|
||||
@@ -84,6 +89,9 @@ export const NativeChatTranscriptRow = memo(function NativeChatTranscriptRow({
|
||||
const deliveryNotice = context.deliveryNotices?.get(message.id)
|
||||
const predecessors = context.taskListPredecessors.get(message.id)
|
||||
const expanded = turnKey ? context.expandedTurnIds.has(turnKey) : undefined
|
||||
const marker = newRowsMarker ? (
|
||||
<NativeChatNewRowsMarker marker={newRowsMarker} onReveal={context.onScrollMessageToTop} />
|
||||
) : null
|
||||
const statusRow = status ? (
|
||||
<NativeChatWorkingStatus
|
||||
startedAt={status.startedAt}
|
||||
@@ -105,6 +113,7 @@ export const NativeChatTranscriptRow = memo(function NativeChatTranscriptRow({
|
||||
sectionClassName
|
||||
)}
|
||||
>
|
||||
{newRowsMarker?.place === 'above-row' ? marker : null}
|
||||
{/* A turn with no user bubble carries its bar above its first row. */}
|
||||
{slot.statusAbove ? statusRow : null}
|
||||
{!slot.drawsMessage ? null : receipt ? (
|
||||
@@ -154,6 +163,7 @@ export const NativeChatTranscriptRow = memo(function NativeChatTranscriptRow({
|
||||
workRun={workRun}
|
||||
/>
|
||||
)}
|
||||
{newRowsMarker?.place === 'above-turn-bar' ? marker : null}
|
||||
{slot.statusAbove ? null : statusRow}
|
||||
{turnDiff ? <NativeChatTurnDiffRollup diff={turnDiff} /> : null}
|
||||
{openedPullRequests ? (
|
||||
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { act, cleanup, screen } from '@testing-library/react'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
import { createRef } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
import { getDefaultSettings } from '../../../../../../shared/constants'
|
||||
import { useAppStore } from '@/store'
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
import type { NativeChatMessageListHandle } from '../../messages/actions/use-native-chat-reveal-latest'
|
||||
import {
|
||||
deliverResizes,
|
||||
layout,
|
||||
marker,
|
||||
ROW_PITCH_PX,
|
||||
scrollTranscript,
|
||||
session,
|
||||
stubLayout,
|
||||
stubResizeObserver,
|
||||
TRANSCRIPT_LENGTH
|
||||
} from '../virtualization/native-chat-windowing-test-harness'
|
||||
|
||||
// Pacing is not this test's subject.
|
||||
vi.mock('../../markdown/use-native-chat-paced-text', async (importOriginal) =>
|
||||
(await import('../../markdown/native-chat-unpaced-text-fixture')).unpacedTextModule(
|
||||
importOriginal
|
||||
)
|
||||
)
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
function chat(
|
||||
length: number,
|
||||
isVisible: boolean,
|
||||
{
|
||||
ref,
|
||||
readCurrent = true
|
||||
}: { ref?: React.Ref<NativeChatMessageListHandle>; readCurrent?: boolean } = {}
|
||||
): React.JSX.Element {
|
||||
const messages: NativeChatMessage[] = Array.from({ length }, (_, index) => ({
|
||||
...marker(index),
|
||||
journalPosition: { sequence: index + 1, index: 0 }
|
||||
}))
|
||||
return (
|
||||
<NativeChatMessageList
|
||||
ref={ref}
|
||||
session={{ ...session(messages), readCurrent }}
|
||||
isVisible={isVisible}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
describe('the "New" marker in the transcript', () => {
|
||||
let paneShown = true
|
||||
let restore: (() => void)[] = []
|
||||
beforeEach(() => {
|
||||
paneShown = true
|
||||
vi.spyOn(document, 'hasFocus').mockReturnValue(true)
|
||||
restore = [
|
||||
stubLayout({ scrollGeometry: true, offsetChain: true, isVisible: () => paneShown }),
|
||||
stubResizeObserver()
|
||||
]
|
||||
})
|
||||
afterEach(() => {
|
||||
for (const undo of restore.toReversed()) {
|
||||
undo()
|
||||
}
|
||||
layout.measuredRowHeights = []
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
// The window mounts only rows near the view; the marker's row is far from the end it opens at.
|
||||
it('is drawn above the first row that came while the chat was hidden, however far back', () => {
|
||||
const { rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
rerender(chat(TRANSCRIPT_LENGTH, false))
|
||||
rerender(chat(TRANSCRIPT_LENGTH + 60, true))
|
||||
|
||||
const row = screen.getByRole('separator', { name: 'New' }).closest<HTMLElement>('[data-index]')
|
||||
expect(row?.dataset.index).toBe(String(TRANSCRIPT_LENGTH))
|
||||
})
|
||||
|
||||
it('tells a screen reader that new messages came, in a region that was already there', () => {
|
||||
const { container, rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
const region = container.querySelector('[data-native-chat-scroll] ~ [aria-live="polite"]')
|
||||
expect(region).toBeEmptyDOMElement()
|
||||
|
||||
rerender(chat(TRANSCRIPT_LENGTH, false))
|
||||
rerender(chat(TRANSCRIPT_LENGTH + 60, true))
|
||||
expect(region).toHaveTextContent('New messages arrived while you were away')
|
||||
})
|
||||
|
||||
it('is neither drawn nor announced when the reader turned it off', () => {
|
||||
const settings = useAppStore.getState().settings
|
||||
useAppStore.setState({
|
||||
settings: { ...getDefaultSettings('/tmp'), nativeChatMarkNewMessages: false }
|
||||
})
|
||||
try {
|
||||
const { container, rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
rerender(chat(TRANSCRIPT_LENGTH, false))
|
||||
rerender(chat(TRANSCRIPT_LENGTH + 60, true))
|
||||
|
||||
expect(screen.queryByRole('separator', { name: 'New' })).toBeNull()
|
||||
expect(
|
||||
container.querySelector('[data-native-chat-scroll] ~ [aria-live="polite"]')
|
||||
).toBeEmptyDOMElement()
|
||||
} finally {
|
||||
useAppStore.setState({ settings })
|
||||
}
|
||||
})
|
||||
|
||||
it('goes once the reader sends something', () => {
|
||||
const ref = createRef<NativeChatMessageListHandle>()
|
||||
const { rerender } = render(chat(TRANSCRIPT_LENGTH, true, { ref }))
|
||||
rerender(chat(TRANSCRIPT_LENGTH, false, { ref }))
|
||||
rerender(chat(TRANSCRIPT_LENGTH + 60, true, { ref }))
|
||||
expect(screen.getByRole('separator', { name: 'New' })).toBeInTheDocument()
|
||||
|
||||
act(() => ref.current?.revealLatest())
|
||||
|
||||
expect(screen.queryByRole('separator', { name: 'New' })).toBeNull()
|
||||
})
|
||||
|
||||
describe('when the reader comes back to new rows', () => {
|
||||
/** Catch up after restoring the hidden pane’s scroll position. */
|
||||
function returnToNewRows(rerender: (ui: React.JSX.Element) => void, count = 60): void {
|
||||
paneShown = false
|
||||
rerender(chat(TRANSCRIPT_LENGTH, false, { readCurrent: false }))
|
||||
paneShown = true
|
||||
rerender(chat(TRANSCRIPT_LENGTH, true, { readCurrent: false }))
|
||||
rerender(chat(TRANSCRIPT_LENGTH + count, true))
|
||||
}
|
||||
const scrollTop = (container: HTMLElement): number | undefined =>
|
||||
container.querySelector('[data-native-chat-scroll]')?.scrollTop
|
||||
|
||||
it('brings a reader who was at the end to where the new rows begin', () => {
|
||||
const { container, rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
returnToNewRows(rerender)
|
||||
|
||||
expect(scrollTop(container)).toBe(TRANSCRIPT_LENGTH * ROW_PITCH_PX)
|
||||
})
|
||||
|
||||
it('keeps the reader where the new rows begin while a reply is still being drawn', async () => {
|
||||
const { container, rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
returnToNewRows(rerender, 1)
|
||||
|
||||
const drawn: number[] = []
|
||||
drawn[TRANSCRIPT_LENGTH] = 2_000
|
||||
layout.measuredRowHeights = drawn
|
||||
act(() => void deliverResizes())
|
||||
await act(async () => {
|
||||
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
|
||||
})
|
||||
|
||||
expect(scrollTop(container)).toBe(TRANSCRIPT_LENGTH * ROW_PITCH_PX)
|
||||
})
|
||||
|
||||
it('leaves a reader who was parked further up where they were', () => {
|
||||
const { container, rerender } = render(chat(TRANSCRIPT_LENGTH, true))
|
||||
const readingAt = 2_000
|
||||
scrollTranscript(container, readingAt)
|
||||
returnToNewRows(rerender)
|
||||
|
||||
expect(screen.getByRole('separator', { name: 'New' })).toBeInTheDocument()
|
||||
expect(scrollTop(container)).toBe(readingAt)
|
||||
})
|
||||
})
|
||||
})
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NativeChatNewRowsMarker } from './NativeChatNewRowsMarker'
|
||||
import type { NativeChatNewRowsMarkerState as Marker } from './native-chat-new-rows-marker'
|
||||
import { overrideLayoutProperty } from '../virtualization/native-chat-windowing-test-harness'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
function marker(overrides: Partial<Marker> = {}): Marker {
|
||||
return {
|
||||
key: 'answer',
|
||||
place: 'above-row',
|
||||
arriving: true,
|
||||
onArrived: vi.fn(),
|
||||
onDismiss: vi.fn(),
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
const VIEWPORT_PX = 600
|
||||
const ROW_TOP_PX = 1_000
|
||||
|
||||
let restoreLayout: (() => void)[] = []
|
||||
|
||||
/** Place the view bottom aboveMarkerPx short of a marker positioned intoRowPx within its row. */
|
||||
function pane(
|
||||
value: Marker,
|
||||
{ intoRowPx = 0, aboveMarkerPx = 0 }: { intoRowPx?: number; aboveMarkerPx?: number } = {}
|
||||
) {
|
||||
const isRow = (element: HTMLElement): boolean => element.hasAttribute('data-index')
|
||||
const isMarker = (element: HTMLElement): boolean => element.getAttribute('role') === 'separator'
|
||||
const layout = (name: string, get: (this: HTMLElement) => unknown) =>
|
||||
overrideLayoutProperty(name, { get })
|
||||
restoreLayout = [
|
||||
layout('clientHeight', () => VIEWPORT_PX),
|
||||
layout('scrollTop', () => ROW_TOP_PX + intoRowPx - VIEWPORT_PX - aboveMarkerPx),
|
||||
layout('offsetTop', function () {
|
||||
return isRow(this) ? ROW_TOP_PX : isMarker(this) ? intoRowPx : 0
|
||||
}),
|
||||
layout('offsetParent', function () {
|
||||
return isRow(this) || isMarker(this) ? this.parentElement : null
|
||||
})
|
||||
]
|
||||
const onReveal = vi.fn()
|
||||
const view = render(
|
||||
<div data-native-chat-root="true">
|
||||
<div data-native-chat-typing-redirect-ignore="true">
|
||||
<input aria-label="Find in chat" />
|
||||
</div>
|
||||
<div data-native-chat-scroll>
|
||||
<div data-index="3">
|
||||
<NativeChatNewRowsMarker marker={value} onReveal={onReveal} />
|
||||
</div>
|
||||
</div>
|
||||
<textarea aria-label="composer" />
|
||||
</div>
|
||||
)
|
||||
return { ...view, onReveal }
|
||||
}
|
||||
|
||||
describe('NativeChatNewRowsMarker', () => {
|
||||
afterEach(() => {
|
||||
for (const restore of restoreLayout) {
|
||||
restore()
|
||||
}
|
||||
})
|
||||
|
||||
it('brings itself to the top when it sits too far down its row to show with it', () => {
|
||||
const { onReveal } = pane(marker({ place: 'above-turn-bar' }), { intoRowPx: 500 })
|
||||
expect(onReveal).toHaveBeenCalledWith(screen.getByRole('separator'))
|
||||
})
|
||||
|
||||
it('does not pull the reader back to it once it has arrived', () => {
|
||||
const { onReveal } = pane(marker({ arriving: false }))
|
||||
expect(onReveal).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('goes once the reader writes to this chat, not to another pane or its find field', () => {
|
||||
const value = marker()
|
||||
pane(value)
|
||||
const typeIn = (target: Element) =>
|
||||
fireEvent(target, new Event('beforeinput', { bubbles: true }))
|
||||
typeIn(document.body)
|
||||
typeIn(screen.getByLabelText('Find in chat'))
|
||||
expect(value.onDismiss).not.toHaveBeenCalled()
|
||||
|
||||
typeIn(screen.getByLabelText('composer'))
|
||||
expect(value.onDismiss).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,84 @@
|
||||
import { useEffect, useLayoutEffect, useRef } from 'react'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { NATIVE_CHAT_BOTTOM_THRESHOLD_PX } from '../scroll/native-chat-autoscroll'
|
||||
import type { NativeChatNewRowsMarkerState } from './native-chat-new-rows-marker'
|
||||
import { nativeChatScrollOffsetWithin } from '../virtualization/use-native-chat-viewport-align'
|
||||
|
||||
/** Fields in the pane that take text for something other than the conversation. */
|
||||
const NOT_THE_CONVERSATION = '[data-native-chat-typing-redirect-ignore="true"]'
|
||||
|
||||
export function NativeChatNewRowsMarker({
|
||||
marker: { arriving, onArrived, onDismiss },
|
||||
onReveal
|
||||
}: {
|
||||
marker: NativeChatNewRowsMarkerState
|
||||
/** Scrolls a transcript element to the top of the view, and stops following the end. */
|
||||
onReveal: (element: HTMLElement) => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const label = t('components.native-chat.newRowsMarker', 'New')
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!arriving) {
|
||||
return
|
||||
}
|
||||
onArrived()
|
||||
const marker = ref.current
|
||||
const row = marker?.closest<HTMLElement>('[data-index]')
|
||||
const scroller = row?.closest<HTMLElement>('[data-native-chat-scroll]')
|
||||
if (!marker || !row || !scroller) {
|
||||
return
|
||||
}
|
||||
const top = nativeChatScrollOffsetWithin(marker, scroller)
|
||||
// Preserve a reader parked above new rows; replies can still be short while paced rendering catches up.
|
||||
if (
|
||||
top === null ||
|
||||
top - (scroller.scrollTop + scroller.clientHeight) > NATIVE_CHAT_BOTTOM_THRESHOLD_PX
|
||||
) {
|
||||
return
|
||||
}
|
||||
// Reveal the prompt’s row unless it would leave the marker too low in the viewport.
|
||||
const intoRow = top - (nativeChatScrollOffsetWithin(row, scroller) ?? top)
|
||||
onReveal(intoRow < scroller.clientHeight / 2 ? row : marker)
|
||||
}, [arriving, onArrived, onReveal])
|
||||
|
||||
useEffect(() => {
|
||||
const pane = ref.current?.closest('[data-native-chat-root]')
|
||||
// Only conversation input dismisses the marker; Find and other unrelated fields do not.
|
||||
const onInput = (event: Event): void => {
|
||||
if (!(event.target instanceof Element && event.target.closest(NOT_THE_CONVERSATION))) {
|
||||
onDismiss()
|
||||
}
|
||||
}
|
||||
pane?.addEventListener('beforeinput', onInput)
|
||||
return () => pane?.removeEventListener('beforeinput', onInput)
|
||||
}, [onDismiss])
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
role="separator"
|
||||
aria-label={label}
|
||||
className="flex items-center gap-3 text-2xs font-semibold uppercase tracking-[0.05em] text-chat-unread transition-opacity duration-300 ease-out starting:opacity-0 motion-reduce:transition-none"
|
||||
>
|
||||
<span>{label}</span>
|
||||
<span aria-hidden className="h-px flex-1 bg-chat-unread/50" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Keep the live region mounted before inserting text so screen readers announce it. */
|
||||
export function NativeChatNewRowsAnnouncement({ marked }: { marked: boolean }): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
return (
|
||||
<div aria-live="polite" className="sr-only">
|
||||
{marked
|
||||
? t(
|
||||
'components.native-chat.newRowsAnnouncement',
|
||||
'New messages arrived while you were away'
|
||||
)
|
||||
: null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act, renderHook } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
import { buildNativeChatTranscriptSlots } from '../../conversation/slots/native-chat-transcript-slots'
|
||||
import {
|
||||
nativeChatNewRowsMarkerPlacement,
|
||||
useNativeChatNewRowsMarker
|
||||
} from './native-chat-new-rows-marker'
|
||||
|
||||
const at = (sequence: number) => ({ sequence, index: 0 })
|
||||
|
||||
/** A row the journal placed at `sequence`; null for one it has not (a terminal-backed chat's). */
|
||||
function row(
|
||||
id: string,
|
||||
sequence: number | null,
|
||||
role: NativeChatMessage['role'] = 'assistant',
|
||||
text = id
|
||||
): NativeChatMessage {
|
||||
return {
|
||||
id,
|
||||
role,
|
||||
blocks: [{ type: 'text', text }],
|
||||
timestamp: 1,
|
||||
source: 'transcript',
|
||||
...(sequence === null ? {} : { journalPosition: at(sequence) })
|
||||
}
|
||||
}
|
||||
|
||||
type Turn = { working?: boolean; worked?: number; expanded?: boolean }
|
||||
|
||||
function slotsOf(
|
||||
messages: NativeChatMessage[],
|
||||
{ working = false, worked, expanded = false }: Turn = {}
|
||||
) {
|
||||
const turnKey = working || worked !== undefined ? 'prompt' : undefined
|
||||
return buildNativeChatTranscriptSlots({
|
||||
messages,
|
||||
turnKeys: messages.map(() => turnKey),
|
||||
liveTurnKey: working ? turnKey : undefined,
|
||||
receipts: new Map(),
|
||||
turnStatuses: {
|
||||
active: null,
|
||||
completedByTurn:
|
||||
worked === undefined
|
||||
? {}
|
||||
: { prompt: { startedAt: null, thinking: false, workedSeconds: worked } }
|
||||
},
|
||||
turnDiffs: new Map(),
|
||||
expandedTurnKeys: new Set(expanded && turnKey ? [turnKey] : []),
|
||||
isWorking: working,
|
||||
lifecycleWorking: working
|
||||
})
|
||||
}
|
||||
|
||||
const SEEN = [row('prompt', 1, 'user'), row('reply', 2)]
|
||||
const LATER = [...SEEN, row('answer', 3), row('more', 4)]
|
||||
const ASKED = [row('prompt', 1, 'user')]
|
||||
const DONE = [...ASKED, row('step', 2), row('answer', 3)]
|
||||
|
||||
const missed = (key: string, after: number, through: number) => ({
|
||||
key,
|
||||
after: at(after),
|
||||
through: at(through)
|
||||
})
|
||||
|
||||
describe('where the "New" marker draws', () => {
|
||||
it('is above the first row that came while the reader was away', () => {
|
||||
expect(nativeChatNewRowsMarkerPlacement(slotsOf(LATER), missed('answer', 2, 4))).toEqual({
|
||||
key: 'answer',
|
||||
place: 'above-row'
|
||||
})
|
||||
})
|
||||
|
||||
it("is above the turn bar when only that bar parts the row from the reader's prompt", () => {
|
||||
const asked = [row('prompt', 1, 'user'), row('answer', 2)]
|
||||
expect(
|
||||
nativeChatNewRowsMarkerPlacement(slotsOf(asked, { worked: 17 }), missed('answer', 1, 2))
|
||||
).toEqual({ key: 'prompt', place: 'above-turn-bar' })
|
||||
})
|
||||
|
||||
it('stays under the rows of an opened turn the reader had already seen', () => {
|
||||
expect(
|
||||
nativeChatNewRowsMarkerPlacement(
|
||||
slotsOf(DONE, { worked: 17, expanded: true }),
|
||||
missed('answer', 2, 3)
|
||||
)
|
||||
).toEqual({ key: 'answer', place: 'above-row' })
|
||||
})
|
||||
|
||||
it('is above the bar of a turn the agent opened, whether the turn is open or shut', () => {
|
||||
const turn = DONE.slice(1)
|
||||
for (const expanded of [false, true]) {
|
||||
expect(
|
||||
nativeChatNewRowsMarkerPlacement(
|
||||
slotsOf(turn, { worked: 17, expanded }),
|
||||
missed('answer', 1, 3)
|
||||
)
|
||||
).toEqual({ key: 'step', place: 'above-row' })
|
||||
}
|
||||
})
|
||||
|
||||
it('is absent when nothing came, or the row that did is gone', () => {
|
||||
expect(nativeChatNewRowsMarkerPlacement(slotsOf(LATER), null)).toBeUndefined()
|
||||
expect(nativeChatNewRowsMarkerPlacement(slotsOf(SEEN), missed('answer', 2, 4))).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('useNativeChatNewRowsMarker', () => {
|
||||
let hasFocus: ReturnType<typeof vi.spyOn>
|
||||
beforeEach(() => {
|
||||
hasFocus = vi.spyOn(document, 'hasFocus').mockReturnValue(true)
|
||||
})
|
||||
afterEach(() => hasFocus.mockRestore())
|
||||
|
||||
type ChatProps = {
|
||||
messages: NativeChatMessage[]
|
||||
showing: boolean
|
||||
waiting?: NativeChatMessage[]
|
||||
turn?: Turn
|
||||
}
|
||||
|
||||
function chat(messages: NativeChatMessage[], turn?: Turn) {
|
||||
const initialProps: ChatProps = { messages, showing: true }
|
||||
return renderHook(
|
||||
(props: ChatProps) =>
|
||||
useNativeChatNewRowsMarker(
|
||||
slotsOf(props.messages, props.turn ?? turn),
|
||||
slotsOf(props.waiting ?? []),
|
||||
props.showing
|
||||
),
|
||||
{ initialProps }
|
||||
)
|
||||
}
|
||||
|
||||
function leaveAndReturn(left: NativeChatMessage[], onReturn: NativeChatMessage[], turn?: Turn) {
|
||||
const view = chat(left, turn)
|
||||
view.rerender({ messages: left, showing: false })
|
||||
view.rerender({ messages: onReturn, showing: true })
|
||||
return view
|
||||
}
|
||||
|
||||
it('marks nothing that arrives while the reader is looking', () => {
|
||||
const view = chat(SEEN)
|
||||
view.rerender({ messages: LATER, showing: true })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
})
|
||||
|
||||
it('marks what a hidden chat is handed when the reader comes back to it', () => {
|
||||
expect(leaveAndReturn(SEEN, LATER).result.current.marker?.key).toBe('answer')
|
||||
})
|
||||
|
||||
it("is never above the reader's own prompt", () => {
|
||||
const sent = [...SEEN, row('next-prompt', 3, 'user'), row('answer', 4)]
|
||||
expect(leaveAndReturn(SEEN, sent).result.current.marker?.key).toBe('answer')
|
||||
})
|
||||
|
||||
it('marks nothing the reader watches arrive after missing nothing', () => {
|
||||
const view = leaveAndReturn(SEEN, SEEN)
|
||||
view.rerender({ messages: LATER, showing: true })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
})
|
||||
|
||||
it('marks what came while the window was in the background', () => {
|
||||
const view = chat(SEEN)
|
||||
hasFocus.mockReturnValue(false)
|
||||
act(() => {
|
||||
window.dispatchEvent(new Event('blur'))
|
||||
})
|
||||
view.rerender({ messages: LATER, showing: true })
|
||||
hasFocus.mockReturnValue(true)
|
||||
act(() => {
|
||||
window.dispatchEvent(new Event('focus'))
|
||||
})
|
||||
expect(view.result.current.marker?.key).toBe('answer')
|
||||
})
|
||||
|
||||
it('goes once the reader answers', () => {
|
||||
const view = leaveAndReturn(SEEN, LATER)
|
||||
act(() => view.result.current.dismiss())
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
})
|
||||
|
||||
it('does not appear when the reader answered before the chat had caught up', () => {
|
||||
const view = chat(SEEN)
|
||||
view.rerender({ messages: SEEN, showing: false })
|
||||
act(() => view.result.current.dismiss())
|
||||
view.rerender({ messages: LATER, showing: true })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
})
|
||||
|
||||
it('marks the first reply to a chat that held no row the journal had placed', () => {
|
||||
const sending = [row('prompt', null, 'user')]
|
||||
const view = leaveAndReturn(sending, [row('prompt', 1, 'user'), row('answer', 2)])
|
||||
expect(view.result.current.marker?.key).toBe('answer')
|
||||
})
|
||||
|
||||
it('is arriving on the return, until the row that draws it has brought it into view', () => {
|
||||
const view = leaveAndReturn(SEEN, LATER)
|
||||
expect(view.result.current.marker?.arriving).toBe(true)
|
||||
act(() => view.result.current.marker?.onArrived())
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'answer', arriving: false })
|
||||
})
|
||||
|
||||
it('stays where it is through another look away, until the reader answers', () => {
|
||||
const view = leaveAndReturn(SEEN, LATER)
|
||||
act(() => view.result.current.marker?.onArrived())
|
||||
|
||||
view.rerender({ messages: LATER, showing: false })
|
||||
expect(view.result.current.marker?.key).toBe('answer')
|
||||
|
||||
view.rerender({ messages: [...LATER, row('newer', 5)], showing: true })
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'answer', arriving: false })
|
||||
})
|
||||
|
||||
it('marks the next time away afresh once the reader has answered', () => {
|
||||
const view = leaveAndReturn(SEEN, LATER)
|
||||
act(() => view.result.current.dismiss())
|
||||
|
||||
view.rerender({ messages: LATER, showing: false })
|
||||
view.rerender({ messages: [...LATER, row('newer', 5)], showing: true })
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'newer', arriving: true })
|
||||
})
|
||||
|
||||
it('marks the next time away afresh when the row it marked has gone', () => {
|
||||
const view = leaveAndReturn(SEEN, LATER)
|
||||
view.rerender({ messages: SEEN, showing: true })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
|
||||
view.rerender({ messages: SEEN, showing: false })
|
||||
view.rerender({ messages: [...SEEN, row('newer', 5)], showing: true })
|
||||
expect(view.result.current.marker?.key).toBe('newer')
|
||||
})
|
||||
|
||||
it('marks a message that was held behind the running turn once it joins the transcript', () => {
|
||||
const view = chat(SEEN)
|
||||
view.rerender({ messages: SEEN, showing: false })
|
||||
view.rerender({ messages: SEEN, showing: true, waiting: [row('held', 3)] })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
|
||||
// The turn writes on in front of the reader, then the handover places the message after that.
|
||||
view.rerender({ messages: [...SEEN, row('live', 4)], showing: true, waiting: [row('held', 3)] })
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
view.rerender({ messages: [...SEEN, row('live', 4), row('held', 5)], showing: true })
|
||||
expect(view.result.current.marker?.key).toBe('held')
|
||||
})
|
||||
|
||||
it('stays above a queued message while the turn writes on ahead of it', () => {
|
||||
const queued: NativeChatMessage = { ...row('held', 3), queued: true }
|
||||
const view = leaveAndReturn(SEEN, [...SEEN, queued])
|
||||
expect(view.result.current.marker?.key).toBe('held')
|
||||
|
||||
view.rerender({ messages: [...SEEN, row('live', 4), queued], showing: true })
|
||||
expect(view.result.current.marker?.key).toBe('held')
|
||||
})
|
||||
|
||||
it('keeps its place when the reader opens the turn that came while they were away', () => {
|
||||
const view = leaveAndReturn(ASKED, DONE, { worked: 17 })
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'prompt', place: 'above-turn-bar' })
|
||||
|
||||
view.rerender({ messages: DONE, showing: true, turn: { worked: 17, expanded: true } })
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'prompt', place: 'above-turn-bar' })
|
||||
})
|
||||
|
||||
it('stays through another look away after the reader shuts the turn they opened', () => {
|
||||
const shut = { worked: 17 }
|
||||
const view = leaveAndReturn(ASKED, DONE, { worked: 17, expanded: true })
|
||||
view.rerender({ messages: DONE, showing: true, turn: shut })
|
||||
view.rerender({ messages: DONE, showing: false, turn: shut })
|
||||
view.rerender({ messages: DONE, showing: true, turn: shut })
|
||||
expect(view.result.current.marker).toMatchObject({ key: 'prompt', place: 'above-turn-bar' })
|
||||
})
|
||||
|
||||
describe('a reply still being written when the reader left', () => {
|
||||
const begun = [row('prompt', 1, 'user'), row('reply', 2, 'assistant', 'The plan')]
|
||||
const grown = [row('prompt', 1, 'user'), row('reply', 2, 'assistant', 'The plan has parts.')]
|
||||
const marked = (onReturn: NativeChatMessage[]) =>
|
||||
leaveAndReturn(begun, onReturn, { working: true }).result.current.marker?.key
|
||||
|
||||
it('is marked new when it grew while they were away', () => {
|
||||
expect(marked(grown)).toBe('reply')
|
||||
})
|
||||
|
||||
it('is not marked when it is as they left it', () => {
|
||||
expect(marked(begun)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('gives way to the next row when it is as they left it', () => {
|
||||
expect(marked([...begun, row('more', 3)])).toBe('more')
|
||||
})
|
||||
|
||||
it('is marked new when it grew with no row placed before it', () => {
|
||||
const alone = [row('reply', 2, 'assistant', 'The plan')]
|
||||
const grownAlone = [row('reply', 2, 'assistant', 'The plan has parts.')]
|
||||
const view = leaveAndReturn(alone, grownAlone, { working: true })
|
||||
expect(view.result.current.marker?.key).toBe('reply')
|
||||
})
|
||||
|
||||
describe('with a follow-up delivered into the turn after it', () => {
|
||||
const followUp = row('follow-up', 3, 'user')
|
||||
const marked = (onReturn: NativeChatMessage[]) =>
|
||||
leaveAndReturn([...begun, followUp], onReturn, { working: true }).result.current.marker?.key
|
||||
|
||||
it('is still marked new when it grew', () => {
|
||||
expect(marked([...grown, followUp])).toBe('reply')
|
||||
})
|
||||
|
||||
it('gives way to what answers the follow-up when it is as they left it', () => {
|
||||
expect(marked([...begun, followUp, row('answer', 4)])).toBe('answer')
|
||||
})
|
||||
|
||||
it('marks nothing when nothing changed', () => {
|
||||
expect(marked([...begun, followUp])).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a message held behind the turn, placed after it', () => {
|
||||
const markedWith = (held: NativeChatMessage, onReturn: NativeChatMessage[]) => {
|
||||
const view = chat(begun, { working: true })
|
||||
view.rerender({ messages: begun, showing: true, waiting: [held] })
|
||||
view.rerender({ messages: begun, showing: false, waiting: [held] })
|
||||
view.rerender({ messages: onReturn, showing: true, waiting: [held] })
|
||||
return view.result.current.marker?.key
|
||||
}
|
||||
|
||||
it('is still marked new when it grew', () => {
|
||||
expect(markedWith(row('held', 3, 'user'), grown)).toBe('reply')
|
||||
})
|
||||
|
||||
it('marks nothing when neither it nor the held message changed', () => {
|
||||
const fromAgent: NativeChatMessage = {
|
||||
...row('held', 3, 'user'),
|
||||
from: {
|
||||
kind: 'agent',
|
||||
senders: [
|
||||
{
|
||||
party: { address: 'term_peer', terminalHandle: 'term_peer', orcaSessionId: null },
|
||||
name: 'Claude'
|
||||
}
|
||||
],
|
||||
orchestration: null
|
||||
}
|
||||
}
|
||||
// Seen while it waited, it is not news once the turn ends and it joins the transcript.
|
||||
expect(markedWith(fromAgent, [...begun, fromAgent])).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('marks nothing in a chat read from a terminal, whose rows the journal never placed', () => {
|
||||
const view = leaveAndReturn([row('a', null)], [row('a', null), row('b', null)])
|
||||
expect(view.result.current.marker).toBeUndefined()
|
||||
})
|
||||
})
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
// Mark the first row that arrived or kept growing while the reader was away.
|
||||
|
||||
import { useCallback, useMemo, useState } from 'react'
|
||||
import { useOrcaWindowForegroundFocused } from '@/hooks/use-orca-window-foreground-focused'
|
||||
import { compareAgentJournalPositions } from '../../../../../../shared/agent-session/journal/agent-session-journal-position'
|
||||
import type { AgentJournalPosition } from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { useAppStore } from '@/store'
|
||||
import { nativeChatMarksNewMessages } from '../../../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
import {
|
||||
nativeChatSlotIndexOf,
|
||||
nativeChatSlotKey
|
||||
} from '../../conversation/slots/native-chat-transcript-slot-selection'
|
||||
import type { NativeChatTranscriptSlot } from '../../conversation/slots/native-chat-transcript-slots'
|
||||
|
||||
/** Use journal positions for conversation rows, including folded-turn bars; terminal-backed rows have none and remain unmarked. */
|
||||
function rowPosition(slot: NativeChatTranscriptSlot): AgentJournalPosition | undefined {
|
||||
return slot.kind === 'message' && slot.depth === 0 && (slot.drawsMessage || slot.statusAbove)
|
||||
? slot.message.journalPosition
|
||||
: undefined
|
||||
}
|
||||
|
||||
/** Before every row the journal places: what the reader has read to when no row precedes. */
|
||||
const BEFORE_EVERY_ROW: AgentJournalPosition = { sequence: -1, index: 0 }
|
||||
|
||||
/** Where a reader who looks away now has read to, and the reply the agent is still writing. */
|
||||
type NativeChatLeftAt = {
|
||||
/** The newest row there was, as a position: that row may have folded away by the return. */
|
||||
position: AgentJournalPosition
|
||||
/** A growing reply counts as missed from the position immediately before it. */
|
||||
writing: { key: string; size: number; before: AgentJournalPosition } | null
|
||||
}
|
||||
|
||||
function rowSize(slot: NativeChatTranscriptSlot): number {
|
||||
return slot.kind === 'message'
|
||||
? JSON.stringify((slot.workRun ?? [slot.message]).map((message) => message.blocks)).length
|
||||
: 0
|
||||
}
|
||||
|
||||
function newestRowPosition(
|
||||
slots: readonly NativeChatTranscriptSlot[],
|
||||
limit?: AgentJournalPosition
|
||||
): AgentJournalPosition {
|
||||
let newest = BEFORE_EVERY_ROW
|
||||
for (const slot of slots) {
|
||||
const at = rowPosition(slot)
|
||||
if (
|
||||
at &&
|
||||
(!limit || compareAgentJournalPositions(at, limit) < 0) &&
|
||||
compareAgentJournalPositions(at, newest) > 0
|
||||
) {
|
||||
newest = at
|
||||
}
|
||||
}
|
||||
return newest
|
||||
}
|
||||
|
||||
function nativeChatLeftAt(
|
||||
slots: readonly NativeChatTranscriptSlot[],
|
||||
waitingSlots: readonly NativeChatTranscriptSlot[]
|
||||
): NativeChatLeftAt {
|
||||
const all = [...slots, ...waitingSlots]
|
||||
// Later user prompts or held sends do not stop the turn’s latest assistant row from growing.
|
||||
const writer = slots.findLast(
|
||||
(slot) =>
|
||||
slot.kind === 'message' &&
|
||||
slot.activeTurnIsWorking &&
|
||||
slot.message.role !== 'user' &&
|
||||
rowPosition(slot) !== undefined
|
||||
)
|
||||
const at = writer && rowPosition(writer)
|
||||
const writing = at
|
||||
? { key: nativeChatSlotKey(writer), size: rowSize(writer), before: newestRowPosition(all, at) }
|
||||
: null
|
||||
return { position: newestRowPosition(all), writing }
|
||||
}
|
||||
|
||||
/** The first row that came while the reader was away, and the journal stretch it came in. */
|
||||
export type NativeChatMissedRows = {
|
||||
/** The row, not a position: a queued message is placed again when it is handed over. */
|
||||
key: string
|
||||
after: AgentJournalPosition
|
||||
/** The newest row on the return: what is written after it was watched arriving. */
|
||||
through: AgentJournalPosition
|
||||
}
|
||||
|
||||
function isMissedRow(
|
||||
slot: NativeChatTranscriptSlot,
|
||||
after: AgentJournalPosition,
|
||||
through: AgentJournalPosition
|
||||
): boolean {
|
||||
const at = rowPosition(slot)
|
||||
return (
|
||||
at !== undefined &&
|
||||
compareAgentJournalPositions(at, after) > 0 &&
|
||||
compareAgentJournalPositions(at, through) <= 0 &&
|
||||
(slot.kind !== 'message' || slot.message.role !== 'user' || slot.message.from !== undefined)
|
||||
)
|
||||
}
|
||||
|
||||
function nativeChatMissedRows(
|
||||
slots: readonly NativeChatTranscriptSlot[],
|
||||
{ position, writing }: NativeChatLeftAt
|
||||
): NativeChatMissedRows | null {
|
||||
const row = writing && slots.find((slot) => nativeChatSlotKey(slot) === writing.key)
|
||||
const after = writing && !(row && rowSize(row) === writing.size) ? writing.before : position
|
||||
const through = newestRowPosition(slots)
|
||||
const first = slots.find((slot) => isMissedRow(slot, after, through))
|
||||
return first ? { key: nativeChatSlotKey(first), after, through } : null
|
||||
}
|
||||
|
||||
export type NativeChatNewRowsMarkerPlacement = {
|
||||
/** Key of the row the marker draws in. */
|
||||
key: string
|
||||
place: 'above-row' | 'above-turn-bar'
|
||||
}
|
||||
|
||||
export type NativeChatNewRowsMarkerState = NativeChatNewRowsMarkerPlacement & {
|
||||
/** The reader has just come back: bring the marker into view, once. */
|
||||
arriving: boolean
|
||||
onArrived: () => void
|
||||
onDismiss: () => void
|
||||
}
|
||||
|
||||
/** Place above the first missed row, or its turn bar when the two lines would otherwise touch. */
|
||||
export function nativeChatNewRowsMarkerPlacement(
|
||||
slots: readonly NativeChatTranscriptSlot[],
|
||||
missed: NativeChatMissedRows | null
|
||||
): NativeChatNewRowsMarkerPlacement | undefined {
|
||||
if (missed === null) {
|
||||
return undefined
|
||||
}
|
||||
const { key, after, through } = missed
|
||||
// Opening a folded turn draws missed rows above the one marked while it was shut.
|
||||
const index = slots.findIndex(
|
||||
(slot) => nativeChatSlotKey(slot) === key || isMissedRow(slot, after, through)
|
||||
)
|
||||
const first = slots[index]
|
||||
if (!first) {
|
||||
return undefined
|
||||
}
|
||||
const before = slots[index - 1]
|
||||
return before?.kind === 'message' &&
|
||||
before.status &&
|
||||
!before.statusAbove &&
|
||||
!before.turnDiff &&
|
||||
!before.openedPullRequests
|
||||
? { key: nativeChatSlotKey(before), place: 'above-turn-bar' }
|
||||
: { key: nativeChatSlotKey(first), place: 'above-row' }
|
||||
}
|
||||
|
||||
export function useNativeChatNewRowsMarker(
|
||||
slots: readonly NativeChatTranscriptSlot[],
|
||||
/** Rows held behind the running turn: seen and missed like any other, drawn outside `slots`. */
|
||||
waitingSlots: readonly NativeChatTranscriptSlot[],
|
||||
/** The pane is the one showing, and shows what the host holds now. */
|
||||
isShowingLatest: boolean
|
||||
): {
|
||||
marker: NativeChatNewRowsMarkerState | undefined
|
||||
/** The slot drawing the marker, or -1. */
|
||||
index: number
|
||||
/** The reader answered the conversation, so nothing in it is news to them. */
|
||||
dismiss: () => void
|
||||
} {
|
||||
// Off tracks nothing, so nothing is ever marked.
|
||||
const enabled = useAppStore((state) => nativeChatMarksNewMessages(state.settings))
|
||||
const focused = useOrcaWindowForegroundFocused(enabled && isShowingLatest)
|
||||
const watching = !enabled || focused
|
||||
const [seen, setSeen] = useState<{
|
||||
watching: boolean
|
||||
/** While the reader is away: where they had read to. */
|
||||
left: NativeChatLeftAt | null
|
||||
/** Stands until the reader answers. */
|
||||
missed: NativeChatMissedRows | null
|
||||
arriving: boolean
|
||||
}>({ watching, left: null, missed: null, arriving: false })
|
||||
if (!enabled) {
|
||||
if (!seen.watching || seen.left !== null || seen.missed !== null) {
|
||||
setSeen({ watching, left: null, missed: null, arriving: false })
|
||||
}
|
||||
} else if (seen.watching !== watching) {
|
||||
const all = [...slots, ...waitingSlots]
|
||||
if (watching) {
|
||||
const missed = seen.left ? nativeChatMissedRows(all, seen.left) : seen.missed
|
||||
setSeen({ watching, left: null, missed, arriving: seen.left !== null && missed !== null })
|
||||
} else {
|
||||
// An unanswered marker whose row still stands is kept: the reader may be midway through it.
|
||||
const marked = nativeChatNewRowsMarkerPlacement(all, seen.missed) !== undefined
|
||||
setSeen({ ...seen, watching, left: marked ? null : nativeChatLeftAt(slots, waitingSlots) })
|
||||
}
|
||||
}
|
||||
const { missed } = seen
|
||||
const placement = useMemo(() => nativeChatNewRowsMarkerPlacement(slots, missed), [slots, missed])
|
||||
const dismiss = useCallback(() => {
|
||||
// Where they left as well: an answer sent before the chat has caught up settles that too.
|
||||
setSeen((held) =>
|
||||
held.missed === null && held.left === null ? held : { ...held, missed: null, left: null }
|
||||
)
|
||||
}, [])
|
||||
const onArrived = useCallback(() => {
|
||||
setSeen((held) => (held.arriving ? { ...held, arriving: false } : held))
|
||||
}, [])
|
||||
const { key, place } = placement ?? {}
|
||||
const marker = useMemo(
|
||||
() =>
|
||||
key && place
|
||||
? { key, place, arriving: seen.arriving, onArrived, onDismiss: dismiss }
|
||||
: undefined,
|
||||
[key, place, seen.arriving, onArrived, dismiss]
|
||||
)
|
||||
return { marker, index: nativeChatSlotIndexOf(slots, key), dismiss }
|
||||
}
|
||||
+10
-1
@@ -8,6 +8,7 @@ import type { NativeChatTranscriptSlot } from '../../conversation/slots/native-c
|
||||
import type { NativeChatTranscriptWindow } from './use-native-chat-transcript-window'
|
||||
import type { ReaderGesture } from '../scroll/native-chat-autoscroll'
|
||||
import { NativeChatForwardedGestureContext } from '../scroll/native-chat-reader-scroll-input'
|
||||
import type { NativeChatNewRowsMarkerState } from '../new-rows/native-chat-new-rows-marker'
|
||||
import {
|
||||
NativeChatReplyRevealsContext,
|
||||
useNativeChatReplyReveals
|
||||
@@ -19,12 +20,14 @@ export function NativeChatTranscriptItems({
|
||||
loadedMessageIds,
|
||||
context,
|
||||
window,
|
||||
newRowsMarker,
|
||||
forwardGesture
|
||||
}: {
|
||||
slots: readonly NativeChatTranscriptSlot[]
|
||||
loadedMessageIds: ReadonlySet<string>
|
||||
context: NativeChatTranscriptRowContext
|
||||
window: NativeChatTranscriptWindow
|
||||
newRowsMarker?: NativeChatNewRowsMarkerState
|
||||
/** A reader gesture a row's visual frame took before the transcript could see it. */
|
||||
forwardGesture: (gesture: ReaderGesture) => void
|
||||
}): React.JSX.Element {
|
||||
@@ -44,7 +47,13 @@ export function NativeChatTranscriptItems({
|
||||
<Fragment key={item.key}>
|
||||
<div aria-hidden style={{ height: Math.max(0, item.start - previousEnd) }} />
|
||||
<div data-index={item.index} ref={window.measureRow} className="flow-root w-full">
|
||||
<NativeChatTranscriptRow slot={slot} context={context} />
|
||||
<NativeChatTranscriptRow
|
||||
slot={slot}
|
||||
context={context}
|
||||
newRowsMarker={
|
||||
rowKeys[item.index] === newRowsMarker?.key ? newRowsMarker : undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
+8
-3
@@ -9,20 +9,25 @@ export type NativeChatPinnedRowsInput = {
|
||||
count: number
|
||||
/** Mount reveal targets before their cards expand and report scroll positions. */
|
||||
revealIndex?: number | null
|
||||
/** Keep the New marker mounted so it can reveal itself and detect reader replies. */
|
||||
newRowsMarkerIndex?: number | null
|
||||
}
|
||||
|
||||
/** Pin the live tail for aria-live announcements and measured-height accuracy during streaming. */
|
||||
export function nativeChatPinnedRowIndexes({
|
||||
count,
|
||||
revealIndex
|
||||
revealIndex,
|
||||
newRowsMarkerIndex
|
||||
}: NativeChatPinnedRowsInput): ReadonlySet<number> {
|
||||
const pinned = new Set<number>()
|
||||
if (count <= 0) {
|
||||
return pinned
|
||||
}
|
||||
pinned.add(count - 1)
|
||||
if (revealIndex != null && revealIndex >= 0 && revealIndex < count) {
|
||||
pinned.add(revealIndex)
|
||||
for (const index of [revealIndex, newRowsMarkerIndex]) {
|
||||
if (index != null && index >= 0 && index < count) {
|
||||
pinned.add(index)
|
||||
}
|
||||
}
|
||||
return pinned
|
||||
}
|
||||
|
||||
+5
-2
@@ -54,6 +54,7 @@ export function useNativeChatTranscriptWindow({
|
||||
slots,
|
||||
isVisible,
|
||||
revealIndex,
|
||||
newRowsMarkerIndex,
|
||||
typography = DEFAULT_ROW_TYPOGRAPHY
|
||||
}: {
|
||||
scrollRef: React.RefObject<HTMLDivElement | null>
|
||||
@@ -61,6 +62,8 @@ export function useNativeChatTranscriptWindow({
|
||||
isVisible: boolean
|
||||
/** Slot the transcript was asked to reveal, or -1. */
|
||||
revealIndex: number
|
||||
/** Slot drawing the "New" marker, or -1. */
|
||||
newRowsMarkerIndex?: number
|
||||
/** Chat text scale; gap scales with the text size. */
|
||||
typography?: NativeChatRowTypography
|
||||
}): NativeChatTranscriptWindow {
|
||||
@@ -71,8 +74,8 @@ export function useNativeChatTranscriptWindow({
|
||||
const previousMeasurementKeysRef = useRef<ReadonlySet<string> | null>(null)
|
||||
const retiredMeasurementCountRef = useRef(0)
|
||||
const pinned = useMemo(
|
||||
() => nativeChatPinnedRowIndexes({ count: slots.length, revealIndex }),
|
||||
[slots.length, revealIndex]
|
||||
() => nativeChatPinnedRowIndexes({ count: slots.length, revealIndex, newRowsMarkerIndex }),
|
||||
[slots.length, revealIndex, newRowsMarkerIndex]
|
||||
)
|
||||
// Keep measured offsets through content-only growth to preserve the end anchor; rebuild only on structural changes.
|
||||
// Encoded only when the slots change: scroll and range renders reuse it.
|
||||
|
||||
@@ -14,7 +14,10 @@ import { NativeChatShellEnvironmentSetting } from './NativeChatShellEnvironmentS
|
||||
import { NativeChatIdleStopSetting } from './NativeChatIdleStopSetting'
|
||||
import { SearchableSetting } from '../section-layout/SearchableSetting'
|
||||
import { nativeChatQueueFollowUps } from '../../../../../shared/native-chat/input/native-chat-follow-up-behavior'
|
||||
import { nativeChatScrollsToLatestOnSend } from '../../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
import {
|
||||
nativeChatMarksNewMessages,
|
||||
nativeChatScrollsToLatestOnSend
|
||||
} from '../../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
import { SettingsSubsectionHeader, SettingsSwitchRow } from '../form-controls/SettingsFormControls'
|
||||
import { getChatBehaviorEntriesByKey, getChatBehaviorTitle } from './chat-behavior-search'
|
||||
import { getChatPermissionSearchEntry } from './chat-permission-search'
|
||||
@@ -54,6 +57,7 @@ export function ChatBehaviorSetting({
|
||||
...(hostContinuesUsageLimits ? [entries.autoContinueAfterUsageLimit] : []),
|
||||
...(hostQueuesMessages ? [entries.queueFollowUps] : []),
|
||||
entries.scrollToLatestOnSend,
|
||||
entries.markNewMessages,
|
||||
entries.linkPreviews,
|
||||
entries.shellEnvironment
|
||||
]
|
||||
@@ -64,6 +68,7 @@ export function ChatBehaviorSetting({
|
||||
const queueFollowUps = nativeChatQueueFollowUps(settings)
|
||||
const autoContinueEnabled = settings.nativeChatAutoContinueAfterUsageLimit === true
|
||||
const scrollToLatestOnSend = nativeChatScrollsToLatestOnSend(settings)
|
||||
const markNewMessages = nativeChatMarksNewMessages(settings)
|
||||
const linkPreviewsEnabled = settings.nativeChatLinkPreviews !== false
|
||||
return (
|
||||
<section id="chat-behavior" className="space-y-3">
|
||||
@@ -162,6 +167,20 @@ export function ChatBehaviorSetting({
|
||||
}
|
||||
/>
|
||||
</SearchableSetting>
|
||||
<SearchableSetting
|
||||
{...entries.markNewMessages}
|
||||
id={entries.markNewMessages.targetSectionId}
|
||||
forceVisible={forceVisible}
|
||||
className="max-w-none"
|
||||
>
|
||||
<SettingsSwitchRow
|
||||
label={entries.markNewMessages.title}
|
||||
description={entries.markNewMessages.description}
|
||||
checked={markNewMessages}
|
||||
ariaLabel={entries.markNewMessages.title}
|
||||
onChange={() => updateSettings({ nativeChatMarkNewMessages: !markNewMessages })}
|
||||
/>
|
||||
</SearchableSetting>
|
||||
<SearchableSetting
|
||||
{...entries.linkPreviews}
|
||||
id={entries.linkPreviews.targetSectionId}
|
||||
|
||||
@@ -78,6 +78,18 @@ export const getChatBehaviorEntriesByKey = createLocalizedCatalog(() => ({
|
||||
translate('components.settings.nativeChat.scrollToLatestOnSendSearchPosition', 'position')
|
||||
]
|
||||
},
|
||||
markNewMessages: {
|
||||
targetSectionId: 'chat-mark-new-messages',
|
||||
title: translate(
|
||||
'components.settings.nativeChat.markNewMessagesTitle',
|
||||
'Mark new messages when returning to a chat'
|
||||
),
|
||||
description: translate(
|
||||
'components.settings.nativeChat.markNewMessagesCopy',
|
||||
'Coming back to a chat draws a New line above what arrived while you were away, and scrolls to it if you were reading the latest.'
|
||||
),
|
||||
keywords: [translate('components.settings.nativeChat.markNewMessagesSearchUnread', 'unread')]
|
||||
},
|
||||
linkPreviews: {
|
||||
targetSectionId: 'chat-link-previews',
|
||||
title: translate('components.settings.nativeChat.linkPreviewsTitle', 'Link previews'),
|
||||
|
||||
@@ -19771,6 +19771,8 @@
|
||||
"showAgent": "{{value0}} im Gespräch anzeigen"
|
||||
},
|
||||
"jumpToLatest": "Zur neuesten Nachricht springen",
|
||||
"newRowsAnnouncement": "Während der Abwesenheit sind neue Nachrichten eingegangen",
|
||||
"newRowsMarker": "Neu",
|
||||
"find": {
|
||||
"label": "Im Chat suchen",
|
||||
"noResults": "Keine Ergebnisse",
|
||||
@@ -20640,6 +20642,9 @@
|
||||
"scrollToLatestOnSendTitle": "Beim Senden zur neuesten Nachricht scrollen",
|
||||
"scrollToLatestOnSendCopy": "Senden im hochgescrollten Zustand springt zur neuesten Nachricht und folgt der Antwort. Deaktiviere dies, um deine Position zu behalten.",
|
||||
"scrollToLatestOnSendSearchPosition": "Position",
|
||||
"markNewMessagesTitle": "Neue Nachrichten bei der Rückkehr in einen Chat markieren",
|
||||
"markNewMessagesCopy": "Bei der Rückkehr in einen Chat erscheint eine Neu-Linie über dem, was in deiner Abwesenheit eingegangen ist. Warst du bei der neuesten Nachricht, scrollt der Chat dorthin.",
|
||||
"markNewMessagesSearchUnread": "ungelesen",
|
||||
"inlineVisualsTitle": "Eingebettete Grafiken",
|
||||
"inlineVisualsCopy": "Dem Agenten erlauben, Diagramme, Schaubilder und Mockups in seinen Antworten anzuzeigen. Gilt für neu gestartete Chats.",
|
||||
"inlineVisualsToggleLabel": "Eingebettete Grafiken umschalten",
|
||||
|
||||
@@ -20355,6 +20355,8 @@
|
||||
"showAgent": "Show {{value0}} in the conversation"
|
||||
},
|
||||
"jumpToLatest": "Jump to latest",
|
||||
"newRowsAnnouncement": "New messages arrived while you were away",
|
||||
"newRowsMarker": "New",
|
||||
"find": {
|
||||
"label": "Find in chat",
|
||||
"noResults": "No results",
|
||||
@@ -21306,6 +21308,9 @@
|
||||
"scrollToLatestOnSendTitle": "Scroll to latest when sending",
|
||||
"scrollToLatestOnSendCopy": "Sending while scrolled up jumps to the latest message and follows the reply. Turn off to keep your place.",
|
||||
"scrollToLatestOnSendSearchPosition": "position",
|
||||
"markNewMessagesTitle": "Mark new messages when returning to a chat",
|
||||
"markNewMessagesCopy": "Coming back to a chat draws a New line above what arrived while you were away, and scrolls to it if you were reading the latest.",
|
||||
"markNewMessagesSearchUnread": "unread",
|
||||
"inlineVisualsTitle": "Inline visuals",
|
||||
"inlineVisualsCopy": "Let the agent show charts, diagrams and mockups inside its replies. Applies to newly started chats.",
|
||||
"inlineVisualsToggleLabel": "Toggle inline visuals",
|
||||
|
||||
@@ -19410,6 +19410,8 @@
|
||||
"toggleDetails": "Alternar detalles del turno"
|
||||
},
|
||||
"jumpToLatest": "Saltar a lo último",
|
||||
"newRowsAnnouncement": "Llegaron mensajes nuevos mientras no estabas",
|
||||
"newRowsMarker": "Nuevo",
|
||||
"find": {
|
||||
"label": "Buscar en el chat",
|
||||
"noResults": "Sin resultados",
|
||||
@@ -20392,6 +20394,9 @@
|
||||
"scrollToLatestOnSendTitle": "Desplazar a lo último al enviar",
|
||||
"scrollToLatestOnSendCopy": "Enviar con el chat desplazado hacia arriba salta al último mensaje y sigue la respuesta. Desactívalo para mantener tu posición.",
|
||||
"scrollToLatestOnSendSearchPosition": "posición",
|
||||
"markNewMessagesTitle": "Marcar los mensajes nuevos al volver a un chat",
|
||||
"markNewMessagesCopy": "Al volver a un chat aparece una línea Nuevo encima de lo que llegó mientras no estabas, y el chat se desplaza hasta ella si estabas leyendo lo más reciente.",
|
||||
"markNewMessagesSearchUnread": "no leído",
|
||||
"followUpBehaviorCopy": "Los mensajes enviados mientras el agente trabaja esperan como tarjetas hasta que termina el turno, en lugar de entrar en el turno en curso. Cmd/Ctrl+Intro hace lo contrario para un mensaje y, si no hay texto escrito, dirige la primera tarjeta en espera al turno en curso. Los mensajes con imágenes también esperan como tarjetas.",
|
||||
"inlineVisualsTitle": "Elementos visuales inline",
|
||||
"inlineVisualsCopy": "Permite que el agente muestre gráficos, diagramas y maquetas dentro de sus respuestas. Se aplica a los chats nuevos.",
|
||||
|
||||
@@ -19649,6 +19649,8 @@
|
||||
"toggleDetails": "Basculer les détails du tour"
|
||||
},
|
||||
"jumpToLatest": "Aller au dernier message",
|
||||
"newRowsAnnouncement": "De nouveaux messages sont arrivés en votre absence",
|
||||
"newRowsMarker": "Nouveau",
|
||||
"find": {
|
||||
"label": "Rechercher dans le chat",
|
||||
"noResults": "Aucun résultat",
|
||||
@@ -20740,6 +20742,9 @@
|
||||
"scrollToLatestOnSendTitle": "Défiler jusqu’au dernier message à l’envoi",
|
||||
"scrollToLatestOnSendCopy": "Envoyer après avoir remonté le fil fait défiler jusqu’au dernier message et suit la réponse. Désactivez cette option pour garder votre position.",
|
||||
"scrollToLatestOnSendSearchPosition": "position",
|
||||
"markNewMessagesTitle": "Signaler les nouveaux messages au retour dans un chat",
|
||||
"markNewMessagesCopy": "En revenant dans un chat, une ligne Nouveau s'affiche au-dessus de ce qui est arrivé pendant votre absence, et le chat y défile si vous lisiez les derniers messages.",
|
||||
"markNewMessagesSearchUnread": "non lu",
|
||||
"followUpBehaviorCopy": "Les messages envoyés pendant que l’agent travaille attendent sous forme de cartes jusqu’à la fin du tour, au lieu d’entrer dans le tour en cours. Cmd/Ctrl+Entrée fait l’inverse pour un message et, si rien n’est saisi, dirige la première carte en attente vers le tour en cours. Les messages contenant des images attendent aussi sous forme de cartes.",
|
||||
"inlineVisualsTitle": "Visuels intégrés",
|
||||
"inlineVisualsCopy": "Laissez l'agent afficher des graphiques, des diagrammes et des maquettes dans ses réponses. S'applique aux nouveaux chats.",
|
||||
|
||||
@@ -18947,6 +18947,8 @@
|
||||
"toggleDetails": "ターンの詳細を切り替えます"
|
||||
},
|
||||
"jumpToLatest": "最新にジャンプ",
|
||||
"newRowsAnnouncement": "離れている間に新しいメッセージが届きました",
|
||||
"newRowsMarker": "新着",
|
||||
"find": {
|
||||
"label": "チャット内を検索",
|
||||
"noResults": "結果はありません",
|
||||
@@ -19915,6 +19917,9 @@
|
||||
"scrollToLatestOnSendTitle": "送信時に最新までスクロール",
|
||||
"scrollToLatestOnSendCopy": "上にスクロールした状態で送信すると、最新のメッセージに移動して返信を追従します。オフにすると現在の位置を維持します。",
|
||||
"scrollToLatestOnSendSearchPosition": "位置",
|
||||
"markNewMessagesTitle": "チャットに戻ったときに新着メッセージを示す",
|
||||
"markNewMessagesCopy": "チャットに戻ると、離れている間に届いたメッセージの上に「新着」の線を表示します。最新のメッセージを読んでいた場合は、そこまでスクロールします。",
|
||||
"markNewMessagesSearchUnread": "未読",
|
||||
"followUpBehaviorCopy": "Agent の作業中に送信したメッセージは、実行中のターンに送られず、ターンが終わるまでカードとして待機します。Cmd/Ctrl+Enter では 1 件だけその逆になり、何も入力されていない場合は最初の待機カードを実行中のターンに送ります。画像付きメッセージもカードとして待機します。",
|
||||
"inlineVisualsTitle": "インライン表示",
|
||||
"inlineVisualsCopy": "Agent が返信内でグラフ、図、モックアップを表示できるようにします。新しく開始したチャットに適用されます。",
|
||||
|
||||
@@ -18947,6 +18947,8 @@
|
||||
"toggleDetails": "턴 세부정보 전환"
|
||||
},
|
||||
"jumpToLatest": "최신으로 이동",
|
||||
"newRowsAnnouncement": "자리를 비운 동안 새 메시지가 도착했습니다",
|
||||
"newRowsMarker": "새 메시지",
|
||||
"find": {
|
||||
"label": "채팅에서 찾기",
|
||||
"noResults": "결과 없음",
|
||||
@@ -19915,6 +19917,9 @@
|
||||
"scrollToLatestOnSendTitle": "보낼 때 최신 메시지로 스크롤",
|
||||
"scrollToLatestOnSendCopy": "위로 스크롤한 상태에서 보내면 최신 메시지로 이동하고 답장을 따라갑니다. 끄면 현재 위치가 유지됩니다.",
|
||||
"scrollToLatestOnSendSearchPosition": "위치",
|
||||
"markNewMessagesTitle": "채팅으로 돌아올 때 새 메시지 표시",
|
||||
"markNewMessagesCopy": "채팅으로 돌아오면 자리를 비운 동안 도착한 내용 위에 '새 메시지' 선을 표시합니다. 최신 메시지를 보고 있었다면 그 위치로 스크롤합니다.",
|
||||
"markNewMessagesSearchUnread": "읽지 않음",
|
||||
"followUpBehaviorCopy": "Agent가 작업하는 동안 보낸 메시지는 진행 중인 턴에 들어가지 않고 턴이 끝날 때까지 카드로 대기합니다. Cmd/Ctrl+Enter를 누르면 메시지 하나에 대해 반대로 동작하며, 입력한 내용이 없으면 첫 대기 카드를 진행 중인 턴으로 보냅니다. 이미지가 포함된 메시지도 카드로 대기합니다.",
|
||||
"inlineVisualsTitle": "인라인 시각 자료",
|
||||
"inlineVisualsCopy": "에이전트가 답변 안에 차트, 다이어그램, 목업을 표시하도록 합니다. 새로 시작한 채팅에 적용됩니다.",
|
||||
|
||||
@@ -20831,6 +20831,8 @@
|
||||
"pendingWork": "Aguarde a conclusão do trabalho e das mensagens pendentes antes de usar este comando.",
|
||||
"notDoneGoalChangeIncomplete": "Não foi possível concluir a alteração do objetivo. Verifique o chat."
|
||||
},
|
||||
"newRowsAnnouncement": "Novas mensagens chegaram enquanto você estava ausente",
|
||||
"newRowsMarker": "Novas",
|
||||
"find": {
|
||||
"label": "Localizar no chat",
|
||||
"noResults": "Nenhum resultado",
|
||||
@@ -21610,6 +21612,9 @@
|
||||
"scrollToLatestOnSendTitle": "Rolar até o mais recente ao enviar",
|
||||
"scrollToLatestOnSendCopy": "Enviar com o chat rolado para cima leva à mensagem mais recente e acompanha a resposta. Desative para manter sua posição.",
|
||||
"scrollToLatestOnSendSearchPosition": "posição",
|
||||
"markNewMessagesTitle": "Marcar mensagens novas ao voltar para um chat",
|
||||
"markNewMessagesCopy": "Ao voltar para um chat, uma linha Novas aparece acima do que chegou enquanto você estava fora, e o chat rola até ela se você estava lendo as mais recentes.",
|
||||
"markNewMessagesSearchUnread": "não lida",
|
||||
"inlineVisualsTitle": "Visualizações nas respostas",
|
||||
"inlineVisualsCopy": "Permitir que o agente mostre gráficos, diagramas e mockups nas respostas. Aplica-se a novos chats.",
|
||||
"inlineVisualsToggleLabel": "Ativar ou desativar visualizações nas respostas",
|
||||
|
||||
@@ -20421,6 +20421,8 @@
|
||||
"showAgent": "Показать {{value0}} в разговоре"
|
||||
},
|
||||
"jumpToLatest": "К последним сообщениям",
|
||||
"newRowsAnnouncement": "Пока вас не было, появились новые сообщения",
|
||||
"newRowsMarker": "Новое",
|
||||
"find": {
|
||||
"label": "Найти в чате",
|
||||
"noResults": "Ничего не найдено",
|
||||
@@ -21327,6 +21329,9 @@
|
||||
"scrollToLatestOnSendTitle": "Прокручивать к последнему сообщению при отправке",
|
||||
"scrollToLatestOnSendCopy": "Отправка при прокрутке вверх переносит к последнему сообщению и следит за ответом. Отключите, чтобы остаться на месте.",
|
||||
"scrollToLatestOnSendSearchPosition": "позиция",
|
||||
"markNewMessagesTitle": "Отмечать новые сообщения при возвращении в чат",
|
||||
"markNewMessagesCopy": "При возвращении в чат над тем, что пришло в ваше отсутствие, появляется линия «Новое». Если вы читали последние сообщения, чат прокручивается к ней.",
|
||||
"markNewMessagesSearchUnread": "непрочитанные",
|
||||
"inlineVisualsTitle": "Визуализации в чате",
|
||||
"inlineVisualsCopy": "Агент сможет показывать графики, схемы и макеты прямо в ответах. Применяется к новым чатам.",
|
||||
"inlineVisualsToggleLabel": "Включить визуализации в чате",
|
||||
|
||||
@@ -19756,6 +19756,8 @@
|
||||
"showAgent": "{{value0}} öğesini konuşmada göster"
|
||||
},
|
||||
"jumpToLatest": "En son öğeye git",
|
||||
"newRowsAnnouncement": "Siz yokken yeni mesajlar geldi",
|
||||
"newRowsMarker": "Yeni",
|
||||
"find": {
|
||||
"label": "Sohbette bul",
|
||||
"noResults": "Sonuç yok",
|
||||
@@ -20622,6 +20624,9 @@
|
||||
"scrollToLatestOnSendTitle": "Gönderirken en son mesaja kaydır",
|
||||
"scrollToLatestOnSendCopy": "Yukarı kaydırılmışken göndermek en son mesaja atlar ve yanıtı takip eder. Konumunuzu korumak için kapatın.",
|
||||
"scrollToLatestOnSendSearchPosition": "konum",
|
||||
"markNewMessagesTitle": "Bir sohbete dönünce yeni mesajları işaretle",
|
||||
"markNewMessagesCopy": "Bir sohbete döndüğünüzde, siz yokken gelenlerin üstünde bir Yeni çizgisi gösterilir. En son mesajları okuyorduysanız sohbet oraya kaydırılır.",
|
||||
"markNewMessagesSearchUnread": "okunmamış",
|
||||
"inlineVisualsTitle": "Yanıtlarda görseller",
|
||||
"inlineVisualsCopy": "Ajanın yanıtlarında grafikler, diyagramlar ve taslaklar göstermesine izin verin. Yeni başlatılan sohbetlere uygulanır.",
|
||||
"inlineVisualsToggleLabel": "Yanıtlardaki görselleri aç/kapat",
|
||||
|
||||
@@ -19472,6 +19472,8 @@
|
||||
"showAgent": "在對話中顯示 {{value0}}"
|
||||
},
|
||||
"jumpToLatest": "跳到最新訊息",
|
||||
"newRowsAnnouncement": "你離開期間有新訊息",
|
||||
"newRowsMarker": "新訊息",
|
||||
"find": {
|
||||
"label": "在聊天中查詢",
|
||||
"noResults": "沒有結果",
|
||||
@@ -20323,6 +20325,9 @@
|
||||
"scrollToLatestOnSendTitle": "傳送時捲動到最新訊息",
|
||||
"scrollToLatestOnSendCopy": "向上捲動時傳送訊息會跳到最新訊息並跟隨回覆。關閉後會保留目前位置。",
|
||||
"scrollToLatestOnSendSearchPosition": "位置",
|
||||
"markNewMessagesTitle": "返回聊天時標記新訊息",
|
||||
"markNewMessagesCopy": "返回聊天時,在你離開期間收到的內容上方顯示「新訊息」分隔線;如果你之前在看最新訊息,會捲動到該處。",
|
||||
"markNewMessagesSearchUnread": "未讀",
|
||||
"inlineVisualsTitle": "內嵌視覺化",
|
||||
"inlineVisualsCopy": "允許代理程式在其回覆中顯示圖表、示意圖和原型圖。適用於新啟動的聊天。",
|
||||
"inlineVisualsToggleLabel": "切換內嵌視覺化",
|
||||
|
||||
@@ -18887,6 +18887,8 @@
|
||||
"toggleDetails": "切换回合详情"
|
||||
},
|
||||
"jumpToLatest": "跳到最新消息",
|
||||
"newRowsAnnouncement": "你离开期间有新消息",
|
||||
"newRowsMarker": "新消息",
|
||||
"find": {
|
||||
"label": "在聊天中查找",
|
||||
"noResults": "没有结果",
|
||||
@@ -19915,6 +19917,9 @@
|
||||
"scrollToLatestOnSendTitle": "发送时滚动到最新消息",
|
||||
"scrollToLatestOnSendCopy": "向上滚动时发送消息会跳到最新消息并跟随回复。关闭后将保持当前位置。",
|
||||
"scrollToLatestOnSendSearchPosition": "位置",
|
||||
"markNewMessagesTitle": "返回聊天时标记新消息",
|
||||
"markNewMessagesCopy": "返回聊天时,在你离开期间收到的内容上方显示“新消息”分隔线;如果你之前在看最新消息,会滚动到该处。",
|
||||
"markNewMessagesSearchUnread": "未读",
|
||||
"followUpBehaviorCopy": "智能体工作时发送的消息会作为卡片等待,直到本轮结束,而不是进入当前轮次。Cmd/Ctrl+Enter 对单条消息执行相反操作;输入框为空时,该快捷键会将第一张等待中的卡片引入当前轮次。带图片的消息也会作为卡片等待。",
|
||||
"inlineVisualsTitle": "内联可视化",
|
||||
"inlineVisualsCopy": "允许智能体在其回复中显示图表、示意图和原型图。适用于新启动的聊天。",
|
||||
|
||||
@@ -31,6 +31,18 @@ export type NativeChatGlobalSettings = {
|
||||
nativeChatTurnDiffSummary?: boolean
|
||||
/** Lines saying how CI went on a pull request the chat opened or pushed to. Absent means on. */
|
||||
nativeChatCiResultLines?: boolean
|
||||
/** A "New" line above what arrived while the reader was away. Absent follows the default below. */
|
||||
nativeChatMarkNewMessages?: boolean
|
||||
}
|
||||
|
||||
/** Not written into default settings, so flipping this reaches everyone who never chose. */
|
||||
const NATIVE_CHAT_MARKS_NEW_MESSAGES_BY_DEFAULT = true
|
||||
|
||||
export function nativeChatMarksNewMessages(
|
||||
settings: { readonly nativeChatMarkNewMessages?: unknown } | null | undefined
|
||||
): boolean {
|
||||
const value = settings?.nativeChatMarkNewMessages
|
||||
return typeof value === 'boolean' ? value : NATIVE_CHAT_MARKS_NEW_MESSAGES_BY_DEFAULT
|
||||
}
|
||||
|
||||
/** Only explicit OFF keeps a reader's place on send. */
|
||||
|
||||
Reference in New Issue
Block a user