pi-codex-compaction 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This project follows the spirit of [Keep a Changelog](https://keepachangelog.com
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.5] - 2026-09-17
10
+
11
+ ### Fixed
12
+
13
+ - Persist the Codex compaction confirmation as a rendered, non-model session entry so Pi's post-compaction chat rebuild does not erase it.
14
+
9
15
  ## [0.1.4] - 2026-09-15
10
16
 
11
17
  ### Added
package/README.md CHANGED
@@ -37,8 +37,9 @@ pi -e /path/to/pi-mono/packages/pi-codex-compaction
37
37
 
38
38
  After a Codex checkpoint is saved, the TUI shows
39
39
  `[compaction (codex)] Checkpoint saved.` Pi's built-in `[compaction]` heading
40
- remains unchanged. The notice is not added to model context or stored in the
41
- session, and is not replayed on reload. Standard Pi compaction does not show it.
40
+ remains unchanged. The notice is stored as a TUI-only custom session entry, so it
41
+ survives the compaction chat rebuild and reload. It is not added to model context.
42
+ Standard Pi compaction does not create a Codex success notice.
42
43
  Print, JSON, and RPC modes receive no extra notification.
43
44
 
44
45
  When Pi starts compaction on a supported Codex model, the extension sends a streamed Responses request whose `input` contains only discardable history, any compatible prior checkpoint, and a `compaction_trigger` item. The normal request envelope is retained because Codex's compaction path is parity-tested against ordinary Responses requests; this includes the effective system prompt, active tool definitions, reasoning level, prompt-cache fields, and routing fields. The request uses the `remote_compaction_v2` beta feature, and the returned opaque checkpoint and bounded provider usage are stored in the Pi compaction entry. Later requests rehydrate the raw checkpoint only when the model, endpoint, account, and authentication mode match; other providers/models receive the bounded textual fallback instead.
@@ -111,6 +112,11 @@ Costs follow Pi's catalog estimates. They are not a ChatGPT subscription bill.
111
112
 
112
113
  ### Reference and smoke test
113
114
 
115
+ The automated display smoke tests exercise Pi's actual compaction-end handler
116
+ and chat renderer for manual, threshold, and overflow compaction. They check
117
+ redraw, reload, standard compaction, and exclusion from subsequent model requests.
118
+ Only provider responses and terminal I/O are replaced with local fixtures.
119
+
114
120
  Behavior was checked against `openai/codex` commit
115
121
  `654b0a77d0d2f81aa21f61caf7af4be88fe550bb` (2026-09-11), notably
116
122
  `core/src/compact_remote_v2{,_attempt}.rs`. No Codex code was copied.
@@ -119,9 +125,10 @@ API. Async tools and mid-turn steering require upstream Pi support.
119
125
 
120
126
  For a small live test, load this package and select `openai-codex/gpt-6-astra`.
121
127
  Send two short messages, run `/compact`, then ask about the first message.
122
- Confirm `[compaction (codex)] Checkpoint saved.` appears. Then run
128
+ Confirm `[compaction (codex)] Checkpoint saved.` remains visible after the
129
+ compaction finishes and after `/reload`. Then run
123
130
  `/compact Focus on recent work` and confirm the standard-compaction warning
124
- appears without a Codex success notice.
131
+ appears without a new Codex success notice.
125
132
  Repeat with `/fast on` and `pi-codex-tools` loaded. Check that compaction succeeds,
126
133
  the continuation retains context, and session usage includes compaction tokens.
127
134
  Use only a temporary file if you test `apply_patch`. Do not generate images.
@@ -3,6 +3,7 @@ import type {
3
3
  ExtensionHandler,
4
4
  SessionBeforeCompactEvent,
5
5
  } from "@earendil-works/pi-coding-agent";
6
+ import { Text } from "@earendil-works/pi-tui";
6
7
  import { BETA_FEATURE, getCodexAccountFingerprint } from "../src/codex-wire.js";
7
8
  import { reportInstallTelemetry } from "../src/install-telemetry.js";
8
9
  import {
@@ -26,9 +27,15 @@ const FALLBACK_MESSAGES: Record<CompactionFallback["reason"], string> = {
26
27
  "remote-failed": "the remote request failed",
27
28
  };
28
29
 
30
+ const COMPACTION_SAVED_ENTRY = "pi-codex-compaction:saved:v1";
31
+
29
32
  export default function piCodexCompaction(pi: ExtensionAPI): void {
30
33
  reportInstallTelemetry();
31
34
 
35
+ pi.registerEntryRenderer(COMPACTION_SAVED_ENTRY, (_entry, _options, theme) =>
36
+ new Text(theme.fg("dim", "[compaction (codex)] Checkpoint saved."), 1, 0),
37
+ );
38
+
32
39
  const onBeforeCompact: ExtensionHandler<SessionBeforeCompactEvent, { compaction?: NonNullable<Awaited<ReturnType<typeof createRemoteCompaction>>> }> = async (event, ctx) => {
33
40
  if (!supportsRemoteCompaction(ctx.model)) return undefined;
34
41
 
@@ -88,7 +95,9 @@ export default function piCodexCompaction(pi: ExtensionAPI): void {
88
95
  if (ctx.mode !== "tui" || !ctx.hasUI || !event.fromExtension) return;
89
96
  if (!findActiveRemoteCompaction([event.compactionEntry])) return;
90
97
  try {
91
- ctx.ui.notify("[compaction (codex)] Checkpoint saved.", "info");
98
+ // Pi rebuilds chat after session_compact, removing transient notifications.
99
+ // A rendered custom entry survives that rebuild without entering LLM context.
100
+ pi.appendEntry(COMPACTION_SAVED_ENTRY, { version: 1 });
92
101
  } catch {
93
102
  // Display failures must not affect a saved checkpoint or continuation.
94
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-codex-compaction",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Use OpenAI Codex RemoteCompactionV2 for supported Pi sessions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,11 +49,13 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@earendil-works/pi-ai": "*",
52
- "@earendil-works/pi-coding-agent": "*"
52
+ "@earendil-works/pi-coding-agent": "*",
53
+ "@earendil-works/pi-tui": "*"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@earendil-works/pi-ai": "^0.85.1",
56
57
  "@earendil-works/pi-coding-agent": "^0.85.1",
58
+ "@earendil-works/pi-tui": "^0.85.1",
57
59
  "@types/node": "^26.2.0",
58
60
  "tsx": "^4.23.5",
59
61
  "typescript": "^7.0.2"