Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/mobile/src/features/threads/ThreadComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ function useCompactComposerEditor(text: ScaledTextRole, value: string) {
const editorStyle = useAnimatedStyle(() => ({
position: "absolute",
overflow: "hidden",
// The compact slot is unknown until its first layout, so the editor would draw over the + button.
opacity: isExpanded || editorWidth.value > 0 ? 1 : 0,
height,
...(isExpanded
? { left: 14, right: 14 }
Expand Down
15 changes: 10 additions & 5 deletions apps/mobile/src/features/threads/ThreadFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3465,9 +3465,15 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
headerMaterialVisibleRef.current = visible;
onHeaderMaterialVisibilityChange?.(visible);
};
const feedThreadKey = scopedThreadKey(props.environmentId, props.threadId);
const [loadedListKey, setLoadedListKey] = useState<string | null>(null);
// LegendList hides rows until it has scrolled to the end, but not its header.
const settling = props.feed.length > 0 && loadedListKey !== feedThreadKey;
const handleMetricsChange = () => {
const state = listRef.current?.getState();
if (state) onIsAtEndChange?.(state.isAtEnd);
// Offset 0 before the first positioning, and the gaps while rows measure in, are not the
// user leaving the end; only a scroll away stops end following.
if (state) onIsAtEndChange?.(settling || state.isAtEnd || state.isFollowingEnd);
};
const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
reportHeaderMaterialVisibility(
Expand All @@ -3482,6 +3488,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
handleMetricsChange();
const stops = [
state.listen("isAtEnd", handleMetricsChange),
state.listen("isFollowingEnd", handleMetricsChange),
state.listen("totalSize", handleMetricsChange),
state.listen("footerSize", handleMetricsChange),
state.listen("headerSize", handleMetricsChange),
Expand All @@ -3490,15 +3497,13 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
for (const stop of stops) stop();
};
}, [listRef, handleMetricsChange]);
const feedThreadKey = scopedThreadKey(props.environmentId, props.threadId);
const [workGroupScrollPositions] = useState(
() => new Map<string, ThreadWorkGroupScrollPosition>(),
);

// Opening at a message: once the filled list has loaded, the render that sees
// the jump unfolds a run hiding the message and stops following the end, so
// the committed list holds the target row with end maintenance off.
const [loadedListKey, setLoadedListKey] = useState<string | null>(null);
const { jumpToMessageId } = props;
const jumpReady = !!jumpToMessageId && loadedListKey === feedThreadKey;
if (jumpReady && revealedMessageId !== jumpToMessageId) {
Expand Down Expand Up @@ -3993,7 +3998,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
onScroll={handleScroll}
scrollEventThrottle={16}
ListHeaderComponent={
<>
<View style={settling ? { opacity: 0 } : undefined}>
{usesNativeAutomaticInsets ? null : <View style={{ height: topContentInset }} />}
{setupAnchorIndex < 0 && props.worktreeSetup ? (
<WorktreeSetupCard key={props.threadId} {...props.worktreeSetup} />
Expand All @@ -4003,7 +4008,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
{props.historyControls ? (
<ThreadFeedLoadEarlierControl {...props.historyControls} />
) : null}
</>
</View>
}
ListFooterComponent={
props.pendingHandoff ? (
Expand Down
19 changes: 15 additions & 4 deletions apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3384,19 +3384,30 @@ describe("AcpAdapterV2", () => {
yield* replay("user_message_chunk", "u1", "lo");
yield* replay("agent_message_chunk", "a1", "hi");
yield* replay("user_message_chunk", "u2", "next");
yield* replay("agent_message_chunk", "a1", " there");
yield* replay("agent_message_chunk", "a1", " ");
yield* replay("agent_message_chunk", "a1", "there");
yield* replay("agent_message_chunk", "a3", "\t");
yield* replay("agent_message_chunk", "a3", "code");
yield* replay("agent_message_chunk", "a4", "\n\n");
const first = yield* runtime.readThreadSnapshot({ providerThread });
yield* replay("agent_message_chunk", "a2", "done");
yield* replay("user_message_chunk", "u2", " one");
yield* replay("user_message_chunk", "u2", "\n");
yield* replay("user_message_chunk", "u2", "\tone");
const second = yield* runtime.readThreadSnapshot({ providerThread });

const texts = (snapshot: typeof first) =>
snapshot.messages.map((message) => `${message.role}:${message.text}`);
assert.deepEqual(texts(first), ["user:hello", "assistant:hi there", "user:next"]);
assert.deepEqual(texts(first), [
"user:hello",
"assistant:hi there",
"user:next",
"assistant:\tcode",
]);
assert.deepEqual(texts(second), [
"user:hello",
"assistant:hi there",
"user:next one",
"user:next\n\tone",
"assistant:\tcode",
"assistant:done",
]);
}).pipe(Effect.provide(layerTest), Effect.scoped),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
{"type":"emit_inbound","label":"response:get_entries","frame":{"id":"t3-7","type":"response","command":"get_entries","success":true,"data":{"entries":[{"type":"model_change","id":"5e37f535","parentId":"f3bce6ef","timestamp":"2026-01-01T00:00:00.437Z","provider":"openrouter","modelId":"deepseek/deepseek-v4-flash"},{"type":"session_info","id":"16d089a9","parentId":"5e37f535","timestamp":"2026-01-01T00:00:00.440Z","name":"Replay fixture: multi_turn"},{"type":"message","id":"ea6f5949","parentId":"16d089a9","timestamp":"2026-01-01T00:00:00.448Z","message":{"role":"system","content":"","sections":{"preamble":"<system-prompt-section>","tools":"<system-prompt-section>","rules":"<system-prompt-section>","docs":"<system-prompt-section>","cwd":"<system-prompt-section>"},"timestamp":1790898591750,"toolsAdded":[{"name":"read","description":"Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to 2000 lines or 50KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.","parameters":{"type":"object","required":["path"],"properties":{"path":{"type":"string","description":"Path to the file to read (relative or absolute)"},"offset":{"type":"number","description":"Line number to start reading from (1-indexed)"},"limit":{"type":"number","description":"Maximum number of lines to read"}}},"constrainedSampling":{"type":"json_schema","strict":"prefer"}},{"name":"bash","description":"Execute a bash command in the current working directory. Returns stdout and stderr. Output is truncated to last 2000 lines or 50KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.","parameters":{"type":"object","required":["command"],"properties":{"command":{"type":"string","description":"Shell command to execute"},"timeout":{"type":"number","description":"Timeout in seconds (optional, no default timeout)"}}},"constrainedSampling":{"type":"json_schema","strict":"prefer"}},{"name":"edit","description":"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.","parameters":{"type":"object","required":["path","edits"],"properties":{"path":{"type":"string","description":"Path to the file to edit (relative or absolute)"},"edits":{"type":"array","items":{"type":"object","required":["oldText","newText"],"properties":{"oldText":{"type":"string","description":"Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call."},"newText":{"type":"string","description":"Replacement text for this targeted edit."}}},"description":"One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead."}}},"constrainedSampling":{"type":"json_schema","strict":"prefer"}},{"name":"write","description":"Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Automatically creates parent directories.","parameters":{"type":"object","required":["path","content"],"properties":{"path":{"type":"string","description":"Path to the file to write (relative or absolute)"},"content":{"type":"string","description":"Content to write to the file"}}},"constrainedSampling":{"type":"json_schema","strict":"prefer"}}]}},{"type":"message","id":"ff895990","parentId":"ea6f5949","timestamp":"2026-01-01T00:00:00.448Z","message":{"role":"user","content":[{"type":"text","text":"Respond with exactly: first fixture turn complete"}],"timestamp":1767225600444}},{"type":"message","id":"5c0d3865","parentId":"ff895990","timestamp":"2026-01-01T00:00:01.723Z","message":{"role":"assistant","content":[{"type":"thinking","thinking":"The user wants me to respond with exactly: \"first fixture turn complete\"","thinkingSignature":"<signature>"},{"type":"text","text":"first fixture turn complete"}],"api":"openai-completions","provider":"openrouter","model":"deepseek/deepseek-v4-flash","usage":{"input":1787,"output":21,"cacheRead":0,"cacheWrite":0,"reasoning":18,"totalTokens":1808,"cost":{"input":0.00007480382,"output":0.0000017581199999999999,"cacheRead":0,"cacheWrite":0,"total":0.00007656194}},"stopReason":"stop","timestamp":1767225600465,"responseId":"gen-1790898592-RtbvUBJEB0AHaUCPMqrg","rawStopReason":"stop","thinkingLevel":"high"}}],"leafId":"5c0d3865"}}}
{"type":"expect_outbound","label":"get_session_stats","frame":{"type":"get_session_stats","id":"t3-8"}}
{"type":"emit_inbound","label":"response:get_session_stats","frame":{"id":"t3-8","type":"response","command":"get_session_stats","success":true,"data":{"sessionFile":"/pi-sessions/session-1.jsonl","sessionId":"00000000-0000-4000-8000-000000000002","userMessages":1,"assistantMessages":1,"toolCalls":0,"toolResults":0,"totalMessages":3,"tokens":{"input":1787,"output":21,"cacheRead":0,"cacheWrite":0,"total":1808},"cost":0.00007656194,"contextUsage":{"tokens":1808,"contextWindow":1048576,"percent":0.17242431640625}}}}
{"type":"expect_outbound","label":"get_state","frame":{"type":"get_state","id":"t3-1000"}}
{"type":"emit_inbound","label":"response:get_state","frame":{"id":"t3-1000","type":"response","command":"get_state","success":true,"data":{"model":{"type":"chat","id":"deepseek/deepseek-v4-flash","name":"DeepSeek: DeepSeek V4 Flash 0423","api":"openai-completions","baseUrl":"https://openrouter.ai/api/v1","provider":"openrouter","reasoning":true,"thinkingLevelMap":{"off":"none","minimal":null,"low":null,"medium":null,"high":"high","xhigh":"xhigh","max":null},"input":["text"],"cost":{"input":0.04186,"output":0.08372,"cacheRead":0.008372,"cacheWrite":0},"contextWindow":1048576,"maxTokens":131072,"compat":{"supportsDeveloperRole":false,"thinkingFormat":"openrouter","supportsStrictMode":true,"sendSessionAffinityHeaders":true,"requiresReasoningContentOnAssistantMessages":true}},"thinkingLevel":"high","isStreaming":false,"isCompacting":false,"steeringMode":"one-at-a-time","followUpMode":"one-at-a-time","sessionFile":"/pi-sessions/session-1.jsonl","sessionId":"00000000-0000-4000-8000-000000000002","sessionName":"Replay fixture: multi_turn","autoCompactionEnabled":true,"messageCount":3,"pendingMessageCount":0}}}
{"type":"expect_outbound","label":"prompt","frame":{"type":"prompt","message":"Respond with exactly: second fixture turn complete","streamingBehavior":"steer"}}
{"type":"emit_inbound","label":"response:prompt","frame":{"type":"response","command":"prompt","success":true,"data":{"disposition":"started"}}}
{"type":"emit_inbound","label":"agent_start","frame":{"type":"agent_start"}}
Expand Down
Loading
Loading