Skip to content

feat(code): import claude code sessions#2873

Merged
adboio merged 1 commit into
mainfrom
06-11-feat_code_import_claude_code_sessions
Jun 26, 2026
Merged

feat(code): import claude code sessions#2873
adboio merged 1 commit into
mainfrom
06-11-feat_code_import_claude_code_sessions

Conversation

@adboio

@adboio adboio commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

for activation reasons, we want users to be able to import/resume/continue claude code cli sessions in posthog code

Changes

downstack PRs set up the backend, this PR adds UX for importing sessions, rendered in the "suggestions" list on the new task page

Screenshot 2026-06-26 at 9.28.03 AM.png

Screenshot 2026-06-26 at 9.28.00 AM.png

How did you test this?

manually

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

adboio commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/task-detail/components/ContinueCliSessions.tsx

Reviewed by React Doctor for commit 6543cda.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (2)

  1. packages/workspace-server/src/services/agent/agent.ts, line 2534-2570 (link)

    P2 Silent history loss when imported session fails to load

    When loadSession throws, agentSessionId stays undefined and the code falls through to start a fresh session. The import record in the DB is never rolled back, so the source session will continue to show as "imported" in the picker — but the task opened will have no history. The user has no indication that the replay failed; they'll see a blank task conversation and likely assume the import itself failed (it didn't) or that their history is missing permanently.

    Consider surfacing this failure as a task-level error event or a toast notification so users understand the session loaded without history, rather than discovering it silently.

  2. packages/core/src/task-detail/taskCreationSaga.ts, line 859-868 (link)

    P2 Fire-and-forget branch link can leave DB branch unset while workspace.linkedBranch appears linked

    linkImportedSessionBranch fires the linkTaskBranch mutation without awaiting, while the very next line sets workspace.linkedBranch synchronously. If the IPC call fails (and the caught warning is discarded), the persistent task record will have no branch linked — but the in-flight session object sees the branch as linked, so the branch-mismatch prompt won't surface during the current session lifetime. On the next reconnect, with no linked branch in the DB, the prompt will be absent again, silently never firing.

    Since branch linking is described as "best-effort", this may be acceptable, but it is worth documenting why the in-memory assignment still happens when the async call can silently fail.

Reviews (1): Last reviewed commit: "feat(code): import claude code sessions" | Re-trigger Greptile

Comment on lines +56 to +62
export const recordCliImportInput = z.object({
sourceSessionId: z.string(),
importedSessionId: z.string(),
repoPath: z.string(),
taskId: z.string(),
fingerprint: cliSessionFingerprintSchema,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 recordCliImportInput accepts arbitrary strings for sourceSessionId and importedSessionId

Every other endpoint that uses these values as path segments (importCliSessionInput, deleteImportedCliSessionInput, deleteImportRecordInput) enforces z.string().uuid() with the comment "uuid keeps the value safe to use as a path segment." recordCliImportInput does not, even though the importedSessionId is recorded as a DB key and later passed to deleteImportedCliSessionInput / deleteImportRecordInput which do enforce UUID. The inconsistency means a caller that crafts a non-UUID importedSessionId in the record step could produce a row that is un-deletable via the delete endpoints (they'd reject the non-UUID value). In practice both values always come from the import endpoint's output, but adding .uuid() here makes the contract explicit and defends against future callers.

Suggested change
export const recordCliImportInput = z.object({
sourceSessionId: z.string(),
importedSessionId: z.string(),
repoPath: z.string(),
taskId: z.string(),
fingerprint: cliSessionFingerprintSchema,
});
export const recordCliImportInput = z.object({
/** uuid keeps the value safe to use as a path segment. */
sourceSessionId: z.string().uuid(),
/** uuid keeps the value safe to use as a path segment. */
importedSessionId: z.string().uuid(),
repoPath: z.string(),
taskId: z.string(),
fingerprint: cliSessionFingerprintSchema,
});

@adboio adboio requested a review from a team June 23, 2026 19:07
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch 2 times, most recently from 0f599e5 to 2a00a71 Compare June 23, 2026 19:45
@adboio adboio changed the base branch from main to graphite-base/2873 June 23, 2026 20:02
adboio added a commit that referenced this pull request Jun 23, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from 2a00a71 to 1a2fbf6 Compare June 23, 2026 20:02
@adboio adboio changed the base branch from graphite-base/2873 to posthog-code/import-cc-2-backend June 23, 2026 20:02
adboio added a commit that referenced this pull request Jun 24, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the posthog-code/import-cc-2-backend branch from 8cbec5f to b944070 Compare June 24, 2026 15:20
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from 1a2fbf6 to d8f4c50 Compare June 24, 2026 15:20
adboio added a commit that referenced this pull request Jun 24, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from d8f4c50 to d46b00c Compare June 24, 2026 15:40
@adboio adboio force-pushed the posthog-code/import-cc-2-backend branch from b944070 to e9a736c Compare June 24, 2026 15:40
adboio added a commit that referenced this pull request Jun 24, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the posthog-code/import-cc-2-backend branch from e9a736c to 0253564 Compare June 24, 2026 16:16
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from d46b00c to c316286 Compare June 24, 2026 16:16
adboio added a commit that referenced this pull request Jun 25, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from c316286 to 2513dfe Compare June 25, 2026 21:28
adboio added a commit that referenced this pull request Jun 25, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from 2513dfe to a00c253 Compare June 25, 2026 21:29
@adboio adboio mentioned this pull request Jun 25, 2026
2 tasks
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from a00c253 to 4f1e4ef Compare June 26, 2026 14:06
@adboio adboio marked this pull request as ready for review June 26, 2026 14:07
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "feat(code): continue a Claude Code sessi..." | Re-trigger Greptile

@adboio adboio changed the base branch from posthog-code/import-cc-2-backend to graphite-base/2873 June 26, 2026 14:32
@adboio adboio force-pushed the graphite-base/2873 branch from 0253564 to fa1ccb0 Compare June 26, 2026 14:42
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from 4f1e4ef to d393e71 Compare June 26, 2026 14:42
@adboio adboio changed the base branch from graphite-base/2873 to posthog-code/import-cc-2-backend June 26, 2026 14:42
@adboio adboio force-pushed the posthog-code/import-cc-2-backend branch from fa1ccb0 to f15ae36 Compare June 26, 2026 14:43
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from d393e71 to ead83ed Compare June 26, 2026 14:43
@adboio adboio changed the base branch from posthog-code/import-cc-2-backend to graphite-base/2873 June 26, 2026 14:57
adboio added a commit that referenced this pull request Jun 26, 2026
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the graphite-base/2873 branch from f15ae36 to 4089bea Compare June 26, 2026 14:58
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from ead83ed to 0d627e5 Compare June 26, 2026 14:58
@graphite-app graphite-app Bot changed the base branch from graphite-base/2873 to main June 26, 2026 14:58
Client side of importing a Claude Code CLI session: the task-creation
saga step that snapshots and records the import (with rollback
compensation) and links the session's branch, session replay-history
loading on connect, and the new-task picker UI for browsing and
importing recent CLI sessions for the selected repo.

Part 3/3 of splitting #2873 (import Claude Code sessions).

Generated-By: PostHog Code
Task-Id: 6c93b6e8-27b6-45c8-8135-73a09076ea93
@adboio adboio force-pushed the 06-11-feat_code_import_claude_code_sessions branch from 0d627e5 to 6543cda Compare June 26, 2026 14:58
@adboio adboio merged commit 8e6b951 into main Jun 26, 2026
24 checks passed

adboio commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

@adboio adboio deleted the 06-11-feat_code_import_claude_code_sessions branch June 26, 2026 15:09
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.

2 participants