Skip to content

Release v0.16.2 — Private spaces, Drive mentions in chat, and steadier chats - #12922

Merged
DimitrijeGlibic merged 85 commits into
prodfrom
release/v0.16.2
Nov 20, 2026
Merged

DimitrijeGlibic merged 85 commits into
prodfrom
release/v0.16.2

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Private spaces, Drive mentions in chat, and steadier chats

New

Improved

Fixed

Security

Internal

sutharjay1 and others added 30 commits November 19, 2026 20:39
…aults; centered settings (#12881)

## Demo video

**Web, Workspace settings (General → Security → Branding → General),
1440×900, Kortix light then Kortix dark: content is centered in the
pane, and the promo card floats in the bottom-right corner with a
layered shadow.**


https://github.com/user-attachments/assets/e08c1dda-baea-4cb6-9ad8-239781a51cdd

## Quick verification

Outcome: gray text and status colors pass contrast in light mode, Kortix
light / Kortix dark are the default themes, workspace settings content
is centered, and the promo card floats bottom-right on desktop.

- **Gray text:** 404 `text-muted-foreground/NN` and
`text-foreground/≤60` classes are now `text-muted-foreground`. Worst
case on the light sidebar went from 1.51:1 to 5.22:1. Hover states that
would have matched their base color now go to `text-foreground`. Most
visible in a session's tool rows, the file viewer and the command
palette.
- **Status colors (brand decision J-7):** each `kortix-*` accent has a
light and a dark value. Light green `#037225` and red `#c21425` reach
4.55:1 on `#dedede` (the darkest light fill), so `+12 / −3` counters
pass on hovered and selected rows. Orange, yellow, blue and purple reach
3:1 on `#e6e6e6`. Dark mode keeps the old values. Mobile is unchanged
(`mobile_value`).
- **Themes:** new users get Kortix light (`light`) and Kortix dark
(`dark`). "Pure light" and "Pure dark" stay selectable. Saved
preferences keep their stored id. Labels are updated in all 9 locales;
the desktop shell's launch background follows.
- **Settings:** open `/workspaces/<id>/admin/general` on a wide window;
the content block has equal margins (measured 225 px / 224 px at 1440
px). Account panes (Members, Roles, Usage …) are centered the same way.
- **Promo card:** on desktop it floats bottom-right, portaled to
`<body>`, with `smooth-shadow-ring-lg`. It never renders on chat, DM,
channel or Spaces pages, and shows on home or a single session only from
a 1700 px window. Phones keep it in the sidebar sheet.
- Checks run: `apps/web` and `@kortix/ui` typecheck 0 errors; ESLint 0
errors on changed files; `generate-tokens.ts --check` no drift; targeted
tests pass (`@kortix/ui` 154, `apps/web` 48 + 34, `desktop-electron`
20); browser check on the local stack shows no hydration error. Reviewed
with sol-loop (GPT Sol, medium): approved.
- Not affected: migrations, API, IAM, billing, mobile native code.



<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/enable-autofix?expires=1797692735&installation_model_id=434224&pr_number=12881&ref=codesmith_pr_footer&repository=kortix-ai%2FCompanyOS&return_to=https%3A%2F%2Fgithub.com%2Fkortix-ai%2FCompanyOS%2Fpull%2F12881&signature=b532fddb77862fedf30b680dde5f924c09405834741027427bc96caa5170b2f2"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/kortix-ai/codesmith/CompanyOS/pr/12881?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->
…KRTX-4882) (#12696)

## Review in 60 seconds

- KRTX-4882 incident guard: serialize the three cost-explorer window
reads per API replica. Three reads can wait without a DB connection;
overflow returns typed `429 cost_read_busy` with Retry-After: 5.
- The existing cost-explorer query policy retries overflow responses.
This feedback fixes the SDK error classification: only `429
cost_read_busy` skips global onError. Callers still receive the complete
ApiError. Other 429s and a 500 carrying that code still report.
- The permit remains held until the actual read settles, even if the API
deadline has already answered. This prevents overlapping orphaned window
scans, not all pool contention.

No demo video: code-only change. API admission and SDK transport error
classification; the existing packages/ui query retry policy is included,
but no layout or component rendering changed. Browser behavior is
unverified.

**Risk:** medium — serialized reads can delay the heatmap. Twenty query
retries are bounded and do not guarantee every row completes under
sustained load. A single admitted summary can occupy all six pool
connections. This is not a statement timeout or query-speed fix.

**Verified:** SDK HTTP tests 283 pass, 0 fail; new regression 3 pass, 0
fail (previously 2 pass, 1 fail); SDK typecheck exit 0; API guard/route
tests 6/10/33/23 pass, 0 fail; UI billing query tests 18 pass, 0 fail;
route coverage 0 uncovered. Local stack startup failed: Supabase REST
cannot load missing kortix schema; no production benchmark performed.

suna-skills: worktree, testing, learnings, contributing, sdk
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed

Refs KRTX-4882. This PR implements the incident containment scope agreed
in the issue comments. It does not satisfy the original 30-day
under-10-second requirement. The speed-up is tracked separately by
KRTX-4903; do not close KRTX-4882 as a proven speed-up.

## Summary

The latest G9 numbered requests are addressed: expected busy responses
no longer generate global error toasts, and the body explicitly
describes the included packages/ui retry policy rather than claiming no
UI-package changes. Earlier replica-wide bound and OpenAPI 429 fixes
remain intact.

## Demo video

No demo video: code-only change. No visual evidence claimed.

## Type of change

fix(api/sdk): bounded cost-read admission and expected busy response
handling.

## What is affected

`/v1/usage/session-costs`, `/cost-by-project` JSON/CSV, `/cost-summary`;
packages/ui cost query retry configuration; SDK HTTP error reporting. No
migration or public export change.

## How was this tested?

All commands below ran in this session. Targeted suites were rerun after
merging origin/dev.

```text
cd packages/sdk && bun test src/core/http/cost-read-busy.test.ts
Before fix: 2 pass, 1 fail; expected 0 global reports, received 1.
After fix: 3 pass, 0 fail; 18 expect() calls.

cd packages/sdk && bash scripts/test.sh src/core/http
283 pass; 0 fail (sum of isolated file summaries).

pnpm --filter @kortix/sdk typecheck
exit 0 (package and examples tsgo).

cd apps/api && bun test --env-file=scripts/test.env src/shared/cost-read-guard.test.ts
6 pass; 0 fail.
cd apps/api && bun test --env-file=scripts/test.env src/router/routes/usage-cost-summary-http.test.ts
10 pass; 0 fail.
cd apps/api && bun test --env-file=scripts/test.env src/router/routes/usage-session-costs-http.test.ts
33 pass; 0 fail.
cd apps/api && bun test --env-file=scripts/test.env src/router/routes/usage-cost-by-project-http.test.ts
23 pass; 0 fail.

cd packages/ui && bun test src/internal/billing/use-cost-explorer.test.ts src/internal/billing/use-session-costs.test.ts
18 pass; 0 fail.

bun tests/bin/ke2e.ts coverage → 95.9% covered · 1740/1814 routes · 74 allowlisted · 0 uncovered

node_modules/.bin/biome lint packages/sdk/src/core/http/cost-read-busy.test.ts
Checked 1 file. No fixes applied.

cd packages/sdk && ../../node_modules/.bin/eslint src/core/http/response-error.ts src/core/http/cost-read-busy.test.ts
Not available: SDK has no eslint.config file. Exit 2; no lint success claimed.

pnpm --filter @kortix/sdk run smoke:install
OK: @kortix/sdk imports and constructs from the packed tarball
✔ install smoke test passed

git diff --check
exit 0.
```

Local stack: `pnpm worktree start krtx-4882 --no-web --no-tunnel` exits
1: primary Supabase REST answers 503 because schema kortix does not
exist. No HTTP smoke or browser demo claimed.

Logs are retained in the worker session under /workspace/out. No whole
monorepo/package test run: current repository instructions require named
affected files only. Production timing, DB EXPLAIN integration suites
and browser/desktop behavior are not verified. No SQL changes were made,
so EXPLAIN assertions remain unchanged by inspection.

## Security & data review

Synthetic data only. Only the exact HTTP status/code pair suppresses
global reporting; the error remains available to callers. No
authorization change.

## Rollout / rollback

Revert this PR. No schema or configuration changes. After deployment,
verify the deployed commit before performing one read-only cost request;
do not loop benchmarks against production.

## Reviewer checklist

- SDK regression fails before classification change and preserves
status, code and payload afterward.
- Other rate limits and server errors still invoke onError.
- Existing replica-wide guard remains bounded and releases in finally.
- G8 contract coverage command and its real 0 uncovered output are on
the same line.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
… (KRTX-4929) (#12728)

## Review in 60 seconds

- Invalid git refs and hashes return HTTP 400 instead of an unhandled
500 (KRTX-4929). Production evidence identifies `readRepoFileBytes`
through the project file route.
- Branch settings reject option-shaped values before persistence. The
mirror terminates `git log` option parsing before revisions, protecting
previously stored values too.
- Regression checks reproduced the unsafe settings write and a synthetic
host-file overwrite before the fix. Both pass after it; local HTTP
settings read-back passes.

No demo video: code-only change

**Risk:** low — Safe branches need not exist upstream; that preserves
database-only and temporarily unreachable project settings. Revert this
PR to roll back. No migration or SDK export change.
**Verified:** 79 pass, 0 fail across six targeted API test files; API
typecheck exit 0; changed-source eslint exit 0 (test files are ignored
by repository config); local PROJ-7 1/1 passed. Whole-package tests not
run per repository testing policy.

suna-skills: worktree, testing, learnings, contributing, create-pr
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed

## Demo video

No demo video: code-only change

## Quick verification

Outcome: malformed refs return a non-paging client error; unsafe default
branches cannot become `git log` options. Fixes KRTX-4929:
https://linear.app/kortix/issue/KRTX-4929.

## How was this tested?

```text
$ cd apps/api && bash scripts/test.sh src/__tests__/unit-git-ref.test.ts src/projects/routes/project-detail-icon-patch.test.ts src/projects/routes/project-detail-glyph-patch.test.ts src/projects/git/mirror-view-stale.test.ts src/projects/git/mirror-transient.test.ts src/projects/git/mirror-invalidated-flight.test.ts
 79 pass
 0 fail
 260 expect() calls
Ran 79 tests across 6 files. [3.96s]

$ pnpm --filter kortix-api typecheck
> tsgo --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsgo.tsbuildinfo
exit 0

$ cd apps/api && pnpm exec eslint src/shared/git-ref.ts src/__tests__/unit-git-ref.test.ts src/projects/routes/project-detail.ts src/projects/routes/project-detail-icon-patch.test.ts src/projects/git/mirror.ts src/projects/git/mirror-view-stale.test.ts
0 errors, 3 warnings (the three test files are ignored by repository config)
exit 0

$ . scripts/hermetic-test-env.sh; pnpm test -- --id PROJ-7
✓ [1/1] PASS PROJ-7 0.9s
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 1.5s
```

Red checks performed in this session: original shared validator: 6 pass,
1 fail; settings handler before validation: 22 pass, 1 fail (expected
400, received 200); mirror before option termination: 5 pass, 1 fail
(synthetic file replaced by tree hash). The final HTTP flow PATCHes both
branch aliases, receives 400, then GET proves the branch remains
`release`.

The worktree stack started with local Supabase and API. The initial root
flow attempt inherited incompatible archive configuration; rerunning
with the repository hermetic environment passed. No production request
was mutated. Better Stack read-only evidence confirms six occurrences at
07:52 UTC on Nov 14: project file route → readRepoFileBytes →
validateRef. The 24-hour zero-occurrence acceptance remains unverified
until deployment to prod.

Confirm after prod: application 2346961, pattern
`2e6c429f48f743931b165e8d1e9e49cd242a419cb8085abde1319dcf36dfdcd0` must
have zero new occurrences for 24 h. Only the merge gate resolves Better
Stack after prod carries the fix.

## Summary

Return 400 for rejected git input and close the reviewed default-branch
option-injection path.

## Type of change

- [x] Bug fix (API)

## Security & data review

No production writes or customer data. The git injection regression uses
a temporary synthetic file.

## Rollout / rollback

No migration. Revert the PR. Observe the named Better Stack pattern
after prod deployment.

## Reviewer checklist

- [x] Red/green regression checks executed.
- [x] Real HTTP settings flow passed.
- [x] No new dependency, type escape, or SDK export.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
)

## Review in 60 seconds

- **What:** Markdown pasted into a doc (an artifact doc, or an agent's
instructions) now opens as formatting: `- ` lists, `#### ` headings,
`**bold**`, links, quotes and fences, the same as when it is typed or
when the file opens. Before, a pasted clipboard stayed literal text, and
the saved file even escaped it (`\- bullet one`, `\#### jay`). This is
Jay's report in #kortix-triage.
- **Why it broke:** the shared doc editor
(`packages/ui/src/markdown/doc-editor/doc-extensions.tsx`) converts
Markdown only when a file opens (`markdownToHtml`) and through typed
input rules. ProseMirror runs no input rules on paste, so a plain-text
clipboard, or a code editor's unformatted HTML lines, became plain
paragraphs.
- **Fix:** a new `MarkdownPaste` extension
(`packages/ui/src/markdown/doc-editor/doc-paste.ts`), one line in
`docExtensions`. When the pasted text contains real Markdown syntax
(checked with marked's lexer) it pastes `markdownToHtml(text)` through
ProseMirror's own HTML paste, so the existing paste sanitizer
(`PastedMarkdownSource`) still runs. Shift+paste, a paste inside a code
block and a clipboard with formatted HTML (a web page, another doc)
behave exactly as before.


https://github.com/user-attachments/assets/2498bbc0-221c-44b0-bdcc-9c2e4403dac9

**Walkthrough** (harness: the shared Kortix doc editor the artifact page
mounts, `docExtensions` + `ARTIFACT_DOC_CSS`, rendered with
`@tiptap/react` like the existing artifact page editor, not the full
app; real Ctrl+V / Ctrl+Shift+V through the browser clipboard. Left =
the same extensions without `markdownPaste`, i.e. origin/dev.)
1. Empty docs. ![step
1](https://github.com/user-attachments/assets/420680b3-0003-4be0-adc4-ef37dbf276bb)
2. Ctrl+V of Jay's exact text: left stays `- ` / `####` text and saves
`\- bullet one`; right becomes a list, a heading and bold and saves
clean Markdown. ![step
2](https://github.com/user-attachments/assets/1efbf82d-7c37-410b-aff2-b05ddf5a6e40)
3. Ctrl+Shift+V on the right: pasted as typed, literal. ![step
3](https://github.com/user-attachments/assets/b9fd2189-6397-4ccf-89e1-d6f3d9589467)
4. Ctrl+V of a code-editor clipboard (`text/plain` + unformatted
`text/html`, confirmed from the paste event): heading, list, inline code
and link. ![step
4](https://github.com/user-attachments/assets/b66d5c77-d2a8-454f-a244-994a0c3dd3c5)

**Risk:** low — paste-only behavior in the shared doc editor;
Shift+paste, code blocks and formatted HTML clipboards keep today's
path; one-commit revert.
**Verified:** `bun test src/markdown/doc-editor` 139 pass 0 fail; the 2
bug tests fail before the fix and pass after; `pnpm --filter @kortix/ui
test` has 20 failures that are identical on origin/dev without this
change (pre-existing, listed below); eslint clean; typecheck clean
except one pre-existing origin/dev error; browser demo on the harness.
Not run: the full app stack (`next dev` was OOM-killed on this 11 GB
sandbox earlier), so the artifact page itself was not recorded.
suna-skills: worktree, testing, learnings, kortix-design-system
Self-review: 3 items found and fixed

## Summary

Pasting Markdown into a Kortix doc now formats it, as typing it already
did. Before this change, Jay pasted a list, a `####` heading and
`**bold**` into an artifact doc on dev.kortix.com and saw the raw
symbols. The artifact page
(`apps/web/src/features/artifacts/doc-editor.tsx`, existing, unchanged)
and agent instructions share `docExtensions`, so both get the fix. The
artifact page's own existing `handlePaste` (media files, a lone
GitHub/Linear link) runs first as before: it returns false for text, so
it is unaffected.

Closes KRTX-4947

## Demo video

The video and step screenshots are in **Review in 60 seconds** above
(harness, clearly labelled; not the full app).

## Type of change

- [x] Bug fix (non-breaking)

## What is affected

- Affected: paste into any doc built from `docExtensions`: artifact docs
and agent instructions.
- Not affected: typing, opening and saving files (byte-for-byte fidelity
tests all pass), media and link pastes, Shift+paste, pastes into code
blocks, rich HTML pastes, any other editor.

## Verification

| Command / scenario | Result | What it proves |
| --- | --- | --- |
| `bun test src/markdown/doc-editor` (packages/ui) | PASS 139 / 0 | fix
+ no doc fidelity regression |
| Same 7 paste tests without the extension | 2 FAIL (the bug) / 5 PASS
(guards) | tests catch the bug |
| `pnpm test` (packages/ui), with vs without the change at origin/dev
ee14eb3 | 20 identical pre-existing failures | no new failure |
| Real Ctrl+V / Ctrl+Shift+V in Chromium on the harness | PASS | the
conversion works in a real browser paste |

## How was this tested?

Regression tests first, red without the extension (`doc-paste` present,
`docExtensions` not using it):
```
$ bun test src/markdown/doc-editor/doc-fidelity.test.ts -t 'pasted Markdown'   # before the fix
(fail) a plain-text clipboard becomes a list, a heading and bold
(fail) a code editor clipboard (unformatted HTML lines) becomes formatting too
(pass) inline Markdown pasted mid-sentence stays in that paragraph
(pass) Shift+paste keeps the text exactly as typed
(pass) a paste inside a code block keeps the Markdown as code
(pass) a formatted HTML clipboard keeps its own formatting
(pass) plain prose pastes as it did before
```
With the fix, the whole doc editor directory:
```
$ cd packages/ui && bun test src/markdown/doc-editor
 139 pass
 0 fail
Ran 139 tests across 5 files. [3.76s]
```
Whole package suite (pre-existing failures, identical on origin/dev
without this change):
```
$ pnpm test   # packages/ui, before rebase
 9502 pass
 21 fail
Ran 9523 tests across 862 files. [504.67s]
$ bun test --isolate <the 13 failing files> src/markdown/doc-editor   # rebased on origin/dev ee14eb3
with this change:     285 pass, 20 fail
origin/dev (reverted): 277 pass, 20 fail   (same 20 failing tests; the +8 are this PR's tests)
```
Pre-existing: `pnpm --filter @kortix/ui test` fails the same at
origin/dev (exports map missing toast-clearance, module layers
use-reduced-motion, kortix-ui skill docs, connectors chunk, git-view
autosave, copy-block, composer-underbar, transcript, peer-message-row,
panel mode gate, gateway logs, schedule sheet, new-entity-menu).
Pre-existing: `pnpm typecheck` (packages/ui) fails the same at
origin/dev:
`src/customize/connectors/connector-identity.test.tsx(33,81): error
TS2352`; no error in the changed files.
```
$ npx eslint src/markdown/doc-editor/doc-paste.ts src/markdown/doc-editor/doc-extensions.tsx src/markdown/doc-editor/doc-fidelity.test.ts
(exit 0, no findings)
```

## Security & data review

No data, auth or secrets touched. Pasted Markdown goes through
`markdownToHtml` and then ProseMirror's HTML paste, so
`PastedMarkdownSource` still strips `data-md` / raw-block markers and
the schema's `SafeAttributes` still apply. Text containing HTML tags is
never converted (it stays literal), so a paste cannot introduce a raw
HTML block. Synthetic text only in the demo.

## Rollout / rollback

Ships with the web app; no flag, migration or env var. Rollback: revert
this commit.

## Reviewer checklist

1. `packages/ui/src/markdown/doc-editor/doc-paste.ts`: the paste guard
order (Shift, code block, `isMarkdown`, formatted HTML), and the
event-less `view.pasteHTML` that avoids re-entering the handler.
2. `isMarkdown`: false positives on plain prose (indented text, bare
URLs and `2 * 3` stay literal; covered by tests).
3. Shift tracking mirrors ProseMirror's own `input.shiftKey` rule
(Shift+Insert counts as a normal paste).

## Reviewer focus

The import cycle `doc-extensions → doc-paste → markdown →
doc-extensions` is runtime-lazy (`markdownToHtml` is only called at
paste time); `module boundaries > no import cycle spans two top-level
modules` passes.

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…KRTX-4944) (#12801)

## Review in 60 seconds

- A message sent from the workspace home with an attachment sometimes
stayed in the new chat's composer (Send enabled, survives a reload, one
click re-sends it). Cause: the home composer keeps the sent text on
screen while the session is created, and when the attachment list
changed afterwards (the send releasing its upload, or an upload
finishing after Send) the draft saver stored that on-screen text as an
unsent draft; the home-to-session handoff then moved it into the new
session's composer. It only happened when that re-render landed before
the page switched, so it looked random.
- Fix in the shared draft hook `useComposerDraft`
(`packages/ui/src/session/composer/draft/use-composer-draft.ts`): at
Send it remembers what the send left on screen (document, quotes, tiles)
and skips a save of exactly that. The first real change (typing,
clearing, a new quote) or a refused send ends the guard; `composer.tsx`
reports the refusal (`sendRefused()` in `onFailed`). Text typed while a
send is in flight is still saved and handed to the new chat.
- Regression tests in `use-composer-draft.test.tsx` (new, 8 cases): both
attachment paths fail on origin/dev; text-only, typed-during-send,
refused-send recovery, a retyped command, an added quote and a file
added after a refused send are covered.


https://github.com/user-attachments/assets/81fae9bd-07df-4161-8c37-6e51ce1cf4f2

**Walkthrough**
1. Before the fix (origin/dev hook on the same local stack, real
capture): after Send with `notes.txt` attached, the chat's composer
still holds the sent text. ![Step
1](https://github.com/user-attachments/assets/e6e9812e-e718-424a-9863-54fc23876318)
2. With the fix: project home, `notes.txt` attached, message typed.
![Step
2](https://github.com/user-attachments/assets/6935f494-ee78-497d-947d-a0b344bbc0cc)
3. After Send: the new chat shows the message and the reply; the
composer is empty (placeholder, Send disabled). ![Step
3](https://github.com/user-attachments/assets/2b768383-dca0-4bfb-b567-f27e500041a2)
4. After a reload: still empty, no saved draft for the chat. ![Step
4](https://github.com/user-attachments/assets/e5cdfcc1-e282-478a-b079-615505028388)
5. On a chat page, text typed while an attachment send is in flight is
kept, also after a reload. ![Step
5](https://github.com/user-attachments/assets/fcb192d5-d1a5-4adf-a48a-a39376c14697)
6. Workspace home, create forced to fail, then a second file added
without editing the text: after a reload the text and both files are
back. ![Step
6](https://github.com/user-attachments/assets/e32a79de-0c66-4a8a-a83a-1f7c1bd20b38)

**Risk:** low — the draft hook skips one save (exactly what a send left
on screen, until the next change or a refusal). Every other save path is
unchanged; a composer that empties itself on Send never arms the guard.
**Verified:** `bun test --isolate
src/session/composer/draft/use-composer-draft.test.tsx` → 8 pass, 0 fail
(2 fail at origin/dev) · composer and thread neighbors → 285 pass, 0
fail · local stack http://localhost:13000: attachment send left the text
2/2 on origin/dev, 0/6 on the final head
suna-skills: contributing, create-pr, worktree, testing, ponytail,
ponytail-review
ponytail: full · review: 1 shrink applied (one guard check instead of
two), then Lean already. Ship. · markers: 0

## Summary

On the workspace home ("What does … need done?"), a message sent with an
attachment could reappear in the new chat's composer right after it was
sent, ready to be sent again, and stayed there after a reload. Text-only
sends did not show it. After this change the new chat opens with an
empty composer. Anything typed after Send is still kept as a draft, and
a send that fails still leaves an editable, saved draft.

Reported in #kortix-triage (screenshot of a sent message still in the
composer) and by the dogfood journey `sess-attach-upload` (2/2 on dev).

Closes KRTX-4944

## Demo video

The demo video is in Review in 60 seconds.

## What is affected

- Web and desktop: every composer that uses `useComposerDraft`
(workspace home, first chat, chat page, space composer). Only the home
composer leaves its text on screen at Send, so only it changes behavior;
the others empty the box before the guard is taken, so the guard is
never set for them.
- Not affected: mobile (`apps/mobile` has its own draft hook that saves
on text changes only and has no home-to-session handoff), the API, the
SDK, stored data, migrations.

## Type of change

- [x] Bug fix

## How was this tested?

All on head `c675e857a1`, worktree `suna-stale-input`, base `origin/dev`
`a175fc378e`.

Targeted test, head:
```
$ cd packages/ui && bun test --isolate src/session/composer/draft/use-composer-draft.test.tsx
 8 pass
 0 fail
Ran 8 tests across 1 file. [317.00ms]
```

Same file with the hook at origin/dev (red run before the fix — the
reported bug):
```
(fail) useComposerDraft after a send that keeps its text on screen > a released attachment does not carry the sent text into the session composer
(fail) useComposerDraft after a send that keeps its text on screen > an upload finishing after Send does not save the sent text as the draft
 5 pass
 2 fail
```
(origin/dev has no `sendRefused`; that run used the 7 cases before the
refusal case was added.) The first failure received `"What is the first
word in the attached file"` in `kortix_draft:session:<id>`, the second
`"Summarize the attached file"` in the home draft.

Red runs before each review fix:
```
hook at 2c4790f (guard outlived the send):
(fail) ... > a sent command typed again is saved again
(fail) ... > a quote added to the text still on screen is a new draft
 5 pass
 2 fail
hook at 349253b (guard not ended by a refused send):
Expected: "Create failed, try again"
Received: null
(fail) ... > after a refused send, a file added to the text still on screen is saved
 7 pass
 1 fail
```

Neighbors (draft store, serialization, uploads, recovery, reset, logic,
editor, attachment submission, submit latch, chat-input wrapper, session
chat, question lock):
```
$ bun test --isolate src/session/composer/draft/*.test.* src/session/composer/composer-draft-recovery.test.ts src/session/composer/composer-reset.test.ts src/session/composer/composer-logic.test.ts src/session/composer/editor/composer-editor.test.ts src/session/composer/attachment-submission.test.ts src/session/composer/composer-submit-latch.test.ts src/session/composer/composer-chat-input.mentions.test.tsx src/session/thread/session-chat.test.tsx src/session/thread/session-question-lock.test.tsx
 285 pass
 0 fail
Ran 285 tests across 13 files. [5.37s]
```

Typecheck and lint of the touched package:
```
$ pnpm --filter @kortix/ui typecheck
src/customize/connectors/connector-identity.test.tsx(33,81): error TS2352: Conversion of type '{ status: "needs_account"; }' to type 'Partial<AdminConnector>' may be a mistake ...
$ npx eslint src/session/composer/composer.tsx src/session/composer/draft/use-composer-draft.ts src/session/composer/draft/use-composer-draft.test.tsx
✖ 2 problems (0 errors, 2 warnings)
```
Pre-existing: the TS2352 fails the same at origin/dev (untouched file);
the same 2 warnings appear at origin/dev for these files (the handoff
cleanup ref and one in composer.tsx).

Local stack (`pnpm worktree start stale-input`, web :13000, API :13008,
synthetic `@example.test` account), agent-browser: project home → attach
`notes.txt` → type → Enter → read the chat composer and `localStorage`
drafts.
```
origin/dev hook, attachment run 1: {"composer":"What is the first word in the attached file","draft":[["kortix_draft:session:<id>", ... "What is the first wo ...]]}
origin/dev hook, text only:        {"composer":"\n", ...}   (no draft for that chat)
origin/dev hook, attachment run 2: {"composer":"Summarize the attached notes", ... "kortix_draft:session:<id>" ... "Summarize the attach ...}
final head, attachment runs 1-3:   {"composer":"\n","draft":[]}   (and 3 more on 349253b, same)
final head, text only:             {"composer":"\n","draft":[]}
chat page, typed during an attachment send, after reload: "Typed while it sends"
home, create forced to fail (POST /v1/workspaces/<id>/sessions aborted), second file added, reload:
  349253b: {"composer":"\n","draft":[]}
  final head: {"composer":"Refused create, then a second file","draft":[["kortix_draft:project:<id>",["notes.txt","notes2.txt"]]]}
```

Not run: the `apps/web` typecheck (killed by the sandbox OOM, exit 137,
while the dev server ran; this PR changes no exported type of
`@kortix/ui`); the full `@kortix/ui` suite (per AGENTS.md, only the
files covering the change); the native Electron shell (the shell renders
the same web composer). No test renders the real `Composer` component,
so the one-line `sendRefused()` call in `onFailed` is covered by the
browser run above, not by a unit test.

## Security & data review

No new data, network call, permission or secret. Drafts stay in the same
`localStorage` keys; this only skips one write.

## Rollout / rollback

No flag, no migration. Revert the PR to roll back.

## Reviewer checklist

- [x] The two attachment tests fail on origin/dev and pass here
- [x] Text typed after Send is still saved and handed to the new chat
(test + browser)
- [x] A refused send still leaves a saved draft (test + browser)
- [ ] Reviewer focus: `use-composer-draft.ts` `handleDocChange` /
`clearSavedDraft` / `sendRefused`, and the `sendRefused()` call in
`composer.tsx` `onFailed`

Self-review: 4 items found and fixed (two independent fresh-context
reviews on kortix/codex/gpt-6.1-sol: the guard outlived the send for a
retyped command; definite-assignment assertions in the test harness; a
refused home send kept the guard armed. ponytail-review: the guard was
checked in two places).

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Review in 60 seconds
- KRTX-4950: replace the long Slack channel-connected welcome with one
heading and two short instructions.
- Remove examples, workspace/policy details and slash-command help; keep
mentions as a safe way for anyone to follow up.
- Remove the workspace-name database lookup, which the minimal message
no longer uses. No routing changes.

**Risk:** low — copy and an unnecessary read only; revert this commit to
restore the previous welcome.
**Verified:** focused regression 35 pass / 0 fail; API typecheck and
dispatch eslint pass. Full API suite: 16,202 pass / 52 fail across 18
batches; baseline comparison recorded below. Local stack fails at
Supabase health checks (REST 503); real Slack rendering not verified.
suna-skills: worktree, testing, learnings, contributing, create-pr,
kortix-brand-guidelines, kortix-design-system

No demo video: local stack could not start (Supabase REST 503); no Slack
messages were sent. Payload verified through the real welcome handler
with only external dependencies mocked.

## Summary
KRTX-4950 simplifies the message people see when Kortix joins a Slack
channel:

**Kortix is connected.**

Mention @kortix to start a task. Mention Kortix in the thread to follow
up.

The plain-text fallback carries the same content. This affects future
welcomes, not previously posted Slack messages.

Closes https://linear.app/kortix/issue/KRTX-4950

## Demo
No recording: real Slack delivery requires an external workspace write,
and the local stack failed its Supabase health check. No fabricated
rendering is presented as a Slack demo.

## Demo video
No demo video: local stack unavailable; welcome payload covered by a
regression test.

## Type of change
User-visible Slack copy simplification.

## What is affected
The channel-connected welcome and its notification/accessibility
fallback only. Event routing, thread behavior, workspace settings and
slash commands are unchanged.

## Verification
Focused tests, API typecheck, changed production file eslint and diff
whitespace checks passed. See exact commands below.

## How was this tested?
Full API unit suite completed (exit 1): 16,202 pass / 52 fail across 18
batches. It was launched with `bash apps/api/scripts/test.sh` (1,400+
test files in 18 batches). It is not green: unrelated failures include
CLI command inventory, audit route labels, billing atomic hold, project
agent discovery, request-primitives and worker-timer tripwires, and
partial Git-store tests. The unchanged `origin/dev` checkout was tested
as well. A focused baseline reproduction over the failing files reports:

```text
cd /workspace/suna-slack-base/apps/api
bun test --isolate --env-file=scripts/test.env <21 failing test files>
357 pass
45 fail
1200 expect() calls
Ran 402 tests across 21 files. [27.36s]
```

Pre-existing: those 45 failure names are identical at origin/dev and the
PR; the preview env-sync retry failure differs between environments: PR
rerun 89 pass / 1 fail, baseline 90 pass / 0 fail. This remains an
unresolved verification discrepancy, not a claimed pre-existing pass;
the welcome-only production diff does not touch preview code. The
redundant full baseline suite was stopped after batch 5/18; the focused
21-file baseline comparison completed. No unrelated fixes included. The
52 failing assertions include repeated failures across batched
invocations; 46 distinct failure names.

At head f82d402 in the task worktree:

```text
cd apps/api
bun test --env-file=scripts/test.env --isolate src/__tests__/unit-slack-classify-event.test.ts
35 pass
0 fail
39 expect() calls
Ran 35 tests across 1 file. [2.65s]
```

Test written and run before changing the renderer:
```text
bun test --env-file=scripts/test.env --isolate src/__tests__/unit-slack-classify-event.test.ts
34 pass
1 fail
39 expect() calls
Ran 35 tests across 1 file. [1458.00ms]
FAIL: posts only the connection status and task instructions, with matching fallback
```

```text
pnpm --filter kortix-api typecheck
> tsgo --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsgo.tsbuildinfo
exit 0
cd apps/api && pnpm exec eslint src/channels/slack/dispatch.ts
exit 0 (no diagnostics)
git diff --check
exit 0
```

The existing ESLint config ignores test files; the test file was
exercised by Bun and the API typecheck instead. A root-directory ESLint
invocation could not locate package config; rerunning from apps/api
passed.

```text
pnpm worktree start minimal-slack-welcome
supabase_rest_kortix-local unexpected status 503
primary Supabase credentials are unavailable
exit 1
```

## Security & data review
Synthetic fixtures only. No secrets or customer data in tests or
artifacts. No Slack write, schema or permission changes.

## Rollout / rollback
Standard deployment; no migration or flags. Revert this commit to
restore prior copy and its workspace-name lookup. Open only: normal
factory gates apply; Marko authorized normal handling on 2026-11-19
(session f7c7b6db, seq402).

## Risks and rollback
Low risk: the same handler and postBlocks call are retained. Real Slack
rendering/delivery remains unverified.

## Reviewer focus
- apps/api/src/channels/slack/dispatch.ts: minimal blocks and matching
fallback; no change to join guards.
- apps/api/src/__tests__/unit-slack-classify-event.test.ts: exact
payload and negative join cases.

## Reviewer checklist
- Acceptance criteria mapped to dispatch.ts welcome renderer and
regression payload assertions.
- Self-review: 0 items found and fixed. Checks A–H read against the
final diff; tests went red before the fix and green afterward.
- ponytail: full · review: Lean already. Ship. · markers: 0

<details>
<summary>Changed files</summary>

- apps/api/src/channels/slack/dispatch.ts — shorten welcome and remove
unused project-name read.
- apps/api/src/__tests__/unit-slack-classify-event.test.ts — exercise
the welcome handler and join guards.

</details>

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Review in 60 seconds

- Retry read-only attachment URL signing once after ECONNRESET.
- Preserve permanent failures and the two-attempt bound.
- Add regressions and the operational learning.

No demo video: code-only change.

**Risk:** low — One additional read-only signing request after a reset
only.

suna-skills: worktree, testing, learnings, contributing, create-pr

ponytail: full · review: Lean already. Ship. · markers: 0
**Verified:** 48 unit tests and 17 PostgreSQL tests pass; API typecheck
and eslint exit 0. SESS-30 excluded locally (funded capability).

## Demo video

No demo video: code-only change.

## Quick verification

Outcome: attachment descriptor signing recovers from one reset Storage
connection instead of immediately returning 503.

- Retry the read-only signing request once for Storage's wrapped
`ECONNRESET`. No write retries, HTTP-refusal retries, or telemetry
suppression.
- Preserve the missing-object 404 and exhausted-failure 503 responses.
Add recovery, retry-bound, and no-retry regression cases.
- Record the operational rule in the learnings ledger.

**Root cause:** API 0.15.11 attempted signed-download URL creation once;
its production breadcrumb identified `ECONNRESET: The socket connection
was closed unexpectedly.` The adapter returned a wrapped transport
error, which became HTTP 503 and a captured exception. Better Stack
recorded 1 occurrence affecting 1 user on 2026-11-16 at 22:24:17 UTC.
Both descriptor callers use the shared signer.

**Risk:** One additional request only for a confirmed reset; persistent
failures remain visible. No schema, auth, configuration, or
public-contract changes. Revert this commit to remove the retry.

**Verified:** targeted transport/binding/materializer tests: 48 pass, 0
fail; real PostgreSQL attachment integration: 17 tests, 1/1 suites pass;
API typecheck and changed production-file eslint exit 0. Local stack
health returns 200. SESS-30 cannot execute in the local profile because
it declares the external `funded` capability; not claimed passed.
Whole-package tests omitted under the repository's targeted-only
development policy.

## How was this tested?

<details><summary>Commands and actual results</summary>

Before implementation, from apps/api:
```sh
. ../../scripts/hermetic-test-env.sh
bun --env-file=scripts/test.env test --isolate src/projects/prompt-attachments-transport.test.ts
# 17 pass; 2 fail; 72 expect() calls
# Recovery threw 503; retry-bound expected 2 calls but received 1.
```
After implementation and merging origin/dev:
```sh
bun --env-file=scripts/test.env test --isolate src/projects/prompt-attachments-transport.test.ts src/projects/prompt-attachments.test.ts src/projects/session-lifecycle/prompt-attachment-materializer.test.ts
# 48 pass
# 0 fail
# 172 expect() calls
# Ran 48 tests across 3 files. [2.70s]
pnpm --filter kortix-api typecheck
# exit 0
cd apps/api && pnpm exec eslint src/projects/prompt-attachment-storage.ts
# exit 0, no output
```
Real PostgreSQL:
```sh
pnpm test -- --db-only apps/api/src/__tests__/integration-prompt-attachments.test.ts
# [db-suites] PASS 1/1 suites, 17 tests, 8.6s
# [test] PASS db 9.5s
```
The DB suite exercises runtime descriptor signing, command
authorization, binding, retention and cleanup. Existing HTTP fake
success responses remain valid; no DB predicate changed.

Local surface:
```sh
pnpm worktree start krtx-4957 --no-web
curl http://localhost:13008/v1/health
# HTTP 200 {"status":"ok","service":"kortix-api",...}
pnpm test -- --id SESS-30
# Error: no local flows selected; excluded: SESS-30 (external capabilities: funded)
```
The initial Supabase startup failed with Docker RWLayer unexpectedly
nil. A second startup succeeded. The Storage transport regression uses
the real Supabase adapter against synthetic HTTP responses and injects
the production reset shape; no production requests or customer files
were changed.
</details>

Self-review: 0 items found and fixed

self-review: approve · head c57dd4b

suna-skills: worktree, testing, learnings, contributing (attachments and
preview-environments references), create-pr

ponytail: full · review: Lean already. Ship. · markers: 0

model=kortix/codex/gpt-6.1-sol route=code
reason=conservative-code-default

Confirm after prod: application_id 2346961, pattern
dc19f8d90e8d917267a665e4fc58acfe9c0ee25d9f9c2c711888b1602ecab498 must
have 0 new occurrences for 24h. This observation remains unverified
until release; exhausted or unrelated errors are not suppressed.

Closes KRTX-4957 — https://linear.app/kortix/issue/KRTX-4957

factory-key:
betterstack:2346961:dc19f8d90e8d917267a665e4fc58acfe9c0ee25d9f9c2c711888b1602ecab498

## Summary

The shared signer retries one wrapped ECONNRESET. No other error
classification changes.

## Type of change

- [x] Bug fix

## Security & data review

No IAM, customer data, migrations or credentials changed. Fixtures are
synthetic. Production telemetry was read-only.

## Rollout / rollback

Normal API deploy. Revert the commit to remove the retry. Verify the
Better Stack pattern after production carries the fix.

## Reviewer checklist

- [x] Regression failed before the fix and passes afterward.
- [x] Targeted tests, API typecheck and changed-file lint ran.
- [x] No public export, schema or production configuration change.
- [x] Unrun funded flow and post-prod observation explicitly disclosed.

Rework verification (head c57dd4b): merged origin/dev 6bd6dc1
without changing the approved signer or test diff. Related tests: 48
pass, 0 fail, 172 expect() calls [3.56s]. PostgreSQL: 1/1 suites, 17
tests pass [7.1s]. API typecheck and changed-file eslint exit 0.
Learnings index check and git diff --check exit 0.

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…#12883)

## Review in 60 seconds

- The project sidebar no longer has an Inbox row. The row, with its bell
icon, tooltip and Needs-you count badge, lived in one sidebar-only
component. That component is deleted, and both places that rendered it
drop it: `ProjectNavItems` (the normal sidebar, the collapsed peek, the
mobile sheet, the Spaces "More" group) and `ProjectSpacesNav` (the
Spaces list).
- Inbox itself is unchanged. It still opens from the workspace menu
(`workspace-switcher.tsx`, existing), ⌘K (`menu-registry.ts`, existing)
and `/inbox`. The notification data, the polling and `tabUnreadCount`
are untouched. The other sidebar rows keep their order.
- The old "sidebar has no Inbox row" tests could not fail. They mocked
`ProjectNavItems` to null and looked for `/workspaces/<id>/inbox`, but
the row links to `/inbox`. The test now renders the real nav rows with a
signed-in viewer and a waiting Needs-you notification. It fails 3 of 7
on the base code (`href="/inbox"` found) and passes 7 of 7 with the fix.

Demo 1 (default sidebar → the workspace menu still has Inbox → `/inbox`
opens → collapsed sidebar peek):


https://github.com/user-attachments/assets/006e894e-4fac-466f-9d24-5feb795e4310

Demo 2 (Spaces sidebar, `chat` flag on, with More opened):


https://github.com/user-attachments/assets/e265217f-602f-4673-9f9c-b9ee633e5af9

Demo 3 (mobile sheet, 390×844):


https://github.com/user-attachments/assets/ef572e29-0a2a-45b0-bc71-79efe5617740

**Walkthrough**
1. Default sidebar: New session, Customize, Drive, Apps, Artifacts,
Sessions. No Inbox row. ![Step
1](https://github.com/user-attachments/assets/f8e4caf4-c698-47b2-874f-260454a44d28)
2. The workspace menu still lists Inbox. ![Step
2](https://github.com/user-attachments/assets/9af45a0e-8b08-4e99-ab6f-a7924f71ffa6)
3. Clicking it opens `/inbox`. ![Step
3](https://github.com/user-attachments/assets/d5968d81-2c1a-4258-895d-85406ed574e2)
4. Sidebar collapsed, peeked from the left edge: no Inbox row. ![Step
4](https://github.com/user-attachments/assets/2cc24b89-10f0-4e0d-9cdb-24a1dd1cd516)
5. Spaces sidebar (`chat` on): Review, Your space, general, New space.
No Inbox row. ![Step
5](https://github.com/user-attachments/assets/7e075937-0904-41f1-b4c5-5fbe8e00ae7c)
6. Spaces sidebar with More opened: Customize, Drive, Apps, Artifacts,
Sessions. No Inbox row. ![Step
6](https://github.com/user-attachments/assets/aab9af26-7c86-4f00-b0ee-e4343f3eb774)
7. Mobile sheet: no Inbox row. ![Step
7](https://github.com/user-attachments/assets/4216cfd2-4a0b-4ab0-b3a2-5777e4cc9cd4)

**Risk:** low — removes one navigation row from `packages/ui`. The only
prop removed (`ProjectNavItems` `inbox`) had one caller,
`sidebar-more-group.tsx`, updated here. Inbox stays reachable from the
workspace menu, ⌘K and `/inbox`. Rollback is a revert of this PR.
**Verified:** `bun test
src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx` → 7
pass; 0 fail (3 fail at base 476c40e on `href="/inbox"`) · `bun test
src/features/apps/apps-feature-gate.test.ts` → 15 pass; 0 fail ·
packages/ui sidebar + notifications suite, file by file → 207 pass; 0
fail · `tsgo --noEmit` packages/ui and apps/web → exit 0 · eslint → exit
0 · local stack http://localhost:13000 (desktop, collapsed peek, mobile,
Spaces with `chat` on)
suna-skills: worktree, testing, learnings, contributing (+ references),
create-pr, kortix-design-system, agent-browser
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 3 items found and fixed
Model: model=claude-agent/opus route=visual reason=route-label

## Summary

Marko asked to remove Inbox from the project sidebar navigation
(KRTX-4949). The change removes the navigation entry only, as the issue
asks. The Inbox feature, its data and its other entry points stay.

- `packages/ui/src/workspace/sidebar/footer/project-inbox-nav.tsx`:
deleted. It was the sidebar-only Inbox row: bell icon, label/tooltip,
Needs-you `CountBadge`.
- `packages/ui/src/workspace/sidebar/project-nav-items.tsx`: `inbox`
leaves `NAV_ROWS`, the `inbox` prop and its filter go.
- `packages/ui/src/workspace/sidebar/sidebar-more-group.tsx`: drops the
now-removed `inbox={false}` prop.
- `packages/ui/src/workspace/sidebar/project-spaces-nav.tsx`: drops the
Inbox row above Review.
-
`apps/web/src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx`:
the Inbox checks now render the real rows and cover desktop, the mobile
sheet and the Spaces list with More opened.

Reading of the issue: "all applicable project sidebar navigation
variants" means the default sidebar, its collapsed (off-canvas peek)
state, the mobile sheet, and the Spaces sidebar with its More group. All
four render through the two components changed here. The workspace
menu's Inbox item is not sidebar navigation, so it stays. Without it, a
person would have no pointer path to Inbox.

Closes KRTX-4949

## Demo video

The demo video is in Review in 60 seconds. All three videos were
recorded on this worktree's local stack (`http://localhost:13000`) with
a synthetic `pr-demo-<epoch>@example.test` account and a synthetic
workspace.

## Type of change

- [x] Bug fix / UI change (navigation row removed)
- [ ] New feature
- [ ] Breaking change
- [x] Tests

## How was this tested?

Red at base 476c40e: the new test file, with the base sidebar code
restored (`git checkout 476c40e --
packages/ui/src/workspace/sidebar`), fails for the stated reason:

```
$ cd apps/web && bun test src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx
Expected to not contain: "href=\"/inbox\""
(fail) the desktop sidebar has no Inbox row (KRTX-4949)
Expected to not contain: "href=\"/inbox\""
(fail) the mobile sheet has no Inbox row (KRTX-4949)
Expected to not contain: "href=\"/inbox\""
(fail) with chat on, neither the Spaces list nor the opened More group has an Inbox row (KRTX-4949)
 4 pass
 3 fail
Ran 7 tests across 1 file.
```

Green at the head:

```
$ cd apps/web && bun test src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx
 7 pass
 0 fail
Ran 7 tests across 1 file. [1.82s]
```

Neighbor tests that name a changed module or the Inbox entry points:

```
$ cd apps/web && bun test src/features/apps/apps-feature-gate.test.ts
 15 pass
 0 fail
Ran 15 tests across 1 file. [2.35s]

$ cd packages/ui && bun test src/workspace/sidebar/workspace-menu-model.test.ts src/internal/notifications/notification-rows.test.ts
 36 pass
 0 fail
Ran 36 tests across 2 files. [19.00ms]
```

Touched package suite, `packages/ui` (every test file under
`src/workspace/sidebar` and `src/internal/notifications`, 22 files, each
run as its own `bun test <file>`):

```
$ cd packages/ui && for f in src/workspace/sidebar/*.test.* src/workspace/sidebar/*/*.test.* src/internal/notifications/*.test.*; do bun test $f; done
head b092ae2:            207 pass; 0 fail
base origin/dev daf68c9: 207 pass; 0 fail
```

Pre-existing: the same 22 files in ONE bun process (`bun test
src/workspace/sidebar src/internal/notifications`) fail the same at
origin/dev (daf68c9: 185 pass, 3 fail; two files crash on a leaked
`primitives/hint` mock, `Export named 'Hint' not found`). At the head
the same command gives 202 pass, 5 fail:
`project-manifest-issues-alert.test.tsx` renders translation keys from
the leaked `i18n` mock of `share-session-modal.test.tsx`. That file
passes alone, 10 pass; 0 fail, at head and at base. This PR changes
neither file.

Typecheck and lint:

```
$ cd packages/ui && pnpm run typecheck        # tsgo --noEmit
exit 0
$ cd apps/web && npx tsgo --noEmit            # after generating .source with bun (see below)
exit=0, 0 "error TS" lines
$ cd packages/ui && npx eslint src/workspace/sidebar/project-nav-items.tsx src/workspace/sidebar/project-spaces-nav.tsx src/workspace/sidebar/sidebar-more-group.tsx
exit 0
$ cd apps/web && npx eslint src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx
exit 0
```

Local stack (`pnpm worktree start krtx-4949-inbox-nav --no-tunnel`, web
`:13000`, api `:13008`), driven with agent-browser:

```
default sidebar, a11y snapshot:   link "New session Ctrl J" · link "Customize" · link "Drive" · link "Apps" · link "Artifacts" · button "Sessions"   (no Inbox)
workspace menu:                   menuitem "Switch workspace" · "Workspace settings" · "Invite people" · "Inbox" · "Preferences" · …
click menuitem "Inbox" → get url: http://localhost:13000/inbox   (heading "Inbox")
mobile sheet (390x844):           link "New session" · "Customize" · "Drive" · "Apps" · "Artifacts" · button "Sessions"   (no Inbox)
chat flag on (local synthetic workspace): link "Review" · "Your space" · "general" · button "New space" · button "More"; More open → "Customize" · "Drive" · "Apps" · "Artifacts" · "Sessions"   (no Inbox)
```

Pre-existing: `bun test src/features/apps/apps-feature-gate.test.ts
src/features/workspace/project-sidebar/project-sidebar-kbd.test.tsx` in
ONE bun process fails the same at origin/dev (476c40e: 19 pass, 2
fail): module mocks leak between the two files. Each file passes alone
(above). With this PR the same pairing fails 3 (the new Spaces test hits
the same leak).

Environment notes, not failures of this change:
- `pnpm run typecheck` in apps/web first runs `node
scripts/generate-fumadocs-source.mjs`. The sandbox's
`/usr/local/bin/node` is v22.11, which cannot import `.ts`, so I
generated `.source` with bun and ran `tsgo` directly. The stack ran on
pnpm's node v22.23.1.
- The stack ran with `--no-tunnel`, so the dev overlay shows the
expected `KORTIX_URL points at a loopback address` ApiError. No session
was started.
- Not shown in the browser: the count badge on a real unread Needs-you
notification, since no session ran locally. The unit test covers it: the
inbox mock holds an unread `question`, so the base code renders the row
with badge `1` and the head renders no row.

## Security & data review

- No data, API, schema or permission change. A UI row is removed; the
notification query it ran is still used by `NotificationHost` and the
Inbox page.
- Demo media show only synthetic data (`@example.test` account,
generated workspace name).

## Rollout / rollback

- Rollout: ships with the next web deploy. No flag, no migration.
- Rollback: revert this PR. That restores the row component and both
call sites.

## Reviewer checklist

- [x] Every hunk traces to KRTX-4949
- [x] A test fails without the fix (3 of 7 at base) and passes with it
- [x] Typecheck and eslint ran on the touched packages
- [x] The change ran on the local stack, with a demo for each sidebar
variant
- [x] No customer data in code, tests or media

## Quick verification

- Outcome: the project sidebar has no Inbox row in any variant; Inbox
still opens from the workspace menu, ⌘K and `/inbox`.
- Open a workspace on dev: the sidebar lists New session, Customize,
Drive, Apps, Artifacts. Open the workspace menu: Inbox is there and
opens `/inbox`.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…#12891)

The CLI keeps the host it used last. A person who once followed a dev, local or self-hosted guide ran the kortix.com prompt against that host: the production guide installed the CLI but never selected a host. Step 0 now runs `kortix hosts use cloud` and checks `kortix hosts current`.
## Demo video

Not recorded. The PR changes toast placement only.

## Quick verification

- Cause: `useToastClearance` set `--toast-offset-right` to the
composer's right edge, so toasts sat inside the chat column.
- Fix: toasts always use the window's bottom-right corner (`right:
24px`). A docked composer lifts them only when it overlaps the toast's
356 px lane.
- Local app at 1440×900, session page, Copy-triggered toast: toast rect
right 1416, bottom 876 (24 px from the corner).
- `bun test src/primitives/toast-clearance.test.ts` (packages/ui): 6
pass, 0 fail.
- `pnpm --filter Kortix-Computer-Frontend typecheck`: exit 0. `tsgo
--noEmit` (packages/ui): exit 0. eslint on the changed files: clean.
…12899)

A masked replay now keeps text that is a string of the translation catalog (placeholders only as numbers) and the provider names; message and document text and everything else stay hidden. Click events on private pages keep the same interface text. Privacy policy and PostHog subprocessor row updated.
…12798)

## Demo video

**Web, `/workspaces/<id>/spaces`, 1440×900, a space's creator: the
Spaces page (one card per space: who sees it, what it is for, sessions,
last activity) → "Board prep" (one header row, Home with the history by
day and an About rail) → a space opens in the sidebar's Spaces block →
the Files tab.**


https://github.com/user-attachments/assets/bb954c0e-aa3f-4e45-bb6a-15e0cc5587a3

| Spaces page | Space Home | Dark |
| --- | --- | --- |
| ![Spaces
page](https://github.com/user-attachments/assets/7d974cde-3108-41ef-8506-8dbaae0e1366)
| ![Space
Home](https://github.com/user-attachments/assets/2e0ca58d-1d57-40cc-8c11-aa78f828a42e)
| ![Space Home
dark](https://github.com/user-attachments/assets/55149ef5-9c6d-4993-ab03-4cda81469763)
|

| Teammate (a plain member): no Share, the people count | Phone, 390 px
|
| --- | --- |
| ![Teammate
view](https://github.com/user-attachments/assets/149df0ff-5345-4802-9bd9-f351e9d2a237)
|
![Phone](https://github.com/user-attachments/assets/35cc3cdc-20a7-40c0-868d-56353153afcf)
|

## Quick verification

**Outcome.** A workspace groups sessions into Spaces, like Claude
Projects, separate from the Slack-style channels.

- **A space** has a name, a description ("What is it for?"), its
sessions, tabs and a Files folder. You start a session in it from its
page, or with the "Space" chip on the home composer.
- **The agent knows its space.** Every turn of a session in a space
names the space and its description. The session mounts the space folder
read-write at `/drives/space` and learns `kortix sessions ls --space
<id>` to read the other sessions.
- **Private by default, shared as a unit.** A new space is visible only
to its creator. "Share" offers "Specific people" or "Everyone in this
workspace". Whoever sees a space sees every session in it, their child
sessions, and its files, whatever each session's own sharing. A session
outside any space keeps its own sharing.
- **Admins:** they see a private space only when the owner-only security
setting "Admins can open every session and space" (account session
oversight) is on, the same rule as for private sessions.
- **Layout, like a Slack or Teams channel without a chat timeline:**
- **Spaces page:** a card per space: its name, who sees it ("Only you",
"Shared with 1 person", "Everyone in this workspace"), what it is for in
two lines, its session count and last activity, the people's avatars.
- **Header:** one row: the name and its menu (Edit details, Delete), the
description, then one control for who sees it and Share (the avatars
inside the Share button; a member without the right sees the avatars
alone).
- **Tabs:** **Home**, **Files** (the space's folder, built in), the
space's own tabs (file, folder, artifact, app, link), "+". The open tab
is in the URL (`?tab=`).
- **Home:** the composer, then the history grouped Today / Yesterday /
This week / Earlier, each row with its live status mark, title, starter
avatar and time, searchable. On wide screens an **About** rail: what it
is for (Edit), People (Share), the 5 newest Files.
- **Sidebar:** a **Spaces** block above Sessions. The heading opens the
Spaces page, its "+" names a new space in place. Each space is a row
like a nav row: its glyph turns into a caret on hover that shows its
sessions under it; its name opens the space; the open space is the
current row. Spaces start collapsed. The separate Spaces nav row is
gone.
  - The tab components are the channels' own, not copies.
- **Behind the `session_groups` flag,** which Settings now names
"Spaces". `chat` is renamed "Channels". Stored keys are unchanged.

**Try it:**

1. Settings → Feature flags → "Spaces" on.
2. Sidebar → Spaces → "New space". The space page reads "Private".
3. Send a message in the space composer. Ask the agent which space it is
in: it answers with the name and the description.
4. "+" → Folder → "This space's files" adds a files tab.
5. "Share" → pick a teammate → Save. The teammate now lists the space,
opens its sessions and its files. Remove them: they lose all of it on
the next request.

**What changes** (additive, nothing renamed or removed in the SDK):

- **DB:**
- `project_session_groups` gains `description`, `visibility`
(`private`/`project`) and `tabs`.
  - A new table, `project_session_group_members`.
- Existing groups become `private` to their creator. Fail-closed: a
space now shares its sessions, so making them workspace-wide would
expose members' private sessions.
  - The check constraint is validated in its own migration.
- **API:**
- `PUT /session-groups/:id/sharing` (creator only, `403
group_manage_forbidden`; a non-member → `400 not_a_member`) and `PUT
/session-groups/:id/tabs`.
  - `POST /sessions` takes `group_id`.
- Filing someone else's private session into or out of a space → `403
group_share_forbidden`.
  - A private space answers `404` to anyone it is not shared with.
- `GET /session-groups` gives each space `session_count` (top-level,
live sessions) and `last_activity_at`, from one grouped query on the
`(group_id, updated_at)` index.
- **Access rules,** in one module (`shared/session-group-access.ts`):
- Sharing only widens. It applies in the session list SQL and its JS
fold, the single-session read, and the preview/runtime proxy gate.
- It never reaches across a hidden private channel or to an agent's own
token, and only while the flag is on.
  - A reader I missed would hide a session, never show one.
- **Files:**
  - Space folders move to `/Spaces/<group_id>`, outside `/Company`.
- They are reserved like private channel folders: admins do not reach
them by role.
- Each person who sees the space gets a computed write grant, so sharing
and unsharing apply on the next request.
- **SDK:** `setWorkspaceSessionGroupSharing`,
`setWorkspaceSessionGroupTabs`, two hooks, and `sessionGroups.share` /
`setTabs` (surface snapshot: names added only). `ProjectSessionGroup`
gains the optional `session_count` and `last_activity_at` (test first).
- **CLI:** `kortix sessions ls --space <id>` and `kortix sessions new
--space <id>`.
- **Fix found on the way:** opening a session someone shared with you
showed a "workspace.connector.write" permission toast, because the
background `GET …/connect-requests` refused a plain member. That read is
now silent.

<details><summary>Checks run on <code>c7b98f7595</code> (sharing,
access) and <code>d635c25ee6</code> (revamp, after merging dev), the
worktree stack with its own DB, real Platinum sandboxes, two real
users</summary>

| Check | Result |
| --- | --- |
| Flows `SGRP-1/2/3/5/6/7` (`pnpm test -- --id …`) | 6 of 6 PASS on
`d635c25ee6`. `SGRP-3`: the list gives Store A `session_count` 1 and
`last_activity_at` = its session's `updated_at`; an empty space 0 and
null. `SGRP-5`: private space → `404` for others; shared → list and read
its sessions and children; not the owner's other private session; member
edits but cannot share or delete; unshare revokes; flag off shares
nothing. `SGRP-6`: tabs. `SGRP-7`: an admin sees a private space only
with oversight on. |
| Mutation check | Making `sharedGroupIdsFor` return nothing turns
`SGRP-5` red (`expected [200], got 404`); restored. |
| `pnpm test -- --db-only integration-session` | 46 of 46 suites, 466
tests PASS, incl. `integration-session-list-sql-predicates` (SQL list
and JS rule agree). On `d635c25ee6`: `integration-session-groups` 9
tests PASS. |
| Two users, local stack | Teammate before sharing: no space, session
`404`, not listed. After: space, 3 sessions, transcript, files
(`write`). After unsharing: folder `404`, session `404`. |
| Agent context | 5 real sessions answered with their space's name and
description, and wrote and read the space's files through
`/drives/space`. |
| Migration | Applied to the branch DB: the 2 existing groups read
`private`. `@kortix/db lint`: 0 issues. The shared primary DB is
untouched. |
| SDK gates | `typecheck` clean; full suite 7,400 tests in 483 files, 0
fail; `smoke:install` passes; surface diff only adds names. |
| Unit tests | api-contract, session-where, drives folders (30),
feature-flags, SDK session-groups and connectors (104), CLI
sessions-list, UI: every test file in the touched folders. 0 fail. |
| T0 | `tsgo` clean for api, sdk, ui, web, cli. `kortix-api lint` clean.
Brand `audit.sh` clean. ESLint 0 errors. `i18n-catalogs check` ok;
strings in 9 locales. |
| Revamp, local stack (agent-browser) | The API counts match the DB
(`Customer research` 1, `Board prep` 3). Spaces page, space Home, the
sidebar block (collapsed, expanded, current row) and Files at 1440×900,
light and dark; at 390 px the page fits. The teammate sees no Share
control, "2 people" (it may not read the owner's email, so no partial
list). |
| Revamp, gates | UI and API typecheck clean; ESLint 0 errors on the
touched files; brand `audit.sh` clean; every UI test file under
`workspace/sidebar`, `workspace/session-spaces` and `workspace/spaces`:
24 files, 181 tests, 0 fail; SDK `session-groups.test.ts` 15 pass,
surface tests pass; api-contract schemas 103 pass. |
| `@kortix/ui typecheck` | 1 error in `connector-identity.test.tsx`, a
file this branch does not change. |

</details>

**Risks and gaps:**

- **Not in the CLI:** sharing. Agents cannot share by design: a session
token gets `403`.
- **Proxy cache:** after un-sharing, the preview/proxy gate keeps its
cached verdict for up to 10 s on a replica. Channels have the same
window.
- **Name uniqueness:** space names are unique per workspace, private
ones included. A taken name answers `409` even when that space is hidden
from you.
- **Rollback:** an older API build does not read `visibility`. It lists
private space names to every member, but never their sessions, because
sessions keep their own sharing there.
- **Drive titles:** the Drive header and breadcrumb show the folder id;
the tree and the list show the space name.
- **Not checked:** desktop (Electron) and mobile.
- **Naming:** the Channels sidebar (flag `chat`) is still titled
"Spaces" in the sidebar strings; with both flags on, two sections read
"Spaces". Renaming the Channels strings is outside this PR.
- **Held for your review** (new feature, IAM-sensitive, visual). Not
self-merged.

**Reviewer focus:**

- `apps/api/src/shared/session-group-access.ts` and its 3 callers:
`session-list.ts` `byRules`, `session-visibility.ts`, and
`preview-ownership.ts` via `sharedThroughSpace`.
- `drives/service.ts` `privateChannelFoldersFor` and `driveSubjectFor`.
- The migration's private default for existing groups.

---------

Co-authored-by: Jay Suthar <sutharjay3635@gmail.com>
…3923) (#11508)

## Demo video

No demo video: local stack unavailable — `pnpm worktree start krtx-3923`
refuses the shared primary database because its Kortix schema is not
initialized. The initial Supabase boot returned PostgREST 503 (`schema
"kortix" does not exist`). The primary stack then exited during API
environment validation: PLATINUM_API_KEY, PLATINUM_API_URL,
STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are unavailable. No
credential values are recorded. This is a platform-visible change, not a
code-only exemption. Successful submission, New session navigation,
refresh and Electron remain unverified.

## Quick verification

- Outcome: KRTX-3923 prevents accessory cleanup from persisting
submitted composer text again. Intentional unsent drafts and failed-send
recovery remain covered. https://linear.app/kortix/issue/KRTX-3923
- Merged current `origin/dev` into the existing branch, preserving its
sent-content guard, home-to-session handoff and refused-send handling.
Submitted text is excluded from accessory snapshots until a document
edit or send refusal.
- Risk: medium — shared web/desktop draft lifecycle. No schema,
dependency or storage-key change. Rollback: revert this PR.
- Browser walkthrough, Electron and Docker-backed product flows were not
run because the worktree stack refuses its uninitialized shared
application database. No passing browser result is claimed.
- Repo testing policy forbids a whole-package run during development;
ran the four affected draft files instead.

```sh
$ pnpm --filter @kortix/ui test src/session/composer/draft/submitted-draft.test.tsx # current dev implementation, before fix
3 pass
3 fail
14 expect() calls
Ran 6 tests across 1 file. [338.00ms]

$ pnpm --filter @kortix/ui test src/session/composer/draft/submitted-draft.test.tsx src/session/composer/draft/use-composer-draft.test.tsx src/session/composer/draft/composer-draft.test.ts src/session/composer/draft/composer-draft-store.test.ts
58 pass
0 fail
88 expect() calls
Ran 58 tests across 4 files. [409.00ms]

$ pnpm --filter @kortix/ui typecheck
> tsgo --noEmit
exit 0

$ pnpm --filter @kortix/ui exec eslint src/session/composer/draft/use-composer-draft.ts src/session/composer/draft/submitted-draft.test.tsx
0 errors, 1 warning
exit 0
```

The warning is the existing home-handoff ref cleanup warning; the ref
intentionally reads its navigation destination during cleanup. Six
additional tests cover accessory cleanup/unmount, pagehide, new
accessories without submitted text, subsequent typing, unsent
restoration and scope isolation. Eight existing hook tests also pass,
including failed-send recovery and upload completion. No regression is
claimed fixed by source-text assertions.

Self-review: 1 item found and fixed (preserve trunk's sendRefused
recovery when reconciling submitted state). Checks A–H performed
locally; browser acceptance remains unchecked.

ponytail: full · review: Lean already. Ship. · markers: 0
suna-skills: worktree, testing, learnings, contributing, create-pr,
agent-browser, kortix-brand, kortix-design-system

Feedback: 1 addressed (merge conflict) · 1 answered without a change
(demo unavailable; exact current database prerequisite stated). Head:
aa7855a.
model=claude-agent/opus route=visual reason=route-label
Actual capacity route: model=kortix/codex/gpt-6.1-sol route=visual
reason=claude-exhausted; intended=claude-agent/opus.

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…n the DB pool (KRTX-4895) (#12702)

## Review in 60 seconds

- KRTX-4895: one caller's heavy usage-rollup flood exhausted the
database pool; notifications requests waited in auth and returned 503.
Earlier investigation found 348 API 5xx in one five-minute bucket,
including notifications.
- All four account-wide usage rollups now share a two-in-flight limit
per caller and a 60/minute per-route token bucket. Refusals return 429
and Retry-After without an audit write. Single-session detail remains
unguarded.
- Rebased by merging current origin/dev; fixed the replica-wide queue
test to use distinct callers so it tests that queue rather than the new
caller limit.

No demo video: code-only change

**Risk:** low — limits are replica-local, not fleet quotas.
Authentication still precedes the guard. This bounds one caller's
rollups, not all database traffic. Revert this PR to remove the guard;
raising KORTIX_USAGE_ROLLUPS_PER_MIN removes only the rate ceiling, not
concurrency.
**Verified:** 88 usage-route tests pass across five independently
executed files; API typecheck exit 0; changed-source eslint exit 0;
route coverage 0 uncovered. Real local HTTP COST-4: 1/1 passed, 0
failed; COST-2 excluded for external capabilities.

suna-skills: worktree, testing, learnings, contributing, create-pr
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed (stale PR evidence; queue test used
one caller and hit the new caller ceiling before reaching the replica
queue).

## Summary

Closes KRTX-4895. Root cause and historical telemetry are in the issue's
original investigation. No production infrastructure or data changed.
Current work adds missing contract evidence and reconciles the existing
tests with the trunk's replica-wide cost-read guard.

## How was this tested?

At head 78ed29f, after merging origin/dev:

`bun tests/bin/ke2e.ts coverage` → `95.9% covered · 1740/1814 routes ·
74 allowlisted · 0 uncovered`

```text
ke2e coverage — spec ↔ flow ↔ route parity
95.9% covered · 1740/1814 routes · 74 allowlisted · 0 uncovered
✓ coverage gate passed
```

Each file was run separately from apps/api with `bun test <file>` and
synthetic environment overrides:
`ALLOWED_SANDBOX_PROVIDERS=platinum
SUPABASE_URL=https://supabase.example.test
FRONTEND_URL=https://app.example.test INTERNAL_KORTIX_ENV=dev
PLATINUM_INFERENCE_URL=https://inference.example.test
KORTIX_CONFIG_ARCHIVE_S3_ENDPOINT=https://archive.example.test`.

```text
bun test src/router/routes/usage-cost-by-project-http.test.ts
23 pass
0 fail
bun test src/router/routes/usage-cost-summary-http.test.ts
10 pass
0 fail
bun test src/router/routes/usage-rollup-rate-limit.test.ts
6 pass
0 fail
bun test src/router/routes/usage-session-costs-http.test.ts
33 pass
0 fail
bun test src/router/routes/usage.test.ts
16 pass
0 fail
```

Red without the fix: temporarily restored origin/dev's usage.ts route
wiring, ran the rollup regression test, then restored the head file.
Result: `2 pass; 4 fail`, including expected 429 / received 200 and the
concurrent-limit test timing out. No temporary source changes remain.

The initial cost-summary test run failed because a single caller hit the
new two-in-flight ceiling before filling the replica queue. After using
distinct synthetic callers, all 10 tests pass, including queue refusal
and recovery.

```text
cd apps/api && pnpm typecheck
> tsgo --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsgo.tsbuildinfo
exit 0
cd apps/api && pnpm exec eslint src/middleware/rate-limit.ts src/router/routes/usage.ts src/config.ts
exit 0
```

After the trunk merge, typecheck initially lacked the newly added
`ignore` dependency. `pnpm install --frozen-lockfile --prefer-offline`
exit 0 repaired dependencies; the subsequent typecheck exits 0.

Local stack: `pnpm worktree start krtx-4895 --no-web --no-tunnel` failed
during fresh Supabase startup: PostgREST schema-cache load reports
`schema "kortix" does not exist`, then `supabase_rest_kortix-local
unexpected status 503`. The supported test runner subsequently
bootstrapped the database and successfully exercised real local HTTP
through COST-4. `pnpm test -- --id COST-2` booted the deterministic
local API, gateway and migrated database, then exited 1: `no local flows
selected; excluded: COST-2 (external capabilities: funded, sandbox)`.
The runner cleaned up its stack. COST-2 is not counted as passed.
Production baseline for 24 hours remains unverified until deployment.

No whole-package/full test run: repo-local AGENTS.md and testing skill
require named targeted files only.

## Rollout / rollback

No migration, SDK export or UI change. Replica-local ceilings multiply
with replicas. Revert the PR to remove both limits. After production
deployment, check notifications 5xx for 24 hours using aggregate
ClickHouse counts, without customer identifiers.

## Demo video

No demo video: code-only change

## Type of change

- [x] Bug fix

## Security & data review

No customer data or secrets. Synthetic callers only. Authentication
precedes the guard.

## Reviewer checklist

- Check per-caller concurrency release in finally.
- Check four guarded rollups and unguarded single-session detail.
- Re-run the five named usage test files and coverage.

### Real local HTTP

`pnpm test -- --id COST-4` on the worktree deterministic stack:
```text
✓ [1/1] PASS COST-4 1.3s
fixtures: 4 database-only projects · 0 managed repositories
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 1.8s
```
Covers all four usage rollups and single-session detail with
account/workspace authorization and negative paths. Runner stopped its
API, gateway and Supabase afterward.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
)

## Demo video


https://github.com/user-attachments/assets/c9a5f03e-d6e3-499f-bfa5-723e1ca048e9

Previous worker's authenticated local-stack demo with synthetic data.
This retry changes only test setup and merges dev; no runtime behavior
changed in this retry. The current sandbox stack failed to start:
Supabase REST returned 503 because the kortix schema does not exist. No
fresh browser recording or Electron verification.

## Quick verification

- Outcome: shared change-request links open canonical Review selection;
CLI open/show supply browser URLs. Closes KRTX-4976.
- UUID, numeric, encoded references and query/fragment preservation use
existing authorized routes. No authorization or database changes.
- Merged origin/dev (770f920) into the existing branch; Git resolved
it cleanly. Added the real translation provider/catalog to the
compatibility component test.
- Risk: medium — navigation compatibility; existing access controls
remain unchanged. Rollback: revert this PR.

Checks rerun in this retry on head 8700848:
```text
bun test --isolate packages/shared/src/change-request-links.test.ts 'apps/web/src/app/[locale]/(app)/workspaces/[id]/change-requests/[crId]/page.test.ts' apps/web/src/components/projects/change-request-link.test.tsx apps/cli/src/__tests__/cr-parity.test.ts apps/cli/src/__tests__/cr-principal.test.ts
61 pass; 0 fail; 135 expect() calls; 5 files
cd apps/web && bun test --isolate 'src/app/[locale]/(app)/workspaces/[id]/change-requests/[crId]/page.test.ts' src/components/projects/change-request-link.test.tsx
14 pass; 0 fail; 22 expect() calls
bun test --isolate apps/web/src/middleware-public-routes.test.ts apps/web/src/middleware-desktop-routes.test.ts
12 pass; 0 fail
bun test --isolate packages/starter/src/__tests__/managed-skills-drift.test.ts packages/starter/src/__tests__/embedded.test.ts
11 pass; 0 fail
```

Web, CLI, shared and starter package typechecks exit 0. Changed web
runtime/test-file ESLint exit 0. CLI SDK-boundary: 0 violations. Brand
audit clean. Full package suites not run per repository targeted-test
policy.

Initial targeted run after installation: 58 pass, 3 fail (test lacked
translation context); real provider setup fixes all three. Earlier
premature run before dependency installation completed: 0 pass, 25 fail,
2 errors; superseded by completed-install runs above. Original worker's
red-before-runtime-fix evidence remains in issue history; this retry
does not claim to have rerun that earlier base experiment.

Unrun: current local browser/HTTP flow and Docker-backed integration
flows, because worktree start failed with missing kortix schema / REST
503. Dev and prod verification pending deployment; no release claimed.

Self-review: 1 items found and fixed (translation context in component
test). Checks A–H reviewed locally; independent G9 remains required on
this head.
ponytail: full · review: Lean already. Ship. · markers: 0
suna-skills: worktree, testing, learnings, contributing, create-pr,
kortix-brand, kortix-design-system
model=kortix/codex/gpt-6.1-sol route=visual reason=claude-exhausted;
intended=claude-agent/opus

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
… page (KRTX-4488) (#12692)

## Review in 60 seconds

- Newest root log pages derive a bounded tail instead of projecting
every message in a long session.
- Merge current dev into the existing PR and preserve the default
context exclusion and explicit `include=context` behavior.
- Add HTTP assertions for both context modes; retain the tail
equivalence regression and full-read fallback.

No demo video: code-only change

**Risk:** low — read-only projection; journal hashing and restore keep
whole-log behavior. Tail reads still scan branch metadata; this is not
constant-time.
**Verified:** focused daemon tests 281 pass / 0 fail; restore 30 pass /
0 fail; context HTTP regression 1 pass / 0 fail; tail export 28 pass / 0
fail; typecheck and changed-file eslint exit 0; architecture 237 pass /
0 fail. Real daemon HTTP rig exercises `/kortix/runtime/log`. Full
application stack unavailable: local Supabase startup exits 1 (missing
kortix schema).
suna-skills: worktree, testing, learnings, contributing, create-pr
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 1 items found and fixed

## Summary

Closes KRTX-4488. The existing investigation identified repeated
whole-session projection on long-lived boxes: daemon time matched
request latency, while the control plane remained fast. Earlier hashing
removal reduced the cost but did not bound message projection. This PR
derives the last `limit × 4` entries for newest root pages and falls
back to the complete projection when it cannot establish pagination or
child linkage.

Feedback: 3 addressed · 0 answered without a change. Earlier missing
evidence sections and the current dev conflict are corrected. Merge
resolution preserves trunk's context opt-in. No unresolved GitHub review
threads exist.

## Demo video

No demo video: code-only change

## Type of change

Performance improvement to the daemon log read; merge-conflict repair
and regression coverage. No schema, dependency, or public export
changes.

## How was this tested?

All commands run in `apps/kortix-sandbox-agent-server` in this session.
Tests use synthetic fixtures and the actual daemon HTTP routes.

```text
$ bash scripts/test.sh src/__tests__/pi-session-log.test.ts src/__tests__/pi-harness.test.ts
281 pass
0 fail
1983 expect() calls
Ran 281 tests across 2 files. [28.33s]

$ bash scripts/test.sh src/__tests__/pi-session-log-restore.test.ts
30 pass
0 fail
281 expect() calls
Ran 30 tests across 1 file. [2.58s]

$ bash scripts/test.sh src/__tests__/pi-harness.test.ts --test-name-pattern 'the log routes page'
1 pass
252 filtered out
0 fail
22 expect() calls
Ran 1 test across 1 file. [697.00ms]

$ bash scripts/test.sh src/__tests__/pi-session-log.test.ts
28 pass
0 fail
137 expect() calls
Ran 28 tests across 1 file. [608.00ms]

$ pnpm typecheck
exit 0
$ pnpm exec eslint src/harness/pi/turns.ts src/harness/pi/session-log.ts src/__tests__/pi-session-log.test.ts src/__tests__/pi-harness.test.ts
exit 0
$ bun run test:architecture
237 tests
237 pass
0 fail
```

Red-without-fix: temporarily restored the implementation of
`session-log.ts` from origin/dev, retained the regression, then restored
the head implementation:

```text
$ bash scripts/test.sh src/__tests__/pi-session-log.test.ts --test-name-pattern 'a tail derives'
Expected: <= 1
Received: 12
0 pass
27 filtered out
1 fail
Ran 1 test across 1 file. [459.00ms]
```

`pnpm worktree start krtx-4488-feedback` exited 1: Supabase REST
returned 503 because schema `kortix` does not exist; the web/API stack
never started. No full-stack flow claimed. The daemon HTTP rig
independently boots the real app and verifies pagination, context
inclusion, and exclusions.

Whole-package and root full suites were not run: the product
repository's AGENTS.md and testing skill prohibit development-wide runs.
All three test files naming the changed exports ran. Production latency
remains unverified until the daemon asset deploys and boxes converge.
Acceptance remains p95 ≤ 1342.5 ms (1.5 × the issue's 895 ms baseline)
for 24 hours; compare like-volume windows and long-session box cohorts.

## Security & data review

Read-only changes. No authentication or authorization changes. Context
remains excluded by default. Explicit context inclusion is covered by
HTTP assertions. Synthetic fixtures only; no customer identifiers or
secrets added.

## Rollout / rollback

The daemon must roll into runtime assets and running boxes must
reconcile. Revert this PR to roll back. After deployment, read-only
health commit checks precede latency verification. No production
infrastructure changes.

## Reviewer checklist

- Tail suffix equality, sequence preservation, and fallback remain
covered.
- Current dev context filtering survives the conflict resolution.
- Restore and journal hashing stay unchanged.
- Production p95 is a post-deployment check, not a sandbox claim.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…ers (KRTX-4928) (#12722)

## Review in 60 seconds

- One provider-box removal helper replaces three copies; callers keep
logging, escalation and stamp-failure behavior.
- Shared snapshot deletion, archived-row updates, transition markers and
background warnings replace duplicate scaffolds; two unused null view
fields are removed.
- KRTX-4928 feedback: refresh stale evidence on head `aaaf8a6`. No
production-code edits in this feedback cycle; merge current trunk into
the existing branch.

No demo video: code-only change

**Risk:** low — behavior-preserving refactor. The removal helper stays
outside the widely mocked registry. Template deletion resolves identity
before provider lookup; neither performs a side effect before this
point.

**Verified:** final-head targeted tests: 262 pass, 0 fail, 729
assertions across 10 files; API typecheck exit 0; ESLint on seven
changed production files exit 0; seven importing suites 135 pass, 0 fail
at head and trunk. Three characterization files on trunk: 23 pass, 0
fail. Whole-package suite not run under repository targeted-testing
policy. Local-stack verification remains unavailable: initial shared
Supabase startup fails with missing `kortix` schema; primary bootstrap
retry fails at the same missing-schema boundary.

suna-skills: worktree, testing, learnings, contributing, create-pr

ponytail: full · review: Lean already. Ship. · markers: 0

Self-review: 1 items found and fixed (stale primary evidence and
deltas). Prior G9 stamp-failure and type-escape fixes retained and
rechecked.

## Summary

Closes KRTX-4928. Six deduplication/deletion findings implemented. The
helper module location differs from the suggested registry location to
avoid stripping the export in registry mocks. No feature, migration or
public-contract change.

## Demo video

No demo video: code-only change

## Type of change

- [x] Refactor (no behavior change)

## How was this tested?

Supervisor continuation 2, direct shell command at unchanged head
`aaaf8a6`:
```sh
bun test --env-file=scripts/test.env --isolate src/platform/providers/remove-box.test.ts src/projects/reaping/box-removal-characterization.test.ts src/snapshots/template-prebuilds-delete-kick.test.ts src/projects/provider-transition/provider-transition-marker.test.ts src/projects/sandbox-reaper.test.ts src/projects/reaping/archived-box-removal.test.ts src/apps/images.test.ts src/snapshots/delete-sandbox-image-identity.test.ts src/projects/provider-transition/provider-transition-store-activate.test.ts src/apps/remove-app-runtime-auth-outage.test.ts
 262 pass
 0 fail
 729 expect() calls
Ran 262 tests across 10 files. [4.12s]
```


Supervisor verification, run directly in this session at unchanged head
`aaaf8a6`:
```sh
bun --env-file=scripts/test.env test --isolate src/platform/providers/remove-box.test.ts src/projects/reaping/box-removal-characterization.test.ts src/snapshots/template-prebuilds-delete-kick.test.ts src/projects/provider-transition/provider-transition-marker.test.ts
 27 pass
 0 fail
 51 expect() calls
Ran 27 tests across 4 files. [1158.00ms]
bun --env-file=scripts/test.env test --isolate src/projects/sandbox-reaper.test.ts src/projects/reaping/archived-box-removal.test.ts src/apps/images.test.ts src/snapshots/delete-sandbox-image-identity.test.ts src/projects/provider-transition/provider-transition-store-activate.test.ts src/apps/remove-app-runtime-auth-outage.test.ts
 235 pass
 0 fail
 678 expect() calls
Ran 235 tests across 6 files. [3.40s]
```
The two direct runs total 262 pass, 0 fail and 729 assertions. A
whole-package suite remains prohibited by the repository AGENTS.md and
testing skill; these explicit files cover the touched API behavior.


Final head `aaaf8a6`, after merging `origin/dev`. Commands run from
`apps/api` unless stated otherwise.

```sh
bun --env-file=scripts/test.env test --isolate src/platform/providers/remove-box.test.ts src/apps/images.test.ts src/apps/remove-app-runtime-auth-outage.test.ts src/snapshots/delete-sandbox-image-identity.test.ts src/snapshots/template-prebuilds-delete-kick.test.ts src/projects/reaping/archived-box-removal.test.ts src/projects/reaping/box-removal-characterization.test.ts src/projects/sandbox-reaper.test.ts src/projects/provider-transition/provider-transition-store-activate.test.ts src/projects/provider-transition/provider-transition-marker.test.ts
 262 pass
 0 fail
 729 expect() calls
Ran 262 tests across 10 files. [4.58s]

pnpm typecheck
exit 0

pnpm exec eslint src/apps/images.ts src/platform/providers/remove-box.ts src/projects/provider-transition/provider-transition-activate.ts src/projects/provider-transition/provider-transition-routing.ts src/projects/reaping/archived-box-removal.ts src/projects/reaping/idle-volume-retire.ts src/snapshots/template-prebuilds.ts
exit 0
```

Additional importing suites, same command at head and trunk:

```sh
bun --env-file=scripts/test.env test --isolate src/__tests__/unit-managed-provision-guards.test.ts src/__tests__/unit-rebuild-shared-template-guard.test.ts src/__tests__/unit-session-runtime-guards.test.ts src/__tests__/unit-trigger-fire-paths.test.ts src/platform/services/session-sandbox.test.ts src/projects/routes/project-from-repository-personal-account.test.ts src/projects/provider-transition/provider-transition-audit.test.ts
# Head
 135 pass
 0 fail
 623 expect() calls
Ran 135 tests across 7 files. [12.53s]
# origin/dev
 135 pass
 0 fail
 623 expect() calls
Ran 135 tests across 7 files. [12.16s]
```

Characterization files copied onto trunk source (new-helper-specific
test excluded):

```sh
bun --env-file=scripts/test.env test --isolate src/projects/reaping/box-removal-characterization.test.ts src/snapshots/template-prebuilds-delete-kick.test.ts src/projects/provider-transition/provider-transition-marker.test.ts
 23 pass
 0 fail
 46 expect() calls
Ran 23 tests across 3 files. [1176.00ms]
```

No whole-package run: repository AGENTS.md and testing skill require
targeted files, not whole-package suites. Historical counts from earlier
sessions are removed rather than presented as current evidence.

Local-stack attempt from the primary checkout:
```sh
pnpm worktree start krtx-4928-feedback
supabase_rest_kortix-local unexpected status 503
primary Supabase credentials are unavailable
exit 1
```
PostgREST reports `schema "kortix" does not exist` during initial
startup. A primary `pnpm dev` bootstrap retry reaches the same
schema-cache failure and stops its containers. No real provider deletion
was performed. DB suites remain unverified:
- `integration-workspace-volume.test.ts`: retired-row identity/update
guards remain unchanged; shared helper preserves remove/status
classification.
- `metadata-merge.integration.test.ts`: patch payloads and
archived/pending WHERE guards remain unchanged.
- `provider-transition-fence.integration.test.ts`: generation bump and
lease fencing SQL remain unchanged.
- `provider-transition-flow.integration.test.ts`: activation CAS, locks
and marker payload keys remain unchanged.

Deltas at final head against `origin/dev`:
```sh
git diff --shortstat origin/dev
 12 files changed, 580 insertions(+), 107 deletions(-)
```
Net +473 lines including characterization coverage. Production
TypeScript +159 / −106 (net +53). The numeric deletion estimate is not
attained; no tests are removed to manufacture a negative delta. The
deduplication outcomes are attained.

`git diff --color-moved=zebra --color-moved-ws=allow-indentation-change
origin/dev` summary: both exact-identity safety comment blocks in
`deleteSandboxImage` are highlighted as moved blocks, indentation-only.
Comments retained verbatim. Churn check: each touched file has 2–6
commits in the last 30 days; none exceeds 10.

signal: handrolled_remove_box_copies 3 → 1; marker_definitions 2 → 1;
dead_view_fields 2 → 0. Counted from the three callers, the shared
helper and transition marker builder. The archived stamp-failure status
fallback is retained separately to preserve original DB-failure
behavior.

## Security & data review

No auth, secret or network change. Exact snapshot identity never
re-resolves a slug; KRTX-4465 guard comments retained.

## Rollout / rollback

No migration, flag or environment change. Revert the squash commit.

## Reviewer checklist

- [x] Both archived-row stamp-failure distinctions covered by
characterization tests.
- [x] Exact snapshot deletion remains independent of slug resolution.
- [x] Transition marker keys match existing consumers.
- [x] Primary counts and exact-head deltas refreshed.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Review in 60 seconds

- Add shared human-reader defaults and per-trigger overrides for new
trigger sessions.
- Keep reader grants separate from mutation IAM and agent authority.
- Batch space-kind checks for run lists; preserve DM/private-channel
protections.

No demo video: code-only change. Only API logic, docs and generated JSON
schemas change; public schema files are not UI.
**Risk:** medium — creation-time snapshots; no implicit backfill or live
policy changes.
**Verified:** 210 affected tests pass; 11/11 DB suites, 58 tests; TRG-44
1/1; API typecheck and source eslint exit 0.
suna-skills: worktree, testing, learnings, contributing and references,
create-pr.

## Summary

Closes KRTX-4984. Additive declarative trigger-session read policy; no
mutation authority.

## Demo video

No demo video: code-only change. API logic and generated manifest schema
assets have no interactive UI.

## Type of change

Feature and query-scaling correction.

## How was this tested?


- Outcome: KRTX-4984 adds creation-time shared human-reader defaults and
per-trigger overrides, without mutation authority or implicit agent
access.
- Reader list checks now batch channel/DM kinds once. Current membership
revocation, private-channel protection and explicit named-monitor policy
remain enforced.
- Existing sessions are not backfilled. Reconcile affects future
creations only. Existing independent owner/manager rights remain
unchanged.
- Closes KRTX-4984: https://linear.app/kortix/issue/KRTX-4984

**Risk:** additive read-only policy; no migration or live sharing
expansion. Revert this PR to remove the new declaration and reader path.
**Verified:** 210 affected unit tests pass; 15 focused permission tests
pass; 11/11 PostgreSQL suites, 58 tests pass; TRG-44 local HTTP flow 1/1
passed; API typecheck and changed-source eslint exit 0.

<details><summary>How was this tested? — this feedback worker</summary>

```sh
cd apps/api
bun --env-file=scripts/test.env test --isolate src/shared/preview-ownership.test.ts src/sandbox-proxy/routes/preview.test.ts src/sandbox-proxy/routes/preview-characterization.test.ts src/projects/lib/wake-ladder-authorization.test.ts src/projects/lib/__tests__/session-visibility-list.test.ts src/projects/trigger-reader-policy.test.ts src/projects/lib/session-inventory.test.ts
210 pass
0 fail
629 expect() calls
Ran 210 tests across 7 files. [2.98s]

bun --env-file=scripts/test.env test --isolate src/projects/lib/__tests__/session-visibility-list.test.ts src/projects/trigger-reader-policy.test.ts
15 pass
0 fail
50 expect() calls
Ran 15 tests across 2 files. [354.00ms]

# New test file against prior implementation e110aec, then implementation restored:
bun --env-file=scripts/test.env test --isolate src/projects/lib/__tests__/session-visibility-list.test.ts
5 pass
3 fail
29 expect() calls
Ran 8 tests across 1 file. [192.00ms]
# Bounded-query cases exceed their ceilings without the fix.

cd ../..
pnpm test -- --db-only integration-trigger-readers integration-session-ancestor-read integration-session-list
[db-suites] PASS 11/11 suites, 58 tests, 15.0s
[test] PASS db 41.7s

pnpm test -- --id TRG-44
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 1.1s
[test] PASS flows 98.1s

pnpm --filter kortix-api typecheck
# exit 0
cd apps/api
pnpm exec eslint src/projects/trigger-reader-access.ts src/projects/lib/session-visibility.ts src/projects/lib/session-list.ts src/projects/lib/session-inventory.ts
# exit 0
```

The real local API answered health 200 at localhost:13008. The
deterministic HTTP runner started and stopped its own stack.
Pre-existing: `bun --env-file=scripts/test.env test --isolate
src/projects/lib/session-list.test.ts` fails identically at origin/dev
a43aae8: 0 pass, 3 fail; `unexpected table in db.select().from()`.
Head's combined affected run: 210 pass, those same 3 fail. No unrelated
repair.
An initial DB selector `integration-session-access` matched no suite;
corrected to the existing ancestor/list/reader suites above.
Not verified: deployed dev pending merge/deploy, external cloud sandbox
turns. Whole-package tests intentionally not run under repository
testing policy. Manifest/schema code is unchanged in this feedback
cycle; earlier verification remains in the previous handoff, not claimed
as this worker's runs.
</details>

Feedback: 1 addressed · 0 answered without a change. Fix a93faf3;
trunk merge b8f7c55; final import cleanup 9eac86e.
Self-review: 2 items found and fixed
suna-skills: worktree, testing, learnings, contributing and references,
create-pr.
ponytail: full · review: Lean already. Ship. · markers: 0
model=kortix/codex/gpt-6.1-sol route=code reason=light-retry-escalation

## Security & data review

Synthetic fixtures only. No live policy writes. Reader access does not
grant lifecycle, prompt, config, sharing, approvals or writable proxy
access.

## Rollout / rollback

No migration. New declarations apply to future session creation. Revert
the PR to remove this capability.

## Reviewer checklist

- [x] Focused behavioral tests and real local HTTP flow pass.
- [x] Pre-existing trunk test failures identified and reproduced at
base.
- [x] No production sharing change or customer data.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
… shows one set of connect rows (KRTX-4948) (#12884)

## Review in 60 seconds

- **Desktop checkout now returns to the app.** The desktop shell's
navigation gate sent Stripe Checkout and the billing portal to the
system browser. Stripe's success, cancel and return URLs then also
opened there, so the app window never saw the return and the Subscribe
button kept its spinner. `checkout.stripe.com`, `billing.stripe.com` and
`pay.kortix.com` (Kortix's custom Stripe domain: a CNAME to
`hosted-checkout.stripecdn.com` that serves Stripe Checkout) now load in
the window, https on the default port only. Every other Stripe host and
every lookalike host still opens in the system browser.
- **Project home shows one set of "Connect ChatGPT / Connect Claude"
rows.** Home rendered the dismissible `SubscriptionOffer` next to the
composer, and the composer rendered its own no-model rows. Each decided
from a different input (the page from `/model-picker`, the composer from
its own selected model). When they disagreed, both sets rendered. Now
the composer's `ModelConnectionBar` owns both: the no-model rows, or the
dismissible offer where home provides `SubscriptionOfferContext`, never
both. First-chat home and the regular project home had the same pattern;
both are fixed.
- **Root cause, one sentence each:** (1) `shouldLoadInApp` had no rule
for Stripe's hosted pages; (2) two components owned the same rows and
read different inputs.

Demo: the regular project home on the local stack. The rows now render
inside the composer. A row's ✕ hides it, and the hidden row stays hidden
after a reload.


https://github.com/user-attachments/assets/dccca5d0-302f-46db-8999-214f74295b70

**Walkthrough**
1. First-chat home with a model: one set of tiles above the composer
(the composer-owned offer). ![first-chat home, one set of
rows](https://github.com/user-attachments/assets/1bac925a-b34c-4cba-86db-179282962231)
2. Regular project home: one set of rows under the composer card.
![project home, one set of
rows](https://github.com/user-attachments/assets/19cb29fa-0004-47d6-a818-eccbe6d59f0c)
3. Hover on "Connect ChatGPT": the arrow becomes the ✕ ("Don't show
ChatGPT"). ![hover shows the dismiss
control](https://github.com/user-attachments/assets/9d2db8a1-e039-4b21-bd2a-de867aa8eff6)
4. Click ✕: the ChatGPT row is gone. ![ChatGPT row
dismissed](https://github.com/user-attachments/assets/9bbf7c7a-681c-47de-ab69-2aa5a256bb62)
5. Reload: only "Connect Claude" is left. ![after
reload](https://github.com/user-attachments/assets/de24ac15-6d0d-4cba-bec3-39bfc3645543)

**Risk:** low — the desktop rule is an exact host set (3 hosts, https,
default port), and privileged IPC (`kortix:invoke`, window controls)
still checks the sender origin, so a Stripe page in the window gets no
native privilege. The shell rule ships only with the next desktop build:
installed shells keep the old behaviour until they update. A payment
method that redirects the whole page to a third-party site (for example
a bank redirect) still opens that site in the system browser; card 3-D
Secure runs in an iframe and is not affected. The offer rows lost their
own `px-4` / `max-w-210` wrapper and now sit in the composer's slot
(`mt-4` below, `mb-4` above), aligned with the composer card
(screenshots 1 and 2).
**Verified:** `bun test src` (apps/desktop-electron) → 254 pass, 0 fail;
`bun test --isolate` (packages/ui, whole suite) → 9516 pass, 0 fail;
`bun test --isolate src/workspace/home/first-chat.test.tsx` → 2 pass, 0
fail (red before the fix: 1 fail, "Expected: 1, Received: 2"); `bun test
src/nav-rules.test.js` → 10 pass, 0 fail (red before the fix: 3 fail);
`tsc --noEmit -p packages/ui` → exit 0; eslint on the changed UI files →
exit 0; local stack: both homes render one set of rows. Not run: the
desktop Electron app itself (the sandbox has no desktop build); the
literal "dismiss the Out-of-credits dialog" flow on the local stack
(session create returned 503 from the dev sandbox provider, so a send
never reached the credits check).
suna-skills: worktree, testing, learnings, contributing (+references),
create-pr, billing, agent-browser
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed

Closes KRTX-4948

## Summary

Two desktop-reported defects, one PR (one issue).

1. `apps/desktop-electron/src/nav-rules.js` gains
`isStripeHostedPage(url)`, an exact `https:` + `host` match against
`checkout.stripe.com`, `billing.stripe.com` and `pay.kortix.com`.
`apps/desktop-electron/src/main.js` `shouldLoadInApp` calls it after the
preview-host rule. The return URLs Stripe sends back to
(`billingReturnUrl`, `cancelUrl`, the portal `return_url`) are built
from the window's own URL (existing
`apps/web/src/features/billing/use-change-credit-plan.ts`), which on
desktop is always an allowed app path, so the return lands in the app
and the existing return watcher runs.
2. `packages/ui/src/session/models/model-connection-layout.ts` adds
`SubscriptionOfferContext` (a project id, default `null`).
`packages/ui/src/session/models/model-connection-gate.tsx`
`ModelConnectionBar` renders the no-model rows when `show`, else
`SubscriptionOffer` when the context names a project.
`packages/ui/src/workspace/home/first-chat.tsx` and
`packages/ui/src/workspace/home/welcome-body.tsx` provide the context
around the composer instead of rendering the offer themselves
(welcome-body keeps its rule: no offer after the first turn is sent).
`SubscriptionOffer` takes a `className` for its slot.

Why the production domain matters: `pay.kortix.com` resolves to Stripe's
hosted checkout, so a fix that listed only `checkout.stripe.com` and
`billing.stripe.com` would miss production.

## Demo video

The video and the walkthrough are in "Review in 60 seconds".

## Type of change

- [x] Bug fix
- [ ] New feature
- [ ] Refactor
- [ ] Docs / tests only

## How was this tested?

Regression tests first, red before the fix (the same test files run over
the `origin/dev` sources):

```
$ cd packages/ui && bun test --isolate src/workspace/home/first-chat.test.tsx    # before the fix
error: expect(received).toBe(expected)
Expected: 1
Received: 2
(fail) first-chat connect rows > one set of rows when the composer has no usable model, though /model-picker lists one
(pass) first-chat connect rows > one set of rows, the dismissible offer, when the composer has a model
 1 pass
 1 fail

$ cd apps/desktop-electron && bun test src/nav-rules.test.js    # before the fix
TypeError: isStripeHostedPage is not a function
 7 pass
 3 fail
```

After the fix, on head 1b83faa (the branch with `origin/dev` merged in):

```
$ cd apps/desktop-electron && bun test src/nav-rules.test.js
 10 pass
 0 fail
 39 expect() calls
Ran 10 tests across 1 file.

$ cd apps/desktop-electron && bun test src
 254 pass
 0 fail
 663 expect() calls
Ran 254 tests across 22 files.

$ cd packages/ui && bun test --isolate src/workspace/home/first-chat.test.tsx
 2 pass
 0 fail
 6 expect() calls
Ran 2 tests across 1 file.

$ cd packages/ui && bun test --isolate
 9516 pass
 0 fail
Ran 9516 tests across 863 files. [596.37s]

$ cd packages/ui && NODE_OPTIONS=--max-old-space-size=6144 npx tsc --noEmit -p .
(exit 0)

$ cd packages/ui && npx eslint src/workspace/home/first-chat.tsx src/workspace/home/first-chat.test.tsx src/workspace/home/welcome-body.tsx src/session/models/model-connection-gate.tsx src/session/models/subscription-offer.tsx src/session/models/model-connection-layout.ts
(exit 0)
```

The first-chat test renders the real `FirstChat`, `ModelConnectionBar`,
`SubscriptionOffer` and their hooks over a seeded React Query cache
(`/model-picker` serves one runnable Kortix model, no ChatGPT or Claude
plan). It mocks nothing under test. It counts the `role="group"` row
sets: 1 with the composer in its no-model state (no ✕), 1 with a model
(the dismissible offer).

Production domain check (read-only DNS and one GET, no payment):

```
$ curl -s "https://dns.google/resolve?name=pay.kortix.com&type=CNAME"   → ['hosted-checkout.stripecdn.com.']
$ curl -sI https://pay.kortix.com/c/pay/cs_test_x | grep content-security-policy
content-security-policy: ... connect-src 'self' https://api.stripe.com ... frame-src 'self' https://js.stripe.com ...
```

Local stack (`pnpm worktree start krtx-4948 --no-tunnel`, web :13000,
API :13008, synthetic `@example.test` user): first-chat home and the
regular project home each render exactly one set of rows; ✕ hides one
row and the choice survives a reload (video). Not run here: the Electron
app, and the Out-of-credits dialog flow (a send got 503 from the dev
sandbox provider before any credits check).

Pre-existing: `npx biome check apps/desktop-electron/src/main.js
apps/desktop-electron/src/nav-rules.js` reports formatter errors the
same at origin/dev; eslint is the package's lint.

## Security & data review

- No customer data in code, tests or this PR: synthetic ids
(`p-synthetic`, `cs_test_synthetic`) and an `@example.test` user.
- New in-window hosts are an exact allowlist; `http:`, other ports,
other Stripe hosts and lookalikes (`checkout.stripe.com.example.test`,
`evilcheckout.stripe.com`, `pay.kortix.com.example.test`) stay external
(tested).
- A Stripe page in the main window cannot call `kortix:invoke` or
`kortix:window`: both check the sender origin against the configured app
URL (existing `isTrustedSender`).

## Rollout / rollback

- Web/UI: ships with the next deploy. Rollback: revert this PR.
- Desktop: ships with the next desktop build; older installed shells
keep the old gate. Rollback: revert and rebuild.
- No migration, no API change, no SDK public-export change.

## Reviewer checklist

- [x] Every hunk traces to KRTX-4948
- [x] A regression test per fix, red before and green after
- [x] Whole suite of each touched package run
- [x] Synthetic data only

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Review in 60 seconds

- Cost reports retain their existing permit until every original
parallel query settles, including nested reconciliation.
- Lazy Drizzle queries are normalized once. Failure draining reuses the
same native promises and preserves the original error.
- Behavioral regressions cover real Drizzle QueryPromise execution
counts, queue recovery, multiple failures, and service wiring.

No demo video: code-only change

**Risk:** low — failed reports wait for siblings instead of returning
early; a stuck query retains the permit as intended. Admission limits,
SQL and response shapes are unchanged.
**Verified:** 269 targeted tests pass; API typecheck and lint exit 0;
COST-4 real local HTTP flow 1/1 passed; route coverage gate passed; four
DB suites pass (16 tests).
suna-skills: worktree, testing, learnings, contributing (attachments
reference), create-pr, billing
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed

## Summary

Fixes KRTX-4992: https://linear.app/kortix/issue/KRTX-4992

Current dev has `withCostReadGuard`, not the rejected PR's report-slot
helper. This change adds one draining primitive beside that guard and
uses it for the eight parallel joins in the two cost services. Fail-fast
Promise.all previously released a permit while siblings still ran.
Re-assimilating lazy builders during draining would instead execute them
twice.

## Demo video

No demo video: code-only change. The real local HTTP COST-4 flow
exercises cost-summary, cost-by-project and session-cost authorization
and reporting.

## Type of change

Bug fix; no migration or public API change.

## How was this tested?

```sh
cd apps/api
. ../../scripts/hermetic-test-env.sh
bun test --isolate --env-file=scripts/test.env src/shared/cost-read-queries.test.ts src/shared/cost-read-guard.test.ts src/shared/cost-rollups.test.ts src/shared/session-costs.test.ts src/shared/session-costs-service.test.ts src/shared/cost-value-parity.test.ts src/router/routes/usage-cost-summary-http.test.ts src/router/routes/usage-cost-by-project-http.test.ts src/router/routes/usage-session-costs-http.test.ts src/admin/analytics-usage-unavailable.test.ts src/__tests__/unit-workspace-binding-coverage.test.ts src/mcp/shape.test.ts
269 pass
0 fail
733 expect() calls
Ran 269 tests across 12 files. [1.86s]
```

```sh
pnpm --filter kortix-api typecheck
> tsgo --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsgo.tsbuildinfo
exit 0
pnpm --filter kortix-api lint
> eslint src
exit 0
cd tests && bun bin/ke2e.ts coverage
95.9% covered · 1740/1814 routes · 74 allowlisted · 0 uncovered
✓ coverage gate passed
pnpm test -- --id COST-4
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 1.9s
[test] PASS flows 99.3s
pnpm test -- --db-only integration-moved-project-costs integration-cost-rollups-covering-index integration-llm-value gateway-source-spend
[db-suites] PASS 4/4 suites, 16 tests, 11.8s
[test] PASS db 39.7s
```

Red-first: the new QueryPromise test against the original fail-fast join
had one passing case and two failing cases: the next report started
before drain. Replacing allSettled(nativePromises) with
allSettled(originalBuilders) also failed both cases (two executions
instead of one). The real session-service regression against original
Promise.all joins failed because the next report started before nested
reconciliation drained. Both final tests pass above.

Pre-existing: `pnpm exec eslint --no-ignore
src/shared/session-costs-service.test.ts` fails the same at origin/dev:
two existing `../projects/lib/access` import violations (layers and
projects-surface). Default API lint excludes test files and passes. The
new standalone test has no forced-lint errors.

The initial `pnpm worktree start krtx-4992 --no-web` failed because an
empty local Supabase lacked the kortix schema. The flow runner
subsequently initialized migrations and exercised real local HTTP
successfully. Whole-package tests are not run: repo-local AGENTS/testing
require named targeted files. COST-1/2 cloud-sandbox flows are not run;
COST-4 covers the local reporting routes. Dev verification and
independent exact-head G9 remain pending the normal merge gate.

## Security & data review

No auth, SQL, credential, schema or production-data change. Fixtures are
synthetic. No added casts, any, suppressions or TODOs.

## Rollout / rollback

Normal API deployment. Revert this commit to restore the previous join
behavior; no data rollback.

## Reviewer checklist

- Acceptance mapped to helper lines 63–70; eight service joins;
QueryPromise and nested service regressions.
- Original rejection identity and post-failure queue progress asserted.
- Self-review A–H complete; independent G9 still required.

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Review in 60 seconds

- Clearing an agent pin now suppresses the legacy account-wide fallback
in that project instead of exposing it again.
- The existing preference row records the clear atomically. Other
projects retain their legacy pins; account and project defaults are
unchanged.
- PostgreSQL and HTTP regressions cover retired-agent cleanup and
repeated clears. No schema, CLI, or authorization change.

No demo video: code-only change

**Risk:** low — an empty project-scoped model is an internal clear
marker, omitted from resolved agent defaults. Explicit re-pinning
replaces it.
**Verified:** focused API tests 42 pass / 0 fail; resolution 48 pass / 0
fail; caller tests 85 pass / 0 fail; CLI subprocess tests 18 pass / 0
fail; PostgreSQL lifecycle and HTTP regression pass; API typecheck and
changed-source eslint exit 0; local PROJ-37 1/1 passed. PROJ-27 is
excluded by the local profile because it requires funded capability.
Post-deployment verification remains pending.

suna-skills: worktree, testing, learnings, contributing (attachments and
preview-environments references), create-pr
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 1 items found and fixed
model=kortix/codex/gpt-6.1-sol route=code
reason=conservative-code-default

## Summary

Closes KRTX-4962: https://linear.app/kortix/issue/KRTX-4962

Root cause: deleting the project agent row exposes the older
account-wide agent row on every fresh read. DELETE already awaits
persistence and invalidates the account cache; CLI already awaits DELETE
before reporting success. Preserve an explicit clear using the existing
indexed upsert rather than deleting another project's fallback.

## Demo video

No demo video: code-only change. The actual HTTP handlers and PostgreSQL
read-back are tested below.

## Type of change

Bug fix. No migration or public SDK export change.

## How was this tested?

Commands ran in `/workspace/suna-krtx-4962` unless noted. Package-wide
suites were not run: repository AGENTS.md/testing explicitly require
targeted files during development.

```text
# From apps/api, before implementation:
bun test --isolate --env-file=scripts/test.env src/repositories/model-preferences.test.ts
22 pass
1 fail
Ran 23 tests across 1 file. [116.00ms]
# Regression: cleared retired agent remained in the agents map.

# Real PostgreSQL against the original implementation:
pnpm test -- --db-only model-preferences.integration
0 pass
1 fail
3 expect() calls
Ran 1 test across 1 file. [309.00ms]
# Fresh read unexpectedly contained retired: legacy-model after clear.

# After implementation:
pnpm test -- --db-only model-preferences.integration
[db-suites] PASS 1/1 suites, 1 tests, 2.1s

pnpm test -- --db-only integration-agent-name-gate-http
[db-suites] PASS 1/1 suites, 6 tests, 5.6s
# Includes actual DELETE and fresh GET requests for a retired legacy pin.

# From apps/api:
bun test --isolate --env-file=scripts/test.env src/repositories/model-preferences.test.ts src/projects/routes/model-write-guards.test.ts
42 pass
0 fail
84 expect() calls
Ran 42 tests across 2 files. [1482.00ms]

bun test --isolate --env-file=scripts/test.env src/llm-gateway/resolution/default-model.test.ts src/__tests__/unit-choose-default-model.test.ts
48 pass
0 fail
74 expect() calls
Ran 48 tests across 2 files. [2.33s]

bun test --isolate --env-file=scripts/test.env src/llm-gateway/models/seed-default.test.ts src/llm-gateway/servable-catalog-parity.test.ts src/projects/routes/model-access-default.test.ts src/projects/routes/session-open-bundle.test.ts src/__tests__/unit-trigger-fire-paths.test.ts
85 pass
0 fail
442 expect() calls
Ran 85 tests across 5 files. [4.27s]

# From apps/cli; real CLI subprocesses:
bun test --isolate src/__tests__/agents-command.test.ts src/__tests__/models-command.test.ts
18 pass
0 fail
89 expect() calls
Ran 18 tests across 2 files. [20.02s]

pnpm --filter kortix-api typecheck
exit 0
# From apps/api:
pnpm exec eslint src/repositories/model-preferences.ts
exit 0

git diff --check
exit 0

pnpm test -- --id PROJ-27 --id PROJ-37
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 2.1s
# Repeated --id selects the last id: this ran PROJ-37 only, on localhost:13008.
pnpm test -- --id PROJ-27
Error: no local flows selected; excluded: PROJ-27 (external capabilities: funded)
```

The new PostgreSQL lifecycle covers legacy-only clear, set/read/clear,
repeated clear, re-pin, and seed-only write after clear. Account/default
and unrelated pins remain unchanged. Other projects still see their own
legacy fallback. New HTTP coverage uses the existing in-process
application with a real DB and git fixture. Existing guard tests verify
unauthorized DELETE cannot write. No production data was changed.

Local setup initially required starting Supabase and migrating the empty
DB. `pnpm worktree start krtx-4962 --no-web` initially refused the
uninitialized primary schema. The targeted flow runner subsequently
initialized it and exercised PROJ-37 on the real worktree API. One
overlapping runner setup failed; the sequential HTTP rerun passed.
PROJ-27 remains unrun because funded is an explicit external-profile
exclusion, not a pass. The workspace split and project-transfer DB
suites were read, not run: their assertions concern nonempty
account/project models, whose paths remain unchanged. A deployed
restart/reconciliation check remains unverified; the clear is persisted
in PostgreSQL, not process memory.

## Security & data review

Synthetic fixtures only. Existing project.model.write checks remain
unchanged. Failed persistence still throws before API success. No
secrets, customer data, new permissions, or production writes.

## Rollout / rollback

Normal API deployment, no migration. Existing pins are unchanged until
explicitly cleared. Re-pin to replace a clear marker. Reverting restores
the prior read/delete behavior without deleting legacy rows; any stored
empty markers remain and should be re-pinned if restoring an old pin is
desired.

## Reviewer checklist

- Acceptance mapped to repository clear/read code and PostgreSQL/HTTP
regressions.
- Self-review A–H completed; removed an unreachable predicate branch.
- No new dependencies, type escapes, or unrelated changes.
- G9 and deployment verification remain separate gates.

<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/enable-autofix?expires=1797698387&installation_model_id=434224&pr_number=12889&ref=codesmith_pr_footer&repository=kortix-ai%2FCompanyOS&return_to=https%3A%2F%2Fgithub.com%2Fkortix-ai%2FCompanyOS%2Fpull%2F12889&signature=1f0118c67ceec23cb92a063ec20172d4dfc95ad51d82adfd5d80a6cb6cf5e6f8"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/kortix-ai/codesmith/CompanyOS/pr/12889?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…e in-app browser (KRTX-4966) (#12799)

## Review in 60 seconds

- iOS app: the kortix.com Smart App Banner also shows inside the app's
own in-app browser (Safari View Controller). Its **OPEN** sends
`kortix://` to the app already running behind that browser. Before, the
root link handler (`apps/mobile/app/_layout.tsx`) only logged "Not an
auth callback", so the browser stayed open and the tap looked dead. Now
`closeBrowserOnAppOpen` (`apps/mobile/lib/utils/browser-return.ts`)
closes the browser on iOS (`dismissAuthSession` + `dismissBrowser`, the
native not-open rejection ignored).
- A warm `kortix://` keeps the current screen
(`apps/mobile/app/+native-intent.ts`); before, expo-router re-routed the
hidden screen to `/`. A cold start still begins at `/`.
- Auth callbacks, share, invite and browser-return links (`providers`,
`connectors`, `web`) take their existing paths (test-covered). Android
does nothing new: expo-web-browser has no dismiss there, and the banner
is iOS only. Mobile version 1.6.44 → 1.6.45 (`set-version.mjs --next`).

No demo video: the change runs only in the native iOS app (Safari View
Controller + Smart App Banner), and this Linux sandbox has no iOS
simulator or device. The web local stack runs no part of this diff.

**Risk:** low — iOS only, and only for the exact URL `kortix://` (or
`kortix:///`). A tap on OPEN during an in-app sign-in closes that sheet,
and the app shows the screen behind it.
**Verified:** `bun test lib/utils/browser-return.test.ts` → 8 pass, 0
fail (red before the fix) · 4 mutants of the helper each fail a test ·
neighbor tests → 74 pass, 0 fail · `bun test --isolate` (whole mobile
package) → 3880 pass, 5 pre-existing fails (same at origin/dev) · `expo
export --platform ios` → bundle built · `pnpm typecheck` → 1
pre-existing error · `curl https://kortix.com/auth` → banner
`app-argument=kortix://` · not run: local stack (primary Supabase not
provisioned in this sandbox; no surface of this diff runs on it), a tap
on a physical iPhone
suna-skills: contributing, create-pr, testing, worktree, learnings,
ponytail, ponytail-review
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 3 items found and fixed

## Summary

Root cause: `handleDeepLink` in `apps/mobile/app/_layout.tsx` had no
case for the bare app URL `kortix://` (the banner's `app-argument`,
served by `apps/web/src/app/[locale]/layout.tsx`, existing), so nothing
closed the in-app browser.

- `apps/mobile/lib/utils/browser-return.ts`: `isAppOpenUrl` and
`closeBrowserOnAppOpen`, pure, with the browser injected so `bun test`
covers it.
- `apps/mobile/app/_layout.tsx`: the root link handler calls it first
and returns.
- `apps/mobile/app/+native-intent.ts`: `kortix://` joins share and
browser-return links: `null` warm (no navigation), `/` cold.
- Version files: `app.json`, `ios/Kortix/Info.plist`,
`ios/Kortix/Supporting/Expo.plist`, `android/app/build.gradle`,
`android/app/src/main/res/values/strings.xml`.

Closes KRTX-4966

## Demo video

No demo video: this Linux sandbox has no iOS simulator or device (native
iOS runtime unavailable), and the change runs only in the native iOS app
(Safari View Controller + Smart App Banner). The web local stack runs no
part of this diff.

## Quick verification

- Outcome: inside the Kortix iOS app's in-app browser, the kortix.com
Smart App Banner's OPEN closes the browser and returns to the app.
- Device check (TestFlight build from this merge): in the app, open a
kortix.com page in the in-app browser (for example Settings → a
kortix.com link), tap OPEN on the banner. Expected: the browser closes
and the screen you came from shows.
- Tests: `cd apps/mobile && bun test lib/utils/browser-return.test.ts` →
8 pass, 0 fail (red before the fix: 0 pass, 1 fail)
- Neighbor tests: `cd apps/mobile && bun test` on the 8 files that name
a changed module → 74 pass, 0 fail
- Whole package: `cd apps/mobile && bun test --isolate` → 3880 pass, 5
pre-existing fails (the same 5 at origin/dev); iOS bundle export OK;
details below.

## Type of change

- [x] Bug fix

## How was this tested?

Red, before the fix (this test file, sources at origin/dev):

```
$ cd apps/mobile && bun test lib/utils/browser-return.test.ts
SyntaxError: Export named 'isAppOpenUrl' not found in module '.../apps/mobile/lib/utils/browser-return.ts'.
 0 pass
 1 fail
 1 error
```

Red, with the helper but `+native-intent.ts` at origin/dev:

```
$ cd apps/mobile && bun test lib/utils/browser-return.test.ts
Received: "kortix://"
(fail) redirectSystemPath: the iOS Smart App Banner OPEN (kortix://) > a warm open keeps the current screen; a cold start begins at the splash
 7 pass
 1 fail
```

Mutants of `closeBrowserOnAppOpen` (each applied alone, then reverted).
Every one fails a test:

```
no .catch on dismissBrowser   -> (fail) no open browser is not an error                         7 pass 1 fail
no iOS check                  -> (fail) Android has no dismiss API: handled, nothing called      7 pass 1 fail
no dismissBrowser call        -> (fail) the bare app URL closes the in-app browser on iOS (+1)   6 pass 2 fail
regex /^kortix:\/\//i         -> (fail) every other link is left to its own handler              7 pass 1 fail
```

Green, at this head:

```
$ cd apps/mobile && bun test lib/utils/browser-return.test.ts
 8 pass
 0 fail
 37 expect() calls
Ran 8 tests across 1 file.
```

Every test file that names a changed module or the version files:

```
$ cd apps/mobile && bun test lib/utils/browser-return.test.ts lib/invites/invite-landing.test.ts lib/session/connect-model.test.ts lib/projects/web-project-links.test.ts components/kortix/sheet-imports.test.ts components/updates/UpdateRequiredGate.test.tsx lib/auth/sso-required.test.ts scripts/set-version.test.ts
 74 pass
 0 fail
 207 expect() calls
Ran 74 tests across 8 files.
```

Whole mobile package:

```
$ cd apps/mobile && bun test --isolate
 3880 pass
 5 fail
Ran 3885 tests across 352 files. [30.81s]
```

Pre-existing: the 5 fails are in `lib/markdown/markdown-keys.test.ts`
(4, `react-native-markdown-display AST keys (patched)`) and
`lib/utils/theme.test.ts` (1, `global.css matches apps/web
globals.css`). With the 9 files of this diff reset to origin/dev, `cd
apps/mobile && bun test --isolate lib/utils/theme.test.ts
lib/markdown/markdown-keys.test.ts` fails the same (61 pass, 5 fail).
This PR touches neither file.

Pre-existing: `cd apps/mobile && pnpm typecheck` fails the same at
origin/dev (1 error, `components/session/ProjectScreen.tsx(1004,9):
error TS2322`). This PR adds no error. `apps/mobile` has no eslint
config.

iOS JS bundle (Metro + Hermes) builds with the change:

```
$ cd apps/mobile && npx expo export --platform ios --output-dir /tmp/expo-export-ios
Exported: /tmp/expo-export-ios
```

The banner input the fix keys on, live:

```
$ curl -s https://kortix.com/auth | grep -o '<meta name="apple-itunes-app"[^>]*>'
<meta name="apple-itunes-app" content="app-id=6754448524, app-argument=kortix://"/>
```

expo-web-browser 58.0.7 iOS (`ios/WebBrowserModule.swift`):
`dismissBrowser` throws `WebBrowserNotOpenException` when no Safari View
Controller is open (hence the `.catch`); `dismissAuthSession` is a no-op
without a session. A programmatic dismiss resolves `openBrowserAsync`
with `dismiss`, the same as the Done button, so `openBrowserUntilClosed`
and its callers are unaffected.

Not run: the worktree's local stack (`pnpm worktree start` stops: the
primary Supabase has no `kortix` schema in this sandbox); no file of
this diff runs on the web or API stack. Not verified: a tap on the
banner on a physical iPhone or simulator. That iOS delivers `kortix://`
to the app while its own Safari View Controller is open is inferred from
the report, not observed. The TestFlight build after the merge is the
device check.

## Security & data review

No auth, token or data handling changes. The handler matches only
`kortix://` and calls the two dismiss functions of expo-web-browser. No
customer data in this PR.

## Rollout / rollback

Mobile changes merged into `dev` build iOS for TestFlight. Rollback:
revert this PR.

## Reviewer checklist

- [x] Root cause named; the regression tests fail before the fix and
pass at this head
- [x] Auth-callback, share, invite and browser-return links unchanged
(test-covered)
- [ ] Device check on TestFlight after the merge

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

Peer-work progress keeps intermediate replies inside expanded activity.
The final answer stays visible.


https://github.com/user-attachments/assets/60908b55-8ca2-401d-aaa3-5352b0acb19f

**Walkthrough**
1. The completed peer run shows its compact progress row and final
answer. ![Collapsed
activity](https://github.com/user-attachments/assets/87ada464-1114-44b4-a337-36c8e4e5c147)
2. Open progress to read the peer report and intermediate reply.
![Expanded
activity](https://github.com/user-attachments/assets/57c1c564-79e8-47f6-b9bb-33fd8f892f5d)
3. Close progress; the final answer remains visible. ![Final
answer](https://github.com/user-attachments/assets/b9947090-13bb-44ed-b029-5b1e3de82767)

## Quick verification

- Outcome: KRTX-4982 folds intermediate peer replies and live peer
activity into the existing run disclosure.
- Existing grouping boundaries preserve questions, deliverable cards,
errors, and ordinary single-agent streaming. The launch acknowledgment
remains a separate turn; this change does not merge launch turns into
report runs.
- Root cause: the run renderer deliberately placed absorbed turns'
answers outside its activity fold; live anchors also bypassed the work
split.
- **Risk:** medium — shared transcript rendering changes. Revert this PR
to restore the previous layout. No schema or SDK public API change.
- **Verified:** focused renderer tests, UI typecheck, changed-file
eslint, brand audit, and saved synthetic peer transcript on the local
worktree stack.
- Local API `/v1/health`: HTTP 200. Browser DOM assertions: expanded
activity contains the intermediate reply; collapsed activity hides it;
final answer remains visible in both states. Video uses synthetic data.
Four frames inspected.
- Not verified: real live peer execution, native Electron, mobile, or
deployed dev. Live peer folding and ordinary streaming are covered by
renderer tests. Local saved-session fixture cannot start its synthetic
repository; the computer retry banner is unrelated to transcript
rendering.

```sh
pnpm --filter @kortix/ui test src/session/thread/transcript-agent-run.test.tsx
# RED before answer-fold fix: 6 pass, 1 fail
# RED before live-fold fix: 7 pass, 1 fail (hidden expected true, received false)
pnpm --filter @kortix/ui test src/session/thread/transcript-agent-run.test.tsx src/session/thread/transcript-completion.test.tsx src/session/thread/transcript-notice-fold.test.tsx src/session/thread/transcript-response.test.tsx src/session/thread/transcript-show-work.test.tsx
21 pass
0 fail
84 expect() calls
Ran 21 tests across 5 files. [15.42s]
pnpm --filter @kortix/ui typecheck
# exit 0
pnpm --filter @kortix/ui exec eslint src/session/thread/transcript.tsx src/session/thread/transcript-agent-run.test.tsx
# exit 0; 0 errors, 1 existing react-hooks/set-state-in-effect warning at transcript.tsx:1382
.agents/skills/kortix-brand/scripts/audit.sh packages/ui/src/session/thread/transcript.tsx packages/ui/src/session/thread/transcript-agent-run.test.tsx
# clean — every value came from the allowlist
```

Tests were rerun after merging origin/dev. No DB-backed test changes.

## How was this tested?

Re-run in the feedback-cycle session (ee47affa) on head cd02617, fresh
checkout + `pnpm install --frozen-lockfile`:

```sh
cd packages/ui && bun test --isolate src/session/thread/transcript-agent-run.test.tsx
 8 pass
 0 fail
 25 expect() calls
Ran 8 tests across 1 file. [2.46s]

pnpm --filter @kortix/ui test   # whole @kortix/ui unit suite
 9535 pass
 0 fail
Ran 9535 tests across 863 files. [534.69s]

NODE_OPTIONS=--max-old-space-size=8192 npx tsc --noEmit -p packages/ui
# exit 0 (the default heap ran out of memory, exit 134; nothing to do with this diff)

npx eslint src/session/thread/transcript.tsx src/session/thread/transcript-agent-run.test.tsx
# exit 0; ✖ 1 problem (0 errors, 1 warning): the existing react-hooks/set-state-in-effect warning
```

Self-review: 1 items found and fixed (retain report/reply order inside
expanded activity).
ponytail: full · review: Lean already. Ship. · markers: 0
suna-skills: worktree, testing, learnings, contributing, create-pr,
kortix-brand, kortix-design-system, kortix-ui, sdk (read-only
investigation)
model=kortix/codex/gpt-6.1-sol route=visual reason=claude-exhausted;
intended=claude-agent/opus

Closes KRTX-4982
https://linear.app/kortix/issue/KRTX-4982

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…12896)

## Demo video

No demo video: code-only change (CLI request routing; no UI changes).

## Quick verification

- **Outcome:** `kortix tokens ls` and `tokens rm` can manage personal
keys after their original workspace closes. On exactly `403
workspace_closed`, use the existing person-owned `/me/tokens` surface.
Other denials remain errors. Workspace grants and credential fences are
unchanged.
- Root cause: the CLI used workspace-scoped token routes even for
unbound personal credentials. Current trunk already revokes
workspace-bound keys on closure; personal keys intentionally survive.
- Review fix (G9 item 1, commit 34d8d1c): the `/me/tokens` fallback
returns the caller's personal history, including revoked keys. Plain
`ls`, `ls --all` and `ls --mine` now list only live keys on the fallback
(`status='active'` and `revoked_at` null). Revoked keys appear only with
`ls --mine --all`, the same rule as the normal `--mine` list.
- Closes KRTX-4945 — https://linear.app/kortix/issue/KRTX-4945
- **Risk:** fallback lists the caller's personal keys across workspaces,
as the existing Personal keys page does. It never lists another person's
keys. Revert the CLI commit to roll back. No migration or SDK export
changes.
- **Verified:** review-fix regression red without the fix (1 pass; 1
fail; revoked tok_b/tok_c listed by default `ls`), green with it; 31
pass, 0 fail targeted CLI tests after the trunk merge; targeted CLI
tests, typecheck, configured CLI lint, and real CLI/API calls on the
local worktree stack. No deployed writes.

```text
cd apps/cli && bun test src/__tests__/tokens-command.test.ts -t "closed workspace" (review regression, fallback filter stashed)
(pass) a closed workspace does not block listing or revoking the caller personal keys
- Expected  - 0
+ Received  + 2
(fail) a closed workspace lists only live personal keys unless --mine --all
1 pass; 1 fail

same command with the fix
2 pass; 21 filtered out; 0 fail; 13 expect() calls

cd apps/cli && bun test src/__tests__/tokens-command.test.ts src/__tests__/tokens-split.characterization.test.ts (head 4ffaea9, after merging origin/dev)
31 pass
0 fail
186 expect() calls
Ran 31 tests across 2 files. [4.78s]
pnpm typecheck (apps/cli) → exit 0 · pnpm lint:sdk-boundary → CLI SDK boundary: 0 violations. · git diff --check → exit 0

Earlier round:
bun test apps/cli/src/__tests__/tokens-command.test.ts (new tests, unchanged trunk implementation)
21 pass; 1 fail; 142 expect() calls; Ran 22 tests across 1 file. [4.40s]
closed-workspace regression: expected exit 0, received 1

pnpm --filter @kortix/cli test src/__tests__/tokens-command.test.ts src/__tests__/tokens-split.characterization.test.ts
30 pass
0 fail
178 expect() calls
Ran 30 tests across 2 files. [4.20s]

pnpm --filter @kortix/cli typecheck
exit 0

pnpm --filter @kortix/cli lint:sdk-boundary
CLI SDK boundary: 0 violations.

git diff origin/dev...HEAD --check
exit 0
```

- Local `proj-delete-account-cleanup` observation: Mailpit sign-in →
create synthetic workspace → mint personal key 201 → delete workspace
200 → key still authenticates 200 → workspace token list 403 → personal
list 200 → real CLI `tokens ls --mine --json` exit 0 → `tokens rm
<token_id> -y --force` exit 0 → revoked key 401. Profile Delete
immediately then returned to `/auth`; old browser JWT returned 401.
- Not verified: re-sign-in after account deletion, root-runner flow and
deployed dogfood rerun. Initial Supabase bootstrap failed on missing
schema; repository local-up migrations recovered it and the local stack
ran. The contributing sign-in script's label lookup failed; completed
the same Mailpit flow with browser refs and its mail helper.
- ESLint invocation cannot run: apps/cli has no eslint.config. Its
configured lint:sdk-boundary passed. Whole-package tests not run under
repository targeted-only testing policy.
- Self-review: 1 items found and fixed (G9 item 1: revoked rows in the
default fallback list). Checks A–H completed; no added type escapes,
dependencies or permission changes.
- suna-skills: worktree, testing, learnings, contributing, create-pr,
agent-browser.
- ponytail: full · review: Lean already. Ship. · markers: 0
- model=claude-agent/opus route=visual reason=route-label (feedback
cycle). Earlier round: model=kortix/codex/gpt-6.1-sol route=visual
reason=claude-exhausted.

<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/enable-autofix?expires=1797703283&installation_model_id=434224&pr_number=12896&ref=codesmith_pr_footer&repository=kortix-ai%2FCompanyOS&return_to=https%3A%2F%2Fgithub.com%2Fkortix-ai%2FCompanyOS%2Fpull%2F12896&signature=d656bd9422ecb3a585afc01cd6a4955d7f3b2ad72f707475132205114235348c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/kortix-ai/codesmith/CompanyOS/pr/12896?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

No demo video: local stack unavailable for native mobile interaction in
this sandbox. No iOS or Android emulator is installed. Expo web startup
fails before the selector renders (`Cannot read properties of null
(reading 'useEffect')`), so the local-stack web origin does not reach
the mobile picker. Native touch scrolling, both themes and device
screenshots remain unverified; the component tests below do not prove
native hit testing.

## Quick verification

Outcome: mobile names agents the way web does: "My Kortix", legacy
built-in aliases, separated slugs, and the configured `title` from
`kortix.yaml`, both in the Agent picker rows and in the composer chip.
Mobile version is 1.6.46 (the trunk took 1.6.45 in KRTX-4966, so this
task re-synced and bumped once, per apps/mobile/AGENTS.md). The
off-screen Agent tab was already repaired on trunk by #12760; this PR
adds coverage for its full-height list, bottom padding, last-row
selection and tab callback without another layout rewrite.

- **Review in 60 seconds:**
- `lib/session/composer-config.ts`: `agentDisplayName` uses the shared
web formatter. `threadAgents` (the roster behind ProjectHome and
SessionPage) now keeps each agent's `title`, as the SDK's
`projectConfigAgentsToRuntimeAgents` does. `composerChip` takes
`agentTitle` for the resolved agent, matching web's
`agent-selector.tsx`.
- `ModelPickerSheet.tsx` passes `a.title`; `ProjectHome.tsx` and
`SessionChatInput.tsx` pass the selected agent's title to the chip.
- Tests: config → `threadAgents` → `ModelPickerSheet` rows (`GitHub PR
Reviewer`, `My Kortix`, `Chief of staff`); the chip title (and that a
pending agent never borrows it); the 40-row `PickerSheet`
scroll/select/tab characterization.
- Open the composer selector: Agent and Model tabs remain available.
Choose an agent, then a model. Scroll to the final choice. A configured
title shows in the row and the chip. Native-device confirmation remains
required.
- Refs KRTX-4980: https://linear.app/kortix/issue/KRTX-4980
- Review feedback (G9, head 6e3b1b4): `threadAgents` dropped `title`.
Fixed in b65f9b8; the same gap in the composer chip was fixed in
12677d8.
- Review feedback (G9, head 12677d8): the roster test cast its config
with `as unknown as ProjectConfigSummary`. Fixed in 56426a6: a
complete typed `ProjectConfigSummary` fixture (every required field), no
cast. The same commit replaces the new PickerSheet test's `tree!`
assertions with a narrowed renderer. The PR's diff now adds no `as
unknown`, `as never`, `!` or `any`.
- Red before each fix, green after:
- formatter: `bun test lib/session/composer-config.test.ts` → **19 pass,
1 fail** (expected `My Kortix`, received `Mykortix`), then 20 pass, 0
fail.
- roster title through the adapter: `bun test --isolate
components/session/ModelPickerSheet.test.tsx` without the `threadAgents`
hunk → **3 pass, 1 fail** (expected `GitHub PR Reviewer`, received
`Github pr reviewer`); with it → 4 pass, 0 fail.
- chip title: `bun test --isolate lib/session/composer-config.test.ts`
without the chip hunks → **20 pass, 1 fail** (received `Github pr
reviewer`); with them → 21 pass, 0 fail.

```text
cd apps/mobile
bun test --isolate lib/session/composer-config.test.ts components/session/ModelPickerSheet.test.tsx components/session/PickerSheet.test.tsx components/kortix/native-sheet.test.tsx components/kortix/use-close-then.test.tsx components/session/session-chat-input-renders.test.tsx components/session/project-home-renders.test.tsx
93 pass
0 fail
259 expect() calls
Ran 93 tests across 7 files. [4.08s]

bun test --isolate            # whole apps/mobile unit suite
3883 pass
5 fail
Ran 3888 tests across 353 files. [28.70s]
```

The 7-file run is on head 6dfbd02. The whole suite ran on 90aa7f3
(origin/dev merged in); 6dfbd02 only Biome-formats PickerSheet.test.tsx,
which passes in the 7-file run.

Pre-existing: the 5 suite failures (`lib/markdown/markdown-keys.test.ts`
×4, `lib/utils/theme.test.ts` ×1) fail the same at origin/dev: `bun test
--isolate lib/markdown/markdown-keys.test.ts lib/utils/theme.test.ts` →
61 pass, 5 fail in both trees.
Pre-existing: `npx tsgo --noEmit` (apps/mobile typecheck) fails the same
at origin/dev with one error, `ProjectScreen.tsx(1004,9): TS2322`,
`openSpringConfig` not on `DrawerProps`. No errors in changed files.
Pre-existing: mobile has no ESLint config; `biome check` reports the
same error counts on every changed source file at origin/dev and at the
head (base/head: ProjectHome 2/2, SessionChatInput 5/5, composer-config
2/2, composer-config.test 2/2, ModelPickerSheet 2/2,
ModelPickerSheet.test 4/4). The new PickerSheet.test.tsx reports 0. `git
diff --check` passes.

Risk: low. Display labels only; selection keys stay the agent `name`. No
API, IAM or schema changes. Revert this PR to roll back. Native
selection and scrolling are not newly proven on a device.

Self-review: 6 items found and fixed (round 1, earlier head: 1; cycle 2:
the composer chip still showed the slug-derived name, and the test
fixture used an invalid `source` value with an untyped agent row; cycle
3: `tree!` non-null assertions in PickerSheet.test.tsx, the version bump
lost when the trunk took 1.6.45, and Biome import/format errors in the
new PickerSheet.test.tsx)

suna-skills: worktree, testing, learnings, contributing, create-pr,
kortix-brand, kortix-design-system, ponytail, ponytail-review; mobile
AGENTS.md and design.md.

ponytail: full · review: Lean already. Ship. · markers: 0

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

- A tab that already shows a signed-in user now decides the reset from
its own in-document identity only. It no longer resets because the
shared `localStorage` marker is missing or names another account.
- Root cause: auth-js emits `SIGNED_IN` when a tab becomes visible and
its access token is still valid. `AuthProvider` then asks
`shouldResetClientState`. On a drifted marker, the old rule wiped every
client cache, so the tab rendered a blank loading frame until it
refetched everything.
- The marker drifts while the session cookie stays: storage is cleared
or blocked, or the Kortix side panel signs in to another account. The
panel shares this origin's `localStorage` but keeps its own partitioned
cookie. Cold loads and real user switches still reset.


https://github.com/user-attachments/assets/7d13c3ab-0276-4915-ae1f-825423b222d1

**Walkthrough**
1. Before (previous head `a8a43e5`): another document wrote a different
account into `kortix-last-user-id`. On tab return, the page drops to a
blank frame with a loading spinner, and the page text length falls to 0.
![Step
1](https://github.com/user-attachments/assets/ae1b07ef-5be0-484d-8fee-ad4e13896186)
2. After (this head): the same tab return keeps the interface. The page
text length stays at 1503, and the tab writes its own user back into the
marker. ![Step
2](https://github.com/user-attachments/assets/69a18d39-d2b9-4776-92a7-ffd8cd4cea43)

**Risk:** low. Only a live document that already published the same user
skips the reset. A different in-document user and every cold load (no
in-document user) keep the old rule. A same-user re-adopt reads nothing
from storage (`adoptDeviceCaches` returns early for the adopted user).
Rollback: revert the two commits.
**Verified:** focused auth tests: 56 pass, 0 fail. New test red on the
previous head `a8a43e5`: 9 pass, 1 fail. Both drift tests red on
`origin/dev`: 8 pass, 2 fail. Web typecheck exit 0 after the trunk
merge. Changed-file ESLint exit 0. Brand audit clean. Local stack: real
tab switch with agent-browser, measured with a MutationObserver. Before:
minimum page text 0 for the marker-from-another-account case and for the
missing-marker case. After: 1503 for the other-account, missing and same
cases. Probe extension: an iframe of a site inside an extension page
with `<all_urls>` host permission read the top-level tab's
`localStorage` value. The same iframe inside another site read `null`.
Not verified: the real Kortix side panel with a second account, native
Electron, a long streaming turn, and Chrome Memory Saver tab discard (a
discard reloads the page, a different path).
suna-skills: worktree, testing, learnings, contributing, create-pr,
kortix-brand, kortix-design-system
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 2 items found and fixed

## Quick verification

Outcome: returning to a tab no longer wipes a known user's interface
when the shared identity marker is missing or names another account.

Closes KRTX-4938. https://linear.app/kortix/issue/KRTX-4938

**Why another person does not see it:** all three conditions must hold.
(1) The marker in `localStorage` drifted while the session cookie
survived. (2) The tab returns while its access token is still valid.
auth-js stops the refresh timer in a hidden tab, and a return within 90
s of expiry refreshes the token instead (`TOKEN_REFRESHED`, no reset).
(3) The reset refetch is slow enough to see; it took about 0.3 s on the
local stack. The reported screenshot is a blank content area with no app
shell, the same frame the reset path renders.

**How was this tested?**

```text
cd apps/web
bun test src/lib/auth/identity-marker.test.ts      # identity-marker.ts at a8a43e5 (previous head)
(fail) returning to a tab whose storage marker drifted > the same document user retains its live state when another document rewrote the marker
 9 pass
 1 fail

bun test src/lib/auth/identity-marker.test.ts      # identity-marker.ts at origin/dev
(fail) ... > the same document user retains its live state
(fail) ... > the same document user retains its live state when another document rewrote the marker
 8 pass
 2 fail

bun test src/lib/auth/identity-marker.test.ts src/features/providers/auth-provider-identity.test.ts src/lib/auth/sign-out-navigation.test.ts   # this head, after merging origin/dev
 56 pass
 0 fail
 1149 expect() calls
Ran 56 tests across 3 files. [2.10s]

pnpm --filter Kortix-Computer-Frontend typecheck     # after merging origin/dev
exit 0

cd apps/web && ../../node_modules/.bin/eslint src/lib/auth/identity-marker.ts src/lib/auth/identity-marker.test.ts
exit 0

.agents/skills/kortix-brand/scripts/audit.sh apps/web/src/lib/auth/identity-marker.ts apps/web/src/lib/auth/identity-marker.test.ts
✓ clean — every value came from the allowlist.

pnpm worktree start krtx-4938 --no-tunnel   # web :13000, api :13008
GET /v1/health → 200
tab-return probe (set marker, open a second tab, return, MutationObserver on body):
  previous head, marker = another account : {"minText":0,"textNow":1503,"marker":"<own user>"}
  origin/dev,    marker removed           : {"minText":0,"textNow":1503,"marker":"<own user>"}
  this head,     marker = another account : {"minText":1503,"pending":false,"marker":"<own user>"}
  this head,     marker removed           : {"minText":1503,"pending":false,"marker":"<own user>"}
  this head,     marker = same user       : {"minText":1503,"pending":false,"marker":"<own user>"}

storage-partition probe (agent-browser --extension, test extension with host_permissions <all_urls>):
  top-level http://localhost:13999 sets probe-key
  iframe of that origin inside chrome-extension://<id>/page.html → "set-by-top-level-tab"
  same iframe inside http://127.0.0.1:13998                      → "null"
```

The repository's targeted-only testing rule (AGENTS.md, testing
philosophy) skips the full `apps/web` package suite. No DB-backed test
names the changed symbol (`grep -rl shouldResetClientState` finds only
the two test files above).

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
agent-kortix and others added 10 commits November 20, 2026 11:48
…12944)

## Demo video

No demo video: code-only change.

## Quick verification

Outcome: trigger admissions now retain their workspace reference during
the workspace cutover. This repairs the remaining catalog failure
identified in the red nightly run. Refs KRTX-5039; the complete Tests
lane is not yet proven green.

- Adds a deferred, NOT VALID, NO ACTION workspace FK. The existing
project FK keeps its cascade. No existing migration changes.
- Exercises admissions through transaction commit, rejected workspace
deletion, and project-delete cascade. The existing hard-cap caller still
passes concurrency, hourly/day boundaries, and trigger isolation.
- Other nightly failures already have merged repairs. Ubuntu mirror HTTP
520 remains an external runner condition; no runner or production
configuration is changed here.

```text
pnpm test -- --db-only workspaces-twin-foreign-keys
Before fix: 4 pass, 1 fail; missing kortix.project_trigger_admissions.project_id.
Final test against pre-fix migrated database: 3 pass, 2 fail.

pnpm test -- --db-only workspaces-twin-foreign-keys trigger-hard-admission
After merging origin/dev: PASS 2/2 suites, 8 tests, 7.2s
PASS packages/db/scripts/workspaces-twin-foreign-keys.integration.test.ts 5 tests
PASS apps/api/src/projects/trigger-hard-admission.integration.test.ts 3 tests

pnpm test -- --db-only workspaces-twin-foreign-keys integration-connector-connected-as
PASS 2/2 suites, 15 tests, 7.8s

cd apps/api; . ../../scripts/hermetic-test-env.sh
bun test --env-file=scripts/test.env --isolate src/projects/lib/session-list.test.ts src/shared/sql-correlated-subquery-guard.test.ts src/__tests__/unit-audit-route-labels.test.ts
16 pass; 0 fail; 41 expect() calls

pnpm --dir tests exec vitest run --config unit/vitest.config.ts unit/kortix-yaml-doc.test.ts unit/api-docker-workspace-install.test.ts
Test Files 2 passed (2); Tests 4 passed (4)

pnpm --dir tests exec vitest run --config unit/vitest.config.ts unit/learnings-ledger.test.ts
Test Files 1 passed (1); Tests 5 passed (5)

pnpm --filter @kortix/db lint
Found 0 issues in 466 files
pnpm --filter @kortix/db typecheck
exit 0
cd packages/db; bun scripts/generate.ts __local_schema_sync
No schema changes, nothing to migrate
bun tests/bin/ke2e.ts coverage
coverage gate passed; 0 uncovered
```

ESLint has no matching configuration for the DB test; root ESLint
reports no config, API config ignores it. No lint pass is claimed for
that file. Whole-package/full suites were not run, per repository
testing policy. Local primary migration applied successfully; catalog
proves the new constraint is deferred and unvalidated. `pnpm worktree
start krtx-5039` runs the local API. `curl
http://localhost:13008/v1/health` returns status=ok, service=kortix-api.
Initial startup needed local schema bootstrap; after applying local
migrations, startup succeeds.

Risk: low — additive metadata-only FK, 2s lock timeout, no historical
scan. It rejects future admissions whose workspace row is missing.
Rollback requires a forward migration dropping only this constraint.

Self-review: 1 items found and fixed (exercise the actual admissions
table instead of an unrelated policy table).
ponytail: full · review: Lean already. Ship. · markers: 0
suna-skills: worktree, testing, learnings, contributing, create-pr,
migration
model=kortix/codex/gpt-6.1-sol route=code
reason=conservative-code-default

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

No demo video: code-only change. Backend template reads; no UI change.

## Quick verification

- Outcome: template listings honor bounded stale-mirror reads for
project Dockerfiles instead of forcing a foreground tip proof. Build and
deletion identity resolution keep their fresh-tip default. Refs
KRTX-4867.
- Root cause: the previous route opt-in reached manifest reads but
`resolveUserDockerfile` forced `tip-proof` again during template
identity resolution. Production 0.16.1 already contains PR #12652 (merge
bced586). Current prod commit cddd9d3 is 911 commits ahead, zero behind.
This is not an unpromoted fix.
- Production evidence: last-hour p95 3158.8 ms / 197 requests, preceding
24-hour p95 1808.55 ms / 3090 requests, zero 5xx. Sample slow requests
show Git 1626–3405 ms. A separate sample has 25 requests over 2 s: 16
include Git, 9 spend over 2 s in DB. Stage durations overlap; do not add
them. DB-heavy outliers are not proven to originate in this template
path. The five most recent uptime incidents are resolved; the newest
ended November 18 at 17:45 UTC.
- **Risk:** medium — listings may use the existing request's bounded
stale mirror policy. Mirror invalidation and maximum age remain
unchanged. Builds still require a fresh tip. No migration, IAM, provider
mutation, SDK export, or response shape change. Rollback: revert this
commit.
- **Verified:** regression red without the listing fix, green with it;
related tests; API typecheck; changed-source ESLint; route coverage;
SBX-3 attempted but blocked before HTTP by duplicate trunk migration.
Full package suite intentionally not run under product AGENTS/testing.
Current feedback session: the local runner reaches migrations, then
fails on duplicate project_trigger_admissions_project_id_workspaces_fk.
No HTTP pass is claimed for this head.

<details><summary>How was this tested? Current head 454c797,
2026-11-20</summary>

Merged origin/dev into the existing canonical branch (105fa16). Git
resolved the overlap automatically. Regenerated the learning index to
remove a duplicate inherited through the union merge (454c797). No
behavior change in this feedback cycle.

```text
cd apps/api
bun test --isolate --env-file=scripts/test.env src/snapshots/templates-view-freshness.test.ts src/snapshots/templates-region-identity.test.ts src/snapshots/templates-tenant-identity.test.ts src/snapshots/builder-list-templates.test.ts src/snapshots/delete-sandbox-image-identity.test.ts src/snapshots/template-prebuilds-delete-kick.test.ts src/__tests__/unit-sandbox-templates-reconcile.test.ts src/__tests__/unit-snapshot-hash-fingerprint.test.ts src/projects/routes/sandbox-health-stale-mirror.test.ts src/projects/git/mirror-view-stale.test.ts src/projects/git/commits.test.ts src/__tests__/unit-sandbox-health-budget.test.ts
75 pass
0 fail
161 expect() calls
Ran 75 tests across 12 files. [7.50s]

# Remove only the listing freshness override, run templates-view-freshness.test.ts:
2 pass
1 fail
Expected length: 1; Received length: 0
# Restore final file and rerun:
3 pass
0 fail
7 expect() calls
Ran 3 tests across 1 file. [1173.00ms]

bun test --isolate --env-file=scripts/test.env src/__tests__/unit-trigger-fire-paths.test.ts src/__tests__/unit-managed-provision-guards.test.ts src/__tests__/unit-session-runtime-guards.test.ts
79 pass
0 fail
440 expect() calls
Ran 79 tests across 3 files. [5.79s]

pnpm --filter kortix-api typecheck
> tsgo --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsgo.tsbuildinfo
exit 0
cd apps/api && ./node_modules/.bin/eslint src/snapshots/templates.ts src/snapshots/template-prebuilds.ts
exit 0
bun tests/bin/ke2e.ts coverage
95.9% covered · 1744/1818 routes · 74 allowlisted · 0 uncovered
✓ coverage gate passed
.agents/skills/learnings/scripts/index.sh --check
exit 0
git diff --check
exit 0
```

Caller boundary: the real sandbox-health handler authorizes before
opting into stale reads (sandboxes.ts:384–391), then calls the memo/list
adapter. Regression exercises populated ready listing with an
unavailable upstream, default build rejection, and invalidated mirror
rejection. Build, delete and provider-transition callers retain default
tip-proof identity resolution. The newly merged delete-kick caller tests
pass. DB metadata suite template-residential-proxy.integration.test.ts
is unchanged: CRUD/image assertions do not invoke freshness. Full
package suite is prohibited by product AGENTS/testing. Prompt benchmark
provisions cloud sessions and does not measure this read route; not run.

```text
pnpm test -- --id SBX-3
error: constraint "project_trigger_admissions_project_id_workspaces_fk" for relation "project_trigger_admissions" already exists
[test] FAIL api-cli-flows 98.3s
```
Local stack start was also attempted; no route assertion ran. Both
origin/dev migrations 20261120083000000 and 20261120094700000 add the
same constraint. The branch changes neither. Pre-existing: `pnpm test --
--id SBX-3` fails the same at origin/dev (cited duplicate constraint;
`[test] FAIL api-cli-flows 27.3s`). No production writes.
</details>

**Production verification still required:** after promotion, evaluate
hourly p95 for 24 h against 3043.5 ms (1.5 × 2029). No production
improvement is inferred from local tests. The remaining DB-heavy tail
needs further attribution if the target still fails.

```sql
WITH src AS (
 SELECT dt, raw FROM remote(t502678_kortix_api_logs)
 WHERE dt > now() - INTERVAL 24 HOUR
 UNION ALL
 SELECT dt, raw FROM s3Cluster(primary, t502678_kortix_api_s3)
 WHERE _row_type=1 AND dt > now() - INTERVAL 24 HOUR
 AND dt < (SELECT min(dt) FROM remote(t502678_kortix_api_logs))
)
SELECT toStartOfHour(dt) AS hour, count() AS requests,
 quantile(0.95)(JSONExtractInt(raw,'duration')) AS p95_ms
FROM src
WHERE JSONExtractString(raw,'method')='GET'
 AND JSONExtractString(raw,'path') LIKE '/v1/workspaces/%/sandbox-health'
 AND JSONExtractInt(raw,'status')>0
GROUP BY hour ORDER BY hour;
```


Self-review: 1 items found and fixed (duplicate learning-index entry
after merge); A–H checked on final diff. No behavior defect found.
Feedback: 1 addressed · 1 answered without a change (pre-existing Strix
DELETE finding, replied with unchanged-dev evidence; not claimed fixed).
suna-skills: worktree, testing, learnings, contributing (references),
create-pr
ponytail: full · review: Lean already. Ship. · markers: 0
model=kortix/codex/gpt-6.1-sol route=code
reason=conservative-code-default

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
… (KRTX-5034) (#12943)

## Demo video


https://github.com/user-attachments/assets/d7ae6355-2b46-4797-ac4a-c11ff4efdb4e

Local stack (`http://localhost:13000`) with a desktop user agent, and
the workspace's `desktop_tabs` and `session_groups` flags on. Synthetic
user `pr-demo-…@example.test` and a synthetic Space, "Launch plan".

**Walkthrough**
1. Fresh start: the tab strip is hidden, and the sidebar lists the Space
"Launch plan". ![step
1](https://github.com/user-attachments/assets/c0ce3eee-f41e-4a0a-b835-d5d147197c66)
2. Opening the Space from the sidebar opens a tab that reads **Launch
plan** with the space's own icon. Before this fix the tab read "Page".
![step
2](https://github.com/user-attachments/assets/339476e7-0c92-4a15-a65e-ef1a5d5f57c7)
3. A shared legacy link, `/change-requests/<id>`, redirects into Review
and lands in one **Review** tab, with no orphan "Page" tab left behind.
![step
3](https://github.com/user-attachments/assets/87cb403f-41a0-4f18-95bc-7c2906175278)

## Quick verification

Outcome: desktop tabs now name the two project routes they used to call
"Page" (KRTX-5034). `/space/<groupId>` shows the Space's name and icon,
and `/change-requests/<id>` belongs to the Review tab it redirects to.
The guard test in `tab-route.test.ts` is unchanged.

- Root cause: #12798 added `space/[groupId]` and #12864 added
`change-requests/[crId]`, but neither route was added to the
classification in `tabRoute`. Both fell through to the generic `section`
kind, which the route guard rejects. That broke release #12922.
- `apps/web/src/features/desktop-tabs/tab-route.ts`:
- adds a new kind, `sessionSpace` (tab group `session-space:<id>`), kept
separate from a `kortix.yaml` `/spaces/<slug>` space;
- maps `change-requests` to the Review page, the same way the
`reminders` and `channels` redirects are handled.
- `apps/web/src/features/desktop-tabs/desktop-tab-strip.tsx`: a new
`SessionSpaceLabel` reads the same cached space list as the sidebar, so
it adds no request. The tab shows the space's name and icon
(`SpaceIconBare`). While the list loads it reads "Spaces"; when the
space is gone it reads "Unavailable". No new strings.
- `packages/ui/scripts/deep-exports.json` exposes
`./workspace/session-spaces/space-icon`. `packages/ui/package.json` was
regenerated with `gen-exports`; the only change is that one export.
- Tests: the guard and two new tests in `desktop-tabs-store.test.ts`
failed before the fix and pass after it.
- Review feedback (G9, head d653c65): new `desktop-tab-label.test.tsx`
renders the real `TabLabel` (now exported) for a `/space/<id>` path
through `tabRoute`, with a seeded QueryClient and the real English
messages, no mocks. It checks three cases: the Space's name and emoji
icon (picked out of two spaces by its decoded id `g%201` → `g 1`),
"Spaces" while loading, "Unavailable" once loaded without the Space. The
reviewer's mutations now fail it: `title="Page"` → `Received: "🚀Page"`;
`StackIcon` instead of `SpaceIconBare` → `Received: "Launch plan"`.

```
# red run before the fix (origin/dev tab-route.ts)
$ bun test src/features/desktop-tabs/tab-route.test.ts
(fail) every project page is a named tab > /workspaces/project-1/change-requests/x1
(fail) every project page is a named tab > /workspaces/project-1/space/x1
 39 pass
 2 fail
$ bun test src/features/desktop-tabs/desktop-tabs-store.test.ts
(fail) tabRoute > a shared change-request link belongs to the Review tab it redirects to
(fail) tabRoute > one Space (session group) is its own tab, apart from a kortix.yaml space
 52 pass
 2 fail

# new rendered-label test, red at base (origin/dev tab-route.ts) and under the reviewer's mutations
$ bun test src/features/desktop-tabs/desktop-tab-label.test.tsx   # base tab-route.ts
 0 pass
 3 fail
$ # mutation title={space.name} -> title="Page"
Expected: "🚀Launch plan"
Received: "🚀Page"
 2 pass
 1 fail
$ # mutation SpaceIconBare -> StackIcon
Expected: "🚀Launch plan"
Received: "Launch plan"
 2 pass
 1 fail

# after the fix (head, after merging origin/dev)
$ bun test src/features/desktop-tabs/
 98 pass
 0 fail
Ran 98 tests across 3 files.
$ bun test src/package-exports.test.ts src/exports.test.ts      # packages/ui
 7 pass
 1 skip
 0 fail
$ bun test tests/unit/ui-deep-exports.test.ts
 2 pass
 0 fail
$ node scripts/gen-exports.mjs --check                          # packages/ui
gen-exports: no drift
$ npx tsgo --noEmit   # apps/web, after the dev merge → only the pre-existing TS1117 below;  packages/ui → exit 0
$ npx eslint src/features/desktop-tabs/   # apps/web → exit 0, no output
```

- Whole `apps/web` unit suite (`pnpm test`): this head (364ec2a, after
merging origin/dev) gives 5042 pass, 5 fail. The failing files are
`platform-card.test.tsx`, `heic-convert.browser.test.ts`,
`blume-docs.test.ts` (2) and `dev-server.test.ts` (parallel-only), all
in the list below; none of them import desktop-tabs. The first cycle's
run: 5032 pass, 10 failures. All are pre-existing and fail the same at
origin/dev with my change stashed, with identical counts:
- `scripts/audit-i18n.test.mjs`, `scripts/blume-docs.test.ts`
(unchanged)
- `src/app/[locale]/(public)/share/public-share-chrome.test.tsx`
(unchanged)
- `src/features/billing/cost-explorer/sessions-level.test.tsx`
(unchanged)
  - `src/features/marketing/download/platform-card.test.tsx` (unchanged)
  - `src/i18n/workspace-vocabulary.test.ts` (unchanged)
  - `src/lib/security/heic-convert.browser.test.ts` (unchanged)

Two failures from the parallel run, in `dev-server.test.ts` and
`general-tab.autosave-loop.test.tsx`, pass when run alone (unchanged
files).
- Pre-existing: after merging origin/dev, `pnpm typecheck` in apps/web
fails with only `TS1117` (a duplicate key) in
`packages/shared/src/audit-route-labels.ts` (unchanged). That file is
identical to origin/dev, so it fails the same at origin/dev.
- Not run: the whole `@kortix/ui` unit suite. Its source is unchanged,
only the export map changed, and the export tests above cover that.
- Try it: in the desktop app with `desktop_tabs` and `session_groups`
on, open a Space from the sidebar. The tab shows its name and icon. Then
open `/workspaces/<id>/change-requests/<cr id>`: it lands in the Review
tab.
- Risk: low. The change is client-only tab naming and grouping, with no
API or schema change. An already-open "Page" tab for these routes
regroups on the next navigation.
- Self-review: 3 items found and fixed (test fixture casts replaced with
full typed fixtures; missing next-intl `timeZone` warning; stale test
counts in this body). ponytail: full · review: Lean already. Ship. ·
markers: 0. suna-skills: worktree, testing, learnings, contributing,
create-pr.

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

No demo video: local stack unavailable for recording in this sandbox.
The worktree web dev server (Next 16 / Turbopack on :13000) stopped
serving after its restarts on 2026-11-20 (`curl localhost:13000/auth` →
000 for 5+ minutes while the API answered 200; the stack then shut
itself down), and every recording either failed to finalize (`moov atom
not found`) or captured an unstyled page that never finished loading.
Failed recordings are not attached.

Before the web server failed, the controlled recovery ran green on the
local stack (worktree `krtx-4973`, fixed SDK, synthetic `@example.test`
user and session). A browser init script (`demo-init.js`, local only,
not committed) sent one synthetic `kortix.control.turn` frame (turn
already ended, no runtime log frames). It withheld the assistant from
the first stored-log page, answered the second read with 503, and let
later reads through to the real local API. Probe output (the page's own
text, polled every ~2 s, no refresh):

```text
Demo harness · turn ended (synthetic) · 5s · log reads: #1 200 (reply not committed yet) | user:true reply:false
Demo harness · turn ended (synthetic) · 8s · log reads: #1 200 (reply not committed yet) → #2 503 → #3 200 | user:true reply:true
Demo harness · turn ended (synthetic) · 18s · log reads: … → #3 200 → #4 200 | user:true reply:true
```

The reply appears about 2 s after the first page without a refresh,
through the bounded turn-end follow-ups. Trunk SDK has no follow-up for
a turn that had already ended at join (red in the hook tests below).
This is a simulated frame/read-failure test, not a real cloud turn, and
not attribution of the reported screenshots.

**Risk:** medium. This shared SDK hook drives web, mobile and
white-label session views. Each completed-turn observation adds at most
three follow-up reads (2 s, 10 s, 30 s). The ordering token is request
start, not a server commit watermark. Persistence beyond the bounded
follow-ups still relies on reconnect, visibility or a manual read.
**Verified:** hook tests 63 pass / 6 fail before the fix → 69 pass / 0
fail after; 10 targeted SDK files 211 pass / 0 fail; `@kortix/sdk`
typecheck exit 0; local-stack controlled recovery green (probe above).
Unverified: demo video (local web server unavailable, see above), real
cloud turn, native mobile/Electron, deployed dev/prod.
suna-skills: worktree, testing, learnings, sdk, contributing, create-pr,
agent-browser
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 3 items found and fixed (all in the first cycle; this
cycle's re-check of the merged head found 0 new)
founder_review: yes
founder_summary: The issue asks for a tested proposal for approval; no
merge or deployment is authorized.

## Quick verification

- Outcome: a delayed same-generation API page can no longer remove an
assistant reply that a newer runtime page loaded, and a completed turn
whose reply was not yet readable recovers through three bounded
follow-up reads, with no hard refresh. Tombstones, deletion, older
paging, reconnect and session switching are unchanged and covered. Refs
KRTX-4973 — https://linear.app/kortix/issue/KRTX-4973

Red before the fix (dev's `use-session-log.ts` with this branch's tests,
run 2026-11-20 on the merged head):

```text
cd packages/sdk && bun test src/react/use-session-log.test.ts
(fail) … KRTX-4973: delayed same-generation API fallback cannot settle over a newer runtime page
(fail) … KRTX-4973: failed and incomplete turn-end reads recover the assistant in the thread hook
(fail) … KRTX-4973: initial last_ended recovers a reply committed after the first page
(fail) … KRTX-4973: initial completed snapshot renegotiates after initial failures exhaust
(fail) … KRTX-4973: incomplete pages exhaust only three delayed follow-ups
(fail) … KRTX-4973: switch established v2 cancels settlement and pending runtime read
 63 pass
 6 fail
Ran 69 tests across 1 file. [2.81s]
```

Green after the fix (head after merging `origin/dev`):

```text
cd packages/sdk && bun test src/react/use-session-log.test.ts
 69 pass
 0 fail
 267 expect() calls
Ran 69 tests across 1 file. [2.86s]
```

```text
pnpm --filter @kortix/sdk test src/react/use-session-log.test.ts src/core/session-log/store.test.ts src/core/session-log/source.test.ts src/core/session-log/saved-log.test.ts src/browser/stores/sync-store-session-log.test.ts src/react/use-session-sync-local-copy.test.ts src/core/session-log/shell-exit.test.ts src/core/session-log/v1-view.test.ts src/core/session-sync/saved-transcript.test.ts src/browser/session-sync/export-messages.test.ts
per file: 4, 5, 3, 25, 9, 18, 25, 32, 21, 69 pass; 0 fail each
211 pass; 0 fail; exit 0

pnpm --filter @kortix/sdk typecheck
exit 0
```

Root cause and scope: the backend stored-log read applies no
assistant-role filter. The client let overlapping API fallback and
runtime page reads apply out of order, so a delayed user-only snapshot
settled away an unrevisioned assistant from a newer one. Established-v2
turn-end rereads had no retry after a failure or an incomplete snapshot.
The fix touches two SDK files only
(`packages/sdk/src/react/use-session-log.ts` and its test). It orders
successful pages by request start, guards stopped continuations and adds
bounded completed-turn follow-ups. The reducer still owns revisions,
deletion settlement and tombstones. No backend, schema, export,
saved-cache or rendering change. Revert the squash commit to roll back;
no data migration.

Do not merge without explicit approval (the issue authorizes a PR for
approval only).

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
## Demo video

No demo video: code-only change. This repairs internal reconnect-wait
resource cleanup; reconnect policy and public exports are unchanged.

## Quick verification

Outcome: reconnect backoffs release their abort listeners after timeout
or abort, and pre-aborted waits schedule no timer. Closes KRTX-5040.

- Regression on trunk: `bun test
packages/sdk/src/core/stream/event-attempt.test.ts` → 1 pass, 4 fail.
Fixed: 5 pass, 0 fail, 34 assertions. Retained abort listeners after 20
delays: **20 → 0**.
- `/usr/local/bin/pnpm --filter @kortix/sdk test
src/core/stream/event-attempt.test.ts
src/core/stream/event-stream.test.ts
src/core/stream/event-stream-auth.test.ts src/index.isomorphic.test.ts
src/public-surface.test.ts` → respectively 5, 53, 2, 34 and 1 pass; 0
failures. Existing stream and auth tests are unchanged.
- `/usr/local/bin/pnpm --filter @kortix/sdk typecheck` → exit 0. `pnpm
exec eslint --config apps/web/eslint.config.mjs
packages/sdk/src/core/stream/event-attempt.ts
packages/sdk/src/core/stream/event-attempt.test.ts` → exit 0 (Next
pages-directory notice only).
- `pnpm --filter @kortix/sdk run smoke:install` → `OK: @kortix/sdk
imports and constructs from the packed tarball`; `✔ install smoke test
passed`.
- Local session streaming remains **unverified**: `pnpm worktree start
krtx-5040` failed because fresh Supabase PostgREST requires the missing
`kortix` schema (`3F000`, status 503). No running API was available.
Full package suite not run under repository policy; targeted files and
import/public-export tripwires ran instead.
- **Risk:** low, limited to backoff resource lifecycle. Rollback: revert
this PR. No dependencies, public names, retry timing, jitter or park
decisions changed.
- Issue-specific correctness acceptance takes precedence over generic
behavior-preserving refactor boilerplate. No code extraction or moved
block is claimed. `git diff --color-moved=zebra
--color-moved-ws=allow-indentation-change origin/dev` summary: local
lifecycle replacement, no moved blocks; existing comments retained
verbatim. Production file 557 → 562 lines; total diff: `2 files changed,
93 insertions(+), 3 deletions(-)`.
- Caller boundary: `openEventStream` passes one lifetime signal through
`event-stream.ts:373`; its unchanged tests exercise healthy/unhealthy
reconnects, jitter, park, fanout and close. Other same-named helpers
belong to `core/http/abort.ts`, reject on abort, and were not changed or
substituted.
- Self-review: 1 items found and fixed (assert timeout cleanup before
close so close cannot mask a leak). Checks A–H completed locally; no
delegation. suna-skills: worktree, testing, learnings, sdk,
contributing, create-pr.
- ponytail: full · review: Lean already. Ship. · markers: 0

model=kortix/codex/gpt-6.1-sol route=code
reason=conservative-code-default

<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/enable-autofix?expires=1797772518&installation_model_id=434224&pr_number=12945&ref=codesmith_pr_footer&repository=kortix-ai%2FCompanyOS&return_to=https%3A%2F%2Fgithub.com%2Fkortix-ai%2FCompanyOS%2Fpull%2F12945&signature=ec3a9dfb1b70a16274337c872058ce8173b7c127966fc71a0ecb9dd06d8cb9ae"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/kortix-ai/codesmith/CompanyOS/pr/12945?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
…view (#12946)

Staging and prod set KORTIX_CHROME_ENABLED=true so the Chrome Web Store build signs in and store reviewers can test it; CHROME_LAUNCHED stays false. Privacy policy section "Kortix in Chrome", bun run package, store-listing reference.
…FK (#12947)

#12938 and #12944 both add project_trigger_admissions_project_id_workspaces_fk; the second failed with 42710 on dev and every fresh database. A checksum-pinned runtime copy adds it only where it is missing; the migration lint rejects a duplicate slug.
…2952)

Every signed-in app screen sends screen_ready (route template, duration_ms, navigation load/route, fetches) to PostHog; new Terraform dashboard Kortix · Speed shows p75 by continent, country and screen.
@DimitrijeGlibic DimitrijeGlibic changed the title Release v0.16.2 — Private spaces, steadier chats, and clearer settings Release v0.16.2 — Private spaces, Drive mentions in chat, and steadier chats Nov 20, 2026
github-actions Bot and others added 2 commits November 20, 2026 16:12
…onnections working (#12957)

## Demo video

No UI changes, so there is no video. The behavior is a server-side
decision in the disconnect route, proven by the DB suite below and
reproduced on staging before the fix.

## Quick verification

Outcome: disconnecting one Kortix Google connector (Gmail, Calendar,
Drive, Docs or Sheets) no longer breaks the user's other Google
connectors.

- **Bug (reproduced on staging 2026-11-20):** one Google account had
Calendar and Drive connected through the Kortix Google client.
Disconnecting Drive made the next Calendar call fail with
`credential_rejected … (HTTP 401) … Google rejected the access token`.
Google keeps one grant per account for an OAuth client, so revoking any
token revokes every token for that account, in every workspace.
- **Fix:** `revokeConnectionOAuth2` skips the upstream revoke while
another active connection signed in through the same Kortix client
(issuer + `client_id`) as the same account (`metadata.connected_as`,
case-insensitive). It still deletes the local credential and marks the
connection `revoked`. The account's last connection revokes at Google,
as before. The rule applies only to Kortix clients flagged
`oneGrantPerAccount` (Google). Bring-your-own OAuth apps and connections
with no `connected_as` revoke as before.
- **DB suite:** `pnpm test -- --db-only integration-google-shared-grant`
→ `PASS 1/1 suites, 2 tests`. With the check disabled, the first test
fails (`Expected [] / Received 4 calls` to
`https://oauth2.googleapis.com/revoke`).
- **Also ran:** `pnpm --filter kortix-api typecheck` (0 errors), `pnpm
--filter kortix-api lint` (clean), and `pnpm test -- --db-only
integration-undecryptable-secrets` (11 tests pass; it also revokes
OAuth2 connections).
- **Not affected:** no migration and no route or SDK change. Composio
connections are untouched.
- **Runbook:**
`.agents/skills/compliance/references/google-oauth-verification.md` gets
the new disconnect rule, how to record the demo video without other
windows in frame, and the 2026-11-20 submission to Google.
- **After merge:** on dev, connect Calendar and Drive with one Google
account, disconnect Drive, then call Calendar. It must still answer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/enable-autofix?expires=1797784140&installation_model_id=434224&pr_number=12957&ref=codesmith_pr_footer&repository=kortix-ai%2FCompanyOS&return_to=https%3A%2F%2Fgithub.com%2Fkortix-ai%2FCompanyOS%2Fpull%2F12957&signature=71eb1e8b1d79e055d12f2211cdaf209f087d6c6ae7b7dbb0ed650cb7adfe6e98"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img
alt="Autofix with [code]smith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png"
width="190" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/kortix-ai/codesmith/CompanyOS/pr/12957?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->
…6) (#12724)

## Review in 60 seconds

- `GET /v1/projects` with no `account_id` listed only the caller's
earliest-joined account. A person with two workspaces (each its own
account) saw one project, while `GET /v1/workspaces` and `GET
/v1/accounts` listed both (dogfood journey
`proj-delete-account-cleanup`). A person (browser session or unscoped
PAT) who names no account now gets the projects of every account they
belong to, most recently updated first.
- The cross-account list is the union of `?account_id=<each account>`.
Each account goes through the same `actorOf` +
`listAccessible('project.read')` decision as before
(`listAccountProjects`: the old handler body, moved as is), so it
returns only rows the same credential can already read one account at a
time. A workspace-bound key, an API key, a service account, an OAuth
client, an operator acting as an account, and any request that names an
account still list one account.
- An account whose session policy revoked this session is left out and
the other accounts still list, as `GET /v1/workspaces` does.
`isRevokedSession` moves from `workspace-records.ts` to
`middleware/session-gate.ts`, where the `401 session_token_revoked` is
thrown, and both lists import it.

No demo video: code-only change

No regression test: not missing. The regression tests are the product
flows `tests/src/flows/workspace-routes.flow.ts` (WS-ROUTE-4) and
`tests/src/flows/workspace-auth.flow.ts` (WS-AUTH-4), red before the fix
and green after (below). `check-pr-evidence`'s test-file pattern does
not match a repo-root `tests/` path.

**Risk:** low. The response shape is unchanged. Every client that calls
the route without `account_id` now sees every account's projects: the
mobile app's `listProjectSessionSandboxes`
(`apps/mobile/lib/platform/client.ts`) and the deprecated SDK
`listProjects` (so `ensureSandbox`, which now picks the most recently
updated project across accounts). Each project's own routes resolve its
account. The web app no longer reads the accountless list: dev removed
the marketplace and its **Add to project** picker (#12949, the only web
reader of `qk.projects.list()`), so the trunk merge takes that file's
deletion over this PR's comment edit on it, and every remaining web
reader passes an `accountId` (`rg "qk\.projects\.list\(" apps/web/src`).
Cost: one per-account read per membership, the same fan-out `GET
/v1/workspaces` does.
**Verified:** Feedback cycle 4 (head 4f10a39: one docs row + one SDK
comment + trunk merge, this session, Docker up): ran `pnpm test -- --id
WS-ROUTE-4,WS-AUTH-4,WS-ROUTE-1,WS-ROUTE-2,WS-ROUTE-3,TOK-4,ACCT-6,IAM-45,PROJ-1,WS-AUTH-13,WS-AUTH-2,WS-AUTH-3`
→ `12/12 passed · 0 failed` · the same WS-ROUTE-4,WS-AUTH-4 with the 4
API files + shared at origin/dev → `0/2 passed · 2 failed` (red without
the fix) · ran bun tests/bin/ke2e.ts coverage → `1736/1812 routes · 76
allowlisted · 0 uncovered · coverage gate passed` · 11 API unit files →
`162 pass, 0 fail` · sdk `use-accounts.test.ts` +
`contract-drift.test.ts` → `10 pass, 0 fail` · `@kortix/sdk` and
`kortix-api` typecheck exit 0 · eslint on the 4 API files exit 0 ·
journey `proj-delete-account-cleanup` on the local stack (`pnpm worktree
start krtx-4926 --no-web`, api http://localhost:13008): 2 workspaces →
`GET /v1/projects` lists both, delete → 404 and absent, then `[]`.
Earlier cycles: `pnpm test -- --id WS-ROUTE-4` → red before the fix
(`project of account 1 of 3 missing from GET /v1/projects`), green after
· `pnpm test -- --id
ACCT-6,TOK-4,IAM-45,PROJ-1,PROJ-18,WS-AUTH-4,WS-AUTH-13,WS-ROUTE-1,WS-ROUTE-4`
→ `8/8 passed · 0 failed` (PROJ-18 excluded by the local profile: needs
Stripe) · 10 API unit files → `138 pass, 0 fail` · `pnpm --filter
kortix-api typecheck` exit 0 · tests `tsc --noEmit` exit 0 · eslint exit
0 · journey `proj-delete-account-cleanup` on the local stack (api
http://localhost:13008, web http://localhost:13000) before and after.
Feedback cycle (head 2092cbf, comment-only change + trunk merge):
`@kortix/sdk`, `@kortix/cli`, web `tsgo --noEmit` exit 0 · web eslint on
the 2 changed files exit 0 · web `bun test` 5 command-palette files →
`147 pass, 0 fail` · sdk `use-accounts.test.ts` +
`contract-drift.test.ts` → `10 pass, 0 fail` · cli 5 test files → `32
pass` + `54 pass`, `0 fail` (rerun after the trunk merge). The API flows
were not rerun this cycle: no `apps/api` or `tests/` byte changed since
d1464f1, where G9 reran them `8/8` and `5/5`. ke2e coverage at 2092cbf →
`1725/1799 routes · 74 allowlisted · 0 uncovered · coverage gate
passed`; the 10 API unit files rerun at 2092cbf → `138 pass, 0 fail`.
Feedback cycle 3 (head 4a80aae: docs/comment-only change + trunk merge):
ran `pnpm test -- --id
WS-ROUTE-4,WS-AUTH-4,WS-ROUTE-1,WS-ROUTE-2,WS-ROUTE-3,TOK-4,ACCT-6,IAM-45,PROJ-1,WS-AUTH-13,WS-AUTH-2,WS-AUTH-3`
→ `12/12 passed · 0 failed` · the same WS-ROUTE-4,WS-AUTH-4 with the 4
API files at origin/dev → `0/2 passed · 2 failed` (red without the fix)
· ran bun tests/bin/ke2e.ts coverage → `1744/1818 routes · 74
allowlisted · 0 uncovered · coverage gate passed` · 11 API unit files →
`159 pass, 0 fail` · sdk `use-accounts.test.ts` +
`contract-drift.test.ts` → `10 pass, 0 fail` · `@kortix/sdk` typecheck
exit 0 · Pre-existing: `@kortix/shared` typecheck fails the same at
origin/dev (1 error, `src/space-icon.test.ts`) and `biome check` on the
2 changed TS files fails the same at origin/dev (Found 4 errors). Not
run: the whole `kortix-api` unit suite. The CompanyOS `AGENTS.md`
testing rule 1 forbids a whole package's tests during development, so I
ran every unit test file that imports a changed module instead.
suna-skills: worktree, testing, learnings, contributing (+ references),
create-pr (template)
ponytail: full · review: Lean already. Ship. · markers: 0
Self-review: 20 items found and fixed (feedback cycle 4: the G9 row
`developers.mdx` legacy SDK table, the same stale class in the
`use-accounts.ts` header, the Risk line naming the picker dev deleted,
and the incomplete Changed-files list; feedback cycle 3: 3 more stale
"one account's" comments of the same class, in
`packages/shared/src/workspace-routes.ts` (2) and
`packages/sdk/src/react/use-accounts.ts` `projectsQueryOptions`;
feedback cycle 2: the missing ke2e coverage output) (5 in the first
cycle; this cycle: 5 more stale comments of the same class, an
unverified "role and state" claim and an ambiguous "API key" wording in
my own new JSDoc)

## Summary

On the dev deployment's dogfood journey `proj-delete-account-cleanup`, a
synthetic customer with two workspaces got only the first workspace's
project from `GET /v1/projects`. The second workspace's project was
reachable only with `?account_id=`. The handler resolved one account
(`resolveProjectAccount`, which defaults to the earliest-joined
membership) and filtered by it. So a leftover project in a second
workspace was invisible to the journey's absence check, and to any API
user who lists projects.

Now a person who names no account lists every account: the same
per-account read, run once per membership, merged and sorted by
`updated_at` descending. `?account_id=` behaves as before. Every
credential bound to one account behaves as before.

Root cause: `apps/api/src/projects/routes/projects.ts` `GET /` scoped
the list to `resolveProjectAccount(c).accountId`, a single default
account, for every caller.

Closes KRTX-4926

## Demo video

No demo video: code-only change. The proof is the request/response
transcript in "How was this tested?" (journey before/after on the local
stack).

## Type of change

- [x] Bug fix (`fix(api)`): restores the listing a person expects from
`GET /v1/projects`.
- [ ] Migration, flag, or SDK public-export change: none.

## What is affected

- `GET /v1/projects` with no `account_id`, for a person (Supabase
browser session or unscoped PAT): lists every account. Response element
shape unchanged (`ProjectSchema`).
- Not affected: `GET /v1/projects?account_id=…` (one account, same 400
`invalid_account_id` / 403 checks), workspace-bound keys
(`tokenProjectId`), service accounts, API keys, OAuth clients,
impersonation, `GET /v1/workspaces` (only its local `isRevokedSession`
moved to an import).
- CLI: no code change. `kortix projects ls --all` and `kortix workspaces
ls` read `GET /v1/workspaces` and already list every account (checked
below). `kortix projects ls` (the older name) stays scoped to the active
account by design and prints the `kortix projects ls --all` hint.
- Docs and spec: the route's OpenAPI `description`, the
`workspaces/routes.ts` and `workspace-records.ts` header comments that
said "GET /v1/projects lists one account", and
`tests/spec/end-to-end.md` (WS-ROUTE-4, WS-AUTH-4).

## Verification

| Command / scenario | Result | What it proves |
| --- | --- | --- |
| `pnpm test -- --id WS-ROUTE-4` at the trunk handler | FAIL (expected):
`project of account 1 of 3 missing from GET /v1/projects` | the
regression test reproduces the bug |
| `pnpm test -- --id WS-ROUTE-4` at the fix | PASS `1/1 passed · 0
failed` | 3 accounts listed, each with its own `account_id`, newest
first |
| `pnpm test -- --id WS-AUTH-4` at the trunk handler / with the
revoked-session skip removed | FAIL (expected) both: `expected [200],
got 401 … session_token_revoked` | the new step covers the
revoked-account edge |
| 9 flows naming `GET /v1/projects` | PASS `8/8 passed · 0 failed`
(PROJ-18 excluded: Stripe) | the flows I did not write still hold: bound
PAT lists its one workspace (TOK-4, WS-AUTH-13), new person `[]`
(ACCT-6), service account one account (IAM-45) |
| 10 API unit files that import a changed module | PASS `138 pass, 0
fail` | session gate, workspace binding, route aliases, account_id param
|
| `pnpm --filter kortix-api typecheck`, tests `tsc --noEmit`, eslint on
changed files | exit 0 ×3 | T0 |
| journey `proj-delete-account-cleanup`, local stack, before / after | 1
project → 2 projects; delete → 404 and absent from the list | the
observation is gone |

Tested on worktree `krtx-4926` (head of this PR), local stack with the
shared local Supabase. PROJ-18 (needs Stripe) holds by reading: it takes
`list[0].account_id` of a person and asserts that account's quota is
capped at 1, which is true for any account in the list that holds its
one project.

## How was this tested?

### Feedback cycle 4 (G9 request_changes on 4a80aae, 1 item; and the
merge conflict with dev)

1. `apps/web/content/docs/developers.mdx` (was line 9366, the legacy SDK
name table): "The legacy calls list one account." → they list, for a
person, the projects of every account they belong to, or one account's
with `accountId`; a credential bound to one account lists that
account's. (4f10a39)
- Same class: `packages/sdk/src/react/use-accounts.ts` file header ("one
account's projects") reworded (4f10a39). `rg -n "legacy calls list one
account"` → no hit. The line is outside every `generated:` region of the
page.
- Conflict: dev deleted
`apps/web/src/features/marketplace/marketplace-project-picker.ts`
(#12949, marketplace removed); this PR had only reworded its header
comment. Resolved by taking the deletion (47e8b33). No other file
conflicted.

```
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4,WS-ROUTE-1,WS-ROUTE-2,WS-ROUTE-3,TOK-4,ACCT-6,IAM-45,PROJ-1,WS-AUTH-13,WS-AUTH-2,WS-AUTH-3   # head 4f10a39
local profile: 12/12 selected · 0 external/todo excluded
✓ [9/12] PASS WS-ROUTE-4 0.9s
✓ [11/12] PASS WS-AUTH-4 2.4s
results: 12/12 passed · 0 failed · 0 skipped · 0 todo · 3.6s

$ git checkout origin/dev -- apps/api/src/middleware/session-gate.ts apps/api/src/projects/routes/projects.ts apps/api/src/projects/routes/workspace-records.ts apps/api/src/workspaces/routes.ts packages/shared/src/workspace-routes.ts
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4
✗ [1/2] FAIL WS-ROUTE-4 0.5s — project of account 1 of 3 missing from GET /v1/projects
✗ [2/2] FAIL WS-AUTH-4 1.3s — status in [200] — expected [200], got 401 (… "code":"session_token_revoked")
results: 0/2 passed · 2 failed · 0 skipped · 0 todo · 1.8s
$ git checkout HEAD -- <the same files>

$ bun tests/bin/ke2e.ts coverage; echo $?   # ran bun tests/bin/ke2e.ts coverage at head 4f10a39
95.8% covered · 1736/1812 routes · 76 allowlisted · 0 uncovered
✓ coverage gate passed
0

$ (cd apps/api && pnpm test <the 11 unit files of cycle 3>)
 162 pass
 0 fail
Ran 162 tests across 11 files. [17.12s]

$ (cd packages/sdk && bun test src/react/use-accounts.test.ts src/contract-drift.test.ts)
 10 pass
 0 fail
$ (cd packages/sdk && pnpm typecheck); echo $?            → 0
$ pnpm --filter kortix-api typecheck; echo $?             → 0
$ (cd apps/api && npx eslint src/projects/routes/projects.ts src/projects/routes/workspace-records.ts src/middleware/session-gate.ts src/workspaces/routes.ts); echo $?   → 0
$ (cd apps/api && bun test src/projects/lib/sessions.error-docs.test.ts)   # reads developers.mdx
 4 pass
 0 fail
```

Journey `proj-delete-account-cleanup` on the local stack (`pnpm worktree
start krtx-4926 --no-web`; the web dev server does not boot in this
sandbox: `generate-fumadocs-source.mjs` fails with
`ERR_UNKNOWN_FILE_EXTENSION ".ts"` on Node 22.11, unrelated to this PR,
and the change is API-only). A synthetic user signed in through local
Mailpit (the contributing skill's `preview-auth-email.sh`, then the
Supabase verify link) and created two workspaces with `POST
/v1/workspaces`:

```
$ GET /v1/projects
journey-b
journey-a
$ GET /v1/projects?account_id=<account of journey-b>
journey-b
$ GET /v1/workspaces | length
2
$ GET /v1/projects (no token)            → 401
$ ?account_id=<random uuid>              → 403
$ ?account_id=not-a-uuid                 → {"status":400,"code":"invalid_account_id"}
$ DELETE /v1/workspaces/<journey-b>      → 200
$ GET /v1/projects/<journey-b>           → {"error":"Not found"} 404
$ GET /v1/projects
journey-a
$ DELETE /v1/workspaces/<journey-a>      → 200
$ GET /v1/projects
[]
```

### Feedback cycle 3 (G9 request_changes on 2092cbf, 3 items; and the G8
hold on the ke2e line)

1. `apps/web/content/docs/developers.mdx`: the legacy-route table row
(was line 2654) and the `useWorkspaces` hook row (was 8971) now say `GET
/v1/projects` / `useProjects` list every account of a person, or one
account's with `?account_id=` / `accountId`. (commit 879e56f)
2. `packages/sdk/README.md` lines 1254 and 1546: same rewording.
(879e56f)
3. Body: "cli 7 test files" → "cli 5 test files" (the cited commands run
2 + 3 files).
- Same class, found by a repo-wide `git grep -i "one account's"`:
`packages/shared/src/workspace-routes.ts` (the `GET /v1/projects` note
and the `WORKSPACE_LEGACY_REPLACEMENTS` comment, 4a80aae) and
`packages/sdk/src/react/use-accounts.ts` (`projectsQueryOptions` JSDoc,
879e56f). Every remaining hit names an explicit account (`--account
<id>`, the mobile `['projects', accountId]` key) or an older server
(`apps/cli/src/project-bind.ts:120`) and stays true.
- Trunk merged (`d4ec70f`, clean). No code byte changed; the flows were
rerun on the merged head anyway.

```
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4,WS-ROUTE-1,WS-ROUTE-2,WS-ROUTE-3,TOK-4,ACCT-6,IAM-45,PROJ-1,WS-AUTH-13,WS-AUTH-2,WS-AUTH-3   # head 4a80aae
local profile: 12/12 selected · 0 external/todo excluded
✓ [9/12] PASS WS-ROUTE-4 1.1s
✓ [11/12] PASS WS-AUTH-4 2.3s
results: 12/12 passed · 0 failed · 0 skipped · 0 todo · 3.7s

$ git checkout origin/dev -- apps/api/src/middleware/session-gate.ts apps/api/src/projects/routes/projects.ts apps/api/src/projects/routes/workspace-records.ts apps/api/src/workspaces/routes.ts packages/shared/src/workspace-routes.ts
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4
✗ [1/2] FAIL WS-ROUTE-4 0.5s — project of account 1 of 3 missing from GET /v1/projects
✗ [2/2] FAIL WS-AUTH-4 1.3s — status in [200] — expected [200], got 401 (code session_token_revoked)
results: 0/2 passed · 2 failed · 0 skipped · 0 todo · 1.9s
$ git checkout HEAD -- apps/api/src packages/shared/src

$ bun tests/bin/ke2e.ts coverage; echo $?   # ran bun tests/bin/ke2e.ts coverage at head 4a80aae
ke2e coverage — spec ↔ flow ↔ route parity
95.9% covered · 1744/1818 routes · 74 allowlisted · 0 uncovered
✓ coverage gate passed
0

$ pnpm --filter kortix-api test <the 10 unit files listed under Original cycle> src/__tests__/unit-openapi-workspace-spec.test.ts
 159 pass
 0 fail
Ran 159 tests across 11 files. [11.69s]

$ (cd packages/sdk && bun test src/react/use-accounts.test.ts src/contract-drift.test.ts)
 10 pass
 0 fail
Ran 10 tests across 2 files. [42.00ms]

$ (cd packages/sdk && pnpm typecheck); echo $?
0
$ (cd packages/shared && pnpm typecheck)   # Pre-existing: fails the same at origin/dev
src/space-icon.test.ts(33,52): error TS2769: No overload matches this call.
$ npx biome check packages/sdk/src/react/use-accounts.ts packages/shared/src/workspace-routes.ts   # Pre-existing: same at origin/dev
Found 4 errors.
```

### Feedback cycle 2 (G9 request_changes on 2092cbf, 1 item: the ke2e
coverage output)

Body-only change: the PR head is still 2092cbf (no new commit;
`origin/dev` is already an ancestor of it). The ke2e coverage gate ran
on this head in this session:

```
$ bun tests/bin/ke2e.ts coverage; echo $?
ke2e coverage — spec ↔ flow ↔ route parity
95.9% covered · 1725/1799 routes · 74 allowlisted · 0 uncovered
○ 15 flow(s) declare no routes: ART-3, INIT-1, INIT-2, INIT-3, INIT-4, CREATE-1, HOSTS-1, HOSTS-2, HOSTS-3, HOSTS-4, HOSTS-5, HOSTS-6, LOGOUT-1, SHIP-8, SEC-K

✓ coverage gate passed
0
$ pnpm --filter kortix-api test <the 10 unit files listed under Original cycle>   # head 2092cbf, this session
 138 pass
 0 fail
 2810 expect() calls
Ran 138 tests across 10 files. [7.90s]
```

### Feedback cycle (G9 request_changes on d1464f1, 3 items)

1. `packages/sdk/src/core/rest/projects-client/projects.ts`
`listProjects` JSDoc: now says a person lists every account they belong
to, an account-bound credential lists its one.
2. `apps/web/src/features/marketplace/marketplace-project-picker.ts`
(since deleted on dev, #12949; see feedback cycle 4) header comment: no
longer says the unscoped list is the primary (earliest-joined) account.
3. This body's **Risk** line names the web Add-to-project picker (and
the mobile caller).

The same stale claim, found by `grep -rn "earliest-joined\|ONE default
account\|one account's projects"` over `apps/web/src apps/cli/src
packages/sdk/src`, is fixed in `packages/sdk/src/react/use-accounts.ts`
(`useProjects`), `apps/web/src/features/workspace/command-palette.tsx`,
`apps/cli/src/commands/projects.ts` (2 comments) and
`apps/cli/src/api/client.ts`. Comments only, no code byte.

```
$ (cd packages/sdk && pnpm typecheck); echo $?            → 0
$ (cd apps/cli && pnpm typecheck); echo $?                → 0
$ (cd apps/web && npx tsgo --noEmit); echo $?             → 0
$ (cd apps/web && npx eslint src/features/marketplace/marketplace-project-picker.ts src/features/workspace/command-palette.tsx); echo $?   → 0
$ (cd apps/web && bun test --isolate src/features/workspace/command-palette{-search,,-visibility,-boundary}.test.ts* src/features/workspace/workspace-palette.test.ts)
 147 pass
 0 fail
Ran 147 tests across 5 files. [8.21s]
$ (cd packages/sdk && bun test src/react/use-accounts.test.ts src/contract-drift.test.ts)
 10 pass
 0 fail
$ (cd apps/cli && bun test src/__tests__/{accounts,projects-clone}.test.ts)      # after the trunk merge
 32 pass
 0 fail
$ (cd apps/cli && bun test src/__tests__/{workspaces.blackbox,ship,repository-disconnected}.test.ts)
 54 pass
 0 fail
Ran 54 tests across 3 files. [21.52s]
```

Pre-existing: `npx biome check` on the 6 changed files fails the same at
origin/dev (`Found 18 errors.` with this cycle's change stashed and with
it applied; formatting of untouched lines).

### Original cycle

Regression test, red on the trunk handler
(`tests/src/flows/workspace-routes.flow.ts`, flow WS-ROUTE-4):

```
$ pnpm test -- --id WS-ROUTE-4          # apps/api/src/projects/routes/projects.ts at origin/dev
  · [1/1] START WS-ROUTE-4
✗ [1/1] FAIL WS-ROUTE-4 0.4s — project of account 1 of 3 missing from GET /v1/projects
results: 0/1 passed · 1 failed · 0 skipped · 0 todo · 0.9s
```

The same flow with the fix:

```
$ pnpm test -- --id WS-ROUTE-4
✓ [1/1] PASS WS-ROUTE-4 0.5s
results: 1/1 passed · 0 failed · 0 skipped · 0 todo · 1.2s
```

WS-AUTH-4's new step (a person in two accounts, one account's idle
policy revoked the session), red on the trunk handler and red with only
the `isRevokedSession` skip removed:

```
$ pnpm test -- --id WS-AUTH-4           # trunk handler
✗ [1/1] FAIL WS-AUTH-4 1.2s — status in [200] — expected [200], got 401 (… "code":"session_token_revoked")
results: 0/1 passed · 1 failed · 0 skipped · 0 todo · 1.7s
$ pnpm test -- --id WS-AUTH-4           # fix without `if (isRevokedSession(err)) return [];`
✗ [1/1] FAIL WS-AUTH-4 1.2s — status in [200] — expected [200], got 401 (… "code":"session_token_revoked")
results: 0/1 passed · 1 failed · 0 skipped · 0 todo · 1.7s
```

Both new steps at the final test text, trunk handler then fix:

```
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4   # apps/api/src/projects/routes/projects.ts at origin/dev
✗ [1/2] FAIL WS-ROUTE-4 0.4s — project of account 1 of 3 missing from GET /v1/projects
✗ [2/2] FAIL WS-AUTH-4 1.2s — status in [200] — expected [200], got 401 (… "code":"session_token_revoked")
results: 0/2 passed · 2 failed · 0 skipped · 0 todo · 1.7s
$ pnpm test -- --id WS-ROUTE-4,WS-AUTH-4   # this PR
✓ [1/2] PASS WS-ROUTE-4 0.6s
✓ [2/2] PASS WS-AUTH-4 1.5s
results: 2/2 passed · 0 failed · 0 skipped · 0 todo · 2.0s
```

Every flow that names `GET /v1/projects`, at the fix:

```
$ pnpm test -- --id ACCT-6,TOK-4,IAM-45,PROJ-1,PROJ-18,WS-AUTH-4,WS-AUTH-13,WS-ROUTE-1,WS-ROUTE-4
local profile: 8/9 selected · 1 external/todo excluded
✓ [1/8] PASS TOK-4 0.8s
✓ [2/8] PASS ACCT-6 0.9s
✓ [3/8] PASS IAM-45 1.2s
✓ [4/8] PASS PROJ-1 1.3s
✓ [5/8] PASS WS-ROUTE-4 0.9s
✓ [6/8] PASS WS-ROUTE-1 1.0s
✓ [7/8] PASS WS-AUTH-13 2.1s
✓ [8/8] PASS WS-AUTH-4 2.5s
results: 8/8 passed · 0 failed · 0 skipped · 0 todo · 3.2s
```

Unit test files that import a changed module (`session-gate`,
`workspace-records`, `routes/projects`, the workspace binding and route
aliases):

```
$ pnpm --filter kortix-api test src/middleware/session-gate.test.ts src/accounts/request-gates.test.ts src/__tests__/unit-restrict-account-creation.test.ts src/__tests__/unit-iam-session-gate.test.ts src/__tests__/unit-worker-entry-imports.test.ts src/projects/routes/provision-legacy-body.test.ts src/__tests__/unit-workspace-binding-coverage.test.ts src/__tests__/unit-workspace-route-aliases.test.ts src/__tests__/unit-project-account-id-param.test.ts src/__tests__/unit-resolve-account.test.ts
 138 pass
 0 fail
Ran 138 tests across 10 files. [8.01s]
```

T0:

```
$ pnpm --filter kortix-api typecheck            → exit 0
$ (cd tests && pnpm typecheck)                  → exit 0
$ (cd apps/api && npx eslint src/projects/routes/projects.ts src/projects/routes/workspace-records.ts src/middleware/session-gate.ts src/workspaces/routes.ts)  → exit 0
```

Journey `proj-delete-account-cleanup` on the local stack (`pnpm worktree
start krtx-4926`). A synthetic user signed in through Mailpit (the
contributing skill's `preview-auth-email.sh`) and created two workspaces
with `POST /v1/workspaces`, `dogfood-local-a` and `dogfood-local-b`,
each in its own account. Before (trunk handler, hot-reloaded):

```
$ curl -s -H "Authorization: Bearer $JWT" localhost:13008/v1/projects | jq -r ".[].name"
dogfood-local-a
$ curl ... /v1/projects?all=true | jq length
1
$ curl ... /v1/projects?include_archived=true | jq length
1
$ curl ... /v1/workspaces | jq length
2
$ curl ... /v1/accounts | jq length
2
```

After (this PR):

```
$ curl -s -H "Authorization: Bearer $JWT" localhost:13008/v1/projects | jq -r ".[] | .name+\" \"+.updated_at"
dogfood-local-b 2026-11-14T07:28:08.399Z
dogfood-local-a 2026-11-14T07:28:02.126Z
$ curl ... /v1/projects?all=true | jq length
2
$ curl ... /v1/projects?include_archived=true | jq length
2
$ curl ... "/v1/projects?account_id=<account of dogfood-local-b>" | jq -r ".[].name"
dogfood-local-b
$ curl ... /v1/workspaces | jq length
2
$ curl -s -o /dev/null -w "%{http_code}" localhost:13008/v1/projects   # no token
401
$ curl ... "/v1/projects?account_id=<random uuid>" -w "%{http_code}"  # not a member
403
$ curl ... "/v1/projects?account_id=not-a-uuid" | jq -c "{status,code}"
{"status":400,"code":"invalid_account_id"}
$ curl -s -H "Authorization: Bearer <workspace key of dogfood-local-a>" localhost:13008/v1/projects | jq -r ".[].name"
dogfood-local-a
```

The journey's delete and absence check, after the fix:

```
$ curl -X DELETE ... /v1/workspaces/<dogfood-local-b> -w "%{http_code}"
200
$ curl ... /v1/projects/<dogfood-local-b>
{"error":"Not found"} 404
$ curl ... /v1/projects | jq -r ".[].name"
dogfood-local-a
$ kortix projects ls --all --json | jq -r ".[].projects[].name"
dogfood-local-a
$ kortix projects ls --json | jq -r ".[].name"
dogfood-local-a
$ curl -X DELETE ... /v1/workspaces/<dogfood-local-a>
200
$ curl ... /v1/projects
[]
```

`kortix` here is the worktree's CLI (`bun apps/cli/src/index.ts`,
`KORTIX_API_URL=http://localhost:13008`). Before the delete, `kortix
projects ls --all --json` and `kortix workspaces ls --json` both listed
`dogfood-local-a` and `dogfood-local-b`.

## Security & data review

- Authorization: the union adds no access. Each account in it goes
through the same `actorOf` + `listAccessible('project.read', 'project')`
decision as `GET /v1/projects?account_id=<that account>`. Only a person
reaches the union: `newWorkspaceCallerDenial(newWorkspaceCallerOf(c))
=== null`, which means a Supabase session or an unscoped PAT, not
impersonated and not workspace-bound. A workspace key is shown to list
its one workspace (TOK-4, WS-AUTH-13, local curl above).
- Session policy: an account's revoked session still gets nothing from
that account (WS-AUTH-4).
- Data: no write and no new column. Tests and this body use synthetic
data only.

## Rollout / rollback

- Contract change, additive. `GET /v1/projects` without `account_id`
returns more rows for a person in several accounts. The element shape,
the auth decision per row and every narrower credential are unchanged.
- Rollback: revert this PR. There is no migration, no flag and no data
change.
- Load: one per-account read per membership, run in parallel, the same
fan-out `GET /v1/workspaces` already does on every switcher open.

## Reviewer checklist

1. `apps/api/src/projects/routes/projects.ts` `GET /`: the person test
(`newWorkspaceCallerDenial(newWorkspaceCallerOf(c)) === null`, the same
test `buildProvisionContext` uses) decides who gets the union. Check
that no credential bound to one account can reach the union branch.
2. `listAccountProjects`: the old handler body, moved as is. It returns
rows instead of `c.json`, and one stale comment about `any` is dropped.
3. `tests/src/flows/workspace-auth.flow.ts` WS-AUTH-4: the new step
asserts that the revoked account is left out and the other account still
lists.

<details>
<summary>Changed files</summary>

- `apps/api/src/projects/routes/projects.ts`: `GET /v1/projects` lists
every account for a person; `listAccountProjects` holds the per-account
read; OpenAPI description.
- `apps/api/src/middleware/session-gate.ts`: exports `isRevokedSession`
(moved).
- `apps/api/src/projects/routes/workspace-records.ts`: imports
`isRevokedSession`; header comment.
- `apps/api/src/workspaces/routes.ts`: the `GET /v1/workspaces`
description and the header comment no longer say the legacy list is one
account.
- `tests/src/flows/workspace-routes.flow.ts`: WS-ROUTE-4 step, the
3-account list with no `account_id`.
- `tests/src/flows/workspace-auth.flow.ts`: WS-AUTH-4 step, revoked
account left out, other account listed.
- `tests/spec/end-to-end.md`: WS-ROUTE-4 and WS-AUTH-4 contracts.
- Docs and comments only: `apps/web/content/docs/developers.mdx` (3
rows), `packages/sdk/README.md` (2 rows),
`packages/sdk/src/core/rest/projects-client/projects.ts` (`listProjects`
JSDoc), `packages/sdk/src/react/use-accounts.ts` (header,
`projectsQueryOptions`, `useProjects`),
`packages/shared/src/workspace-routes.ts` (2 comments),
`apps/cli/src/api/client.ts` and `apps/cli/src/commands/projects.ts`
(comments, help text),
`apps/web/src/features/workspace/command-palette.tsx` (comment).

</details>

---------

Co-authored-by: Kortix Agent <292857086+agent-kortix@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

Tests - release attempt 2 ended failure: contract / packages-api lane, contract / packages-rest lane, full suite + quality gates. Rerunning it once: https://github.com/kortix-ai/CompanyOS/actions/runs/44775350839

A job that passes on the rerun is a flake. Fix it at the root or delete it the same day (the testing skill, No quarantine). A job that fails twice is real.

@github-actions

Copy link
Copy Markdown
Contributor Author

Tests - release attempt 2 ended failure: full suite + quality gates. Rerunning it once: https://github.com/kortix-ai/CompanyOS/actions/runs/44784215965

A job that passes on the rerun is a flake. Fix it at the root or delete it the same day (the testing skill, No quarantine). A job that fails twice is real.

@DimitrijeGlibic DimitrijeGlibic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release suite green on d64e222 (run 44784215965). Approving v0.16.2.

@DimitrijeGlibic

Copy link
Copy Markdown
Contributor

Admin-merged over one environmental check, with the release owner's approval (2026-11-20).

@DimitrijeGlibic
DimitrijeGlibic merged commit 6795ec0 into prod Nov 20, 2026
102 of 108 checks passed
@DimitrijeGlibic
DimitrijeGlibic deleted the release/v0.16.2 branch November 20, 2026 18:09
@DimitrijeGlibic

Copy link
Copy Markdown
Contributor

Correction to the comment above: the merge did not use --admin (the prod ruleset has no bypass actors). A 4th attempt of "Self-host schema bootstrap" got through Docker Hub and passed; the gate job then passed, and the release merged normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants