From a484eb7bf85053edeed569850509828e8ee5d69f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 16:02:36 -0800 Subject: [PATCH 1/6] build(deps): bump novita-sandbox from 1.0.3-b2 to 2.1.5 in /scripts/typecheck-sandbox-providers (#22599) Bumps [novita-sandbox](https://novita.ai/sandbox) from 1.0.3-b2 to 2.1.5. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../sandbox-providers/novita/package.json | 2 +- .../pnpm-lock.yaml | 131 ++++++++++++++---- 2 files changed, 102 insertions(+), 31 deletions(-) diff --git a/packages/plugins/sandbox-providers/novita/package.json b/packages/plugins/sandbox-providers/novita/package.json index 42ffb4991d5..d144a7659b8 100644 --- a/packages/plugins/sandbox-providers/novita/package.json +++ b/packages/plugins/sandbox-providers/novita/package.json @@ -51,7 +51,7 @@ "postpack": "if [ -f package.dev.json ]; then mv package.dev.json package.json; fi" }, "dependencies": { - "novita-sandbox": "^1.0.3-b2" + "novita-sandbox": "^2.1.5" }, "devDependencies": { "@types/node": "^24.0.0", diff --git a/scripts/typecheck-sandbox-providers/pnpm-lock.yaml b/scripts/typecheck-sandbox-providers/pnpm-lock.yaml index 748530e8ade..df7f16ad973 100644 --- a/scripts/typecheck-sandbox-providers/pnpm-lock.yaml +++ b/scripts/typecheck-sandbox-providers/pnpm-lock.yaml @@ -137,8 +137,8 @@ importers: ../../packages/plugins/sandbox-providers/novita: dependencies: novita-sandbox: - specifier: ^1.0.3-b2 - version: 1.0.3-b2 + specifier: ^2.1.5 + version: 2.1.5 devDependencies: '@types/node': specifier: ^24.0.0 @@ -156,9 +156,6 @@ packages: resolution: {integrity: sha512-aUhnhF3nN/0iqP82hclSLH0YWbG6A4vB7iBWR94lMaQfQkMHjT0YX+RYcNY8QAO3y9iZniYDJCC3+zqQLgGcrA==} engines: {node: '>=20'} - '@bufbuild/protobuf@2.16.0': - resolution: {integrity: sha512-FWa0sPlqYGJgpTs6OxBRcL/AW4JT0OIO+W1ajerluoTVh8CV0B7XM1qsNCRgnkSCkRCgOICKHRQlY17jrsm0+Q==} - '@bufbuild/protobuf@2.17.0': resolution: {integrity: sha512-hcPkSz6D7MiTU/5VBBhK+kxaYDoOdQ6yJRFJ3kS8Nydp+VZXfg1vrpABKPNod8bXMufsVCmiUJVIKFzCzta4uw==} @@ -1075,6 +1072,10 @@ packages: resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==} engines: {node: 20 || >=22} + brace-expansion@5.1.2: + resolution: {integrity: sha512-ELhY3JEerIBbhgW+rh0/8glkZAaMqn1x3BAvp3yTULSEGozMK/5PT6WTdBgsdvJqwwmv7MAQNOydfYbvK1Vgfw==} + engines: {node: 20 || >=22} + call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -1147,6 +1148,9 @@ packages: devtools-protocol@0.0.1182435: resolution: {integrity: sha512-EmlkWb62wSbQNE1gRZZsi4KZYRaF5Skpp183LhRU7+sadKR06O1dHCjZmFSEG6Kv7P6S/UYLxcY3NlYwqKM99w==} + dockerfile-ast@0.7.1: + resolution: {integrity: sha512-oX/A4I0EhSkGqrFv0YuvPkBUSYp1XiY8O8zAKc8Djglx8ocz+JfOr8gP0ryRMC2myqvDLagmnZaU9ot1vG2ijw==} + dotenv@16.3.1: resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} engines: {node: '>=12'} @@ -1257,6 +1261,10 @@ packages: resolution: {integrity: sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==} engines: {node: 18 || 20 || >=22} + glob@14.0.7: + resolution: {integrity: sha512-ob8P0VbyEjcLG2ycNYmzYhZj65kkcN5b7tt5moGhTq3rkXtuU8MB+i0GIzPtLnSHVF2DkK4M+nQRojDvsOGVJw==} + engines: {node: 18 || 20 || >=22} + gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -1323,6 +1331,10 @@ packages: resolution: {integrity: sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==} engines: {node: 20 || >=22} + lru-cache@11.5.4: + resolution: {integrity: sha512-B8nJCTi8JuSaDBg0tBdnImV6j5O2CXaqKfdj24ZTCFbyivN8KZ2Z+RL3aHjwJAfLutD9cNnObG4SIgW4gMufiw==} + engines: {node: 20 || >=22} + magic-string@1.4.5: resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==} @@ -1347,6 +1359,10 @@ packages: kerberos: optional: true + minimatch@11.0.10: + resolution: {integrity: sha512-L3/cjhQ5E6lft0VCp/2mO3Ic74RnutKy3rz7iGwp/6w1hKcO262g2rbfacFyw6eBig5OdI0nu5PpuA0/WQs9Tw==} + engines: {node: 20 || >=22} + minimatch@11.0.9: resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==} engines: {node: 20 || >=22} @@ -1394,9 +1410,9 @@ packages: resolution: {integrity: sha512-+P72GAjVAbTxjjwUmwjVrqrdZROD4nf8KgpBoDxqXXTiYZZt/ud60dE5yvCSr9lRO8e8yv6kgJIC0K0PfZFVQw==} hasBin: true - novita-sandbox@1.0.3-b2: - resolution: {integrity: sha512-W0TbVfacreckxdbw1Tbh9dPYVZKjr4e0qRnMj/oxNj+gw01CRKA5Nf8uwSPaMI5daRazyo+ZVnV7WZchKhHbNQ==} - engines: {node: '>=16.0.0'} + novita-sandbox@2.1.5: + resolution: {integrity: sha512-CMDW+NqbrjoN/db+qr4ZGQ1UlwCMTm3To9ITFTVk/j6/lmivfvm3l6RVWwP24FlDwoX5f/LEWje/v5lusII1qg==} + engines: {node: '>=20'} oauth4webapi@3.8.8: resolution: {integrity: sha512-8N28E+a/oxfXWBgOMt+ZP/JUf/XR+IFbvkAEPP3gznXOMv9BpAAwiIj0TFNz3tGTPc0ZQ8zmWBNgN1nAys0gng==} @@ -1408,14 +1424,14 @@ packages: once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + openapi-fetch@0.14.1: + resolution: {integrity: sha512-l7RarRHxlEZYjMLd/PR0slfMVse2/vvIAGm75/F7J6MlQ8/b9uUQmUF2kCPrQhJqMXSxmYWObVgeYXbFYzZR+A==} + openapi-fetch@0.17.0: resolution: {integrity: sha512-PsbZR1wAPcG91eEthKhN+Zn92FMHxv+/faECIwjXdxfTODGSGegYv0sc1Olz+HYPvKOuoXfp+0pA2XVt2cI0Ig==} - openapi-fetch@0.9.8: - resolution: {integrity: sha512-zM6elH0EZStD/gSiNlcPrzXcVQ/pZo3BDvC6CDwRDUt1dDzxlshpmQnpD6cZaJ39THaSmwVCxxRrPKNM1hHrDg==} - - openapi-typescript-helpers@0.0.8: - resolution: {integrity: sha512-1eNjQtbfNi5Z/kFhagDIaIRj6qqDzhjNJKz8cmMW0CVdGwT6e1GLbAfgI0d28VTJa1A8jz82jm/4dG8qNoNS8g==} + openapi-typescript-helpers@0.0.15: + resolution: {integrity: sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==} openapi-typescript-helpers@0.1.0: resolution: {integrity: sha512-OKTGPthhivLw/fHz6c3OPtg72vi86qaMlqbJuVJ23qOvQ+53uw1n7HdmkJFibloF7QEjDrDkzJiOJuockM/ljw==} @@ -1427,6 +1443,10 @@ packages: resolution: {integrity: sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==} engines: {node: 18 || 20 || >=22} + path-scurry@3.0.3: + resolution: {integrity: sha512-Ie3c3F+7WJOUCr0r8V8uEunY5Sj4PGFDoBZvFw7JmHJs/+H5GZK+GsIM8tHMcZy7c27Zj+U1NOcVzqlC7tBJpg==} + engines: {node: 18 || 20 || >=22} + path-to-regexp@6.3.0: resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} @@ -1532,6 +1552,10 @@ packages: resolution: {integrity: sha512-lkukzdoGngZHJZXxW4S/E4Fp9ghTDlyZXrQGRNoJ/LXvDKcXUTq2sg5yQe74po7Voea6n/IN09+wE/QvJMiifA==} engines: {node: '>=18'} + tar@7.5.24: + resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==} + engines: {node: '>=18'} + teex@1.0.1: resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==} @@ -1666,6 +1690,12 @@ packages: jsdom: optional: true + vscode-languageserver-textdocument@1.0.16: + resolution: {integrity: sha512-qeNEuOi9a3qkqRf7Gfez2WL2VwlBTLCNekHBGO9kxPVUp9XuY15yfTJ9jwvOwKI0I2MhUUfZq95NSp+LK1CLQg==} + + vscode-languageserver-types@3.18.6: + resolution: {integrity: sha512-DEDtik4YupS+nOg4JxqJ2H5ec/m4tTD9a5mGcBVGYkQKZQo1AIF3ZToiP8+A0kUzyhyqX5dMnPDEnhtmzts7GA==} + web-streams-polyfill@4.0.0-beta.3: resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==} engines: {node: '>= 14'} @@ -1764,8 +1794,6 @@ snapshots: '@bufbuild/protobuf': 2.17.0 '@grpc/grpc-js': 1.14.7 - '@bufbuild/protobuf@2.16.0': {} - '@bufbuild/protobuf@2.17.0': {} '@cbor-extract/cbor-extract-darwin-arm64@2.2.3': @@ -1827,19 +1855,19 @@ snapshots: optionalDependencies: vitest: 5.1.2(@opentelemetry/api@1.10.0)(@types/node@24.19.2)(vite@7.3.7(@types/node@24.19.2)(yaml@2.9.1)) - '@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.16.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0))': + '@connectrpc/connect-web@2.0.0-rc.3(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0))': dependencies: - '@bufbuild/protobuf': 2.16.0 - '@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0) + '@bufbuild/protobuf': 2.17.0 + '@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0) '@connectrpc/connect-web@2.3.0(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.3.0(@bufbuild/protobuf@2.17.0))': dependencies: '@bufbuild/protobuf': 2.17.0 '@connectrpc/connect': 2.3.0(@bufbuild/protobuf@2.17.0) - '@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0)': + '@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0)': dependencies: - '@bufbuild/protobuf': 2.16.0 + '@bufbuild/protobuf': 2.17.0 '@connectrpc/connect@2.3.0(@bufbuild/protobuf@2.17.0)': dependencies: @@ -2394,6 +2422,10 @@ snapshots: dependencies: balanced-match: 4.0.4 + brace-expansion@5.1.2: + dependencies: + balanced-match: 4.0.4 + call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -2465,6 +2497,11 @@ snapshots: devtools-protocol@0.0.1182435: {} + dockerfile-ast@0.7.1: + dependencies: + vscode-languageserver-textdocument: 1.0.16 + vscode-languageserver-types: 3.18.6 + dotenv@16.3.1: {} dunder-proto@1.0.1: @@ -2609,6 +2646,12 @@ snapshots: minipass: 7.1.3 path-scurry: 3.0.0 + glob@14.0.7: + dependencies: + minimatch: 11.0.10 + minipass: 7.1.3 + path-scurry: 3.0.3 + gopd@1.2.0: {} has-symbols@1.1.0: {} @@ -2657,6 +2700,8 @@ snapshots: lru-cache@11.5.3: {} + lru-cache@11.5.4: {} + magic-string@1.4.5: dependencies: '@jridgewell/sourcemap-codec': 1.6.0 @@ -2682,6 +2727,11 @@ snapshots: - bufferutil - utf-8-validate + minimatch@11.0.10: + dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 + brace-expansion: 5.1.2 + minimatch@11.0.9: dependencies: '@isaacs/nonrecursive-glob-match': 1.1.0 @@ -2727,14 +2777,18 @@ snapshots: detect-libc: 2.1.2 optional: true - novita-sandbox@1.0.3-b2: + novita-sandbox@2.1.5: dependencies: - '@bufbuild/protobuf': 2.16.0 - '@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0) - '@connectrpc/connect-web': 2.0.0-rc.3(@bufbuild/protobuf@2.16.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.16.0)) + '@bufbuild/protobuf': 2.17.0 + '@connectrpc/connect': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0) + '@connectrpc/connect-web': 2.0.0-rc.3(@bufbuild/protobuf@2.17.0)(@connectrpc/connect@2.0.0-rc.3(@bufbuild/protobuf@2.17.0)) + chalk: 5.6.2 compare-versions: 6.1.1 - openapi-fetch: 0.9.8 + dockerfile-ast: 0.7.1 + glob: 14.0.7 + openapi-fetch: 0.14.1 platform: 1.3.6 + tar: 7.5.24 oauth4webapi@3.8.8: {} @@ -2744,15 +2798,15 @@ snapshots: dependencies: wrappy: 1.0.2 + openapi-fetch@0.14.1: + dependencies: + openapi-typescript-helpers: 0.0.15 + openapi-fetch@0.17.0: dependencies: openapi-typescript-helpers: 0.1.0 - openapi-fetch@0.9.8: - dependencies: - openapi-typescript-helpers: 0.0.8 - - openapi-typescript-helpers@0.0.8: {} + openapi-typescript-helpers@0.0.15: {} openapi-typescript-helpers@0.1.0: {} @@ -2766,6 +2820,11 @@ snapshots: lru-cache: 11.5.3 minipass: 7.1.3 + path-scurry@3.0.3: + dependencies: + lru-cache: 11.5.4 + minipass: 7.1.3 + path-to-regexp@6.3.0: {} pathe@2.0.3: {} @@ -2947,6 +3006,14 @@ snapshots: minizlib: 3.1.0 yallist: 5.0.0 + tar@7.5.24: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.3 + minizlib: 3.1.0 + yallist: 5.0.0 + teex@1.0.1: dependencies: streamx: 2.28.1 @@ -3048,6 +3115,10 @@ snapshots: transitivePeerDependencies: - msw + vscode-languageserver-textdocument@1.0.16: {} + + vscode-languageserver-types@3.18.6: {} + web-streams-polyfill@4.0.0-beta.3: {} webidl-conversions@3.0.1: {} From bbb226dcbea34a7f6e60d9460f2075f639a8e44b Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Fri, 4 Dec 2026 18:07:05 -0600 Subject: [PATCH 2/6] fix(ui): hide mobile task composer and bottom nav while reading back (#23693) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The task page shows a chat thread with a pinned composer and a bottom navigation bar on mobile > - On a phone, these two bars use a large part of the screen when you read earlier messages > - The old task page hid the bottom navigation when you scrolled. The new chat thread scrolls inside its own container, so that behavior stopped > - This pull request makes the thread scroller drive the auto-hide mobile chrome again, and it also hides the composer > - The benefit is more reading space when you read back through a task, with the standard mobile scroll-to-dismiss behavior ## Linked Issues or Issue Description **Is your feature request related to a problem?** On mobile, the task chat page keeps the composer and the bottom navigation on screen at all times. When you scroll up to read earlier messages, these bars cover a large part of the screen. **Describe the solution you'd like** When you scroll the thread away from the latest message, the composer and the bottom navigation slide out of view. When you scroll back toward the latest message, or reach it, they slide back. When the keyboard is open, the composer stays on screen. **Describe alternatives you've considered** Hide only the bottom navigation. This gives less reading space and does not match common mobile chat apps. ## What Changed - `useMobileNavVisibility` also tracks nested scroll containers that have `data-mobile-chrome-scroll="bottom"`. It measures distance from the bottom of the thread, so the resting zone is the latest message. It ignores the viewport growth that occurs when the composer collapses, so the bars do not flicker. An open keyboard keeps the chrome visible. - `TaskMessageScroller` sets the marker attribute on the thread scroller. - `Layout` and `Layout.production` publish `data-mobile-nav` on `#main-content`. - `index.css` slides the composer dock out with a negative bottom margin and removes the bottom padding while the chrome is hidden. The motion uses the existing mobile nav motion tokens. Reduced motion makes the change instant. - `TaskChatComposerDock` measures its height on mobile as well as in the coordinator layout. The wheel forwarding stays coordinator-only. - New unit tests: `ui/src/hooks/useMobileNavVisibility.test.tsx`. - New Storybook stories: `Tasks and conversations/Task creation and lifecycle/Task chat/Mobile chrome auto-hide` (interactive, reading back, heading back), with play assertions. ## Verification - `npx vitest run ui/src/hooks/useMobileNavVisibility.test.tsx ui/src/lib/mobile-nav-scroll` passes (11 tests). - `npx vitest run ui/src/components/Layout.mobile.test.tsx ui/src/components/TaskChatThread.test.tsx ui/src/hooks/useMobileVisualViewport.test.tsx` passes (446 tests). - I ran the three stories in Storybook at 390×844. Reading back gives `data-mobile-nav="hidden"`, the nav has `data-visible="false"`, and the dock is hidden. Heading back restores all three. - Manual: open a long task on a phone, scroll up, and confirm both bars slide away. Then scroll down and confirm they return. ## Risks - Low risk. The change applies only on mobile when a task chat shell is present. Desktop and the coordinator layout keep their current behavior. - Physical iPhone touch acceptance is still needed. Momentum scroll and rubber-band behavior can differ from the browser test. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- DESIGN.md | 8 + ui/src/components/Layout.production.tsx | 1 + ui/src/components/Layout.tsx | 1 + .../task-chat/TaskChatComposerDock.tsx | 10 +- .../task-chat/TaskMessageScroller.tsx | 3 + ui/src/hooks/useMobileNavVisibility.test.tsx | 217 ++++++++++++++++++ ui/src/hooks/useMobileNavVisibility.ts | 128 +++++++++-- ui/src/index.css | 31 +++ ...sk-chat-mobile-chrome-autohide.stories.tsx | 158 +++++++++++++ 9 files changed, 535 insertions(+), 22 deletions(-) create mode 100644 ui/src/hooks/useMobileNavVisibility.test.tsx create mode 100644 ui/storybook/stories/tasks/task-chat-mobile-chrome-autohide.stories.tsx diff --git a/DESIGN.md b/DESIGN.md index 265e8f2d96b..275b9a25686 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -75,6 +75,14 @@ Mobile task conversations size their shell to the visible viewport, with one message scroller and a normal flex footer for the composer. Navigation stays at the layout viewport bottom, behind the keyboard. +A task conversation is the one exception to stable page padding. Its message +scroller drives the navigation, measured from the latest message. Reading back +through the thread slides the composer and the navigation away together, and +the thread takes the freed height. The chrome hides only after the reader is +farther back than that freed height, so hiding never snaps the thread to the +latest message. Moving back toward the latest message, or reaching it, brings +both back. An open keyboard always keeps the composer on screen. + Cold task opens reveal the instruction and recent conversation independently of recovery, related metadata, and historical run activity. Saved document cards, the saved plan, and the bounded latest turn arrive before first reveal so they diff --git a/ui/src/components/Layout.production.tsx b/ui/src/components/Layout.production.tsx index 070f9b94a46..88d8f9fec33 100644 --- a/ui/src/components/Layout.production.tsx +++ b/ui/src/components/Layout.production.tsx @@ -548,6 +548,7 @@ export function Layout() {
('[data-testid="task-chat-thread"]'); - if (!dock || !thread || !thread.closest(".coordinator-workspace")) return; + if (!dock || !thread) return; + const coordinator = thread.closest(".coordinator-workspace") !== null; + // Coordinator overlays the dock on the thread; mobile collapses it while + // the auto-hiding chrome is tucked away. Both need its measured height. + if (!coordinator && !mobile) return; const forwardGapWheel = (event: WheelEvent) => { if (event.target !== dock || event.ctrlKey || event.defaultPrevented) return; const scroller = thread.querySelector('[data-testid="task-chat-scroller"]'); @@ -35,7 +39,7 @@ export function TaskChatComposerDock({ children, mobile, streamlined, concealed : deltaMode === WheelEvent.DOM_DELTA_PAGE ? scroller.clientWidth : 1; scroller.scrollBy({ left: deltaX * horizontalUnit, top: deltaY * verticalUnit, behavior: "instant" }); }; - dock.addEventListener("wheel", forwardGapWheel, { passive: false }); + if (coordinator) dock.addEventListener("wheel", forwardGapWheel, { passive: false }); const measure = () => thread.style.setProperty("--task-composer-dock-height", `${dock.getBoundingClientRect().height}px`); measure(); const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure); @@ -45,7 +49,7 @@ export function TaskChatComposerDock({ children, mobile, streamlined, concealed observer?.disconnect(); thread.style.removeProperty("--task-composer-dock-height"); }; - }, [placeholder]); + }, [placeholder, mobile]); return
{scrollingHistory ? <> {scrollingHistory && (scrollingHistory.hasMore || scrollingHistory.loading || scrollingHistory.error) ? ( diff --git a/ui/src/hooks/useMobileNavVisibility.test.tsx b/ui/src/hooks/useMobileNavVisibility.test.tsx new file mode 100644 index 00000000000..fe82c2919b9 --- /dev/null +++ b/ui/src/hooks/useMobileNavVisibility.test.tsx @@ -0,0 +1,217 @@ +// @vitest-environment jsdom +import { act } from "react"; +import { createRoot, type Root } from "react-dom/client"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { useMobileNavVisibility } from "./useMobileNavVisibility"; + +let visible: boolean | null = null; +function Host({ enabled = true }: { enabled?: boolean }) { + visible = useMobileNavVisibility(enabled, "/PAP/issues/PAP-1"); + return null; +} + +// The composer dock (50px) plus the nav offset padding (100px): how much the +// thread viewport grows at its bottom edge when the chrome tucks away. +const DOCK_HEIGHT = 50; +const NAV_PADDING = 100; +const VISIBLE_HEIGHT = 500; +const HIDDEN_HEIGHT = VISIBLE_HEIGHT + DOCK_HEIGHT + NAV_PADDING; + +let root: Root; +let container: HTMLDivElement; +let frames: FrameRequestCallback[] = []; +let main: HTMLElement; +let thread: HTMLDivElement; +let geometry: { scrollHeight: number; clientHeight: number }; +let rawScrollTop = 0; + +function flushFrames() { + const pending = frames; + frames = []; + act(() => pending.forEach((callback) => callback(0))); +} + +const maxScrollTop = () => Math.max(0, geometry.scrollHeight - geometry.clientHeight); +const fromBottom = () => maxScrollTop() - thread.scrollTop; + +function emitScroll() { + thread.dispatchEvent(new Event("scroll")); + flushFrames(); +} + +/** Scroll the thread to `distance` CSS pixels above its latest message. */ +function scrollThread(distance: number) { + thread.scrollTop = maxScrollTop() - distance; + emitScroll(); +} + +/** + * Apply the layout for the current chrome state, as the CSS does: hiding grows + * the thread viewport at its bottom edge, and the browser clamps `scrollTop` + * to the new maximum. + */ +function settleChrome() { + geometry.clientHeight = visible ? VISIBLE_HEIGHT : HIDDEN_HEIGHT; + main.style.paddingBottom = visible ? `${NAV_PADDING}px` : "0px"; + thread.scrollTop = rawScrollTop; + emitScroll(); +} + +beforeEach(() => { + vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); + vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => frames.push(callback)); + vi.stubGlobal("cancelAnimationFrame", () => {}); + const tokens = document.documentElement.style; + tokens.setProperty("--mobile-nav-scroll-top-zone", "24px"); + tokens.setProperty("--mobile-nav-scroll-hide-distance", "32px"); + tokens.setProperty("--mobile-nav-scroll-show-distance", "16px"); + + geometry = { scrollHeight: 4000, clientHeight: VISIBLE_HEIGHT }; + rawScrollTop = 0; + main = document.createElement("main"); + main.id = "main-content"; + main.style.paddingBottom = `${NAV_PADDING}px`; + const shell = document.createElement("div"); + shell.dataset.testid = "task-chat-thread"; + thread = document.createElement("div"); + thread.setAttribute("data-mobile-chrome-scroll", "bottom"); + Object.defineProperty(thread, "scrollHeight", { configurable: true, get: () => geometry.scrollHeight }); + // Browsers clamp scrollTop to the live scroll range. + Object.defineProperty(thread, "scrollTop", { + configurable: true, + get: () => Math.max(0, Math.min(rawScrollTop, maxScrollTop())), + set: (value: number) => { rawScrollTop = Math.max(0, Math.min(value, maxScrollTop())); }, + }); + Object.defineProperty(thread, "clientHeight", { configurable: true, get: () => geometry.clientHeight }); + const dock = document.createElement("div"); + dock.dataset.testid = "task-chat-composer-dock"; + dock.getBoundingClientRect = () => ({ height: DOCK_HEIGHT } as DOMRect); + shell.append(thread, dock); + main.append(shell); + document.body.append(main); + + container = document.createElement("div"); + document.body.append(container); + root = createRoot(container); +}); + +afterEach(() => { + act(() => root.unmount()); + container.remove(); + main.remove(); + document.documentElement.removeAttribute("style"); + document.body.querySelectorAll(".paperclip-app-shell").forEach((node) => node.remove()); + frames = []; + visible = null; + vi.unstubAllGlobals(); +}); + +describe("useMobileNavVisibility with a bottom-anchored task thread", () => { + it("tucks the chrome away when reading back from the latest message and restores it heading back", () => { + act(() => root.render()); + scrollThread(0); + expect(visible).toBe(true); + + // Reading within the space the chrome would free never hides it, so the + // thread can never be clamped to the latest message by hiding. + scrollThread(100); + scrollThread(170); + scrollThread(200); + expect(visible).toBe(true); + scrollThread(210); + expect(visible).toBe(false); + settleChrome(); + expect(visible).toBe(false); + expect(fromBottom()).toBe(60); + + // Keep reading older messages: the chrome stays out of the way. + scrollThread(600); + expect(visible).toBe(false); + + // A deliberate drag back toward the latest message reveals it. + scrollThread(590); + expect(visible).toBe(false); + scrollThread(580); + expect(visible).toBe(true); + + // The viewport shrinking back is not a swipe away from the latest message. + settleChrome(); + expect(visible).toBe(true); + }); + + it("returns the chrome when the reader reaches the latest message", () => { + act(() => root.render()); + scrollThread(0); + scrollThread(400); + expect(visible).toBe(false); + settleChrome(); + scrollThread(300); + scrollThread(320); + scrollThread(0); + expect(visible).toBe(true); + }); + + it("never strands the chrome hidden at the latest message after a short drag", () => { + act(() => root.render()); + scrollThread(0); + // A short drag up stays inside the space the chrome would free. + scrollThread(40); + scrollThread(120); + expect(visible).toBe(true); + + // Just past that space the chrome hides; the larger viewport keeps the + // reading position, and dragging to the latest message brings it back. + scrollThread(190); + expect(visible).toBe(true); + scrollThread(210); + expect(visible).toBe(false); + settleChrome(); + expect(visible).toBe(false); + expect(fromBottom()).toBeGreaterThan(0); + scrollThread(0); + expect(visible).toBe(true); + }); + + it("keeps the composer on screen while the keyboard is open", () => { + const shell = document.createElement("div"); + shell.className = "paperclip-app-shell"; + shell.dataset.keyboardOpen = "true"; + document.body.append(shell); + act(() => root.render()); + scrollThread(0); + scrollThread(400); + expect(visible).toBe(true); + }); + + it("shows the chrome when the keyboard opens and keeps it after the keyboard closes", async () => { + const shell = document.createElement("div"); + shell.className = "paperclip-app-shell"; + document.body.append(shell); + act(() => root.render()); + scrollThread(0); + scrollThread(400); + expect(visible).toBe(false); + settleChrome(); + + await act(async () => { shell.dataset.keyboardOpen = "true"; }); + expect(visible).toBe(true); + await act(async () => { delete shell.dataset.keyboardOpen; }); + settleChrome(); + scrollThread(fromBottom() + 10); + expect(visible).toBe(true); + }); + + it("ignores threads that did not opt in and stays visible on desktop", () => { + thread.removeAttribute("data-mobile-chrome-scroll"); + act(() => root.render()); + scrollThread(0); + scrollThread(400); + expect(visible).toBe(true); + + thread.setAttribute("data-mobile-chrome-scroll", "bottom"); + act(() => root.render()); + scrollThread(0); + scrollThread(400); + expect(visible).toBe(true); + }); +}); diff --git a/ui/src/hooks/useMobileNavVisibility.ts b/ui/src/hooks/useMobileNavVisibility.ts index c3c68de1463..8a1b1cf3cfc 100644 --- a/ui/src/hooks/useMobileNavVisibility.ts +++ b/ui/src/hooks/useMobileNavVisibility.ts @@ -1,6 +1,21 @@ import { useEffect, useState } from "react"; import { MobileNavScrollTracker } from "../lib/mobile-nav-scroll"; +/** + * Opt-in marker for a nested scroll container that should drive the + * auto-hiding mobile chrome (bottom nav and pinned composer). The value is the + * container's resting edge: `"bottom"` for a chat thread that rests at its + * latest message, so moving away from the bottom hides the chrome and moving + * back toward it reveals the chrome again. + */ +export const MOBILE_CHROME_SCROLL_ATTRIBUTE = "data-mobile-chrome-scroll"; + +function bottomAnchoredScroller(target: EventTarget | null): HTMLElement | null { + return target instanceof HTMLElement && target.getAttribute(MOBILE_CHROME_SCROLL_ATTRIBUTE) === "bottom" + ? target + : null; +} + export function useMobileNavVisibility(enabled: boolean, pathname: string): boolean { const [visible, setVisible] = useState(true); @@ -10,35 +25,110 @@ export function useMobileNavVisibility(enabled: boolean, pathname: string): bool const styles = getComputedStyle(document.documentElement); const distance = (token: string) => Number.parseFloat(styles.getPropertyValue(token)) || 0; - const scrollBounds = () => { + const options = { + topZone: distance("--mobile-nav-scroll-top-zone"), + hideDistance: distance("--mobile-nav-scroll-hide-distance"), + showDistance: distance("--mobile-nav-scroll-show-distance"), + }; + const documentBounds = () => { const root = document.scrollingElement ?? document.documentElement; return { top: window.scrollY || root.scrollTop || 0, max: Math.max(0, root.scrollHeight - root.clientHeight), }; }; - const initial = scrollBounds(); - const tracker = new MobileNavScrollTracker({ - topZone: distance("--mobile-nav-scroll-top-zone"), - hideDistance: distance("--mobile-nav-scroll-hide-distance"), - showDistance: distance("--mobile-nav-scroll-show-distance"), - }, initial.top, initial.max); - let frame: number | null = null; - const onScroll = () => { - if (frame !== null) return; - frame = requestAnimationFrame(() => { - frame = null; - const { top, max } = scrollBounds(); - const previous = tracker.visible; - const next = tracker.update(top, max); - if (next !== previous) setVisible(next); + let current = true; + // A bottom-anchored thread is measured from its latest message, so the + // tracker's resting zone is the bottom of the thread instead of the top. + // Tucking the chrome away grows the thread viewport at its bottom edge by + // the composer dock plus the nav offset. Measuring against that expanded + // viewport in both states keeps the reported position continuous across + // the change: nothing hides until the reader is far enough back that the + // growth cannot clamp them to the latest message, and once hidden, + // reaching the real bottom of the thread brings the chrome back. + const collapseGrowth = (scroller: HTMLElement) => { + if (!current) return 0; + const dock = scroller + .closest('[data-testid="task-chat-thread"]') + ?.querySelector('[data-testid="task-chat-composer-dock"]'); + const main = scroller.closest("#main-content"); + const dockHeight = dock?.getBoundingClientRect().height ?? 0; + const padding = main ? Number.parseFloat(getComputedStyle(main).paddingBottom) || 0 : 0; + return dockHeight + padding; + }; + const threadBounds = (scroller: HTMLElement) => { + const liveMax = Math.max(0, scroller.scrollHeight - scroller.clientHeight); + const scrollTop = Math.max(0, Math.min(scroller.scrollTop, liveMax)); + const growth = collapseGrowth(scroller); + const max = Math.max(0, liveMax - growth); + return { top: Math.max(0, liveMax - scrollTop - growth), max }; + }; + const initial = documentBounds(); + const documentTracker = new MobileNavScrollTracker(options, initial.top, initial.max); + let threadTrackers = new WeakMap(); + // Typing in the composer keeps it on screen; the keyboard resize is not a swipe. + const keyboardOpen = () => document.querySelector('.paperclip-app-shell[data-keyboard-open="true"]') !== null; + + const apply = (next: boolean) => { + if (next === current) return; + current = next; + setVisible(next); + }; + + let documentFrame: number | null = null; + const onDocumentScroll = () => { + if (documentFrame !== null) return; + documentFrame = requestAnimationFrame(() => { + documentFrame = null; + const { top, max } = documentBounds(); + apply(documentTracker.update(top, max)); }); }; - window.addEventListener("scroll", onScroll, { passive: true }); + let threadFrame: number | null = null; + let pendingThread: HTMLElement | null = null; + const onNestedScroll = (event: Event) => { + const scroller = bottomAnchoredScroller(event.target); + if (!scroller) return; + pendingThread = scroller; + if (threadFrame !== null) return; + threadFrame = requestAnimationFrame(() => { + threadFrame = null; + const target = pendingThread; + pendingThread = null; + if (!target?.isConnected) return; + const { top, max } = threadBounds(target); + let tracker = threadTrackers.get(target); + if (!tracker) { + // The first event only establishes a baseline; it is never a swipe. + tracker = new MobileNavScrollTracker(options, top, max); + threadTrackers.set(target, tracker); + return; + } + const next = tracker.update(top, max); + apply(keyboardOpen() ? true : next); + }); + }; + + // Opening the keyboard shows the chrome; re-baseline the trackers so + // closing it again does not tuck the composer away under the reader. + const keyboardObserver = typeof MutationObserver === "undefined" ? null : new MutationObserver(() => { + if (!keyboardOpen()) return; + documentTracker.visible = true; + threadTrackers = new WeakMap(); + apply(true); + }); + keyboardObserver?.observe(document.documentElement, { attributes: true, attributeFilter: ["data-keyboard-open"], subtree: true }); + + window.addEventListener("scroll", onDocumentScroll, { passive: true }); + // Element scroll events do not bubble, so observe nested threads in capture. + document.addEventListener("scroll", onNestedScroll, { passive: true, capture: true }); return () => { - window.removeEventListener("scroll", onScroll); - if (frame !== null) cancelAnimationFrame(frame); + window.removeEventListener("scroll", onDocumentScroll); + document.removeEventListener("scroll", onNestedScroll, { capture: true }); + keyboardObserver?.disconnect(); + if (documentFrame !== null) cancelAnimationFrame(documentFrame); + if (threadFrame !== null) cancelAnimationFrame(threadFrame); }; }, [enabled, pathname]); diff --git a/ui/src/index.css b/ui/src/index.css index 8d9b7f78793..197d08acc2f 100644 --- a/ui/src/index.css +++ b/ui/src/index.css @@ -1058,6 +1058,37 @@ html:has(.paperclip-app-shell[data-keyboard-open="true"] [data-classic-task-shel padding-bottom: 0; } +/* Reading away from the latest message tucks the composer away with + the auto-hiding bottom nav so the thread takes the full height; heading back + toward the latest message brings both back. The shell clips the dock as it + slides below the main column. Typing (keyboard open) never collapses it. */ +.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]):has([data-task-chat-shell]) #main-content { + transition: padding-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-enter)) var(--mobile-nav-motion-ease, var(--motion-ease-out-expo)); +} + +.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content [data-task-chat-shell] [data-testid="task-chat-composer-dock"] { + transition: + margin-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-enter)) var(--mobile-nav-motion-ease, var(--motion-ease-out-expo)), + visibility 0s; +} + +.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]):has([data-task-chat-shell]) #main-content[data-mobile-nav="hidden"] { + padding-bottom: 0; +} + +.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content[data-mobile-nav="hidden"] [data-task-chat-shell] [data-testid="task-chat-composer-dock"] { + margin-bottom: calc(-1 * var(--task-composer-dock-height, 0px)); + visibility: hidden; + pointer-events: none; + transition: + margin-bottom var(--mobile-nav-motion-duration, var(--motion-mobile-nav-exit)) var(--mobile-nav-motion-ease, var(--motion-ease-standard)), + visibility 0s linear var(--mobile-nav-motion-duration, var(--motion-mobile-nav-exit)); +} + +.paperclip-app-shell[data-mobile="true"]:not([data-keyboard-open="true"]) #main-content[data-mobile-nav="hidden"] [data-task-chat-shell] [data-testid="task-chat-scroller"] ~ button { + bottom: calc(var(--sz-safe-bottom) + var(--spacing) * 3); +} + @media (prefers-reduced-motion: reduce) { :root { --motion-mobile-nav-enter: 0ms; diff --git a/ui/storybook/stories/tasks/task-chat-mobile-chrome-autohide.stories.tsx b/ui/storybook/stories/tasks/task-chat-mobile-chrome-autohide.stories.tsx new file mode 100644 index 00000000000..223e2ef4a7f --- /dev/null +++ b/ui/storybook/stories/tasks/task-chat-mobile-chrome-autohide.stories.tsx @@ -0,0 +1,158 @@ +import type { CSSProperties } from "react"; +import type { Meta, StoryObj } from "@storybook/react-vite"; +import { expect, waitFor } from "storybook/test"; +import { MobileBottomNav } from "@/components/MobileBottomNav"; +import { TaskChatComposer } from "@/components/task-chat/TaskChatComposer"; +import { TaskChatComposerDock } from "@/components/task-chat/TaskChatComposerDock"; +import { TaskChatThreadView } from "@/components/task-chat/TaskChatThreadView"; +import { useMobileNavVisibility } from "@/hooks/useMobileNavVisibility"; +import { useMobileVisualViewport } from "@/hooks/useMobileVisualViewport"; + +const paragraphs = (count: number, topic: string) => + Array.from({ length: count }, (_, index) => + `${topic} ${index + 1}: I checked this section against the spec, noted the differences, and recorded what still needs a decision.`, + ).join("\n\n"); + +const items = [ + { id: "ask-1", kind: "message" as const, author: "human" as const, text: "Audit the onboarding flow and tell me what is slowing people down." }, + { id: "reply-1", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(10, "Finding") }, + { id: "ask-2", kind: "message" as const, author: "human" as const, text: "Which of these should we fix first?" }, + { id: "reply-2", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(8, "Priority") }, + { id: "ask-3", kind: "message" as const, author: "human" as const, text: "Great — draft the plan for the top three." }, + { id: "reply-3", kind: "message" as const, author: "agent" as const, authorName: "Researcher", text: paragraphs(6, "Step") }, +]; + +/** + * The production mobile task page frame: the Layout's main column publishes + * the auto-hiding chrome state exactly as `Layout.tsx` does, and the real + * thread scroller, composer dock, and bottom navigation respond to it. + */ +function MobileChromeAutoHide() { + const viewportRef = useMobileVisualViewport(true); + const navVisible = useMobileNavVisibility(true, "/ONB/issues/ONB-12"); + return
+
+
+
+ ONB-12 · Onboarding audit +
+
+
+
+
+ + + {}} /> + +
+
+
+
+
+
+ +
; +} + +function scroller(canvasElement: HTMLElement) { + const element = canvasElement.ownerDocument.querySelector('[data-testid="task-chat-scroller"]'); + if (!element) throw new Error("Task thread scroller is missing"); + return element; +} + +/** Scroll in small steps, like a finger drag, so the tracker sees deliberate movement. */ +async function dragThread(element: HTMLElement, by: number) { + const step = Math.sign(by) * 8; + for (let moved = 0; Math.abs(moved) < Math.abs(by); moved += step) { + element.scrollTop += step; + await new Promise((resolve) => requestAnimationFrame(resolve)); + } +} + +const chromeState = (canvasElement: HTMLElement) => { + const doc = canvasElement.ownerDocument; + return { + nav: doc.querySelector(".mobile-bottom-nav")?.getAttribute("data-visible"), + main: doc.getElementById("main-content")?.getAttribute("data-mobile-nav"), + dockVisibility: getComputedStyle(doc.querySelector('[data-testid="task-chat-composer-dock"]')!).visibility, + }; +}; + +async function settleAtLatest(canvasElement: HTMLElement) { + const element = scroller(canvasElement); + await waitFor(() => expect(element.scrollHeight).toBeGreaterThan(element.clientHeight * 2)); + element.scrollTop = element.scrollHeight; + await new Promise((resolve) => requestAnimationFrame(resolve)); + return element; +} + +const meta = { + id: "task-chat-mobile-chrome-autohide", + title: "Tasks and conversations/Task creation and lifecycle/Task chat/Mobile chrome auto-hide", + component: MobileChromeAutoHide, + parameters: { + layout: "fullscreen", + docs: { description: { component: "On a phone, the task page rests at the latest message with the composer and bottom navigation on screen. Drag back through the conversation and both slide away so the thread uses the full height. Drag back toward the latest message, or reach it, and both return. Typing with the keyboard open never hides the composer. Reduced motion switches instantly." } }, + paperclip: { + "capabilities": [ + "tasks/discussion", + ], + "implementation": "production", + "boundary": "fixtures", + "notes": "Production thread scroller, composer dock, bottom navigation, and useMobileNavVisibility in the Layout's mobile task-page frame. Static fixture messages; no agent or provider calls. Physical iPhone touch acceptance is still required.", + }, + }, + globals: { theme: "light", viewport: { value: "mobile", isRotated: false } }, +} satisfies Meta; +export default meta; +type Story = StoryObj; + +/** Interactive: start at the latest message and drag the thread yourself. */ +export const Interactive: Story = { + name: "01 · Drag the thread", + play: async ({ canvasElement }) => { + await settleAtLatest(canvasElement); + await waitFor(() => expect(chromeState(canvasElement).main).toBe("visible")); + }, +}; + +/** Reading back through the thread tucks the composer and navigation away. */ +export const ReadingBack: Story = { + name: "02 · Reading back hides composer and nav", + play: async ({ canvasElement }) => { + const element = await settleAtLatest(canvasElement); + await dragThread(element, -480); + await waitFor(() => { + const state = chromeState(canvasElement); + expect(state.main).toBe("hidden"); + expect(state.nav).toBe("false"); + expect(state.dockVisibility).toBe("hidden"); + }); + }, +}; + +/** Heading back toward the latest message brings both back. */ +export const HeadingBack: Story = { + name: "03 · Heading back restores them", + play: async ({ canvasElement }) => { + const element = await settleAtLatest(canvasElement); + await dragThread(element, -480); + await waitFor(() => expect(chromeState(canvasElement).main).toBe("hidden")); + await dragThread(element, 40); + await waitFor(() => { + const state = chromeState(canvasElement); + expect(state.main).toBe("visible"); + expect(state.nav).toBe("true"); + expect(state.dockVisibility).toBe("visible"); + }); + }, +}; From 627e1be76d0b746a9eec227b184c19d78d4266c6 Mon Sep 17 00:00:00 2001 From: paperclipbugbot Date: Fri, 4 Dec 2026 16:08:46 -0800 Subject: [PATCH 3/6] fix(db): give each database address time for a retransmitted SYN (#23784) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The server reads and writes all state through one postgres.js pool in `packages/db`. > - Sentry recorded a production query failure. Every address of the database host failed to connect: `connect ETIMEDOUT` on three IPv4 addresses and `ENETUNREACH` on three IPv6 addresses. > - Node tries the addresses of a host name in turn ("happy eyeballs"). It gives each address except the last only 250 ms. The last address was IPv6 and this host has no IPv6 route, so it failed at once. > - Thus the connection failed after about 750 ms. One dropped SYN was sufficient, because Linux sends the first SYN again only after 1 s. The 30 s `connect_timeout` of postgres.js did not apply. > - This pull request gives each address 2 s by default, so a retransmitted SYN can get an answer. > - The benefit is that a short network stall to the database no longer fails queries. ## Linked Issues or Issue Description No public GitHub issue exists. This is a bug report. **What happened?** A server query failed with `Failed query: select ... from "companies" ...`. The cause was an `AggregateError` with code `ETIMEDOUT`. Its errors were `ETIMEDOUT`, `ENETUNREACH`, `ETIMEDOUT`, `ENETUNREACH`, `ETIMEDOUT`, `ENETUNREACH`. Each `ETIMEDOUT` came from Node's per-address attempt timer (`internalConnectMultipleTimeout`), not from postgres.js. **Steps to reproduce** 1. Use a database host name that resolves to IPv4 addresses and IPv6 addresses, on a machine without an IPv6 route. 2. Make the IPv4 addresses drop SYN packets for less than one second. 3. Run a query that opens a new pooled connection. **Expected behavior** The connection waits for a retransmitted SYN. It fails only after `connect_timeout`. **Actual behavior** The connection fails after about 750 ms with `AggregateError` `ETIMEDOUT`. ## What Changed - `patches/postgres@3.4.9.patch`: postgres.js now calls `socket.connect({ port, host, autoSelectFamilyAttemptTimeout })` when the new `auto_select_family_attempt_timeout` option is set. Without the option, the call is the same as before. The change is in both the ESM and CJS builds. - `packages/db/src/client.ts`: new `connectAttemptTimeoutMs` client option and `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` variable. `resolveDatabaseClientOptions` sets a default of 2000 ms, so all pools from `createDb` use it. `client.ts` was already longer than 1,000 lines. This change adds the option next to the other driver options in that file, because they share one parser and one mapping. - `packages/db/src/postgres-connect-attempt-timeout.test.ts`: new regression test. It examines the arguments that the patched driver gives to `net.Socket.prototype.connect`. - `packages/db/src/client-options.test.ts`: tests for the new variable, its validation, the mapping and the default. - `docs/deploy/database.md` and `doc/DATABASE.md`: document the new variable. - I did not commit `pnpm-lock.yaml`. The patch hash changes, and the lockfile policy in `doc/ci-workflows.md` lets CI and the refresh workflow update it. ## Verification - Red, then green: `cd packages/db && npx vitest run src/postgres-connect-attempt-timeout.test.ts`. Before the fix, both tests failed. The driver called `connect(1, "127.0.0.1")` with no options. After the fix, both tests pass. - Focused: `npx vitest run src/postgres-connect-attempt-timeout.test.ts src/client-options.test.ts src/postgres-connection-recovery.test.ts src/client-disconnect-replay.test.ts src/client.test.ts src/postgres-receive-buffer.test.ts`. Result: 6 files, 48 tests pass. Some of these tests open real connections through the patched driver. - `pnpm exec tsc --noEmit -p packages/db` passes. - `pnpm verify` exits 2, because the postgres patch is a global CI input. Required CI supplies the broad coverage. - Manual reproduction on Node v24.23.0. A script overrides `dns.lookup` to give the production address shape: three loopback IPv4 listeners with full accept queues, which drop SYNs, and three unroutable IPv6 addresses. The listeners start to accept after 600 ms. - Before: `AggregateError code=ETIMEDOUT after 764ms inner=ETIMEDOUT,ENETUNREACH,ETIMEDOUT,ENETUNREACH,ETIMEDOUT,ENETUNREACH`. This is the same as the production error. - After, with the 2000 ms default: the listener accepted the client's retransmitted SYN at 1.035 s, and the TCP connection opened. The stub was not a Postgres server, so the query then stopped at the test's 3 s `connect_timeout`. ## Risks - Low risk. The option changes only how long Node waits for one address before it tries the next one. `connect_timeout` still bounds the whole attempt. - If an IPv6 address comes first and drops packets without an error, each new connection can wait up to 2 s before it tries IPv4, not 250 ms. Operators can set `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` lower. - Unix-socket connections (`path`) and custom `socket` factories do not change. - The patch hash of `postgres@3.4.9` changes. CI resolves the lockfile for this run, and the refresh workflow commits the new lockfile after merge. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edit and test execution). ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- doc/DATABASE.md | 1 + docs/deploy/database.md | 3 +- packages/db/src/client-options.test.ts | 15 ++++- packages/db/src/client.ts | 31 +++++++++- .../postgres-connect-attempt-timeout.test.ts | 48 ++++++++++++++ patches/postgres@3.4.9.patch | 62 ++++++++++++++++--- 6 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 packages/db/src/postgres-connect-attempt-timeout.test.ts diff --git a/doc/DATABASE.md b/doc/DATABASE.md index ecb92a12e1c..d4508f845dd 100644 --- a/doc/DATABASE.md +++ b/doc/DATABASE.md @@ -133,6 +133,7 @@ DATABASE_PREPARED_STATEMENTS=false # use false when the pooler does not suppor DATABASE_POOL_MAX=25 # connection pool size; default: 10 DATABASE_IDLE_TIMEOUT_SECONDS=60 # close idle pooled connections; default: 60 (0 = keep open) DATABASE_CONNECT_TIMEOUT_SECONDS=10 # default: 30 +DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS=2000 # time for each address of the host before the next; default: 2000 DATABASE_MAX_LIFETIME_SECONDS=1800 # recycle a pooled connection after this long; default: 30-60 min (random) DATABASE_APPLICATION_NAME=paperclip # application_name in pg_stat_activity; default for the server's main pool: paperclip: ``` diff --git a/docs/deploy/database.md b/docs/deploy/database.md index 57cb92f5c4f..bab93856de4 100644 --- a/docs/deploy/database.md +++ b/docs/deploy/database.md @@ -73,7 +73,7 @@ statements longer than 8 KB. If a prepared statement fails because the pooler's stale after a schema change or was lost, Paperclip stops preparing that statement and retries it once unprepared. -Related optional client tuning: `DATABASE_POOL_MAX`, `DATABASE_IDLE_TIMEOUT_SECONDS`, `DATABASE_CONNECT_TIMEOUT_SECONDS`, `DATABASE_MAX_LIFETIME_SECONDS`, `DATABASE_APPLICATION_NAME`. Driver defaults apply when unset, except that idle pooled connections close after 60 seconds (`DATABASE_IDLE_TIMEOUT_SECONDS=0` keeps them open) and the server's main pool reports `application_name=paperclip:` (other pools use names that start with `paperclip`). See [Connection pool settings](#connection-pool-settings). +Related optional client tuning: `DATABASE_POOL_MAX`, `DATABASE_IDLE_TIMEOUT_SECONDS`, `DATABASE_CONNECT_TIMEOUT_SECONDS`, `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS`, `DATABASE_MAX_LIFETIME_SECONDS`, `DATABASE_APPLICATION_NAME`. Driver defaults apply when unset, except that idle pooled connections close after 60 seconds (`DATABASE_IDLE_TIMEOUT_SECONDS=0` keeps them open), each address of the database host gets 2 seconds to answer a connection attempt, and the server's main pool reports `application_name=paperclip:` (other pools use names that start with `paperclip`). See [Connection pool settings](#connection-pool-settings). ## Connection Pool Settings @@ -84,6 +84,7 @@ The server opens one postgres.js pool for its own queries (and a second one when | `DATABASE_POOL_MAX` | `10` (driver) | Maximum pooled connections. | | `DATABASE_IDLE_TIMEOUT_SECONDS` | `60` | Close a pooled connection after this much idle time. `0` keeps idle connections open forever (the driver default). | | `DATABASE_CONNECT_TIMEOUT_SECONDS` | `30` (driver) | Give up on a connection attempt after this long. | +| `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` | `2000` | When the database host name resolves to several addresses, wait this long for one address before trying the next. Node's own default (250 ms) is shorter than one TCP retransmission, so a single dropped packet could fail the connection. `DATABASE_CONNECT_TIMEOUT_SECONDS` still bounds the whole attempt. | | `DATABASE_MAX_LIFETIME_SECONDS` | 30–60 min, randomized (driver) | Recycle a pooled connection once it is this old. | | `DATABASE_APPLICATION_NAME` | `paperclip:` (server main pool) | Value of `application_name` in `pg_stat_activity`. The boot id tells the sessions of each server process apart after a restart. Find Paperclip's backends with `SELECT * FROM pg_stat_activity WHERE application_name LIKE 'paperclip%';` | | `DATABASE_DEDICATED_CONNECTION_MAX` | `24` | Dedicated lock connections in use at once per process before new callers wait. Nested callers do not wait. | diff --git a/packages/db/src/client-options.test.ts b/packages/db/src/client-options.test.ts index 3e4836e7ad8..c31a35180a2 100644 --- a/packages/db/src/client-options.test.ts +++ b/packages/db/src/client-options.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { DEFAULT_DATABASE_APPLICATION_NAME, + DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS, databaseClientOptionsFromEnv, postgresJsOptions, @@ -35,6 +36,7 @@ describe("databaseClientOptionsFromEnv", () => { DATABASE_POOL_MAX: "25", DATABASE_IDLE_TIMEOUT_SECONDS: "60", DATABASE_CONNECT_TIMEOUT_SECONDS: "10", + DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS: "1500", DATABASE_MAX_LIFETIME_SECONDS: "1800", DATABASE_APPLICATION_NAME: " paperclip-web ", }), @@ -42,6 +44,7 @@ describe("databaseClientOptionsFromEnv", () => { maxConnections: 25, idleTimeoutSeconds: 60, connectTimeoutSeconds: 10, + connectAttemptTimeoutMs: 1500, maxLifetimeSeconds: 1800, applicationName: "paperclip-web", }); @@ -60,6 +63,9 @@ describe("databaseClientOptionsFromEnv", () => { expect(() => databaseClientOptionsFromEnv({ DATABASE_CONNECT_TIMEOUT_SECONDS: "1.5" })).toThrow( /DATABASE_CONNECT_TIMEOUT_SECONDS/, ); + expect(() => databaseClientOptionsFromEnv({ DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS: "0" })).toThrow( + /DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS/, + ); expect(() => databaseClientOptionsFromEnv({ DATABASE_IDLE_TIMEOUT_SECONDS: "-1" })).toThrow( /DATABASE_IDLE_TIMEOUT_SECONDS/, ); @@ -81,6 +87,7 @@ describe("databaseClientOptionsFromEnv", () => { maxConnections: 25, idleTimeoutSeconds: 60, connectTimeoutSeconds: 10, + connectAttemptTimeoutMs: 1500, maxLifetimeSeconds: 1800, applicationName: "paperclip-web", }), @@ -89,6 +96,7 @@ describe("databaseClientOptionsFromEnv", () => { max: 25, idle_timeout: 60, connect_timeout: 10, + auto_select_family_attempt_timeout: 1500, max_lifetime: 1800, connection: { application_name: "paperclip-web" }, }); @@ -102,13 +110,15 @@ describe("databaseClientOptionsFromEnv", () => { }); describe("resolveDatabaseClientOptions", () => { - it("reaps idle connections and names the pool when the environment sets nothing", () => { + it("reaps idle connections, bounds each address attempt and names the pool when the environment sets nothing", () => { expect(resolveDatabaseClientOptions({})).toEqual({ idleTimeoutSeconds: DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS, + connectAttemptTimeoutMs: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, applicationName: DEFAULT_DATABASE_APPLICATION_NAME, }); expect(postgresJsOptions(resolveDatabaseClientOptions(databaseClientOptionsFromEnv({})))).toEqual({ idle_timeout: DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS, + auto_select_family_attempt_timeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, connection: { application_name: DEFAULT_DATABASE_APPLICATION_NAME }, }); }); @@ -118,9 +128,10 @@ describe("resolveDatabaseClientOptions", () => { resolveDatabaseClientOptions({ maxConnections: 3, idleTimeoutSeconds: 0, + connectAttemptTimeoutMs: 500, applicationName: "paperclip-cli", }), - ).toEqual({ maxConnections: 3, idleTimeoutSeconds: 0, applicationName: "paperclip-cli" }); + ).toEqual({ maxConnections: 3, idleTimeoutSeconds: 0, connectAttemptTimeoutMs: 500, applicationName: "paperclip-cli" }); expect(postgresJsOptions(resolveDatabaseClientOptions({ idleTimeoutSeconds: 0 }))).toMatchObject({ idle_timeout: 0, }); diff --git a/packages/db/src/client.ts b/packages/db/src/client.ts index 303d460e803..2045df0fa86 100644 --- a/packages/db/src/client.ts +++ b/packages/db/src/client.ts @@ -151,6 +151,13 @@ export interface DatabaseClientOptions { idleTimeoutSeconds?: number; /** postgres.js `connect_timeout` in seconds (driver default: 30). */ connectTimeoutSeconds?: number; + /** + * Time in milliseconds that one connection attempt gives each address of the + * database host before it tries the next one (Node's + * `autoSelectFamilyAttemptTimeout`, default 250). The whole attempt is still + * bounded by `connectTimeoutSeconds`. + */ + connectAttemptTimeoutMs?: number; /** * postgres.js `max_lifetime` in seconds. Bounds how long one pooled * connection is reused before the client replaces it (driver default: a @@ -183,6 +190,16 @@ export interface DatabaseClientOptions { export const DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS = 60; /** `application_name` reported to PostgreSQL unless `DATABASE_APPLICATION_NAME` overrides it. */ export const DEFAULT_DATABASE_APPLICATION_NAME = "paperclip"; +/** + * Each address of the database host gets this many milliseconds unless + * `DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS` says otherwise. Node's own default of + * 250 ms is shorter than the first SYN retransmission (1 s on Linux). When the + * host name also has AAAA records and this machine has no IPv6 route, the last + * address fails at once, so a connection failed after about 750 ms when one + * packet was dropped, long before `connect_timeout`. 2 s lets each address + * answer a retransmitted SYN. + */ +export const DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS = 2_000; function envBoolean(env: NodeJS.ProcessEnv, name: string): boolean | undefined { const value = env[name]?.trim().toLowerCase(); @@ -235,6 +252,8 @@ export function databaseClientOptionsFromEnv(env: NodeJS.ProcessEnv = process.en if (idleTimeoutSeconds !== undefined) options.idleTimeoutSeconds = idleTimeoutSeconds; const connectTimeoutSeconds = envPositiveInteger(env, "DATABASE_CONNECT_TIMEOUT_SECONDS"); if (connectTimeoutSeconds !== undefined) options.connectTimeoutSeconds = connectTimeoutSeconds; + const connectAttemptTimeoutMs = envPositiveInteger(env, "DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS"); + if (connectAttemptTimeoutMs !== undefined) options.connectAttemptTimeoutMs = connectAttemptTimeoutMs; const maxLifetimeSeconds = envPositiveInteger(env, "DATABASE_MAX_LIFETIME_SECONDS"); if (maxLifetimeSeconds !== undefined) options.maxLifetimeSeconds = maxLifetimeSeconds; const applicationName = envNonEmptyString(env, "DATABASE_APPLICATION_NAME"); @@ -248,15 +267,17 @@ export function databaseClientOptionsFromEnv(env: NodeJS.ProcessEnv = process.en /** * Fills in Paperclip's defaults for the options the caller left unset: idle - * connections are reaped after `DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS`, and the - * pool identifies itself as `DEFAULT_DATABASE_APPLICATION_NAME`. Everything - * else stays at the driver default. An explicit value (including + * connections are reaped after `DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS`, each + * address of the database host gets `DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS`, + * and the pool identifies itself as `DEFAULT_DATABASE_APPLICATION_NAME`. + * Everything else stays at the driver default. An explicit value (including * `idleTimeoutSeconds: 0`) always wins over the default. */ export function resolveDatabaseClientOptions(options: DatabaseClientOptions): DatabaseClientOptions { return { ...options, idleTimeoutSeconds: options.idleTimeoutSeconds ?? DEFAULT_DATABASE_IDLE_TIMEOUT_SECONDS, + connectAttemptTimeoutMs: options.connectAttemptTimeoutMs ?? DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, applicationName: options.applicationName ?? DEFAULT_DATABASE_APPLICATION_NAME, }; } @@ -267,6 +288,10 @@ export function postgresJsOptions(options: DatabaseClientOptions): Record = {}; if (options.applicationName !== undefined) connection.application_name = options.applicationName; diff --git a/packages/db/src/postgres-connect-attempt-timeout.test.ts b/packages/db/src/postgres-connect-attempt-timeout.test.ts new file mode 100644 index 00000000000..660b13ed64b --- /dev/null +++ b/packages/db/src/postgres-connect-attempt-timeout.test.ts @@ -0,0 +1,48 @@ +import net from "node:net"; +import postgres from "postgres"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { + DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, + postgresJsOptions, + resolveDatabaseClientOptions, +} from "./client.js"; + +// Node tries each address of a database host name in turn (happy eyeballs) and +// by default gives every address but the last only 250 ms. When the last +// address is IPv6 on a host with no IPv6 route, it fails at once, so a host +// name with three A and three AAAA records fails to connect after about 750 ms +// whatever `connect_timeout` says. A single dropped SYN then fails the query. +describe("database connect attempt timeout", () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + it("gives each address of the database host enough time for a retransmitted SYN by default", () => { + expect(DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS).toBeGreaterThanOrEqual(1_000); + expect(postgresJsOptions(resolveDatabaseClientOptions({}))).toMatchObject({ + auto_select_family_attempt_timeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, + }); + }); + + it("passes the per-address budget to the socket that postgres.js opens", async () => { + const connect = vi.spyOn(net.Socket.prototype, "connect"); + // Port 1 on loopback refuses at once; only the connect arguments matter. + const sql = postgres("postgres://paperclip:unused@127.0.0.1:1/paperclip", { + ...postgresJsOptions(resolveDatabaseClientOptions({ connectTimeoutSeconds: 5 })), + max: 1, + onnotice: () => {}, + }); + try { + await expect(sql`select 1`).rejects.toMatchObject({ code: "ECONNREFUSED" }); + } finally { + await sql.end({ timeout: 0 }); + } + + expect(connect).toHaveBeenCalled(); + expect(connect.mock.calls[0]?.[0]).toMatchObject({ + host: "127.0.0.1", + port: 1, + autoSelectFamilyAttemptTimeout: DEFAULT_DATABASE_CONNECT_ATTEMPT_TIMEOUT_MS, + }); + }); +}); diff --git a/patches/postgres@3.4.9.patch b/patches/postgres@3.4.9.patch index b9cd7a82c8f..598df858e19 100644 --- a/patches/postgres@3.4.9.patch +++ b/patches/postgres@3.4.9.patch @@ -1,5 +1,5 @@ diff --git a/cjs/src/connection.js b/cjs/src/connection.js -index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4b140ec2f 100644 +index 07f6716702ac888215c86ad6e0071aaf55ae519c..3ecac096b4d757364d4a9b33add6ded4eecbd80f 100644 --- a/cjs/src/connection.js +++ b/cjs/src/connection.js @@ -173,8 +173,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose @@ -21,7 +21,22 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4 } async function connect() { -@@ -438,6 +440,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose +@@ -351,7 +353,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose + return socket.connect(options.path) + + socket.ssl = ssl +- socket.connect(port[hostIndex], host[hostIndex]) ++ socket.connect({ ++ port: port[hostIndex], ++ host: host[hostIndex], ++ ...(options.auto_select_family_attempt_timeout ++ ? { autoSelectFamilyAttemptTimeout: options.auto_select_family_attempt_timeout } ++ : {}) ++ }) + socket.host = host[hostIndex] + socket.port = port[hostIndex] + +@@ -438,6 +446,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose remaining = 0 incomings = null clearImmediate(nextWriteTimer) @@ -29,7 +44,7 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4 socket.removeListener('data', data) socket.removeListener('connect', connected) idleTimer.cancel() -@@ -451,6 +454,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose +@@ -451,6 +460,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose return reconnect() !hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket)) @@ -40,7 +55,7 @@ index 07f6716702ac888215c86ad6e0071aaf55ae519c..4ee75faa8ae47555576e3b4e0ec6b7c4 hadError && options.shared.retries++ delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000 diff --git a/cjs/src/index.js b/cjs/src/index.js -index f09c61c7e998f411560b95c9a8e1ed6a97972c11..04dded5c7e2cdc34ac01b29a87cc93248ec8c9c6 100644 +index f09c61c7e998f411560b95c9a8e1ed6a97972c11..5ae05848b627d4e7b849eb093a3d9ceb7f922b6d 100644 --- a/cjs/src/index.js +++ b/cjs/src/index.js @@ -216,8 +216,19 @@ function Postgres(a, b) { @@ -102,6 +117,14 @@ index f09c61c7e998f411560b95c9a8e1ed6a97972c11..04dded5c7e2cdc34ac01b29a87cc9324 c.queue === full ? queries.push(q) : c.execute(q) || move(c, full) +@@ -493,6 +514,7 @@ function parseOptions(a, b) { + onclose : o.onclose, + onparameter : o.onparameter, + socket : o.socket, ++ auto_select_family_attempt_timeout: o.auto_select_family_attempt_timeout, + transform : parseTransform(o.transform || { undefined: undefined }), + parameters : {}, + shared : { retries: 0, typeArrayMap: {} }, diff --git a/cjs/src/queue.js b/cjs/src/queue.js index 8438f5da92cf7637d98a33491d75c75b1c817c25..1c9a330fa173ecae84219055368cf630feadbda2 100644 --- a/cjs/src/queue.js @@ -131,7 +154,7 @@ index 8438f5da92cf7637d98a33491d75c75b1c817c25..1c9a330fa173ecae84219055368cf630 xs[index - 1] = undefined } diff --git a/src/connection.js b/src/connection.js -index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe689e685683 100644 +index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..a5057f0d1b03898b4c22b8711498871f200cce69 100644 --- a/src/connection.js +++ b/src/connection.js @@ -173,8 +173,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose @@ -153,7 +176,22 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68 } async function connect() { -@@ -438,6 +440,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose +@@ -351,7 +353,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose + return socket.connect(options.path) + + socket.ssl = ssl +- socket.connect(port[hostIndex], host[hostIndex]) ++ socket.connect({ ++ port: port[hostIndex], ++ host: host[hostIndex], ++ ...(options.auto_select_family_attempt_timeout ++ ? { autoSelectFamilyAttemptTimeout: options.auto_select_family_attempt_timeout } ++ : {}) ++ }) + socket.host = host[hostIndex] + socket.port = port[hostIndex] + +@@ -438,6 +446,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose remaining = 0 incomings = null clearImmediate(nextWriteTimer) @@ -161,7 +199,7 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68 socket.removeListener('data', data) socket.removeListener('connect', connected) idleTimer.cancel() -@@ -451,6 +454,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose +@@ -451,6 +460,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose return reconnect() !hadError && (query || sent.length) && error(Errors.connection('CONNECTION_CLOSED', options, socket)) @@ -172,7 +210,7 @@ index 1b1cccde43b4570d5d071d6ffaab2669b3c2065a..0a4c4cc185f14afa30c7c6a294bafe68 hadError && options.shared.retries++ delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000 diff --git a/src/index.js b/src/index.js -index c7fba3dace20173f4cb13f3f138bb6d213b43683..f0888986add8ba02c8853f792ae42dd1cec88c82 100644 +index c7fba3dace20173f4cb13f3f138bb6d213b43683..59fcbc0d44e709e86abdf34e47ad6bc98a9e6974 100644 --- a/src/index.js +++ b/src/index.js @@ -216,8 +216,19 @@ function Postgres(a, b) { @@ -234,6 +272,14 @@ index c7fba3dace20173f4cb13f3f138bb6d213b43683..f0888986add8ba02c8853f792ae42dd1 c.queue === full ? queries.push(q) : c.execute(q) || move(c, full) +@@ -493,6 +514,7 @@ function parseOptions(a, b) { + onclose : o.onclose, + onparameter : o.onparameter, + socket : o.socket, ++ auto_select_family_attempt_timeout: o.auto_select_family_attempt_timeout, + transform : parseTransform(o.transform || { undefined: undefined }), + parameters : {}, + shared : { retries: 0, typeArrayMap: {} }, diff --git a/src/queue.js b/src/queue.js index c4ef97164f057db99dce1b9af3401dbb1af37e31..46e7ade55c0a3250137a21117c03ce9166b40bc2 100644 --- a/src/queue.js From bf49fce70f1796d44be6f19668880b8096ed33e6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2026 00:12:55 +0000 Subject: [PATCH 4/6] chore(lockfile): refresh pnpm lockfiles (#23802) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip uses a dependency lock for reproducible builds. > - Dependency changes on master need matching lock entries. > - Paid eval reports also pin a reviewed offline correction. > - Reports must install before paid model work starts. > - This automated PR keeps the lock and report proof together. ## Linked Issues or Issue Description **What happened?** Dependency manifests on master changed after the last committed lock refresh. **Expected behavior** Frozen installs must match those manifests. Eval reports must retain matching offline lock proof. **Steps to reproduce** Run a frozen install before and after this lock refresh. ## What Changed - Refresh the dependency lock from the manifests on master. - Refresh the sandbox provider lockfiles from their manifests on master. - Include the matching offline report correction and hashes. - Resync the SDK public source proof's lock pins from the refreshed lock. ## Verification - Pinned pnpm resolution completed with lifecycle scripts disabled. - The report proof refresh accepted the reviewed committed baseline. - The workflow rejected changes outside the lock and report proof files. ## Risks The lockfile bot merges this PR without CI or review when it verifies every added version on npm and all versions outside the harness allowlist are at least 3 days old. Otherwise the PR waits for a maintainer, and the daily refresh tries again. The bot merges only the exact commit this workflow generated from manifests already reviewed on master. Unknown report lock baselines remain blocked. This update changes no permissions or paid enable gates. ## Model Used None — generated by pnpm and the deterministic report-lock updater. ## Checklist - [x] Thinking path and problem description included - [x] Generated lock and matching report proof included - [x] Release-age gate decides between bot merge and maintainer review Co-authored-by: lockfile-bot --- pnpm-lock.yaml | 34 ++-- tests/runner-e2e/report-lock.json | 6 +- tests/runner-e2e/report-lock.patch | 151 ++++++++++++++++-- .../runner-e2e/source-sdk-public-inputs.json | 4 +- 4 files changed, 162 insertions(+), 33 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad688a5c9e7..084c6324c3d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,7 +46,7 @@ patchedDependencies: hash: 55uhvnotpqyiy37rn3pqpukhei path: patches/embedded-postgres@18.1.0-beta.16.patch postgres@3.4.9: - hash: 7s673zkrux4f7d7y4kyzk7opyu + hash: 2ucarb2ongic7ioq4v4x67fgri path: patches/postgres@3.4.9.patch importers: @@ -139,7 +139,7 @@ importers: version: 17.4.2 drizzle-orm: specifier: 0.45.2 - version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) + version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) embedded-postgres: specifier: ^18.1.0-beta.16 version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) @@ -411,13 +411,13 @@ importers: version: link:../shared drizzle-orm: specifier: ^0.45.2 - version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) + version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) embedded-postgres: specifier: ^18.1.0-beta.16 version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) postgres: specifier: ^3.4.9 - version: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu) + version: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri) devDependencies: '@types/node': specifier: ^24.0.0 @@ -1024,7 +1024,7 @@ importers: version: 2.2.0(@grpc/grpc-js@1.14.5)(nice-grpc-common@2.0.4)(nice-grpc@2.1.17) '@vercel/connect': specifier: 2.3.3 - version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))) + version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))) acorn: specifier: 8.18.0 version: 8.18.0 @@ -1042,7 +1042,7 @@ importers: version: 3.0.1(ajv@8.20.0) better-auth: specifier: 1.7.16 - version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) + version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) chat: specifier: 4.39.0 version: 4.39.0(ai@7.0.130(zod@4.6.7))(zod@4.6.7) @@ -1063,7 +1063,7 @@ importers: version: 17.4.2 drizzle-orm: specifier: ^0.45.2 - version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) + version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) embedded-postgres: specifier: ^18.1.0-beta.16 version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) @@ -10356,12 +10356,12 @@ snapshots: optionalDependencies: '@opentelemetry/api': 1.9.1 - '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))': + '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))': dependencies: '@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3) '@better-auth/utils': 0.5.1 optionalDependencies: - drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) + drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) '@better-auth/kysely-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)': dependencies: @@ -14313,14 +14313,14 @@ snapshots: dependencies: execa: 5.1.1 - '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))': + '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))': dependencies: '@vercel/oidc': 3.8.9 optionalDependencies: '@chat-adapter/slack': 4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7) '@modelcontextprotocol/sdk': 1.31.0(zod@4.6.7) ai: 7.0.130(zod@4.6.7) - better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) + better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) '@vercel/oidc@3.2.0': {} @@ -14579,10 +14579,10 @@ snapshots: before-after-hook@4.0.0: {} - better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))): + better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))): dependencies: '@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3) - '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))) + '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))) '@better-auth/kysely-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5) '@better-auth/memory-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1) '@better-auth/mongo-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1) @@ -14600,7 +14600,7 @@ snapshots: zod: 4.6.7 optionalDependencies: drizzle-kit: 0.31.11 - drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) + drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) pg: 8.18.0 react: 19.2.8 react-dom: 19.2.8(react@19.2.8) @@ -15195,12 +15195,12 @@ snapshots: esbuild: 0.25.12 tsx: 4.23.15 - drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)): + drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)): optionalDependencies: '@opentelemetry/api': 1.9.1 kysely: 0.29.5 pg: 8.18.0 - postgres: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu) + postgres: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri) dunder-proto@1.0.1: dependencies: @@ -17113,7 +17113,7 @@ snapshots: dependencies: xtend: 4.0.2 - postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu): {} + postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri): {} posthog-node@5.38.2(rxjs@7.8.2): dependencies: diff --git a/tests/runner-e2e/report-lock.json b/tests/runner-e2e/report-lock.json index 4cd5564e77b..743cd7f4d79 100644 --- a/tests/runner-e2e/report-lock.json +++ b/tests/runner-e2e/report-lock.json @@ -1,6 +1,6 @@ { - "inputSha256": "43742a66f2dd438c5913a34840c94188f8ec05fda7fc11c1c8889913cdcf433b", - "outputSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3", - "patchSha256": "f6aab695df1f8d9819ae189386866efd3bd4dc839c7eb7540e25b9225aad5e28", + "inputSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3", + "outputSha256": "f47176419e462f4a44b99634a85cd1cafeba926b1dd06ac97459a08e13ac8135", + "patchSha256": "795835e506471683a18c0faff8a04a586b480a4169b88e80546b429f48d33b2d", "basis": "Generated with the trusted master lockfile refresh. Review this offline correction and its hashes with the dependency changes." } diff --git a/tests/runner-e2e/report-lock.patch b/tests/runner-e2e/report-lock.patch index 8f90bf41fe8..488a8b2cb46 100644 --- a/tests/runner-e2e/report-lock.patch +++ b/tests/runner-e2e/report-lock.patch @@ -1,14 +1,143 @@ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml -index b925688a..ad688a5c 100644 +index ad688a5c..084c6324 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml -@@ -1121,6 +1121,9 @@ importers: - tar-stream: - specifier: 3.2.0 - version: 3.2.0 -+ tldts: -+ specifier: 7.4.10 -+ version: 7.4.10 - ws: - specifier: ^8.22.0 - version: 8.22.0 +@@ -46,7 +46,7 @@ patchedDependencies: + hash: 55uhvnotpqyiy37rn3pqpukhei + path: patches/embedded-postgres@18.1.0-beta.16.patch + postgres@3.4.9: +- hash: 7s673zkrux4f7d7y4kyzk7opyu ++ hash: 2ucarb2ongic7ioq4v4x67fgri + path: patches/postgres@3.4.9.patch + + importers: +@@ -139,7 +139,7 @@ importers: + version: 17.4.2 + drizzle-orm: + specifier: 0.45.2 +- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) ++ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) + embedded-postgres: + specifier: ^18.1.0-beta.16 + version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) +@@ -411,13 +411,13 @@ importers: + version: link:../shared + drizzle-orm: + specifier: ^0.45.2 +- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) ++ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) + embedded-postgres: + specifier: ^18.1.0-beta.16 + version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) + postgres: + specifier: ^3.4.9 +- version: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu) ++ version: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri) + devDependencies: + '@types/node': + specifier: ^24.0.0 +@@ -1024,7 +1024,7 @@ importers: + version: 2.2.0(@grpc/grpc-js@1.14.5)(nice-grpc-common@2.0.4)(nice-grpc@2.1.17) + '@vercel/connect': + specifier: 2.3.3 +- version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))) ++ version: 2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)))) + acorn: + specifier: 8.18.0 + version: 8.18.0 +@@ -1042,7 +1042,7 @@ importers: + version: 3.0.1(ajv@8.20.0) + better-auth: + specifier: 1.7.16 +- version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) ++ version: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) + chat: + specifier: 4.39.0 + version: 4.39.0(ai@7.0.130(zod@4.6.7))(zod@4.6.7) +@@ -1063,7 +1063,7 @@ importers: + version: 17.4.2 + drizzle-orm: + specifier: ^0.45.2 +- version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) ++ version: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) + embedded-postgres: + specifier: ^18.1.0-beta.16 + version: 18.1.0-beta.16(patch_hash=55uhvnotpqyiy37rn3pqpukhei) +@@ -10356,12 +10356,12 @@ snapshots: + optionalDependencies: + '@opentelemetry/api': 1.9.1 + +- '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))': ++ '@better-auth/drizzle-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))': + dependencies: + '@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3) + '@better-auth/utils': 0.5.1 + optionalDependencies: +- drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) ++ drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) + + '@better-auth/kysely-adapter@1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5)': + dependencies: +@@ -14313,14 +14313,14 @@ snapshots: + dependencies: + execa: 5.1.1 + +- '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))': ++ '@vercel/connect@2.3.3(@chat-adapter/slack@4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7))(@modelcontextprotocol/sdk@1.31.0(zod@4.6.7))(ai@7.0.130(zod@4.6.7))(better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))))': + dependencies: + '@vercel/oidc': 3.8.9 + optionalDependencies: + '@chat-adapter/slack': 4.39.0(patch_hash=eskb5kxp7eud5v3ostluhynfoa)(ai@7.0.130(zod@4.6.7))(zod@4.6.7) + '@modelcontextprotocol/sdk': 1.31.0(zod@4.6.7) + ai: 7.0.130(zod@4.6.7) +- better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) ++ better-auth: 1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))) + + '@vercel/oidc@3.2.0': {} + +@@ -14579,10 +14579,10 @@ snapshots: + + before-after-hook@4.0.0: {} + +- better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))): ++ better-auth@1.7.16(@opentelemetry/api@1.9.1)(drizzle-kit@0.31.11)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)))(pg@8.18.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(vitest@5.0.3(@opentelemetry/api@1.9.1)(@types/node@24.13.3)(jsdom@30.0.1(@noble/hashes@2.4.0))(vite@8.2.2(@types/node@24.13.3)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))): + dependencies: + '@better-auth/core': 1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3) +- '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu))) ++ '@better-auth/drizzle-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri))) + '@better-auth/kysely-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1)(kysely@0.29.5) + '@better-auth/memory-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1) + '@better-auth/mongo-adapter': 1.7.16(@better-auth/core@1.7.16(@better-auth/utils@0.5.1)(@better-fetch/fetch@1.3.3)(@opentelemetry/api@1.9.1)(better-call@1.4.5(zod@4.6.7))(jose@6.2.12)(kysely@0.29.5)(nanostores@1.5.3))(@better-auth/utils@0.5.1) +@@ -14600,7 +14600,7 @@ snapshots: + zod: 4.6.7 + optionalDependencies: + drizzle-kit: 0.31.11 +- drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)) ++ drizzle-orm: 0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)) + pg: 8.18.0 + react: 19.2.8 + react-dom: 19.2.8(react@19.2.8) +@@ -15195,12 +15195,12 @@ snapshots: + esbuild: 0.25.12 + tsx: 4.23.15 + +- drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu)): ++ drizzle-orm@0.45.2(@opentelemetry/api@1.9.1)(kysely@0.29.5)(pg@8.18.0)(postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri)): + optionalDependencies: + '@opentelemetry/api': 1.9.1 + kysely: 0.29.5 + pg: 8.18.0 +- postgres: 3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu) ++ postgres: 3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri) + + dunder-proto@1.0.1: + dependencies: +@@ -17113,7 +17113,7 @@ snapshots: + dependencies: + xtend: 4.0.2 + +- postgres@3.4.9(patch_hash=7s673zkrux4f7d7y4kyzk7opyu): {} ++ postgres@3.4.9(patch_hash=2ucarb2ongic7ioq4v4x67fgri): {} + + posthog-node@5.38.2(rxjs@7.8.2): + dependencies: diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 52b16ea8e4b..8a9cd18f09e 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -598,12 +598,12 @@ "packages/shared/src/worktree-seed-source.test.ts": "852856b1b5b8f4d0d3dada6501886fe50a2c2dde", "packages/shared/src/worktree-seed-source.ts": "3d1a09bed2d969feabef3400ff84fd499c1408f4", "packages/shared/tsconfig.json": "5a24989cd30dcf3749ca7e60d4e83d6ddbb14714", - "pnpm-lock.yaml": "ad688a5c9e7a190afa2e670d5a9a45b4781156ab", + "pnpm-lock.yaml": "084c6324c3ddee458cede84d727b837b6b6c4381", "scripts/ensure-plugin-build-deps.mjs": "356e0e0f80e50890067027da3003485cf5d2ccbe", "tsconfig.base.json": "2d0e41f723add0c678936eb9ae1c60eab710f8e0", "tsconfig.json": "994ee490fb97be7cc0954f4dfd88cf0723290e6c" }, - "lockSha256": "d44e2238d0db22352b3fc884c409a47cd769b83ecec2ac5288ac1bc9ddea5eb3", + "lockSha256": "f47176419e462f4a44b99634a85cd1cafeba926b1dd06ac97459a08e13ac8135", "compilerPackageSha256": "3722b30210616a13a3213ded11575ba6b2dbab10c32a5ef67afca8513e27017e", "parserPackageSha256": "6d6a65b879cd7cd249a4367c0b57cce00e78c728de45056ac2a5ca1d1f528d1a", "parserEntrySha256": "6969920ae0610df927b6b3e675d1309372c268e36d391652af8e3e0183cbe8f8", From f23af2e079539ee4f863f39a2966323c027bb1f5 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Fri, 4 Dec 2026 16:21:51 -0800 Subject: [PATCH 5/6] Fix user attribution for agent lifecycle verification (#23800) ## Thinking Path > - Paperclip manages work for AI agents. > - An agent must pass execution checks before it can run work. > - Personal AI accounts require the identity of the responsible user. > - An environment change could start those checks without a user identity. > - The manual connection test still passed because it used the signed-in user. > - This pull request records the configuring user and repairs missing identity on an authorized retry. ## Linked Issues or Issue Description **What happened?** An agent could pass its manual connection test and stay paused after an environment change. Background verification had no responsible user and rejected access to the selected personal AI account. Retry now repeated the same failure. **Expected behavior** Verification started by a configuration change uses the configuring user. An authorized retry can repair an older operation that has no responsible user. Existing account sharing and task access checks still apply. **Steps to reproduce** 1. Use an agent with a personal AI connection and no saved lifecycle user or company default responsible user. 2. Move the agent to an environment that requires setup. 3. Run its manual connection test. The test passes under the signed-in user. 4. Observe failed background verification. Retry now does not repair the missing identity. **Paperclip version or commit** Reproduced on base commit `f0d4f6c3eb2e931f2f7a3e8b426f964aeb54aeee`. **Deployment mode** Authenticated hosted server. The local regression uses disposable PostgreSQL databases on macOS arm64, Node 25.6.1, and pnpm 9.15.4. ## What Changed - Record the authenticated responsible user when a configuration change starts a new lifecycle operation. Include the verified human context for an agent acting on behalf of a user. Keep the prior identity for changes without that context. - Pass the authenticated board identity to the existing retry command. Fill only missing responsibility; preserve an operation's recorded owner. - Start a new operation when repairing a missing identity. Repeat the host check under that identity. A prior attempt cannot complete the replacement operation. - Extend the lifecycle owner suites to cover human and delegated configuration attribution, retry repair, existing owners, active leases, readiness, and request-body spoofing. The existing board, agent, and company access checks remain covered. The lifecycle module owns the repair. Its internal store contract now accepts the authenticated retry identity. The routes supply those values after their existing authorization checks. No new API field, migration, provider policy, or credential permission is added. ## Verification - Before the fix, focused regressions failed in four cases: configuration attribution, board retry attribution, and retry identity repair with and without a lease. - The three owner suites passed all 141 tests after the fix. The final retry suite passed all 27 tests, including rejection of a stale host completion after identity repair. - Server typechecking passed with `node scripts/typecheck-layers.mjs` after the Runner and SDK build prerequisites. An initial test-only type error was corrected with the lifecycle operation type. - `pnpm verify --explain` returned exit 2 because the internal port type lies outside the resolved runtime test graph. Required CI will supply the listed broad typecheck, test, build, and end-to-end coverage. No full local suite pass is claimed. - Test budget, module boundaries, runtime push guard, whitespace, and local secret/PII checks passed. - CI found one stale mocked retry expectation in `agent-cross-tenant-authz-routes.test.ts`. It now checks the authenticated board user as well as the agent ID. All 18 tests in that suite pass locally. The interrupted native-runner CI job was stopped by a runner shutdown; the new revision will rerun CI. - Greptile reviewed the final `e5701b3584a57bbdde269b60439c561acca1f9b1` revision at 5/5. There are no unresolved review threads. - GitHub CI passed on `e5701b3584a57bbdde269b60439c561acca1f9b1`: all 68 reported checks are green, including typecheck, build, native Runner, serialized server, general tests, and end-to-end shards. [CI run](https://github.com/paperclipai/paperclip/actions/runs/47452634326). The initial canceled Runner attempt and stale mock failure are superseded by this successful run. - Hosted acceptance remains pending deployment of the reviewed revision. No live provider call is made by the regression tests. ## Risks - Identity repair does not change credential sharing. Verification still fails if the responsible user lacks access to the selected account. - An identity repair starts a replacement operation and fences any old lease. Existing plugin and host work must pass under that operation before readiness. - No schema or migration changes. Background retry behavior without an explicit user keeps the saved identity. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning and terminal tool access. The harness does not expose the context-window size. ## 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 --- .../agent-cross-tenant-authz-routes.test.ts | 2 +- server/src/lib/agent-records.ts | 1 + .../__tests__/environment-plugins.test.ts | 22 +++++++++--- .../__tests__/lifecycle.test.ts | 3 +- .../__tests__/verification-retry.test.ts | 35 ++++++++++++++++--- .../agent-lifecycle/adapters/configuration.ts | 4 ++- .../agent-lifecycle/adapters/postgres.ts | 12 ++++++- .../agent-lifecycle/application/ports.ts | 2 +- server/src/modules/agent-lifecycle/index.ts | 6 ++-- server/src/routes/agents.ts | 3 +- 10 files changed, 73 insertions(+), 17 deletions(-) diff --git a/server/src/__tests__/agent-cross-tenant-authz-routes.test.ts b/server/src/__tests__/agent-cross-tenant-authz-routes.test.ts index 6c0ae8c29f7..616b1e9fdea 100644 --- a/server/src/__tests__/agent-cross-tenant-authz-routes.test.ts +++ b/server/src/__tests__/agent-cross-tenant-authz-routes.test.ts @@ -779,7 +779,7 @@ describe("agent lifecycle retry authorization", () => { const res = await requestApp(app, base => request(base).post(`/api/agents/${agentId}/lifecycle/retry`).send({})); expect(res.status).toBe(200); expect(res.body).toMatchObject({ id: agentId, lifecycleState: "preparing", lifecycleError: null }); - expect(mockAgentService.retryLifecycle).toHaveBeenCalledWith(agentId); + expect(mockAgentService.retryLifecycle).toHaveBeenCalledWith(agentId, "board"); expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ companyId, entityId: agentId, action: "agent.lifecycle_retried", actorType: "user", actorId: "board", })); diff --git a/server/src/lib/agent-records.ts b/server/src/lib/agent-records.ts index b09bdf56ede..fec1336537b 100644 --- a/server/src/lib/agent-records.ts +++ b/server/src/lib/agent-records.ts @@ -76,6 +76,7 @@ export interface ClaudeLoginContext { } export interface UpdateAgentOptions { + responsibleUserId?: string | null; expectedConfigurationRevision?: string; expectedConfiguration?: Pick; recordRevision?: RevisionMetadata; diff --git a/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts b/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts index f27a97a3528..f325dacfbb7 100644 --- a/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/environment-plugins.test.ts @@ -165,13 +165,19 @@ const support = await getEmbeddedPostgresTestSupport(); }); it.each(["idle", "running"])("automatically pauses an %s agent, prepares its new environment, and verifies before readiness", async status => { - const id = await agent(otherEnvironmentId, { status, lifecycleRequiredPluginIds: [] }); - const saved = await agentConfiguration(db).update(id, { defaultEnvironmentId: boundEnvironmentId }); + const id = await agent(otherEnvironmentId, { status, lifecycleRequiredPluginIds: [], + lifecycleOperation: { id: randomUUID(), hostComplete: true, completedPluginIds: [], attempts: 0, responsibleUserId: "earlier-configurer" } }); + const saved = await agentConfiguration(db).update(id, { defaultEnvironmentId: boundEnvironmentId }, { + recordRevision: { createdByUserId: "current-configurer", source: "patch" }, + }); expect(saved).toMatchObject({ defaultEnvironmentId: boundEnvironmentId, lifecycleState: "pausing", status: "paused" }); expect(await current(id)).toMatchObject({ lifecycleHolds: [], lifecycleOperation: { resumeState: "verifying" } }); const phases: string[] = []; - const runHost = vi.fn(async (row: LifecycleAgent) => { phases.push(row.lifecycleState); return "complete" as const; }); + const runHost = vi.fn(async (row: LifecycleAgent) => { + expect(row.lifecycleOperation?.responsibleUserId).toBe("current-configurer"); + phases.push(row.lifecycleState); return "complete" as const; + }); await worker(runHost).process(id); expect(phases).toEqual(["pausing", "resuming", "verifying"]); expect(call.mock.calls.map(args => args[2].phase)).toEqual(["resuming", "verifying"]); @@ -186,14 +192,22 @@ const support = await getEmbeddedPostgresTestSupport(); principalId, membershipRole: "member", status: "active" }); await db.insert(principalPermissionGrants).values({ companyId, principalType: type === "board" ? "user" : "agent", principalId, permissionKey: "agents:configure" }); + const responsibleUserId = type === "board" ? principalId : randomUUID(); + if (type === "agent") { + await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: responsibleUserId, + membershipRole: "member", status: "active" }); + await db.insert(principalPermissionGrants).values({ companyId, principalType: "user", principalId: responsibleUserId, permissionKey: "agents:configure" }); + } const actor: Express.Request["actor"] = type === "board" ? { type, source: "session", userId: principalId, companyIds: [companyId], memberships: [{ companyId, membershipRole: "member", status: "active" }] } - : { type, source: "agent_key", agentId: principalId, companyId }; + : { type, source: "agent_key", agentId: principalId, companyId, onBehalfOfUserId: responsibleUserId, + onBehalfOfMemberships: [{ companyId, membershipRole: "member", status: "active" }] }; await request(app(actor)).post(`/api/agents/${id}/pause`).send({}).expect(403); const response = await request(app(actor)).patch(`/api/agents/${id}`).send({ defaultEnvironmentId: boundEnvironmentId }); expect(response.status, JSON.stringify(response.body)).toBe(200); expect(await current(id)).toMatchObject({ defaultEnvironmentId: boundEnvironmentId, lifecycleState: "pausing", status: "paused" }); + expect((await current(id)).lifecycleOperation?.responsibleUserId).toBe(responsibleUserId); }); it.each(["board", "agent"] as const)("rejects a %s without configuration permission before saving the environment or pausing", async type => { diff --git a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts index 82ca28eaa79..7d4885485a8 100644 --- a/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/lifecycle.test.ts @@ -1246,10 +1246,11 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: "board", membershipRole: "admin" }); await db.insert(principalPermissionGrants).values(["agents:create", "agents:configure"].map(permissionKey => ({ companyId, principalType: "user", principalId: "board", permissionKey }))); const url = `/api/agents/${agent.id}/lifecycle/retry`; - const response = await request(app(board)).post(url).send({}); + const response = await request(app(board)).post(url).send({ responsibleUserId: "untrusted-user" }); expect(response.status, JSON.stringify(response.body)).toBe(200); expect(response.body.lifecycleState).toBe("preparing"); expect(response.body).not.toHaveProperty("lifecycleOperation"); + expect((await current(agent.id)).lifecycleOperation?.responsibleUserId).toBe("board"); expect(await db.select().from(activityLog).where(and(eq(activityLog.entityId, agent.id), eq(activityLog.action, "agent.lifecycle_retried")))) .toEqual([expect.objectContaining({ actorType: "user", actorId: "board" })]); await request(app({ type: "agent", source: "agent_key", companyId, agentId: agent.id })).post(url).send({}).expect(403); diff --git a/server/src/modules/agent-lifecycle/__tests__/verification-retry.test.ts b/server/src/modules/agent-lifecycle/__tests__/verification-retry.test.ts index 23dfeb303bd..a8a2d70dffc 100644 --- a/server/src/modules/agent-lifecycle/__tests__/verification-retry.test.ts +++ b/server/src/modules/agent-lifecycle/__tests__/verification-retry.test.ts @@ -173,20 +173,47 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu expect(await store.claim(agent!.id, "new-check", new Date())).not.toBeNull(); }); - it("permits an explicit retry of the same operation and completes verification before readiness", async () => { + it.each([false, true].flatMap(leased => [undefined, "saved-owner"].map(responsibleUserId => ({ leased, responsibleUserId }))))( + "repairs missing retry identity and fences older attempts: %j", async ({ leased, responsibleUserId }) => { + const operation: NonNullable = { id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, responsibleUserId, + ...(leased ? { leaseOwner: "active-verifier", leaseUntil: new Date(Date.now() + 60_000).toISOString() } : { retryRequired: true }) }; + const [agent] = await db.insert(agents).values({ companyId, name: "Retry identity", status: "paused", + lifecycleState: "verifying", lifecycleRequiredPluginIds: [], lifecycleOperation: operation }).returning(); + const store = createLifecycleStore(db, createAgentLifecycleEffects()); + await createAgentLifecycle(db).retry(agent.id, "requesting-user"); + const retried = await current(agent.id); + if (!responsibleUserId) { + expect(retried.lifecycleOperation).toMatchObject({ responsibleUserId: "requesting-user", hostComplete: false, completedPluginIds: [] }); + expect(retried.lifecycleOperation).not.toHaveProperty("leaseOwner"); + expect(retried.lifecycleOperation!.id).not.toBe(operation.id); + expect(retried.lifecycleVersion).toBe(agent.lifecycleVersion + 1); + expect(await store.completeHost(agent, "active-verifier")).toBe(false); + return; + } + expect(retried.lifecycleOperation).toMatchObject({ id: operation.id, + responsibleUserId: responsibleUserId ?? "requesting-user", + ...(leased ? { leaseOwner: operation.leaseOwner, leaseUntil: operation.leaseUntil, recheckRequested: true } : {}) }); + expect(retried.lifecycleVersion).toBe(agent.lifecycleVersion); + }, + ); + + it("completes verification under the repaired identity before readiness", async () => { const { agent, work, runHost } = await failed(); let release!: () => void; const verification = new Promise(resolve => { release = resolve; }); - runHost.mockImplementation(async () => { await verification; return "complete"; }); + runHost.mockImplementation(async agent => { + expect(agent.lifecycleOperation?.responsibleUserId).toBe("requesting-user"); + await verification; return "complete"; + }); let processing: Promise | undefined; try { - await createAgentLifecycle(db).retry(agent.id); + await createAgentLifecycle(db).retry(agent.id, "requesting-user"); processing = work.process(agent.id); const retried = await current(agent.id); expect(retried).toMatchObject({ lifecycleState: "verifying", status: "paused" }); expect(retried.lifecycleOperation).not.toHaveProperty("retryRequired"); expect(retried.lifecycleOperation).not.toHaveProperty("verificationFailures"); - expect(retried.lifecycleOperation!.id).toBe(agent.lifecycleOperation!.id); + expect(retried.lifecycleOperation!.id).not.toBe(agent.lifecycleOperation!.id); } finally { release(); await processing; diff --git a/server/src/modules/agent-lifecycle/adapters/configuration.ts b/server/src/modules/agent-lifecycle/adapters/configuration.ts index 788341b1165..e661a4d8d8e 100644 --- a/server/src/modules/agent-lifecycle/adapters/configuration.ts +++ b/server/src/modules/agent-lifecycle/adapters/configuration.ts @@ -55,7 +55,9 @@ export async function updateAgentConfiguration(tx: Db, effects: LifecycleEffects ...(prepareSetup || prepareEnvironment ? { lifecycleState: "preparing" as const } : {}), ...(pauseForEnvironment ? { lifecycleState: "pausing" as const, status: "paused", pausedAt: new Date() } : {}), ...(stopSetup ? { lifecycleState: "pausing" as const } : {}), - lifecycleOperation: { ...current.lifecycleOperation!, id: randomUUID(), hostComplete: false, + lifecycleOperation: { ...current.lifecycleOperation!, + responsibleUserId: options?.responsibleUserId ?? options?.recordRevision?.createdByUserId ?? current.lifecycleOperation?.responsibleUserId, + id: randomUUID(), hostComplete: false, completedPluginIds: [], attempts: 0, leaseOwner: undefined, leaseUntil: undefined, leaseHolder: undefined, retryAt: undefined, retryRequired: undefined, verificationFailures: undefined, waitingForSignal: undefined, recheckRequested: undefined, diff --git a/server/src/modules/agent-lifecycle/adapters/postgres.ts b/server/src/modules/agent-lifecycle/adapters/postgres.ts index 99871678dc5..2d30ef1a6f5 100644 --- a/server/src/modules/agent-lifecycle/adapters/postgres.ts +++ b/server/src/modules/agent-lifecycle/adapters/postgres.ts @@ -18,7 +18,7 @@ const LIFECYCLE_PENDING_MAX_MS = 60_000; export function lifecyclePendingRetryDelayMs(passes: number) { return Math.min(LIFECYCLE_PENDING_MAX_MS, LIFECYCLE_PENDING_BASE_MS * 2 ** Math.max(0, passes - 1)); } -type ChangeOptions = { version?: number; owner?: string; reason?: string }; +type ChangeOptions = { version?: number; owner?: string; reason?: string; responsibleUserId?: string | null }; // Prepared drafts wait for the wizard; they have no background verification obligation. export const pendingLifecycleWork = and( @@ -119,6 +119,16 @@ async function changeLockedAgent(tx: Db, effects: LifecycleEffects, agent: Lifec agent.lifecycleRequiredPluginIds.some(id => !agent.lifecycleOperation!.completedPluginIds.includes(id)))) return null; if (command === "retry") { transition(agent.lifecycleState, command); + if (options.responsibleUserId && !agent.lifecycleOperation?.responsibleUserId) { + await effects.notifyWork(tx); + const [restarted] = await tx.update(agents).set({ lifecycleError: null, lifecycleVersion: agent.lifecycleVersion + 1, + lifecycleOperation: { ...agent.lifecycleOperation, id: randomUUID(), responsibleUserId: options.responsibleUserId, + hostComplete: false, completedPluginIds: [], attempts: 0, leaseOwner: undefined, leaseUntil: undefined, leaseHolder: undefined, + retryAt: undefined, retryRequired: undefined, verificationFailures: undefined, waitingForSignal: undefined, recheckRequested: undefined }, + updatedAt: new Date(), + }).where(eq(agents.id, agent.id)).returning(); + return restarted; + } if (agent.lifecycleOperation?.leaseUntil && Date.parse(agent.lifecycleOperation.leaseUntil) > Date.now()) { await effects.notifyWork(tx); const [requested] = await tx.update(agents).set({ lifecycleOperation: diff --git a/server/src/modules/agent-lifecycle/application/ports.ts b/server/src/modules/agent-lifecycle/application/ports.ts index a7e99599c30..f3d231aec59 100644 --- a/server/src/modules/agent-lifecycle/application/ports.ts +++ b/server/src/modules/agent-lifecycle/application/ports.ts @@ -14,7 +14,7 @@ export interface LifecycleAgent { export interface LifecycleStore { get(id: string): Promise; - change(id: string, command: LifecycleCommand, options?: { version?: number; owner?: string; reason?: string }): Promise; + change(id: string, command: LifecycleCommand, options?: { version?: number; owner?: string; reason?: string; responsibleUserId?: string | null }): Promise; claim(id: string, owner: string, now: Date): Promise; renew(agent: LifecycleAgent, owner: string, now: Date): Promise; setRequiredPlugins(agent: LifecycleAgent, owner: string, pluginIds: string[]): Promise; diff --git a/server/src/modules/agent-lifecycle/index.ts b/server/src/modules/agent-lifecycle/index.ts index 73222afe1b5..27ff9bf2144 100644 --- a/server/src/modules/agent-lifecycle/index.ts +++ b/server/src/modules/agent-lifecycle/index.ts @@ -106,8 +106,8 @@ export function createAgentLifecycle(db: Db, effects: LifecycleEffects) { assertRootDatabase(db); const records = agentRecords(db, effects); const store = createLifecycleStore(db, effects); - async function change(id: string, command: "pause" | "resume" | "terminate" | "retry", reason?: string) { - const result = await store.change(id, command, { reason }); + async function change(id: string, command: "pause" | "resume" | "terminate" | "retry", reason?: string, responsibleUserId?: string | null) { + const result = await store.change(id, command, { reason, responsibleUserId }); if (result) scheduleAgentLifecycle(db, id); return result ? records.getById(id) : null; } @@ -153,7 +153,7 @@ export function createAgentLifecycle(db: Db, effects: LifecycleEffects) { pauseAgent: (id: string, reason = "manual") => change(id, "pause", reason), resumeAgent: (id: string, reason = "user") => change(id, "resume", reason), terminateAgent: (id: string) => change(id, "terminate"), - retry: (id: string) => change(id, "retry"), + retry: (id: string, responsibleUserId?: string | null) => change(id, "retry", undefined, responsibleUserId), clearError: records.clearError, purgeAgent: (id: string) => purgeAgent(db, effects, id), }; diff --git a/server/src/routes/agents.ts b/server/src/routes/agents.ts index b5f5b534943..603f143bf0c 100644 --- a/server/src/routes/agents.ts +++ b/server/src/routes/agents.ts @@ -6053,6 +6053,7 @@ export function agentRoutes( const actor = getActorInfo(req); const updateOptions = { + responsibleUserId: responsibleUserForAiRequest(req), expectedConfigurationRevision, ...(runtimeSettings ? { expectedConfiguration: { adapterType: existing.adapterType, adapterConfig: existing.adapterConfig, @@ -6102,7 +6103,7 @@ export function agentRoutes( const existing = await getAccessibleAgent(req, res, id); if (!existing) return; await assertCanConfigureAgentSetup(req, existing); - const agent = await svcLifecycle.retry(id); + const agent = await svcLifecycle.retry(id, responsibleUserForAiRequest(req)); if (!agent) { res.status(404).json({ error: "Agent not found" }); return; } const actor = getActorInfo(req); await logActivity(db, { companyId: agent.companyId, actorType: actor.actorType, actorId: actor.actorId, From 8abbf84fc706fa04247d15210b936c9539755a2e Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Fri, 4 Dec 2026 18:24:02 -0600 Subject: [PATCH 6/6] fix(ui): stop coalescing native runner turns across consecutive agent replies (#23799) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agent chats and task threads assemble settled runs and reply bubbles through `TaskChatThread` and `ui/src/components/task-chat/transcript-adapter.ts`. > - Native Paperclip Runner turns set `standaloneHeader: true` and render an open chronological timeline (`beforeTurn`) above their reply bubble, including provider progress commentary such as "I'll check...". > - `coalesceSettledTurns` was designed for legacy collapsed "Worked" footers and merged back-to-back same-agent turns across intermediate agent bubbles, including native `standaloneHeader` turns and cross-task `send_chat_message` updates. > - When an agent completed several consecutive automated runs without an intervening user message, every earlier run's progress commentary moved off its original reply and piled up above the newest reply, making the commentary list stick to the bottom of the chat. > - `attachSettledTurns` also attached settled turns to any preceding same-agent bubble without checking anchor ownership, allowing unanchored native turns or turns with their own `finalResponse` to attach above an earlier reply or cross-task message. > - This pull request stops `coalesceSettledTurns` from merging `standaloneHeader` turns (and stops legacy coalescing across `fast_response` and `chatMessage` bubbles) and enforces explicit `anchorCommentId` ownership checks in `attachSettledTurns`. > - The benefit is that each native runner turn keeps its own commentary and timeline on its own reply bubble, while legacy collapsed footer coalescing keeps its existing behavior. ## Linked Issues or Issue Description **What happened?** In Agent Chat (and any task thread with consecutive native Paperclip Runner runs from the same agent), when an agent runs several times in a row without an intervening user message (for example, consecutive automated follow-up wakes and cross-task `send_chat_message` updates), every prior run's provider progress commentary (such as "I'll check the latest result...") is removed from its original reply and stacked together above the newest reply bubble. Whenever a new run finishes, the accumulated commentary block moves down again to the newest reply, making earlier "I'll check..." messages appear sticky at the bottom of the chat. **Expected behavior** Each native Paperclip Runner turn keeps its own chronological timeline and progress commentary attached only to its own reply bubble (or stays standalone in chronological order when unanchored). Earlier runs' commentary never accumulates or moves onto later replies. **Steps to reproduce** 1. Open a persistent Agent Chat or task thread for an agent running on the native Paperclip Runner with a provider that emits progress commentary (`channel: "progress"`). 2. Let the agent complete two or more consecutive runs without an intervening user message (for example, automated task-completion wakes with optional cross-task `send_chat_message` updates in between), with their settled transcripts loaded. 3. Observe that the earlier reply loses its own commentary and the newest reply renders every prior run's commentary stacked above its body. **Paperclip version or commit** Reproduced on `master` (commit `306437a2a5`). **Deployment mode** Self-hosted server ## What Changed - Require `anchorCommentId: string | null` on `SettledTurnMergeMeta` in `ui/src/components/task-chat/transcript-adapter.ts`, and populate it from `TaskChatThread` (`ui/src/components/TaskChatThread.tsx`) and `ui/src/components/design-sandbox/settled-preview-reply.ts`. - Update `coalesceSettledTurns` in `ui/src/components/task-chat/transcript-adapter.ts` so `standaloneHeader` (native Paperclip Runner) turns never coalesce across runs or replies, and so legacy turn coalescing stops at `origin: "fast_response"` and cross-task `chatMessage` bubbles. - Update `attachSettledTurns` in `ui/src/components/task-chat/transcript-adapter.ts` so turns carrying `finalResponse` never attach to a preceding bubble, cross-task `chatMessage` bubbles never accept an attached turn, and `standaloneHeader` turns attach only when `meta.anchorCommentId === prev.id`. - Add red-then-green regression tests in `ui/src/components/task-chat/transcript-adapter.test.ts` and `ui/src/components/TaskChatThread.test.tsx` covering consecutive native runner turns, interleaved cross-task `chatMessage` bubbles, `fast_response` boundaries, unanchored/mismatched `standaloneHeader` turns, and `finalResponse` turns. ## Verification - Confirmed red before the fix and green after the fix: - `pnpm vitest run ui/src/components/task-chat/transcript-adapter.test.ts ui/src/components/TaskChatThread.test.tsx` (failed 3 unit tests + 1 component test before the fix; passed after the fix). - `pnpm vitest run ui/src/components/task-chat/ ui/src/components/TaskChatThread.test.tsx ui/src/pages/IssueDetail.agentChatPanel.test.tsx` (30 test files passed, 962 passed, 1 skipped on latest head `13e71a2e58`). - `pnpm --filter @paperclipai/ui typecheck` (passed with 0 errors on latest head `13e71a2e58`). ## Risks Low risk. Legacy collapsed-footer turns (`standaloneHeader` falsy) keep their existing back-to-back coalescing behavior across consecutive replies from the same agent. Native `standaloneHeader` turns now remain scoped to their own reply bubble or chronological slot instead of merging across turns. ## Model Used - Google Gemini (Antigravity, high reasoning effort, with code inspection, file editing, test execution, and API diagnostics). ## 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 - [ ] 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 --- ui/src/components/TaskChatThread.test.tsx | 108 +++++++++++++ ui/src/components/TaskChatThread.tsx | 18 ++- .../design-sandbox/settled-preview-reply.ts | 2 +- .../task-chat/transcript-adapter.test.ts | 147 +++++++++++++++++- .../task-chat/transcript-adapter.ts | 27 +++- 5 files changed, 289 insertions(+), 13 deletions(-) diff --git a/ui/src/components/TaskChatThread.test.tsx b/ui/src/components/TaskChatThread.test.tsx index 1c6b3da2d1d..101d04d0152 100644 --- a/ui/src/components/TaskChatThread.test.tsx +++ b/ui/src/components/TaskChatThread.test.tsx @@ -6418,3 +6418,111 @@ it("explains a missing provider runtime with an installation repair", () => { expect(container.textContent).toContain("Reinstall or rebuild Paperclip"); expect(container.textContent).toContain("test the agent's runtime"); }); + +it("keeps each consecutive native runner turn's progress commentary on its own reply instead of stacking onto the latest message", () => { + nativeTranscriptState.transcriptByRun.set("codie-run-1", [ + assistantEntry("2026-12-04T17:18:17.000Z", "I'll check the setup task's final notes.", "progress"), + assistantEntry("2026-12-04T17:18:39.000Z", "PAP-7268 is complete (first update).", "final"), + ]); + nativeTranscriptState.transcriptByRun.set("codie-run-2", [ + assistantEntry("2026-12-04T17:52:43.000Z", "I'll check the latest saved result for PAP-7268.", "progress"), + assistantEntry("2026-12-04T17:53:12.000Z", "PAP-7268 is Done (second update).", "final"), + ]); + + const codie = { id: "agent-codie", name: "Codie", urlKey: "codie", icon: null } as unknown as Agent; + renderThread({ + issueId: "chat-codie", + conversationMode: true, + agentMap: new Map([[codie.id, codie]]), + comments: [ + { + id: "reply-1", + companyId: "company-1", + issueId: "chat-codie", + authorType: "agent", + authorAgentId: codie.id, + authorUserId: null, + body: "PAP-7268 is complete (first update).", + presentation: null, + metadata: null, + runId: "codie-run-1", + createdByRunId: "codie-run-1", + createdAt: new Date("2026-12-04T17:18:41.000Z"), + updatedAt: new Date("2026-12-04T17:18:41.000Z"), + }, + { + id: "cross-task-msg", + companyId: "company-1", + issueId: "chat-codie", + authorType: "agent", + authorAgentId: codie.id, + authorUserId: null, + body: "- Native recovery PR #23696 merged.", + presentation: null, + metadata: { + version: 1, + sections: [], + chatMessage: { + sourceTaskId: "task-7354", + sourceTaskIdentifier: "PAP-7354", + sourceRunId: "other-task-run", + contentHash: "hash-1", + }, + }, + runId: "other-task-run", + createdByRunId: "other-task-run", + createdAt: new Date("2026-12-04T17:35:00.000Z"), + updatedAt: new Date("2026-12-04T17:35:00.000Z"), + }, + { + id: "reply-2", + companyId: "company-1", + issueId: "chat-codie", + authorType: "agent", + authorAgentId: codie.id, + authorUserId: null, + body: "PAP-7268 is Done (second update).", + presentation: null, + metadata: null, + runId: "codie-run-2", + createdByRunId: "codie-run-2", + createdAt: new Date("2026-12-04T17:53:15.000Z"), + updatedAt: new Date("2026-12-04T17:53:15.000Z"), + }, + ], + onAdd: async () => {}, + linkedRuns: [ + { + runId: "codie-run-1", + runtimeMode: "native", + status: "succeeded", + agentId: codie.id, + agentName: "Codie", + adapterType: "paperclip_runner", + createdAt: "2026-12-04T17:17:24.000Z", + startedAt: "2026-12-04T17:17:24.000Z", + finishedAt: "2026-12-04T17:18:39.000Z", + execution: { phase: "completed", label: "Completed", canStop: false, cause: null, lastConfirmedActivityAt: null, retryAt: null, attempt: 1, maxAttempts: 3, recoveryOwner: null, nextAction: null, permittedActions: [], predecessorRunId: null, successorRunId: null }, + }, + { + runId: "codie-run-2", + runtimeMode: "native", + status: "succeeded", + agentId: codie.id, + agentName: "Codie", + adapterType: "paperclip_runner", + createdAt: "2026-12-04T17:52:00.000Z", + startedAt: "2026-12-04T17:52:00.000Z", + finishedAt: "2026-12-04T17:53:12.000Z", + execution: { phase: "completed", label: "Completed", canStop: false, cause: null, lastConfirmedActivityAt: null, retryAt: null, attempt: 1, maxAttempts: 3, recoveryOwner: null, nextAction: null, permittedActions: [], predecessorRunId: null, successorRunId: null }, + }, + ], + }); + + const firstCommentEl = container.querySelector("#comment-reply-1"); + const secondCommentEl = container.querySelector("#comment-reply-2"); + expect(firstCommentEl?.textContent).toContain("I'll check the setup task's final notes."); + expect(firstCommentEl?.textContent).not.toContain("I'll check the latest saved result for PAP-7268."); + expect(secondCommentEl?.textContent).toContain("I'll check the latest saved result for PAP-7268."); + expect(secondCommentEl?.textContent).not.toContain("I'll check the setup task's final notes."); +}); diff --git a/ui/src/components/TaskChatThread.tsx b/ui/src/components/TaskChatThread.tsx index 6f040a42e1e..e05880eedb6 100644 --- a/ui/src/components/TaskChatThread.tsx +++ b/ui/src/components/TaskChatThread.tsx @@ -2038,6 +2038,7 @@ export function TaskChatThread(props: TaskChatThreadProps) { turnMergeMetaById.set(turnId, { agentKey: meta?.agentId ?? "", agentName: meta?.agentName, + anchorCommentId: null, parts: [{ entries, durationMs, failed }], }); settledTurns.push({ @@ -2251,9 +2252,17 @@ export function TaskChatThread(props: TaskChatThreadProps) { Number.isFinite(segment.startMs) && Number.isFinite(segmentFinishedMs) ? Math.max(0, segmentFinishedMs - segment.startMs) : durationMs; + const anchorCommentId = segmented + ? null + : sourceIsPaperclipRunner + ? sourceHasPresentationComment + ? sourcePresentationCommentId + : null + : (lastCommentIdByRun.get(source.id) ?? null); turnMergeMetaById.set(turnId, { agentKey: meta?.agentId ?? "", agentName: meta?.agentName, + anchorCommentId, parts: [ { entries: segment.entries, durationMs: segmentDurationMs, failed }, ], @@ -2283,13 +2292,7 @@ export function TaskChatThread(props: TaskChatThreadProps) { failed, }), }, - anchorCommentId: segmented - ? null - : sourceIsPaperclipRunner - ? sourceHasPresentationComment - ? sourcePresentationCommentId - : null - : (lastCommentIdByRun.get(source.id) ?? null), + anchorCommentId, // A post-steering segment ties the acknowledgement-backed human // bubble and is therefore inserted immediately after it. The first // segment retains the normal run-start slot. @@ -2346,6 +2349,7 @@ export function TaskChatThread(props: TaskChatThreadProps) { turnMergeMetaById.set(turnId, { agentKey: liveRun.agentId ?? "", agentName: liveRun.agentName, + anchorCommentId: null, parts: [ { entries: segment.entries, diff --git a/ui/src/components/design-sandbox/settled-preview-reply.ts b/ui/src/components/design-sandbox/settled-preview-reply.ts index 1c5b06149a4..02c294cc802 100644 --- a/ui/src/components/design-sandbox/settled-preview-reply.ts +++ b/ui/src/components/design-sandbox/settled-preview-reply.ts @@ -9,5 +9,5 @@ export function settledPreviewReply(response: TaskChatMessageItem, entries: Para id: `${runId}:turn`, kind: "turn", settled: true, historical: true, items: settledRunChildren(parsed), summary: buildTurnSummary(entries, { durationMs, failed }), }; - return attachSettledTurns([response, turn], new Map([[turn.id, { agentKey: "synthetic-agent", agentName: response.authorName, parts: [{ entries, durationMs, failed }] }]])); + return attachSettledTurns([response, turn], new Map([[turn.id, { agentKey: "synthetic-agent", agentName: response.authorName, anchorCommentId: null, parts: [{ entries, durationMs, failed }] }]])); } diff --git a/ui/src/components/task-chat/transcript-adapter.test.ts b/ui/src/components/task-chat/transcript-adapter.test.ts index 0518129503f..a3cd3c582b0 100644 --- a/ui/src/components/task-chat/transcript-adapter.test.ts +++ b/ui/src/components/task-chat/transcript-adapter.test.ts @@ -2558,6 +2558,7 @@ describe("coalesceSettledTurns (PAP-362)", () => { { agentKey: "agent-1", agentName: "CEO", + anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }], }, ], @@ -2566,6 +2567,7 @@ describe("coalesceSettledTurns (PAP-362)", () => { { agentKey: "agent-1", agentName: "CEO", + anchorCommentId: null, parts: [{ entries: runB, durationMs: 15_000 }], }, ], @@ -2628,6 +2630,7 @@ describe("coalesceSettledTurns (PAP-362)", () => { otherAgent.set("run-b:turn", { agentKey: "agent-2", agentName: "QA", + anchorCommentId: null, parts: [{ entries: runB }], }); const sameShape: TaskChatItem[] = [ @@ -2643,8 +2646,8 @@ describe("coalesceSettledTurns (PAP-362)", () => { it("lets another agent's chat message end the merge when runs carry no display name", () => { const unnamed = new Map([ - ["run-a:turn", { agentKey: "agent-1", parts: [{ entries: runA, durationMs: 30_000 }] }], - ["run-b:turn", { agentKey: "agent-1", parts: [{ entries: runB, durationMs: 15_000 }] }], + ["run-a:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }] }], + ["run-b:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runB, durationMs: 15_000 }] }], ]); const fromAgent = (id: string, agentId: string, authorName: string): TaskChatItem => ({ id, kind: "message", author: "agent", authorName, agent: { id: agentId }, text: "Note.", @@ -2693,6 +2696,89 @@ describe("coalesceSettledTurns (PAP-362)", () => { (merged[0] as Extract).animateFold, ).toBe(true); }); + + it("never coalesces standaloneHeader (native runner) turns across consecutive replies", () => { + const nativeTurn = (id: string, commentary: string): TaskChatItem => ({ + id, + kind: "turn", + settled: true, + historical: true, + standaloneHeader: true, + items: [ + { + id: `${id}:phase:0`, + kind: "activity_phase", + active: false, + summary: "", + interstitial: { + id: `${id}:interstitial:0`, + kind: "message", + author: "agent", + channel: "progress", + interstitial: true, + text: commentary, + }, + items: [], + }, + ], + summary: buildTurnSummary([], { durationMs: 10_000 }), + }); + const nativeMeta = new Map([ + ["run-1:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-1", parts: [{ entries: [], durationMs: 10_000 }] }], + ["run-2:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-2", parts: [{ entries: [], durationMs: 12_000 }] }], + ]); + const items: TaskChatItem[] = [ + { id: "msg-1", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "First update.", sourceRunId: "run-1" }, + nativeTurn("run-1:turn", "I'll check the setup task's final notes."), + { id: "msg-2", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "Second update.", sourceRunId: "run-2" }, + nativeTurn("run-2:turn", "I'll check the latest saved result for PAP-7268."), + ]; + const out = coalesceSettledTurns(items, nativeMeta); + expect(out.map((i) => i.id)).toEqual(["msg-1", "run-1:turn", "msg-2", "run-2:turn"]); + const firstTurn = out[1] as Extract; + const secondTurn = out[3] as Extract; + expect(firstTurn.items).toHaveLength(1); + expect(secondTurn.items).toHaveLength(1); + }); + + it("does not coalesce legacy turns across fast_response or cross-task chatMessage bubbles", () => { + const withFastResponse: TaskChatItem[] = [ + agentBubble("msg-a"), + turn("run-a:turn", runA, 30_000), + { id: "msg-fr", kind: "message", author: "agent", authorName: "CEO", origin: "fast_response", text: "On it." }, + agentBubble("msg-b"), + turn("run-b:turn", runB, 15_000), + ]; + expect(coalesceSettledTurns(withFastResponse, metaById).map((i) => i.id)).toEqual([ + "msg-a", + "run-a:turn", + "msg-fr", + "msg-b", + "run-b:turn", + ]); + + const withChatMessage: TaskChatItem[] = [ + agentBubble("msg-a"), + turn("run-a:turn", runA, 30_000), + { + id: "msg-cross", + kind: "message", + author: "agent", + authorName: "CEO", + text: "Merged PR #123.", + chatMessage: { sourceTaskId: "task-1", sourceTaskIdentifier: "PAP-7354", sourceRunId: "other-run", contentHash: "abc" }, + }, + agentBubble("msg-b"), + turn("run-b:turn", runB, 15_000), + ]; + expect(coalesceSettledTurns(withChatMessage, metaById).map((i) => i.id)).toEqual([ + "msg-a", + "run-a:turn", + "msg-cross", + "msg-b", + "run-b:turn", + ]); + }); }); describe("attachSettledTurns (round 9)", () => { @@ -2725,6 +2811,7 @@ describe("attachSettledTurns (round 9)", () => { { agentKey: "agent-1", agentName: "CEO", + anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }], }, ], @@ -2771,7 +2858,7 @@ describe("attachSettledTurns (round 9)", () => { it("matches the bubble's agent ID when the run carries no display name", () => { const unnamed = new Map([ - ["run-a:turn", { agentKey: "agent-1", parts: [{ entries: runA, durationMs: 30_000 }] }], + ["run-a:turn", { agentKey: "agent-1", anchorCommentId: null, parts: [{ entries: runA, durationMs: 30_000 }] }], ]); const fromAgent = (agentId: string, authorName: string): TaskChatItem => ({ id: `msg-${agentId}`, kind: "message", author: "agent", authorName, agent: { id: agentId }, text: "Done.", @@ -2808,6 +2895,59 @@ describe("attachSettledTurns (round 9)", () => { (twice[0] as Extract).attachedTurn?.id, ).toBe("run-a:turn"); }); + + it("never attaches an unanchored or mismatched standaloneHeader turn, finalResponse turn, or cross-task chatMessage bubble", () => { + const standaloneTurn = (id: string, extra?: Partial): TaskChatTurnItem => ({ + id, + kind: "turn", + settled: true, + standaloneHeader: true, + items: [], + summary: buildTurnSummary([], { durationMs: 10_000 }), + ...extra, + }); + const meta = new Map([ + ["run-unanchored:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: null, parts: [] }], + ["run-anchored:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-1", parts: [] }], + ["run-other:turn", { agentKey: "codie", agentName: "Codie", anchorCommentId: "msg-2", parts: [] }], + ]); + const bubble1: TaskChatItem = { + id: "msg-1", kind: "message", author: "agent", authorName: "Codie", agent: { id: "codie" }, text: "First reply.", sourceRunId: "run-1", + }; + + // Unanchored native turn after an earlier reply stays standalone (must not invert above msg-1). + const unanchoredOut = attachSettledTurns([bubble1, standaloneTurn("run-unanchored:turn")], meta); + expect(unanchoredOut.map((i) => i.id)).toEqual(["msg-1", "run-unanchored:turn"]); + + // Mismatched anchorCommentId native turn stays standalone. + const mismatchedOut = attachSettledTurns([bubble1, standaloneTurn("run-other:turn")], meta); + expect(mismatchedOut.map((i) => i.id)).toEqual(["msg-1", "run-other:turn"]); + + // Turn carrying its own finalResponse never attaches to a preceding bubble. + const withFinal = standaloneTurn("run-anchored:turn", { + finalResponse: { id: "final-1", kind: "message", author: "agent", text: "Own final." }, + }); + const finalOut = attachSettledTurns([bubble1, withFinal], meta); + expect(finalOut.map((i) => i.id)).toEqual(["msg-1", "run-anchored:turn"]); + + // Cross-task send_chat_message bubble never accepts an attached turn. + const crossTaskBubble: TaskChatItem = { + id: "msg-1", + kind: "message", + author: "agent", + authorName: "Codie", + agent: { id: "codie" }, + text: "Merged PR #123.", + chatMessage: { sourceTaskId: "task-1", sourceTaskIdentifier: "PAP-7354", sourceRunId: "other-run", contentHash: "abc" }, + }; + const crossOut = attachSettledTurns([crossTaskBubble, standaloneTurn("run-anchored:turn")], meta); + expect(crossOut.map((i) => i.id)).toEqual(["msg-1", "run-anchored:turn"]); + + // Matching anchored native turn attaches cleanly to its own reply bubble. + const matchedOut = attachSettledTurns([bubble1, standaloneTurn("run-anchored:turn")], meta); + expect(matchedOut).toHaveLength(1); + expect((matchedOut[0] as Extract).attachedTurn?.id).toBe("run-anchored:turn"); + }); }); describe("assembleThreadItems (PAP-367)", () => { @@ -2899,6 +3039,7 @@ describe("assembleThreadItems (PAP-367)", () => { { agentKey: "agent-1", agentName: "CEO", + anchorCommentId: null, parts: [{ entries: [toolCall("Read")], durationMs: 34_000 }], }, ], diff --git a/ui/src/components/task-chat/transcript-adapter.ts b/ui/src/components/task-chat/transcript-adapter.ts index 78e07f84359..ed7abee71b1 100644 --- a/ui/src/components/task-chat/transcript-adapter.ts +++ b/ui/src/components/task-chat/transcript-adapter.ts @@ -2498,6 +2498,12 @@ export interface SettledTurnMergeMeta { agentKey: string; /** Display name, used to keep another agent's bubble from bridging a merge. */ agentName?: string; + /** + * Explicit reply comment id this turn anchored to (`null` = unanchored). + * Keeps unanchored or mismatched standaloneHeader turns from attaching above + * an earlier agent bubble and inverting chronology. + */ + anchorCommentId: string | null; parts: TurnSummaryPart[]; } @@ -2542,6 +2548,15 @@ export function coalesceSettledTurns( let heldIdx = -1; // index in `out` of the last mergeable settled turn for (const item of items) { if (item.kind === "turn" && item.settled) { + // Paperclip Runner turns own an open chronological timeline rendered + // above their reply bubble (`beforeTurn`), including progress commentary. + // Never coalesce them across runs or replies: doing so steals earlier + // runs' timelines and stacks every prior commentary onto the newest reply. + if (item.standaloneHeader) { + out.push(item); + heldIdx = -1; + continue; + } const meta = metaFor(item.id); const held = heldIdx >= 0 ? (out[heldIdx] as TaskChatTurnItem) : null; const heldMeta = held ? metaFor(held.id) : undefined; @@ -2572,7 +2587,12 @@ export function coalesceSettledTurns( continue; } out.push(item); - if (item.kind === "message" && item.author === "agent") { + if ( + item.kind === "message" && + item.author === "agent" && + item.origin !== "fast_response" && + !item.chatMessage + ) { // The same agent's reply bubble sits between its runs — keep merging // across it. A different agent's bubble ends the run of turns. const heldMeta = @@ -2608,15 +2628,18 @@ export function attachSettledTurns( if ( item.kind === "turn" && item.settled && + !item.finalResponse && prev?.kind === "message" && prev.author === "agent" && prev.origin !== "fast_response" && + !prev.chatMessage && !prev.interstitial && !prev.streaming && prev.attachedTurn == null ) { const meta = metaById.get(item.id); - if (meta != null && sameTurnAgent(meta, prev)) { + const standaloneOwnershipMatches = !item.standaloneHeader || meta?.anchorCommentId === prev.id; + if (meta != null && sameTurnAgent(meta, prev) && standaloneOwnershipMatches) { out[out.length - 1] = { ...prev, attachedTurn: item }; continue; }