pi-edit-last
Restore the last user message to the Pi editor using session tree navigation.
Package details
Install pi-edit-last from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-edit-last- Package
pi-edit-last- Version
0.1.1- Published
- Oct 10, 2026
- Downloads
- 474/mo · 474/wk
- Author
- tong233
- License
- MIT
- Types
- extension
- Size
- 14.6 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./extensions/edit-last.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-edit-last
Restore the latest user message on the current Pi session branch to the editor, so you can edit and send it again.
Install
Requires Pi and Node.js 22.19 or later. Tested with @earendil-works/pi-coding-agent 1.1.0.
pi install npm:pi-edit-last
Run /reload in an existing Pi session, or restart Pi. You can also install from GitHub:
pi install git:github.com/tong233/pi-edit-last
If you previously installed ~/.pi/agent/extensions/edit-last.ts, move that file outside the extensions directory before installing this package to avoid duplicate commands and shortcuts. Keep a backup if you want to revert.
Use
Run /last or press Ctrl+Shift+E. Edit the restored text and press Enter when you are ready to send it. The extension does not send restored text automatically.
It uses Pi's session tree navigation, like selecting the latest user message in /tree. The active branch moves to the parent of that message. The original message and subsequent history remain available in /tree.
- Searches only the current branch; preserves multiline text and whitespace.
- Runs only in interactive TUI mode, while the agent is idle and no messages are queued.
- Protects existing drafts and drafts typed during navigation.
- Leaves messages containing images untouched; use
/treefor those. - Handles cancelled navigation and session changes without overwriting the editor.
Session navigation does not undo file changes, commands, or other side effects. Use Git or another appropriate tool to undo those separately. Keyboard shortcuts may conflict with terminal settings or other extensions.
When the latest user message is also the current leaf, the extension adds an internal edit-last-anchor entry before navigating. This entry is excluded from model context and avoids Pi's no-op navigation to the current leaf.
Notifications, command descriptions, and shortcut descriptions use English.
Update or remove
pi update npm:pi-edit-last
pi remove npm:pi-edit-last
Develop
npm ci
npm run check
npm test
pi -e ./extensions/edit-last.ts
Tests include safeguards and integration with Pi's actual resource loader, session tree, and shortcut command dispatch. They make no model requests. Pi loads the TypeScript source directly; no build step or bundled host runtime is needed.
Distribution
This is both an npm package and a Pi package. The pi.extensions manifest declares the entry point; the pi-package keyword makes it eligible for discovery at pi.dev/packages. Gallery indexing is managed by Pi and may not be immediate.
See CONTRIBUTING.md for first publication and subsequent automated releases.