Skip to content

Commit 09b5489

Browse files
committed
fix(web): retain explicit full-history preferences across sends
1 parent cb367fe commit 09b5489

3 files changed

Lines changed: 22 additions & 29 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7635,8 +7635,8 @@ export default function ChatView(props: ChatViewProps) {
76357635
: t("chat.view.compactUnavailable")
76367636
: null;
76377637
// Tokens a stale Claude session would re-read on its next turn. While set,
7638-
// the composer shows a Compact chip and Enter compacts first; turning the
7639-
// chip off sends the next message with full history. Held queues and
7638+
// the composer offers Full/Compact, defaulting to Full until the user opts
7639+
// into compaction. Held queues and
76407640
// multi-model sends never compact first, so the offer hides for them.
76417641
const resumeCompactionTokens =
76427642
activeContextWindow &&
@@ -7655,22 +7655,16 @@ export default function ChatView(props: ChatViewProps) {
76557655
})
76567656
? activeContextWindow.usedTokens
76577657
: null;
7658-
// Threads whose Compact chip is turned off. A send that starts its turn
7659-
// clears its thread's entry; a failed send keeps it for the retry.
7660-
const [fullHistoryThreadKeys, setFullHistoryThreadKeys] = useState<ReadonlySet<string>>(
7661-
() => new Set(),
7662-
);
7663-
const keepFullHistory = fullHistoryThreadKeys.has(routeThreadKey);
7664-
const setKeepFullHistory = (threadKey: string, keep: boolean) => {
7665-
setFullHistoryThreadKeys((current) => {
7666-
if (current.has(threadKey) === keep) return current;
7667-
const next = new Set(current);
7668-
if (keep) next.add(threadKey);
7669-
else next.delete(threadKey);
7670-
return next;
7671-
});
7672-
};
7673-
const toggleKeepFullHistory = () => setKeepFullHistory(routeThreadKey, !keepFullHistory);
7658+
// Resuming a large thread must not silently replace history with a summary.
7659+
// Keep this explicit choice across sends and reloads, scoped to this client,
7660+
// environment, and thread. Existing installations start with full history.
7661+
const [compactOnResume, setCompactOnResume] = useLocalStorage(
7662+
`t3code:compact-on-resume:${routeThreadKey}`,
7663+
false,
7664+
Schema.Boolean,
7665+
);
7666+
const keepFullHistory = !compactOnResume;
7667+
const toggleKeepFullHistory = () => setCompactOnResume((compact) => !compact);
76747668
const toggleKeepFullHistoryStable = useStableCallback(toggleKeepFullHistory);
76757669
const handleRestoreThreadBranch = () => {
76767670
if (!canWriteSourceControl) return;
@@ -9187,9 +9181,8 @@ export default function ChatView(props: ChatViewProps) {
91879181
);
91889182
const messageIdForSend = newMessageId();
91899183
const messageCreatedAt = new Date().toISOString();
9190-
// A stale Claude session compacts before this message so the turn does not re-read the
9191-
// old history. The message queues behind the /compact run, since steering into it is
9192-
// rejected.
9184+
// Only an explicit Compact preference puts this message behind a /compact
9185+
// run. Full history sends through the normal dispatch path.
91939186
const compactBeforeSend =
91949187
resumeCompactionTokens !== null &&
91959188
!keepFullHistory &&
@@ -9918,7 +9911,6 @@ export default function ChatView(props: ChatViewProps) {
99189911
failure = startResult;
99199912
} else {
99209913
turnStartSucceeded = true;
9921-
setKeepFullHistory(routeThreadKey, false);
99229914
// The turn is under way and will spend quota, so that thread's limits
99239915
// snapshot is stale. Uploads may have outlasted a navigation, so only
99249916
// the sending thread's panel clears.

‎apps/web/src/components/chat/ComposerPrimaryActions.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface ComposerPrimaryActionsProps {
5353
onPreviousPendingQuestion: () => void;
5454
onInterrupt: () => void;
5555
onImplementPlanInNewThread: () => void;
56-
/** Tokens a stale session would re-read. When set, a Compact chip shows the count and Enter compacts first. */
56+
/** Tokens a stale session would re-read. When set, a Full/Compact chip lets the user choose whether to summarize. */
5757
compactBeforeSendTokens?: number | null;
5858
/** The Compact chip is turned off, so the next send keeps full history. */
5959
keepFullHistory?: boolean;
@@ -112,7 +112,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
112112
onInterrupt,
113113
onImplementPlanInNewThread,
114114
compactBeforeSendTokens = null,
115-
keepFullHistory = false,
115+
keepFullHistory = true,
116116
onToggleKeepFullHistory,
117117
}: ComposerPrimaryActionsProps) {
118118
const { t } = useI18n();
@@ -397,7 +397,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
397397
}
398398
>
399399
<Minimize2Icon aria-hidden="true" />
400-
{keepFullHistory ? t("settings.label.full") : t("chat.view.compact")}
400+
{keepFullHistory ? t("chat.ui.fullHistory") : t("chat.view.compact")}
401401
<span>{compactTokens}</span>
402402
</TooltipTrigger>
403403
<TooltipPopup>

‎docs/user/providers-claude.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ window. Leave it empty for Claude Code's default.
5050

5151
You can also send `/compact` in an existing conversation. Web and desktop offer
5252
**Compact context** from the context meter. When you return to a large thread
53-
after Claude's prompt cache expires, a **Compact** chip with the thread's token count shows
54-
next to the send button. While it is on, Enter summarizes the history first, then
55-
sends your message. Click the chip to switch it to **Full** and keep the full
56-
history for that message. The cache lasts about an hour on a Claude
53+
after Claude's prompt cache expires, a **Full** chip with the thread's token count shows
54+
next to the send button. Full history is the default. Click the chip to choose
55+
**Compact** if you want Enter to summarize the history first, then send your message.
56+
The client remembers this choice for the environment and thread across sends and
57+
reloads. Switch back to **Full** to keep the complete history. The cache lasts about an hour on a Claude
5758
subscription and 5 minutes with an API key, Bedrock, or Vertex. See [commands and skills](./composer.md#commands-and-skills) for using
5859
composer commands.
5960

0 commit comments

Comments
 (0)