Improve pull request flow, add branch selection for worktree creation, fix auto-mode concurrency count (#787)

* Changes from fix/fetch-before-pull-fetch

* feat: Improve pull request flow, add branch selection for worktree creation, fix for automode concurrency count

* feat: Add validation for remote names and improve error handling

* Address PR comments and mobile layout fixes

* ```
refactor: Extract PR target resolution logic into dedicated service
```

* feat: Add app shell UI and improve service imports. Address PR comments

* fix: Improve security validation and cache handling in git operations

* feat: Add GET /list endpoint and improve parameter handling

* chore: Improve validation, accessibility, and error handling across apps

* chore: Format vite server port configuration

* fix: Add error handling for gh pr list command and improve offline fallbacks

* fix: Preserve existing PR creation time and improve remote handling
This commit is contained in:
gsxdsm
2026-02-19 21:55:12 -08:00
committed by GitHub
parent ee52333636
commit 7df2182818
80 changed files with 4729 additions and 1107 deletions

View File

@@ -49,6 +49,8 @@ export function AgentView() {
// Ref for quick create session function from SessionManager
const quickCreateSessionRef = useRef<(() => Promise<void>) | null>(null);
// Guard to prevent concurrent invocations of handleCreateSessionFromEmptyState
const createSessionInFlightRef = useRef(false);
// Session management hook
const { currentSessionId, handleSelectSession } = useAgentSession({
@@ -130,6 +132,51 @@ export function AgentView() {
await clearHistory();
};
// Handle creating a new session from empty state.
// On mobile the SessionManager may be unmounted (hidden), clearing the ref.
// In that case, show it first and wait for the component to mount and
// re-populate quickCreateSessionRef before invoking it.
//
// A single requestAnimationFrame isn't always sufficient — React concurrent
// mode or slow devices may not have committed the SessionManager mount by
// the next frame. We use a double-RAF with a short retry loop to wait more
// robustly for the ref to be populated.
const handleCreateSessionFromEmptyState = useCallback(async () => {
if (createSessionInFlightRef.current) return;
createSessionInFlightRef.current = true;
try {
let createFn = quickCreateSessionRef.current;
if (!createFn) {
// SessionManager is likely unmounted on mobile — show it so it mounts
setShowSessionManager(true);
// Wait for mount: double RAF + retry loop (handles concurrent mode & slow devices)
const MAX_RETRIES = 5;
for (let i = 0; i < MAX_RETRIES; i++) {
await new Promise<void>((r) =>
requestAnimationFrame(() => requestAnimationFrame(() => r()))
);
createFn = quickCreateSessionRef.current;
if (createFn) break;
// Small delay between retries to give React time to commit
if (i < MAX_RETRIES - 1) {
await new Promise<void>((r) => setTimeout(r, 50));
createFn = quickCreateSessionRef.current;
if (createFn) break;
}
}
}
if (createFn) {
await createFn();
} else {
console.warn(
'[AgentView] quickCreateSessionRef was not populated after retries — SessionManager may not have mounted'
);
}
} finally {
createSessionInFlightRef.current = false;
}
}, []);
// Auto-focus input when session is selected/changed
useEffect(() => {
if (currentSessionId && inputRef.current) {
@@ -177,7 +224,7 @@ export function AgentView() {
{/* Session Manager Sidebar */}
{showSessionManager && currentProject && (
<div className="fixed inset-y-0 left-0 w-72 z-30 lg:relative lg:w-80 lg:z-auto border-r border-border shrink-0 bg-card">
<div className="fixed inset-y-0 left-0 w-72 z-30 pt-[env(safe-area-inset-top,0px)] lg:pt-0 lg:relative lg:w-80 lg:z-auto border-r border-border shrink-0 bg-card">
<SessionManager
currentSessionId={currentSessionId}
onSelectSession={handleSelectSession}
@@ -212,6 +259,7 @@ export function AgentView() {
messagesContainerRef={messagesContainerRef}
onScroll={handleScroll}
onShowSessionManager={() => setShowSessionManager(true)}
onCreateSession={handleCreateSessionFromEmptyState}
/>
{/* Input Area */}