Repository navigation
feat(threads): promote owned threads to top level and return them to their owner - #763
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9112429407
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Owned threads need an explicit way to become independent so their owner can wrap up separately. Add reversible promotion through the thread organizer and sidebar, and refuse it while a delegated task still owes work. Implemented by GPT-6.2 Sol high through Codex in T3 Code. Carry-Group: incubator
A promoted thread can still be mistaken for a task because its requester reference survives. Refuse new task rounds on the destination while promoted and keep released threads and their input requests out of the former owner’s navigation, tag visibility, and badges. Implemented by GPT-6.2 Sol high through Codex in T3 Code. Carry-Group: incubator
Restore the valid default explicitly. Lock the local placement chain before checking it so Return cannot create a cycle. Cross-project owners and side chats keep their returned children at the project root for placement. Implemented by GPT-6.2 Sol high through Codex in T3 Code. Carry-Group: incubator
Restore only valid execution parents on Return. Keep idle released delegates in sidebar snapshots and let their recovery and worktree retention follow their own state. Implemented by GPT-6.2 Sol (high) through Codex in T3 Code. Carry-Group: incubator
Apply the same lineage filter when listing older settled threads and fetching them. Use ownership for the settlement shortcut so released threads follow their own settings. Implemented by GPT-6.2 Sol (high) through Codex in T3 Code. Carry-Group: incubator
9112429 to
ca17687
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca17687600
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
No description provided. |
Part of #751. Some owned threads appeared at the top level even when their orchestrator was visible. The LastCode sidebar now uses the recorded owner to place them. ## 🧭 The graph rule Each logical project resolves owners from the shells it already has, using environment and thread ID together. An owned thread uses its explicit placement when the target is visible. Otherwise it nests under a visible owner in the same logical project, or appears in a derived group in the destination project. The grouping is display-only. ## 📐 Rules | # | Rule | Behavior | | --- | --- | --- | | 1 | Owned threads | An owned thread always has an owner or a group above it in the sidebar. | | 2 | Same project | The child nests under its owner, including across connected environments when both projects share the existing repository group. | | 3 | Different project | The destination shows one collapsed group per owner. The label uses the owner's title, and its link opens the owner. | | 4 | Historical threads | Stored creator provenance alone keeps the thread's existing placement. A released thread can appear as a root. | | 5 | Explicit placement | A valid non-null `groupedUnderThreadId` wins, including a stored group thread. The sidebar creates the other groups in memory. | | 6 | Unavailable owner | The fallback group opens by default. Its label comes from the owner's loaded shell or stored remote title. If neither supplies a title, it shows the translated “Creator unavailable” label with the owner ID. Selection keeps the active path visible through collapse. Rows reattach when normal shell loading brings the owner in. Cycles break into reachable groups. | | 7 | Attribution | The row and menu read stored `creatorOrigin`, `delegatedFrom`, and the legacy `creatorThreadId`. An unavailable creator can still be named. | ## 🎯 Surfaces and decisions - **Shared surfaces:** LastCode web and desktop share the placement code, project menu, keyboard order and Command Palette search. - **Attention:** Sidebar attention rolls up from descendants and from collapsed owner groups. Pending approval and user input stay visible in the group status. A collapsed destination group also shows direct child failures. - **Palette listing:** The initial jump list keeps the existing exclusion for subagents and delegated tasks represented by a visible owner. A typed search can find an owned task whose owner is unavailable. - **Hidden tags:** The LastCode sidebar and search apply hidden tags to each thread's own tags, so a hidden owner leaves independently visible work discoverable. Existing older-settled paging brings in more shells through the same projection. - **Not changed:** Inbox, the default sidebar and native mobile keep their own navigation, since this issue targets the LastCode sidebar. Command Palette in Inbox mode keeps its existing list policy. - **Data source:** The graph reads provider-neutral shell metadata for local and connected environments. - **Out of scope for PR C:** launch tools, scheduled work, native routes, settings controls, RPCs, persistence and server-side lifecycle. Archive and promote belong to PR D, temporary project visibility to PR E. Existing menu mutations are preserved. - **Promote integration:** PR #763 supplies Promote and Return to owner. The rebased menu keeps those actions and the creator label. Legacy grouping still writes explicit placement to the existing eligible local creator. - **Follow-up:** Store the owner’s title at launch so the fallback group can name an owner whose shell is unavailable. - **Copy and docs:** New group controls reuse existing translated strings. No user documentation update is needed. ## ✅ Verification **Tests.** 112 focused unit tests, 49 focused browser tests, 15 React Compiler checks, web type checking and targeted lint passed. Local Quick CI is deferred to the required GitHub checks. **Browser.** Before and after were captured in the same isolated dev browser, using Replay threads and two real connected dev environments on one machine. - **Fixture scopes:** same-project launch, remote task in the same repository group, cross-project group, disconnected owner, and an independent comparison. - **Synthetic ownership:** the ownership records are synthetic, applied to the isolated projection databases. The app itself loaded and rendered the shells. The after image shows the fallback using a stored title. A separate isolated app fixture with an untitled owner showed the translated “Creator unavailable” label, with the child visible and the group expanded. - **Checked:** Search opened the collapsed cross-project child, and the group link returned to the owner, clearing the previous selection and setting the new selection anchor. **Performance.** Browser measurement rebuilt the thread index and projected 40 projects, with mixed local, remote, independent and cross-project shells. Eight warmups, then 25 paired samples that alternated order. Values are before → after. | Shells | Median (ms) | p90 (ms) | | ---: | ---: | ---: | | 4,000 | 5.3 → 7.4 | 6.0 → 8.3 | | 12,000 | 14.6 → 19.6 | 18.7 → 22.4 | This measures graph projection and indexing only. It excludes sorting, React rendering and shell transport. Ownership lookup and graph traversal are bounded by the number of loaded shells, and there are no extra transcript reads. ## 🧱 Upstream-owned files Each changed path was checked against `origin/main`. | File | Added | Removed | | --- | ---: | ---: | | `apps/web/src/components/CommandPalette.logic.ts` | 7 | 5 | | `apps/web/src/components/CommandPaletteThreadItems.tsx` | 3 | 4 | ## Before and after | Before | After | | --- | --- | | <img width="499" alt="Owned threads appeared as project roots" src="https://github.com/user-attachments/assets/ff22d502-ce57-45f0-924a-345a438decd3"> | <img width="499" alt="Same-project children nest under their owner, with a collapsed destination group and an open fallback group" src="https://github.com/user-attachments/assets/94aa4c7e-4ffe-4b38-9c7c-7a4eb6546d6e"> | Local review: 2 initial full-diff rounds, 1 orchestrator-fix delta round and 1 post-rebase full-diff round with Codex Terra 6.1 (xhigh), approved. GPT-6.2 Sol high via Codex in LastCode. Carry-Source-Ref: refs/lastcode/carry-sources/pr-762/54f369a59cb010a885d3d70dd738f06a1f631595 Carry-Source-Base: 757e54a Carry-Source-Head: 54f369a
Part of #751 ## Problem Agents launch threads in other projects, and #753 now records who owns them. Archiving the parent at wrap-up still left that owned work open, so it had to be archived thread by thread. This PR makes wrap-up follow ownership across projects, and keeps threads the user has written in open by default. ## What gets archived Within the **current environment**, archiving uses the existing placement and delegated family and follows `getThreadOwner` transitively across projects. **Historical threads** whose creator record has no ownership keep their existing archive behavior. **Threads released from ownership** stay outside the added cascade. **Unarchive** uses the persisted `archivedWith` cohort. An already-archived intermediate keeps its prior restore cohort for legacy placement and lineage. A descendant reached only through recorded ownership restores with the operation that archived it. ## Human-message rule A child stays open by default when its stored shell records a message with **user role and user authorship**. The `latestUserAuthoredMessageAt` signal excludes agent relays and idle compaction. Renames and other actions that adopt the workspace do not set this message signal. The child and its downstream family stay owned. If the child is already archived, its messages still protect the live branch. Web and desktop can include the branch with separate confirmation. Mobile previews the default selection and offers Review so the user can open and archive a conversation directly. ## Preview and protections - **Preview first.** Web, desktop, mobile, and the tool show the family before the wider selection applies. Clients list titles and projects, what stays open, and active, unread, or protected state. The tool returns the environment ID and project IDs. - **Server re-check.** The server validates the exact selection again under its locks. - **Saved workspaces.** Each archive selection shows its own discardable and retained copies. The server binds disposal consent to the confirmed thread IDs. A copy shared with a thread that stays open remains available. - **Bulk.** An explicitly selected child still gets its own archive when the parent's default keeps it open. When two operations share a thread, the later one refreshes and can proceed only when its confirmed selection still matches after removing threads the batch already archived. - Existing activity, permission, shutdown, and retry protections apply to the selected family. ## Groups In an archive that uses the new ownership preview, a marked group is eligible when it has no conversations, runs, recorded Project Actions, user adoption, or protection, and every live member is in the same confirmed archive. It then archives with the family and can be restored from the archive. ## Scope and follow-ups - **Current environment only.** Linked environments can already preview or archive a known thread ID with the peer's authorization. They cannot enumerate a remote part of a family by owner, or record an offline destination as pending. - **Cross-environment follow-up.** Use an owner-qualified inventory and a durable operation record. Review the exact selection per reachable peer, use that peer’s authorization, and record its receipt. Show offline or denied peers as pending or blocked and retry idempotently. Restore the cohorts that actually committed. - **Temporary projects.** PR #761 landed the project listing service. The orchestrator is scheduling removal at wrap-up separately. Promotion landed in #763 and is included through the base. ## Archive performance Measured on the same 4,866 real thread projections. The dev migration preserved complete histories for 191 visible, stopped threads. The benchmark added the remaining projection rows from a read-only snapshot and archived only the migrated threads. | Median wall time | Original main | Original PR | Current main | Guarded indexed PR | | --- | ---: | ---: | ---: | ---: | | Candidate query | 0.08 ms | 33.85 ms | 0.09 ms | 0.43 ms | | Family preview | 12.76 ms | 48.19 ms | 13.47 ms | 14.48 ms | | Archive one 11-thread family | 176 ms | 425 ms | 183 ms | 178 ms | | Archive 50 threads, including previews | 654 ms | 11.44 s | 671 ms | 778 ms | Across five alternating pairs per comparison, the original query added a median 10.70 seconds to the 50-thread batch. The guarded indexed query added 108 ms (range +66 to +139 ms). The traced statements account for a median 76 ms of this difference. The 11-thread command runs the candidate query three times at dispatch and four times at completion. Preview adds one. The bulk ran 284 statements, including 50 previews. SQLite's original plan materialized `recorded_owner_candidates` and scanned the thread table twice. The new plan seeks both partial expression indexes from the recursive family and group lookups. The expressions guard malformed JSON so legacy recovery can keep running. The recorded restore-cohort lookup runs only when the root has both cohort fields. Ownership qualification stays in `getThreadOwner`. ## Verification - **Seeded parity.** On a LastCode database seed, current main and the indexed head selected and archived the same 27 threads across three real historical families. Archive events and exact restore cohorts matched. Each case used its own disposable copy, production dispatch, and the production archive runner, with the background worker disabled. The seed stayed byte-for-byte identical. - **Tests.** Archive and promotion server tests, the saved-workspace regression, Chromium confirmation tests, compiled web tests, and mobile and shared unit tests passed. Quick CI passed on the current head. Three bulk-archive regressions cover shared members in both orders and a refresh that finds new work. The database recovery, migration, and archive suites verify guarded lookups on legacy data and index selection. - **Browser.** The isolated browser applied the default cascade across two projects, and the user-authored conversation stayed open. - **Evals.** The new tool eval passed 0/4 on the baseline and 4/4 after the first tool change. The idle control passed 3/3 on both. The rebased tool text passed all 12 scored samples, including 3/3 for the typed-in branch and 2/2 for the idle control. The provider stream ended early on three samples, which remained unscored. - **Context growth.** The measured agent tool list grew by 314 bytes (85,690 → 86,004). The budget changes by one line. <details><summary>Browser evidence</summary> The existing archive menu on the synthetic fixture. <img width="840" alt="Archive option in the existing thread menu" src="https://github.com/user-attachments/assets/87994587-c683-4fd7-9b1a-3e2cb0353b39" /> The cross-project preview with the typed-in conversation kept open. <img width="840" alt="Archive preview with projects, selection, and a keep-open conversation" src="https://github.com/user-attachments/assets/da231c65-2c75-49c1-b7f8-00bb46c4e810" /> Opting in to archive the typed-in child now updates the saved-copy list to match the selection. Both captures use the same Chromium fixture. | Before | After | | --- | --- | | <img width="414" alt="After opt-in, the saved copy still appears under retained copies" src="https://github.com/user-attachments/assets/71bd3d69-c49e-43a1-be6f-24559f768658" /> | <img width="414" alt="After opt-in, the shared saved copy appears in the list to discard" src="https://github.com/user-attachments/assets/3176ef20-d563-4775-bf04-b3adeac23810" /> | </details> ## Upstream-owned files | File | Added | Removed | | --- | ---: | ---: | | `apps/mobile/src/features/home/useThreadListActions.test.ts` | 4 | 0 | | `apps/server/src/mcp/toolkits/thread/handlers.ts` | 6 | 0 | | `apps/server/src/mcp/toolkits/thread/tools.ts` | 4 | 2 | | `apps/server/src/orchestration-v2/Orchestrator.ts` | 6 | 35 | | `apps/server/src/orchestration-v2/ProjectionStore.ts` | 3 | 1 | | `apps/server/src/orchestration-v2/ThreadManagementService.ts` | 2 | 1 | | `apps/server/src/provider/agentContextBudget.json` | 1 | 1 | | `packages/client-runtime/src/operations/commands.ts` | 8 | 0 | | `packages/contracts/src/orchestrationV2.ts` | 4 | 0 | | Each of `apps/mobile/src/i18n/translations/{de,en,es,fr,ja,ko,pt-BR,ru,sv,zh}.json` | 3 | 0 | | Each of `apps/web/src/i18n/translations/{de,en,es,fr,ja,ko,pt-BR,ru,sv,zh}.json` | 5 | 0 | 🤖 Generated with [Claude Code](https://claude.com/claude-code) Local review: 4 rounds with GPT-6.1 Terra (xhigh), approved. The fourth round reviewed the final safety changes after churn-gate. A separate scoped source review approved the archive query and index migration. Carry-Source-Ref: refs/lastcode/carry-sources/pr-764/51687d0e8003745ca2058df231e4d0fcf7e87310 Carry-Source-Base: afdac03 Carry-Source-Head: 51687d0
Part of #751.
Owned threads had no explicit way to become independent conversations. This adds one, plus the way back.
What changed
t3_thread_organize({ threadId, action: "promote" }), run on the environment holding the thread.action: "return_to_owner"restores the prior owner.thread.ownership.changewiththreadId,commandId, andaction.lineage.independentto true andgroupedUnderThreadIdto null. It keeps the creator origin, delegated-from reference, and lineage parent. It clears pin and active ordering keys tied to the old placement.When promotion is allowed
creatorOriginis sufficient, even during a running turn.completionDelivery.state(acknowledged,delivered, ordisposed). The pending/claimed and live-task predicate used for completion also guards promotion.remoteDelegationsassociations. Each must besettledwith afinalRun, ordisposed;preparedoractiveblocks promotion. The requester can still fetch and record the result after destination promotion.run.actionObligations(waiting work, transfers into live continuations), plusrun.pullRequestWatchObligationsandrun.pullRequestWatchContinuation(active or undelivered work). Archived, deleted, or unresolved-archive threads refuse ownership changes.task_cancel, then retry. The sidebar shows a disabled Promote item with the reason.Return
owner.threadIdmust exist; checked witharchivedAt,deletedAt, and a stoppingarchivePendingstate.ownerStateChecked: false. Return does not verify a reverse link.Out of scope
canPromotefields: unchanged and inert, since this is an explicit ownership command.Proof
3ed52aaa0a58before the GitHub review fixes. The first four commits gained only their requiredCarry-Group: incubatortrailer.Local review: 4 rounds with Codex Terra (xhigh), approved. The fourth was the bounded confirmation requested by the churn-gate judge.
Upstream-owned files
Files present on the upstream mirror, with additions and deletions against LastCode's base.
apps/server/src/mcp/toolkits/project/handlers.tsapps/server/src/mcp/toolkits/thread/handlers.tsapps/server/src/mcp/toolkits/thread/tools.tsapps/server/src/observability/RpcInstrumentation.tsapps/server/src/orchestration-v2/Orchestrator.tsapps/server/src/orchestration-v2/ProjectionStore.test.tsapps/server/src/orchestration-v2/ProjectionStore.tsapps/server/src/orchestration-v2/ShellStream.tsapps/server/src/orchestration-v2/ThreadManagementService.tsapps/server/src/orchestration-v2/ThreadSearch.test.tsapps/server/src/orchestration-v2/ThreadSearch.tsapps/server/src/orchestration-v2/ThreadSettlementService.test.tsapps/server/src/orchestration-v2/ThreadSettlementService.tsapps/server/src/orchestration-v2/testkit/OrchestratorScenario.tsapps/server/src/peer/RemoteDelegation.test.tsapps/server/src/provider/agentContextBudget.jsonapps/server/src/relay/AgentAwarenessRelay.test.tsapps/server/src/storageCleanup.test.tsapps/server/src/storageCleanup.tsapps/server/src/ws.tsapps/web/src/i18n/translations/de.jsonapps/web/src/i18n/translations/en.jsonapps/web/src/i18n/translations/es.jsonapps/web/src/i18n/translations/fr.jsonapps/web/src/i18n/translations/ja.jsonapps/web/src/i18n/translations/ko.jsonapps/web/src/i18n/translations/pt-BR.jsonapps/web/src/i18n/translations/ru.jsonapps/web/src/i18n/translations/sv.jsonapps/web/src/i18n/translations/zh.jsondocs/user/thread-sidebar.mdpackages/client-runtime/src/state/threadCommands.tspackages/client-runtime/src/state/threadShell.test.tspackages/client-runtime/src/state/threadShell.tspackages/client-runtime/src/state/threadTagFilter.test.tspackages/client-runtime/src/state/threadTagFilter.tspackages/contracts/src/clientRpcPermissions.tspackages/contracts/src/index.tspackages/contracts/src/orchestrationV2.tspackages/contracts/src/rpc.tsSidebar screenshots
Implemented by GPT-6.2 Sol (high) through Codex in T3 Code.