Skip to content

feat(platform): add chat pinning to copilot sidebar#13453

Open
Abhi1992002 wants to merge 7 commits into
devfrom
Abhi1992002/copilot-chat-pinning
Open

feat(platform): add chat pinning to copilot sidebar#13453
Abhi1992002 wants to merge 7 commits into
devfrom
Abhi1992002/copilot-chat-pinning

Conversation

@Abhi1992002

@Abhi1992002 Abhi1992002 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Why / What / How

Why: Users want to keep important copilot chats accessible instead of losing them as the recency-sorted sidebar list grows. This is the small, separable "pin chats" win flagged in the sidebar/projects discussion — low overlap with the larger agent-personas/projects work, so it can ship independently and behind a flag.

What: Adds the ability to pin/unpin a copilot chat. Pinned chats surface at the top of the sidebar regardless of recency. The UI is gated behind a new chat-pinning LaunchDarkly flag so we can roll it out incrementally (and bundle it with the other sidebar UI updates).

How:

  • Storage uses a dedicated ChatSession.isPinned boolean column (mirrors the existing LibraryAgent.isFavorite pattern) so the list query can order pinned-first at the DB level rather than per-page in memory.
  • list_sessions orders by (isPinned desc, updatedAt desc) and returns is_pinned on each summary.
  • A new PATCH /sessions/{id}/pinned route toggles the flag (owner-scoped, mirrors the title-update path including the Redis cache update). Pinning does not bump updatedAt so it doesn't reorder within its bucket.
Screen.Recording.2026-06-30.at.4.29.07.PM.mov

Changes 🏗️

Backend

  • schema.prisma: add ChatSession.isPinned Boolean @default(false) + migration 20260630120000_add_chat_session_is_pinned.
  • copilot/model.py: ChatSessionInfo.is_pinned, populate in from_db, new update_session_pinned() (DB + cache).
  • copilot/db.py: update_chat_session_pinned(); get_user_chat_sessions now orders pinned-first.
  • api/features/chat/routes.py: UpdateSessionPinnedRequest, PATCH /sessions/{id}/pinned, is_pinned on SessionSummaryResponse.

Frontend (all behind Flag.CHAT_PINNING)

  • use-get-flag.ts: new chat-pinning flag + env override.
  • ChatSidebar: Pin/Unpin dropdown action wired to the new mutation.
  • ChatSessionBlock: pin indicator on pinned rows (+ Storybook story).

Tests

  • Backend: route tests (pin/unpin/404/422), list_sessions returns is_pinned, db helper + ordering tests.
  • Frontend: sidebar integration tests (pin action + pinned indicator/Unpin label).

Note: pnpm generate:api must be run so the usePatchV2UpdateSessionPinned hook + MSW handlers (and is_pinned on the session type) are regenerated from the updated OpenAPI spec.

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Backend unit tests pass (routes_test.py 96 passed, db_test.py incl. new pin/ordering tests)
    • pnpm generate:api then pnpm test:unit for the sidebar integration tests
    • Enable chat-pinning flag, pin a chat → it jumps to the top with a pin icon; unpin → returns to recency order
    • Pinned state persists across reload

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
Add the ability to pin copilot chats to the top of the sidebar.

Backend:
- New ChatSession.isPinned column (+ migration), mirrors LibraryAgent.isFavorite
- PATCH /sessions/{id}/pinned route + update_session_pinned model/db helpers
- list_sessions orders pinned-first (isPinned desc, updatedAt desc) and
  returns is_pinned on each summary

Frontend (behind chat-pinning flag):
- Pin/Unpin action in the chat dropdown menu
- Pin indicator on pinned chat rows
- chat-pinning feature flag + env override

Tests: route + db unit tests, sidebar integration tests, ChatSessionBlock story.
@Abhi1992002 Abhi1992002 requested a review from a team as a code owner June 30, 2026 05:57
@Abhi1992002 Abhi1992002 requested review from Bentlybro and kcze and removed request for a team June 30, 2026 05:57
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jun 30, 2026
@github-actions github-actions Bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 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

Adds chat session pinning across storage, API, feature flag, and sidebar UI, including a new pin/unpin endpoint, pinned session ordering, and pinned-state display in the chat sidebar.

Changes

Chat Session Pinning

Layer / File(s) Summary
Schema, migration, and DB helper
autogpt_platform/backend/schema.prisma, autogpt_platform/backend/migrations/.../migration.sql, autogpt_platform/backend/backend/copilot/db.py, autogpt_platform/backend/backend/data/db_manager.py, autogpt_platform/backend/backend/copilot/db_test.py, autogpt_platform/backend/backend/copilot/sharing/db_test.py
Adds isPinned to ChatSession, creates the migration column, adds update_chat_session_pinned scoped by (id, userId), updates session ordering to sort pinned rows first, exposes the new RPC through the database manager clients, and updates DB/sharing fixtures and tests.
ChatSessionInfo model and update_session_pinned
autogpt_platform/backend/backend/copilot/model.py
Adds is_pinned to ChatSessionInfo, maps it from Prisma, and implements update_session_pinned with DB update, cached-session refresh, and failure handling.
REST endpoint and session listing
autogpt_platform/backend/backend/api/features/chat/routes.py, autogpt_platform/backend/backend/api/features/chat/routes_test.py, autogpt_platform/frontend/src/app/api/openapi.json
Adds is_pinned to session summaries, populates it in /sessions, defines UpdateSessionPinnedRequest, and adds PATCH /sessions/{session_id}/pinned with auth validation and 404 handling.
CHAT_PINNING feature flag
autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
Adds Flag.CHAT_PINNING, sets its default to false, and supports NEXT_PUBLIC_FORCE_FLAG_CHAT_PINNING.
Frontend ChatSessionBlock and ChatSidebar UI
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/..., autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx, autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
ChatSessionBlock renders a pinned icon when enabled, and ChatSidebar wires pin/unpin mutation handling, pinned state display, and the conditional dropdown action.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • Bentlybro
  • kcze

Poem

🐇 I hopped through chat rows soft and bright,
A pin now gleams to hold them right.
From schema deep to sidebar view,
The pinned ones stay near you. 📌

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% 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
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding chat pinning to the copilot sidebar.
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.
Description check ✅ Passed The description clearly matches the pin/unpin chat session changes across backend, frontend, and tests.
✨ 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 Abhi1992002/copilot-chat-pinning

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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
autogpt_platform/backend/backend/api/features/chat/routes.py (1)

378-438: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the /sessions ordering docs to match the new contract.

Line 387 still says this endpoint is ordered by “most recently updated”, but the backing query now sorts pinned sessions first and only uses updatedAt as the tiebreaker. Leaving that wording in place will make the generated API docs inaccurate for clients.

🤖 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 `@autogpt_platform/backend/backend/api/features/chat/routes.py` around lines
378 - 438, Update the list_sessions endpoint documentation so the ordering
contract matches the current behavior: the docstring in list_sessions and any
related /sessions response docs should no longer say the results are ordered by
“most recently updated” alone. Describe the actual ordering used by
get_user_sessions, with pinned sessions first and updatedAt only as the
tiebreaker, so the generated API docs stay accurate for clients.
🧹 Nitpick comments (2)
autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx (1)

103-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the standard Orval error extraction in this mutation.

This toast can drop backend-provided detail text for pin/unpin failures. Please mirror the usual Copilot mutation pattern here: prefer ApiError.response?.detail, then error.message, then a generic fallback.

Based on learnings, Copilot Orval hook onError handlers should explicitly handle ApiError, prefer error.response?.detail, then fall back to error.message and a generic message.

🤖 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
`@autogpt_platform/frontend/src/app/`(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
around lines 103 - 118, The onError handler in ChatSidebar’s
usePatchV2UpdateSessionPinned mutation is not using the standard Orval error
extraction, so backend detail text can be lost. Update the toast logic to handle
ApiError explicitly and prefer ApiError.response?.detail first, then fall back
to error.message, and finally a generic message; keep the change scoped to the
mutation’s onError handler and its toast call.

Source: Learnings

autogpt_platform/backend/backend/api/features/chat/routes_test.py (1)

145-197: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use snapshots for these new API response tests.

These cases are validating response payloads for /sessions and /sessions/{id}/pinned, but they still hard-code the JSON shape inline. Converting them to snapshot assertions will keep future contract changes like is_pinned visible in one reviewable diff instead of scattered across per-field checks. As per coding guidelines, autogpt_platform/backend/**/*_test.py: “Use pytest with snapshot testing for API responses”.

Also applies to: 1291-1314

🤖 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 `@autogpt_platform/backend/backend/api/features/chat/routes_test.py` around
lines 145 - 197, The new API response tests in test_update_pinned_success,
test_update_pinned_unpin, test_update_pinned_missing_field_rejected, and
test_update_pinned_not_found still assert response payloads inline instead of
using snapshots. Update these /sessions/{id}/pinned tests to use snapshot
assertions for the response bodies (and any validation/error payloads where
applicable) so future contract changes are captured consistently in one place.

Source: Coding guidelines

🤖 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 `@autogpt_platform/backend/backend/copilot/model.py`:
- Around line 1238-1258: The outer try/except in update_chat_session_pinned is
swallowing unexpected DB/runtime errors and returning False, which the chat
route later interprets as not found or unauthorized. Keep the existing False
return only for the legitimate not-found/ownership path from
chat_db().update_chat_session_pinned, and remove or narrow the broad exception
handling so unexpected failures from update_chat_session_pinned propagate
instead of being converted into a 404. Update the logging around
_get_session_from_cache and cache_chat_session separately if needed, but do not
catch generic exceptions around the main update_chat_session_pinned call.

---

Outside diff comments:
In `@autogpt_platform/backend/backend/api/features/chat/routes.py`:
- Around line 378-438: Update the list_sessions endpoint documentation so the
ordering contract matches the current behavior: the docstring in list_sessions
and any related /sessions response docs should no longer say the results are
ordered by “most recently updated” alone. Describe the actual ordering used by
get_user_sessions, with pinned sessions first and updatedAt only as the
tiebreaker, so the generated API docs stay accurate for clients.

---

Nitpick comments:
In `@autogpt_platform/backend/backend/api/features/chat/routes_test.py`:
- Around line 145-197: The new API response tests in test_update_pinned_success,
test_update_pinned_unpin, test_update_pinned_missing_field_rejected, and
test_update_pinned_not_found still assert response payloads inline instead of
using snapshots. Update these /sessions/{id}/pinned tests to use snapshot
assertions for the response bodies (and any validation/error payloads where
applicable) so future contract changes are captured consistently in one place.

In
`@autogpt_platform/frontend/src/app/`(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx:
- Around line 103-118: The onError handler in ChatSidebar’s
usePatchV2UpdateSessionPinned mutation is not using the standard Orval error
extraction, so backend detail text can be lost. Update the toast logic to handle
ApiError explicitly and prefer ApiError.response?.detail first, then fall back
to error.message, and finally a generic message; keep the change scoped to the
mutation’s onError handler and its toast call.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48526266-0b88-4134-9c70-28e788e7ddd4

📥 Commits

Reviewing files that changed from the base of the PR and between b6438a2 and a313874.

📒 Files selected for processing (13)
  • autogpt_platform/backend/backend/api/features/chat/routes.py
  • autogpt_platform/backend/backend/api/features/chat/routes_test.py
  • autogpt_platform/backend/backend/copilot/db.py
  • autogpt_platform/backend/backend/copilot/db_test.py
  • autogpt_platform/backend/backend/copilot/model.py
  • autogpt_platform/backend/backend/copilot/sharing/db_test.py
  • autogpt_platform/backend/migrations/20260630120000_add_chat_session_is_pinned/migration.sql
  • autogpt_platform/backend/schema.prisma
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.stories.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSessionBlock/ChatSessionBlock.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/ChatSidebar.tsx
  • autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatSidebar/__tests__/ChatSidebar.test.tsx
  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
Comment thread autogpt_platform/backend/backend/copilot/model.py Outdated
- Expose update_chat_session_pinned on DatabaseManager(Async)Client so
  chat_db().update_chat_session_pinned type-checks (pyright)
- Regenerate committed openapi.json with the new pinned endpoint so
  generate:api produces usePatchV2UpdateSessionPinned (fixes FE build/e2e)
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.17857% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.71%. Comparing base (b6438a2) to head (f891014).
⚠️ Report is 5 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13453      +/-   ##
==========================================
- Coverage   74.71%   74.71%   -0.01%     
==========================================
  Files        2537     2537              
  Lines      192322   192437     +115     
  Branches    18928    18935       +7     
==========================================
+ Hits       143690   143772      +82     
- Misses      44500    44530      +30     
- Partials     4132     4135       +3     
Flag Coverage Δ
platform-backend 81.99% <92.78%> (+<0.01%) ⬆️
platform-frontend 43.13% <78.57%> (+0.06%) ⬆️
platform-frontend-e2e 31.84% <14.28%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 81.99% <92.78%> (+<0.01%) ⬆️
Platform Frontend 47.43% <73.33%> (-0.06%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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

🤖 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 `@autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts`:
- Line 50: The rollout flag for chat pinning is currently fail-open because
`useGetFlag()` falls back to `defaultFlags[Flag.CHAT_PINNING]`, which turns the
feature on when LaunchDarkly is unavailable or returns no value. Update the flag
handling in `useGetFlag` so `Flag.CHAT_PINNING` defaults to false unless
LaunchDarkly explicitly returns true, preserving the kill switch for the sidebar
UI. Keep the change localized to the `defaultFlags`/fallback logic in
`useGetFlag` and ensure the chat pinning flag is treated as a gated rollout
rather than a safe default-on feature.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 618081de-1fdb-4cd7-811e-272f174f6278

📥 Commits

Reviewing files that changed from the base of the PR and between b0ea7c0 and ecdb71a.

📒 Files selected for processing (1)
  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
  • GitHub Check: integration_test
  • GitHub Check: check API types
  • GitHub Check: Analyze (python)
  • GitHub Check: end-to-end tests
  • GitHub Check: Check PR Status
  • GitHub Check: test (3.12)
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: type-check (3.11)
⚠️ CI failures not shown inline (2)

GitHub Actions: PR Overlap Detection / 0_check-overlaps.txt: feat(platform): add chat pinning to copilot sidebar

Conclusion: failure

View job details

##[group]Run python .github/scripts/detect_overlaps.py 13453
 �[36;1mpython .github/scripts/detect_overlaps.py 13453�[0m
 shell: /usr/bin/bash -e {0}
 env:
   pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
   PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
   Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
   GH_***REDACTED***
 ##[endgroup]
 Warning: PR `#13330` has >100 files, overlap detection may be incomplete
 Warning: PR `#13433` has >100 files, overlap detection may be incomplete
 Warning: PR `#12653` has >100 files, overlap detection may be incomplete
 Warning: PR `#13429` has >100 files, overlap detection may be incomplete
 Warning: PR `#12206` has >100 files, overlap detection may be incomplete
 Warning: PR `#12669` has >100 files, overlap detection may be incomplete
 Error running gh pr diff 13429: could not find pull request diff: HTTP 406: Sorry, the diff exceeded the maximum number of files (300). Consider using 'List pull requests files' API or locally cloning the repository instead. (https://api.github.com/repos/Significant-Gravitas/AutoGPT/pulls/13429)
 PullRequest.diff too_large
 Checking PR `#13453` in Significant-Gravitas/AutoGPT
 PR `#13453`: feat(platform): add chat pinning to copilot sidebar
 Base branch: dev
 Files changed: 15
 Found 170 other open PRs targeting dev
 Found 15 PRs with file overlap (excluding ignored files)
 ##[error]Process completed with exit code 1.

GitHub Actions: PR Overlap Detection / check-overlaps: feat(platform): add chat pinning to copilot sidebar

Conclusion: failure

View job details

##[group]Run python .github/scripts/detect_overlaps.py 13453
 �[36;1mpython .github/scripts/detect_overlaps.py 13453�[0m
 shell: /usr/bin/bash -e {0}
 env:
   pythonLocation: /opt/hostedtoolcache/Python/3.11.15/x64
   PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib/pkgconfig
   Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.15/x64
   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.15/x64/lib
   GH_***REDACTED***
 ##[endgroup]
 Warning: PR `#13330` has >100 files, overlap detection may be incomplete
 Warning: PR `#13433` has >100 files, overlap detection may be incomplete
 Warning: PR `#12653` has >100 files, overlap detection may be incomplete
 Warning: PR `#13429` has >100 files, overlap detection may be incomplete
 Warning: PR `#12206` has >100 files, overlap detection may be incomplete
 Warning: PR `#12669` has >100 files, overlap detection may be incomplete
 Error running gh pr diff 13429: could not find pull request diff: HTTP 406: Sorry, the diff exceeded the maximum number of files (300). Consider using 'List pull requests files' API or locally cloning the repository instead. (https://api.github.com/repos/Significant-Gravitas/AutoGPT/pulls/13429)
 PullRequest.diff too_large
 Checking PR `#13453` in Significant-Gravitas/AutoGPT
 PR `#13453`: feat(platform): add chat pinning to copilot sidebar
 Base branch: dev
 Files changed: 15
 Found 170 other open PRs targeting dev
 Found 15 PRs with file overlap (excluding ignored files)
 ##[error]Process completed with exit code 1.
🧰 Additional context used
📓 Path-based instructions (8)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development

Format frontend code using pnpm format

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Fully capitalize acronyms in symbols, e.g. graphID, useBackendAPI
No linter suppressors (// @ts-ignore``, // eslint-disable) — fix the actual issue

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/__generated__/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/
'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend development

autogpt_platform/frontend/**/*.{ts,tsx}: Use function declarations (not arrow functions) for components/handlers
No any types unless the value genuinely can be anything
Keep render functions and hooks under ~50 lines; extract named helpers or sub-components when they grow longer

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/src/**/*.{ts,tsx}: Use generated API hooks from @/app/api/__generated__/endpoints/ following the pattern use{Method}{Version}{OperationName}, and regenerate with pnpm generate:api
Separate render logic from business logic using component.tsx + useComponent.ts + helpers.ts pattern, colocate state when possible and avoid creating large components, use sub-components in local /components folder
Use function declarations for components and handlers, use arrow functions only for callbacks
Do not use useCallback or useMemo unless asked to optimise a given function

autogpt_platform/frontend/src/**/*.{ts,tsx}: Keep files under ~200 lines; extract sub-components or hooks into their own files when a file grows beyond this
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName}
Always import the -Icon-suffixed alias from @phosphor-icons/react (e.g. TrashIcon, PlusIcon, SquareIcon) — bare exports are deprecated
Do not use useCallback or useMemo unless asked to optimize a given function
Never use src/components/__legacy__/* — use design system components from src/components/

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

No barrel files or index.ts re-exports in the frontend

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Do not type hook returns, let Typescript infer as much as possible

autogpt_platform/frontend/src/**/*.ts: Extract component logic into custom hooks grouped by concern, not by component, with each hook in its own .ts file
Do not type hook returns; let TypeScript infer as much as possible

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never type with any, if no types available use unknown

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
autogpt_platform/frontend/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

Avoid index and barrel files

Files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
🧠 Learnings (3)
📚 Learning: 2026-04-01T18:54:16.035Z
Learnt from: Bentlybro
Repo: Significant-Gravitas/AutoGPT PR: 12633
File: autogpt_platform/frontend/src/app/(platform)/library/components/AgentFilterMenu/AgentFilterMenu.tsx:3-10
Timestamp: 2026-04-01T18:54:16.035Z
Learning: In the frontend, the legacy Select component at `@/components/__legacy__/ui/select` is an intentional, codebase-wide visual-consistency pattern. During code reviews, do not flag or block PRs merely for continuing to use this legacy Select. If a migration to the newer design-system Select is desired, bundle it into a single dedicated cleanup/migration PR that updates all Select usages together (e.g., avoid piecemeal replacements).

Applied to files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
📚 Learning: 2026-04-07T09:24:16.582Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12686
File: autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/__tests__/PainPointsStep.test.tsx:1-19
Timestamp: 2026-04-07T09:24:16.582Z
Learning: In Significant-Gravitas/AutoGPT’s `autogpt_platform/frontend` (Vite + `vitejs/plugin-react` with the automatic JSX transform), do not flag usages of React types/components (e.g., `React.ReactNode`) in `.ts`/`.tsx` files as missing `React` imports. Since the React namespace is made available by the project’s TS/Vite setup, an explicit `import React from 'react'` or `import type { ReactNode } ...` is not required; only treat it as missing if typechecking (e.g., `pnpm types`) would actually fail.

Applied to files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
📚 Learning: 2026-04-02T05:43:49.128Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12640
File: autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/WelcomeStep.tsx:13-13
Timestamp: 2026-04-02T05:43:49.128Z
Learning: Do not flag `import { Question } from "phosphor-icons/react"` as an invalid import. `Question` is a valid named export from `phosphor-icons/react` (as reflected in the package’s generated `.d.ts` files and re-exports via `dist/index.d.ts`), so it should be treated as a supported named export during code reviews.

Applied to files:

  • autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts
Comment thread autogpt_platform/frontend/src/services/feature-flags/use-get-flag.ts Outdated
- model.py: let unexpected DB errors in update_session_pinned propagate
  (only return False for real not-found/wrong-user) so the route returns
  5xx instead of masking failures as 404
- routes.py: correct list_sessions docstring — pinned-first, updatedAt tiebreaker
- ChatSidebar: use standard Orval ApiError.response?.detail extraction in
  the pin/unpin onError toast
@github-actions github-actions Bot added size/xl and removed size/l labels Jun 30, 2026
@Abhi1992002

Copy link
Copy Markdown
Contributor Author

@coderabbitai addressed your review in 87f3e9a:

  • update_session_pinned swallowing DB errors (Major) — fixed; broad outer try/except removed so unexpected failures propagate as 5xx, False reserved for real not-found/wrong-user.

  • list_sessions ordering docstring (outside-diff) — updated to "pinned sessions first, most-recently-updated as tiebreaker".

  • ChatSidebar pin/unpin onError (nitpick) — now uses the standard Orval extraction: ApiError.response?.detailerror.message → generic fallback.

  • Snapshot tests for the pin routes (nitpick) — skipping intentionally. The sibling test_update_title_* tests for the adjacent PATCH /sessions/{id}/title endpoint assert the {"status": "ok"} payload inline; converting only the pin tests to snapshots would make the two endpoints' test styles inconsistent. The is_pinned contract is already covered by test_list_sessions_returns_is_pinned.

  • Docstring coverage warning — the substantive new functions have docstrings; the gap is test functions, which we leave undocumented by convention.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@Abhi1992002 Thanks for the thorough follow-up — that all sounds good.

The update_session_pinned error-handling change, the ordering doc update, and the ChatSidebar error extraction update address my concerns. Your rationale for keeping the pin-route assertions inline for consistency with the adjacent title-route tests also makes sense, and I’m fine with leaving test functions undocumented if that’s the established convention here.

🐇✨


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Comment thread autogpt_platform/backend/backend/copilot/db.py
Comment thread autogpt_platform/backend/backend/copilot/model.py
A pin written out-of-band by update_session_pinned could be reverted in
the Redis cache when an end-of-stream upsert wrote a stale in-memory
session (is_pinned=False). Mirror the existing cached-title preservation
in upsert_chat_session so is_pinned is taken from the cache too. Adds a
regression test.
@0ubbe

0ubbe commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

!deploy

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deploying PR #13453 to development environment...

@0ubbe

0ubbe commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Preview Environment Deployed Successfully

📊 Deployment Summary

Service Status
Redis ✅ Success
RabbitMQ ✅ Success
Backend Server ✅ Success
WebSocket Server ✅ Success
Scheduler Server ✅ Success
Notification Server ✅ Success
Frontend (Vercel) ✅ Success

🔔 Please check Discord for the preview environment URLs and details.

The deployment status and URLs will be posted in the AutoGPT Discord server.

@github-actions github-actions Bot added the conflicts Automatically applied to PRs with merge conflicts label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically applied to PRs with merge conflicts platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/xl

2 participants