Commit Graph
109 Commits
Author SHA1 Message Date
Przemyslaw Kukulski 547237eafb fix: don't report sign-out error when old session token is already invalid (#6980)
* fix: don't report sign-out error when old session token is already invalid

* Review feedback
2026-12-02 14:15:12 +01:00
Peter Evans 1e7ae9deb8 feat: list every invitation link of a workspace in the workspace settings modal (#6802)
* feat: list every invitation link of a workspace in the workspace settings modal

* fix: show the table of view invite links, keep the list steady while searching and wrap its header
2026-11-27 17:16:07 +04:00
Tsering PaljorandJeremie Pardou 250748c8dc feat: Workspace level integrations (#6547)
* Add ADR-013 for workspace level integrations

* Add implementation

* Improve context section and remove technical points

* Move bulk replacement point to v2

* Remove workspace-level ownership on import since manual promotion should handle this.

* Add a glossary section

* Do Lazy creation + Celery migration

* Remove demotion

* Tighten the Options considered section

* Add Decision describing where the integrations are managed

* Update implementation plan after changes to ADR

* Sync plan and adr

* Rename adr and implementation

* Add the shared application that owns workspace integrations

* Create the shared application of every workspace

* Let only workspace admins manage workspace integrations

* Let applications use the integrations of their workspace.

* Trash workspace integrations in their workspace.

* Copy workspace integrations into exports and keep them in duplicates.

* Workspace admins can share integrations with every application in the workspace.

* Load the shared application of each workspace in the frontend and keep it out of application lists.

* Manage workspace integrations from an Integrations page in workspace settings.

* Offer workspace integrations in the integration dropdowns of every application.

* Move promoted integrations to the workspace list in other open tabs.

* Let admins make an app's integration available to the whole workspace from its integration settings.

* Preselect a workspace integration for new nodes and data sources when the app has none of its own.

* fix tests

* Delete implementation file

* More fixes after rebase

* Fix tests

* Let builders of an application see and use the workspace integrations from it.

* Show the workspace integrations, read-only, in the integration settings of applications.

* Keep a dashboard's integration out of promotion to the workspace.

* Leave the shared applications out of the admin dashboard's application count.

* Create the shared application of the workspaces made by the fill commands.

* Say in the promotion modal that an integration nobody authorized will run as the promoting admin.

* Say in the promotion modal that undoing it won't make the integration run as the previous person again.

* Ignore integration ids in sample data when publishing copies the workspace integrations an app uses.

* Let only undoing a promotion move an integration out of the workspace.

* Let the shared application backfill stop itself after 5 minutes and skip workspaces another transaction has locked.

* Say in the workspace integrations settings that published applications and workflows keep their own copy until they're published again.

* Leave the shared application out of the assistant evals' application counts.

* Refresh the workspace integrations when the Builder's data, events, users and integrations panels open.

* Say that anything new using a promoted integration blocks undoing the promotion, even from its own application.

* Warn when a database button sends through a workspace integration with no host or token.

* Refuse roles and invitations on the shared application.

* Fix tests

* Show an application only the workspace integrations of types it can use.

* Say in the promotion modal what builders of other applications can do as the integration.

* Leave the shared application type out of the API docs for creating and updating applications.

* Check who receives a workspace integration event in one permission call.

* Say which workspaces have a shared application and who creates it.

* Let a redone promotion record what uses the integration again.

* Update docstrings

* Stop template visitors from listing the integrations of the template's workspace.

* Let database buttons find their own copy of a workspace integration after an import.

* Say what holds the workspace row lock while a shared application is created.

* Fix tests

* Stop the workspace integration form component from being made reactive.

* Make test runs use a new copy of the workflow after an integration it uses changes.

* Hide the Members settings tab from members who can't list the workspace members.

* Add changelog

* Fix migration conflict

* Fix migration conflict

* Fix test

* Update comments and ADR number

* Link to the workspace integrations from the sidebar's Settings menu.

* fix: refresh agent action errors when workspace integrations change

* fix: move workspace integrations into workspace settings

* fix: use share icon for workspace integration promotion

* refactor: use explicit shared application relations

* feat: centralize default integration selection

* refactor: share integration change notifications

* refactor: prepare integration mappings before import

* refactor: collect integration references during export

* refactor: prepare integration ownership changes without a new hook

* test: restore registered service model after mocking

* test: cover shared integration defaults in Builder

* test: include Slack in Agent workspace integration choices

* Fix migrations

* Stop template visitors from listing the workspace integrations through an application of the template.

* Only offer integrations of the user source's integration type when updating a user source.

* Say the workspace integration copy means published Application Builder apps and automation workflows.

* Use the same spacing under both integration settings sections and enlarge their headings.

* Keep the shared application out of automatic snapshot schedules.

* Fix test after rebase

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-27 15:49:32 +04:00
Peter EvansandJeremie Pardou 2b8e6ba569 feat: add per-workspace snapshot allowances and protected snapshots (#6783)
* feat: add per-workspace snapshot allowances and protected snapshots

* fix: guard snapshot replacement and separate quota management

* refactor: delegate snapshot permission descriptions to application types

* fix: highlight inherited workspace snapshot maximums

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-23 11:23:05 +00:00
Przemyslaw Kukulski 7ea2f1c56b feat: template marketplace tweaks and fixes (#6741)
* feat: template marketplace tweaks and fixes

* Review feedback
2026-11-19 20:25:02 +01:00
Peter Evans 864c6d6f51 feat: let visitors report abuse on published applications (#6715)
* feat: let visitors report abuse on published applications

* fix: let logged-in app users report published applications
2026-11-18 09:00:31 +00:00
Davide Silvestri 5169076065 feat: introduce User-backed workspace identities (#6556)
* feat: introduce User-backed workspace identities

Replaces workspace core.Agent subjects with identities stored as Django
Users, so permissions, execution and attribution use the same record.

- User.objects and WorkspaceUser.objects are human-only; permission and
  identity code opts in through objects_and_identities. is_human and
  is_identity classify a user at runtime.
- Login, tokens, seats, notification recipients, personal views and
  last-admin checks stay human-only. Roles, teams and field grants work
  for identities unchanged.
- Agent applications run as an identity, never as a person. Every shared
  tool rechecks the identity's authority on each call, and MCP refuses a
  tool that skips that boundary.
- Migrations add the profile metadata and index, remove the Agent model
  and delete or clear legacy Agent data: trash entries, role assignments,
  team memberships, integration authorizations and run-as bindings.
- Rename the management API, UI, events and feature flag to identity.

Squashed and rebased onto develop; the previous history is kept on
backup/6556-before-develop-rebase.

* refactor: remove generic subject options endpoint

* refactor: simplify identity selection and Agent run-as options

* feat: distinguish identity notification senders

* fix: restrict identity bindings to identity managers

* docs: record users and identities verification

* fix: restore snapshots as the person restoring

A restore checked the snapshot creator's permission and used the creator
to decide whether an Agent keeps its identity binding. It now checks the
person restoring, passed to the import as `restored_by`. `copied_by` stays
unset on restore, so credential checks keyed on it behave as on develop.

Restoring a snapshot whose creator was deleted works again. The copy rule
for identity bindings covers Agent run-as only; a copied Local Baserow
integration keeps its authorized subject.

* fix: leave settings pages the user may not open

A settings route without a permitted tab rendered an empty page, as the
Identities page did with its feature flag off. It now opens the first
page the user may see.

* fix: renumber the legacy Agent cleanup migrations

Develop added agent 0016 and integrations 0043, so the migrations that
clear legacy Agent run-as bindings and integration authorizations move to
agent 0017 and integrations 0044.

* test(agent): run the trigger self-event test as an identity

The test added on develop created a `core.Agent`, which this branch
removes. It now uses an identity user as the Agent's run-as subject.

* perf: load user types once per batched permission check

* refactor: state the stored subjects in each subject type

* fix: give every user a profile

* fix: keep identity attribution on rows copied in their workspace

* refactor: give people and identities their own subject type

UserSubjectType stays the type both are registered and stored under. It forwards what differs to HumanSubjectType and IdentitySubjectType, so get_specific_type is the only place in subject code that inspects the user type. The registry returns the specific type on request and get_by_model keeps returning the stored type, which never reads the profile.

An identity's membership is checked in one query instead of two.

* fix: keep the roles of identities when a database is duplicated

The role import read subjects through the model's default manager, which only returns people, so duplicating or restoring a database failed when an identity held a role on it. It now resolves the subject through the subject registry.

A subject that no longer exists is skipped instead of failing the whole duplicate or restore.

* refactor: look up a subject type from its content type in one place

* fix: reload a cached token whose profile is incomplete

A token cached by the previous release has a profile without the user type, which reads as not a person, so its requests were refused until the entry expired. The token cache now treats it as a miss, with the check the user cache already used.

* refactor: check the user type once where the check was repeated

The MCP endpoint loader, the personal view permission manager and the identity trash type each asked the same question several times. The rule that an identity is never selected by email moves from the team handler to the identity subject type.

* refactor: leave trashed workspaces out of the identity membership manager

WorkspaceUser.objects_and_identities was named after objects but also returned memberships of trashed workspaces, so callers filtered them by hand. It now follows the existing pair: it leaves trashed workspaces out, and objects_and_identities_and_trash includes them, as objects_and_trash does for people.

* test: state the behaviour of every user type

The table fails when a user type is added and says what has to be decided first. An unknown type is checked to be denied.

* refactor: refuse to say whether a stored user subject is interactive

The answer differs between a person and an identity, so reading it from the stored type would be wrong for one of them. It now raises and points to the specific type.

* refactor: lock the person in membership writes instead of checking the type

Leaving a workspace, removing a member and adding a user lock the user through the people manager, which refuses an identity or an unknown type in the same query. Nothing adds an identity through add_user_to_workspace, so its branch for identities goes. The last admin check compares the membership with the people who are admin, which needs no type check.

* test: leave no rows behind in the legacy authorization migration test

The test left an integration that pointed at a user that didn't exist and a workspace, in the database the migration tests share. Tests that ran after it then failed on the foreign key or on the workspace id. It now uses a real user and empties the two tables.

* docs: describe the subject types and compare the Subject table alternative

ADR 013 is shorter and states that people and identities each have a specific subject type under the stored auth.User type. It compares shared User storage with a Subject table that users and identities would both point to.

* chore: run the legacy run-as cleanup after the agent actions migration

Develop added agent migration 0017, so the cleanup becomes 0018 and depends on it.

* test: leave no rows behind in the legacy agent migration tests

Like the legacy authorization test, these left a workspace in the database the migration tests share, which a later test that creates workspaces with fixed ids collides with.

* fix: write and read the workspace role of an identity in one place

The role assignment API wrote the role of an identity through the membership update of people, which told every member of the workspace about it and stored Builder as MEMBER, while the identities API stored BUILDER and returned the stored value. Both now write through the identity handler, which stores the role like the role of a person, and the role is read with the resolver the workspace members use.

* fix: take no row lock in the membership writes of a person

Leaving a workspace locked the user before the membership while removing or updating a member locks the membership first, so the two could deadlock. The user type never changes and these operations refuse an identity, so the lock protected nothing: they now only check that the user is a person. Leaving no longer locks the admin memberships and removing a member no longer checks for the last admin, as before identities.

* fix: find an identity by its name only in the subject options

The search also matched the email and username, which for an identity hold an internal key, so searching a part of that key returned every identity.

* chore: run the identity migrations after the new ones on develop

Develop added core 0138, integrations 0044 and enterprise 0073, so the identity migrations become core 0139 and 0140, integrations 0045 and enterprise 0074 and depend on them.

* fix: keep the identity of a copied integration only for identity managers

A duplicated application or a restored snapshot kept the identity its Local Baserow integration acts as, without checking the person who made the copy. Restoring a snapshot could so bring back a binding an admin had removed. The copy now keeps the identity only when that person may bind identities, as the Agent application already did, and is otherwise authorized as that person.

* docs: follow the renumbered migrations and the copy rule in the test plan

The test plan named the identity migrations and their tests by their old numbers and still said a copied integration keeps its subject.

* test(agent): run the row trigger tests as an identity

The row trigger tests added on develop created a `core.Agent`, which this
branch removes. They now use an identity user as the Agent's run-as
subject, and the e2e fixture creates it through the identities endpoint.
2026-11-18 08:44:31 +00:00
Peter Evans d77b5fd2d5 feat: let admins password protect invitation links (#6643)
* feat: let admins password protect invitation links

* test: expect the invitation link token header in the workspace service spec
2026-11-17 16:08:01 +00:00
Przemyslaw Kukulski 47ef996921 feat: a way back for a blocked user template (#6696)
* feat: a blocked user template has a way back

* Review feedback
2026-11-16 12:09:41 +01:00
Przemyslaw Kukulski 7121039db6 feat: block and unblock user templates from the admin Templates page (#6661)
* feat: block and unblock user templates from the admin Templates page

* Review feedback
2026-11-12 20:24:32 +01:00
Davide Silvestri 9f9e068a27 feat(agent): show waiting approvals and let editors stop the asking (#6610)
* feat(agent): count pending approvals per application and conversation

* feat(agent): show waiting approvals in the sidebar, header and conversation list

* feat(agent): always allow a held tool from the approval

* feat(agent): add Always allow and the ask before changes switch

* fix(agent): read pending counts from the primary and lock the conversation first

* test(agent): run approval test actions through the action registry

* test(agent): read the decision result in the web search approval test

* test(agent): let the waiting conversations request start before answering it

* fix(agent): keep older waiting conversations through a reconnect

* perf(agent): count pending approvals for many users and conversations at once

The core hook takes many users and returns counts per user and application, so
creating or restoring an Agent and the count task count once for all members
instead of once per member; the task sends every count in one broadcast.
Pending approvals are defined once, and a page of conversations gets its counts
in one query passed to the serializer, like its runs, instead of an annotation
with a per-object fallback.

* refactor(agent): return one decision result and name the count signal after its event

The service and the action both return the decision result, which carries the
approved and rejected tools, so they are computed once for the audit params and
Always allow. Always allow bumps the Agent's updated_on like a configuration
update. The signal is renamed application_pending_count_updated, like its
websocket event.

* fix(agent): keep the deciding tab's waiting counts current

A decision lowers the Agent's count before its request and restores it when the
request fails, unless the call was decided elsewhere. Its conversation count
goes through the tracked update, so a list read that started earlier restarts
instead of bringing the old count back. The pill adds only the waiting
conversations it hadn't loaded, and leaves a conversation picked while it loads
selected.

* chore(agent): describe the ask switch and drop the unused counter class

The ask switch is described by its text and the row separator is hidden from
screen readers. The sidebar no longer adds tree__action--has-counter, whose
padding --has-options already sets.

* test: give fixture fields unique default names

Two fields of one table could get the same random name, so a formula
referencing the other field referenced itself and failed with
SelfReferenceFieldDependencyError.

* refactor(agent): show the sidebar count with the warning counter

The admin Templates count added badge-counter--warning, so the Agent's count
uses it too instead of its own yellow color prop on BadgeCounter.

* fix(agent): reconcile approval counts and cycle loaded conversations

* fix(agent): name the tools Always allow stops asking for

* fix(agent): load older pages until the pill reaches a waiting conversation
2026-11-11 17:25:51 +00:00
Przemyslaw Kukulski 5e6ce919b6 feat: share a user template with a private link (#6611)
* feat: share a user template with a private link

* Review feedback
2026-11-10 12:50:34 +01:00
Przemyslaw Kukulski 91df1115d3 feat: review user templates from the admin page, with an approval setting (#6549)
* feat: review user templates from the admin page, with an approval setting

* Review feedback

* Review feedback 2

* Review feedback 3
2026-11-10 12:27:38 +01:00
Peter Evans 73aa028b7b feat: group the Authenticate as picker into members and identities (#6577) 2026-11-05 11:43:42 +00:00
Peter EvansandJeremie Pardou 5e271e22c9 feat: add permanent workspace invite links (#6521)
* feat: add permanent workspace invite links behind the rbac_improvements feature flag

* feat: ask logged-in users to confirm before joining a workspace through an invite link

* feat: make the invite link code length configurable with a default of 12 and a minimum of 7

* feat: let admins name invite links so they remember what each one is for

* feat: show only the invite path in the link column to make room for the name

* fix: harden invite links and let people sign up through them with single sign-on

* fix: ask people who sign up through an invite link with single sign-on to confirm joining

* feat: let invite links raise a member's role after they confirm, without ever lowering it

* fix: move shared clipboard helper into core

* fix: validate workspace invitation link roles

* refactor: share confirmation modal across core features

* refactor: use literal frontend translation keys

* fix: label invitation route Invite links

* fix: copy invitation links when clicking their paths

* fix: align invitation migration with latest develop

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-04 08:37:21 +01:00
Przemyslaw Kukulski 98f727dc2e feat: make a user template public or private, with a Shared templates listing (#6546)
* feat: make a user template public or private

* Review feedback

* Review feedback 2
2026-11-03 21:10:25 +01:00
Przemyslaw Kukulski 2f17b58e1c feat: download a user template (#6477)
* feat: download a user template

* Review feedback

* Review feedback 2
2026-11-03 07:49:04 +01:00
Davide Silvestri 362f690b9e feat(chat-runs): per-run-type limits and a core run stream (#6454)
* feat(chat-runs): limit active runs per run type, per user or workspace

Each run type now counts only its own runs. The per-user limit keeps its default of 2, and a run type can add a per-workspace limit.

* feat(chat-runs): follow any run over one core streaming endpoint

GET /api/chat-runs/<run_id>/stream/ relays the output of any run type behind its read check. Helm and the install guides route /api/chat-runs/ to the ASGI service; the guides also gain Kuma's /assistant/ route.

* feat(chat-runs): read the core run stream by default in the frontend

The base ChatRunType reads the core stream, applies the resume baseline and retries once after a token refresh.

* refactor(chat-runs): expose the output fold for lost runs

Run types rebuild a lost run's partial text from the buffered output with fold_output.

* perf(chat-runs): send heartbeat records and skip repeated run reads

While no output arrives, an open stream sends run.heartbeat as a JSON
record, so a follower can tell a quiet stream from a stalled one. The stream
view hands follow_run the run state it read for its permission check,
finish_run returns the ended run instead of letting callers read it again,
and a lease renewal takes one statement while the run goes on. The
per-workspace limit hook receives the workspace, so a run type can set the
limit per plan.

* perf(chat-runs): follow runs from their open stream in the frontend

The store reads a run's status only while it has no stream or the stream
lost its output, and restarts a stream that stays silent for 15 seconds,
also after the computer slept. Following a run opens its stream directly,
and Stop doesn't read a run whose stream is open. Each run type keeps one
chat subscription, released with unsubscribeFromChat; refreshChat runs only
when a subscription is confirmed on a new websocket, and window focus or a
regained network only re-attach followers. The developer guide documents
the subscription and heartbeat contract.

* perf(chat-runs): write a reply's first words at once

- The journal writes output after a quiet moment at once and batches
  what follows, so the first words no longer wait for the 250 ms timer.
- The stream adapter settles when aborted. Chrome can fire the last
  progress event after the request is done, where aborting fires no event.
- A stream refused with 503 is retried with the next status check
  instead of spending every reconnect attempt at once.

* refactor(chat-runs): register the stream route by URL name
2026-10-30 10:35:50 +01:00
Przemyslaw Kukulski 356f9a9da6 feat: install a user template (#6460)
* feat(install-user-template): Install a user template

* Review feedback

* Review feedback v2
2026-10-28 14:07:20 +01:00
alamin-br b14271c6e6 fix: accept workspace invitations only with the emailed token or a verified email (#6502)
* fix: accept workspace invitations only with the emailed token or a verified email

Accepting by id only compared the username with the invited address, which anyone can
register without verifying it. The emailed token now proves ownership and verifies the
email; without it, the user's email has to be verified.

* fix: require a verified email to reject invitations and keep accept visible

Rejecting still only checked the username, so whoever registered the invited address could delete the invitation. Accept stays visible after a verification error so it works once the email is verified.

* fix: hide accept for unverified users, allow reject, skip the check without SMTP

Without an email backend neither the invitation nor a verification email arrives, so the check can't be met.
Signing up from the invitation link verifies the email, so the user is signed in even when verification is enforced.

* fix: leaving a workspace hangs and removing the current user deletes the wrong workspace
2026-10-28 11:19:47 +01:00
alamin-br 0061c13bcc fix(backend): build emailed frontend links from the embedded share URL (#6478)
* fix(backend): validate frontend base URL in emailed links

The hostname check used urlparse, which disagrees with browsers on URLs
containing backslashes, so links could point at another host.

* fix(backend): build emailed frontend links from settings

The client base_url only selects the embedded share URL now, so its host
and path never reach the link and the endpoints no longer return an error.

* fix: drop base_url from emailed links and use the embedded share URL

The client value no longer influences links, so the API stops accepting it.
Row edit and MCP OAuth links now also honour BASEROW_EMBEDDED_SHARE_URL.

* fix: keep MCP OAuth on the web frontend and share the embed URL helper

The consent page is part of the app and SSO only accepts the web frontend URL.
Notification and abuse report links dropped the embed URL path through urljoin.

* test: cover deceptive base_url and embed URL links on every email endpoint

The new attack tests fail on develop with the link pointing at evil.com.
2026-10-23 16:38:00 +02:00
Przemyslaw Kukulski cb0ef177ac feat: delete a user template (#6455)
* feat(delete-user-template): Delete a user template, and when its author is deleted

* Review feedback
2026-10-23 15:23:42 +02:00
Jonathan Adeline af125616d1 feat: refresh workspace members, invites, teams and agents pages (#6306)
* feat: align management pages with the refreshed table design

* feat: refresh agent dialogs using shared UI components

* test: cover refreshed management pages and agent dialogs

* fix: use the standard UI modal for agent management

* feat: expand member rows with available role details

* Revert "feat: expand member rows with available role details"

This reverts commit e0516c6ce43896508b918db10b028f1cdf88c29b.

* docs: show scoped member roles in CrudTable stories

* fix: align tab labels with badges

* fix: define management role icons in the role registry

* fix: reuse shared name abbreviations in management tables

* style: format management tables and tabs for CI

* test: preserve agent totals and tab badges after rebase
2026-10-22 17:06:02 +04:00
Przemyslaw Kukulski 58a9449209 feat: create a user template and list it in "Your templates" (#6421)
* feat(jobs): Opt-in lock so a job type can refuse a cancel after its commit

* feat(create-user-template): Create a user template and list it in "Your templates"

* fix(create-user-template): Address review feedback

- Only the owner can open a user template; the slug endpoint returns 404
  otherwise and includes `type`.
- List templates through `/api/templates/?view=flat` instead of `/own/`.
- Rename the job's copy to `template_workspace`, renumber the migration to
  0132 after develop's core migrations, guard it like 0128, and move
  revision fields and metadata to the update PR.
- Clear references outside the selection instead of failing the import,
  lock the owner row against a concurrent delete, and keep leftovers
  tracked until they're deleted.
- Load workspace permissions only for the wizard, handle instances without
  categories, restore a running job before a failed one, and open the
  default template again in the template modal.
- Reuse existing export, cancel and serializer code, keep one icon list,
  remove overlapping tests, and give template fixtures a unique slug.
2026-10-22 12:05:04 +02:00
Davide Silvestri 9eabe6b06b feat(core): add Redis-backed background chat runs (#6382)
* feat(core): add Redis-backed background chat runs

Run AI work once in Celery and follow bounded Redis Streams over HTTP. Keep
lifecycle, Stop, leases and final outcomes in Postgres without per-token writes.
Include the shared frontend follower, adapter registry, recovery API, migration,
queue/deployment wiring and adapter guide. No product uses it yet.

Part of #6346

* Remove unused chat run response header exposure

* Extract shared async streaming HTTP router

* Simplify chat run follower and group engine constants

- Check read access once when a stream opens; read run state from Postgres
  only after 5 s without output or on run.finished.
- Split follow_run into small steps around _OutputReader.
- Turn event kinds, error codes and stop reasons into StrEnums; the
  Kuma-only model_unavailable code moves to Kuma.
- Document ChatRunType hooks with param, return and raises fields.
- Add BASEROW_ASGI_HTTP_MAX_CONCURRENT_STREAMS and size the follower Redis
  pool by it.
- Give handler publish/recover calls their own event loop, so cleanup
  cannot close pools shared by HTTP followers.
- Update ADR 010 and the background chat runs docs.

* Clean up chat run interfaces and test setup

* Prune chat runs once after 7 days and skip overdue claims

- Delete each expired page with one statement. Incomplete runs get one more
  ensure_interruption_warning call first, and are deleted even if it fails,
  so run metadata never accumulates. The hook now returns None.
- Keep runs for 7 days instead of 30.
- Never claim a queued run older than NOT_STARTED_AFTER; the sweeper ends it.

* Retry brief Redis failures in chat run followers

- A connection error, or a buffer that does not exist yet, is retried with
  the same cursor, sending heartbeats meanwhile.
- run.replay_unavailable is only sent once the follower stops reading, so
  the browser can treat it as final.

* Let finished chat run output expire with the active TTL

Nothing reads a buffer once its run has finished: followers return the saved
outcome first and recovery only reads running runs. Drop finish() and the
24 h TTL, so a finished buffer expires an hour after its last append.
_publish_terminal now reuses _publish.

* Run the chat run scale tests on fakeredis

Build the buffer's real read and write pools on fakeredis connections, so
these tests always run and backend CI needs no Redis service. The Kuma e2e
tests cover a real Redis.

* Address the remaining chat run review comments

- Serialize the saved outcome after the transaction, so only a failed save
  is logged as one.
- Make the primary-pin test transactional; inside the test transaction the
  router always used the primary, so it could not fail.
- Cover the race past the per-user lock, a lost run after Stop and an old
  writer appending to a recreated buffer.
- End the admission test's request with a disconnect, so a regression fails
  instead of looping.
- Document that one worker process runs AI replies one at a time.

* Move the chat run migration after develop's core 0130

* Log only the class of an outcome serialization error

* Test that the run deadline asks a run to stop

* Keep a run's status when a resumed follower rebuilds its output

* Note that slow DNS lookups turn off a run's live output
2026-10-21 14:52:59 +02:00
Peter EvansandJeremie Pardou a36e7e3688 feat: implementing the new invite-to-scope feature. (#6361)
* Implementing the new invite-to-scope design and functionality.

* Simplifying the invitation acceptance, we don't need the redirect.

* Fix the action type description

* Addressing my own review feedback, and making sure the workspace invitation form behaves like the scoped one.

* Further tweaks after testing edge cases manually

* Lint fix

* Taking a DRYer approach to validating the subject chips.

* Lint fix

* Addressing feedback

* fix: block invitation batches containing invalid emails

Malformed addresses could be silently cleared after a partial batch send.
Keep them visible and block submission until corrected or removed.

* fix: respect workspace invitation permission in scope sharing

Scoped Admins could attempt email invites denied by workspace permissions.
Gate new-email invitations while keeping existing subjects assignable.

* feat: unify workspace and scoped access lists

Workspace and scope lists duplicated markup and lacked consistent controls.
Share rows, add workspace edit/cancel actions, and cap lists at six rows.

* fix: reconcile invitation branch with develop

Develop enables agents and adds an Enterprise migration at the same number.
Align invitation subjects and renumber the branch migration after develop.

* refactor: resolve workspace user roles in the backend

The frontend duplicated the backend mapping from basic roles to RBAC roles.
Expose role_uid in user payloads and reuse it for inherited access counts.

* fix: validate invitation emails before submission

The permissive database validator let malformed invitation addresses reach the API.
Use the existing strict validator for email suggestions, chips, and batch submission.

* fix: align invitation input focus styling

The invite input used a gray border tied to whether suggestions were open.
Use the standard blue border with focus-within so Escape preserves the focus highlight.

* feat: limit email invitation batches

Large invitation batches can exhaust the sending allowance partway through.
Default to five new emails per batch, configurable, with a message before submission.

* feat: let roles declare the invitation default

RBAC invitations should default to Viewer without Enterprise-specific logic in core.
Let role types declare the default: Member for basic workspaces and Viewer for RBAC.

* refactor: keep invitation role semantics in their owning modules

Core invitation UI should not interpret Enterprise role IDs or depend on Database roles.
Move basic roles to core and let Enterprise supply invitation subtitles through role metadata.

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-10-21 13:33:41 +01:00
alamin-br 585694941f feat(mcp): choose tools per connection and share list_views with Kuma (#6425)
* feat(assistant): add MCP metadata decorator for Kuma tools

* feat(mcp): offer Kuma's read tools over MCP from the same definition

Builder page lookups are now scoped to the chat workspace so a read can't cross workspaces.

* fix(mcp): keep endpoints without an allow-list on today's tools

A null allow-list now means the tools enabled on 2026-10-19, so new tools need an explicit grant. Cross-workspace tests assert the exact exception.

* fix(assistant): treat a workflow in another workspace as missing

A different error for a foreign workflow let a client probe workflow IDs across workspaces.

* feat(mcp): return tool errors as MCP error results

Expected errors reach the client as readable error results without an ERROR log, only unexpected ones are logged.

* chore: add changelog entry for Kuma read tools over MCP

* fix(mcp): keep null grants on legacy tools in the consent screen

A null allowed_tools made the consent screen tick every tool on reconnect.

* chore(mcp): tidy tests and validation error handling

Only argument validation maps pydantic errors to client errors; one raised in a tool body is now an internal error.

* chore(mcp): rewrap get_allowed_tools docstring

* chore(mcp): drop null grant handling from the consent page

The consent API now sends the legacy tool list for a grant with no saved tools, so the page never receives null.

* fix(mcp): keep client errors readable and server errors logged

Row tool errors on develop reached the client verbatim; the new mapping hid some behind "Internal error.".

* fix(mcp): map remaining field errors and document the legacy allow-list

* feat(mcp): keep existing connections on the tools they had

Fill every null allow-list with the legacy tools, so tools added later never reach an existing endpoint. New endpoint keys store their tools explicitly.

* feat(mcp): group tools by area

The consent page lists tools by group and offers presets built from them. It also gets the tools each workspace can't use.

* feat(mcp): read-only and full-access presets on the consent page

The tool list moves into McpToolPicker so Settings can reuse it.

* feat(mcp): change a connection's tools without reconnecting

PATCH on an OAuth connection or an endpoint key replaces its tools, checked against what the endpoint can use, and logs the change in the audit log.

* feat(mcp): edit tools from Settings

Each connected app gets an Edit tools modal and a hint for the tools it has off, since new tools never turn on by themselves.

* chore(mcp): changelog for tool groups and Settings

* test(mcp): point the OAuth e2e test at the tool picker checkboxes

* fix(mcp): keep stored tools on edit and check availability at consent

Sending back a connection's own list failed when one of its tools was unavailable, and
consent stored tools the workspace can't use. Removing tools now needs no permission.

* fix(mcp): keep hidden tools when editing a connection's tools

Ticking any box in Settings dropped granted tools that are only unavailable for now, and a
slow save for one app could close the modal opened for another.

* refactor(mcp): share list_views from core and expose database tools only

Tool definitions live in contrib and know nothing about MCP or Kuma, so the Agent Builder can reuse them. Builder and automation tools ship later with their write tools.

* fix(mcp): reuse REST errors, validate row values and name blocked fields

Bad row values and field-level denials now read like the REST API's errors instead of "Internal error." or a generic denial.

* refactor(mcp): drop tool availability until a tool needs it

No tool overrides is_available since the Kuma tools left this PR. Also loads form field options in one query in list_views and logs stored tool names.
2026-10-21 12:14:33 +02:00
Jérémie Pardou 93eeb19dcb feat: run Local Baserow integrations as Agents (#6064)
* Run Local Baserow integrations as Agents

* fix tests

* feat(core): add reusable subject options endpoint

* Add beta badge

* fix(audit-log): require actor type with actor id

* fix(audit-log): avoid duplicate actor export columns

* fix(audit-log): guard deprecated actor fields

* Restore the feature flag

* fix tab alignement

* fix(integrations): reject trashed authorized agents

* Fix migration conflict

* fix(audit-log): assert structured validation error

* fix(database): support agent row deletion trash entries

* fix(database): support agent row notifications

* fix(core): enforce subject option permissions

* chore: fix formatting after rebase

* fix(core): include agents in member totals

* fix(database): batch row history actor migration

* fix(integrations): handle trashed authorized agents

* fix(core): remove untranslated subject labels

* chore: move nodes around

* test: mock integration registry in AI agent service tests

* fix: resolve database migration conflict

* Add changelog entry

* feat: use typed subjects for local Baserow integrations

* fix: make audit actor migration retry-safe

* fix: retain historical audit actors

* Please linting

* fix: use canonical local integration subjects

* fix: order listed workspaces

* fix: validate current user integration authorization

* fix: preserve integration authorization on update

* docs: clarify migration deployment compatibility

* fix: paginate local baserow agent selection

* fix: validate selectable subject options

* fix: preserve integration authorization on update

* fix: show saved integration user in subject dropdown

* fix(enterprise): protect team subject options

* fix(builder): redispatch data sources for trashed agents

* fix(database): split row history actor backfill

* fix(enterprise): require audit log actor type

* fix(enterprise): use audit log actor options

* fix(core): prevent blank agent names

* fix(integrations): resolve migration conflict

* fix(integrations): pass SMTP preparation context

* docs: clarify migration rollout guidance

* fix: handle trashed integration subjects

* fix: reuse local integration authorization column

* fix: allow unconfigured local integrations

* fix: only update changed integration values

* fix: cache local integration subjects

* fix: sort field permission subjects by name

* fix: include historical audit log actors

* fix: center grow tab labels

* chore: remove unused AI providers flag

* fix: support agent file uploads

* Please linter

* fix: initialize integration edit values

* fix: preserve integration authorization updates

* fix: bound audit log actor pagination

* fix: support legacy local integration fixtures
2026-10-19 10:38:57 +02:00
alamin-br 2c5fca6538 feat(mcp): OAuth sign-in for MCP clients with CIMD, DCR and consent (#6312)
* feat(mcp): add django-oauth-toolkit metadata and scopes for MCP OAuth POC

Adds the OAuth provider settings, endpoint scope validator and discovery URLs behind BASEROW_MCP_OAUTH_ENABLED.

* feat(mcp): redirect OAuth authorize to Baserow consent and issue endpoint-bound codes

The consent API validates the authorization query, binds the code to an MCP endpoint, and returns the client redirect URL.

* fix(mcp): reject non-S256 and foreign-resource OAuth requests and read consent client from credentials

Shared validation backs both authorize and consent; the token audience is pinned to the MCP resource.

* test(mcp): cover CIMD host allowlist for MCP OAuth

* feat(mcp): serve Streamable HTTP /mcp with OAuth or endpoint-key bearer auth

MCP clients doing OAuth need a single resource URL; endpoint keys keep working as bearers.

* feat(mcp): revoke OAuth tokens when their MCP endpoint is deleted

Scope is matched as a whole word so endpoint:1 never hits endpoint:12.

* feat(mcp): add title and read-only/destructive annotations to MCP tools

MCP directories require a title and readOnlyHint/destructiveHint on every tool.

* feat(mcp): add consent page for MCP OAuth sign-in

* fix(mcp): only issue OAuth tokens through the consent flow

Open DCR let a client register for the password grant and request an endpoint scope,
skipping consent. DCR and the token endpoint now allow only authorization_code and
refresh_token, and only the consent view can add an endpoint scope.

* fix(mcp): strip trailing slash from the OAuth issuer and resource URL

A PUBLIC_BACKEND_URL ending in / produced a //mcp audience and a mismatched issuer.

* fix(mcp): add iss to OAuth deny and error redirects

The metadata advertises RFC 9207 support, so every redirect back to the client carries iss.

* fix(mcp): pass the authorize query to /mcp-authorize as base64url

The login redirect re-encoded the plain query, so the consent request failed after
signing in. /mcp-authorize also stays clear of the backend /mcp/* route.

* feat(mcp): limit an endpoint to its allowed tools

Null keeps every enabled tool, so existing endpoints and keys are unchanged.
tools/call now also refuses disabled tools, which match_by_name let through.

* feat(mcp): consent picks a workspace and tools

Users never see the endpoint row behind an OAuth connection; consent creates
or reuses it per client and workspace and stores the chosen tools.

* feat(mcp): pick a workspace and tools on the consent page

Replaces the MCP endpoint picker; the backend manages the endpoint row now.

* fix(mcp): reuse a consent grant only for the same OAuth client

Keying on the client name let manual endpoints and same-named clients share a grant.

* feat(mcp): drop dynamic client registration, keep CIMD only

Clients without CIMD use the endpoint key in the Authorization header.

* feat(mcp): redesign the consent page

Card with client avatar pair, verified badge, database counts and tool badges.

* feat(mcp): list and disconnect OAuth connections, refuse grant keys

Endpoints created by OAuth consent only accept their OAuth tokens, so their key
is refused on SSE and as a bearer, and they move from the endpoint list to a
connected apps API.

* feat(mcp): connect URL and connected apps in MCP server settings

Shows the one OAuth URL with per-client setup steps and lets users disconnect
apps they granted. Endpoint keys stay below under their own title.

* fix(mcp): hide OAuth grants from endpoint routes and left workspaces

The legacy endpoint routes no longer return grant rows or their key, and the
connections list skips grants in workspaces the user left, which can't be used
or disconnected.

* fix(mcp): load consent on the client so tool checkboxes render ticked

Server-rendered checkboxes lacked the checked class, which hydration kept while the state was ticked.

* fix(mcp): define django-oauth-toolkit swappable model settings

migrate resolves them when checking for model changes on an already migrated DB, which broke CI.

* fix(mcp): reset the SSE endpoint key when the key is unknown

The early 401 left current_key set, leaking it into later work in the same context.

* feat(mcp): give OAuth grants no key and one row per client and workspace

* fix(mcp): resolve the /mcp endpoint once and drop the /mcp/ route

* feat(mcp): hash OAuth tokens, expire refresh tokens and accept offline_access

Resource metadata lists only mcp; the CIMD host allowlist is now BASEROW_MCP_OAUTH_CIMD_ALLOWED_HOSTS.

* test(mcp): assert offline_access reaches the token and add refresh expiry control

* feat(mcp): rate-limit the OAuth token endpoint per client IP

* fix(mcp): validate consent once and only keep a grant when a code is issued

* fix(mcp): roll back the grant when the library answers consent with an error

oauthlib re-validates while issuing and returns non-fatal errors as a redirect, which committed the grant.

* fix(mcp): revoke OAuth grants when a user leaves the workspace

* fix(mcp): count only usable tools on connected apps

* fix(mcp): start reconnects from the existing grant's tools on the consent page

* fix(mcp): give the connections section its own BEM elements

* feat(mcp): send mcp_connected for Streamable HTTP clients

* fix(mcp): route /mcp, /oauth and OAuth metadata to the backend

* fix(mcp): route /mcp-authorize to frontend before /mcp to prevent 404

* feat(mcp): let MCP clients without CIMD register with DCR

Registration is anonymous, limited to public code-grant clients with https or loopback redirects, and unused clients are removed after a day.

* fix(mcp): reject DCR redirect URIs containing whitespace

DOT splits stored redirect URIs on whitespace, so one URI could smuggle in a second.

* docs(mcp): document OAuth sign-in for MCP clients

* test(mcp): load the URLconf before tests turn OAuth off

The OAuth routes are only mounted if the flag is on at URLconf import, so a test
that turned it off first left later tests in the worker with 404s.

* feat(mcp): periodically clear expired OAuth tokens

Rotation and reuse protection leave revoked refresh tokens, used codes and
expired access tokens behind. DCR registration tokens now expire so they're cleared too.

* style(mcp): drop dead and invalid rules in the OAuth SCSS

* fix(mcp): keep unnamed library metadata routes instead of crashing

* refactor(mcp): remove unused MCPEndpointHandler.get_by_key

* fix(mcp): only accept an OAuth token for its own client's grant

* fix(mcp): leave resource_metadata out of the 401 when OAuth is off

The metadata route isn't mounted then, so the hint pointed at a 404.

* fix(mcp): rate-limit the OAuth authorize redirect per client IP

Each anonymous authorize request can fetch and store a CIMD client.

* fix(mcp): delete CIMD clients that have no grant

Anonymous authorize requests store CIMD clients and nothing removed them.

* fix(mcp): say a CIMD host published the client, not that it verified it

With the default * allowlist the host is not vouched for.

* fix(mcp): name a DCR client without client_name by its redirect host

The consent title read "Connect " and the grant had an empty name.

* fix(mcp): route MCP and OAuth paths to the backend in the no-caddy nginx config

* fix(mcp): reject an access token that has no application

It crashed the /mcp request instead of returning invalid_token.

* fix(mcp): return the 404 JSON for RFC 7592 PUT and DELETE

Django's CSRF check answered them with a 403 page first.

* refactor(mcp): move the shared client avatar placeholder out of mcp_authorize

The connections list extended a placeholder defined in another component.

* fix(mcp): issue a refresh token only for offline_access

ADR 009 decision 6 ties refresh tokens to the offline_access scope.

* fix(mcp): stop the consent page from being framed

The consent page grants a client access, so it is a clickjacking target.

* fix(mcp): make the consent page tool toggles keyboard reachable

* docs(mcp): say the CIMD host allowlist only covers CIMD clients

* docs(mcp): route MCP and OAuth paths in the k8s and AWS examples

/mcp is only served by the ASGI app, so the examples sent it to a 404.

* fix(mcp): refuse to show the consent form inside a frame

Logging in inside a frame reaches the consent page by client-side navigation, which skips the frame headers.

* fix(mcp): always issue OAuth refresh tokens

Users stay signed in until they disconnect or the app goes unused for 30 days,
whether or not the client asks for offline_access.

* fix(mcp): keep the endpoint scope when a refresh narrows scopes

A refresh asking for scope=mcp issued a token without endpoint:<id>, which
failed on /mcp and escaped revocation on Disconnect.

* fix(mcp): keep OAuth clients that are still in use after a disconnect

Cleanup deleted a disconnected client the next day while the app kept using
its client_id. Clients now go after 30 days without a token, and an unknown
client on authorize tells the user to re-add the server.

* fix(mcp): serve the SSE route with a trailing slash

Turning off redirect_slashes made /mcp/<key>/sse/ a 404 instead of a redirect.

* fix(mcp): drop the error code from the 401 when no token was sent

RFC 6750 section 3.1 says no error code when the request has no credentials.

* fix(mcp): delete grantless CIMD clients a day after creation

Any anonymous authorize re-fetch bumps a CIMD client's updated, so it can't
mark use. CIMD clients are fetched again on demand anyway.

* fix(mcp): mark the OAuth client as used after saving its tokens

Matches the cleanup's lock order, tokens before the application row.

* style(mcp): rewrap the OAuth validator docstring

* fix(mcp): describe offline_access as it now behaves

Refresh tokens are issued whether or not it is requested.

* feat(mcp): audit log MCP OAuth connect and disconnect

ADR 009 decision 6: connecting and disconnecting are recorded in the audit log.

* test(mcp): give the OAuth action tests a unique module name

test_actions.py clashed with other test modules of the same name and broke collection in CI.

* fix(mcp): let users disconnect their OAuth grants without endpoint permissions

Listing grants and using them only needs membership, so disconnecting must not need the MCP endpoint operations either.

* fix(mcp): require the mcp scope on OAuth tokens used at /mcp

A refresh asking only for offline_access issued a token without mcp that /mcp still accepted. Refreshes now keep mcp, and /mcp rejects tokens without it.

* fix(mcp): ignore the redirect URI's own query when checking for an issued code

A client registered with a redirect URI like https://app.example/cb?error=0 never got a code.

* fix(mcp): send the OAuth connect PostHog event only after consent commits

The consent transaction rolls back when no code is issued, and the event was already sent by then. The audit log entry stays in the transaction.

* fix(mcp): keep OAuth grants out of the key endpoint lookup

Callers had to remember to pass a key-only queryset; grants have their own lookup.

* fix(mcp): show a CIMD client's host in a neutral badge

Any host can publish a client metadata document, so a green check made lookalike hosts look trusted.

* fix(mcp): show the readable reason when the consent request is rejected

* style(mcp): tidy an import and an outdated comment

* fix(mcp): name every client on the consent page by its client name

Matches Settings, which shows the client name with the host as a badge. A nameless CIMD client falls back to the host that published its metadata.

* fix(mcp): show fatal authorize errors on the styled consent page

The authorize endpoint answered unknown clients and bad redirect URIs with a bare text 400.

* test(mcp): add an e2e spec for the OAuth connect and disconnect flow

Enables BASEROW_MCP_OAUTH_ENABLED on the e2e and CI backends so the spec runs.

* fix(mcp): send only an error code to the consent error page

Free text in the URL could be injected and came back double-encoded after login. The page now maps codes to its own text and shows errors without sign in.

* fix(mcp): keep a CIMD client's host in the consent title

Any host can publish metadata under any name, so the title reads "Connect {name} from {host}". The neutral badge only repeated the host and is dropped.

* test(mcp): check the MCP status before parsing the body in the e2e spec

* test(mcp): await the login redirect in the consent middleware spec

The unawaited navigation ran the settings middleware after the request mock was restored, making a real request.

* fix(mcp): address final review findings on the OAuth flow

Authorize errors no longer redirect to client-registered URIs, CIMD redirect URIs follow the DCR rule, consent is rate-limited per user, and deleting a grant any way revokes its tokens.

* fix(mcp): accept ChatGPT, Claude and VS Code CIMD documents

django-oauth-toolkit 3.4.1 ignores token_endpoint_auth_methods_supported and refuses extra grant types; fixed upstream in #1856 and #1858 but not released.

* fix(mcp): update ChatGPT connect steps to the Plugins page

* feat(mcp): split MCP server settings into OAuth and Endpoint tabs

* fix(mcp): route /mcp without a trailing slash on K8s

The OAuth resource is /mcp, which the /mcp/ prefix missed.

* fix(mcp): give the CIMD document download one deadline

The library's timeout applies per read, so a slow-drip document held a worker.

* fix(mcp): bound anonymous client registrations

Caps the body at 16 KB and redirect URIs at 10; unsupported URIs are dropped instead of failing the registration.

* fix(mcp): rate-limit token revocation, count only failed token calls

Revocation loads the client, which can fetch and store a CIMD client.

* fix(mcp): preselect the granted workspace when reconnecting

It picked the first workspace with databases, so one Allow could move the app with every tool ticked.

* fix(mcp): carry the consent request in the path so SSO keeps it

SSO sign-in only keeps the return path. The frame headers move to the page so every spelling of the path gets them.

* fix(mcp): canonicalize the resource URL, scrub OAuth fields from Sentry

SDK clients send the resource normalized; the Sentry denylist only matches exact keys.

* fix(mcp): lock the membership while granting an OAuth client

A member removed during consent could otherwise keep the new grant.

* chore(mcp): count databases through the registry, add missing translations

* test(mcp): check the OAuth routes follow the flag

* test(e2e): skip the MCP OAuth test only when the route is missing

 Any other status hid a broken metadata endpoint.

* fix(mcp): explain rejected CIMD clients and load failures on the consent page

 Both showed the invalid request message, which suggested re-adding the server.

* fix(mcp): answer a refresh that lost a race with invalid_grant

With hashed storage the library returned a blank token and the token view raised a 500.

* feat(mcp): mark connected apps whose sign-in has ended

Grants stay listed after their refresh token expires, but the app has to sign in again.

* docs(mcp): add a self-hosting note for MCP OAuth sign-in

Covers the public URL, routing, outbound HTTPS for CIMD, the client IP the limits use and what turning the flag off does.

* fix(mcp): sign OAuth apps out on password change or reset

Browser sessions already end then; grants stay so apps show as signed out.

* feat(mcp): tick only the read tools on a first connection

Changing data becomes opt-in; reconnecting still starts from the existing grant.

* fix(helm): keep the MCP consent page on the frontend on a shared domain

Caddy ingress turns Prefix /mcp into /mcp*, which also caught /mcp-authorize.
2026-10-15 08:40:09 +00:00
Davide Silvestri 64c9fff85e feat [6/8]: prepare AI provider management for rollout (#6070)
* feat: retire AI provider flag and add rollout audit

* test: remove obsolete AI provider flag setup and docs

* chore: clean up AI provider configuration and tests

* feat: deprecate legacy AI provider environment configuration

* docs: explain AI provider migration sizing and timing

* docs: mark AI provider migration audit for removal

* docs: explain AI provider migration audit usage

* fix: log AI provider env deprecations after logging setup

log_ai_provider_env_deprecations() ran at the tail of _setup_health_checks(),
which ready() calls before setup_logging(). The notice went out through
loguru's default sink and missed BASEROW_BACKEND_LOG_LEVEL, the Baserow
format, and the OpenTelemetry log exporter, so operators shipping logs to a
collector never saw it.

Also drop two references the flag removal invalidated: the getEffectiveAIAgentModels
JSDoc still described filtering as conditional on the removed provider flag, and
the AI field architecture doc still pointed provider authors at the deleted
legacy workspace-setting hook. That doc now names BuiltInGenerativeAIModelType,
which is what grants an integration override model inheritance.

* fix: reuse environment AI settings in generation workers

* feat: import legacy AI provider settings on upgrade

Removing the ai-providers flag makes database-backed providers the default, which
would leave every existing installation on an empty AI providers page with a
management command as the only way to populate it. A data migration imports the
environment and each workspace's stored settings instead, so a standard upgrade
needs no commands.

Both scopes are imported in one migration. Legacy workspace settings replaced the
instance ones entirely, while database providers inherit, so each imported workspace
is also switched off the instance provider of the same type. Without that a workspace
would silently gain models billed to the instance account.

Settings that cannot fit their columns are skipped and logged rather than raising
DataError and rolling back the whole upgrade. The migration reverses as a no-op
because the previous version does not read these tables, so deleting rows would only
discard edits made during a rollback window.

migrate_ai_provider_settings stays as the recovery path and now shares its planning
logic with the migration, so both agree on which legacy settings are complete. It
deliberately does not switch workspaces off inherited providers, and warns instead.

* chore: remove the temporary AI provider audit command

audit_ai_provider_settings existed to inventory legacy configuration before a manual
import. The upgrade now imports automatically, so the command has no remaining step
to support. Removal was already tracked in #5749.

* docs: reduce AI provider docs to lasting behaviour

The upgrade procedure, rehearsal plan and sizing query described a one-time
transition and do not help anyone after the release; they live in the pull request
instead. What remains explains how providers work: the two scopes, how they combine,
the inheritance switch, what the deprecated environment variables still do, and how
integration overrides and published applications behave.

Also corrects claims that no longer hold: published applications keep materialised
credentials only when they were published before the upgrade, the import is no longer
optional, and a workspace-owned provider suppresses the environment fallback too.

* docs: shorten the AI provider changelog entries

Bullet points render as single list items under the entry. The released entries
average around twenty characters; these ran to four hundred, so the detail belongs
in the AI providers guide rather than the changelog.

* docs: clarify where imported AI credentials are stored

The previous wording implied Baserow's own exports carry provider credentials.
They do not: AIIntegrationType lists ai_settings as a sensitive field and
ImportExportConfig excludes those by default, and AIProviderConfig is not part of
any export path.

* docs: explain the AI provider upgrade and where to configure providers

State that the upgrade imports the BASEROW_* provider variables once and no longer
reads them, list the exceptions, and give the exact navigation for instance admins
(Admin tools -> AI providers) and workspace admins (workspace Settings -> AI
providers). Map each deprecated variable to the field that replaces it.

* fix: renumber the legacy AI provider import after 0121_agent

Develop's core 0121_agent and this branch's import migration both depended on
0120, leaving two leaf nodes, so migrate refused to run and the startup check and
E2E shards failed. The import is now 0122 and depends on 0121_agent.

* feat: remove the legacy workspace generative AI settings endpoint

GET/PATCH /api/workspaces/{id}/settings/generative-ai/ had no caller left, yet a
PATCH was still honoured for any provider type without a workspace provider and
never shown in the AI providers UI. Remove it with the handler parameter,
receivers and frontend handler that only it could trigger.

* fix: stop instance AI provider changes from fanning out per workspace

An instance-level change queued one Celery task per 25 workspaces behind a global
blocking lock, sent a payload to every connected user, and made the premium receiver
serialize every AI field on the instance. Instance changes now notify staff only;
other users see them after a reload. The render lock is per scope, and the in-use
guards no longer read one row per workspace.

* fix: keep inherited Kuma when a workspace switches off the instance provider

The upgrade switches imported workspaces off the same-type instance provider, which
made an inherited instance Kuma model invalid there, so Kuma fell back to the
deprecated env model or turned off. Inheriting the instance Kuma selection now
ignores workspace switch-offs; explicit workspace selections stay strict and are
the only ones that block a switch-off.

* fix: skip malformed Ollama URLs during AI provider migration

* fix: preserve skipped legacy AI provider connections

* test: cover independent legacy AI workspace connections

* fix: skip malformed legacy AI provider settings

* fix: move legacy AI import after current core migrations

The linear rebase omitted the migration renumbering from the previous merge commit, while develop advanced through core 0124. Rename the existing AI import to 0125, depend on 0124, and update its historical migration test so core has a single leaf.
2026-09-25 17:05:10 +02:00
Bram 6e5680264c All workspaces homepage [6/7]: Added recently viewed page (#6107)
* Added recently viewed page and show that on workspace homepage

* Fixed undo redo

* Fixed feedback
2026-09-25 13:32:42 +02:00
Bram eb1c1c613e All workspaces homepage [5/7] All workspaces sort functionality (#6002)
* Added sort to all workspaces homepage and remember preference

* Fixed feedback

* Fixed migration conflict

* Fixed feedback
2026-09-25 13:04:06 +02:00
Jérémie Pardou ad80341c03 feat: add Agent subject type (#5851)
* Add workspace Agents and permission management

* fix: remove all duplicate team subject memberships

* fix: align agent team role inheritance with users

* fix: delegate workspace role storage to subject types

* fix: preserve agent team memberships through trash

* Fix migration conflict

* fix: save agent settings pages independently

* fix: preserve agent roles across license changes

* fix: stabilize agent list pagination

* fix: filter agent websocket events by list permission

* fix: authorize agent team membership changes

* fix: serialize concurrent agent team updates

* fix: refresh agent teams through realtime events

* fix: restrict personal views to user subjects

* fix: deny agents with unavailable roles

* fix: exclude agents in trashed workspaces

* test: cover permanent agent access cleanup

* fix: gate agents in team selectors

* fix: accept trash option for preview actors

* fix: set native agent form button types

* fix: ignore stale agent modal saves

* fix: show permitted agent management actions

* fix: validate subject lookup fields

* perf: optimize batched user membership checks

* perf: cache agent team feature per list

* fix: map agent nonmember API errors

* fix: document paginated agent API schema

* fix: stabilize agent API schema operations

* fix: show agent name validation errors

* fix: show total agent count

* test: cover agent creation submissions

* test: cover agent and subject UI behavior

* docs: define direct subject role contracts

* fix: clarify team access management

* fix: use standard empty agents table

* fix: align agent name column styling

* refactor: move agent trash import

* refactor: align agent extension registry naming

* fix: recover agent team selector loading

* fix: validate every subject in role batches

* fix: ignore stale agent list responses

* perf: index recent team subjects

* fix: restore role handler imports

* Fix lint

* fix: reuse prefetched user memberships

* fix: preserve low priority role fallback

* fix: preserve trashed field permission subjects

* fix: open team picker when agent loading fails

* Fix tests
2026-09-21 16:32:32 +02:00
Davide Silvestri 22cd0eda09 feat: warn about AI model usage instead of silently breaking consumers (#6075)
* feat: report AI provider model usage per feature type

Feature types now count the rows they store referencing a provider model,
so the admin can be warned before disabling, deleting or narrowing one
instead of being blocked. Counting is by provider type and model
identifier because consumers do not store the provider row id, which
makes the result an upper bound: fit to warn, never to block.

Default-model features are excluded, their RESTRICT foreign key already
blocks the change.

* feat: count AI field and AI Agent references to a provider model

Both features store a provider type and model identifier per row rather
than a reference to the model, so nothing told an administrator what a
model change would break. They now count their own rows, skipping every
consumer whose owner is trashed: a field's table, database or workspace,
and an agent service's automation node, builder workflow action,
integration or application.

* feat: expose AI provider model usage over the API

GET /ai-providers/models/<id>/usage/ reports the per-consumer counts to
warn about and, separately, the default-model features that refuse the
change outright. Kuma holds a restricted foreign key, so naming it up
front lets the client say which selection to repoint instead of letting
the admin discover it through a generic error.

Permissions and scoping mirror the sibling model endpoints, so a
workspace-scoped caller cannot read an instance model's usage.

* feat: warn before an AI model change breaks its consumers

Disabling, deleting, renaming or narrowing a model now names what
depends on it and proceeds on confirmation. Disabling was entirely
unguarded before, and a rename orphans consumers just as thoroughly as
a delete because they persist the identifier string.

The counts are an upper bound: an instance model and a workspace model
sharing an identifier are indistinguishable to a consumer, so the copy
says a feature uses the model rather than claiming it will break. A
failed lookup degrades to the plain confirmation instead of trapping
the administrator.

* fix: keep an unavailable AI model visible in the AI field form

The form dropped a saved provider or model as soon as it stopped being
available, leaving empty dropdowns that hid what the field had been
configured with. It now retains the saved selection, disabled and marked
unavailable, the way the AI Agent node form already does, while the
validator keeps reading the genuine list so the field cannot be saved
until a real model is picked.

* docs: describe the AI provider model usage warning

* refactor: drop redundant blocking feature types from model usage

The usage endpoint pre-announced the features whose selection refuses a
change, but ERROR_AI_PROVIDER_MODEL_IN_USE already names them and the
frontend already renders that detail. Worse, the modal applied the list
only on rename, the one path that is never refused: Kuma holds a foreign
key to the model row, so the selection follows the rename instead of
breaking. The same claim was in the installation docs; both are corrected
to say what actually happens.

Also drop the `trashed=False` filters from both model reference counts.
AIAgentService.objects and AIField.objects are no-trash managers, so the
generated SQL already excludes trashed rows.

Rename the endpoint's operation id to get_ai_provider_model_usage: the
documented response is an object, not a list.

* fix: address Qodo review of the model usage warning

Count a service only while a live owner still reaches it. The previous
exclusion dropped the whole service as soon as any related builder action
was trashed, so a service shared by a live and a trashed action vanished
from the warning. Both owner managers already encode which ancestors count
as trashed, so the check reuses them through EXISTS instead of restating
the rules.

Treat a failed usage lookup as unknown rather than zero. Returning empty
counts made every caller skip its confirmation, letting a rename orphan
consumers with no warning at all; the dialog now says the check failed and
still lets the admin proceed.

Cover fetchModelUsage directly: payload forms, workspace scoping and the
snake_case to camelCase mapping had no store test.
2026-09-17 16:31:08 +02:00
Jérémie PardouandTsering Paljor 40c18a3c9f feat: add separate domain for preview (#5682)
Co-authored-by: Tsering Paljor <tsering@baserow.io>
2026-09-09 08:53:47 +02:00
Davide Silvestri ab45c2346a feat [4/8]: per-feature AI model settings (#5796)
* feat: per-feature and workspace-level AI model settings

Baserow could only point every AI feature at one instance-wide model. An
administrator can now register provider models, declare which AI features each
model may serve, and pick the default model per feature; a workspace admin can
inherit that choice, override it, or disable the feature locally.

The assistant resolves its model once per logical request and threads that
snapshot through its nested agents and tools, so a single run can no longer
re-read settings repeatedly or pick a model other than the one it validated.
The scoped provider state is memoized for the duration of a request, keeping
workspace serialization from loading it once per workspace.

Also:
- add Google and Groq provider types, and keep these database-only providers
  out of the legacy workspace settings they cannot round-trip through;
- prune orphaned feature selections so an unloaded feature type's RESTRICT FK
  no longer blocks provider and model deletion;
- record whether a configured model answers text and tool-calling probes, and
  invalidate that result when its credentials or identifier change;
- broadcast provider and availability changes over the existing realtime
  channel so open clients update without reloading;
- read the assistant model from the shared configmap, so frontend pods no
  longer miss it on Helm installs.

Manual test instructions live in docs/testing/kuma-model-settings-test-plan.md.

* fix: address AI provider settings review feedback
2026-09-04 10:53:53 +02:00
Davide Silvestri f27bb387fe feat [3/8]: add workspace AI provider management and complete AI Field resolution (#5785)
* feat: add workspace AI providers for AI fields

* fix: address workspace AI provider review feedback

* fix: address remaining AI provider review feedback

* fix: resolve core migration conflict

* fix: stabilize premium AI provider tests

* address feedback for local imports
2026-08-20 10:49:57 +02:00
Bram 43e1e74bcc feat: Improve admin views performance (#5855) 2026-08-10 17:28:01 +02:00
Bram 0e75a6bb6d feat: Harden workspace invites with Captcha and rate limit (#5808) 2026-07-31 21:34:13 +02:00
Bram 92ce535aba feat: Report abuse in public views (#5766) 2026-07-29 13:24:21 +02:00
Davide Silvestri c3706658a2 feat [1/8]: add instance AI provider management behind a feature flag (#5740)
* feat: add instance AI provider management

* fix: simplify AI provider testing

* fix: remove extra model list spacing

* fix: show AI provider form errors inline

* fix: use icons for AI provider row actions

* fix: place model errors before help text

* chore: polish code

* fix: address feedback

* fix: address remaining frontend CI failures
2026-07-27 14:12:37 +00:00
alamin-br 4ded9a7d37 Allow instance admins to manage users' 2FA state (#5517)
* feat: add password-free TwoFactorAuthHandler.disable_for_user

* feat: add UserAdminHandler.disable_user_two_factor_auth

* feat: add AdminDisableTwoFactorAuthActionType for audit logging

* feat: expose two_factor_auth status in admin users list

* feat: add admin endpoint to remove a user's two-factor authentication

* feat: show 2FA status column in admin users table

* feat: allow admins to remove a user's 2FA from the edit user modal

* chore: add changelog entry for admin 2FA management

* style: add styling for the remove 2FA link in the edit user modal

* fix: correct admin users 2FA column width and edit-modal layout

Give the new 2FA column an explicit width so it no longer sizes to its
content and pushes the row past the container, which had clipped the
rightmost "Highest Role" badge.

Wrap the edit modal's 2FA badge and remove link in a centered flex row
with a gap, and tighten the link so it aligns with the badge instead of
out-weighing the primary Save action.

* fix(review): register AdminDisableTwoFactorAuthActionType in apps.py

The new admin 2FA-removal action type was not registered in the action
type registry like every sibling user action. Audit log entries were
still created (the action_done signal carries the type directly), but the
action was absent from the enterprise audit-log export filter choices
(action_type_registry.get_types()) and unresolvable via the registry.
Register it alongside the other user action types and add a regression
test asserting it is registered.

* fix: show admin users active state as an icon only to free column space

Drop the "Active"/"Deactivated" text label from each row and keep just
the status icon (with a tooltip), so the table reclaims horizontal space
and the enterprise "Highest Role" billable badge is no longer clipped.
Both states keep an icon. Also drop the 2FA column width override, which
over-reserved space without helping.

* test: parametrize admin user password and name validation tests

Collapse the three password-validation tests and the two name-length
tests into test.each cases. Same coverage, less duplication, and a new
validation case only needs another data row.

* fix(review): annotate 2FA serializer schema and document 403

- Add @extend_schema_field(TwoFactorAuthSerializer) to get_two_factor_auth
  so the OpenAPI spec reflects the {type, is_enabled} shape instead of a
  bare object.
- Make the empty-provider case an explicit {} return rather than relying on
  TwoFactorAuthSerializer(None).data, which only yields {} because both
  fields are read_only.
- Document the 403 response on the admin two-factor-auth DELETE endpoint
  (IsAdminUser returns 403 for authenticated non-staff users).

* test: cover admin 2FA self-removal and modal error path

Add a backend test asserting an admin can remove their own 2FA (the
handler intentionally allows self-removal since it can't lock anyone
out), locking in that behavior against a future self-modification guard.

Add a frontend test for the DisableTwoFactorAuthModal failure path: on a
non-204 response the error surfaces in the modal and the optimistic row
clear is not applied, so the 2FA badge stays as-is.

* fix(review): drop misleading 2FA required marker and document empty schema

- Remove required attribute from the read-only 2FA FormGroup in UserForm
  (it wraps a display badge, not an input, so the indicator misled admins).
- Annotate get_two_factor_auth with a raw OpenAPI object schema that omits
  required, so the empty {} (no provider) case is valid while still
  documenting the {type, is_enabled} shape. Response data is unchanged.

* fix(review): null 2FA state, register 2FA actions, trim raises doc

- Return null (not {}) from get_two_factor_auth when no provider is
  configured; document the field as a nullable typed object. Propagated to
  admin/enterprise tests, EditUserModal optimistic update, and the user
  fixture. Make TwoFactorAuthField null-safe so the cell tolerates null.
- Register the pre-existing ConfigureTwoFactorAuthActionType and
  DisableTwoFactorAuthActionType so they appear in the audit-log dropdown.
- Drop the TwoFactorAuthNotConfigured :raises from disable(); it is raised by
  disable_for_user, which already documents it.
2026-06-22 15:34:37 +02:00
Bram 5b77347066 feat (auth): implement Cloudflare Turnstile captcha (#5052) 2026-03-27 17:32:11 +01:00
Tsering PaljorandJeremie Pardou 7bf50f86a4 fix: handle error when user logs out while refresh token is already expired (#4987)
* Handle error when refresh token is already expired.

* Update code

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-03-18 07:51:42 +07:00
Bram c0137f227b Reorganize onboarding and add Kuma AI (#4606) 2026-02-10 11:30:29 +01:00
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00
Bram cfb684af7a [2/6] View level permissions - Filters (#4070) 2025-12-03 19:32:53 +01:00
Bram 05ec05a613 Allow change account email (#4329) 2025-12-03 13:41:50 +01:00
Bram 5f1a456e3b Resolve "Two-factor authentication (2FA) support" (#4074) 2025-11-05 22:47:50 +01:00
Bram 4a9d4ec334 Workspace search (#4076)
Adds ability to search various items in workspace
2025-10-22 20:09:40 +02:00