Skip to content

feat(sessions): add compact option to stale conversation cost warning#3154

Merged
charlesvien merged 1 commit into
mainfrom
posthog-code/stale-conversation-compact-button
Jul 5, 2026
Merged

feat(sessions): add compact option to stale conversation cost warning#3154
charlesvien merged 1 commit into
mainfrom
posthog-code/stale-conversation-compact-button

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

When a large, idle conversation's prompt cache has expired, staff get a warning that continuing will re-process the whole thread at full input price (the "≈$33" notice). The dialog only offered two ways out: Continue anyway (pay the full reload) or Not now (pause). There was no way to keep the thread's context without the expensive reload, so the useful middle option — compacting — was missing.

Changes

Add a Compact instead action to StaleConversationCostDialog. It runs the agent's existing manual-compaction command (/compact), summarizing the history so the thread's context shrinks to a fraction of its size instead of being reloaded whole or thrown away.

  • StaleConversationCostDialog gains an onCompact prop and a third button; the copy now names compaction as the cheap middle path.
  • SessionView wires onCompact to acknowledge the gate (closing the dialog and unlocking the composer) and send /compact, which surfaces the usual "Compacting conversation history…" progress.

Screenshots: n/a (copy + one button in an existing dialog).

How did you test this?

  • biome check on both changed files (clean).
  • Manual reasoning through the gate flow: /compact is the same command the context-error tip already directs users to type, sent through the normal prompt path, so it queues/spawns like any message and drives the existing compaction UI.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog from a Slack thread

The stale-costly-conversation dialog previously offered only "Continue anyway" (pay full input price) or "Not now". Add a "Compact instead" action that runs the agent's existing `/compact` command, so the user can shrink the thread's context in place rather than reloading it whole or losing the context by starting fresh.

Generated-By: PostHog Code
Task-Id: d2fc766b-7a43-4840-859b-efc65c2a3965
@trunk-io

trunk-io Bot commented Jul 5, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit a8bf734.

@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(sessions): add compact option to st..." | Re-trigger Greptile

@charlesvien charlesvien marked this pull request as ready for review July 5, 2026 21:11
@charlesvien charlesvien added Stamphog This will request an autostamp by stamphog on small changes Create Release This will trigger a new release labels Jul 5, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small UI-only change that adds a "Compact instead" button to the stale session cost dialog. The implementation is straightforward — it reuses the existing onContinue gate-clear path and dispatches /compact via onSendPrompt. No data models, API contracts, or business logic touched.

@charlesvien charlesvien merged commit cab5b24 into main Jul 5, 2026
30 checks passed
@charlesvien charlesvien deleted the posthog-code/stale-conversation-compact-button branch July 5, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant