Fix intermittent mobile scroll lock and suppress expected git errors on empty repos

This commit is contained in:
Chris Scott committed 2025-11-29 00:02:10 -05:00
1 parent f90683071f
commit ae929a7c96
5 files changed
+27 -9

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import path from 'path'
async function hasCommits(repoPath: string): Promise<boolean> {
try {
await executeCommand(['git', '-C', repoPath, 'rev-parse', 'HEAD'])
await executeCommand(['git', '-C', repoPath, 'rev-parse', 'HEAD'], { silent: true })
return true
} catch {
return false
+3 -3
View File
@@ -10,7 +10,7 @@ import path from 'path'
async function hasCommits(repoPath: string): Promise<boolean> {
try {
await executeCommand(['git', '-C', repoPath, 'rev-parse', 'HEAD'])
await executeCommand(['git', '-C', repoPath, 'rev-parse', 'HEAD'], { silent: true })
return true
} catch {
return false
@@ -22,13 +22,13 @@ async function safeGetCurrentBranch(repoPath: string): Promise<string | null> {
const repoHasCommits = await hasCommits(repoPath)
if (!repoHasCommits) {
try {
const symbolicRef = await executeCommand(['git', '-C', repoPath, 'symbolic-ref', '--short', 'HEAD'])
const symbolicRef = await executeCommand(['git', '-C', repoPath, 'symbolic-ref', '--short', 'HEAD'], { silent: true })
return symbolicRef.trim()
} catch {
return null
}
}
const currentBranch = await executeCommand(['git', '-C', repoPath, 'rev-parse', '--abbrev-ref', 'HEAD'])
const currentBranch = await executeCommand(['git', '-C', repoPath, 'rev-parse', '--abbrev-ref', 'HEAD'], { silent: true })
return currentBranch.trim()
} catch {
return null
+17 -4
View File
@@ -1,15 +1,24 @@
import { spawn, type ChildProcess } from 'child_process'
import { logger } from './logger'
interface ExecuteCommandOptions {
cwd?: string
silent?: boolean
}
export async function executeCommand(
args: string[],
cwd?: string
cwdOrOptions?: string | ExecuteCommandOptions
): Promise<string> {
const options: ExecuteCommandOptions = typeof cwdOrOptions === 'string'
? { cwd: cwdOrOptions }
: cwdOrOptions || {}
return new Promise((resolve, reject) => {
const [command, ...cmdArgs] = args
const proc: ChildProcess = spawn(command || '', cmdArgs, {
cwd,
cwd: options.cwd,
shell: false
})
@@ -25,7 +34,9 @@ export async function executeCommand(
})
proc.on('error', (error: Error) => {
logger.error(`Command failed: ${args.join(' ')}`, error)
if (!options.silent) {
logger.error(`Command failed: ${args.join(' ')}`, error)
}
reject(error)
})
@@ -34,7 +45,9 @@ export async function executeCommand(
resolve(stdout)
} else {
const error = new Error(`Command failed with code ${code}: ${stderr || stdout}`)
logger.error(`Command failed: ${args.join(' ')}`, error)
if (!options.silent) {
logger.error(`Command failed: ${args.join(' ')}`, error)
}
reject(error)
}
})
@@ -47,6 +47,11 @@ export const MessageThread = memo(function MessageThread({ opcodeUrl, sessionID,
hasInitialScrolledRef.current = false
userScrolledUpRef.current = false
lastMessageCountRef.current = 0
lastScrollTimeRef.current = 0
if (scrollRAFRef.current) {
cancelAnimationFrame(scrollRAFRef.current)
scrollRAFRef.current = null
}
}, [sessionID])
const scrollToBottom = useCallback((force = false) => {
+1 -1
View File
@@ -170,7 +170,7 @@ const { currentPermission, pendingCount, dismissPermission } = usePermissionRequ
/>
<div className="flex-1 overflow-hidden flex flex-col relative">
<div ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden pb-28">
<div key={sessionId} ref={messageContainerRef} className="flex-1 overflow-y-auto overflow-x-hidden pb-28 overscroll-contain touch-pan-y">
{opcodeUrl && repoDirectory && (
<MessageThread
opcodeUrl={opcodeUrl}