Skip to content

feat(nudge): persist nudge injections as display-only session entries (closes #326) - #514

Closed
liu-zhengdong wants to merge 1 commit into
ranxianglei:masterfrom
liu-zhengdong:feat/persist-nudge-records
Closed

liu-zhengdong wants to merge 1 commit into
ranxianglei:masterfrom
liu-zhengdong:feat/persist-nudge-records

Conversation

@liu-zhengdong

Copy link
Copy Markdown

Closes #326. Supersedes #329 (rebased and resolved cleanly on current master v0.1.76).

Summary

When a context-limit nudge is injected, it was previously only shown transiently via ctx.ui.notify() (if debug mode was on), and never written to the session log. Restarts or resuming sessions would wipe all injection history, and multi-line nudge logs spilled onto un-tagged physical lines in acp.log.

Changes

  1. Persistence & TUI rendering (src/index.ts):
    • On injection, append a compact record ([ACP nudge] EMERGENCY 95% · T1 · top range m00120–m00168) via pi.appendEntry("acp-nudge", { text }).
    • Deduped per user turn via runtime.markNudgeRecorded() to prevent spamming the session file during repeated emergency LLM retries.
    • Register an entry renderer with dim box styling using @earendil-works/pi-tui (Box, Text), making records visible in TUI scrollback across process restarts.
    • Zero LLM context pollution: Pi's type: "custom" entries are structurally excluded from core message projection.
  2. Single-line logging (src/log.ts):
    • Escape \r and \n in string fields so every log entry strictly occupies one physical line for clean grep-ability.
  3. Tests & Docs:
    • Added tests/nudge-record.test.ts (format unit test, integration persistence test, entry renderer test) and tests/log.test.ts single-line test.
    • Updated CHANGELOG.md, README.md, and README.zh-CN.md.

Verification

  • npm run typecheck: PASS
  • npm test: PASS (470 tests pass)
  • npm run build: PASS (dist built self-contained, pi-tui inlined)

@liu-zhengdong

Copy link
Copy Markdown
Author

Re-opening with branch name matching repo convention YYYY-MM-DD_short-title

@liu-zhengdong
liu-zhengdong deleted the feat/persist-nudge-records branch September 23, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] Persist nudge echoes as session entries (survive restarts, grep-able log)

1 participant