Files
PaperClipAI/doc
DottaandPaperclip 00d944f96c fix(chat-channels): resume follow-ups after Slack Stop (#15737)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Chat channels let verified users stop an agent and send another
message from Slack.
> - Native execution needs the stopping user's identity to recognize a
deliberate Stop.
> - Slack omitted that identity, so a stopped run could create a
recovery hold.
> - A pending AI login request for another user could then block the new
message.
> - This pull request records the verified stop actor and scopes AI
login waits to the current user.
> - Users can start a fresh turn after a verified Stop while access and
approval gates remain in force.

## Linked Issues or Issue Description

**What happened?**

A user stops a native run from its bound Slack thread. Slack confirms
the Stop. The user sends a follow-up and receives a queued
acknowledgement, but execution does not start. The run can acquire a
recovery hold. A pending AI login request addressed to another user then
blocks explicit continuation.

**Expected behavior**

An acknowledged operator Stop ends the current response. A new
authorized user message starts through normal admission after the
previous execution has stopped. An AI login request for another user
stays pending but does not gate this user's turn. Tool access,
approvals, unknown identities, and unconfirmed cleanup still block
execution.

**Steps to reproduce**

1. Start a native agent run in a Slack thread with a pending AI login
request addressed to a different user.
2. Stop the run with the signed Slack Stop action.
3. Send a new message from a verified linked user.
4. Observe the recovery hold and the pending-decision message on the
saved follow-up.

Refs: #15421 for the related verified linked-user authority path. That
change separates guest and trusted tasks; this change handles
cancellation and login wait scope.

## What Changed

- Pass the verified Slack user's identity to canonical run cancellation.
- Scope AI login waits by the current run's responsible user, with a
company-scoped lookup.
- Use the same wait predicate for explicit continuation, native
execution, and recovery decisions.
- Admit already-saved native follow-ups posted after Stop through the
existing continuation checks. Keep pre-stop and delivered messages held.
- Keep pending cards and their authorization state intact.
- Add regression tests for signed Slack Stop, fresh-turn admission, and
same-user, unknown-user, tool-access, and company-boundary gates.
- Give the two affected database setup hooks the standard 90-second
budget.
- Document Slack Stop and user-scoped AI login waits.

## Verification

- Red: signed Slack Stop omitted the cancelling user; direct
continuation and already-saved post-Stop continuation both returned
`null`.
- Green: 57 continuation/audience checks passed, including legacy
operator Stops, pre-stop input, delivered input, same-user login,
unknown identity, company boundaries, cleanup, ownership, pauses, and
approvals.
- The combined signed Slack Stop and original gate check passed: 39
tests.
- Existing native question/completion suite: 33 tests passed.
- `pnpm -r typecheck` passed.
- `pnpm build` passed.
- Rebased regression check: 18 tests passed on current master. The
reviewed database-support setup change passed all 7 audience checks.
- Full latest-head CI passed, including all server, chat, package,
serialized-server, Runner, browser, build, and canary gates.
- The duplicate local `pnpm test:run` was stopped after the full CI
matrix passed. It was slow on the contended host; no failure had been
reported. The focused reproduction command is:

```sh
pnpm exec vitest run server/src/services/issue-question-context.test.ts server/src/services/explicit-native-continuation.test.ts server/src/__tests__/chat-channels.integration.test.ts --fsModuleCache --testTimeout 60000 -t 'AI connection wait audience|scopes connection waits|resumes an already-saved follow-up|durably retries a signed Slack session stop'
```
- Manual evidence: inspected the bound thread's cancelled run, queued
messages, recovery hold, and login card. The staging deployment has not
been changed.

## Risks

- AI login wait behavior changes only when both the addressee and
current responsible user are known and differ. Missing identity retains
the gate.
- Starting a new turn does not grant access or answer the old card.
Credential selection still uses the new run's authority.
- Process, remote cleanup, recovery, task ownership, pause, budget, and
approval checks remain in place.
- No schema migration or public API change.

## Model Used

OpenAI GPT-6 through Codex, with reasoning, repository inspection,
browser inspection, and code execution. The exact runtime model ID and
context window are not exposed in this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-09 16:47:21 -05:00
..
…
…
…
…
…