diff --git a/FORK.md b/FORK.md index ea144da21706c..8bf9ae7bb3d73 100644 --- a/FORK.md +++ b/FORK.md @@ -571,7 +571,7 @@ migrations after upstream migrations. 125. Re-pairing with another credential drops what the last one cached ([#1129](https://github.com/Jacksondr5/j5code/issues/1129)). Upstream's credentials all read the whole server, so its environment cache (shell and thread snapshots) is never another person's. J5's thread-limited Viewer reads less, so after an Owner phone re-paired as a Viewer, Chats briefly listed the Owner's cached threads. `packages/client-runtime/src/connection/registry.ts`: `register` asks J5-owned `replacesCredential` (`packages/client-runtime/src/j5/replacedCredential.ts`) whether a registration for a saved environment brings a credential other than the stored one, and if so runs `forgetReplacedCredential` before `registrations.register` stores it. That marks the environment's credential replaced, closes the old scope, waits for the cache saves already writing, then runs `cache.clear`; `installEntryLocked` then creates the new scope, whose shell loads nothing. A clear that fails fails the registration with its typed error before the new credential is stored, so no new scope reads the old rows and trying again clears again (Captain's ruling: fail visibly, no retry machinery). A shell lives in its follower's stream scope, not the supervisor's, so it outlasts that teardown and flushes when its follower switches to the new entry. `packages/client-runtime/src/state/shell.ts` therefore takes `savesUnderCurrentCredential(environmentId)` when a shell is made and runs `saveShell` through it (one import and two lines): a save under a replaced credential does nothing, and one let through is recorded in the same step, so the clear waits for it. `packages/client-runtime/src/state/threads.ts` does the same for a thread's detail (`saveThread`), whose finalizer also saves. A thread's state is also retained in memory (`ThreadResumeCache`) so a reopen paints at once, and that object outlives the re-pair: `threads.ts` calls `dropReplacedRetainedState` where `makeEnvironmentThreadState` and the thread atom read it, which drops a state retained before the credential was replaced ([#1147](https://github.com/Jacksondr5/j5code/issues/1147)). Editing a connection, which registers its stored credential again, keeps the cache, and so do relay registrations. Web's saved remote servers go through the same `register`. Clearing, rather than keying the cache on the credential, also holds once upstream resumes the shell from its cache (pingdotgg/t3code#32287): a new credential has nothing to resume from. Upstream's `packages/client-runtime/src/connection/onboarding.test.ts` re-pairs with no stored credential, so its cache mock gains `clear`. Proofs: `packages/client-runtime/src/connection/registry.test.ts`, "moves prepared credential observers when re-pairing an unchanged environment", `packages/client-runtime/src/state/shell-sync.test.ts`, "saves nothing more once a re-pair has replaced the environment's credential" and "clears a replaced credential's cache only after a save already writing ends", and `packages/client-runtime/src/state/threads-sync.test.ts`, "does not recreate a cache a re-pair cleared from its finalizer" (which also covers the retained state). On a pin advance: keep the clear between closing the old scope and creating the new one, and the shell's and thread's saves through `savesUnderCurrentCredential`; if upstream adds another cache outside `EnvironmentCacheStore.clear`, or another writer of the shell cache, hold it to the same check. 126. Cmd/Ctrl+F finds in an artifact, not the thread, when the Artifacts surface has focus ([#1152](https://github.com/Jacksondr5/j5code/issues/1152), Jackson's decisions of 2026-11-22: option a1, and a desktop find bar in its own view). Upstream binds `mod+f` to `chat.find` when neither a terminal nor the preview panel has focus, and the right panel counts as the preview panel, so on web Cmd+F with focus in an artifact already opened the browser's find, and with focus in the chat it searched the chat; the desktop app had no find at all. Thread find needs no change: on web and desktop alike, the default binding's `!previewFocus` condition keeps it from running with focus in the surface (upstream's window listener runs in capture, before the surface's own handler). `ArtifactsPage` (the right-panel tab and the `/artifacts` route) spreads `artifactsSurfaceProps` (`apps/web/src/j5/artifacts/artifactFind.ts`) on its root and marks its preview with `artifactFindAreaProps`; Base UI makes the preview's scroll viewport focusable, so a click on the artifact's text puts focus in the surface. On web the browser then opens its own find. On desktop the surface's `onKeyDown` calls `desktopBridge.setFindBar` with the preview's rect, and J5's find bar (`apps/desktop/src/j5/`) opens at its top right: a small page in its own `WebContentsView` over the main window, which searches with `webContents.findInPage`. A view of its own is what makes it work: a bar inside the page loses its focus to `findInPage` and cannot step into an HTML artifact's sandboxed iframe. Keys typed inside that iframe never reach the page, so `installFindBar` also takes Cmd/Ctrl+F in a `before-input-event` hook on the main window, only when the focused frame is the HTML artifact's iframe (named `j5-artifact-preview`) or a frame inside it; in every other frame, upstream's HTML renders and MCP app frames included, the key reaches the frame untouched. The hook matches frame names only; the artifact iframe is `sandbox=""` and runs no script, and any other frame named `j5-artifact-preview` loses only its own Cmd/Ctrl+F. The bar closes, and forgets its query, when the surface unmounts (`setFindBar(null)`; leaving the tab unmounts it) and on a main-frame navigation, in-page route changes included; Ctrl+wheel zoom closes it too. Menu zoom (View → Zoom, Cmd/Ctrl+=) fires no Electron event, so the bar keeps its old position until the next window resize closes it; that is accepted, because noticing it would mean editing upstream's `zoomWindow`. When the bar held focus at close (Esc, ×, or an automatic close while typing in it), focus goes back to the artifact preview; otherwise it stays where it is. Returning to the window also leaves focus in the surface: `apps/web/src/components/ChatView.logic.ts`'s `shouldRefocusComposerOnWindowFocus` adds J5-owned `ARTIFACTS_SURFACE_SELECTOR` to the places it leaves alone (one import and one line). Without it, the window `focus` event that Esc's refocus fires made upstream's ChatView move focus from the markdown preview's scroll viewport, a plain `div`, to the composer, so the next Cmd/Ctrl+F opened thread find. The search covers the whole window, chat included, as browser find does on web. Upstream edits, each generic enough for another panel to reuse: `packages/contracts/src/ipc.ts` adds `DesktopBridge.setFindBar` and its doc line (four lines, as formatted); `apps/desktop/src/preload.ts` its one line; `apps/desktop/src/ipc/channels.ts` the `SET_FIND_BAR_CHANNEL` line; `apps/desktop/src/ipc/DesktopIpcHandlers.ts` one import and one `ipc.handle(setFindBar)`; `apps/desktop/src/window/DesktopWindow.ts` one import and one `installFindBar(window, environment)` after the main window is registered; `apps/desktop/vite.config.ts` one pack block building the bar's sandboxed preload as `j5-find-bar-preload.cjs`; and `knip.jsonc` that preload as an entry. Thread find, and the command palette's "Find in current thread", are unchanged everywhere else. Proof: `apps/web/src/j5/artifacts/artifactFind.browser.test.tsx` and `apps/desktop/src/j5/findController.test.ts`. On a pin advance, keep the surface selector in `shouldRefocusComposerOnWindowFocus`'s exclusions, the `installFindBar` call beside the main window's setup, and the preload's pack block self-contained; if upstream's `chat.find` binding loses its `!previewFocus` condition, thread find would take Cmd/Ctrl+F in the surface on web and desktop. -127. Links in an Inbox ask open in the asking thread's own right panel, shown beside the Inbox ([#1173](https://github.com/Jacksondr5/j5code/issues/1173), the Inbox design Jackson agreed on 2026-11-22). The Inbox passes the sender thread to `ChatMarkdown.tsx` like a thread does, and J5-owned `apps/web/src/j5/a2a/InboxThreadPanel.tsx` mounts that thread's panel from upstream's exported `ChatRightPanel`, `RightPanelSurfaceContent`, `PanelLayoutControls` and right panel store, so nothing in `ChatView.tsx` changes. One upstream edit: `apps/web/src/components/DiffPanel.tsx` takes an optional `threadRef` and uses it in place of the route's thread (one prop, one line), so a commit link's Diff tab renders on the Inbox route, which names no thread. Without the prop the panel reads the route as before. On a pin advance, if `DiffPanel` stops reading `useThreadRouteRef`, carry the override to whatever it reads instead. Proof: `apps/web/src/j5/a2a/InboxMessage.browser.test.tsx` and `inboxThreadPanel.test.ts`. +127. Links in an Inbox ask open in the asking thread's own right panel, shown beside the Inbox ([#1173](https://github.com/Jacksondr5/j5code/issues/1173), the Inbox design Jackson agreed on 2026-11-22). The Inbox passes the sender thread to `ChatMarkdown.tsx` like a thread does, and J5-owned `apps/web/src/j5/a2a/InboxThreadPanel.tsx` mounts that thread's panel from upstream's exported `ChatRightPanel`, `RightPanelSurfaceContent`, `PanelLayoutControls` and right panel store, so nothing in `ChatView.tsx` changes. One upstream edit: `apps/web/src/components/DiffPanel.tsx` takes an optional `threadRef` and uses it in place of the route's thread (one prop, one line), so a commit link's Diff tab renders on the Inbox route, which names no thread. Without the prop the panel reads the route as before. On a pin advance, if `DiffPanel` stops reading `useThreadRouteRef`, carry the override to whatever it reads instead. Proof: `apps/web/src/j5/a2a/InboxMessage.browser.test.tsx` and `inboxThreadPanelState.test.ts`. 128. A file dropped on a Captain's pinned ask goes only to the ask ([#1176](https://github.com/Jacksondr5/j5code/issues/1176), cleared by the Captain of milestone #23 on 2026-11-22). Upstream's thread view takes every file drop that bubbles out of it and adds the files to the composer, and the pinned ask sits inside it, so a file dropped on the ask's answer box went to both. `apps/web/src/components/chat/workspaceFileDrop.ts`: `makeWorkspaceFileDropHandlers`'s `onDrop` still prevents the default and clears the drop overlay, then returns when J5-owned `isInsideOwnFileDropTarget` (`apps/web/src/j5/a2a/answerFileDrop.ts`) finds the target inside an element carrying `ownFileDropTargetProps`, which the pinned ask's body carries while it can take files (it then takes a drop anywhere on it); `WorkspaceFileDragEvent` gains `target` (one import and two lines). Every other drop is upstream's. A check of `event.defaultPrevented` would be smaller but is not equivalent: ProseMirror prevents the default when it inserts a drop's text or HTML, and upstream then still attaches the files. Proof: `apps/web/src/j5/a2a/answerFileDrop.browser.test.ts`. On a pin advance, keep the check after the overlay is cleared; if upstream gives the composer's banner area its own drop handling, retire this case. diff --git a/apps/web/src/j5/a2a/HumanInboxPage.tsx b/apps/web/src/j5/a2a/HumanInboxPage.tsx index 1e22d8e86caf6..a9a623bfa00cb 100644 --- a/apps/web/src/j5/a2a/HumanInboxPage.tsx +++ b/apps/web/src/j5/a2a/HumanInboxPage.tsx @@ -110,7 +110,7 @@ import { useLogicalProjects } from "../logicalProjects"; import { createVisibleRefreshHook } from "../useVisibleRefresh"; import { notifyHumanInboxChanged } from "./humanInboxRefresh"; import { j5Sharing, useConnectionAccess } from "../sharing/access"; -import { armInboxThreadPanel, reachesAskingThreadPanel } from "./inboxThreadPanel"; +import { armInboxThreadPanel, reachesAskingThreadPanel } from "./inboxThreadPanelState"; import { InboxWithThreadPanel } from "./InboxThreadPanel"; import { useSenderThread } from "./useSenderThread"; diff --git a/apps/web/src/j5/a2a/InboxThreadPanel.tsx b/apps/web/src/j5/a2a/InboxThreadPanel.tsx index 23a245dba2dbf..155e4c72d4ca9 100644 --- a/apps/web/src/j5/a2a/InboxThreadPanel.tsx +++ b/apps/web/src/j5/a2a/InboxThreadPanel.tsx @@ -64,7 +64,7 @@ import { followInboxThreadPanelOpens, type InboxPanelThread, useInboxThreadPanelStore, -} from "./inboxThreadPanel"; +} from "./inboxThreadPanelState"; import { useSenderThread } from "./useSenderThread"; const PreviewPanel = lazy(() => diff --git a/apps/web/src/j5/a2a/inboxThreadPanel.test.ts b/apps/web/src/j5/a2a/inboxThreadPanelState.test.ts similarity index 99% rename from apps/web/src/j5/a2a/inboxThreadPanel.test.ts rename to apps/web/src/j5/a2a/inboxThreadPanelState.test.ts index 793de67a0d41c..ab6b556b8b156 100644 --- a/apps/web/src/j5/a2a/inboxThreadPanel.test.ts +++ b/apps/web/src/j5/a2a/inboxThreadPanelState.test.ts @@ -8,7 +8,7 @@ import { followInboxThreadPanelOpens, reachesAskingThreadPanel, useInboxThreadPanelStore, -} from "./inboxThreadPanel"; +} from "./inboxThreadPanelState"; const refA = scopeThreadRef("env-1" as EnvironmentId, ThreadId.make("thread-A")); const refB = scopeThreadRef("env-1" as EnvironmentId, ThreadId.make("thread-B")); diff --git a/apps/web/src/j5/a2a/inboxThreadPanel.ts b/apps/web/src/j5/a2a/inboxThreadPanelState.ts similarity index 100% rename from apps/web/src/j5/a2a/inboxThreadPanel.ts rename to apps/web/src/j5/a2a/inboxThreadPanelState.ts