Commit Graph
6 Commits
Author SHA1 Message Date
Davide Silvestri 638d7236c3 feat(agent): let triggered runs ask a person (#6812)
* feat(agent): let triggered runs ask a person

A trigger-started reply gets a built-in ask_person tool when the trigger's
may_ask_person is on (default). The call is held like an ask-first call:
the run pauses, counts as going for the overlap rule, and resumes with the
answer of someone who may approve tool calls, or is told nobody will
answer when the question is dismissed. Unattended replies are told that
nobody reads them and whether they may ask; follow-ups keep the
outside-data instruction. Later replies replay each decided question and
its answer as plain turns in their history.

* feat(agent): answer an agent's question in the conversation

A held ask_person call shows as its own card with an answer field, Send
answer and Dismiss, kept out of the approval card's batch actions. Only
people without the approve permission see it read-only. The trigger card
gets a switch to let the agent ask a person, and approval wording now
covers questions too.

* test(agent): cover asking a person end to end and record it in ADR 014

* refactor(agent): build the question tool like web fetch and tell it from actions

The question tool is a plain Pydantic AI tool in agent/tools.py that the
reply runner wraps in a FunctionToolset, like web fetch. A held call is a
question only when it has no tool key, so an action saved as ask_person
before the name was reserved keeps its normal approval. History prefetches
only the decided questions, and the pending approvals menu links to the
conversation only for a pending question.

* test(agent): cover Ask first in a triggered run end to end

With changes set to not ask first, a triggered run creates a database without waiting; turned back on, the same run waits for approval and finishes once approved.

* test(agent): open the Triggers section in the ask-a-person spec

The section was renamed on develop.

* fix(agent): keep web search off next to the question tool on older Gemini

Gemini before 3 refuses web search next to function tools. The question
tool now counts as one, so a triggered run that may ask a person no longer
sends both, gets a 400 and records a failed search on every run.

* fix(agent): keep the ask-a-person switch of a license-locked trigger read-only

The API refuses the change like the trigger's other locked settings, and
the card makes the section inert and the switch read-only, like the
overlap rule.

* fix(agent): reserve the web_fetch action name

An action named web_fetch on an agent with web fetch on gave two tools
with the same name, so every reply failed when its toolsets were built.

* refactor(agent): drop the special case for an action named ask_person

Agents are behind a flag with no production users, so the name is simply
reserved like the other built-in tools: a held ask_person call is always
a question, on the backend and in the conversation.

* fix(agent): answer a waiting question after asking is turned off

ask_person now defers its call, and the resumed run gets the answer, or
the dismissal note, as the call's result. Turning the trigger's switch off
only stops new questions, instead of telling the agent that an answered
question is no longer allowed while the card shows it as answered.

* fix(agent): decide calls held with a question from the pending approvals menu

The question shows as its link row to the conversation, and the other
held calls stay in a card below it, so they can still be approved or
rejected from the menu.
2026-11-25 17:17:04 +00:00
Davide Silvestri 16dbb0690f feat(agent): configure who can chat, approve and continue triggered runs (#6826)
* feat(agent): configure who can chat, approve and continue triggered runs

Approving held tool calls and continuing a conversation a trigger started
become their own operations. With RBAC, an agent's Permissions section
sets who may chat, approve and continue: a lowest role, specific people
or teams, or nobody. Without RBAC every member chats and approves, and
nobody continues. The owner of a private conversation can ask others to
approve its held calls, and leave it to them.

* feat(agent): let everyone in a private conversation leave it and name who stopped a reply

Anyone asked to approve can now remove a private conversation from their
own list; only its owner deletes it for everyone. Once the owner has
left, the last person to leave deletes it for good, as only an owner's
trash may list a private conversation. A reply someone else stopped says
who stopped it.

* fix(agent): close the gaps a security review of participation found

Keep a triggered conversation's opening message untrusted when a person
continues it, audit changes to who can chat, approve and continue, and
require being able to chat to ask others to approve. People asked to
approve follow runs only while they may read the conversations, the
approver picker scans at most a thousand members, and the permission
object lists only the agents the person may see. A reply whose sender
was deleted can still be resumed by someone asked to approve it.

* docs(agent): add the participation test plan with its results

Cover every participation setting, asking others to approve, leaving a
private conversation and stopping replies, with the outcome of the e2e
run and the findings of the security review.

* fix(agent): address the review of participation permissions

- Name only people's messages to the model: a trigger's opening message
  no longer reads as written by a deleted user.
- Check the approver candidates in one pass, so the number of queries
  doesn't grow with the workspace.
- Show the read-only note only to who can't write in a conversation.
- Take a person who leaves the workspace out of the conversations they
  were asked into and the rules naming them, and delete the conversations
  nobody is left in.
- Record a rule change and its audit entry in one transaction.
- Refuse a custom approve rule nobody named in it could use.

* docs(agent): update the participation test plan after the review
2026-11-25 09:24:20 +01:00
Davide Silvestri d1afcddf48 feat(assistant): stop background replies between tool steps (#6384)
* feat(assistant): stop Kuma background runs cleanly

Wire product Stop to durable cancellation, including before stream metadata
arrives. Wait for active tools to drain and keep the items they finished on both
background and existing streaming paths. Cover stopping state and retained work.

Part of #6346

* Add the background Kuma replies changelog entry

One entry for the whole stack, so it lands with the last PR.

* fix(assistant): keep completed shared tool work when stopped

* fix(assistant): honor Stop before tool dispatch and navigation

* fix(assistant): check Stop through the lease renewal before tool calls

The check read the run's idle connection, so a dropped connection failed the reply.

* fix(assistant): keep docs search working after a dropped connection

* refactor(assistant): one isStopping rule for Kuma's panel and run events
2026-11-23 14:22:01 +01:00
Davide Silvestri 74d6625a49 feat(assistant): run Kuma replies in the background (#6383)
* feat(assistant): stream Kuma background replies over HTTP

Behind assistant_background_runs, commit and enqueue the message then follow
Redis on the existing POST/200 cumulative JSON response. Resume the same run
without sending the prompt again. Keep refresh, multi-tab discovery, onboarding
and durable outcome recovery in the Kuma adapter and UI integration.

Part of #6346

* Remove unused Kuma chat run response header

* Register Kuma with the shared async streaming router

* Always execute Kuma messages in background runs

* Use chat run constant enums in Kuma

Kuma's model_unavailable error code moves to its own run constants,
because the engine no longer defines run type specific codes.

* Move the tool executor into Kuma

Kuma is its only user, and it is specific to pydantic-ai agents, so it does
not belong to the shared chat run engine.

* Return nothing from Kuma's interruption warning hook

The engine now prunes a run whatever the hook does, so it no longer reports
whether the warning was kept.

* Stop patching the removed ChatRunBuffer.finish

* Fix and simplify Kuma's background run adapter

- Save "nothing changed" when the model was unavailable or the prompt
  never reached it.
- Keep the progress line after a reconnect and build the compatibility
  records from their models, with the right text for runs that did nothing.
- Delete the in-request path, its cache-key Stop and the event bus.
- Map a second message to 409 directly and return one run shape in the
  chat API.
- Fix docstrings, help texts and the POST schema; drop overlapping tests and
  share run test helpers.

* Fix and simplify Kuma's run follower in the browser

- Keep local-only messages on refresh and show a queued run as queued.
- Settle a request aborted before it is sent and never show raw error pages.
- Fall back to the API for a new view whose broadcast is late.
- Stop a run through the engine.
- Delete the reader for the previous backend, the old cancel call and the
  UI location history.
- Share run test helpers and drop overlapping tests.

* Tighten Kuma's e2e tests, CI setup and docs

- Prove a live resume after a reload and drop a test that proved nothing new.
- Keep Kuma's panel closed in every browser context through the storage state.
- Drop the unused OpenAI key from the e2e setup.
- Rewrite the background replies section of the AI assistant docs.

* Handle Kuma runs whose sender lost access, and other review fixes

- A queued run whose sender can no longer use Kuma ends as access_lost
  without calling the model.
- A chat keeps asking runs for a title while its title is provisional.
- Test that a run captures and saves its onboarding target.
- Pass Phoenix settings to the dev export worker; pin CI's Kuma stub to
  Node 24.22.1.

* Fix Kuma's browser edge cases found in the re-review

- A send whose stream is refused after its run started re-reads the
  chat and counts as accepted.
- A chat read that ends after another chat was chosen is dropped, and
  only a 4xx forgets the tab's stored chat.
- An unsaved outcome stays shown while its run is the chat's latest.
- The status line shows that Kuma is answering.
- Empty stopped or failed answers show only their outcome.
- Logout clears Kuma's chats, messages and pending navigation.

* feat(assistant): follow Kuma replies through shared chat runs

* refactor(assistant): remove obsolete stream-limit recovery

* fix(assistant): simplify Kuma cutover and preserve legacy Stop

* fix(assistant): preserve existing Kuma API contracts

* refactor(assistant): match stream event kinds

* refactor(assistant): simplify execution and navigation

* fix(assistant): show that Kuma is cancelling after Stop

* test(assistant): cover the stale refresh guard and trashed workspaces

* refactor(assistant): close the run follower and drop the unused baseline

* refactor(chat-runs): share the run-in-progress error code

* docs(assistant): document the run limit and the deprecated chat status

* fix(assistant): give a duplicated tab its own Kuma tab id
2026-11-18 11:21:31 +01:00
alamin-br d0aef1e178 Button field: bound one HTTP action by its timeout (#6104)
* fix: stop a trickled response body from outliving its deadline

iter_content blocks inside urllib3 until a whole chunk arrives, so the deadline check never ran against a server sending a byte at a time.

* feat: send an HTTP request under one deadline across redirects

Requests gives every hop a fresh timeout and reads redirect bodies unbounded, so a redirecting endpoint could outlive the button's row lock.

* fix: hang up an HTTP request whose headers outlast its deadline

The per-hop timeout only bounds a single socket read, so a server trickling out a status line or headers could hold the connection open long past the deadline.

* fix: hang up a connection that opens after the HTTP deadline

The watchdog only shut down sockets already open when it fired, so a connection still resolving DNS or finishing a TLS handshake at that moment kept trickling headers past the deadline.

* fix: bound the HTTP request action by one deadline

Its lock budget now covers the worst case that deadline allows.

* fix: send a button's external action outside a database transaction

On a click the dispatch savepoint was the only transaction, held open for the whole network wait.

* test: add a barrier stub e2e tests can hold requests on

* test: hold the button concurrency e2e requests on a barrier

They now wait until the backend's request has arrived instead of relying on a slow endpoint, and F2 proves both locks were held at once.

* fix: report a TLS error while reading a response body as one

* docs: say what the dispatch savepoint and the HTTP watchdog cover

* test: pin the barrier stub image by digest

* test: run the held-request e2e tests one after the other

* fix: keep a redirect's body when it is the final response

The redirect hook already read it, and reading again overwrote it with nothing.

* fix: report a cut-off compressed body as a timeout

A body read until close could not be hung up on, and a cut-off one surfaced as a decode error.

* refactor: run HTTP deadlines on one watchdog thread

A thread and eight classes per request, and a response held in a reference cycle, cost more than one shared watchdog.

* fix: send the Slack action under the request deadline

Its per-socket timeout let a slow endpoint hold the click past the row lock.

* test: give the HTTP deadline tests room on a busy runner

One second of margin was too little under -n auto; a regression still takes ten.

* refactor: let the dispatch context choose to send outside the savepoint

Sending outside the savepoint was inferred from in_atomic_block, which
pytest-django's db fixture always reports True for, so only the
transaction=True tests ever covered production behaviour. The dispatch
context now says explicitly whether its caller sends outside a
transaction of its own.

* refactor: derive a database action's is_external from its service

The action's own flag could drift from the service type it dispatches
through, so it now reads that service type's flag instead of keeping a
second copy.

* refactor: remove the unused HTTP request function getter

The HTTP and Slack services now send through send_http_request, so
nothing calls get_http_request_function any more.

* test: give each held-request e2e run its own barrier keys

The chrome and firefox projects both run this file by default and
were sharing the fixed "slow"/"slow-two" barrier keys and its reset,
so a parallel run of one project could release or wipe the other's hold.

* fix: keep the HTTP deadline watchdog running when a hang-up fails

An unguarded hang_up() killing the one watchdog thread would silently
stop deadline enforcement for the whole process.

* docs: correct the dispatch flag and test comments

The old wording pointed at the wrong transaction and repeated or
narrated stale reasoning that no longer matches the code.

* fix: keep a failed hang-up from logging the request's address

Loguru prints frame locals beside a traceback, and a watched socket's repr names its peer.

* test: stop the failing hang-up test racing its own deadline

A send slower than its 0.3 s deadline on a busy runner timed out before the failing hang-up was in place.

* fix: give every connect attempt only the time left to the deadline

urllib3 and advocate try each resolved address with the timeout the hop started with, so four addresses that never answer took four timeouts.

* test: start the barrier keys over before each held-request test

A released key stays released, so the second test in a worker was answered at once and never held its lock.

* fix: watch a proxied request's connections under its deadline

Requests keeps a pool manager per proxy apart from the adapter's own, so its sockets were never watched and a trickling proxy held a request past its deadline.

* docs: say what sending outside the savepoint relies on

* fix: keep two HTTP timeouts outside a click and drop the audit hook

Builder and automation keep the budget they had until #6117 settles theirs.
send_http_request now reads the body itself, and connect attempts are bounded
in the connect loops, so no process-wide audit hook is needed.
2026-09-21 14:28:47 +02:00
alamin-br 5459f9ecb5 feat[4c/6] Button field: send a Slack message (#6005)
* feat: let a database carry integrations, and take them along in an export

* feat: let a button field post to Slack through a bot of its own database

* feat: offer the Slack action in the button field editor, with the bots of its database

* docs: record where a button's external integrations live, and what an import drops

* fix: draw the button's action list the way the design does

* fix: put a Slack message's answer where its schema says it is

* test: drive the Slack action end to end, and send for real when a bot token is given

* test: let the e2e stack answer for Slack, so a click is proven in CI

* fix: charge a click for a Slack post its API refused

The refusal is raised once the post has been made, so treating it as
'nothing left the instance' handed the outbound slot back and let one row
drive unbounded requests at Slack.

* fix: read one rule for the integration a button may carry

Saving, importing and dispatching each spelled the rule out again, and
dispatch had lost the half about the field's own database. The refusal is
one answer now: three different ones let a caller walk the ids and learn
what the installation holds.

* fix: keep the Slack action standing on an answer that is not Slack's

The endpoint is configurable now, so a refusal need not carry an error
code, and a blocked address reads like the HTTP service's. The channel is
held to its column, and a half-filled form is described rather than
thrown over.

* fix: forget a database's integrations when its application is replaced

Remembering the fetch in a module-level map outlived the object it
described, so after any refetch the bot dropdown stayed empty and the only
thing offered was creating a second bot. A failed fetch is now reported
rather than left as an unhandled rejection.

* test: point the e2e suites at the renamed label and the stub's real path

The email spec picks its action by exact label, which this branch renamed,
and the stub was mounted from a path that does not exist once the recipe
has moved to the repo root.

* test: let the API guard for an unsupported application keep a type to refuse

A database accepts integrations now, so the endpoint test that used one to
prove the guard was asserting the opposite of what ships.

* fix: hold a database to the integrations its buttons can actually carry

Opening a database to integrations opened it to every type, so a Local
Baserow one, carrying an authorized_user, could be created on it and ride
along in every duplicate and snapshot. Refusing it on the action was not
enough. The list is read from the action types themselves, so the two
cannot drift.

* fix: answer a refused address and a stranger's JSON the way the HTTP action does

An address Advocate blocked was charged to the click although nothing was
sent, an answer that is not an object raised out of the service, and the
frame holding the bot token was logged with its locals. The channel form
also refused a length the API accepts.

* fix: check the integration an action carries on every save, not just the first

An edit that resent only the channel and the message skipped the read
check, so someone who may edit the field but not read the bot could
retarget it.

* fix: check who is copying an action against the integration it carries

Duplicating a field and changing a field's type both recreate the actions
without passing through the endpoint that checks the credential, so a copy
kept a bot the person asking for it may not read. The duplication hook now
carries the acting user, and a copy it cannot account for comes back
unconfigured.

* fix: hold a Slack answer to a size and a deadline, the way an HTTP one is held

The endpoint is configurable now, so its answer is not bounded by Slack's
own limits, and the request timeout restarts on every byte. A body that
drips could outlive the lock its dispatch time sizes, letting a second
click post against the same row. The reader the HTTP service already had
now lives beside the request function both of them use.

* fix: read the clicked field once, and survive an id an export made up

The dispatch guard read the field back through every action, two cold
queries apiece inside the lock, when the context already holds it. And an
integration id from an import file is not the validated integer the
endpoint's serializer produces, so a hand-edited export failed the job
with a database error.

* test: land a second click while a Slack post is still in flight

The lock that keeps two clicks off one row had no Slack coverage, which is
what the size and deadline on the answer are there to protect. The stub
holds one channel open long enough for the second click to arrive.

* docs: say what an empty integration list means, and what an authorized user does

It read as though only the row and frontend-only actions carried nothing,
when HTTP and email carry nothing either, for reasons of their own. And an
integration's authorized user does not outrank the clicker, it replaces
them: the dispatch never compares the two.

* fix: check what a duplicating user may read on every path that copies an action

The permission check only ran where a person copies an action in place, since
that was the only path carrying an actor. Duplicating a table or a database
goes through the serialized import instead, which had nobody to check, so the
copy kept a bot its owner may not read.

`ImportExportConfig` now carries who asked for the copy. An import from a file
and a template install still carry nobody, and keep what they came with.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: refuse an imported integration the application would not accept

The endpoint refuses a Local Baserow integration on a database, because its
authorized user would replace the clicker (ADR 006 section 5). The import path
never asked, so a hand written export placed one anyway, and it rode into
every duplicate and snapshot from there.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: read an integration id out of an export before keying the mapping with it

A list or a dict is not hashable, so looking one up aborted the whole import
job with a `TypeError`. `true` hashes equal to 1 and quietly picked up
whatever integration 1 was remapped to. A numeric string missed the mapping
and then resolved the id the export was written with, which is another
database's.

Coerced before the lookup rather than after, and booleans, containers and
floats refused outright.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* perf: read the bot once however many actions of a click share it

`select_related` only saves the base row. The token lives on the subtype, and
resolving that row by row cost a query per action, inside the lock that guards
the row. Three actions sharing one bot read it three times.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: hold a Slack post to the time its lock was sized for

The timeout Requests applies is per socket operation, not for the call as a
whole, and redirects were followed, thirty of them if offered. A configured
endpoint could spend a fresh timeout on every hop and outlive the lock that
guards the row, letting a second click through.

Redirects refused, since `chat.postMessage` answers directly, and the lock
sized off the socket operations the way the email service already does.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: remove only the containers the local e2e run started

A trap replaces the one before it rather than adding to it, so the Slack stub's
had to name httpbin too. It named it whether or not this run started one: point
E2E_HTTP_STUB_URL at your own stub and the block that starts httpbin never
runs, but the exit still removed whatever was using that name.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: let a fetched integration list land on the application still on screen

The fetch mutated the object it was handed, so a `forceSetAll` in flight left
the bots on an object nobody renders while the one on screen stayed empty. And
it cleared and repopulated with no ordering guard, so a bot created while the
request was open was wiped when the answer landed, with nothing to fetch it
again.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: ask again for a bot list the editor failed to fetch

The action cards are hidden rather than unmounted, so a fetch tied to a form's
own `created` ran once for the life of the editor. After a network blip the
dropdown read as a database with no bot, and the only thing offered was
creating a second one. Every form also reported the same failure, so three
Slack actions raised three toasts for one request.

The list owns the fetch now: it knows when a card opens, so reopening one asks
again, and there is one place to report from.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: make the integration dropdown selectable, editable and reachable

Every parent binds it with `v-model`, which listens for `update:modelValue`.
Creating an integration from the footer emitted `input` instead, so the bot was
created and then not selected. The auto select of a lone integration went the
same way.

The footer was an anchor with no href, so tab skipped it and no key opened it,
which left creating a first bot unreachable without a mouse.

And the footer only ever opened the modal to create. A database has no
integration settings page of its own, so an imported bot, whose token the
export stripped, could not be repaired from anywhere.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: say when a Slack action carries a bot with no token

An export strips the credential, so an imported bot arrives named and unusable
while the action still looks configured. Every click was then an outbound
request that was never going to work, and the reason only arrived after it.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* test: cover the Slack request deadline and its refused redirects

The tests for these were written with the fix and then left out of it, so the
lock sizing and the refused redirects went in uncovered.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: report a failed integrations fetch once for the request, not once per waiter

Moving the fetch to the list left the reporting with the caller, and a list can
be asked for the same request more than once. Each caller then caught the same
rejection and raised its own toast. Reported from inside the shared request
instead, so one failure is one message however many are waiting on it.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: describe the Slack answer where the dispatch actually puts it

`generate_schema` advertised `ok`, `channel` and `ts` at the root while the
dispatch kept them under `data`, so every path the data explorer offered for a
Slack node resolved to nothing. Chaining off one has never worked.

The schema describes the wrapper now, rather than the dispatch dropping it.
That leaves every sample an earlier version stored exactly as it is, so no
migration is needed. The cost is that this service describes its answer one
level deeper than the HTTP and email ones, which unwrap theirs instead.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* feat: say who else can use a Slack bot when its token is entered

A database's integrations are shared by everyone who can build in it, and nothing said
so at the moment that matters. The warning goes where the decision is made, and is
worded around reuse rather than exposure, since the token is never shown back.

It comes out again once ownership or private integrations land.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* docs: keep the integration rule in one place, and say what the new methods take

The comment on `allowed_integration_types` listed every action type's reason, which goes
stale the first time someone adds one. It now says what an empty list means and points
at the ADR, which carries the reasoning.

The methods this branch added or changed say what they take and what they answer with.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* docs: bring ADR 006 up to what phase 4c actually built

Section 5 said databases carry integrations while later sections still read as though
external actions were unbuilt: nothing to strip, nothing to reconfigure, no integrations
on a database at all.

Now recorded: which integration types an action may carry and why the list is empty for
most of them, that the database derives what it holds from those lists rather than
keeping a second one, which copy paths carry the requesting user and which deliberately
do not, what happens to a stripped token on import, and the Slack action's own
lifecycle.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* test: prove a Slack answer reaches the paths its schema offers

Three gaps found reviewing the fixes against what was asked for.

The e2e still reopened the dropdown to pick the bot it had just created, which
was the manual step the Vue 3 event was meant to remove. The dropdown now says
so on its own, and a form test covers it, asserting the selected value rather
than the item list, which holds the name either way.

And nothing exercised an automation node reading a Slack result, which is what
the shape question was really about. The new test builds the stored result with
`dispatch_transform` and walks the paths out of `generate_schema`, so moving
either side without the other fails it.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* refactor: cut the comments back to what is not already in the code

Roughly half of what this branch added restated the line below it or explained
at paragraph length what a sentence covers. Kept the ones that say why, dropped
the rest, and fixed a stale reference to an exception this service no longer
raises.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: keep the integration dropdown reaching its parent

Declaring `update:modelValue` in `emits` was half a fix. Vue keeps a declared
event's listener out of `$attrs`, so the parent's `onUpdate:modelValue` stopped
falling through to the dropdown below, which was the only thing carrying a
list selection back. Creating a bot worked; picking an existing one silently
did nothing, for the builder's data sources and user sources as much as for a
button field.

Everything now goes through `select`, and `autoSelectFirst` reads what the
parent actually bound rather than the `value` prop nobody passes.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: do not remember a load that backed off, or share one across requests

A fetch that backed off returned the list it declined to fill, which read as
success: the caller marked the database loaded, so bots that existed before
the request never appeared and nothing asked again. It answers null now, and
only a fetch that committed marks the load.

The in-flight map was also module scope, which one server process shares
across every request it renders. Keyed by store instead.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: let an action's bot be cleared without permission to read it

`get` cannot tell a key the request never sent from one sent as null, so
clearing the integration resolved to the one already carried and was refused
to anyone who could not read it. Removing a credential takes nothing away
from anyone, so it needs no such permission. An absent key still keeps and
checks what the action carries.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: stop a failed Slack request repeating the message back in its error

`except ConnectionError` caught the builtin, which requests' own
ConnectionError does not inherit from, so that branch never ran and the
failure fell through to a clause that raised `str(e)`. Requests builds that
message out of the whole URL, and this one's query string carries the channel
and the resolved message text.

`response.json()` sat in the same block, so a proxy's HTML or a redirect body,
which `allow_redirects=False` now stops following, surfaced as an opaque parse
error. Read outside it, and reported as an answer that is not Slack's.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: let a database still turn integrations off entirely

The override answered from the action types alone, so `supports_integrations`
was dead for databases. The two tests that turn it off to exercise the guard
were passing on the allow-list instead, and would have passed with the guard
deleted. Both now name a type the allow-list accepts, so only the flag can
refuse it.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* docs: say that a bot's token can be read, because it can

The warning claimed the token stays hidden. The integrations endpoint
serializes it in the clear, as it does for every other type, and this branch
is what exposes that endpoint on databases. Reworded, and the ADR with it,
noting that masking it on read is worth doing and is not scoped here.

Also finishes the comment trim, which a script gave up on halfway through, and
sources the Slack logo from the integration type that already owns it.

Claude-Session: https://claude.ai/code/session_0125wkP6wPcyQ3MZwtbDawhr

* fix: send the Slack channel and message in the body, not the query string

Both are row data. A query string is what a proxy writes to its access log, and
this PR makes the destination host configurable, so the message travelled
further than it needed to. The error path already worked around this by
refusing to repeat `str(e)`; sending the payload as form data removes the
reason for that.

* fix: keep a bot out of a duplicate made by someone who may not read it

A duplicate is taken with `exclude_sensitive_data=False`, so the bot was cloned
into the new database with its token. The action's `ReadIntegration` check then
ran against that clone, which lives in an application the duplicator owns and
can read, so it always passed. Denying read on a bot and duplicating the
database was a way to obtain its token.

The credential is left out of the export instead, and the copied action drops it
for want of one it may carry. One `check_multiple_permissions` call for the
whole list rather than one per integration.

The existing test passed only because it denied the operation by name, which
denied the clone too. The new one denies a single object, the way a per-object
role assignment does.

* perf: stop reading the same integration row three times on every save

The check resolves the integration to check it, then hands the id on and the
service type reads the same row twice more, base and subtype. It passes the
instance it already has instead. Its own checks are looser than the ones that
have just run.

The click path resolved integrations with `specific_iterator` directly, which
skips each type's `enhance_queryset`, trading one query per action for one per
related row. It goes through `IntegrationHandler.get_integrations` now.

Also says in the comment why an edit that does not resend the id is still
checked: the channel and the message are the whole of what a bot does.

* fix: skip an integration an application will not take, rather than fail the import

The gate refused the whole job. No export this instance writes can fail it
today, but a release that stops registering an action type would turn every
snapshot holding that integration into one that cannot be restored, and a
restore is the one path a user cannot work around.

The row still does not land, which is what the gate is for. An action naming a
skipped integration imports unconfigured, the same as for any integration it may
not carry. Only the database type narrows what it accepts, so nothing else can
see the None this now returns.

* refactor: tidy what the database does with its integrations

Share one cache across the integrations it exports and imports, the way builder,
automation and dashboard already do, so a type that serializes a file writes it
once. Count them in the import progress, which reported 100% before they were
done.

Keep `supports_integration_type` out of the middle of the class attributes and
read the accepted types once per call instead of scanning the registry inside a
generator. Not cached across calls: a test can register an action type.

Drop `_read_response_within_limit`, which had become a one-line pass-through to
the util the module already imports.

* fix: do not let a delayed integrations fetch undo a change made while it ran

Only a create or a delete bumped the generation the fetch reads, so an edit or a
reorder landing mid-request was overwritten by an answer written before it. For
a bot's token that reads as a missing credential on a bot that has one.

The fetch also restored the counter to what it found after writing its answer,
which dropped a bump a create had committed in the meantime and let a second
fetch write a list without the new bot. It commits the rows directly instead:
its own writes were never a change to back off from.

* fix: say when a Slack action points at a bot that is not there

An empty list read as healthy, so a bot deleted since, or one named by an import
made elsewhere, left the action looking configured until the click failed. It
now waits for the list to have been fetched rather than for it to be non-empty,
and reports a bot it cannot find.

A fetch that failed stays quiet: the list is unknown then, not empty, and the
failure already raises its own message.

* fix: offer to edit an integration only where there is nowhere else to

The edit button went into the shared dropdown, so it appeared in the builder
data source and user source forms, automation, dashboard, the AI agent form and
the SMTP form. All of those have an integration settings page; a database does
not, which is the reason the button exists.

It is behind a prop now, and the Slack form passes it only for a database.

* fix: match the slow Slack stub on the body the request now sends

Moving the payload out of the query string left this stub matching on a
`channel` query parameter that is no longer there, so it never matched and the
catch-all answered at once. The concurrent-click test lost the delay its lock
assertion depends on, and would have passed without ever holding a lock.

* fix: ask again for an integrations list that changed, rather than dropping it

Bumping the generation on an edit or a reorder made the back-off common, and
only the button field caller reads the null it returns. The builder awaits this
inside `loadExtraData` and then marks itself loaded either way, so renaming an
integration while that fetch was open left every data source and user source
dropdown empty until a reload.

It asks again instead, up to three times, and answers null only when the list
will not settle. The tests give the retry the answer a server would have by
then.

* fix: do not call a bot missing when it may only be hidden

`get_integrations` filters the list by what the caller may list, so a bot absent
from it is either deleted or invisible to this user and there is no telling
which. Someone with no list access to a colleague's bot was told a working
action was broken, and following the message would have overwritten it.

* refactor: read the accepted integration types without building a set

One membership test does not need a frozenset of every type: the generator it
replaced short-circuited and allocated nothing. Not keeping the answer was the
right call; building the set was not.

Also `or []` for the imported integrations, since a hand-edited export can name
the key with an explicit null, and two test names and a docstring that still
described the behaviour before this branch changed it.

* test: open the Slack answer's data node before reading its fields

The schema describes the wrapper the dispatch actually writes, so `ok`,
`Channel` and `Message timestamp` sit one level in. The test still expected
them beside the action, and had been failing since the schema was corrected.
Opening the node is what a user does to reach them.

* fix: mount the Slack stub from the directory the recipe actually runs in

`just --justfile e2e-tests/justfile` runs recipes from that file's own
directory, so `$(pwd)/e2e-tests/stubs/slack` pointed a level too deep. Docker
created the missing path and mounted it empty, WireMock started with no
mappings, and every Slack call answered 404. CI was unaffected: it mounts the
stub by workspace path.

* docs: say why the application type is compared as a literal here

`integrations` must not import from `database`, and the sibling forms compare
`application.type === 'automation'` the same way.

* Revert "fix: mount the Slack stub from the directory the recipe actually runs in"

This reverts commit 643efa8781.

* fix: look up an imported bot only in the database the action lands in

An unmapped id is the normal case for a duplicated field or table, and an
export written before 4c carries no mapping at all. The fallback looked that id
up across the whole installation, so it could match another workspace's bot and
write the FK; only a later check nulled it, and anything reading the service in
between saw it.

The field the action is being imported into now reaches the lookup through the
import cache, which the base class already threads down, and the query is
scoped to its database.

* fix: filter the Slack schema by the name a caller can actually send

`allowed_fields` holds first-level names, and `extract_properties` reads them
off `path[0]`. Since the answer moved under `data`, that is the only name any
path into it produces, so filtering the names inside the wrapper matched
nothing and answered an empty schema.

* refactor: resolve a click's specific services once

`_resolve_integrations` and `_lock_ttl_for` each rebuilt the same list, and
only `specific` being a cached property kept that free — a fact neither call
site stated. The dispatch resolves them once and hands both the list.

* fix: skip an integration the import refused, rather than list a None

`import_integration` can now answer None, and builder and automation appended
it straight into a list typed as integrations. Only the database narrows what
it accepts today, but this branch is what makes narrowing possible, so the two
loops have to allow for it rather than rely on nobody using it.

* fix: do not mark an application loaded when its integrations fetch gave up

The fetch answers null when the list kept changing under it, having written
nothing. Builder and automation awaited it and marked themselves loaded either
way, so a rename or a reorder landing during page load left every integration
dropdown empty for the session with no error and no refetch.

* refactor: declare the dropdown's model value instead of reading $attrs

It read the selection out of `$attrs.modelValue` while binding an always-null
`value` to the dropdown below, so what showed depended on the same attribute
also falling through. Both now come from one declared prop.

* fix: follow the application object when the store replaces it

`forceSetAll` builds new application objects and `populate` gives them an empty
integration list, while the editor kept the object it was handed. It read a
list that no longer reflected the store, so a token pasted in elsewhere never
showed and the dropdown could not be refilled. The list reads the object the
store holds now, and asks again when it is replaced.

* Revert "fix: skip an integration the import refused, rather than list a None"

Builder, automation and dashboard all inherit the base
`supports_integration_type`, which answers True for every type, so
`import_integration` cannot hand them a None. The guard was unreachable and
untestable, and reading it suggests a None is expected there.

The docstring keeps the contract, so a type that starts narrowing what it
accepts knows to look at its own call site.
2026-09-07 11:18:39 +02:00