Skip to content

fix(conversations): resume Droid provider sessions#2217

Open
janburzinski wants to merge 2 commits into
mainfrom
emdash/droid-resume-ijcyj
Open

fix(conversations): resume Droid provider sessions#2217
janburzinski wants to merge 2 commits into
mainfrom
emdash/droid-resume-ijcyj

Conversation

@janburzinski
Copy link
Copy Markdown
Collaborator

summary

finally droid actually resumes the last conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 24, 2026

Greptile Summary

This PR wires up end-to-end Droid provider session resumption: a new SessionStart hook captures the provider-native UUID from Droid, persists it in the conversation's JSON config column, and the resume path now passes that UUID (rather than the Emdash conversation ID) to droid --resume.

  • Session capture: A new SessionStart hook entry in the Droid config posts to the hook server; handleProviderSessionHook extracts the session UUID and saveProviderSessionId writes it to the DB, emitting a conversationChanged event for live UI updates.
  • Resume logic: resolveAgentSessionCommandArgs selects providerSessionId for local Droid resumes and falls back to starting a fresh session when no UUID has been stored yet; SSH conversations use requireProviderSessionId: false to preserve the existing passthrough behaviour.
  • Config refactor: createConversation and mapConversationRowToConversation migrate from ad-hoc JSON.parse/stringify to the new conversation-config helpers, and providerSessionId is surfaced on the Conversation type.

Confidence Score: 5/5

Safe to merge; changes are well-scoped and the fallback paths preserve existing behaviour when no provider session ID has been captured yet.

The session-capture and resume paths are logically correct, backed by new unit tests for every branch, and the config refactor is a straightforward extraction with no behavioural change. The only gap is a silent early-return in handleProviderSessionHook when none of the three candidate field names match Droid's actual response body, which would cause the feature to stop working without any diagnostic signal.

src/main/core/agent-hooks/handle-provider-session-hook.ts — the field-name lookup has no warn log on the 'no matching field' path, which would make a future Droid API change very hard to diagnose.

Important Files Changed

Filename Overview
src/main/core/agent-hooks/handle-provider-session-hook.ts New handler that extracts Droid's session UUID from the SessionStart hook body and persists it; guards against non-droid providers and invalid JSON but silently exits when no matching field name is found.
src/main/core/conversations/save-provider-session-id.ts New module that persists the Droid session UUID into the JSON config column and emits a conversationChanged event; correctly validates UUID format and short-circuits on no-op updates.
src/main/core/conversations/resolve-agent-session-command.ts New helper that selects the correct sessionId/isResuming pair for Droid (provider UUID vs conv ID) and passes through unchanged for all other providers.
src/shared/conversation-config.ts New module centralising conversation config serialization/parsing; well-typed with explicit field extraction and UUID validation for Droid session IDs.
src/shared/agent-provider-registry.ts Adds resumeFlag '--resume' to the Droid provider; sets sessionIdFlag to '--resume' as a sentinel (value unused, presence enables session-ID-as-argument logic) — documented via an inline comment.
src/main/core/conversations/impl/local-conversation.ts Delegates session ID resolution to the new resolveAgentSessionCommandArgs helper before building the agent command.
src/main/core/conversations/impl/ssh-conversation.ts Same delegation to resolveAgentSessionCommandArgs as local-conversation, but with requireProviderSessionId: false to preserve the existing resume-passthrough behaviour over SSH.
src/main/core/agent-hooks/agent-hook-service.ts Routes 'session'-type hook events to the new handleProviderSessionHook before the generic enrichEvent/emit path.
src/main/core/conversations/utils.ts Switches from raw JSON.parse to parseConversationConfig and surfaces providerSessionId on the mapped Conversation object.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/main/core/agent-hooks/handle-provider-session-hook.ts:22-24
**Silent failure when no matching session ID field is found**

If Droid's `SessionStart` hook body uses a field name that doesn't match any of `session_id`, `provider_session_id`, or `providerSessionId`, the function returns without logging anything. The entire "resume Droid sessions" feature would then silently not work — there'd be no `providerSessionId` stored, and every resume attempt would fall back to starting fresh. A `log.warn` on the early-return path would make this much easier to diagnose.

Reviews (2): Last reviewed commit: "fix(conversations): clarify Droid resume..." | Re-trigger Greptile

Comment thread src/shared/agent-provider-registry.ts
@janburzinski
Copy link
Copy Markdown
Collaborator Author

@greptileai

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.

1 participant