Skip to content

Commit b3f6b3a

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-27616
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents 36d0c9c + 0f13d63 commit b3f6b3a

69 files changed

Lines changed: 2068 additions & 194 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/app/DesktopCliShim.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const fakeAppImage = (canMount = true, app = REPORTER) => {
5656
`echo $$ >'${root}/mounter.pid'`,
5757
canMount ? `echo '${image}'` : 'echo "Cannot mount AppImage"; exit 1',
5858
// Like the FUSE runtime, any of these unmounts. fd 3 reports to the test when it is open.
59-
`trap 'echo unmounted >&3 2>/dev/null; touch "${root}/unmounted"; exit 0' TERM HUP INT`,
59+
"trap 'echo unmounted >&3 2>/dev/null; exit 0' TERM HUP INT",
6060
"trap 'echo mounted >&3 2>/dev/null' WINCH",
6161
"while :; do sleep 0.05; done",
6262
"",

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const PREVIEW_REGISTER_WEBVIEW_CHANNEL = "desktop:preview-register-webvie
8888
export const PREVIEW_NAVIGATE_CHANNEL = "desktop:preview-navigate";
8989
export const PREVIEW_GO_BACK_CHANNEL = "desktop:preview-go-back";
9090
export const PREVIEW_GO_FORWARD_CHANNEL = "desktop:preview-go-forward";
91+
export const PREVIEW_STOP_LOADING_CHANNEL = "desktop:preview-stop-loading";
9192
export const PREVIEW_REFRESH_CHANNEL = "desktop:preview-refresh";
9293
export const PREVIEW_ZOOM_IN_CHANNEL = "desktop:preview-zoom-in";
9394
export const PREVIEW_ZOOM_OUT_CHANNEL = "desktop:preview-zoom-out";

‎apps/desktop/src/ipc/methods/preview.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ const refresh = tabMethod(
168168
"desktop.ipc.preview.refresh",
169169
(manager, tabId) => manager.refresh(tabId),
170170
);
171+
const stopLoading = tabMethod(
172+
IpcChannels.PREVIEW_STOP_LOADING_CHANNEL,
173+
"desktop.ipc.preview.stopLoading",
174+
(manager, tabId) => manager.stopLoading(tabId),
175+
);
171176
const zoomIn = tabMethod(
172177
IpcChannels.PREVIEW_ZOOM_IN_CHANNEL,
173178
"desktop.ipc.preview.zoomIn",
@@ -472,6 +477,7 @@ export const methods = [
472477
goBack,
473478
goForward,
474479
refresh,
480+
stopLoading,
475481
zoomIn,
476482
zoomOut,
477483
resetZoom,

‎apps/desktop/src/preload.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ contextBridge.exposeInMainWorld("desktopBridge", {
389389
goBack: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_GO_BACK_CHANNEL, { tabId }),
390390
goForward: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_GO_FORWARD_CHANNEL, { tabId }),
391391
refresh: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_REFRESH_CHANNEL, { tabId }),
392+
stopLoading: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_STOP_LOADING_CHANNEL, { tabId }),
392393
zoomIn: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_ZOOM_IN_CHANNEL, { tabId }),
393394
zoomOut: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_ZOOM_OUT_CHANNEL, { tabId }),
394395
resetZoom: (tabId) => ipcRenderer.invoke(IpcChannels.PREVIEW_RESET_ZOOM_CHANNEL, { tabId }),

‎apps/desktop/src/preview/GuestInput.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ describe("preview guest input", () => {
4444
expect(guest.sendCommand).not.toHaveBeenCalledWith("Input.insertText", expect.anything());
4545
});
4646

47+
it("stops the guest navigation without stopping its embedder", async () => {
48+
let guestLoading = true;
49+
let hostLoading = true;
50+
const guest = {
51+
stop: () => {
52+
guestLoading = false;
53+
},
54+
};
55+
const debuggee = {
56+
sendCommand: async () => {
57+
hostLoading = false;
58+
return {};
59+
},
60+
};
61+
await sendPageCommand(
62+
guest as unknown as Electron.WebContents,
63+
debuggee as unknown as Electron.Debugger,
64+
"Page.stopLoading",
65+
{},
66+
);
67+
expect(guestLoading).toBe(false);
68+
expect(hostLoading).toBe(true);
69+
});
70+
4771
it.each([
4872
{
4973
sessionId: undefined,

‎apps/desktop/src/preview/GuestInput.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ export const sendPageCommand = async (
185185
else webContents.reload();
186186
return {};
187187
}
188+
if (method === "Page.stopLoading") {
189+
webContents.stop();
190+
return {};
191+
}
188192
if (!FOCUS_ROUTED_INPUT.has(method) || webContents.focusedFrame) {
189193
return debuggee.sendCommand(method, params);
190194
}

‎apps/desktop/src/preview/Manager.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
21482148
if (wc.navigationHistory.canGoForward()) wc.navigationHistory.goForward();
21492149
});
21502150
const refresh = (tabId: string) => withWebContents("refresh", tabId, (wc) => wc.reload());
2151+
const stopLoading = (tabId: string) => withWebContents("stopLoading", tabId, (wc) => wc.stop());
21512152
const hardReload = (tabId: string) =>
21522153
withWebContents("hardReload", tabId, (wc) => wc.reloadIgnoringCache());
21532154
const findInPage = (
@@ -3531,6 +3532,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
35313532
prepareWebview,
35323533
reapplyZoom,
35333534
refresh,
3535+
stopLoading,
35343536
registerWebview,
35353537
resetZoom: (tabId: string) => applyZoom(tabId, () => DEFAULT_ZOOM_FACTOR),
35363538
setZoomFactor: (tabId: string, zoomFactor: number) =>
@@ -3732,6 +3734,7 @@ export class PreviewManager extends Context.Service<
37323734
readonly goBack: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
37333735
readonly goForward: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
37343736
readonly refresh: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
3737+
readonly stopLoading: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
37353738
readonly zoomIn: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
37363739
readonly zoomOut: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
37373740
readonly resetZoom: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
@@ -3906,6 +3909,7 @@ export const make = Effect.gen(function* PreviewManagerMake() {
39063909
goBack: operations.goBack,
39073910
goForward: operations.goForward,
39083911
refresh: operations.refresh,
3912+
stopLoading: operations.stopLoading,
39093913
zoomIn: operations.zoomIn,
39103914
zoomOut: operations.zoomOut,
39113915
resetZoom: operations.resetZoom,

‎apps/mobile/src/features/layout/workspace/WorkspaceRootScreen.android.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { WorkspaceAppBarScope } from "../../../components/ui/WorkspaceAppBar.and
2424
import { usePaneRole } from "../../../components/ui/Pane";
2525
import { AndroidWorkspaceSidebar } from "./AndroidWorkspaceSidebar.android";
2626
import type { WorkspaceTab } from "./workspace-tabs-state";
27+
import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
28+
import { useHardwareBack } from "../../../lib/backHandler";
2729

2830
const TABS: readonly WorkspaceTab[] = NAVIGATION_TAB_ORDER;
2931

@@ -49,6 +51,18 @@ function WorkspaceRoot() {
4951
: 16,
5052
};
5153
const tab = workspace.state.selectedTab;
54+
const selectTab = useSelectWorkspaceTab();
55+
// Tabs are panes of Home, not routes, so Back has nothing to pop and would leave the app.
56+
// An open search keeps Back for itself.
57+
useHardwareBack(
58+
tab !== "threads" &&
59+
enabled.includes("threads") &&
60+
workspace.state.tabs[tab].searchMode === "resting",
61+
() => {
62+
selectTab("threads");
63+
return true;
64+
},
65+
);
5266

5367
return (
5468
<WorkspaceTabsContext value={context}>

‎apps/mobile/src/features/layout/workspace/workspace-tabs-state.test.ts‎

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
workspaceSearchBottomClearance,
1212
workspaceDockBottomClearance,
1313
workspaceUsesColumns,
14+
type WorkspaceTab,
15+
type WorkspaceTabsState,
1416
} from "./workspace-tabs-state";
1517

1618
describe("compact list clearance", () => {
@@ -179,12 +181,25 @@ describe("workspace root navigation", () => {
179181
});
180182
});
181183

182-
const mocks = vi.hoisted(() => ({ split: false, floating: false }));
184+
const mocks = vi.hoisted(() => ({
185+
split: false,
186+
floating: false,
187+
state: undefined as WorkspaceTabsState | undefined,
188+
openWorkspaceTab: (_tab: string) => {},
189+
backListeners: new Set<() => boolean>(),
190+
}));
183191

184192
vi.mock("../../settings/appearance/AppearancePreferencesProvider", () => ({
185193
useAndroidFloatingTabs: () => mocks.floating,
186194
}));
187195
vi.mock("react-native", () => ({
196+
BackHandler: {
197+
addEventListener: (_event: string, listener: () => boolean) => {
198+
mocks.backListeners.add(listener);
199+
return { remove: () => mocks.backListeners.delete(listener) };
200+
},
201+
},
202+
Keyboard: { dismiss: () => undefined },
188203
useWindowDimensions: () => ({ width: 400, height: 800 }),
189204
View: ({ children }: { children: ReactNode }) => createElement("div", null, children),
190205
}));
@@ -198,12 +213,16 @@ vi.mock("../AdaptiveWorkspaceLayout", () => ({
198213
startNewTask: () => undefined,
199214
}),
200215
}));
216+
vi.mock("@react-navigation/native", () => ({ useIsFocused: () => true }));
217+
vi.mock("../adaptive-workspace-context", () => ({
218+
useAdaptiveWorkspaceLayout: () => ({ openWorkspaceTab: mocks.openWorkspaceTab }),
219+
}));
201220
vi.mock("./navigation-tabs", () => ({
202221
useEnabledNavigationTabs: () => ["threads", "pullRequests", "usage"],
203222
}));
204223
vi.mock("./WorkspaceTabsContext", () => ({
205224
WorkspaceTabsContext: createContext(null),
206-
useWorkspaceTabs: () => ({ state: { selectedTab: "usage" } }),
225+
useWorkspaceTabs: () => ({ state: mocks.state, dispatch: () => undefined }),
207226
}));
208227
vi.mock("./WorkspaceExtraTab", () => ({
209228
WorkspaceExtraTab: function UsageProbe() {
@@ -238,13 +257,37 @@ vi.mock("../../../components/ui/WorkspaceAppBar.android", () => ({
238257
WorkspaceAppBarScope: ({ children }: { children: ReactNode }) => children,
239258
}));
240259

241-
function setup(split: boolean, floating: boolean) {
260+
function setup(split: boolean, floating: boolean, state = selected("usage")) {
242261
mocks.split = split;
243262
mocks.floating = floating;
263+
mocks.state = state;
264+
mocks.openWorkspaceTab = () => undefined;
265+
mocks.backListeners.clear();
244266
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
245267
return { [Symbol.dispose]: () => vi.unstubAllGlobals() };
246268
}
247269

270+
function selected(tab: WorkspaceTab) {
271+
return workspaceTabsReducer(initialWorkspaceTabsState(), { type: "select", tab });
272+
}
273+
274+
/** Android calls the newest listener first and stops at the first that handles Back. */
275+
function pressBack() {
276+
return [...mocks.backListeners].reverse().some((listener) => listener());
277+
}
278+
279+
it("Back from the Pulls tab returns to Threads instead of leaving the app", async () => {
280+
using _actEnvironment = setup(false, false, selected("pullRequests"));
281+
const opened: string[] = [];
282+
mocks.openWorkspaceTab = (tab) => opened.push(tab);
283+
const root = createRoot(document.createElement("div"));
284+
using _root = { [Symbol.dispose]: () => act(() => root.unmount()) };
285+
await act(async () => root.render(createElement(WorkspaceRootScreen)));
286+
287+
expect(pressBack()).toBe(true);
288+
expect(opened).toEqual(["threads"]);
289+
});
290+
248291
it.each([
249292
[false, false],
250293
[true, false],

‎apps/server/src/environment/ServerEnvironment.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export const make = Effect.gen(function* () {
274274
projectCloneTracking: true,
275275
projectOrganization: true,
276276
ignoredFileListing: true,
277+
ignoredFileSearch: true,
277278
triage: true,
278279
oneTimeSchedules: true,
279280
freshContext: true,

0 commit comments

Comments
 (0)