Skip to content

fix(vscode): restore usage footers when reopening chats - #1098

Merged
will-lamerton merged 3 commits into
Nano-Collective:mainfrom
RRXXZZYY:fix/1097-persist-response-usage
Sep 6, 2026
Merged

fix(vscode): restore usage footers when reopening chats#1098
will-lamerton merged 3 commits into
Nano-Collective:mainfrom
RRXXZZYY:fix/1097-persist-response-usage

Conversation

@RRXXZZYY

Copy link
Copy Markdown
Contributor

Description

Closes #1097.

Saved ACP messages now keep the completed turn's token usage and optional estimated cost on the matching assistant message. History replay emits that metadata after the response, and the VS Code panel reuses its existing usage-footer renderer, so reopening a chat restores the same token/cost line shown live.

The field is optional, so existing session files without usage metadata continue to load unchanged.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • New behavior includes passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover persistence, replay/rendering, and the no-new-assistant guard

Passed locally:

  • pnpm test:format
  • pnpm test:types
  • pnpm test:types:vscode
  • pnpm test:lint
  • pnpm test:knip (existing configuration hint only)
  • pnpm test:changesets
  • Five focused AVA regression tests
  • pnpm test:audit
  • pnpm run build
  • pnpm --dir plugins/vscode run build
  • git diff --check

The full AVA run was not green on this Windows checkout: it reported 20 hook failures, 80 test failures, 2 skipped tests, and 1 uncaught exception. The observed failures were in existing Windows path, IPC, permission, cross-device temp-file, and missing-built-CLI cases; all five new regression tests passed. Semgrep was not installed, so the repository script's documented optional security-scan fallback applies.

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

No live provider was exercised; this change is limited to post-response session persistence and local history replay.

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (changeset added; no user documentation change needed)
  • No breaking changes
  • Logging considered; no new log path is needed for metadata persistence/replay

AI assistance

AI assistance was used for implementation and test drafting. I reviewed the final diff, ran the checks above, and verified that the PR contains only the scoped fix and regression coverage.

@RRXXZZYY
RRXXZZYY force-pushed the fix/1097-persist-response-usage branch from a03d38d to 039b3ae Compare August 31, 2026 19:33
@github-actions github-actions Bot added the area:vscode VS Code extension and host integration label Aug 31, 2026
Resolves the conflict in source/acp/acp-agent.ts against Nano-Collective#1071, which moved
the turn claim (session.beginTurn()) and the try/catch above the async prompt
setup. Keeps main's structure and re-applies this branch's two changes inside
it: the previousAssistant snapshot before the user message is appended, and
capturing the runAcpConversation response so attachResponseUsage can stamp it
before the finally block persists the session.
The arrow-key test slept 20ms after each stdin.write and asserted on the
next frame. A keypress reaches Ink through stdin, so the re-render lands on
a later tick that a fixed sleep cannot bound, and on a loaded CI runner the
second arrow press was still unrendered when the assertion ran:

  Value must match expression /\[all-time\]/
  Range 7d | [3m] | all-time

Poll for the expected frame instead, with a 2s ceiling that still fails
loudly if the keypress never lands. Pre-existing flake from Nano-Collective#963, unrelated
to this branch, but it blocked this PR's Unit Tests check.
@will-lamerton
will-lamerton merged commit 8a46cd3 into Nano-Collective:main Sep 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:vscode VS Code extension and host integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Token counts and costs are lost when loading chat history

2 participants