Skip to content

feat: include tool context in session history export - #42

Open
johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-41-export-tool-context
Open

johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-41-export-tool-context

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

The history Export button now writes a self-contained markdown file. Tool entries keep their full input beside the output with the same Done, Failed, and Running wording as the tool cards, assistant thinking is kept, and the file opens with the session title, working folder, and model before downloading under a title-and-date filename.

Part of #4
Closes #41

What changed:

  • src/renderer/export-session.ts adds a pure sessionExportMarkdown and sessionExportFilename. Tool sections use the card status wording, fence input and output with a fence that widens past any backticks inside, and keep the No input. and No output. wording for empty sides. User text sits under You, assistant text and thinking sit under Pi, and an empty selection says so instead of writing a bare heading.
  • src/renderer/App.tsx builds the export through the helper with the previewed session title, working folder, and model, and downloads under the generated filename. The blob, anchor, and revoke flow are unchanged.
  • tests/unit/export-session.test.ts adds seven tests covering a full document match, failed and running status, empty input and output, backtick fence widening, the empty selection, and filename slugs with their fallback.

Verified:

  • bun install --frozen-lockfile passed
  • bun run lint passed, 0 warnings and 0 errors
  • bun run typecheck passed across renderer, main, and preload configs
  • bun run test:unit passed, 81 tests. The new tests are writes the full conversation with context and tool input, marks failed and running tools with the card wording, keeps an empty input and output readable, widens the fence when the output holds backticks, handles an empty selection and a blank title, builds the name from the title and export day, and falls back when the title has no usable words.
  • mise exec -- bun run test:integration passed, 46 tests. A bare-shell run shows 6 failures in SettingsView.test.tsx from a localStorage setup error, and the same 6 fail on clean origin/main at 1a1c91e in this environment, so they are pre-existing here and not caused by this change.
  • mise run build passed after mise trust for this worktree, ending in a successful Vite bundle.
  • bun run test:e2e blocked in this environment. Electron fails to launch and all 43 e2e tests skip with 5 failed files and 3 errors, matching the earlier runs on this machine. Noted once here and not retried.

Proof:

  • Capture method (a) was blocked by the Electron launch failure above, so capture method (d) carries the proof. Running the shipped helper with bun /tmp/proof-export.ts printed the exact file a user downloads. The transcript sits under .tmp/proof/export-sample.txt locally and the sample output is pasted in full below.
# Fix the export

Exported from pidex at 2026-11-08T01:02:03.000Z.

It ran in `/repo/app`.

It used `anthropic/claude-test`.

## You

Move this work to the api repo.

## Pi

I checked the handler and ran the tests.

### Thinking

start from the failing route

## bash / bun run test:unit (Done)

### Input

```
bun run test:unit
```

### Output

```
74 passed
```

## edit / /repo/api/src/route.ts (Done)

### Input

```
/repo/api/src/route.ts

Old:
const a = 1;

New:
const a = 2;
```

### Output

```
Edited /repo/api/src/route.ts
```

filename: pidex-fix-the-export-2026-11-08.md

Known gaps and follow-ups:

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.

Include tool input, status, and session context in the history markdown export

1 participant