# Qwen Code

> Import Qwen Code chats, tool results, images, checkpoints, prompt logs, and subagent sessions.

Hansard imports Qwen Code history from both the older `tmp/` folder layout and
the current `projects/` layout, and skips temporary runtime files. The native
CLI `0.24.7` has been tested with a local synthetic endpoint. Desktop, editor,
SDK, daemon, and messaging interfaces need separate acquisition trials.

Qwen Chat is a separate product. The [coverage reference](https://www.hansard.dev/reference/import-coverage/)
tracks Qwen Code's desktop, browser, editor, SDK, messaging and batch surfaces
independently. A browser connected to a Qwen Code daemon does not establish
cloud execution.

## Source IDs

| Source      | Use it for                                                                                            |
| ----------- | ----------------------------------------------------------------------------------------------------- |
| `qwen-code` | Qwen Code prompt logs, manual checkpoints, saved chats, archived chats, and linked subagent sessions. |

## How the import works

Hansard scans Qwen Code's folder (`~/.qwen` by default) for project prompt logs
and manual checkpoints, older single-file JSON chats, and current or archived
JSONL chat trees. For a chat tree, Hansard starts at the last entry in the file
and follows each entry's parent back to the start, which is the branch Qwen
Code resumes. Pieces of one message that share an ID are combined. Entries on
abandoned branches stay only in the archive's copy of the original file.

Subagent records become their own linked conversations. Scheduled prompts and
runtime notices are kept as context, not as messages you typed. When an
automatic chat transcript covers the same session as a prompt log, the
transcript replaces the prompt-only session. Manual checkpoints stay separate
sessions. Older single-file chats do not record a working directory, so Hansard
leaves them without a project instead of guessing one.

When Qwen Code's shared `usage_record.jsonl` has a matching entry, Hansard adds
its duration, tool results, and edited-line counts to the session. The archive
keeps an exact copy of the usage file as Hansard read it.

Assistant records name the requested model, while API telemetry and the usage
ledger can name a different response model. Hansard preserves the assistant's
recorded model and the independent ledger summary without substituting one
for the other. Telemetry alone does not establish a message-to-response link.

Qwen Code 0.25.0 state records preserve model selections, approval state,
retries, child readiness, turn outcomes, context recall and branch checkpoints.
Source snapshots do not change the active parent chain. Managed-session
headers, events and commit markers remain typed source records. Hansard does
not project their internal events into additional turns or billing counters.

## Import and keep current

**Import now**

```sh
hansard import --source qwen-code --since all
hansard index rebuild
```

You do not need Qwen Code installed to import its saved history.

**Keep current**

With **Automatic** source selection, the watcher still includes `qwen-code`,
so anything new in Qwen Code's folder is archived. Hansard does not install,
start, or configure Qwen Code.

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **Qwen Code** and set **Time** to the window you imported. Use **Folder** to narrow the list when you use this harness in several projects.
3. Select a conversation to check its messages, tool calls, files, commits, model, and token usage.

To keep archiving new sessions from a local harness, open **Settings → Imports**. **Automatic** follows every supported harness installed on this computer. **Custom** lets you turn individual harnesses on or off. Cloud sources and account exports never run from here; each needs its own import command. If a conversation you expect is missing after you reset the filters, run the import command on this page again with `--explain-skips` where the source supports it.

## What Hansard preserves

- Chat messages, reasoning, tool calls and results, diffs, and token usage for
  each message.
- Native tool failure statuses, structured shell output and exit codes, and
  the actual file patch, which takes precedence over requested edit text.
- Embedded image bytes on user messages and tool results. External file
  references remain unavailable when their bytes were not recorded.
- Prompt-only sessions and manual checkpoints with their paths.
- Archived chats, and each subagent journal as a linked conversation.
- Scheduled prompts and runtime notices as context rather than your own
  messages.
- Exact copies of the original files, including the shared usage file.

## Known limitations

- Lock files, temporary streams, and other files Qwen Code used while running
  are not imported.
- A chat tree with an unknown record type or a broken parent chain is not
  imported, rather than read with the closest known format.
- The historical format audit covers releases through `0.21.8`. A separate
  native `0.24.7` trial verifies initial and resumed turns, edits, failures,
  an image result, repeat import, and offline raw rebuild. Other clients,
  branches, compaction, uploads, hosted accounting, and full viewer acceptance
  remain unverified.
- A separate upstream audit covers CLI `0.25.0` with synthetic regressions.
  It does not establish coverage of every intervening historical release.
  No local `0.25.0` store was available for native acceptance. Managed-session
  transaction verification and resource reconstruction remain unimplemented.
- A model that cannot read images may save a skipped-image notice without any
  image bytes. That notice remains a tool result; it is not an attachment.
- Daemon JSON and JSONL exports are different from native chat files and are
  not accepted by this importer. A native export trial omitted embedded image
  bytes, per-message models and some message-level usage. Keep the original
  Qwen Code folder when it is available.

## Refresh an existing archive

To update Qwen Code conversations that an older Hansard version imported,
reimport them from Qwen Code's original files:

```sh
hansard import --source qwen-code --since all
hansard index rebuild
```

The current parser corrects failed-tool and changed-line accounting, preserves
structured results and images, and binds the shared usage ledger for raw
rebuild. Sessions archived by an earlier parser need a reimport to establish
that binding. Afterward,
if original files disappear, use the verified preserved copies:

```sh
hansard rebuild --from-raw --provider qwen --since all
```
