Skip to content

Commit 5de316b

Browse files
authored
Move Low Bandwidth feature to devtools. (#32797)
* Move and rename low bandwidth mode. * Still in use. * remove string * Add a test for low bandwidth mode * Test requests too * update snaps * New year!
1 parent 811670a commit 5de316b

File tree

7 files changed

+116
-10
lines changed

7 files changed

+116
-10
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2026 Element Creations Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import { test, expect } from "../../element-web-test";
9+
import { getSampleFilePath } from "../../sample-files";
10+
11+
test.describe("Devtools", () => {
12+
test.use({
13+
displayName: "Alice",
14+
});
15+
16+
test("should allow enabling low bandwidth mode", async ({ page, homeserver, user, app }) => {
17+
// Upload a picture
18+
const userSettings = await app.settings.openUserSettings("Account");
19+
const profileSettings = userSettings.locator(".mx_UserProfileSettings");
20+
await profileSettings.getByAltText("Upload").setInputFiles(getSampleFilePath("riot.png"));
21+
await app.closeDialog();
22+
23+
// Create an initial room.
24+
const createRoomDialog = await app.openCreateRoomDialog();
25+
await createRoomDialog.getByRole("textbox", { name: "Name" }).fill("Test Room");
26+
await createRoomDialog.getByRole("button", { name: "Create room" }).click();
27+
28+
const composer = app.getComposer().locator("[contenteditable]");
29+
await composer.fill("/devtools");
30+
await composer.press("Enter");
31+
const dialog = page.locator(".mx_Dialog");
32+
await dialog.getByLabel("Developer mode").check();
33+
await dialog.getByLabel("Disable bandwidth-heavy features").click();
34+
// Wait for refresh.
35+
await page.waitForEvent("domcontentloaded");
36+
await app.viewRoomByName("Test Room");
37+
38+
// This only appears when encryption has been disabled in the client.
39+
await expect(page.getByText("The encryption used by this room isn't supported.")).toBeVisible();
40+
41+
// None of these should be requested.
42+
let hasSentTyping = false;
43+
let hasRequestedThumbnail = false;
44+
await page.route("**/_matrix/client/v3/rooms/*/typing/*", async (route) => {
45+
hasSentTyping = true;
46+
await route.fulfill({ json: {} });
47+
});
48+
await page.route("**/_matrix/media/v3/thumbnail/**", async (route) => {
49+
hasRequestedThumbnail = true;
50+
await route.fulfill({ json: {} });
51+
});
52+
await page.route("**/_matrix/client/v1/media/thumbnail/**", async (route) => {
53+
hasRequestedThumbnail = true;
54+
await route.fulfill({ json: {} });
55+
});
56+
57+
await composer.pressSequentially("Provoke typing request", { delay: 5 });
58+
expect(hasSentTyping).toEqual(false);
59+
expect(hasRequestedThumbnail).toEqual(false);
60+
});
61+
});

apps/web/src/components/views/dialogs/DevtoolsDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const DevtoolsDialog: React.FC<IProps> = ({ roomId, threadRootId, onFinished })
115115
<SettingsFlag name="developerMode" level={SettingLevel.ACCOUNT} />
116116
<SettingsFlag name="showHiddenEventsInTimeline" level={SettingLevel.DEVICE} />
117117
<SettingsFlag name="enableWidgetScreenshots" level={SettingLevel.ACCOUNT} />
118+
<SettingsFlag name="lowBandwidth" level={SettingLevel.DEVICE} />
118119
</Form.Root>
119120
{/* The settings field needs to be outside `Form.Root` because `SettingsField` will have a inner Form,
120121
Otherwise we end up with a nester `Form` and that prohibits `preventDefault` so setting the value

apps/web/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { SettingLevel } from "../../../../../settings/SettingLevel";
1616
import SdkConfig from "../../../../../SdkConfig";
1717
import BetaCard from "../../../beta/BetaCard";
1818
import SettingsFlag from "../../../elements/SettingsFlag";
19-
import { type FeatureSettingKey, LabGroup, labGroupNames } from "../../../../../settings/Settings";
19+
import { type FeatureSettingKey, type LabGroup, labGroupNames } from "../../../../../settings/Settings";
2020
import { EnhancedMap } from "../../../../../utils/maps";
2121
import { SettingsSection } from "../../shared/SettingsSection";
2222
import { SettingsSubsection, SettingsSubsectionText } from "../../shared/SettingsSubsection";
@@ -71,10 +71,6 @@ export default class LabsUserSettingsTab extends React.Component<EmptyObject> {
7171
.push(<SettingsFlag level={SettingLevel.DEVICE} name={f} key={f} />);
7272
});
7373

74-
groups
75-
.getOrCreate(LabGroup.Experimental, [])
76-
.push(<SettingsFlag key="lowBandwidth" name="lowBandwidth" level={SettingLevel.DEVICE} />);
77-
7874
labsSections = (
7975
<>
8076
{sortBy(Array.from(groups.entries()), "0").map(([group, flags]) => (

apps/web/src/i18n/strings/en_EN.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,8 @@
828828
"invalid_device_key_id": "Invalid device key ID",
829829
"invalid_json": "Doesn't look like valid JSON.",
830830
"level": "Level",
831-
"low_bandwidth_mode": "Low bandwidth mode",
832-
"low_bandwidth_mode_description": "Requires compatible homeserver.",
831+
"low_bandwidth_mode": "Disable bandwidth-heavy features",
832+
"low_bandwidth_mode_description": "Disables encryption, presence, avatars, read receipts, and typing notifications",
833833
"main_timeline": "Main timeline",
834834
"manual_device_verification": "Manual device verification",
835835
"no_receipt_found": "No receipt found",

apps/web/src/settings/Settings.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ export interface Settings {
327327
}>;
328328
"breadcrumbs": IBaseSetting<boolean>;
329329
"showHiddenEventsInTimeline": IBaseSetting<boolean>;
330+
/**
331+
* This is the 2019-era low bandwidth that deals with disabling features of the
332+
* client. It does NOT make any API or spec changes.
333+
*/
330334
"lowBandwidth": IBaseSetting<boolean>;
331335
"fallbackICEServerAllowed": IBaseSetting<boolean | null>;
332336
"RoomList.preferredSorting": IBaseSetting<SortingAlgorithm>;

apps/web/test/unit-tests/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,50 @@ exports[`DevtoolsDialog renders the devtools dialog 1`] = `
237237
</label>
238238
</div>
239239
</div>
240+
<div
241+
class="_inline-field_19upo_32"
242+
>
243+
<div
244+
class="_inline-field-control_19upo_44"
245+
>
246+
<div
247+
class="_container_udcm8_10"
248+
>
249+
<input
250+
class="_input_udcm8_24"
251+
id="mx_SettingsFlag_4yVCeEefiPqp"
252+
role="switch"
253+
type="checkbox"
254+
/>
255+
<div
256+
class="_ui_udcm8_34"
257+
/>
258+
</div>
259+
</div>
260+
<div
261+
class="_inline-field-body_19upo_38"
262+
>
263+
<label
264+
class="_label_19upo_59"
265+
for="mx_SettingsFlag_4yVCeEefiPqp"
266+
>
267+
Disable bandwidth-heavy features
268+
</label>
269+
<span
270+
class="_message_19upo_85 _help-message_19upo_91"
271+
id="radix-_r_c_"
272+
>
273+
<span>
274+
<span
275+
class="mx_SettingsTab_microcopy_warning"
276+
>
277+
WARNING:
278+
</span>
279+
Disables encryption, presence, avatars, read receipts, and typing notifications
280+
</span>
281+
</span>
282+
</div>
283+
</div>
240284
</form>
241285
<form
242286
class="_root_19upo_16"
@@ -246,7 +290,7 @@ exports[`DevtoolsDialog renders the devtools dialog 1`] = `
246290
>
247291
<label
248292
class="_label_19upo_59"
249-
for="radix-_r_a_"
293+
for="radix-_r_d_"
250294
>
251295
Element Call URL
252296
</label>
@@ -255,7 +299,7 @@ exports[`DevtoolsDialog renders the devtools dialog 1`] = `
255299
>
256300
<input
257301
class="_control_sqdq4_10"
258-
id="radix-_r_a_"
302+
id="radix-_r_d_"
259303
name="input"
260304
title=""
261305
value=""

apps/web/test/unit-tests/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ describe("<LabsUserSettingsTab />", () => {
4848
// non-beta labs section
4949
expect(screen.getByText("Early previews")).toBeInTheDocument();
5050
const labsSections = container.getElementsByClassName("mx_SettingsSubsection");
51-
expect(labsSections).toHaveLength(9);
51+
expect(labsSections).toHaveLength(8);
5252
});
5353
});

0 commit comments

Comments
 (0)