Skip to content

spec: configure clear command behavior#9353

Open
oz-for-oss[bot] wants to merge 1 commit intomasterfrom
oz-agent/spec-issue-9216
Open

spec: configure clear command behavior#9353
oz-for-oss[bot] wants to merge 1 commit intomasterfrom
oz-agent/spec-issue-9216

Conversation

@oz-for-oss
Copy link
Copy Markdown

@oz-for-oss oz-for-oss Bot commented Apr 29, 2026

Summary

  • Add a product spec for a configurable clear command behavior setting.
  • Add a tech spec grounded in Warp's current clear-screen, clear-buffer, terminal settings, and settings UI code paths.
  • Define the default preserve-history behavior and opt-in delete-history behavior, including validation and implementation risks.

Related issue: #9216

Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Zach Lloyd <zachlloyd@users.noreply.github.com>
@cla-bot cla-bot Bot added the cla-signed label Apr 29, 2026
@oz-for-oss oz-for-oss Bot mentioned this pull request Apr 29, 2026
2 tasks
@oz-for-oss
Copy link
Copy Markdown
Author

oz-for-oss Bot commented Apr 29, 2026

@oz-for-oss[bot]

I'm starting a first review of this spec-only pull request.

You can follow along in the session on Warp.

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

I completed the review and posted feedback on this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Author

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds product and technical specs for a configurable clear command behavior that preserves history by default and optionally deletes prior terminal history. The specs cover settings UI, model plumbing, cleanup expectations, validation, and major implementation risks.

Concerns

  • The delete-history contract is ambiguous about whether deleted output is removed only from the current rendered view or also from restored-session persistence, shared-session state, AI history/context, telemetry, and logs.
  • The primary-screen ANSI CSI 2J guidance does not precisely map to the current block-list viewport-gap behavior, which can lead to an implementation that differs from the product spec for non-shell-hook clears.
  • The design needs deterministic deduplication when a shell hook and ANSI clear sequence arrive for one logical clear.
  • Shared-session propagation is underspecified: a local model/view cleanup event is not enough to guarantee viewers observe the sharer's history deletion.
  • AI context cleanup should define pruning versus wholesale reset so unrelated user-provided context is not removed accidentally.

Security

  • Clarify the retention boundary for deleted terminal output so users and implementers do not treat a visual/session-view deletion as erasure from persistence, shared-session transport, AI conversations, telemetry, or logs unless the implementation actually guarantees that.

Verdict

Found: 0 critical, 4 important, 1 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH9216/product.md

6. **Delete session history** mode removes session history that appeared before the clear request:
- After `clear` completes, scrolling to the top of the current terminal view lands at the current prompt or the first output produced after the clear.
- Blocks that were above the clear point are no longer visible, selectable, searchable, copyable from the block list, or attachable as AI context in that terminal view.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] [SECURITY] Delete session history is framed as removing prior output, but the spec only scopes that to the current terminal view; explicitly state whether deleted blocks are purged from restored-session persistence, shared-session streams, AI conversation/history state, telemetry, and logs, or label the setting as visual-only deletion.

Comment thread specs/GH9216/tech.md
This helper owns the state cleanup required by product invariant 13:

- clear selected blocks and block-list text selection
- reset or prune AI context references to deleted blocks
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

💡 [SUGGESTION] Define whether cleanup should prune only AI context entries that reference removed blocks or reset all AI context; the product invariant only requires removed-block references to disappear, and over-resetting could drop unrelated user-added context.

Comment thread specs/GH9216/tech.md

- Add a `clear_primary_screen_all()` helper on `TerminalModel` or `BlockList` that is used when the active surface is the primary block list and `ClearMode::All` is received.
- In `TerminalModel::clear_screen(ClearMode::All)`, preserve current alternate-screen behavior. For the primary block list:
- `PreserveSessionHistory`: keep `delegate!(self.clear_screen(ClearMode::All))`, preserving today's viewport-gap behavior.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] delegate!(self.clear_screen(ClearMode::All)) does not document the block-list viewport-gap primitive and currently routes to the grid clear path, so preserve mode may not match the shell-hook behavior promised in the product spec; name the exact helper to call for primary block-list CSI 2J in each mode.

Comment thread specs/GH9216/tech.md

Do not alter `ClearMode::Saved`; it already represents an explicit saved-history deletion request and should remain independent of the new setting.

If implementation finds that shell-integrated `clear` always emits `ClearValue` before the ANSI sequence, guard against duplicate handling by ensuring a single clear request produces one history deletion. A short-lived parser/model flag for "handled clear hook during this byte-processing batch" is preferable to allowing two consecutive `ResetAndClear` passes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] Deduplication can't be conditional here: the spec applies both shell hooks and primary-screen CSI 2J, so require one logical clear to produce exactly one history deletion/model event and add the corresponding test.

Comment thread specs/GH9216/tech.md

### 7. Shared sessions and restored sessions

For shared sessions, the sharer's model mutation should determine what viewers see. Do not re-interpret the clear behavior on a viewer using the viewer's local setting; viewers should receive the resulting ordered terminal/model events and render the already-preserved or already-deleted history.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] The shared-session section says viewers receive the resulting events, but the proposed event above is local model/view cleanup; specify the shared-session protocol/persistence event or block-list reset representation so viewers cannot retain history the sharer deleted.

Copy link
Copy Markdown
Author

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds product and technical specs for a Terminal setting that preserves Warp's current clear behavior by default and lets users opt into deleting session history for shell-originated clear requests.

Concerns

  • The shared-session design is underspecified: current shared sessions replay PTY bytes to viewers, so the viewer model could apply its own clear setting instead of the sharer's chosen mutation, which conflicts with the product requirement and can leave supposedly deleted terminal history visible to viewers.

Security

  • Shared-session propagation needs an explicit protocol/model mechanism so delete-history clear requests do not depend on viewer-local settings.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH9216/tech.md

### 7. Shared sessions and restored sessions

For shared sessions, the sharer's model mutation should determine what viewers see. Do not re-interpret the clear behavior on a viewer using the viewer's local setting; viewers should receive the resulting ordered terminal/model events and render the already-preserved or already-deleted history.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] [SECURITY] This says viewers should reflect the sharer's clear behavior, but the implementation plan does not specify how to avoid viewer-local re-interpretation of shared PTY clear hook/CSI bytes. Add a shared-session protocol/model event or viewer-side rule plus tests so DeleteSessionHistory actually removes prior blocks for viewers and viewer-local settings cannot diverge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant