Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(desktop): back/forward buttons and trackpad swipe navigation #27430

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/27430/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The desktop app had no visible way to go back or forward, and two-finger trackpad swipes did nothing, unlike in a browser.

  • Buttons: back and forward buttons sit right after the T3 Code logo in the sidebar header. Each is disabled when there's nowhere to go, and the tooltip shows the existing ⌘[ / ⌘] shortcut. The sidebar's minimum width now includes them so they never wrap.
  • Swipe: a two-finger horizontal swipe shows a circle peeking in from the edge of the main content area, at the pointer's height. The arrow turns solid once the swipe has gone far enough (120px), and navigation happens when the fingers lift. Swiping back or holding still before lifting cancels.
  • When a swipe commits: DOM wheel events carry no touch phase. The swipe commits on the first sign of lift: macOS's coasting tail (scroll steps shrinking by a near-constant ratio), an empty wheel event, or Chromium's gestureScrollEnd. The main window already forwarded gestureScrollEnd for the 3D device viewer; it now forwards gestureScrollBegin too. After a swipe commits, the rest of that gesture is ignored until the next begin, so rapid repeated swipes each start fresh and no timers are involved.
  • Left alone: swipes over horizontally scrollable content that can still scroll, swipes inside dialogs, pinch-zoom, and swipes mainly vertical, judged after 8px of movement.
  • Desktop only: browsers already have their own buttons and swipe navigation, and both together would navigate twice.

Before / after

BeforeAfter
Before: sidebar header with only the sidebar toggle and T3 Code logoAfter: back and forward arrows to the right of the T3 Code logo

After: mid-swipe forward, the arrow peeks in at the right edge of the main area

Swipe demo (synthetic wheel events in a browser tab, with the desktop-only gate forced on):

https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/f112fb64cbb93553/swipe-demo.mp4

Tested by hand on a MacBook trackpad in the desktop app, including rapid repeated swipes.

Built with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

    1. @@ -0,0 +126,21 @@
      126+ gesture.sumX += event.deltaX;
      127+ gesture.sumY += event.deltaY;
      128+ if (Math.abs(gesture.sumX) + Math.abs(gesture.sumY) < SWIPE_AXIS_LOCK_DISTANCE) return;
      129+ gesture = lockSwipeAxis(gesture);
      130+ if (gesture.kind === "ignored") return;
      131+ } else {
      132+ const delta = gesture.direction === "back" ? -event.deltaX : event.deltaX;
      133+ if (event.deltaX === 0 && event.deltaY === 0) return release();
      134+ gesture.deltas = [...gesture.deltas.slice(1 - MOMENTUM_SAMPLE_SIZE), delta];
      135+ if (isMomentumTail(gesture.deltas)) return release();
      136+ gesture.distance = Math.max(0, gesture.distance + delta);
      137+ }
      138+ setSwipe({
      139+ direction: gesture.direction,
      140+ progress: Math.min(1, gesture.distance / SWIPE_TRIGGER_DISTANCE),
      141+ y: gesture.y,
      142+ bounds: gesture.bounds,
      143+ tracking: true,
      144+ });
      145+ };
      146+ window.addEventListener("wheel", onWheel, { capture: true, passive: true });
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High components/HistorySwipeNavigation.tsx:146

      A 120px horizontal wheel gesture over phoneTrackpad.ts rotates the 3D device and also navigates browser history on release. The capture listener at window runs before the target can call preventDefault or stopPropagation, and lockSwipeAxis does not exclude these surfaces; ignore their wheel events or process only events they do not consume.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/web/src/components/HistorySwipeNavigation.tsx around line 146:
      
      A 120px horizontal wheel gesture over `phoneTrackpad.ts` rotates the 3D device and also navigates browser history on release. The capture listener at `window` runs before the target can call `preventDefault` or `stopPropagation`, and `lockSwipeAxis` does not exclude these surfaces; ignore their wheel events or process only events they do not consume.
    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Adds desktop history buttons and default trackpad swipe navigation, plus a new line-level lint suppression that requires human review. The unresolved finding reports that gestures rotating the 3D device can also navigate away.

      Needs human approval because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 97e35bc · PR result: 02ce70a · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. juliusmarminge merged this476590d

    5. juliusmarminge closed this

Sign in to join this conversation.