[BUG] Desktop (Windows): claude://resume imports a CLI session that is still running (claude -p) and starts a second process on it

Aperta
#111,489 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
desktop

Direzione di ricerca

The repro is fully specified, but the code named in the report (resumeCliSessionNow, importCliSession with its beforeWrite hook, liveOwnershipRefusal, the deep-link handler) lives in the bundled desktop build, not in this repository, so the first step is confirming whether any of that source is reachable here. Reproduce with claude -p --session-id <uuid> plus claude://resume?session=<uuid> and watch the .jsonl in ~/.claude/projects/<project>/ and main.log. Done looks like the deep link running the same live-ownership refusal as the in-app picker.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:desktop bug has repro platform:windows

Environment

  • Claude desktop 6.28899.2.0 (Windows 11, Microsoft Store/MSIX build)
  • Claude Code 2.1.328 (bundled)

Summary

claude://resume?session=<id> imports a CLI session even while a headless claude -p --session-id <id> run is still writing it. The desktop copies the transcript as it is at that moment, shows it as idle, and starts its own Claude Code process on the same session about 0.1 s later. Two processes then own one session: they write to the same transcript (a duplicate or forked conversation), or the desktop shows a frozen copy while the run continues unseen.

The in-app resume picker checks for a live owner before importing and refuses. The deep-link path skips that check.

Steps to reproduce

  1. Start a long headless run: claude -p --session-id <uuid> "<a task that takes a few minutes>".
  2. While it is still running, open claude://resume?session=<uuid>.
  3. Watch the desktop session and ~/.claude/projects/<project>/<uuid>.jsonl.

Expected

The same behaviour as the in-app resume picker: refuse or wait while the session is running, or follow it read-only until the run ends and then hand it over.

Actual

main.log:

[info] Resume deep link: importing CLI session <id>
[info] Imported CLI session <id> as Desktop session local_<id>
[info] [CCD] Warming session local_<id>
[info] [CCD] Session local_<id> warmed successfully in 110ms

The desktop shows the snapshot as an idle session, and the headless process keeps appending to <id>.jsonl. If the user continues in the desktop, entries with entrypoint: "sdk-cli" and entrypoint: "claude-desktop" interleave in the same transcript.

Data (from 11 days of main.log and the transcripts)

  • 71 resume links in total.
  • 59 were opened after the headless run had ended. All continued cleanly, with no further sdk-cli writes after the import.
  • 11 links (10 sessions) were opened mid-run:
    • 7 sessions got writes from both processes after the import. In 6 the writes were concurrent, for up to about 28 minutes (one run wrote 347 entries after the desktop had started its own process).
    • 3 sessions showed a frozen snapshot while the run kept working for 1 to 5 minutes.

Notes from the bundled code (may be wrong)

  • The resume picker path (resumeCliSessionNow) calls importCliSession with a beforeWrite hook that runs liveOwnershipRefusal and turns a live owner into a refusal.
  • The deep-link handler calls importCliSession(id) with no options, so no live-ownership check runs. The imported record is created with isRunning: false, and the session is warmed straight away.

Related

  • #80773 (a resume link duplicates a session already open as a native Desktop tab)
  • #99349 (a resume link handled twice breaks worktree sessions)
Lingua principale
TypeScript
Stelle
156k
Fork
25k
Merge medio
16h 19m
PR unite (30g)
5

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anthropics/claude-code

Tutte le issue di anthropics/claude-code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.