Skip to content

Clarify premium status when the threshold has already been reached #29

Description

@boadij

Summary

After navigating through the Pi session tree, Downshift can correctly restore a branch's recorded premium phase even when that branch's current context usage is already at or above the configured threshold.

The footer currently renders this state as:

⇣ premium (0% left)

This is technically accurate, but ambiguous. It can look as though Downshift failed to recognize the threshold or failed to switch to economy.

Context

This behavior follows the branch-restoration semantics introduced by #27:

  • /tree restores the destination branch's recorded premium/economy phase.
  • Navigation itself does not evaluate the threshold or generate a handoff.
  • The next context event performs the normal threshold decision.

The issue is therefore the status presentation, not the branch reconciliation behavior.

Observed configuration

Downshift v0.6.2
threshold: 15%
economy: openai-codex/gpt-5.6-luna:high
premium: explicit (openai-codex/gpt-5.6-sol:high)
start on premium: yes
upshift after compaction: yes
handoff note: no

Reproduction

  1. Configure a percent threshold, for example 15%.
  2. Navigate with /tree to a branch whose persisted Downshift phase is premium.
  3. Ensure the restored branch's context usage is already at or above the threshold.
  4. Observe the footer immediately after navigation.

Current behavior

The footer displays:

⇣ premium (0% left)

Downshift remains in the restored premium phase until the next normal context evaluation. With handoff disabled, that evaluation then switches directly to economy.

Expected behavior

The footer should distinguish between:

  • premium with remaining threshold budget, and
  • premium with the threshold already reached.

Suggested wording:

⇣ premium (threshold reached)

For combined token and percent thresholds, the status should remain deterministic and compact while clearly indicating when any configured threshold has been reached.

Proposed implementation

Update statusText() so that when:

  • Downshift is enabled,
  • the current position is premium, and
  • thresholdReached(usage, config.threshold) is true,

it returns an explicit threshold-reached status instead of clamping the remaining value to zero.

The threshold decision and model-switch behavior should remain unchanged.

Non-goals

  • Do not evaluate thresholds during session_tree.
  • Do not switch to economy as part of tree navigation.
  • Do not change branch phase restoration.
  • Do not generate a handoff during passive reconciliation.
  • Do not alter threshold comparison semantics.

Acceptance criteria

  • A premium branch below all configured thresholds continues to show its remaining budget.
  • A premium branch at or above a configured threshold shows an explicit threshold reached status.
  • Economy, paused, off, requested-handoff, and active-handoff status text remains unchanged.
  • Token-only thresholds are covered.
  • Percent-only thresholds are covered.
  • Combined token and percent thresholds are covered.
  • Tree navigation behavior remains position-only reconciliation.
  • Existing threshold downshift and compaction upshift behavior remains unchanged.

Test coverage

Add focused statusText() tests for:

  • percent threshold below, exactly at, and above the limit,
  • token threshold below, exactly at, and above the limit,
  • combined thresholds where one threshold has been reached,
  • unchanged economy and safety-state output.

Add an adapter-level regression test showing that session_tree may restore premium above threshold, displays the clarified status, sends no handoff, and leaves switching to the next context event.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions