refactor(backend): remove deprecated BetaUserCredit class - #12825
refactor(backend): remove deprecated BetaUserCredit class#12825slepybear wants to merge 2 commits into
Conversation
Why: - BetaUserCredit was a temporary class for monthly credit refill feature - The TODO comment explicitly requested its removal - The feature toggle (ENABLE_PLATFORM_PAYMENT) is no longer needed What: - Removed BetaUserCredit class from credit.py - Simplified get_user_credit_model to return UserCredit directly - Updated all test files to use UserCredit instead of BetaUserCredit - Removed test_block_credit_reset test that depended on monthly refill behavior How: - Removed BetaUserCredit class definition - get_user_credit_model now simply returns UserCredit when credits are enabled - All tests updated to reflect that monthly refill feature is deprecated
|
This PR targets the Automatically setting the base branch to |
WalkthroughThe changes remove the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| // Default collapse object outputs to save canvas real-estate | ||
| // User must manually expand to see sub-outputs | ||
| const shouldRenderChildren = isExpanded; |
There was a problem hiding this comment.
Bug: Setting shouldRenderChildren = isExpanded prevents rendering connected sub-output handles, breaking edges that connect to nested object outputs.
Severity: HIGH
Suggested Fix
Restore the auto-expand behaviour for connected descendants: const shouldRenderChildren = isExpanded || descendantIsRelevant;. If the intent is to collapse by default for unconnected objects only, then the previous behaviour already achieved that — connected descendants were the only case that triggered auto-expansion.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx#L90-L92
Potential issue: Before this change, `shouldRenderChildren = isExpanded ||
descendantIsRelevant` ensured that any object node with a connected descendant would
auto-expand to keep the child `OutputNodeHandle` in the DOM. After the change,
`shouldRenderChildren = isExpanded` collapses children regardless of whether a child
output is connected to an edge. When a saved graph is loaded and an edge targets a
nested sub-output of a collapsed object, the `OutputNodeHandle` (React Flow `<Handle>`)
for that sub-output is never rendered. React Flow cannot find the handle DOM element for
the edge, causing the edge to appear broken or invisible. The parent object is still
shown (because `shouldShow` still checks `descendantIsRelevant`), but its children's
handles are absent, creating a disconnect between the data model and the UI.
Did we get this right? 👍 / 👎 to inform future reviews.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## dev #12825 +/- ##
==========================================
- Coverage 65.14% 65.06% -0.08%
==========================================
Files 1831 1831
Lines 135945 135901 -44
Branches 14534 14529 -5
==========================================
- Hits 88555 88429 -126
- Misses 44670 44756 +86
+ Partials 2720 2716 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
autogpt_platform/backend/backend/data/credit_integration_test.py (1)
103-118: Drop the removed beta-refill settings from these test setups.These tests now instantiate
UserCredit()directly, so theenable_credit,enable_beta_monthly_credit, andnum_user_credits_refillmonkeypatches no longer influence the behavior under test. Keeping them here makes the auto-top-up flow still look coupled to the deprecated refill path.Also applies to: 237-245
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@autogpt_platform/backend/backend/data/credit_integration_test.py` around lines 103 - 118, The test_auto_top_up_integration and similar tests are patching deprecated beta-refill settings that no longer affect behavior because the tests instantiate UserCredit() directly; remove the monkeypatch.setattr calls that modify settings.config.enable_credit, settings.config.enable_beta_monthly_credit, and settings.config.num_user_credits_refill from test_auto_top_up_integration and the other test(s) in the same file that perform the same three patches (around the other test block referenced), leaving only the necessary setup (e.g., cleanup_test_user and UserCredit()) so the test asserts the actual auto-top-up flow without coupling to the removed refill feature.autogpt_platform/backend/backend/data/credit_test.py (1)
20-29: Rename or simplify this test now that refill is gone.
test_credit_refillnow verifies that no refill happens, whiledisable_test_user_transactions()still backdatesupdatedAt“to trigger monthly refill.” That mismatch makes the test intent harder to read than it needs to be after this refactor.Also applies to: 125-129
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@autogpt_platform/backend/backend/data/credit_test.py` around lines 20 - 29, The helper disable_test_user_transactions() still backdates updatedAt to "trigger monthly refill" even though refill behavior was removed; rename or simplify this helper and remove the backdating: stop computing old_date and stop setting updatedAt in the upsert, just delete transactions and set balance to 0 (create/update only touching balance), and rename the function to something like disable_test_user_transactions_or_reset_test_user to reflect the new intent; also update the other occurrence that mirrors lines 125-129 to match these same changes and any test names that referenced refill (e.g., test_credit_refill) so they clearly assert "no refill" or use the simplified helper.autogpt_platform/backend/backend/data/credit.py (1)
1168-1181: Update this function’s contract to match the new implementation.Lines 1169-1177 still describe LaunchDarkly-based model selection, but Line 1181 now always returns
UserCredit()when credits are enabled. That leaves the docstring misleading right after removing the beta path, and it also makesuser_idlook semantically important when it no longer is.✏️ Suggested docstring cleanup
async def get_user_credit_model(user_id: str) -> UserCreditBase: """ - Get the credit model for a user, considering LaunchDarkly flags. + Get the credit model for a user. Args: - user_id (str): The user ID to check flags for. + user_id (str): The user ID. Returns: - UserCreditBase: The appropriate credit model for the user + UserCreditBase: `DisabledUserCredit` when credits are disabled, + otherwise `UserCredit`. """🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@autogpt_platform/backend/backend/data/credit.py` around lines 1168 - 1181, The docstring for get_user_credit_model is outdated (mentions LaunchDarkly and implies user_id matters) while the implementation simply returns DisabledUserCredit when settings.config.enable_credit is false and UserCredit otherwise; update the docstring summary, Args and Returns to reflect that behavior, and either remove the unused user_id parameter from the function signature or note in the docstring that user_id is unused/kept for API compatibility; reference get_user_credit_model, DisabledUserCredit and UserCredit so the changes are applied to that function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@autogpt_platform/frontend/src/app/`(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx:
- Around line 90-92: The children are currently hidden when not expanded because
shouldRenderChildren is set solely to isExpanded; update OutputHandler.tsx to
keep descendants mounted when they have active connections or errors. Replace
the simple flag with a computed value (e.g., shouldRenderChildren = isExpanded
|| hasConnectedOrErroredDescendant(output)) where
hasConnectedOrErroredDescendant traverses output.children (or output.outputs)
recursively and returns true if any descendant has an active connection flag
(e.g., connected, isConnected) or an error/validation flag (e.g., hasError,
validationError, brokenConnection). Use that helper in the render condition so
connected/broken nested outputs remain rendered even when collapsed.
---
Nitpick comments:
In `@autogpt_platform/backend/backend/data/credit_integration_test.py`:
- Around line 103-118: The test_auto_top_up_integration and similar tests are
patching deprecated beta-refill settings that no longer affect behavior because
the tests instantiate UserCredit() directly; remove the monkeypatch.setattr
calls that modify settings.config.enable_credit,
settings.config.enable_beta_monthly_credit, and
settings.config.num_user_credits_refill from test_auto_top_up_integration and
the other test(s) in the same file that perform the same three patches (around
the other test block referenced), leaving only the necessary setup (e.g.,
cleanup_test_user and UserCredit()) so the test asserts the actual auto-top-up
flow without coupling to the removed refill feature.
In `@autogpt_platform/backend/backend/data/credit_test.py`:
- Around line 20-29: The helper disable_test_user_transactions() still backdates
updatedAt to "trigger monthly refill" even though refill behavior was removed;
rename or simplify this helper and remove the backdating: stop computing
old_date and stop setting updatedAt in the upsert, just delete transactions and
set balance to 0 (create/update only touching balance), and rename the function
to something like disable_test_user_transactions_or_reset_test_user to reflect
the new intent; also update the other occurrence that mirrors lines 125-129 to
match these same changes and any test names that referenced refill (e.g.,
test_credit_refill) so they clearly assert "no refill" or use the simplified
helper.
In `@autogpt_platform/backend/backend/data/credit.py`:
- Around line 1168-1181: The docstring for get_user_credit_model is outdated
(mentions LaunchDarkly and implies user_id matters) while the implementation
simply returns DisabledUserCredit when settings.config.enable_credit is false
and UserCredit otherwise; update the docstring summary, Args and Returns to
reflect that behavior, and either remove the unused user_id parameter from the
function signature or note in the docstring that user_id is unused/kept for API
compatibility; reference get_user_credit_model, DisabledUserCredit and
UserCredit so the changes are applied to that function.
🪄 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: 949c1958-6986-4433-9bf2-1085089d28a4
📒 Files selected for processing (5)
autogpt_platform/backend/backend/data/credit.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: check API types
- GitHub Check: integration_test
- GitHub Check: Seer Code Review
- GitHub Check: end-to-end tests
- GitHub Check: type-check (3.11)
- GitHub Check: type-check (3.12)
- GitHub Check: test (3.12)
- GitHub Check: test (3.11)
- GitHub Check: test (3.13)
- GitHub Check: type-check (3.13)
- GitHub Check: Analyze (python)
- GitHub Check: Check PR Status
- GitHub Check: conflicts
🧰 Additional context used
📓 Path-based instructions (14)
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 developmentFormat frontend code using
pnpm format
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
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/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
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}: Fully capitalize acronyms in symbols, e.g.graphID,useBackendAPI
Use function declarations (not arrow functions) for components and handlers
Nodark:Tailwind classes — the design system handles dark mode
Use Next.js<Link>for internal navigation — never raw<a>tags
Noanytypes unless the value genuinely can be anything
No linter suppressors (//@ts-ignore``,// eslint-disable) — fix the actual issue
Keep files under ~200 lines; extract sub-components or hooks into their own files when a file grows beyond this
Keep render functions and hooks under ~50 lines; extract named helpers or sub-components when they grow longer
Use generated API hooks from `@/app/api/generated/endpoints/` with pattern `use{Method}{Version}{OperationName}` and regenerate with `pnpm generate:api`
Do not use `useCallback` or `useMemo` unless asked to optimise a given function
Separate render logic (`.tsx`) from business logic (`use*.ts` hooks)
Use ErrorCard for render errors, toast for mutations, and Sentry for exceptions in the frontend
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
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 patternuse{Method}{Version}{OperationName}, and regenerate withpnpm 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/componentsfolder
Use function declarations for components and handlers, use arrow functions only for callbacks
Do not useuseCallbackoruseMemounless asked to optimise a given function
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/frontend/**/*.{tsx,css}
📄 CodeRabbit inference engine (AGENTS.md)
Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/frontend/src/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Component props should use
interface Props { ... }(not exported) unless the interface needs to be used outside the component
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Never type with
any, if no types available useunknown
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/frontend/src/app/(platform)/**/components/**/*.tsx
📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)
Put sub-components in local
components/folder
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/frontend/**/*.tsx
📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)
autogpt_platform/frontend/**/*.tsx: Component props should betype Props = { ... }(not exported) unless it needs to be used outside the component
Use design system components fromsrc/components/(atoms, molecules, organisms)
Never usesrc/components/__legacy__/*
Tailwind CSS only for styling, use design tokens, Phosphor Icons only
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
autogpt_platform/backend/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development
autogpt_platform/backend/**/*.py: Usepoetry run ...command for executing Python package dependencies
Use top-level imports only — avoid local/inner imports except for lazy imports of heavy optional dependencies likeopenpyxl
Use absolute imports withfrom backend.module import ...for cross-package imports; single-dot relative imports are acceptable for sibling modules within the same package; avoid double-dot relative imports
Do not use duck typing — avoidhasattr/getattr/isinstancefor type dispatch; use typed interfaces/unions/protocols instead
Use Pydantic models over dataclass/namedtuple/dict for structured data
Do not use linter suppressors — no# type: ignore,# noqa,# pyright: ignore; fix the type/code instead
Prefer list comprehensions over manual loop-and-append patterns
Use early return with guard clauses first to avoid deep nesting
Use%sfor deferred interpolation indebuglog statements for efficiency; use f-strings elsewhere for readability (e.g.,logger.debug("Processing %s items", count)vslogger.info(f"Processing {count} items"))
Sanitize error paths by usingos.path.basename()in error messages to avoid leaking directory structure
Be aware of TOCTOU (Time-Of-Check-Time-Of-Use) issues — avoid check-then-act patterns for file access and credit charging
Usetransaction=Truefor Redis pipelines to ensure atomicity on multi-step operations
Usemax(0, value)guards for computed values that should never be negative
Keep files under ~300 lines; if a file grows beyond this, split by responsibility (extract helpers, models, or a sub-module into a new file)
Keep functions under ~40 lines; extract named helpers when a function grows longer
...
Files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
autogpt_platform/backend/backend/data/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
All data access in backend requires user ID checks; verify this for any 'data/*.py' changes
Files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
autogpt_platform/{backend,autogpt_libs}/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Format Python code with
poetry run format
Files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
autogpt_platform/**/data/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
For changes touching
data/*.py, validate user ID checks or explain why not needed
Files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
autogpt_platform/backend/**/*_test.py
📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)
autogpt_platform/backend/**/*_test.py: Use pytest with snapshot testing for API responses
Colocate test files with source files using*_test.pynaming convention
Mock at boundaries — mock where the symbol is used, not where it's defined; after refactoring, update mock targets to match new module paths
UseAsyncMockfromunittest.mockfor async functions in tests
When writing tests, use Test-Driven Development (TDD): write failing tests marked with@pytest.mark.xfailbefore implementation, then remove the marker once the implementation is complete
When creating snapshots in tests, usepoetry run pytest path/to/test.py --snapshot-update; always review snapshot changes withgit diffbefore committing
Files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.py
🧠 Learnings (25)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12566
File: autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts:968-974
Timestamp: 2026-03-26T00:32:06.673Z
Learning: In Significant-Gravitas/AutoGPT, the admin-facing methods in `autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts` (e.g., `addUserCredits`, `getUsersHistory`, `getUserRateLimit`, `resetUserRateLimit`) intentionally follow the legacy `BackendAPI` pattern with manually defined types in `autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts`. Migrating these admin endpoints to the generated OpenAPI hooks (`@/app/api/__generated__/endpoints/`) is a planned separate effort covering all admin endpoints together, not done piecemeal per PR. Do not flag individual admin type additions in `types.ts` as blocking issues.
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.
📚 Learning: 2026-03-10T06:22:57.658Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 12354
File: autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/CustomNode.tsx:26-30
Timestamp: 2026-03-10T06:22:57.658Z
Learning: In the AutoGPT platform frontend (autogpt_platform/frontend/), `advanced=true` fields are always declared directly on the top-level `Input` class for every block. Advanced fields are never nested inside objects, arrays, anyOf, oneOf, or allOf variants. Therefore, a top-level-only check of `schema.properties` (as done in `hasAdvancedFields` in `CustomNode.tsx`) is sufficient and correct; a recursive schema walk is not needed.
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-04-07T16:17:45.540Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12699
File: autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx:0-0
Timestamp: 2026-04-07T16:17:45.540Z
Learning: In `autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts`, `handleApplyAction` is synchronous and always succeeds from the user's perspective when the node exists; it early-returns (no-op) only if the node is not found, which cannot happen in normal flow. Therefore, setting `applied=true` immediately on click in `ActionItem` (BuilderChatPanel.tsx) is correct UX — do not flag this pattern as a stale/premature state update.
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/frontend/**/*.{tsx,ts} : Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-04-05T14:10:57.905Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12629
File: autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/reactArtifactPreview.ts:1-1
Timestamp: 2026-04-05T14:10:57.905Z
Learning: In `autogpt_platform/frontend/src/app/(platform)/copilot/components/ArtifactPanel/components/ArtifactContent.tsx` and `autogpt_platform/frontend/src/components/contextual/OutputRenderers/renderers/HTMLRenderer.tsx`, CSP (Content Security Policy) headers are injected via `wrapWithHeadInjection`, not inline in each renderer. Do not flag missing CSP in individual renderer files.
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-04-08T17:27:45.740Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-08T17:27:45.740Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : 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
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-02-27T10:45:49.499Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunMCPTool/helpers.tsx:23-24
Timestamp: 2026-02-27T10:45:49.499Z
Learning: Prefer using generated OpenAPI types from '@/app/api/__generated__/' for payloads defined in openapi.json (e.g., MCPToolsDiscoveredResponse, MCPToolOutputResponse). Use inline TypeScript interfaces only for payloads that are SSE-stream-only and not exposed via OpenAPI. Apply this pattern to frontend tool components (e.g., RunMCPTool) and related areas where similar SSE/openapi-discrepancies occur; avoid re-implementing types when a generated type is available.
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-03-24T02:05:04.672Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12526
File: autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx:0-0
Timestamp: 2026-03-24T02:05:04.672Z
Learning: When gating React component logic on a React Query result (e.g., hooks like `useQuery` / `useGetV2GetCopilotUsage`), prefer destructuring and checking `isSuccess` (or aliasing it to a meaningful boolean like `isSuccess: hasUsage`) instead of relying on `!isLoading`. Reason: `isLoading` can be `false` in error/idle states where `data` may still be `undefined`, while `isSuccess` indicates the query completed successfully and `data` is populated.
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 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/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 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/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 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/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-04-13T13:11:07.445Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12764
File: autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx:143-145
Timestamp: 2026-04-13T13:11:07.445Z
Learning: In `autogpt_platform/frontend`, do not flag direct interpolation of `executionID` UUID strings into URL query parameters (e.g., `activeItem=${executionID}` in JSX/Next links). If the value is a UUID string matching `[0-9a-f-]`, it contains no reserved URL characters, so additional `encodeURIComponent` or Next.js object-based `href` encoding is unnecessary. Only treat it as an encoding issue if the query-param value is not guaranteed to be UUID-formatted (i.e., may include characters outside `[0-9a-f-]`).
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-04-15T22:49:06.896Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11235
File: autogpt_platform/frontend/src/app/(platform)/admin/diagnostics/components/ExecutionsTable.tsx:0-0
Timestamp: 2026-04-15T22:49:06.896Z
Learning: In the AutoGPT frontend (React Query + toast/ErrorCard patterns), do not require `Sentry.captureException` in React Query mutation `catch` blocks. React Query handles error propagation for mutation paths, so follow the established pattern: show toast notifications for mutation errors and use `ErrorCard` for render/fetch errors. Only add `Sentry.captureException` for truly manual/unexpected exception paths that are outside React Query’s control (e.g., standalone async utilities or event handlers not wired through React Query).
Applied to files:
autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/**/test/**/*.py : Use snapshot testing with '--snapshot-update' flag in backend tests when output changes; always review with 'git diff'
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.py
📚 Learning: 2026-03-26T00:32:06.673Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12566
File: autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts:968-974
Timestamp: 2026-03-26T00:32:06.673Z
Learning: In Significant-Gravitas/AutoGPT, the admin-facing methods in `autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts` (e.g., `addUserCredits`, `getUsersHistory`, `getUserRateLimit`, `resetUserRateLimit`) intentionally follow the legacy `BackendAPI` pattern with manually defined types in `autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts`. Migrating these admin endpoints to the generated OpenAPI hooks (`@/app/api/__generated__/endpoints/`) is a planned separate effort covering all admin endpoints together, not done piecemeal per PR. Do not flag individual admin type additions in `types.ts` as blocking issues.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/data/**/*.py : All data access in backend requires user ID checks; verify this for any 'data/*.py' changes
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.py
📚 Learning: 2026-03-04T23:58:18.476Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.py
📚 Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-03-05T15:42:08.207Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12297
File: .claude/skills/backend-check/SKILL.md:14-16
Timestamp: 2026-03-05T15:42:08.207Z
Learning: In Python files under autogpt_platform/backend (recursively), rely on poetry run format to perform formatting (Black + isort) and linting (ruff). Do not run poetry run lint as a separate step after poetry run format, since format already includes linting checks.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-03-16T16:35:40.236Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/api/features/workflow_import.py:54-63
Timestamp: 2026-03-16T16:35:40.236Z
Learning: Avoid using the word 'competitor' in public-facing identifiers and text. Use neutral naming for API paths, model names, function names, and UI text. Examples: rename 'CompetitorFormat' to 'SourcePlatform', 'convert_competitor_workflow' to 'convert_workflow', '/competitor-workflow' to '/workflow'. Apply this guideline to files under autogpt_platform/backend and autogpt_platform/frontend.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-03-31T15:37:38.626Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12623
File: autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py:37-47
Timestamp: 2026-03-31T15:37:38.626Z
Learning: When validating/constructing Anthropic API model IDs in Significant-Gravitas/AutoGPT, allow the hyphen-separated Claude Opus 4.6 model ID `claude-opus-4-6` (it corresponds to `LlmModel.CLAUDE_4_6_OPUS` in `autogpt_platform/backend/backend/blocks/llm.py`). Do NOT require the dot-separated form in Anthropic contexts. Only OpenRouter routing variants should use the dot separator (e.g., `anthropic/claude-opus-4.6`); `claude-opus-4-6` should be treated as correct when passed to Anthropic, and flagged only if it’s used in the OpenRouter path where the dot form is expected.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-04-15T02:43:36.890Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12780
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:0-0
Timestamp: 2026-04-15T02:43:36.890Z
Learning: When reviewing Python exception handlers, do not flag `isinstance(e, X)` checks as dead/unreachable if the caught exception `X` is a subclass of the exception type being handled. For example, if `X` (e.g., `VirusScanError`) inherits from `ValueError` (directly or via an intermediate class) and it can be raised within an `except ValueError:` block, then `isinstance(e, X)` inside that handler is reachable and should not be treated as dead code.
Applied to files:
autogpt_platform/backend/backend/data/credit_metadata_test.pyautogpt_platform/backend/backend/data/credit_integration_test.pyautogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-04-08T17:28:23.439Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/AGENTS.md:0-0
Timestamp: 2026-04-08T17:28:23.439Z
Learning: Applies to autogpt_platform/backend/**/*_test.py : Mock at boundaries — mock where the symbol is **used**, not where it's **defined**; after refactoring, update mock targets to match new module paths
Applied to files:
autogpt_platform/backend/backend/data/credit_test.py
📚 Learning: 2026-03-15T15:30:09.706Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12385
File: autogpt_platform/backend/backend/copilot/tools/helpers.py:149-185
Timestamp: 2026-03-15T15:30:09.706Z
Learning: In autogpt_platform/backend/backend/copilot/tools/helpers.py, within execute_block, when InsufficientBalanceError occurs after post-execution credit charging (concurrent balance drain after pre-check passed), this is treated as a non-fatal billing leak: log at ERROR level with structured JSON fields `{"billing_leak": True, "user_id": ..., "cost": ...}` for monitoring/alerting, then return BlockOutputResponse normally. Discarding the output would worsen UX since the block already executed with potential side effects. Reuse the credit_model obtained during the pre-execution balance check (guarded by `if cost > 0 and credit_model:`) for the post-execution charge; do not perform a second get_user_credit_model call.
Applied to files:
autogpt_platform/backend/backend/data/credit_test.pyautogpt_platform/backend/backend/data/credit.py
📚 Learning: 2026-03-17T10:57:12.953Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.
Applied to files:
autogpt_platform/backend/backend/data/credit.py
| // Default collapse object outputs to save canvas real-estate | ||
| // User must manually expand to see sub-outputs | ||
| const shouldRenderChildren = isExpanded; |
There was a problem hiding this comment.
Connected/broken nested outputs are hidden unless manually expanded.
At Line 92, child rendering is now gated only by isExpanded, so relevant descendants (connected or broken) are unmounted by default. This makes existing nested connections/errors easy to miss.
🔧 Suggested fix
- const shouldRenderChildren = isExpanded;
+ const shouldRenderChildren = isExpanded || descendantIsRelevant;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@autogpt_platform/frontend/src/app/`(platform)/build/components/FlowEditor/nodes/OutputHandler.tsx
around lines 90 - 92, The children are currently hidden when not expanded
because shouldRenderChildren is set solely to isExpanded; update
OutputHandler.tsx to keep descendants mounted when they have active connections
or errors. Replace the simple flag with a computed value (e.g.,
shouldRenderChildren = isExpanded || hasConnectedOrErroredDescendant(output))
where hasConnectedOrErroredDescendant traverses output.children (or
output.outputs) recursively and returns true if any descendant has an active
connection flag (e.g., connected, isConnected) or an error/validation flag
(e.g., hasError, validationError, brokenConnection). Use that helper in the
render condition so connected/broken nested outputs remain rendered even when
collapsed.
|
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
|
Closing — superseded by work already merged to You proposed this cleanup first — the BetaUserCredit removal later shipped via #12969 (commit The remaining If this is wrong, comment here or reopen — this was an automated triage pass reviewed by a maintainer. |
Why
BetaUserCredit was a temporary class for monthly credit refill feature. The TODO comment explicitly requested its removal since the feature toggle (ENABLE_PLATFORM_PAYMENT) is no longer needed.
What
How
Checklist