Skip to content

refactor: Refactor CLI artifact content host - #741

Merged
ilyabo merged 10 commits into
mainfrom
codex/cli-artifact-content-host
Jun 21, 2026
Merged

ilyabo merged 10 commits into
mainfrom
codex/cli-artifact-content-host

Conversation

@ilyabo

@ilyabo ilyabo commented Jun 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the CLI workspace's hidden ArtifactTabs host with a CLI-local selected-artifact content host.
  • Drive sidebar selection from artifacts.config.currentArtifactId instead of opening hidden layout tabs.
  • Keep the start/new-artifact screen and assistant-collapse behavior while rendering only the selected artifact component.

Notes

Inactive artifact React trees are no longer kept mounted by the CLI workspace host. Durable artifact state remains in the room/artifact-specific stores, but transient component-local state may reset when switching artifacts.

Validation

  • pnpm build
  • pnpm --filter sqlrooms-cli-app typecheck
  • pnpm --filter sqlrooms-cli-app build
  • push hooks: knip, turbo typecheck, turbo test

Manual browser smoke testing was limited because the in-app browser control failed to initialize in this session and the Vite dev server socket was not reachable from a separate shell, despite the production build succeeding.

Summary by CodeRabbit

  • New Features
    • Introduced a tab-free useArtifactWorkspace hook for selecting and rendering the current artifact in non-tab surfaces.
  • Refactor
    • Reworked artifact panel flow to use workspace actions plus a content host for start/empty/selected states.
    • Updated artifact tabs to build on the new workspace hook.
    • After creating an artifact, it’s selected immediately.
    • Simplified sidebar artifact selection to follow the current artifact without managing workspace tab layout.
  • UI/Behavior Changes
    • Removed the artifacts panel tab-strip and related deletion confirmation UI.
  • Documentation
    • Added README examples and guidance for useArtifactWorkspace.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new useArtifactWorkspace hook provides tab-free artifact collection, selection, and mutation. useArtifactTabs is refactored to delegate to it and synchronize layout tabs. ArtifactsContainerPanel switches to a context-based selection model using CliArtifactWorkspaceActionsContext and a new CliArtifactContentHost. The sidebar hook is simplified to derive selection from artifact store state and remove workspace layout mutations. Documentation is updated to distinguish tab-free and tab-based artifact surfaces.

Changes

Core artifact workspace abstraction

Layer / File(s) Summary
Workspace hook types and contracts
packages/artifacts/src/artifactWorkspace.tsx
Exports types for selection fallback behavior, workspace descriptor, hook options, and result shape with artifact lists, selection state, and mutable action signatures.
Workspace state derivations and helpers
packages/artifacts/src/artifactWorkspace.tsx
Implements selectors for managed types, artifact config, and artifact IDs; derives selectedArtifactId with fallback when current artifact is missing or unmanaged; memoizes workspace-state fields.
Workspace sync effect and actions
packages/artifacts/src/artifactWorkspace.tsx
Syncs store currentArtifactId when derived selection changes; defines memoized action callbacks for creating (with type defaulting), deleting, renaming, and selecting artifacts constrained to managed IDs.
Workspace hook exports
packages/artifacts/src/index.ts
Re-exports useArtifactWorkspace hook and related types.

useArtifactTabs refactor to use workspace

Layer / File(s) Summary
Tabs imports and type updates
packages/artifacts/src/artifactTabs.tsx
Updates imports to include workspace hook; changes ArtifactTabDescriptor to extend ArtifactWorkspaceDescriptor; removes local isManagedType helper.
Initialize workspace and derive state
packages/artifacts/src/artifactTabs.tsx
Initializes useArtifactWorkspace with options.types; binds workspace artifacts/actions and store actions for layout synchronization.
Tab/layout synchronization
packages/artifacts/src/artifactTabs.tsx
Replaces artifactOrder/tabs computation with workspace-derived lists; adjusts current artifact effect to validate against artifactOrder.
Create, open, delete, rename, select actions
packages/artifacts/src/artifactTabs.tsx
Rewrites all action handlers to delegate artifact mutations to workspace methods then synchronize layout tabs and active tab state.

CLI UI panel and sidebar refactor

Layer / File(s) Summary
Sidebar hook: artifact-store-driven state
apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts
Removes createArtifactLayoutNode import; selectedTabId derives from currentArtifactId; selectArtifact removes workspace layout mutations; deleteArtifact simplified to artifact-store-only deletion.
Panel context and imports
apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
Replaces tab-strip imports with CliArtifactWorkspaceActionsContext; removes tab delete confirmation state; initializes workspace context provider.
Content host and artifact rendering
apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
Introduces CliArtifactContentHost to conditionally render chooser, emptyContent, or artifact content via context; updates SelectedCliArtifactContent to compute panelInfo from artifactTypes and render type component.
Artifact creation and close flows
apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
useCreateCliArtifactCommand invokes creation with actor 'artifact-content-host' and selects via context; CliArtifactsStartScreen closes by selecting return artifact via context; removes AssistantToggleButton and DeleteArtifactDialog.

Documentation

Layer / File(s) Summary
Workspace hook documentation
packages/artifacts/README.md
Documents useArtifactWorkspace as preferred hook for non-tab surfaces; adds usage example and clarifies that useArtifactTabs builds on useArtifactWorkspace to add layout-tabs adapter.

Sequence Diagram

sequenceDiagram
  participant ArtifactsContainerPanel as Panel
  participant CliArtifactWorkspaceActionsContext as Context
  participant CliArtifactContentHost as ContentHost
  participant SelectedCliArtifactContent as ArtifactContent
  participant useArtifactWorkspace as Workspace
  
  Panel->>Workspace: initialize workspace (types, selectFallback)
  Workspace->>Workspace: read currentArtifactId from store
  Workspace->>Workspace: derive selectedArtifactId with fallback
  Panel->>Context: provide selectedArtifactId, artifactIds, selectArtifact
  Context->>ContentHost: context available
  alt artifact selected
    ContentHost->>Workspace: read selectedArtifact from context
    ContentHost->>ContentHost: trigger ensureArtifact effect
    ContentHost->>ArtifactContent: render with selected artifact
    ArtifactContent->>ArtifactContent: render type-specific component
  else content prop provided (chooser open)
    ContentHost->>ContentHost: render content
  else no selection
    ContentHost->>ContentHost: render emptyContent
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • sqlrooms/sqlrooms#616: Modifies artifact-creation flow in ArtifactsContainerPanel.tsx and how post-create artifactId selection is handled, directly overlapping with this PR's useCreateCliArtifactCommand changes.
  • sqlrooms/sqlrooms#699: Introduces useCliArtifactSidebarTabs with workspace-tab-based selection and deletion behavior that this PR refactors to use the new workspace hook.
  • sqlrooms/sqlrooms#738: Modifies deleteArtifact behavior in useCliArtifactSidebarTabs.ts with tab-based cleanup logic that this PR removes in favor of the new workspace abstraction.

Suggested reviewers

  • dmitriy-kostianetskiy

Poem

🐇 No more tabs to juggle and stack,
A workspace hook brings order back.
Context flows, selection stays free,
From tab-strip walls, we're finally set free! ✨
The artifacts dance in the light of the store,
And the code is cleaner than ever before! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main architectural change—replacing the hidden ArtifactTabs with a CLI-local selected-artifact content host.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cli-artifact-content-host

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 and usage tips.

@ilyabo ilyabo changed the title [codex] Refactor CLI artifact content host refactor: Refactor CLI artifact content host Jun 20, 2026
@ilyabo
ilyabo marked this pull request as ready for review June 20, 2026 10:57

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

ℹ️ 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 useMemo(
() => ({
selectedArtifactId: 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.

P2 Badge Fall back to an existing artifact when current is unset

When a rehydrated or synced workspace has artifacts but no valid currentArtifactId (the artifacts schema permits it, and the CRDT mirror clears invalid current selections), this exposes selectedArtifactId as undefined, so CliArtifactContentHost shows the new-artifact start screen instead of opening an existing artifact. The removed ArtifactTabs host repaired this by adding workspace tabs and syncing currentArtifactId from the active tab, so existing workspaces in that state now land on the create screen until the user manually picks/closes. Please initialize/fall back to an artifact from artifactIds when the current ID is missing.

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: 1

🧹 Nitpick comments (2)
apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts (2)

6-91: ⚡ Quick win

Add TSDoc to the exported hook.

As per coding guidelines, exported functions in TypeScript files should have TSDoc comments. Adding documentation would help clarify the hook's purpose and the new store-driven selection model, especially following this refactor.

📝 Suggested TSDoc
+/**
+ * Hook providing sidebar tab state and actions for CLI artifacts.
+ * 
+ * Selection is driven by the artifact store's currentArtifactId rather than layout tabs.
+ * Returns artifact tabs with running AI session counts, and callbacks for selection,
+ * rename, and deletion operations.
+ */
 export function useCliArtifactSidebarTabs() {
🤖 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/workspace/sidebar/useCliArtifactSidebarTabs.ts`
around lines 6 - 91, The exported hook function useCliArtifactSidebarTabs is
missing TSDoc documentation. Add a TSDoc comment block above the function
definition that describes the hook's purpose, what it returns (including the
structure of the return object with properties like artifactTypes,
deleteArtifact, renameArtifact, selectedTabId, selectArtifact, and tabs), and
any relevant details about how it manages artifact state and the store-driven
selection model.

Source: Coding guidelines


13-15: 💤 Low value

Consider renaming selectedTabId to selectedArtifactId for clarity.

Now that the refactor has moved away from the tab-based model, the variable name selectedTabId is misleading. The upstream CliArtifactWorkspaceActionsContext uses selectedArtifactId for the same concept.

Renaming would improve consistency and make the code more self-documenting.

🤖 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/workspace/sidebar/useCliArtifactSidebarTabs.ts`
around lines 13 - 15, Rename the variable `selectedTabId` to
`selectedArtifactId` in the useCliArtifactSidebarTabs hook. This variable holds
the value from state.artifacts.config.currentArtifactId and should be renamed
throughout the file to match the naming convention used in
CliArtifactWorkspaceActionsContext and reflect the artifact-based model rather
than a tab-based one. Update all references to selectedTabId with
selectedArtifactId to maintain consistency across the component.
🤖 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/workspace/sidebar/useCliArtifactSidebarTabs.ts`:
- Around line 61-66: The selectArtifact callback in useCliArtifactSidebarTabs.ts
is missing validation to verify that the artifact exists in the artifactsById
map before calling setCurrentArtifact. Add a defensive check at the beginning of
the selectArtifact function that verifies the artifactId exists in artifactsById
and only proceeds with setCurrentArtifact and setShowArtifactChooser if the
validation passes. This will make the hook more defensive and consistent with
the upstream selectArtifact implementation in
useCliArtifactWorkspaceActionState.

---

Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts`:
- Around line 6-91: The exported hook function useCliArtifactSidebarTabs is
missing TSDoc documentation. Add a TSDoc comment block above the function
definition that describes the hook's purpose, what it returns (including the
structure of the return object with properties like artifactTypes,
deleteArtifact, renameArtifact, selectedTabId, selectArtifact, and tabs), and
any relevant details about how it manages artifact state and the store-driven
selection model.
- Around line 13-15: Rename the variable `selectedTabId` to `selectedArtifactId`
in the useCliArtifactSidebarTabs hook. This variable holds the value from
state.artifacts.config.currentArtifactId and should be renamed throughout the
file to match the naming convention used in CliArtifactWorkspaceActionsContext
and reflect the artifact-based model rather than a tab-based one. Update all
references to selectedTabId with selectedArtifactId to maintain consistency
across the component.
🪄 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: 875672b8-0af0-4e30-9706-518f8b308dca

📥 Commits

Reviewing files that changed from the base of the PR and between 3b3bb0a and 34c9b4a.

📒 Files selected for processing (2)
  • apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
  • apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.ts

Comment thread apps/sqlrooms-cli-ui/src/workspace/sidebar/useCliArtifactSidebarTabs.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: 0325d6ba05

ℹ️ 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 +126 to +129
selectedArtifactId:
currentArtifactId && artifactsById[currentArtifactId]
? currentArtifactId
: artifactIds[0],

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 Persist the fallback artifact as current

When a persisted or synced workspace has artifacts but currentArtifactId is unset or stale, this fallback only exposes artifactIds[0] through the local context. Fresh evidence: this version added the fallback here, but it still never calls setCurrentArtifact, so the content pane can render an artifact while global-selection consumers such as CliWorkspaceTopbar title/delete controls and AssistantChatContainer current context still behave as if no artifact is selected until the user manually reselects it. Set the current artifact when taking this fallback.

Useful? React with 👍 / 👎.

Comment on lines +216 to +217
<Component
key={artifact.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 Preserve mounted artifact panels when switching

This renders only one keyed artifact component, so selecting another artifact unmounts the previous panel. The removed ArtifactTabs passed forceMountContent, and TabsLayout.TabContent documents that mode as preserving local panel state/setup work; with this replacement, unsaved local state such as AppBuilderArtifact's prompt/template/name/status draft is lost if the user briefly switches artifacts before generating or saving. Keep prior panels mounted or hoist those drafts before replacing the force-mounted content path.

Useful? React with 👍 / 👎.

@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: 47479d5ebc

ℹ️ 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 +124 to +127
const selectedArtifactId =
currentArtifactId && artifactsById[currentArtifactId]
? currentArtifactId
: artifactIds[0];

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 Ignore non-CLI current artifacts

When a persisted or synced workspace has currentArtifactId pointing at an artifact whose type is not one of CLI_ARTIFACT_TYPES (the artifact schema allows arbitrary string types), this accepts it as the selected artifact merely because it exists in artifactsById. CliArtifactContentHost then calls ensureArtifact with that unregistered type, which the CLI artifacts slice rejects, instead of falling back to a valid CLI artifact from artifactIds; the workspace can crash or render no panel even though CLI artifacts are present. Please only use the current id here when it is included in the filtered CLI artifact set.

Useful? React with 👍 / 👎.

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

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

);

useEffect(() => {
if (!selectedArtifactId || selectedArtifactId === currentArtifactId) return;

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 Clear invalid current artifacts when no CLI fallback exists

When currentArtifactId is stale or points at a non-CLI artifact and artifactIds is empty, this early return leaves the invalid/non-CLI id in global state even though the content host renders the new-artifact screen. Fresh evidence here is that the new fallback only persists selectedArtifactId, so with no CLI fallback consumers such as the assistant context (which gates on a truthy currentArtifactId) or the topbar can still act on a hidden/unsupported artifact; the previous ArtifactTabs sync cleared the current artifact when no managed tab was active. Clear currentArtifactId in this branch instead of returning with the stale selection intact.

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: 1

🧹 Nitpick comments (1)
packages/artifacts/src/artifactTabs.tsx (1)

226-234: 💤 Low value

Consider removing redundant useMemo wrappers.

These memos return the already-memoized values from useArtifactWorkspace with those same values as dependencies, providing no additional memoization benefit.

♻️ Suggested simplification
-  const artifactOrder = useMemo(
-    () => artifactWorkspace.artifactIds,
-    [artifactWorkspace.artifactIds],
-  );
-
-  const tabs = useMemo<ArtifactTabDescriptor[]>(
-    () => artifactWorkspace.artifacts,
-    [artifactWorkspace.artifacts],
-  );
+  const artifactOrder = artifactWorkspace.artifactIds;
+  const tabs: ArtifactTabDescriptor[] = artifactWorkspace.artifacts;
🤖 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/artifactTabs.tsx` around lines 226 - 234, The useMemo
wrappers for both artifactOrder and tabs are redundant because they return the
same values that are already memoized from useArtifactWorkspace with identical
dependencies, providing no additional memoization benefit. Remove the useMemo
hooks from both variables: replace the artifactOrder useMemo wrapper with a
direct assignment to artifactWorkspace.artifactIds, and replace the tabs useMemo
wrapper with a direct assignment to artifactWorkspace.artifacts, eliminating the
unnecessary dependency arrays.
🤖 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 `@packages/artifacts/src/artifactWorkspace.tsx`:
- Around line 83-88: The typesKey calculation at line 83 fails to differentiate
between undefined (manage all types) and an empty array (manage none), since
both map to an empty string. This causes the managedTypes useMemo hook to not
recalculate when the caller switches between these two cases. Modify the
typesKey calculation to produce distinct values for each case, such as by
including a prefix marker (e.g., use a different sentinel value when
options.types is undefined versus when it's an empty array) so the dependency
array can properly detect the change.

---

Nitpick comments:
In `@packages/artifacts/src/artifactTabs.tsx`:
- Around line 226-234: The useMemo wrappers for both artifactOrder and tabs are
redundant because they return the same values that are already memoized from
useArtifactWorkspace with identical dependencies, providing no additional
memoization benefit. Remove the useMemo hooks from both variables: replace the
artifactOrder useMemo wrapper with a direct assignment to
artifactWorkspace.artifactIds, and replace the tabs useMemo wrapper with a
direct assignment to artifactWorkspace.artifacts, eliminating the unnecessary
dependency arrays.
🪄 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: ea7497e1-ace0-4d04-bd17-99baae659fbd

📥 Commits

Reviewing files that changed from the base of the PR and between fbe18c5 and 4b25049.

📒 Files selected for processing (5)
  • apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx
  • packages/artifacts/README.md
  • packages/artifacts/src/artifactTabs.tsx
  • packages/artifacts/src/artifactWorkspace.tsx
  • packages/artifacts/src/index.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/artifacts/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/sqlrooms-cli-ui/src/workspace/ArtifactsContainerPanel.tsx

Comment on lines +83 to +88
const typesKey = options.types?.join('\u0000') ?? '';
const managedTypes = useMemo(
() => (options.types ? [...options.types] : undefined),
// Keep inline arrays like types={['notebook']} stable by value.
[typesKey],
);

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Differentiate undefined and empty types in memo key.

typesKey at Line 83 maps both undefined and [] to '', so managedTypes can remain stale when the caller switches between “manage all” and “manage none”.

Suggested fix
-  const typesKey = options.types?.join('\u0000') ?? '';
+  const typesKey =
+    options.types === undefined ? 'all' : `managed:${options.types.join('\u0000')}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const typesKey = options.types?.join('\u0000') ?? '';
const managedTypes = useMemo(
() => (options.types ? [...options.types] : undefined),
// Keep inline arrays like types={['notebook']} stable by value.
[typesKey],
);
const typesKey =
options.types === undefined ? 'all' : `managed:${options.types.join('\u0000')}`;
const managedTypes = useMemo(
() => (options.types ? [...options.types] : undefined),
// Keep inline arrays like types={['notebook']} stable by value.
[typesKey],
);
🤖 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/artifactWorkspace.tsx` around lines 83 - 88, The
typesKey calculation at line 83 fails to differentiate between undefined (manage
all types) and an empty array (manage none), since both map to an empty string.
This causes the managedTypes useMemo hook to not recalculate when the caller
switches between these two cases. Modify the typesKey calculation to produce
distinct values for each case, such as by including a prefix marker (e.g., use a
different sentinel value when options.types is undefined versus when it's an
empty array) so the dependency array can properly detect the change.

@ilyabo
ilyabo merged commit 8eaacaf into main Jun 21, 2026
3 checks passed
@ilyabo
ilyabo deleted the codex/cli-artifact-content-host branch June 21, 2026 11:18
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