Skip to content

Commit 7dbefb0

Browse files
fix(mobile): kept history stays visible and can be switched back to compact
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bb26926 commit 7dbefb0

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ export interface ThreadDetailScreenProps {
249249
/** Set while the next send compacts the thread first. */
250250
readonly compactBeforeSend?: {
251251
readonly tokens: number;
252-
readonly keepFullHistory: () => void;
252+
readonly keepFullHistory: boolean;
253+
readonly toggleKeepFullHistory: () => void;
253254
} | null;
254255
readonly creationState:
255256
| {
@@ -1691,11 +1692,19 @@ function ThreadDetailBody(
16911692
{props.compactBeforeSend ? (
16921693
<View className="px-4 pb-3">
16931694
<Notice
1694-
message={`Your next message compacts ${formatTokens(props.compactBeforeSend.tokens)} tokens of history first.`}
1695+
message={
1696+
props.compactBeforeSend.keepFullHistory
1697+
? `Your next message keeps all ${formatTokens(props.compactBeforeSend.tokens)} tokens of history.`
1698+
: `Your next message compacts ${formatTokens(props.compactBeforeSend.tokens)} tokens of history first.`
1699+
}
16951700
icon="arrow.down.right.and.arrow.up.left"
16961701
floating
1697-
onDismiss={props.compactBeforeSend.keepFullHistory}
1698-
dismissLabel="Keep the full history"
1702+
onDismiss={props.compactBeforeSend.toggleKeepFullHistory}
1703+
dismissLabel={
1704+
props.compactBeforeSend.keepFullHistory
1705+
? "Compact first"
1706+
: "Keep the full history"
1707+
}
16991708
/>
17001709
</View>
17011710
) : null}

‎apps/mobile/src/state/thread-task-permissions.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,23 @@ describe("mobile task permissions", () => {
346346
expect.not.objectContaining({ compactBeforeSend: true }),
347347
);
348348
state.draft = { ...state.draft, modelSelection: undefined };
349-
composer.compactBeforeSend?.keepFullHistory();
349+
composer.compactBeforeSend?.toggleKeepFullHistory();
350350
const kept = useThreadComposerState(NO_SIDE_CHATS);
351-
expect(kept.compactBeforeSend).toBeNull();
352-
await kept.onSendMessage();
351+
expect(kept.compactBeforeSend?.keepFullHistory).toBe(true);
352+
kept.compactBeforeSend?.toggleKeepFullHistory();
353+
const compactAgain = useThreadComposerState(NO_SIDE_CHATS);
354+
expect(compactAgain.compactBeforeSend?.keepFullHistory).toBe(false);
355+
await compactAgain.onSendMessage();
356+
expect(state.enqueue).toHaveBeenLastCalledWith(
357+
expect.objectContaining({ compactBeforeSend: true }),
358+
);
359+
compactAgain.compactBeforeSend?.toggleKeepFullHistory();
360+
await useThreadComposerState(NO_SIDE_CHATS).onSendMessage();
353361
expect(state.enqueue).toHaveBeenLastCalledWith(
354362
expect.not.objectContaining({ compactBeforeSend: true }),
355363
);
356364
// Keeping covers one send, as on web.
357-
expect(useThreadComposerState(NO_SIDE_CHATS).compactBeforeSend?.tokens).toBe(248_000);
365+
expect(useThreadComposerState(NO_SIDE_CHATS).compactBeforeSend?.keepFullHistory).toBe(false);
358366
state.freshPending = true;
359367
await composer.onSendMessage();
360368
expect(state.enqueue).toHaveBeenLastCalledWith(

‎apps/mobile/src/state/use-thread-composer-state.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,11 +892,12 @@ export function useThreadComposerState(input: {
892892
providerSubagentStatus,
893893
isCompacting,
894894
compactBeforeSend:
895-
compactTokens === null || selectedThreadKey === null || keepFullHistory
895+
compactTokens === null || selectedThreadKey === null
896896
? null
897897
: {
898898
tokens: compactTokens,
899-
keepFullHistory: () => setKeepFullHistory(selectedThreadKey, true),
899+
keepFullHistory,
900+
toggleKeepFullHistory: () => setKeepFullHistory(selectedThreadKey, !keepFullHistory),
900901
},
901902
composerDraftKey,
902903
followUpBehavior,

0 commit comments

Comments
 (0)