mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fix intermittent mobile scroll lock and suppress expected git errors on empty repos
This commit is contained in:
1 parent
f90683071f
commit
ae929a7c96
5 files changed
+27
-9
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user