Skip to content

feat: Update cli UI - #699

Merged
ilyabo merged 32 commits into
mainfrom
update-cli-ui
Jun 14, 2026
Merged

ilyabo merged 32 commits into
mainfrom
update-cli-ui

Conversation

@ilyabo

@ilyabo ilyabo commented Jun 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR refreshes the SQLRooms CLI workspace around artifact-first navigation and artifact-scoped AI assistance.

  • Reworks the CLI shell with a dedicated workspace sidebar/topbar, artifact chooser, editable workspace/artifact titles, create/delete artifact controls, and a layout migration that moves the assistant to the left side of the workspace.
  • Adds artifact-scoped AI session behavior, including per-artifact chat history filtering, scoped new-session creation, automatic session title generation, context ownership for the current artifact, and clearer run-context instructions for assistant tools.
  • Improves local data workflows with file upload/loading helpers, schema refresh handling, and tighter schema tree spacing.
  • Simplifies the artifact/block model by removing embedded artifact visibility metadata and relying on hosted stateful blocks for embedded worksheet content.
  • Removes the old Block Document rich-text block path and updates docs to describe editable text plus chart/stateful blocks.
  • Polishes UI details including sidebar styling, logo/theme updates, running-session indicators, SQL modal outside-click behavior, and tree spacing.

Validation

  • pnpm --filter @sqlrooms/artifacts test
  • pnpm --filter @sqlrooms/documents test
  • pnpm --filter @sqlrooms/artifacts typecheck
  • pnpm --filter @sqlrooms/documents typecheck
  • pnpm --filter @sqlrooms/ai-core test
  • pnpm --filter @sqlrooms/ai-core typecheck
  • pnpm --filter sqlrooms-cli-app typecheck

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66e45846-adb7-4f0a-989d-3a58de0046bd

📥 Commits

Reviewing files that changed from the base of the PR and between bbdd085 and 9bd1bc8.

📒 Files selected for processing (3)
  • apps/sqlrooms-cli-ui/src/store-types.ts
  • packages/ai-core/src/hooks/useGenerateSessionTitle.ts
  • packages/artifacts/src/ai/artifactAiSlice.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/sqlrooms-cli-ui/src/store-types.ts
  • packages/artifacts/src/ai/artifactAiSlice.ts
  • packages/ai-core/src/hooks/useGenerateSessionTitle.ts

📝 Walkthrough

Walkthrough

The PR adds artifact-owned AI session handling, refactors the CLI workspace into sidebar-based components, updates chat/session APIs, and removes richText block support from documents.

Changes

Artifact-owned AI and session contracts

Layer / File(s) Summary
Session titles and chat APIs
packages/ai-config/src/AiSliceConfig.ts, packages/ai-core/src/AiSlice.ts, packages/ai-core/src/hooks/useGenerateSessionTitle.ts, packages/ai-core/src/components/ChatHeader.tsx, packages/ai-core/src/components/ChatHistoryView.tsx, packages/ai-core/src/components/ChatHistoryItem.tsx, packages/ai-core/src/components/SessionActionsMenu.tsx, packages/ai-core/src/index.ts, packages/ai-core/README.md, packages/ai/README.md, packages/ai/src/index.ts, packages/sqlrooms-cli-ui/src/components/useGenSessionTitle.ts, apps/sqlrooms-cli-ui/src/components/useGenSessionTitle.ts, packages/ai-core/__tests__/ChatHistoryView.test.tsx
Adds session-title generation helpers and hook exports, changes default session names to Untitled, and extends chat header/history components with optional session creation, filtering, empty-state text, rename handling, and running-state indicators.
Artifact ownership helpers and AI slice
packages/artifacts/src/ArtifactsSliceConfig.ts, packages/artifacts/src/ArtifactsSlice.ts, packages/artifacts/src/artifactTabs.tsx, packages/artifacts/src/ai/artifactAiSessionHelpers.ts, packages/artifacts/src/ai/artifactAiSlice.ts, packages/artifacts/src/ai/artifactContextTools.ts, packages/artifacts/src/ai/index.ts, packages/artifacts/src/index.ts, packages/artifacts/package.json, packages/artifacts/README.md, packages/artifacts/__tests__/*, packages/artifacts/src/index.ts
Removes artifact visibility fields from metadata and tab APIs, adds artifact-session ownership helpers and sync logic, exposes the new AI slice and tool contracts, and updates package exports and tests around the artifact-owned AI flow.
CLI assistant context and input flow
apps/sqlrooms-cli-ui/src/artifactTypeIds.ts, apps/sqlrooms-cli-ui/src/artifactTypes.tsx, apps/sqlrooms-cli-ui/src/components/assistantUtils.ts, apps/sqlrooms-cli-ui/src/components/useAssistantContextItems.ts, apps/sqlrooms-cli-ui/src/context/formatRunContextInstructions.ts, apps/sqlrooms-cli-ui/src/context/getRunContext.ts, apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx, apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts
Moves artifact type allowlisting into a dedicated module, scopes assistant context selection and run-context assembly to session-owned artifacts, routes chat creation/history through artifact ownership metadata, and adds the local file loader hook for data imports.
CLI layout and sidebar workspace UI
apps/sqlrooms-cli-ui/src/layout.tsx, apps/sqlrooms-cli-ui/src/room.tsx, apps/sqlrooms-cli-ui/src/store-types.ts, apps/sqlrooms-cli-ui/src/store.ts, apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx, apps/sqlrooms-cli-ui/src/workspace/CliWorkspaceTopbar.tsx, apps/sqlrooms-cli-ui/src/workspace/sidebar/*, apps/sqlrooms-cli-ui/src/style.css, apps/sqlrooms-cli-ui/package.json, apps/sqlrooms-cli-ui/README.md, packages/schema-tree/src/nodes/*, packages/ui/src/components/tree.tsx, packages/sql-editor/src/SqlEditorModal.tsx
Introduces CLI sidebar components and topbar actions, refactors the room shell to use sidebar primitives, migrates persisted layout and workspace title state, adds artifact chooser state to the store, and updates theme, tree spacing, and modal interaction styling.
Document block cleanup
packages/documents/src/BlockDocumentSliceConfig.ts, packages/documents/src/BlockDocumentEditor/BlockDocumentEditorRoot.tsx, packages/documents/src/BlockDocumentEditor/extensions/BlockDocumentRichTextNode.tsx, packages/documents/src/BlockDocumentEditor/node-views/BlockDocumentRichTextNodeView.tsx, packages/documents/src/index.ts, packages/documents/README.md, packages/documents/__tests__/BlockDocumentsSlice.test.ts, dev-docs/tasks/analysis-document-artifacts.md, packages/documents/__tests__/BlockDocumentCommands.test.ts, packages/documents/src/BlockDocumentCommands.ts, packages/documents/src/crdt.ts, packages/documents/__tests__/documentsCrdt.test.ts, packages/documents/__tests__/documentCommands.test.ts
Removes the richText block schema, conversion branches, editor extension, node view, barrel export, and related test fixtures, while updating document wording from rich text to text or editable text.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#707: Introduces per-session draftContextItemIds and session-scoped draft context APIs that directly enable the artifact-scoped session context filtering implemented in this PR.
  • sqlrooms/sqlrooms#400: Adds new Sidebar primitives from @sqlrooms/ui that this PR's sidebar layout directly depends on.
  • sqlrooms/sqlrooms#698: Modifies Chat UI history flow and props that overlap with the history filtering and session creation delegation implemented here.

Poem

🐰 I hop through chats with titles new,
And sidebar breezes hum right through.
Rich text has hopped away at last,
While artifact-scoped sessions hold fast.
In leafy tabs, my carrots glow—
a tidy UI, bright to know.

✨ 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 update-cli-ui

@ilyabo
ilyabo marked this pull request as ready for review June 13, 2026 13:19

@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: 21f86e3dc3

ℹ️ 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 thread apps/sqlrooms-cli-ui/src/store.ts Outdated
Comment on lines +856 to +858
if (currentSessionArtifactId !== currentArtifactId) {
state.artifactAi.selectLatestSessionForArtifact(currentArtifactId);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve unmapped AI sessions before enforcing scope

When a session has no aiSessionArtifacts entry, such as sessions persisted before this commit or sessions created through the still-registered ai.create-session command that calls ai.createSession directly, currentSessionArtifactId is undefined while currentArtifactId is normally set. This branch immediately calls selectLatestSessionForArtifact, which clears or switches away from that session; because the CLI history view also filters by the mapping, those chats become inaccessible. Please backfill/map unscoped sessions or allow missing mappings instead of treating them as a mismatch.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts (1)

6-11: ⚡ Quick win

Non-standard MIME types in LOCAL_DATA_ACCEPTED_FORMATS.

The MIME types text/parquet and text/json are non-standard. According to IANA standards:

  • Parquet files typically use application/vnd.apache.parquet or application/octet-stream
  • JSON files use application/json

While the file input's accept attribute is generally forgiving, using correct MIME types improves clarity and future compatibility.

📝 Proposed fix
 export const LOCAL_DATA_ACCEPTED_FORMATS = {
   'text/csv': ['.csv'],
   'text/tsv': ['.tsv'],
-  'text/parquet': ['.parquet'],
-  'text/json': ['.json'],
+  'application/vnd.apache.parquet': ['.parquet'],
+  'application/json': ['.json'],
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts` around lines 6 -
11, Update the LOCAL_DATA_ACCEPTED_FORMATS map to use standard MIME types:
replace the 'text/parquet' key with 'application/vnd.apache.parquet' (or
'application/octet-stream' if you prefer a generic fallback) and replace
'text/json' with 'application/json', keeping the associated extension arrays
intact; leave 'text/csv' and 'text/tsv' as-is and ensure the symbol
LOCAL_DATA_ACCEPTED_FORMATS is updated accordingly wherever referenced.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts`:
- Around line 22-34: The loop in useLocalFileLoader that uses
convertToValidColumnOrTableName and connector.loadFile can silently overwrite
tables when multiple files normalize to the same table name and also exposes raw
error objects in toast.error; fix by tracking already-used names (use the
existing createdTableNames array) and, before calling connector.loadFile, check
for collisions and if a name exists append a numeric suffix (e.g.,
`${baseName}_${n}`) until unique, then push the final name into
createdTableNames; also sanitize the toast error message by using error
instanceof Error ? error.message : String(error) (use this sanitized string in
toast.error description) and update toast.success to show the final table name
variable you actually created.
- Line 36: The call to refreshTableSchemas() can throw and currently isn't
handled; wrap the await refreshTableSchemas() invocation inside a try-catch in
useLocalFileLoader.ts, and in the catch block call the project's error-toast
utility to show a user-facing error message (e.g., "Failed to refresh table
schemas") and log the error; ensure the catch prevents misleading success
feedback (move or gate any existing success toasts for loaded files so they
don't display when schema refresh fails).

In `@apps/sqlrooms-cli-ui/src/workspace/sidebar/CliArtifactsSidebarSection.tsx`:
- Around line 43-66: The expanded sidebar currently maps artifactTabs.tabs and
renders nothing when the array is empty; add an explicit empty state so expanded
mode shows "No artifacts" like collapsed mode. In
CliArtifactsSidebarSection.tsx, before mapping artifactTabs.tabs (rendering
inside SidebarMenu), check if artifactTabs.tabs.length === 0 and return a
SidebarMenuItem (and SidebarMenuButton if you want consistent styling) that
displays the text "No artifacts" with the same sizing/truncation classes used
for items; otherwise proceed to the existing artifactTabs.tabs.map rendering.
Ensure you do not change selection logic (artifactTabs.selectedTabId) and keep
the same classNames for visual consistency.

---

Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts`:
- Around line 6-11: Update the LOCAL_DATA_ACCEPTED_FORMATS map to use standard
MIME types: replace the 'text/parquet' key with 'application/vnd.apache.parquet'
(or 'application/octet-stream' if you prefer a generic fallback) and replace
'text/json' with 'application/json', keeping the associated extension arrays
intact; leave 'text/csv' and 'text/tsv' as-is and ensure the symbol
LOCAL_DATA_ACCEPTED_FORMATS is updated accordingly wherever referenced.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f26cb0a7-5340-4329-8c21-417db1bec8a6

📥 Commits

Reviewing files that changed from the base of the PR and between b790206 and 21f86e3.

⛔ Files ignored due to path filters (3)
  • apps/sqlrooms-cli-ui/public/logo.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • python/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (51)
  • apps/sqlrooms-cli-ui/README.md
  • apps/sqlrooms-cli-ui/package.json
  • apps/sqlrooms-cli-ui/src/artifactTypeIds.ts
  • apps/sqlrooms-cli-ui/src/artifactTypes.tsx
  • apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx
  • apps/sqlrooms-cli-ui/src/components/DataSourcesPanel.tsx
  • apps/sqlrooms-cli-ui/src/components/assistantUtils.ts
  • apps/sqlrooms-cli-ui/src/components/useAssistantContextItems.ts
  • apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts
  • apps/sqlrooms-cli-ui/src/context/formatRunContextInstructions.ts
  • apps/sqlrooms-cli-ui/src/context/getRunContext.ts
  • apps/sqlrooms-cli-ui/src/layout.tsx
  • apps/sqlrooms-cli-ui/src/room.tsx
  • apps/sqlrooms-cli-ui/src/store-types.ts
  • apps/sqlrooms-cli-ui/src/store.ts
  • apps/sqlrooms-cli-ui/src/style.css
  • apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
  • apps/sqlrooms-cli-ui/src/workspace/CliWorkspaceTopbar.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliArtifactsSidebarSection.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliAssistantToggleButton.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliDataSidebarSection.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliSidebarBrand.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliSidebarFooterControls.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliSidebarToggleButton.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliWorkspaceSidebar.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/DbConnectionsSection.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/index.ts
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts
  • dev-docs/tasks/analysis-document-artifacts.md
  • packages/ai-core/README.md
  • packages/ai-core/__tests__/AiSlice.modelSelection.test.ts
  • packages/ai-core/__tests__/ChatHistoryView.test.tsx
  • packages/ai-core/src/components/ChatHeader.tsx
  • packages/ai-core/src/components/ChatHistoryItem.tsx
  • packages/ai-core/src/components/ChatHistoryView.tsx
  • packages/ai-core/src/components/SessionActionsMenu.tsx
  • packages/ai-core/src/index.ts
  • packages/ai/README.md
  • packages/documents/README.md
  • packages/documents/__tests__/BlockDocumentsSlice.test.ts
  • packages/documents/src/BlockDocumentEditor/BlockDocumentEditorRoot.tsx
  • packages/documents/src/BlockDocumentEditor/extensions/BlockDocumentRichTextNode.tsx
  • packages/documents/src/BlockDocumentEditor/node-views/BlockDocumentRichTextNodeView.tsx
  • packages/documents/src/BlockDocumentSliceConfig.ts
  • packages/documents/src/index.ts
  • packages/schema-tree/src/nodes/ColumnTreeNode.tsx
  • packages/schema-tree/src/nodes/DatabaseTreeNode.tsx
  • packages/schema-tree/src/nodes/SchemaTreeNode.tsx
  • packages/schema-tree/src/nodes/TableTreeNode.tsx
  • packages/sql-editor/src/SqlEditorModal.tsx
  • packages/ui/src/components/tree.tsx
💤 Files with no reviewable changes (8)
  • packages/documents/src/BlockDocumentEditor/node-views/BlockDocumentRichTextNodeView.tsx
  • packages/documents/src/BlockDocumentEditor/extensions/BlockDocumentRichTextNode.tsx
  • packages/documents/src/index.ts
  • packages/documents/src/BlockDocumentEditor/BlockDocumentEditorRoot.tsx
  • apps/sqlrooms-cli-ui/src/components/DataSourcesPanel.tsx
  • apps/sqlrooms-cli-ui/package.json
  • packages/documents/tests/BlockDocumentsSlice.test.ts
  • packages/documents/src/BlockDocumentSliceConfig.ts

Comment thread apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts
Comment thread apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts Outdated

@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: bbdd085bbc

ℹ️ 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".

useTools: false,
...promptOptions,
});
const title = cleanGeneratedSessionTitle(generatedTitle, maxTitleLength);

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 Guard against error text becoming the chat title

When the title-generation model call fails with the default AiSlice.sendPrompt, it resolves to the string error: can not generate response instead of throwing, and this path cleans that sentinel as if it were a valid title before renameSession runs. In no-API-key or transient provider-error scenarios, the first user message renames the chat to the error text and onError is never invoked; treat error results as failures before accepting the generated title.

Useful? React with 👍 / 👎.

Comment on lines 245 to 248
artifactsConfig.artifactOrder.filter((artifactId) => {
const artifact = artifactsConfig.artifactsById[artifactId];
return (
artifact &&
isManagedType(managedTypes, artifact.type) &&
isArtifactVisibleInTabs(artifact, {includeEmbedded})
);
return artifact && isManagedType(managedTypes, artifact.type);
}),

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 Keep legacy embedded artifacts out of workspace tabs

For workspaces saved before this change, embedded child artifacts still exist in artifactOrder with visibility: 'embedded'; ArtifactsSliceConfig.parse now strips that field, and this filter includes every managed artifact type, so those formerly hidden dashboards/pivots/documents become regular workspace tabs/sidebar entries after hydration. Please migrate/drop legacy embedded artifact records or preserve a legacy visibility check before surfacing them.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
packages/ai-core/src/hooks/useGenerateSessionTitle.ts (1)

176-182: ⚡ Quick win

Avoid calling methods inside selectors to prevent unstable references.

Per coding guidelines, selectors should select stable raw state first. Calling getCurrentSession() inside the selector returns a derived object that may trigger unnecessary re-renders. Consider selecting the raw session data:

-  const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);
-  const currentSession = useStoreWithAi((s) => s.ai.getCurrentSession());
-  const uiMessagesLength = useStoreWithAi(
-    (s) => s.ai.getCurrentSession()?.uiMessages?.length ?? 0,
-  );
+  const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);
+  const sessions = useStoreWithAi((s) => s.ai.config.sessions);
+  const currentSession = useMemo(
+    () => sessions.find((s) => s.id === currentSessionId),
+    [sessions, currentSessionId],
+  );
+  const uiMessagesLength = currentSession?.uiMessages?.length ?? 0;

This also consolidates three subscriptions into two and avoids redundant getCurrentSession() calls.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ai-core/src/hooks/useGenerateSessionTitle.ts` around lines 176 -
182, The selectors in useGenerateSessionTitle are calling the
getCurrentSession() method inside selectors (in lines 177 and 178-180), which
violates best practices by creating unstable references that trigger unnecessary
re-renders. Replace the getCurrentSession() method calls with selectors that
access the raw session data directly from the store state (such as selecting
from a sessions collection using the currentSessionId). This will eliminate the
redundant method calls and consolidate the multiple useStoreWithAi subscriptions
into fewer, more stable ones.

Source: Coding guidelines

packages/artifacts/src/ai/artifactAiSlice.ts (1)

166-171: 💤 Low value

Consider more selective store subscription for autoSync.

The subscription on line 168 triggers syncCurrentArtifactAiSession on every state change. While the early-return guards (lines 134, 148-155) and cleanup short-circuit (lines 120-125) prevent wasteful updates, a more targeted subscription that listens only to artifacts.config.currentArtifactId and ai.config changes would reduce unnecessary invocations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/artifacts/src/ai/artifactAiSlice.ts` around lines 166 - 171, The
subscription in the initialize function currently triggers
syncCurrentArtifactAiSession on every state change, which is inefficient. Modify
the store subscription to use a selector-based approach that only triggers the
sync function when specific state slices like artifacts.config.currentArtifactId
and ai.config actually change. This can be done by passing a selector function
to the store subscribe method (or using a selector hook if available) so that
syncCurrentArtifactAiSession is called only when the relevant parts of the state
change, not on every single state update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/ai-core/src/hooks/useGenerateSessionTitle.ts`:
- Around line 176-182: The selectors in useGenerateSessionTitle are calling the
getCurrentSession() method inside selectors (in lines 177 and 178-180), which
violates best practices by creating unstable references that trigger unnecessary
re-renders. Replace the getCurrentSession() method calls with selectors that
access the raw session data directly from the store state (such as selecting
from a sessions collection using the currentSessionId). This will eliminate the
redundant method calls and consolidate the multiple useStoreWithAi subscriptions
into fewer, more stable ones.

In `@packages/artifacts/src/ai/artifactAiSlice.ts`:
- Around line 166-171: The subscription in the initialize function currently
triggers syncCurrentArtifactAiSession on every state change, which is
inefficient. Modify the store subscription to use a selector-based approach that
only triggers the sync function when specific state slices like
artifacts.config.currentArtifactId and ai.config actually change. This can be
done by passing a selector function to the store subscribe method (or using a
selector hook if available) so that syncCurrentArtifactAiSession is called only
when the relevant parts of the state change, not on every single state update.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aaeef111-2cc8-4771-bff3-c2215308a8cf

📥 Commits

Reviewing files that changed from the base of the PR and between 21f86e3 and bbdd085.

📒 Files selected for processing (41)
  • apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx
  • apps/sqlrooms-cli-ui/src/components/useGenSessionTitle.ts
  • apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts
  • apps/sqlrooms-cli-ui/src/context/getRunContext.ts
  • apps/sqlrooms-cli-ui/src/store-types.ts
  • apps/sqlrooms-cli-ui/src/store.ts
  • apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliArtifactsSidebarSection.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliAssistantToggleButton.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts
  • examples/canvas/src/store.ts
  • examples/kepler/src/store.ts
  • examples/notebook/src/store.ts
  • examples/pivot/src/store.ts
  • packages/ai-config/src/AiSliceConfig.ts
  • packages/ai-core/README.md
  • packages/ai-core/src/AiSlice.ts
  • packages/ai-core/src/components/ChatHeader.tsx
  • packages/ai-core/src/components/ChatHistoryView.tsx
  • packages/ai-core/src/hooks/useGenerateSessionTitle.ts
  • packages/ai-core/src/index.ts
  • packages/ai/README.md
  • packages/ai/src/index.ts
  • packages/artifacts/README.md
  • packages/artifacts/__tests__/ArtifactContextAiTools.test.ts
  • packages/artifacts/__tests__/ArtifactsSlice.test.ts
  • packages/artifacts/__tests__/artifactAiSessions.test.ts
  • packages/artifacts/package.json
  • packages/artifacts/src/ArtifactsSlice.ts
  • packages/artifacts/src/ArtifactsSliceConfig.ts
  • packages/artifacts/src/ai/artifactAiSessionHelpers.ts
  • packages/artifacts/src/ai/artifactAiSlice.ts
  • packages/artifacts/src/ai/artifactContextTools.ts
  • packages/artifacts/src/ai/index.ts
  • packages/artifacts/src/artifactTabs.tsx
  • packages/artifacts/src/index.ts
  • packages/documents/__tests__/BlockDocumentCommands.test.ts
  • packages/documents/__tests__/documentCommands.test.ts
  • packages/documents/__tests__/documentsCrdt.test.ts
  • packages/documents/src/BlockDocumentCommands.ts
  • packages/documents/src/crdt.ts
💤 Files with no reviewable changes (3)
  • packages/artifacts/src/ArtifactsSliceConfig.ts
  • packages/documents/src/BlockDocumentCommands.ts
  • packages/artifacts/src/index.ts
✅ Files skipped from review due to trivial changes (5)
  • packages/ai-config/src/AiSliceConfig.ts
  • examples/notebook/src/store.ts
  • packages/ai/README.md
  • packages/ai-core/README.md
  • packages/artifacts/README.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliAssistantToggleButton.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts
  • apps/sqlrooms-cli-ui/src/components/AssistantChatContainer.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/CliArtifactsSidebarSection.tsx
  • packages/ai-core/src/components/ChatHistoryView.tsx
  • apps/sqlrooms-cli-ui/src/components/useLocalFileLoader.ts
  • packages/ai-core/src/components/ChatHeader.tsx

@ilyabo
ilyabo merged commit 75367c9 into main Jun 14, 2026
8 checks passed
@ilyabo
ilyabo deleted the update-cli-ui branch June 14, 2026 16:04

@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: 9bd1bc8cf5

ℹ️ 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".

return {status: 'unchanged', title};
}

renameSession(session.id, 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 Recheck the title before auto-renaming

If the user manually edits an Untitled chat title while the async title-generation request is in flight, this call still renames the session using the stale session object captured before the request. In the CLI the title is now directly editable, and model calls can take long enough for this race to overwrite the user's custom title; re-read the latest session name or otherwise confirm it is still a default title immediately before calling renameSession.

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.

2 participants