pi-pin-last-user-message0.1.0
Pin the current turn's user message to the top row of Pi's fullscreen transcript, with turn counter and one-click jump.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-pin-last-user-message
Keeps the user message of the turn you are currently looking at pinned to the top row of Pi's fullscreen transcript.
Long sessions lose the prompt: you scroll back through tool output and no longer remember what you asked. This extension keeps a one-line bar at row 1 that follows the viewport — whatever turn is at the top, you see the user message that started it, plus which turn / how many.
❯ You 3/12 │ refactor the supplier sync to batch by 500 … 最新 · click 上一条 · ⌃⇧U
Install
pi install npm:pi-pin-last-user-message
Requires Pi ≥ 1.6 (verified against 1.6.0 dist source and running on 1.6.1) and the default fullscreen TUI mode.
What it does
- Pinned bar on row 1, full width, showing the user message of the turn at the viewport top. Scroll to any turn and the bar switches to that turn's prompt; scrolled to the bottom means the latest turn.
- Turn counter chip (
3/12, reverse-video) plus a right-hand state:最新when you are at the latest turn,↑历史when you are above it. The hint on the right degrades by width, then disappears on narrow terminals. - Click the bar = jump up to the previous user message. Same for
ctrl+shift+uand/pin-jump. /pin-align= scroll the message currently shown in the bar to the very top of the viewport (tells you when it is impossible, e.g. the last turn is shorter than the viewport).- Wheel events over the bar pass through, so it never competes with transcript scrolling. It is a
nonCapturingoverlay: it never steals keyboard focus.
In regular mode there is no fixed viewport, so the bar is hidden and the shortcut only explains that tuiMode is needed. Switching back to fullscreen at runtime rebuilds the bar on the next turn.
Appearance
Edit the constants at the top of extensions/pin-last-user-message.ts: PIN_BG, PIN_TEXT_FG, PIN_CHIP_BG, PIN_CHIP_FG (Pi theme tokens such as userMessageBg / selectedBg / accent, or hex values like "#1e3a5f"), and PIN_COUNTER to hide the turn counter. Installed packages are copies, so change the file there and /reload — or fork this repo.
How it works
- The bar is
ctx.ui.custom({ overlay: true, overlayOptions: { anchor: "top-center", row: 0, nonCapturing: true } }), re-rendered every frame while scrolling. - It renders the transcript document and indexes the lines that start with
OSC 133;Aand carry theuserMessageBgbackground — that is what distinguishes user messages from assistant messages. render()readsscrollTopdirectly, so "live" needs no timer and no scroll hook: a scroll already triggers a cheap frame. The index is cached percontentWidth:contentHeight, and finished lines are cached per(width, text, counter, state, theme), so scrolling stays O(viewport).- Text comes from the rendered lines (ANSI stripped), so it matches the screen exactly, including after
/treebranch switches and compaction. - It reads two runtime-private fields (
TuiAltScreen.layoutRoot,TUI.overlayStack) through try/catch. If they are gone in a future Pi release, it falls back to the session's last user message plus the built-inscrollToPrompt(-1).
Caveats
- Fullscreen mode only (the default). Not useful in
regularmode. - Deep-coupling to Pi internals: the private-field probing above is the first thing to check if a Pi upgrade breaks the bar.
- Colors are constants, not settings entries.
中文说明
把「你正在看的那一轮对话」的用户消息常驻在屏幕第 1 行:滚到哪一轮就显示那条提问,右侧标出「第几轮/共几轮」和 最新 / ↑历史;左键点击置顶条或按 ctrl+shift+u(等价 /pin-jump)跳到上一条用户消息,/pin-align 把当前这条对齐到视口顶端。只在默认的 fullscreen 模式下生效,regular 模式不显示。颜色/序号开关改文件顶部常量后 /reload。
Development
npm install # public registry, dev-only type deps
npm run typecheck
pi install ./ # install the working copy
License
MIT