From d39d7e08bbb51cda26117e4a9e1196350e16fbdc Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Sat, 30 May 2026 11:47:08 -0700 Subject: [PATCH 1/3] Quick tweak to apply mobile safari overflow hack to normal webkit --- packages/diffs/src/components/CodeView.ts | 42 +++++++++++++---------- packages/diffs/src/style.css | 1 + 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/packages/diffs/src/components/CodeView.ts b/packages/diffs/src/components/CodeView.ts index ef0e9c6ef..f8285c6a3 100644 --- a/packages/diffs/src/components/CodeView.ts +++ b/packages/diffs/src/components/CodeView.ts @@ -475,21 +475,18 @@ interface SpringStepResult { velocity: number; } -// A vibe slopped heuristic to detect mobile safari only -const MOBILE_SAFARI = (() => { - const { navigator } = globalThis; - - const userAgent = navigator.userAgent; - const isIOS = /iP(?:hone|ad|od)/.test(userAgent); - const isIPadOS = - navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1; - - return ( - (isIOS || isIPadOS) && - /AppleWebKit/.test(userAgent) && - /Safari/.test(userAgent) && - !/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(userAgent) - ); +// A vibe slopped heuristic to detect WebKit browsers without matching +// Chromium, which includes AppleWebKit in its user agent for compatibility. +const IS_WEBKIT = (() => { + return true; + // const { navigator } = globalThis; + // + // const userAgent = navigator.userAgent; + // + // return ( + // /AppleWebKit/.test(userAgent) && + // !/(Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS)/.test(userAgent) + // ); })(); type PendingAlignTypes = Exclude; @@ -762,17 +759,21 @@ export class CodeView { this.pointerEventsDisabled = true; } - // This is a really important fix for mobile safari; under aggressive scroll + // This is a really important fix for WebKit; under aggressive scroll // conditions we'll eventually crash/reload the page. It appears to be // caused by the fact that the code wrapper elements are horizontally // scrollable, so while aggressively scrolling, we disable scrolling. We - // don't want to apply this fix to good browsers since in those cases it + // don't want to apply this fix to other browsers since in those cases it // can fuck with layout in ways that aren't appropriate - if (MOBILE_SAFARI && !this.codeOverflowFix) { + if (IS_WEBKIT && !this.codeOverflowFix) { this.stickyContainer.style.setProperty( SCROLLING_CODE_OVERFLOW_FIX_VARIABLE, 'hidden' ); + this.stickyContainer.style.setProperty( + '--diffs-scrollbar-gutter-override', + '0px' + ); this.codeOverflowFix = true; } @@ -793,7 +794,10 @@ export class CodeView { if (this.codeOverflowFix) { this.stickyContainer.style.setProperty( SCROLLING_CODE_OVERFLOW_FIX_VARIABLE, - 'auto' + 'scroll' + ); + this.stickyContainer.style.removeProperty( + '--diffs-scrollbar-gutter-override' ); this.codeOverflowFix = false; } diff --git a/packages/diffs/src/style.css b/packages/diffs/src/style.css index 85a15f21c..fb7cfeb4f 100644 --- a/packages/diffs/src/style.css +++ b/packages/diffs/src/style.css @@ -786,6 +786,7 @@ ) ); scrollbar-gutter: stable; + overflow-anchor: none; } [data-diffs-scrollbar-measure] { From 0c9dea4a8175d8e4f195adf2d4508f36c046368f Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Mon, 1 Jun 2026 22:50:40 -0700 Subject: [PATCH 2/3] Disable syntax highlighting --- packages/diffs/src/worker/WorkerPoolManager.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/diffs/src/worker/WorkerPoolManager.ts b/packages/diffs/src/worker/WorkerPoolManager.ts index 49b1bcc3c..f218a873a 100644 --- a/packages/diffs/src/worker/WorkerPoolManager.ts +++ b/packages/diffs/src/worker/WorkerPoolManager.ts @@ -61,6 +61,7 @@ import type { } from './types'; const IGNORE_RESPONSE = Symbol('IGNORE_RESPONSE'); +const DISABLE_HIGHLIGHTING = true; class WorkerPoolTerminatedError extends Error { constructor() { @@ -559,6 +560,7 @@ export class WorkerPoolManager { // attempt to highlight. This should be mostly never hit, but it's just an // extra level of safety if ( + DISABLE_HIGHLIGHTING || isFilePlainText(file) || (cachedResult != null && areFileRenderOptionsEqual( @@ -583,6 +585,7 @@ export class WorkerPoolManager { const cachedResult = this.getFileResultCache(file); const highlightKey = this.getFileHighlightKey(file); if ( + DISABLE_HIGHLIGHTING || highlightKey == null || isFilePlainText(file) || (cachedResult != null && @@ -628,6 +631,7 @@ export class WorkerPoolManager { // attempt to highlight. This should be mostly never hit, but it's just an // extra level of safety if ( + DISABLE_HIGHLIGHTING || isDiffPlainText(diff) || (cachedResult != null && areDiffRenderOptionsEqual( @@ -652,6 +656,7 @@ export class WorkerPoolManager { const cachedResult = this.getDiffResultCache(diff); const highlightKey = this.getDiffHighlightKey(diff); if ( + DISABLE_HIGHLIGHTING || highlightKey == null || isDiffPlainText(diff) || (cachedResult != null && From 1c7d9217a79577d613fbe17e5965845a566f2f45 Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Mon, 1 Jun 2026 23:43:09 -0700 Subject: [PATCH 3/3] Optimize toggle --- packages/diffs/src/components/CodeView.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/diffs/src/components/CodeView.ts b/packages/diffs/src/components/CodeView.ts index f8285c6a3..187ce69e0 100644 --- a/packages/diffs/src/components/CodeView.ts +++ b/packages/diffs/src/components/CodeView.ts @@ -475,10 +475,20 @@ interface SpringStepResult { velocity: number; } +let forceOptimize = false; + +if (typeof window !== 'undefined') { + // @ts-expect-error + window.__OPTIMIZE = () => { + forceOptimize = !forceOptimize; + console.log('Optimized:', forceOptimize); + }; +} + // A vibe slopped heuristic to detect WebKit browsers without matching // Chromium, which includes AppleWebKit in its user agent for compatibility. -const IS_WEBKIT = (() => { - return true; +let IS_WEBKIT = () => { + return forceOptimize; // const { navigator } = globalThis; // // const userAgent = navigator.userAgent; @@ -487,7 +497,7 @@ const IS_WEBKIT = (() => { // /AppleWebKit/.test(userAgent) && // !/(Chrome|Chromium|CriOS|Edg|EdgiOS|OPR|OPiOS)/.test(userAgent) // ); -})(); +}; type PendingAlignTypes = Exclude; @@ -765,7 +775,7 @@ export class CodeView { // scrollable, so while aggressively scrolling, we disable scrolling. We // don't want to apply this fix to other browsers since in those cases it // can fuck with layout in ways that aren't appropriate - if (IS_WEBKIT && !this.codeOverflowFix) { + if (IS_WEBKIT() && !this.codeOverflowFix) { this.stickyContainer.style.setProperty( SCROLLING_CODE_OVERFLOW_FIX_VARIABLE, 'hidden'