Skip to content

[Bug]: Left sidebar restores a reduced width after restart if startup viewport is narrow #29512

Closed

Description

@tastelessjolt

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop (shared width restoration in apps/web)

Summary

The main left sidebar containing projects and chats does not reliably return to its chosen width after quitting and reopening the desktop app. The width preference is still persisted; the startup initialization can reduce the value held in React state, and a later window expansion does not restore the preferred width.

This report separates the observed desktop symptom from a deterministic source-level reproduction of a likely cause. The exact viewport width at the desktop React initializer has not been instrumented, so the connection to the native startup sequence is an inference, not an end-to-end measurement.

Steps to reproduce

Desktop symptom:

  1. Open T3 Code desktop and widen the left projects/chats sidebar.
  2. Quit the desktop application and reopen it.
  3. Observe that the sidebar can reopen narrower and needs resizing again.

The suspected trigger is a temporarily narrow initial viewport before the desktop window manager finishes restoring the larger window. It is timing-dependent, so the following source-level reproduction isolates that condition without needing any real projects or conversations:

  1. Use a synthetic persisted sidebar preference of 350 px.
  2. Initialize sidebar state with an 840 px viewport.
  3. Expand the viewport to 1638 px without dragging the sidebar or remounting its layout.
  4. The sidebar remains 208 px, even though the saved preference is 350 px and the larger window can accommodate it.

Expected behavior

Keep the preferred sidebar width independently of the current viewport constraints. A temporarily narrow window may limit the visible width, but expanding it should restore the saved preference when there is room.

For the synthetic example, the visible width should be limited to 208 px at an 840 px viewport and return to 350 px at a 1638 px viewport.

Actual behavior and code investigation

The matching upstream source is commit 47f2c8d29e98.

  • readInitialThreadSidebarWidth reads chat_thread_sidebar_width and immediately passes window.innerWidth into resolveInitialThreadSidebarWidth.
  • resolveInitialThreadSidebarWidth returns the smaller of the preference and the current maximum. The maximum is max(208, floor(viewportWidth) - 640). At 840 px, that means a 350 px preference becomes 208 px.
  • AppSidebarLayout puts that already-reduced value into useState(readInitialThreadSidebarWidth). The viewport resize subscription updates the bounds, but does not re-run the initializer or recover the original preference.
  • The render path already clamps the width. When the viewport expands, it clamps the retained state of 208 px against the new bounds, so it still renders 208 px.
  • The drag-finish handler persists the selected width. This is consistent with a restoration problem rather than a missing save operation.

The same initializer and initial-width clamp were also present when checking main at 0847a448fdca. This was a source inspection, not a test of a newer built release.

Deterministic supporting reproduction

From the repository root, run this with a Node version that supports importing TypeScript directly (verified with Node 26.13.0):

node --input-type=module <<'JS'
import assert from 'node:assert/strict';
import {
  resolveInitialThreadSidebarWidth,
  resolveThreadSidebarMaximumWidth,
  resolveThreadSidebarMinimumWidth,
  clampThreadSidebarWidth,
} from './apps/web/src/components/threadSidebarWidth.ts';

const savedWidth = 350;
const minimumWidth = resolveThreadSidebarMinimumWidth(0);

// Matches the value retained by useState(readInitialThreadSidebarWidth).
const sidebarState = resolveInitialThreadSidebarWidth(savedWidth, 840);

// Matches the derived display bounds after the viewport expands.
const expandedMaximum = resolveThreadSidebarMaximumWidth(1638, minimumWidth);
const visibleAfterExpansion = clampThreadSidebarWidth(
  sidebarState, minimumWidth, expandedMaximum,
);
const visibleIfPreferenceRetained = clampThreadSidebarWidth(
  savedWidth, minimumWidth, expandedMaximum,
);

assert.equal(sidebarState, 208);
assert.equal(visibleAfterExpansion, 208);
assert.equal(visibleIfPreferenceRetained, 350);
console.log({ savedWidth, sidebarState, visibleAfterExpansion, visibleIfPreferenceRetained });
JS

Observed output:

{
  savedWidth: 350,
  sidebarState: 208,
  visibleAfterExpansion: 208,
  visibleIfPreferenceRetained: 350
}

These assertions confirm the current failure mechanism under the stated input sequence; they are not a full React/Electron restart test. An additional local check against the extracted installed bundle produced the same result. Preserving the preference in the initializer while keeping the existing render clamp restored the expected width in that focused check. No patch was installed in the live app.

Impact

Minor bug or occasional failure: the left sidebar must be resized again after restart.

Version or commit

  • Desktop: 0.1.7-nightly.20261102.4080, packaged commit 47f2c8d.
  • A separately running T3 service on the same machine is 0.1.6-nightly.20261031.3977. No service upgrade or restart was performed during this investigation; the source/bundle analysis above targets the installed desktop version.

Environment

Arch Linux, x86_64, kernel 7.2.14-arch1-1. The running Electron desktop process uses --ozone-platform=wayland.

Logs or stack traces

The saved sidebar width was present in the desktop Chromium local-storage files. Startup-adjacent desktop traces also contain repeated window-size transitions equivalent to:

main window bounds: width=840,  height=980, isMaximized=false
main window bounds: width=1638, height=980, isMaximized=false

Some launches additionally log:

saved main window bounds could not be restored; using defaults

Only dimensions and the relevant warning are included here; identifiers, paths, timestamps, and unrelated logs have been omitted. These bounds are consistent with the suspected trigger, but do not establish the value of window.innerWidth at the exact React initialization moment. The desktop minimum window width is 840 px.

Screenshots, recordings, or supporting files

No screenshot or recording of the live desktop workspace is included, to avoid exposing projects or conversations. The deterministic synthetic reproduction and its output are provided above. A privacy-safe screenshot of that reproduction was generated, but the CLI attachment upload was rejected because it requires write access to this repository.

Workaround / possible fix direction

Manually resize the sidebar again after reopening the desktop app.

A possible fix is to retain the saved/default preferred width in state and apply viewport constraints only to the derived rendered width. Existing min/max bounds and the 640 px main-content allowance should still apply. A regression check should cover an initially narrow viewport followed by expansion, as well as missing preferences and storage-read failures.

Related but different: #24191 concerns the sidebar's collapsed/open state. This report concerns its resized width while open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions