Skip to content

chore: Revert "fix(cli): navigate artifact on fork source links" - #795

Merged
ilyabo merged 1 commit into
mainfrom
revert-786-codex/fix-artifact-chat-handoff
Jul 3, 2026
Merged

ilyabo merged 1 commit into
mainfrom
revert-786-codex/fix-artifact-chat-handoff

Conversation

@ilyabo

@ilyabo ilyabo commented Jul 3, 2026 •

Copy link
Copy Markdown
Collaborator

Reverts #786

Summary by CodeRabbit

  • Refactor

    • Streamlined how chat sessions and artifact handoffs are handled across the app.
    • Switching between chats now uses a simpler, more direct session selection flow.
    • The chat interface was simplified, including cleaner message layout and removal of the horizontal scrollbar.
  • Bug Fixes

    • Improved consistency when continuing a conversation after changing artifacts.
    • Reduced the chance of chat state mismatches during handoff and session switching.

@ilyabo
ilyabo merged commit 6d19954 into main Jul 3, 2026
3 of 4 checks passed
@ilyabo
ilyabo deleted the revert-786-codex/fix-artifact-chat-handoff branch July 3, 2026 16:57
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d807e35-490c-4096-bde0-acc8f9d613f0

📥 Commits

Reviewing files that changed from the base of the PR and between 0c571ca and 6e3abab.

📒 Files selected for processing (11)
  • apps/sqlrooms-cli-ui/src/__tests__/artifactChatHandoff.test.ts
  • apps/sqlrooms-cli-ui/src/ai/__tests__/createWorksheetAgentTool.test.ts
  • apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts
  • apps/sqlrooms-cli-ui/src/artifactChatHandoff.ts
  • apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx
  • packages/ai-core/src/components/ChatMessagesContainer.tsx
  • packages/artifacts/README.md
  • packages/artifacts/__tests__/artifactAiChatHandoff.test.ts
  • packages/artifacts/src/ai/artifactAiChatHandoff.ts
  • packages/artifacts/src/ai/artifactAiNavigation.ts
  • packages/artifacts/src/ai/index.ts

📝 Walkthrough

Walkthrough

This PR removes the generic artifact AI chat handoff/navigation module from packages/artifacts (including exports, tests, README docs) and replaces it with a self-contained handoff controller in apps/sqlrooms-cli-ui. It also simplifies createWorksheetAgentTool's mutation-check logic and removes the onSwitchToForkSource prop from ChatMessagesContainer in favor of direct switchSession calls.

Changes

Artifact chat handoff and session switching refactor

Layer / File(s) Summary
Remove generic handoff/navigation module
packages/artifacts/src/ai/artifactAiChatHandoff.ts, packages/artifacts/src/ai/artifactAiNavigation.ts, packages/artifacts/src/ai/index.ts, packages/artifacts/README.md, packages/artifacts/__tests__/artifactAiChatHandoff.test.ts
Deletes readArtifactTargetChange, createArtifactAiChatHandoffController, switchToArtifactAiSession, associated types, barrel exports, tests, and README documentation.
New self-contained handoff controller
apps/sqlrooms-cli-ui/src/artifactChatHandoff.ts, apps/sqlrooms-cli-ui/src/__tests__/artifactChatHandoff.test.ts
Adds PendingArtifactChatHandoff state, a target-change parser, session/message helpers, a commandMiddleware that records pending handoffs, and an onChatFinish that forks and reassigns sessions on completion; removes the prior worksheet-copy-based test suite.
Direct session switching in UI components
packages/ai-core/src/components/ChatMessagesContainer.tsx, apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx
Removes the ChatForkSourceSwitchHandler type and onSwitchToForkSource prop, switches fork click and chat-history selection to call switchSession/ai.switchSession directly, and adjusts scroll area layout.

Worksheet agent tool mutation-check simplification

Layer / File(s) Summary
Simplify worksheet agent tool execution
apps/sqlrooms-cli-ui/src/ai/createWorksheetAgentTool.ts, apps/sqlrooms-cli-ui/src/ai/__tests__/createWorksheetAgentTool.test.ts
Removes AgentRunResult/AgentToolCall-based mutation validation and retry logic, replaces block-count tracking with setCurrentBlockDocument, and deletes the associated test file.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Command
  participant commandMiddleware
  participant Store
  participant onChatFinish

  Command->>commandMiddleware: run AI-surface invocation
  commandMiddleware->>Store: resolve source artifact id
  commandMiddleware->>commandMiddleware: parse artifactTargetChange
  commandMiddleware->>Store: record pending handoff
  Store->>onChatFinish: chat session finishes
  onChatFinish->>Store: verify source/target artifacts and last user message id
  onChatFinish->>Store: fork target session, assign target artifact, select session
Loading

Possibly related PRs

  • sqlrooms/sqlrooms#497: Removes the same AgentRunResult/AgentToolCall-based worksheet mutation validation logic in createWorksheetAgentTool.ts.
  • sqlrooms/sqlrooms#716: Both PRs modify ChatMessagesContainer.tsx fork provenance to switch directly via switchSession(sourceSession.id).
  • sqlrooms/sqlrooms#747: Introduced the original artifactTargetChange-based handoff feature that this PR refactors into a self-contained controller.

Suggested reviewers: dmitriy-kostianetskiy

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-786-codex/fix-artifact-chat-handoff

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e3ababcbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 136 to 138
onSwitchToSource={() => {
if (!sourceSession) return;
if (onSwitchToForkSource) {
onSwitchToForkSource(sourceSession, forkOrigin);
return;
}
switchSession(sourceSession.id);
if (sourceSession) switchSession(sourceSession.id);
}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Select owning artifact before switching to fork source

When the fork provenance points to a session owned by another artifact, clicking “Forked from …” now calls only ai.switchSession. In the CLI store, artifactAi.syncCurrentArtifactAiSession observes the AI-config change while currentArtifactId is still the target artifact and re-selects that artifact’s latest session, so the source link appears to do nothing instead of navigating back to the source artifact. Select the owning artifact before switching sessions, or restore a host callback for artifact-scoped chats.

Useful? React with 👍 / 👎.

Comment on lines 424 to 425
return {
success: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not report success without worksheet changes

For create/update intents such as “add a scatter plot”, if the sub-agent answers with text or only runs read-only query tools, this wrapper now unconditionally returns success: true without checking whether any worksheet block was added or mutated. That leaves the parent chat believing the worksheet changed even though no chart/block was created; mutation requests should retry or fail when no worksheet mutation occurred.

Useful? React with 👍 / 👎.

Comment on lines +184 to +189
const targetSessionId = state.ai.forkSessionFromMessage({
sourceSessionId: handoff.sourceSessionId,
sourceMessageId: assistantMessage.message.id,
sourceMessageIndex: assistantMessage.index,
name: `Continue: ${targetArtifact.title}`,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Copy chart blocks before same-chart handoff forks

When a worksheet user asks to create a new worksheet with the same/copy chart, this path now forks the chat into the target worksheet without writing any chart blocks to that empty target. The fork only creates chat provenance and session ownership, so these copy-chart handoffs leave the newly selected worksheet blank instead of carrying over the requested chart content.

Useful? React with 👍 / 👎.

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