Codeman icon indicating copy to clipboard operation
Codeman copied to clipboard

Foldable phone: inconsistent display preferences and stale layout after folding/unfolding

Open shenlvkang-collab opened this issue 1 month ago • 4 comments

Two related foldable viewport problems

Using Codeman on a foldable phone, the unfolded/full-width view and folded/narrow view show inconsistent UI styling/settings. It feels necessary to configure the same device twice. Also, changing posture while the page is open can leave the previous posture's layout/style active until reloading.

Environment: Codeman 1.44.0, Android foldable phone. Exact model, browser/WebView version and CSS viewport dimensions have not been captured; these symptoms are user-reported. The same loaded page changes width when folded/unfolded.

Reproduction

  1. Open Codeman on the unfolded inner display.
  2. Configure display/layout preferences and use the page.
  3. Fold the phone so the viewport becomes narrower, without reloading.
  4. Observe the UI: the previous wide layout/style can remain active instead of adapting to the narrow display.
  5. Reload or reopen settings and compare folded/unfolded behavior. Some UI preferences/styles appear inconsistent, as if separately configured.
  6. Repeat narrow-to-wide and wide-to-narrow, both on Home and while viewing a session.

Expected

  • A physical phone retains its chosen visual preferences across posture changes; changing responsive arrangement should not unexpectedly reset or switch its theme/style preferences.
  • Layout-dependent UI responds to a width/breakpoint change without manual reload or losing the active session/input.
  • Explicitly separate compact/wide preferences, if intended, should be clearly identified rather than appearing as settings that did not stick.

Code paths to investigate

There is already foldable-aware work: MobileDetection.isHandheldDevice() tries to keep settings identity stable, and getSettingsStorageKey() uses it. This issue is not claiming that settings are always keyed by viewport width.

However, getDeviceType() still uses <600, <768, and desktop breakpoints; display application in settings-ui.js branches on device type. MobileDetection.init()'s resize handler updates body classes, app height, session-list layout and tab overflow but does not generally reapply display settings. The Home media-query handlers in mobile-overview.js and home-sessions.js also skip their change action when activeSessionId is set. Please audit these paths together with the cached settings and viewport/media-query changes.

Suggested regression coverage: resize one Android mobile browser context across 599/600 and 767/768px in both directions, preserving the same localStorage and active session, without navigation. Check theme/settings consistency, responsive controls, sidebar/tab layout and Home visibility. Include virtual-keyboard height-only resize as a separate case so it does not trigger a posture reset.

Additional verified reproduction (2026-10-24)

An isolated Chromium run against the built 1.44.0 application reproduced a stale Home surface while resizing the same page from 1440px to 390px. There was no selected session (activeSessionId === null). After waiting 3.5 seconds, shouldUseMobileOverview() returned true, but #mobileOverview.hidden remained true and #welcomeOverlay was still visible. Calling showWelcome() applied the narrow Home surface. This confirms a dynamic transition problem independently of the user's exact phone model; it does not establish the cause of the separately reported preference inconsistency.

One candidate: the mobile media-query listener is installed by _wireMobileOverview(), which is reached when that surface is first shown. A page first loaded wide may not have installed that listener before its first transition to narrow. Please test wide-first loading as well as narrow-first loading.

shenlvkang-collab avatar Oct 24 '26 05:10 shenlvkang-collab

Thanks @shenlvkang-collab, this is a useful report, and the reproduction against the built app is what makes it actionable.

Your candidate is right. I checked: _wireMobileOverview() in src/web/public/mobile-overview.js installs the phone breakpoint listener only from the first showMobileOverview(). A page that loads wide never shows the phone overview, so it never gets the listener, and folding to narrow with no session selected leaves the welcome overlay up until something calls showWelcome() again. That is exactly the #mobileOverview.hidden === true you measured. The desktop rail (_wireHomeSessions() in home-sessions.js) wires itself the same lazy way, from the first showHomeSessions(), so the narrow-first direction is worth testing the same way. The fix is to install both listeners once at startup rather than on first show.

On the preferences half: the settings namespace is keyed on MobileDetection.isHandheldDevice() precisely so an unfolded phone keeps the same store (codeman-app-settings-mobile), so the stored values themselves should not differ between postures. What can differ is what gets applied: several display choices branch on the width-driven getDeviceType() (the header stats style, for example, is forced to classic below 768px) and are only re-applied on a settings load, not on a breakpoint change. That reads as "a setting that didn't stick". To pin it down I'd need the phone model, the browser (Chrome, Samsung Internet or a wrapper app), window.innerWidth folded and unfolded, and which settings looked different.

A PR for the listener half is welcome. The regression test you sketched is what I'd want: one page resized across 599/600 and 767/768 in both directions with the same localStorage and no navigation, loaded wide-first and narrow-first, plus a height-only keyboard resize that must not count as a posture change.

Ark0N avatar Oct 24 '26 11:10 Ark0N

The layout half is fixed in #790: both home-screen breakpoint listeners are now installed once at startup, so folding a page that loaded wide brings up the phone overview, and unfolding a page that loaded narrow brings back the welcome screen and the rail. It comes with the regression test you sketched (wide-first and narrow-first, across 599/600 and 767/768 in both directions, plus a height-only keyboard resize that must not count as a posture change). That test also caught a second, smaller race: a rail render queued just before the fold could unhide the rail behind the phone overview, which #790 fixes too.

I'm leaving this issue open for the preferences half. To pin that down I still need the phone model, the browser (Chrome, Samsung Internet or a wrapper app), window.innerWidth folded and unfolded, and which settings looked different.

Ark0N avatar Nov 09 '26 01:11 Ark0N

The layout half (#790) shipped today in Codeman 1.50.1: folding a page that loaded wide now brings up the phone overview, and unfolding one that loaded narrow brings back the welcome screen and the rail. Thanks again for the report, @shenlvkang-collab. If the fold still misbehaves for you on 1.50.1, say so here.

Ark0N avatar Nov 10 '26 23:11 Ark0N

Closing this one. The layout half is fixed since 1.50.1 (#790): folding and unfolding now switch between the phone overview and the wide home screen without a reload.

The preferences half I could not pin down. The stored settings are keyed on the device, not on the width, so an unfolded phone reads the same store as a folded one. What can differ is which of them get applied at each width, and to find out which one you saw I still need the four facts asked for above: the phone model, the browser (Chrome, Samsung Internet or a wrapper app), window.innerWidth folded and unfolded, and which settings looked different.

@shenlvkang-collab, if it still happens on 1.51.0, reply here with those and I'll reopen it.

Ark0N avatar Nov 12 '26 13:11 Ark0N