Skip to content

Commit d2e97d6

Browse files
committed
Start preview session without waiting for repo selection
1 parent 4f8dcc4 commit d2e97d6

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

apps/twig/src/main/services/agent/service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
416416
const {
417417
taskId,
418418
taskRunId,
419-
repoPath,
419+
repoPath: rawRepoPath,
420420
credentials,
421421
logUrl,
422422
sessionId: existingSessionId,
@@ -425,6 +425,9 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
425425
permissionMode,
426426
} = config;
427427

428+
// Preview sessions don't need a real repo — use a temp directory
429+
const repoPath = taskId === "__preview__" ? tmpdir() : rawRepoPath;
430+
428431
if (!isRetry) {
429432
const existing = this.sessions.get(taskRunId);
430433
if (existing) {

apps/twig/src/renderer/features/sessions/service/service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ export class SessionService {
480480

481481
async startPreviewSession(params: {
482482
adapter: "claude" | "codex";
483-
repoPath?: string;
484483
}): Promise<void> {
485484
this.previewAbort?.abort();
486485
const abort = new AbortController();
@@ -508,7 +507,7 @@ export class SessionService {
508507
const result = await trpcVanilla.agent.start.mutate({
509508
taskId: PREVIEW_TASK_ID,
510509
taskRunId,
511-
repoPath: params.repoPath || "~",
510+
repoPath: "__preview__",
512511
apiKey: auth.apiKey,
513512
apiHost: auth.apiHost,
514513
projectId: auth.projectId,

apps/twig/src/renderer/features/task-detail/components/TaskInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function TaskInput() {
6060
thoughtOption,
6161
previewTaskId,
6262
isConnecting,
63-
} = usePreviewSession(adapter, selectedDirectory || undefined);
63+
} = usePreviewSession(adapter);
6464

6565
useEffect(() => {
6666
if (view.folderId) {

apps/twig/src/renderer/features/task-detail/hooks/usePreviewSession.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@ interface PreviewSessionResult {
2424
* Manages a lightweight preview session that provides adapter-specific
2525
* config options (models, modes, reasoning levels) for the task input page.
2626
*
27-
* Starts a new preview session when adapter or repoPath change,
27+
* Starts a new preview session when adapter changes,
2828
* and cleans up on unmount or when inputs change.
2929
*/
3030
export function usePreviewSession(
3131
adapter: "claude" | "codex",
32-
repoPath: string | undefined,
3332
): PreviewSessionResult {
3433
useEffect(() => {
3534
const service = getSessionService();
36-
service.startPreviewSession({ adapter, repoPath });
35+
service.startPreviewSession({ adapter });
3736

3837
return () => {
3938
service.cancelPreviewSession();
4039
};
41-
}, [adapter, repoPath]);
40+
}, [adapter]);
4241

4342
const session = useSessionForTask(PREVIEW_TASK_ID);
4443
const modeOption = useModeConfigOptionForTask(PREVIEW_TASK_ID);

0 commit comments

Comments
 (0)