Rename primary organization from "Main" to "Default"#282
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (30)
📝 WalkthroughWalkthroughThis PR comprehensively refactors organization terminology across the codebase, replacing all "main organization" references ( ChangesDefault Organization Terminology Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The PR is a systematic refactoring with high consistency across the codebase. While the scope is large (many files and test assertions), the changes follow a predictable pattern—replacing Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #282 +/- ##
=========================================
Coverage 91.62% 91.62%
Complexity 2328 2328
=========================================
Files 203 203
Lines 8278 8278
=========================================
Hits 7585 7585
Misses 693 693 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
app/Http/Middleware/DemoModeMiddleware.php (1)
51-54:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate stale PHPDoc terminology in
ensureDemoUserExists().The docblock still says “main org” (Line 53), but the method now attaches the demo user to the default org. Please align the comment to avoid drift.
As per coding guidelines "Prefer PHPDoc blocks over inline comments. Only add inline comments for exceptionally complex logic."Proposed patch
- * Attaches to main org with demo role. + * Attaches to default org with demo role.🤖 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 `@app/Http/Middleware/DemoModeMiddleware.php` around lines 51 - 54, Update the PHPDoc for ensureDemoUserExists() to reflect current behavior: replace the phrase “main org” with “default org” and ensure the docblock describes that the demo user is attached to the default organization with the demo role; modify only the docblock above the ensureDemoUserExists() method so it uses the updated terminology and remains a proper PHPDoc block.tests/Pest.php (1)
96-99:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRename helper PHPDoc from “main” to “default” organization.
The helper now seeds
is_default/Default, but the docblock still describes “main organization.” Please update it for consistency.As per coding guidelines "Prefer PHPDoc blocks over inline comments. Only add inline comments for exceptionally complex logic."Proposed patch
- * Create the main organization and set it as the current org context. + * Create the default organization and set it as the current org context.🤖 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 `@tests/Pest.php` around lines 96 - 99, Update the PHPDoc above the helper that creates the organization to call it the "default organization" instead of "main organization" to match the seeded is_default/Default attribute; keep the rest of the doc concise and retain the note that this ensures OrganizationScope and CurrentOrganization work in tests so the docblock accurately reflects the helper's behavior.
🧹 Nitpick comments (3)
app/Policies/OrganizationPolicy.php (1)
28-30: ⚡ Quick winUpdate the
update()docblock to “non-default orgs.”The method behavior now uses
is_default, so this wording should be aligned.Proposed docblock tweak
- * Super admins can rename non-main orgs. + * Super admins can rename non-default orgs.🤖 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 `@app/Policies/OrganizationPolicy.php` around lines 28 - 30, Update the docblock for the OrganizationPolicy::update() method to say “non-default orgs” instead of “non-main orgs” so the comment matches the implemented check using is_default; locate the update() method's docblock in the OrganizationPolicy class and replace the phrase accordingly to keep wording consistent with the is_default logic.app/Services/OAuthService.php (1)
133-135: ⚡ Quick winUpdate stale “main org” wording in docblocks.
Behavior now resolves the default organization (Line 222), but these comments still describe “main org,” which is now outdated.
Proposed doc-only cleanup
- * Updates role in the user's default org (main org or configured OIDC org). + * Updates role in the user's default org (configured org or fallback default org). ... - * Auto-attaches to the default org (main or OIDC-configured org). + * Auto-attaches to the default org (fallback or OIDC-configured org). ... - * Uses OAUTH_DEFAULT_ORGANIZATION_ID if set, otherwise main org. + * Uses OAUTH_DEFAULT_ORGANIZATION_ID if set, otherwise the default org.Also applies to: 179-182, 207-210
🤖 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 `@app/Services/OAuthService.php` around lines 133 - 135, Update stale "main org" wording in the docblocks in app/Services/OAuthService.php so they refer to the resolved "default organization" terminology used by the code; find the docblocks around the "Sync user role from OIDC claims." comment (and the other blocks at the same section near the earlier mentions) and replace any occurrences of "main org" with "default organization" (or similar consistent phrasing) to match the behavior implemented in the default-organization resolution done later in the method.app/Actions/Fortify/CreateNewUser.php (1)
66-67: ⚡ Quick winLine 66 comment still says “main org.”
Please rename it to “default org” to match the actual attach behavior and avoid future confusion.
Proposed comment fix
- // Attach to main org as admin + // Attach to default org as admin🤖 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 `@app/Actions/Fortify/CreateNewUser.php` around lines 66 - 67, Update the misleading inline comment: in the CreateNewUser action, replace the comment "main org" above the $user->organizations()->attach(...) call with "default org" to reflect that the user is being attached to the default organization as admin (reference: CreateNewUser::handle / the attach call using UserRole::Admin->value).
🤖 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 `@app/Mcp/Tools/ListOrganizationsTool.php`:
- Line 34: The new literal "Default organization" should be localized: update
the string concatenation in the return statement inside the
ListOrganizationsTool (the code that checks $org->is_default) to wrap that
phrase with the __('...') helper and ensure the key is added to the locale JSON
files; specifically modify the conditional that appends ' | Default
organization' so it uses __('Default organization') (preserving the surrounding
separator) and then add the translation entry to lang/{locale}.json.
In `@resources/views/livewire/configuration/organization.blade.php`:
- Line 30: Add the missing translation key "The default organization cannot be
edited or deleted." to both locale JSON files (es.json and fr.json): add the
Spanish value "La organización predeterminada no se puede editar ni eliminar."
and the French value "L'organisation par défaut ne peut pas être modifiée ou
supprimée." so the Blade template translation call resolves correctly.
---
Outside diff comments:
In `@app/Http/Middleware/DemoModeMiddleware.php`:
- Around line 51-54: Update the PHPDoc for ensureDemoUserExists() to reflect
current behavior: replace the phrase “main org” with “default org” and ensure
the docblock describes that the demo user is attached to the default
organization with the demo role; modify only the docblock above the
ensureDemoUserExists() method so it uses the updated terminology and remains a
proper PHPDoc block.
In `@tests/Pest.php`:
- Around line 96-99: Update the PHPDoc above the helper that creates the
organization to call it the "default organization" instead of "main
organization" to match the seeded is_default/Default attribute; keep the rest of
the doc concise and retain the note that this ensures OrganizationScope and
CurrentOrganization work in tests so the docblock accurately reflects the
helper's behavior.
---
Nitpick comments:
In `@app/Actions/Fortify/CreateNewUser.php`:
- Around line 66-67: Update the misleading inline comment: in the CreateNewUser
action, replace the comment "main org" above the
$user->organizations()->attach(...) call with "default org" to reflect that the
user is being attached to the default organization as admin (reference:
CreateNewUser::handle / the attach call using UserRole::Admin->value).
In `@app/Policies/OrganizationPolicy.php`:
- Around line 28-30: Update the docblock for the OrganizationPolicy::update()
method to say “non-default orgs” instead of “non-main orgs” so the comment
matches the implemented check using is_default; locate the update() method's
docblock in the OrganizationPolicy class and replace the phrase accordingly to
keep wording consistent with the is_default logic.
In `@app/Services/OAuthService.php`:
- Around line 133-135: Update stale "main org" wording in the docblocks in
app/Services/OAuthService.php so they refer to the resolved "default
organization" terminology used by the code; find the docblocks around the "Sync
user role from OIDC claims." comment (and the other blocks at the same section
near the earlier mentions) and replace any occurrences of "main org" with
"default organization" (or similar consistent phrasing) to match the behavior
implemented in the default-organization resolution done later in the method.
🪄 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: e0faeed5-9f4d-4b15-8806-cede5b96b990
📒 Files selected for processing (31)
app/Actions/Fortify/CreateNewUser.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Http/Resources/OrganizationResource.phpapp/Livewire/Configuration/Organization.phpapp/Livewire/OrganizationSwitcher.phpapp/Mcp/Tools/ListOrganizationsTool.phpapp/Models/Organization.phpapp/Policies/OrganizationPolicy.phpapp/Services/CurrentOrganization.phpapp/Services/OAuthService.phpdatabase/factories/AgentFactory.phpdatabase/factories/DatabaseServerFactory.phpdatabase/factories/DatabaseServerSshConfigFactory.phpdatabase/factories/OrganizationFactory.phpdatabase/factories/UserFactory.phpdatabase/factories/VolumeFactory.phpdatabase/migrations/2026_05_05_000001_create_organizations_tables.phpdatabase/migrations/2026_05_05_000002_backfill_organizations_data.phpdatabase/seeders/DatabaseSeeder.phpdocs/docs/self-hosting/configuration/sso.mddocs/docs/user-guide/organizations.mdresources/views/livewire/configuration/organization.blade.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Auth/OAuthTest.phptests/Feature/Auth/RegistrationTest.phptests/Feature/Configuration/OrganizationTest.phptests/Feature/Dashboard/SnapshotsCardTest.phptests/Feature/DemoModeTest.phptests/Feature/User/CreateTest.phptests/Feature/User/EditTest.phptests/Pest.php
📜 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). (1)
- GitHub Check: ci
🧰 Additional context used
📓 Path-based instructions (7)
**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.php: In PHP files, always use curly braces for control structures, even for single-line bodies.
Use PHP 8 constructor property promotion:public function __construct(public GitHub $github) { }. Do not leave empty zero-parameter__construct()methods unless the constructor is private.
Use explicit return type declarations and type hints for all method parameters in PHP:function isAccessible(User $user, ?string $path = null): bool
Prefer PHPDoc blocks over inline comments. Only add inline comments for exceptionally complex logic.
Use array shape type definitions in PHPDoc blocks for PHP.
Files:
app/Livewire/Configuration/Organization.phptests/Feature/Auth/RegistrationTest.phpdatabase/factories/UserFactory.phpdatabase/factories/DatabaseServerSshConfigFactory.phpapp/Http/Resources/OrganizationResource.phpapp/Services/OAuthService.phpapp/Mcp/Tools/ListOrganizationsTool.phptests/Feature/DemoModeTest.phpdatabase/factories/DatabaseServerFactory.phpapp/Livewire/OrganizationSwitcher.phpdatabase/factories/AgentFactory.phpresources/views/livewire/configuration/organization.blade.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Services/CurrentOrganization.phpdatabase/migrations/2026_05_05_000001_create_organizations_tables.phpapp/Policies/OrganizationPolicy.phpapp/Actions/Fortify/CreateNewUser.phpdatabase/factories/VolumeFactory.phptests/Feature/User/CreateTest.phpdatabase/factories/OrganizationFactory.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phpdatabase/seeders/DatabaseSeeder.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phpdatabase/migrations/2026_05_05_000002_backfill_organizations_data.phptests/Feature/Auth/OAuthTest.phpapp/Models/Organization.php
app/Livewire/**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
app/Livewire/**/*.php: In Livewire components, use#[Validate]attributes or Form objects for validation. Call$this->validate()before processing data.
In Livewire components, useSession::flash()for one-time messages and show them via@if (session('success'))in Blade templates.
In Livewire components, return$this->redirect()withnavigate: truefor SPA-like navigation.
In Mary UI modals, add a boolean property to the component class and usewire:modelin the Blade template.
Keep state server-side in Livewire components so the UI reflects it. Validate and authorize in actions as you would in HTTP requests.
Files:
app/Livewire/Configuration/Organization.phpapp/Livewire/OrganizationSwitcher.php
**/*.{php,blade.php}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{php,blade.php}: Always use named routes and theroute()function when generating links to other pages.
Translations should use__('...')helper function and be stored in JSON translation files inlang/{locale}.json. Keep technical terms like 'Backup', 'Restore', 'Snapshot(s)' in English across all locales.
Files:
app/Livewire/Configuration/Organization.phptests/Feature/Auth/RegistrationTest.phpdatabase/factories/UserFactory.phpdatabase/factories/DatabaseServerSshConfigFactory.phpapp/Http/Resources/OrganizationResource.phpapp/Services/OAuthService.phpapp/Mcp/Tools/ListOrganizationsTool.phptests/Feature/DemoModeTest.phpdatabase/factories/DatabaseServerFactory.phpapp/Livewire/OrganizationSwitcher.phpdatabase/factories/AgentFactory.phpresources/views/livewire/configuration/organization.blade.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Services/CurrentOrganization.phpdatabase/migrations/2026_05_05_000001_create_organizations_tables.phpapp/Policies/OrganizationPolicy.phpapp/Actions/Fortify/CreateNewUser.phpdatabase/factories/VolumeFactory.phptests/Feature/User/CreateTest.phpdatabase/factories/OrganizationFactory.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phpdatabase/seeders/DatabaseSeeder.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phpdatabase/migrations/2026_05_05_000002_backfill_organizations_data.phptests/Feature/Auth/OAuthTest.phpapp/Models/Organization.php
tests/**/*.php
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.php: When creating models for tests, use factories. Check if the factory has custom states before manually setting up the model.
Use faker methods such as$this->faker->word()orfake()->randomDigit()when generating test data. Follow existing conventions on whether to use$this->fakerorfake().
Create Pest tests usingphp artisan make:test --pest {name}without including the test suite directory. Usephp artisan make:test --pest SomeFeatureTestinstead ofphp artisan make:test --pest Feature/SomeFeatureTest.
Files:
tests/Feature/Auth/RegistrationTest.phptests/Feature/DemoModeTest.phptests/Feature/User/CreateTest.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phptests/Feature/Auth/OAuthTest.php
**/*Resource.php
📄 CodeRabbit inference engine (CLAUDE.md)
For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not follow this pattern.
Files:
app/Http/Resources/OrganizationResource.php
resources/views/livewire/**/*.blade.php
📄 CodeRabbit inference engine (CLAUDE.md)
All Livewire component blade files should contain only view markup; all PHP logic must be in the component class.
Files:
resources/views/livewire/configuration/organization.blade.php
resources/views/**/*.blade.php
📄 CodeRabbit inference engine (CLAUDE.md)
resources/views/**/*.blade.php: All UI components in Mary UI should be prefixed withx-(e.g.,<x-button>,<x-input>,<x-card>) and use Heroicons for icons (e.g.,icon="o-user"for outline,icon="s-user"for solid).
In Mary UI select components, use the:optionsprop with array format[['id' => 'value', 'name' => 'Label']].
In Mary UI alerts, useclass="alert-success",class="alert-error", etc. (notvariantprop).
Use Alpine.js for client-side interactions in Livewire instead of JavaScript frameworks.
In Blade templates, use:attrbinding (dynamic syntax) instead of{{ }}interpolation when passing translated strings to component attributes to avoid double-encoding special characters.
Files:
resources/views/livewire/configuration/organization.blade.php
🧠 Learnings (14)
📚 Learning: 2026-02-18T09:45:52.485Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 116
File: app/Livewire/DatabaseServer/ConnectionStatus.php:18-18
Timestamp: 2026-02-18T09:45:52.485Z
Learning: In Livewire components, Eloquent model properties (e.g., public DatabaseServer $server) are automatically locked by the framework to prevent client-side ID tampering. The #[Locked] attribute is only needed for scalar properties (int, string, bool, etc.) that require protection from client-side mutation. Apply this guidance to all Livewire PHP components; use #[Locked] only on primitive properties that you want to shield from client manipulation, and rely on automatic locking for Eloquent model properties.
Applied to files:
app/Livewire/Configuration/Organization.phpapp/Livewire/OrganizationSwitcher.php
📚 Learning: 2026-02-25T10:48:17.811Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 132
File: app/Console/Commands/RecoverAgentLeasesCommand.php:44-48
Timestamp: 2026-02-25T10:48:17.811Z
Learning: When reviewing PHP code, especially with foreign keys that use cascadeOnDelete and are non-nullable, assume child relations exist at runtime (the database will delete children when the parent is deleted). Do not rely on null-safe operators for these relations, as PHPStan already models them as non-null. This guideline applies broadly to PHP files that define models with foreign keys using cascade delete; verify there are no unnecessary null checks or optional chaining on such relations.
Applied to files:
app/Livewire/Configuration/Organization.phptests/Feature/Auth/RegistrationTest.phpdatabase/factories/UserFactory.phpdatabase/factories/DatabaseServerSshConfigFactory.phpapp/Http/Resources/OrganizationResource.phpapp/Services/OAuthService.phpapp/Mcp/Tools/ListOrganizationsTool.phptests/Feature/DemoModeTest.phpdatabase/factories/DatabaseServerFactory.phpapp/Livewire/OrganizationSwitcher.phpdatabase/factories/AgentFactory.phpresources/views/livewire/configuration/organization.blade.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Services/CurrentOrganization.phpdatabase/migrations/2026_05_05_000001_create_organizations_tables.phpapp/Policies/OrganizationPolicy.phpapp/Actions/Fortify/CreateNewUser.phpdatabase/factories/VolumeFactory.phptests/Feature/User/CreateTest.phpdatabase/factories/OrganizationFactory.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phpdatabase/seeders/DatabaseSeeder.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phpdatabase/migrations/2026_05_05_000002_backfill_organizations_data.phptests/Feature/Auth/OAuthTest.phpapp/Models/Organization.php
📚 Learning: 2026-05-06T10:46:47.009Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 275
File: app/Models/User.php:188-216
Timestamp: 2026-05-06T10:46:47.009Z
Learning: In app/Models/User.php, the $cachedRoles cache is intentionally request-scoped to prevent N+1 queries during rendering. Pivot writes (attach() in app/Livewire/User/Create.php, updateExistingPivot() in app/Livewire/Forms/UserForm.php) are terminal within a request, and the cache is not read after a write in the same request. Do not flag missing cache invalidation after pivot writes as a bug; this design is intentional. When reviewing related changes in PHP files under app/, assume this cache pattern and do not raise invalidation issues for these flows.
Applied to files:
app/Livewire/Configuration/Organization.phpapp/Http/Resources/OrganizationResource.phpapp/Services/OAuthService.phpapp/Mcp/Tools/ListOrganizationsTool.phpapp/Livewire/OrganizationSwitcher.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Services/CurrentOrganization.phpapp/Policies/OrganizationPolicy.phpapp/Actions/Fortify/CreateNewUser.phpapp/Models/Organization.php
📚 Learning: 2026-05-07T18:49:56.777Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 275
File: app/Services/Backup/SnapshotVerificationService.php:38-41
Timestamp: 2026-05-07T18:49:56.777Z
Learning: In Laravel code analyzed with Larastan/PHPStan, when you write Eloquent relationship/query callbacks such as those passed to `whereHas`, `whereRelation`, etc. (e.g., `function ($sq) use (...) { ... }`), leave the closure parameters untyped. Avoid adding explicit type hints like `Builder $sq` or `Builder<Model>`, because Larastan’s Laravel-specific stubs typically rely on its own inferred/generic types and explicit hints can cause PHPStan/Larastan generic type-mismatch errors. Larastan should consider these closures correctly without explicit parameter type annotations.
Applied to files:
app/Livewire/Configuration/Organization.phpapp/Http/Resources/OrganizationResource.phpapp/Services/OAuthService.phpapp/Mcp/Tools/ListOrganizationsTool.phpapp/Livewire/OrganizationSwitcher.phpapp/Http/Middleware/DemoModeMiddleware.phpapp/Services/CurrentOrganization.phpapp/Policies/OrganizationPolicy.phpapp/Actions/Fortify/CreateNewUser.phpapp/Models/Organization.php
📚 Learning: 2026-02-13T11:05:37.072Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 105
File: tests/Feature/Services/Backup/Databases/SqliteDatabaseTest.php:8-11
Timestamp: 2026-02-13T11:05:37.072Z
Learning: Adopt a global afterEach hook in tests/Pest.php (or equivalent Pest bootstrap) to clean up temporary directories created during tests. Specifically handle temp dirs named with the prefixes sqlite-db-test-*, backup-task-test-*, restore-task-test-*, and volume-test-*, so individual test files don’t need their own cleanup logic. This applies to all PHP test files under the tests directory.
Applied to files:
tests/Feature/Auth/RegistrationTest.phptests/Feature/DemoModeTest.phptests/Feature/User/CreateTest.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phptests/Feature/Auth/OAuthTest.php
📚 Learning: 2026-04-09T13:59:25.873Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 205
File: tests/Feature/ConfigurationTest.php:165-176
Timestamp: 2026-04-09T13:59:25.873Z
Learning: In this repository, `Notification::fake()` is already performed globally in the base test class (`tests/TestCase.php`) within `setUp()` before each test. When reviewing individual test files under `tests/`, do not flag missing `Notification::fake()` calls, since they are handled by the shared base test setup.
Applied to files:
tests/Feature/Auth/RegistrationTest.phptests/Feature/DemoModeTest.phptests/Feature/User/CreateTest.phptests/Feature/User/EditTest.phptests/Pest.phptests/Feature/Dashboard/SnapshotsCardTest.phptests/Feature/Api/OrganizationContextApiTest.phptests/Feature/Configuration/OrganizationTest.phptests/Feature/Auth/OAuthTest.php
📚 Learning: 2026-05-05T23:16:24.464Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 275
File: app/Services/CurrentOrganization.php:28-39
Timestamp: 2026-05-05T23:16:24.464Z
Learning: Enforce non-nullable return types for id(): string and model(): Organization in PHP service classes under app/Services. Ensure SetCurrentOrganization middleware always resolves an Organization in the web context before these methods are reached; do not reintroduce isResolved guards in callers. A null dereference due to a broken middleware chain is the intended failure signal, not silent null propagation. Document the contract in class docblocks and consider tests to verify the middleware guarantees.
Applied to files:
app/Services/OAuthService.phpapp/Services/CurrentOrganization.php
📚 Learning: 2026-05-07T18:48:26.765Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 275
File: app/Mcp/Tools/ListOrganizationsTool.php:19-22
Timestamp: 2026-05-07T18:48:26.765Z
Learning: When reviewing MCP tools in app/Mcp/Tools/, do not require null guards for `$request->user()` or calls like `app(CurrentOrganization::class)` if the tool is only reachable via the MCP web transport (`Mcp::web()` in routes/ai.php) because that transport is protected by `auth:sanctum` and `SetCurrentOrganization` middleware, which guarantees an authenticated user and that `CurrentOrganization` is resolved before any tool `handle()` runs. Keep null-guard expectations for user/organization access only if the tool can be invoked outside that middleware-guaranteed web path (e.g., via STDIO/local transport).
Applied to files:
app/Mcp/Tools/ListOrganizationsTool.php
📚 Learning: 2026-02-01T11:14:33.775Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 64
File: docs/docs/self-hosting/configuration/application.md:186-189
Timestamp: 2026-02-01T11:14:33.775Z
Learning: In self-hosting documentation, prefer generic 'php artisan' command examples over Docker-specific commands to ensure guidance remains valid for users deploying via Docker, Kubernetes, native installations, or other methods. Apply this consistently across all files under docs/docs/self-hosting. If a Docker-specific command is necessary for illustration, provide a non-Docker alternative or clearly note the context and include an equivalent generic command.
Applied to files:
docs/docs/self-hosting/configuration/sso.md
📚 Learning: 2026-02-01T11:14:56.749Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 64
File: docs/docs/self-hosting/configuration/backup.md:141-144
Timestamp: 2026-02-01T11:14:56.749Z
Learning: In self-hosting documentation (docs/docs/self-hosting), prefer showing plain php artisan commands. Do not assume deployment environment. The Docker command (docker compose exec --user application -T app) is only relevant for local development and should not be included in deployment documentation.
Applied to files:
docs/docs/self-hosting/configuration/sso.md
📚 Learning: 2026-03-28T22:33:16.333Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 195
File: app/Notifications/CLAUDE.md:7-12
Timestamp: 2026-03-28T22:33:16.333Z
Learning: In this repository (David-Crty/databasement), do not flag fenced Markdown code blocks that omit a language identifier (i.e., MD040: missing language after ```). The project treats unlabeled fenced code blocks as plain text by default, so missing language tags are acceptable for Markdown files.
Applied to files:
docs/docs/self-hosting/configuration/sso.mddocs/docs/user-guide/organizations.md
📚 Learning: 2026-01-30T22:27:46.107Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 61
File: resources/views/livewire/volume/connectors/s3-config.blade.php:1-13
Timestamp: 2026-01-30T22:27:46.107Z
Learning: In Blade template files (any .blade.php) within the databasement project, allow using alert-info for informational content inside <x-alert> components. The guideline that permits alert-success and alert-error does not exclude using alert-info for informational purposes. Apply this consistently to all Blade components that render alerts; ensure semantic usage and accessibility.
Applied to files:
resources/views/livewire/configuration/organization.blade.php
📚 Learning: 2026-02-06T10:34:43.585Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 75
File: resources/views/livewire/backup-job/_filters.blade.php:36-40
Timestamp: 2026-02-06T10:34:43.585Z
Learning: In Blade template files, when creating compact inline filter controls, prefer using native <input type="checkbox"> elements with daisyUI classes (e.g., checkbox checkbox-warning checkbox-xs) over the Mary UI <x-checkbox> component. The <x-checkbox> component adds wrapper markup (e.g., <div><fieldset><label> with gap-3) that can break tight inline flex layouts. Use the native input approach for compact inline controls, but reserve <x-checkbox> for form fields that require labels, hints, and errors.
Applied to files:
resources/views/livewire/configuration/organization.blade.php
📚 Learning: 2026-04-10T08:46:55.182Z
Learnt from: David-Crty
Repo: David-Crty/databasement PR: 205
File: database/migrations/2026_04_09_000001_add_notification_channels.php:143-156
Timestamp: 2026-04-10T08:46:55.182Z
Learning: In David-Crty/databasement, treat Laravel migrations as forward-only for production. For migrations in database/migrations/*.php, it is acceptable to delete or transform legacy data in the migration’s up() (e.g., removing app_configs rows) without restoring it in down(), even if down() cannot fully reverse the state. During code review, do not flag missing rollback restoration of migrated/deleted data as a production risk for this repo’s migrations.
Applied to files:
database/migrations/2026_05_05_000001_create_organizations_tables.phpdatabase/migrations/2026_05_05_000002_backfill_organizations_data.php
🔇 Additional comments (16)
app/Services/CurrentOrganization.php (1)
118-123: LGTM — super-admin fallback correctly swapped toOrganization::default().app/Livewire/OrganizationSwitcher.php (1)
42-45: LGTM — both ordering clauses (is_default) are consistent with the model rename.resources/views/livewire/configuration/organization.blade.php (1)
24-47: LGTM —is_defaultguards are consistent in both the name-cell and the actions-cell scope.tests/Feature/DemoModeTest.php (1)
216-247: LGTM —Organization::default()references in both assertions are correct and consistent with the PR-wide rename.database/factories/UserFactory.php (1)
72-72: LGTM —rescue()fallback correctly updated toOrganization::factory()->default()->create().database/factories/DatabaseServerSshConfigFactory.php (1)
28-28: LGTM — factory fallback correctly updated to->default().docs/docs/self-hosting/configuration/sso.md (1)
143-143: LGTM — documentation prose correctly updated to "default organization."database/factories/AgentFactory.php (1)
22-22: LGTM — factory fallback correctly updated to->default(), consistent with other factories in this PR.tests/Feature/User/EditTest.php (1)
81-82: Assertions are aligned with the new default-organization semantics.These updates look consistent and correct.
Also applies to: 110-111, 124-125
app/Http/Resources/OrganizationResource.php (1)
24-25: Resource field rename is correctly applied.
is_defaultexposure in the API resource looks good.database/seeders/DatabaseSeeder.php (1)
20-24: Seeder migration to default organization is consistent.All touched assignments correctly reference the default organization.
Also applies to: 47-48, 63-64, 74-75, 88-89, 99-100, 111-112
app/Services/OAuthService.php (1)
222-223: Fallback switch toOrganization::default()looks correct.No functional concerns in the changed return path.
database/factories/DatabaseServerFactory.php (1)
36-37: Factory fallback rename is consistent with the new org semantics.This change looks good.
tests/Feature/User/CreateTest.php (1)
53-54: Role assertions correctly target the default organization now.These updates are consistent and safe.
Also applies to: 103-104
app/Actions/Fortify/CreateNewUser.php (1)
51-55: Default-org creation and attachment flow looks correct.No functional issues in the changed logic.
Also applies to: 67-68
app/Policies/OrganizationPolicy.php (1)
37-39: Policy checks are correctly migrated tois_default.Authorization logic in the changed lines looks good.
Also applies to: 43-52
| $role = $org->pivot->role ?? 'unknown'; | ||
|
|
||
| return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_main ? ' | Main organization' : ''); | ||
| return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | Default organization' : ''); |
There was a problem hiding this comment.
Localize the new “Default organization” label.
Line 34 introduces a new user-facing literal. Please wrap it with __() to match the repo’s translation rule.
Proposed fix
- return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | Default organization' : '');
+ return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | '.__('Default organization') : '');As per coding guidelines: "Translations should use __('...') helper function and be stored in JSON translation files in lang/{locale}.json."
📝 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.
| return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | Default organization' : ''); | |
| return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | '.__('Default organization') : ''); |
🤖 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 `@app/Mcp/Tools/ListOrganizationsTool.php` at line 34, The new literal "Default
organization" should be localized: update the string concatenation in the return
statement inside the ListOrganizationsTool (the code that checks
$org->is_default) to wrap that phrase with the __('...') helper and ensure the
key is added to the locale JSON files; specifically modify the conditional that
appends ' | Default organization' so it uses __('Default organization')
(preserving the surrounding separator) and then add the translation entry to
lang/{locale}.json.
| </x-slot:trigger> | ||
| <x-slot:content> | ||
| {{ __('The main organization cannot be edited or deleted.') }} | ||
| {{ __('The default organization cannot be edited or deleted.') }} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for any locale JSON files and whether old/new keys are present
echo "=== Locale JSON files ==="
fd --extension json . lang/
echo ""
echo "=== Old key occurrences (should be 0 after update) ==="
rg -rn "main organization cannot be edited" lang/ || echo "Not found"
echo ""
echo "=== New key occurrences (should match locale count) ==="
rg -rn "default organization cannot be edited" lang/ || echo "Not found"Repository: David-Crty/databasement
Length of output: 252
🏁 Script executed:
cat -n lang/es.json lang/fr.jsonRepository: David-Crty/databasement
Length of output: 50380
🏁 Script executed:
rg -i "organization" lang/es.json lang/fr.jsonRepository: David-Crty/databasement
Length of output: 49
🏁 Script executed:
# Search for organization in the codebase
echo "=== Files containing 'organization' ==="
rg -l "organization" --type-list
# Check the Blade file itself
echo ""
echo "=== Organization Blade file content around line 30 ==="
cat -n resources/views/livewire/configuration/organization.blade.php | sed -n '20,40p'
# Check if there are any en.json files
echo ""
echo "=== English locale files ==="
fd --extension json . lang/Repository: David-Crty/databasement
Length of output: 1667
🏁 Script executed:
# Search for en.json specifically
echo "=== Checking for en.json ==="
find . -name "en.json" -o -name "en*.json" 2>/dev/null | head -20
# Check what locale files actually exist
echo ""
echo "=== All JSON files in lang directory ==="
ls -la lang/
# Search the entire codebase for the translation strings
echo ""
echo "=== Searching for 'default organization' in entire codebase ==="
rg "default organization" --type php --type blade -i
# Also search for 'main organization' (the old key)
echo ""
echo "=== Searching for 'main organization' in entire codebase ==="
rg "main organization" --type php --type blade -iRepository: David-Crty/databasement
Length of output: 578
🏁 Script executed:
# Search for the translation strings more broadly
echo "=== Searching for 'default organization' ==="
rg "default organization" -i
# Search for 'main organization'
echo ""
echo "=== Searching for 'main organization' ==="
rg "main organization" -i
# Check the git history to see what the old translation key was
echo ""
echo "=== Recent git commits affecting organization.blade.php ==="
git log --oneline -20 resources/views/livewire/configuration/organization.blade.php 2>/dev/null || echo "Git history not available"
# Check if there's a translation file generation or default locale config
echo ""
echo "=== Laravel config files for translations ==="
find . -name "*.php" -path "*/config/*" | grep -i locale
# Check app config
echo ""
echo "=== Checking app/App locale config ==="
rg "default.*locale" config/ -i 2>/dev/null || echo "Not found in config"Repository: David-Crty/databasement
Length of output: 3941
🏁 Script executed:
# Check Laravel locale configuration and fallback strategy
echo "=== Checking config/app.php for locale settings ==="
cat -n config/app.php | grep -A5 -B5 "locale"
# Check if there's a fallback_locale setting
echo ""
echo "=== Check for fallback locale configuration ==="
rg "fallback" config/ -i
# Let's see the actual locale registration in the app
echo ""
echo "=== Checking service providers for locale setup ==="
rg "setlocale\|App::setlocale\|locale" app/Providers/ -i
# Check what locales the application supports
echo ""
echo "=== Application supported locales ==="
rg "en\|es\|fr" config/app.phpRepository: David-Crty/databasement
Length of output: 1408
🏁 Script executed:
# Let's check the git diff to see what changed in this file
echo "=== Git diff for the organization.blade.php change ==="
git show 95fb402:resources/views/livewire/configuration/organization.blade.php | grep -A5 -B5 "organization cannot" || echo "File not in that commit or pattern not found"
# Check git diff to see the actual change
echo ""
echo "=== Git diff showing the change ==="
git diff HEAD~1 HEAD -- resources/views/livewire/configuration/organization.blade.php 2>/dev/null | grep -A3 -B3 "organization" || echo "No recent changes or git unavailable"
# Check the most recent change to lang files
echo ""
echo "=== Recent git commits affecting lang files ==="
git log --oneline -20 -- lang/ 2>/dev/null || echo "No changes to lang files in recent history"Repository: David-Crty/databasement
Length of output: 860
🏁 Script executed:
# Check what was changed in the commit that renamed "Main" to "Default"
echo "=== Files changed in commit 95fb402 ==="
git show 95fb402 --stat | head -30
# Check specifically if lang files were modified
echo ""
echo "=== Changes to lang files in commit 95fb402 ==="
git show 95fb402 -- lang/ | head -100 || echo "No lang file changes in this commit"
# Check if the old key exists in the lang files
echo ""
echo "=== Searching for 'The main organization' in lang files ==="
rg "The main organization" lang/
# Let's also verify what the fallback behavior means - English files should exist
echo ""
echo "=== Check if English translations are inline or in separate files ==="
grep -r "The default organization" . --include="*.php" --include="*.blade.php" 2>/dev/null | head -5Repository: David-Crty/databasement
Length of output: 9642
🏁 Script executed:
# Let's verify the translation key is actually missing from the Spanish and French files
echo "=== Exact search for the translation key in lang files ==="
grep -n "The default organization cannot be edited or deleted" lang/*.json || echo "Key not found in any locale file"
# Also check with single quotes
echo ""
echo "=== Search with escaped quotes ==="
rg "default organization cannot be edited" lang/
# Let's look at one more thing - the actual structure of lang files to see if this key should be there
echo ""
echo "=== Sample of es.json structure (first 50 lines with organization context) ==="
head -50 lang/es.json | tail -30Repository: David-Crty/databasement
Length of output: 2275
Add the missing translation key to locale files.
The translation key 'The default organization cannot be edited or deleted.' was added to the Blade template but is missing from lang/es.json and lang/fr.json. Non-English users will see the raw English string instead of their localized translation.
Add this key-value pair to both locale files:
"The default organization cannot be edited or deleted.": "La organización predeterminada no se puede editar ni eliminar."(For French, provide the appropriate translation in lang/fr.json.)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@resources/views/livewire/configuration/organization.blade.php` at line 30,
Add the missing translation key "The default organization cannot be edited or
deleted." to both locale JSON files (es.json and fr.json): add the Spanish value
"La organización predeterminada no se puede editar ni eliminar." and the French
value "L'organisation par défaut ne peut pas être modifiée ou supprimée." so the
Blade template translation call resolves correctly.
"Default" better communicates the role of the primary organization — it is the fallback context, not necessarily the most important one. Renames: is_main → is_default column, Organization::main() → Organization::default(), factory state main() → default(), and all references in app code, migrations, factories, seeders, tests, and docs.
95fb402 to
95876ee
Compare
Summary
is_maincolumn →is_default,Organization::main()→Organization::default(), factory statemain()→default()Changed areas
Test plan
Summary by CodeRabbit
Release Notes
Refactor
Documentation