feat(cli): let gist create target a provider session - #1441
Conversation
`gist create` took only an agent id, so it published whatever AI tabs that agent had open in the desktop app. Headless callers address a conversation by its provider session id (`send -s <id>`) and have no tab, so `/gist` from a chat bridge published an unrelated desktop conversation - and a gist is readable by anyone holding the URL. Adds `--session <id>`, threaded through the WebSocket bridge as `agentSessionId`. The renderer publishes the open tab holding that session when there is one, else the provider's stored transcript (SSH remotes included, via the existing `agentSessions.read` path). There is no fallback in either direction: a `--session` that cannot be resolved fails, because publishing the open tabs instead is the substitution this option exists to prevent. A blank `--session` is rejected at both the CLI and the bridge for the same reason. Omitting the flag keeps today's behavior. Truncates at 10k messages and says so in the body rather than silently publishing a partial transcript.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughGist creation now accepts an optional provider session ID. The ID travels through the CLI, web-server, callback, and IPC layers. The renderer publishes a matching live-tab transcript or reads a headless session transcript. Existing open-tab behavior remains unchanged without the option. ChangesGist session targeting
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change adds optional session-specific gist creation while preserving existing behavior when unused; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant MaestroCLI
participant WebServer
participant RendererIntegration
participant AgentSessionStore
participant GitIntegration
MaestroCLI->>WebServer: create_gist with agentSessionId
WebServer->>RendererIntegration: forward session ID
RendererIntegration->>AgentSessionStore: load targeted transcript when no matching live tab exists
AgentSessionStore-->>RendererIntegration: transcript or error
RendererIntegration->>GitIntegration: create session-specific gist
GitIntegration-->>RendererIntegration: gist URL
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue Full details: Docstring CoverageExplanation Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 13 files. (2 skipped: 2 unsupported.) ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds a session-addressable
Confidence Score: 3/5This PR should not merge until targeted stored-session reads are constrained to the requested agent project, because the current Codex and OpenCode path can publish another project's transcript. The new externally selectable session ID reaches provider storage and then gist creation, while two supported storage adapters resolve that ID globally instead of validating it against the requested project. Files Needing Attention: src/renderer/hooks/remote/useRemoteIntegration.ts and the Codex/OpenCode session-storage ownership boundary
|
| Filename | Overview |
|---|---|
| src/renderer/hooks/remote/useRemoteIntegration.ts | Adds targeted live/stored transcript selection, but the stored fallback relies on provider adapters that do not uniformly enforce project ownership. |
| src/main/web-server/handlers/messageHandlers.ts | Validates and forwards the optional provider session ID while preserving the prior request defaults. |
| src/cli/commands/gist.ts | Adds blank-session validation, forwards the normalized ID, and echoes it in successful machine-readable output. |
| src/main/preload/process.ts | Keeps the new callback argument aligned across the preload event bridge. |
| src/tests/renderer/hooks/useRemoteIntegration.test.ts | Covers matching-tab selection, stored fallback, failure without tab fallback, and legacy behavior, but not cross-project provider-session ownership. |
Sequence Diagram
sequenceDiagram
participant CLI
participant WS as WebSocket handler
participant Renderer
participant Storage as Provider session storage
participant GitHub
CLI->>WS: create_gist(agentId, agentSessionId)
WS->>Renderer: remote:createGist
alt Matching open tab
Renderer->>Renderer: Format matching tab logs
else No matching tab
Renderer->>Storage: read(toolType, projectPath, agentSessionId)
Storage-->>Renderer: Normalized transcript
end
Renderer->>GitHub: Create gist from transcript
GitHub-->>CLI: Gist URL
Reviews (1): Last reviewed commit: "feat(cli): let `gist create` target a pr..." | Re-trigger Greptile
| try { | ||
| result = await window.maestro.agentSessions.read( | ||
| session.toolType, | ||
| projectPathForSessions, | ||
| agentSessionId, | ||
| { offset: 0, limit: GIST_SESSION_MESSAGE_LIMIT }, | ||
| sshRemoteId |
There was a problem hiding this comment.
Cross-project transcript export
When a caller supplies a Codex or OpenCode session ID from another project, this fallback passes it to provider storage that resolves sessions globally rather than enforcing projectPath, causing the unrelated transcript to be published to a URL-readable gist. Validate that the selected provider session belongs to the requested agent and project before creating the gist.
How this was verified: The new caller-controlled ID was traced through agentSessions.read to the Codex and OpenCode readers, which locate transcripts by session ID without constraining them to the supplied project.
Knowledge Base Used:
|
CI note: the |
Closes #1440
The gap
maestro-cli gist create <agent-id>took only an agent id, so it published the transcripts of whatever AI tabs that agent had open in the desktop app. Headless callers address a conversation by its provider session id (send -s <id>) and have no tab at all, so Maestro Relay's/gistin a channel discussing topic B published an unrelated desktop conversation about topic A. Gists are readable by anyone holding the URL, so that is a leak rather than a surprise. Playbooks, Cue pipelines, and CI have the same gap:sendis session-addressable,gist createwas not.The change
--sessionis threaded through the WebSocket bridge asagentSessionId(CLI ->create_gistmessage ->CreateGistCallback-> renderer). The renderer resolves the transcript in two steps:agentSessionId, when one exists (logs are already in memory, and every provider has them);agentSessions.readpath, so SSH remotes work viaresolveSessionProjectPath.Omitting the flag keeps today's behavior byte for byte.
Deliberate non-fallbacks
--sessionthat cannot be resolved fails. Falling back to the agent's open tabs is precisely the substitution this option exists to prevent, and the caller cannot tell the difference from the returned URL.--sessionis rejected at the CLI (INVALID_SESSION) and again at the bridge, rather than being treated as absent.The success payload echoes
agentSessionIdso a caller can confirm what was published.Tests
src/__tests__/cli/commands/gist.test.ts(new): flag is forwarded, absent when unused, blank rejected, desktop failure surfaced.useRemoteIntegration.test.ts: publishes only the matching tab, reads the provider transcript when no tab holds the session, fails rather than falling back to the tabs, and the unflagged path still publishes every tab.messageHandlers.test.ts:agentSessionIdforwarded; blank and non-string rejected.npm run lint,npx eslint src/, prettier, and the cli / web-server / preload suites (1910 tests) are green locally. Docs updated indocs/cli.mdplus the generateddocs/cli-reference.md.Summary by CodeRabbit
New Features
-s, --session <id>togist createfor publishing a specific provider session transcript.Bug Fixes
Documentation