Skip to content

✨(sources) add source panel - #480

Open
elvoisin wants to merge 1 commit into
mainfrom
evoisin/source-panel
Open

✨(sources) add source panel#480
elvoisin wants to merge 1 commit into
mainfrom
evoisin/source-panel

Conversation

@elvoisin

@elvoisin elvoisin commented May 19, 2026

Copy link
Copy Markdown
Contributor

add sources panel

Screenshot 2026-05-12 at 18 01 38

Summary by CodeRabbit

  • New Features

    • Added a dedicated sources panel alongside the chat interface for viewing source information.
    • The panel can be opened or hidden from chat messages, with its state remembered between sessions.
    • Improved source listings with numbered entries, clearer type indicators, and enhanced loading or error states.
    • Updated chat action icons, including copy and sources controls, for clearer interaction.
  • Documentation

    • Updated the changelog with the sources panel addition.

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Chat sources now render in a right-side panel through a React portal. Panel visibility persists in chat preferences. Layout code provides the anchor and adjusts chat dimensions. Source items and message action icons use updated rendering and styling.

Changes

Sources Panel Refactor

Layer / File(s) Summary
Sources Panel Context and Store
src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts, src/frontend/apps/conversations/src/features/sources-panel/SourcePanel.tsx, src/frontend/apps/conversations/src/features/sources-panel/index.ts
The preferences store adds persisted sources-panel visibility state. SourcePanel provides the anchor through context and exports the related hook.
Source Item Rendering
src/frontend/apps/conversations/src/features/chat/components/SourceItem.tsx, src/frontend/apps/conversations/src/features/chat/components/SourceItemList.tsx
SourceItem requires an index, adds translated website fallback content, and updates source layout and styling. SourceItemList passes one-based indexes and uses simplified container styling.
Main Layout Panel Integration
src/frontend/apps/conversations/src/layouts/MainLayout.tsx
MainLayout adds the right-side panel anchor, calculates panel offsets, wraps the chat column with SourcePanel, and controls responsive visibility and accessibility behavior.
Chat Portal and Message Actions
src/frontend/apps/conversations/src/features/chat/components/Chat.tsx, src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx, src/frontend/apps/conversations/src/pages/globals.css
Chat synchronizes panel state, derives source parts, builds panel content, and renders it through a portal. MessageItem uses dedicated SVG icons and removes inline source-list rendering. CSS styles the action icons.
Release Note
CHANGELOG.md
The changelog records the new sources panel.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MessageItem
  participant Chat
  participant PreferencesStore
  participant SourcePanel
  User->>MessageItem: toggles sources
  MessageItem->>Chat: selects message sources
  Chat->>PreferencesStore: updates panel visibility
  Chat->>Chat: derives source parts
  Chat->>SourcePanel: renders panel content through portal
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly identifies the main change: adding a sources panel to the conversations interface.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch evoisin/source-panel

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 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
`@src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx`:
- Around line 457-461: The toggle button currently shows a state label
("Hidden") instead of an action; update the JSX in MessageItem (the expression
using isSourceOpen, message.id and sourceParts) so when the panel is open
(isSourceOpen === message.id) it renders the imperative label t('Hide') instead
of t('Hidden'), and when closed it remains t('Show'); keep the count and
pluralization logic (sourceParts.length and t('source'/'sources')) unchanged.

In
`@src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts`:
- Around line 51-57: The partialize function in useChatPreferencesStore
currently omits isSourcesPanelOpen so that preference isn't persisted; update
the partialize return to include isSourcesPanelOpen alongside
themeModePreference, selectedModelHrid, forceWebSearch, isDarkModePreference,
and isPanelOpen so the sources panel open/closed state is stored and restored
across reloads.

In `@src/frontend/apps/conversations/src/layouts/MainLayout.tsx`:
- Around line 86-90: The closed-panel right offset uses a hardcoded '-300px'
while the panel width constant is SOURCES_PANEL_WIDTH_PX (360); update the
ternary in the styled/template string that uses isSourcesPanelOpen so the closed
position uses `-${SOURCES_PANEL_WIDTH_PX}px` instead of '-300px' (i.e., replace
the hardcoded value with the SOURCES_PANEL_WIDTH_PX-based expression) to ensure
the slide distance matches the panel width.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1855b4c3-9f37-4e25-8775-858f8cf95ec3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0e408 and 8fbb597.

⛔ Files ignored due to path filters (5)
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/book-filled.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/book.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/checkmark.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/clipboard.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/sources.svg is excluded by !**/*.svg
📒 Files selected for processing (10)
  • CHANGELOG.md
  • src/frontend/apps/conversations/src/features/chat/components/Chat.tsx
  • src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/SourceItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/SourceItemList.tsx
  • src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts
  • src/frontend/apps/conversations/src/features/sources-panel/SourcePanel.tsx
  • src/frontend/apps/conversations/src/features/sources-panel/index.ts
  • src/frontend/apps/conversations/src/layouts/MainLayout.tsx
  • src/frontend/apps/conversations/src/pages/globals.css

Comment on lines +457 to 461
{isSourceOpen !== message.id ? t('Show') : t('Hidden')}{' '}
{isSourceOpen !== message.id
? `${sourceParts.length} `
: ''}
{sourceParts.length !== 1 ? t('sources') : t('source')}

Copy link
Copy Markdown

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

Use an action label instead of state text for the toggle button.

On Line 457, Hidden reads like a status, not a button action. Prefer an imperative label (Hide) when the panel is open.

🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 458-458: Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=suitenumerique_conversations&issues=AZ4_g4kaNqnL1Qk74aQy&open=AZ4_g4kaNqnL1Qk74aQy&pullRequest=480


[warning] 457-457: Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=suitenumerique_conversations&issues=AZ4_g4kaNqnL1Qk74aQx&open=AZ4_g4kaNqnL1Qk74aQx&pullRequest=480

🤖 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 `@src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx`
around lines 457 - 461, The toggle button currently shows a state label
("Hidden") instead of an action; update the JSX in MessageItem (the expression
using isSourceOpen, message.id and sourceParts) so when the panel is open
(isSourceOpen === message.id) it renders the imperative label t('Hide') instead
of t('Hidden'), and when closed it remains t('Show'); keep the count and
pluralization logic (sourceParts.length and t('source'/'sources')) unchanged.

Comment on lines +51 to +57
partialize: (state) => ({
themeModePreference: state.themeModePreference,
selectedModelHrid: state.selectedModelHrid,
forceWebSearch: state.forceWebSearch,
isDarkModePreference: state.isDarkModePreference,
isPanelOpen: state.isPanelOpen,
}),

Copy link
Copy Markdown

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

Persist isSourcesPanelOpen in chat preferences.

On Line 51, partialize excludes isSourcesPanelOpen, so this preference resets after reload while other panel preferences are restored.

Proposed fix
       partialize: (state) => ({
         themeModePreference: state.themeModePreference,
         selectedModelHrid: state.selectedModelHrid,
         forceWebSearch: state.forceWebSearch,
         isDarkModePreference: state.isDarkModePreference,
         isPanelOpen: state.isPanelOpen,
+        isSourcesPanelOpen: state.isSourcesPanelOpen,
       }),
📝 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
partialize: (state) => ({
themeModePreference: state.themeModePreference,
selectedModelHrid: state.selectedModelHrid,
forceWebSearch: state.forceWebSearch,
isDarkModePreference: state.isDarkModePreference,
isPanelOpen: state.isPanelOpen,
}),
partialize: (state) => ({
themeModePreference: state.themeModePreference,
selectedModelHrid: state.selectedModelHrid,
forceWebSearch: state.forceWebSearch,
isDarkModePreference: state.isDarkModePreference,
isPanelOpen: state.isPanelOpen,
isSourcesPanelOpen: state.isSourcesPanelOpen,
}),
🤖 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
`@src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts`
around lines 51 - 57, The partialize function in useChatPreferencesStore
currently omits isSourcesPanelOpen so that preference isn't persisted; update
the partialize return to include isSourcesPanelOpen alongside
themeModePreference, selectedModelHrid, forceWebSearch, isDarkModePreference,
and isPanelOpen so the sources panel open/closed state is stored and restored
across reloads.

Comment on lines +86 to +90
right: ${isSourcesPanelOpen ? '0px' : '-300px'};
bottom: 0;
z-index: 1001;
width: ${SOURCES_PANEL_WIDTH_PX}px;
`

Copy link
Copy Markdown

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

Use the same offset constant for closed panel position.

On Line 86, the closed position uses -300px while the panel width is 360px. This creates an inconsistent slide distance.

Proposed fix
-                    right: ${isSourcesPanelOpen ? '0px' : '-300px'};
+                    right: ${isSourcesPanelOpen
+                      ? '0px'
+                      : `-${SOURCES_PANEL_WIDTH_PX}px`};
📝 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
right: ${isSourcesPanelOpen ? '0px' : '-300px'};
bottom: 0;
z-index: 1001;
width: ${SOURCES_PANEL_WIDTH_PX}px;
`
right: ${isSourcesPanelOpen
? '0px'
: `-${SOURCES_PANEL_WIDTH_PX}px`};
bottom: 0;
z-index: 1001;
width: ${SOURCES_PANEL_WIDTH_PX}px;
`
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 86-86: Extract this nested ternary operation into an independent statement.

See more on https://sonarcloud.io/project/issues?id=suitenumerique_conversations&issues=AZ4_g4pHNqnL1Qk74aQ0&open=AZ4_g4pHNqnL1Qk74aQ0&pullRequest=480

🤖 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 `@src/frontend/apps/conversations/src/layouts/MainLayout.tsx` around lines 86 -
90, The closed-panel right offset uses a hardcoded '-300px' while the panel
width constant is SOURCES_PANEL_WIDTH_PX (360); update the ternary in the
styled/template string that uses isSourcesPanelOpen so the closed position uses
`-${SOURCES_PANEL_WIDTH_PX}px` instead of '-300px' (i.e., replace the hardcoded
value with the SOURCES_PANEL_WIDTH_PX-based expression) to ensure the slide
distance matches the panel width.

@elvoisin
elvoisin force-pushed the evoisin/source-panel branch from 8fbb597 to 8066847 Compare August 12, 2026 08:24
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai 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.

🔇 Additional comments (3)
src/frontend/apps/conversations/src/features/chat/components/Chat.tsx (2)

394-408: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

⚠️ Unverified finding
Sandbox verification was unavailable.

Keep the preferences store update outside the React state updater.

Line 398 mutates the external preferences store inside setIsSourceOpen. React can retry this updater without committing the local state change. The layout can then reserve the sources panel while isSourceOpen remains closed.

Update isSourceOpen in the callback only. Synchronize setSourcesPanelOpen(Boolean(isSourceOpen)) in a useEffect after React commits the state.


2-18: LGTM!

Also applies to: 46-48, 88-89, 98-98, 410-471, 1007-1007, 1173-1175

CHANGELOG.md (1)

152-152: LGTM!


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18036f86-d740-40b6-8b61-dd0b7427ef63

📥 Commits

Reviewing files that changed from the base of the PR and between fd2d24b and 8066847.

⛔ Files ignored due to path filters (5)
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/book-filled.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/book.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/checkmark.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/clipboard.svg is excluded by !**/*.svg
  • src/frontend/apps/conversations/src/assets/icons/uikit-custom/sources.svg is excluded by !**/*.svg
📒 Files selected for processing (10)
  • CHANGELOG.md
  • src/frontend/apps/conversations/src/features/chat/components/Chat.tsx
  • src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/SourceItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/SourceItemList.tsx
  • src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts
  • src/frontend/apps/conversations/src/features/sources-panel/SourcePanel.tsx
  • src/frontend/apps/conversations/src/features/sources-panel/index.ts
  • src/frontend/apps/conversations/src/layouts/MainLayout.tsx
  • src/frontend/apps/conversations/src/pages/globals.css
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/frontend/apps/conversations/src/pages/globals.css
  • src/frontend/apps/conversations/src/features/chat/components/SourceItemList.tsx
  • src/frontend/apps/conversations/src/features/sources-panel/SourcePanel.tsx
  • src/frontend/apps/conversations/src/layouts/MainLayout.tsx
  • src/frontend/apps/conversations/src/features/chat/stores/useChatPreferencesStore.ts
  • src/frontend/apps/conversations/src/features/sources-panel/index.ts
  • src/frontend/apps/conversations/src/features/chat/components/MessageItem.tsx
  • src/frontend/apps/conversations/src/features/chat/components/SourceItem.tsx

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