Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/mobile/src/features/threads/ThreadHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export function ThreadHeader(props: {
readonly hasThreadCwd: boolean;
readonly inspectorMode: ThreadInspectorMode | null;
readonly onOpenFilesInspector: () => void;
/** Present only on a delegated child the user may pop out. */
readonly onPopOut?: () => void;
}) {
const gt = useGT();
const m = useMessages();
Expand All @@ -44,6 +46,16 @@ export function ThreadHeader(props: {
},
]
: [];
if (props.onPopOut) {
actions.push({
accessibilityLabel: gt("Pop out to top level"),
icon: "arrow.up.right.circle",
subtitle: gt("Make it an ordinary thread"),
overflowOnly: true,
separateBackground: false,
onPress: props.onPopOut,
});
}
const menus = [gitMenu, terminalMenu].filter((menu): menu is AppBarMenu => menu !== null);

return (
Expand Down
45 changes: 44 additions & 1 deletion apps/mobile/src/features/threads/ThreadRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ import { useSelectedThreadGitState } from "../../state/use-selected-thread-git-s
import { useSelectedThreadRequests } from "../../state/use-selected-thread-requests";
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
import { useThreadComposerState } from "../../state/use-thread-composer-state";
import { resolveMergeBackTargetThreadId } from "@t3tools/client-runtime/state/thread-relationships";
import {
resolveMergeBackTargetThreadId,
threadPopOutAvailability,
} from "@t3tools/client-runtime/state/thread-relationships";
import { resolveLatestMergeBackRun } from "@t3tools/client-runtime/state/thread-workflows";
import { threadEnvironment } from "../../state/threads";
import {
Expand Down Expand Up @@ -465,6 +468,45 @@ function ThreadRouteContent(
const navigation = useNavigation();
const selectDetail = useSelectWorkspaceDetail();
const openPullRequest = useOpenPullRequest();
const popOut = useAtomCommand(threadEnvironment.popOut, { reportFailure: false });
const popOutBusyRef = useRef(false);
const popOutAvailability =
selectedThread && canOperateThread
? threadPopOutAvailability(selectedThread.source)
: "unsupported";
const handlePopOut = () => {
if (!selectedThread || popOutBusyRef.current) return;
if (popOutAvailability === "blocked") {
Dialog.alert(gt("Can't pop out yet"), gt("Wait for it to finish or stop it first."));
return;
}
const environmentId = selectedThread.environmentId;
const threadId = selectedThread.id;
Dialog.confirm({
title: gt("Pop out to top level?"),
message: gt(
"It becomes an ordinary thread in your list and stops reporting to the thread that started it.",
),
confirmText: gt("Pop out"),
onConfirm: () => {
if (popOutBusyRef.current) return;
popOutBusyRef.current = true;
void popOut({ environmentId, input: { threadId } })
.then((result) => {
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
Dialog.alert(
gt("Could not pop out thread"),
error instanceof Error ? error.message : gt("Try again."),
);
}
})
.finally(() => {
popOutBusyRef.current = false;
});
},
});
};
const mergeBack = useAtomCommand(threadEnvironment.mergeBack, "merge thread back");
const mergeBackTargetThreadId = resolveMergeBackTargetThreadId(selectedThreadDetail);
const mergeBackRun =
Expand Down Expand Up @@ -1048,6 +1090,7 @@ function ThreadRouteContent(
inspectorMode={inspectorMode}
onOpenFilesInspector={handleOpenFilesInspector}
onReturnToThread={props.onReturnToThread}
onPopOut={popOutAvailability === "unsupported" ? undefined : handlePopOut}
/>
)
}
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4725,6 +4725,8 @@
"11bb30071c8d00e4": "Der Link kann einmal verwendet werden und läuft nach 24 Stunden ab.",
"05ba3b5f06a7acfe": "Dateien schließen",
"c7e4f052c3d6c066": "Dateien öffnen",
"c440ceeaf0452d52": "Auf oberste Ebene verschieben",
"8dcc52104281c7d2": "In einen normalen Thread umwandeln",
"740ee1b96278f02f": "Audio · {size}",
"93ade1a4fd485bc3": "Audio",
"e8043d133bb85048": "Audio pausieren",
Expand Down Expand Up @@ -4760,6 +4762,12 @@
"d506b798402041ab": "Jetzt senden",
"9a62f694ba5c35c5": "Thread wird geöffnet…",
"bb24a2960c689a20": "Dieser Thread ist im aktuellen mobilen Snapshot nicht verfügbar.",
"172e0baea818e9aa": "Verschieben noch nicht möglich",
"dd4ea2dfb2476c35": "Warte, bis er fertig ist, oder stoppe ihn zuerst.",
"4249bde5600d6792": "Auf oberste Ebene verschieben?",
"b000660ae40f4586": "Er wird zu einem normalen Thread in deiner Liste und meldet keine Ergebnisse mehr an den Thread, der ihn gestartet hat.",
"8df226bf3314e35d": "Verschieben",
"84eccdaa4d8f3c01": "Thread konnte nicht verschoben werden",
"41ca8f475c481866": "Subagent von {title}",
"f3e00e6c416eab38": "Von {origin}",
"bdfb9e7660ab25d3": "Thread konnte nicht fortgesetzt werden",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4727,6 +4727,8 @@
"11bb30071c8d00e4": "The link works once and expires in 24 hours.",
"05ba3b5f06a7acfe": "Close files",
"c7e4f052c3d6c066": "Open files",
"c440ceeaf0452d52": "Pop out to top level",
"8dcc52104281c7d2": "Make it an ordinary thread",
"740ee1b96278f02f": "Audio · {size}",
"93ade1a4fd485bc3": "Audio",
"e8043d133bb85048": "Pause audio",
Expand Down Expand Up @@ -4762,6 +4764,12 @@
"d506b798402041ab": "Send now",
"9a62f694ba5c35c5": "Opening thread…",
"bb24a2960c689a20": "This thread is not available in the current mobile snapshot.",
"172e0baea818e9aa": "Can't pop out yet",
"dd4ea2dfb2476c35": "Wait for it to finish or stop it first.",
"4249bde5600d6792": "Pop out to top level?",
"b000660ae40f4586": "It becomes an ordinary thread in your list and stops reporting to the thread that started it.",
"8df226bf3314e35d": "Pop out",
"84eccdaa4d8f3c01": "Could not pop out thread",
"41ca8f475c481866": "Subagent of {title}",
"f3e00e6c416eab38": "From {origin}",
"bdfb9e7660ab25d3": "Could not resume thread",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4718,6 +4718,8 @@
"11bb30071c8d00e4": "El enlace solo se puede usar una vez y caduca en 24 horas.",
"05ba3b5f06a7acfe": "Cerrar archivos",
"c7e4f052c3d6c066": "Abrir archivos",
"c440ceeaf0452d52": "Mover al nivel superior",
"8dcc52104281c7d2": "Convertir en un hilo normal",
"740ee1b96278f02f": "Audio · {size}",
"93ade1a4fd485bc3": "Audio",
"e8043d133bb85048": "Pausar audio",
Expand Down Expand Up @@ -4753,6 +4755,12 @@
"d506b798402041ab": "Enviar ahora",
"9a62f694ba5c35c5": "Abriendo hilo…",
"bb24a2960c689a20": "Este hilo no está disponible en la instantánea móvil actual.",
"172e0baea818e9aa": "Aún no se puede mover",
"dd4ea2dfb2476c35": "Espera a que termine o detenlo primero.",
"4249bde5600d6792": "¿Mover al nivel superior?",
"b000660ae40f4586": "Se convierte en un hilo normal de tu lista y deja de enviar resultados al hilo que lo inició.",
"8df226bf3314e35d": "Mover",
"84eccdaa4d8f3c01": "No se pudo mover el hilo",
"41ca8f475c481866": "Subagente de {title}",
"f3e00e6c416eab38": "De {origin}",
"bdfb9e7660ab25d3": "No se pudo reanudar el hilo",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4719,6 +4719,8 @@
"11bb30071c8d00e4": "Le lien est à usage unique et expire dans 24 heures.",
"05ba3b5f06a7acfe": "Fermer les fichiers",
"c7e4f052c3d6c066": "Ouvrir les fichiers",
"c440ceeaf0452d52": "Déplacer au premier niveau",
"8dcc52104281c7d2": "En faire un fil ordinaire",
"740ee1b96278f02f": "Audio · {size}",
"93ade1a4fd485bc3": "Audio",
"e8043d133bb85048": "Mettre l’audio en pause",
Expand Down Expand Up @@ -4754,6 +4756,12 @@
"d506b798402041ab": "Envoyer maintenant",
"9a62f694ba5c35c5": "Ouverture du fil…",
"bb24a2960c689a20": "Ce fil n’est pas disponible dans l’instantané mobile actuel.",
"172e0baea818e9aa": "Déplacement encore impossible",
"dd4ea2dfb2476c35": "Attendez la fin ou arrêtez-le d'abord.",
"4249bde5600d6792": "Déplacer au premier niveau ?",
"b000660ae40f4586": "Il devient un fil ordinaire dans votre liste et ne transmet plus ses résultats au fil qui l'a lancé.",
"8df226bf3314e35d": "Déplacer",
"84eccdaa4d8f3c01": "Impossible de déplacer le fil",
"41ca8f475c481866": "Sous-agent de {title}",
"f3e00e6c416eab38": "Depuis {origin}",
"bdfb9e7660ab25d3": "Impossible de reprendre le fil",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -4699,6 +4699,8 @@
"11bb30071c8d00e4": "リンクは 1 回だけ使用でき、24 時間後に期限が切れます。",
"05ba3b5f06a7acfe": "ファイルを閉じる",
"c7e4f052c3d6c066": "ファイルを開く",
"c440ceeaf0452d52": "最上位に移動",
"8dcc52104281c7d2": "通常のスレッドにする",
"740ee1b96278f02f": "音声 · {size}",
"93ade1a4fd485bc3": "音声",
"e8043d133bb85048": "音声を一時停止",
Expand Down Expand Up @@ -4734,6 +4736,12 @@
"d506b798402041ab": "今すぐ送信",
"9a62f694ba5c35c5": "スレッドを開いています…",
"bb24a2960c689a20": "このスレッドは現在のモバイルのスナップショットでは利用できません。",
"172e0baea818e9aa": "まだ移動できません",
"dd4ea2dfb2476c35": "完了するまで待つか、先に停止してください。",
"4249bde5600d6792": "最上位に移動しますか?",
"b000660ae40f4586": "一覧の通常のスレッドになり、開始元のスレッドへの結果報告を停止します。",
"8df226bf3314e35d": "移動",
"84eccdaa4d8f3c01": "スレッドを移動できませんでした",
"41ca8f475c481866": "{title} のサブエージェント",
"f3e00e6c416eab38": "{origin} から",
"bdfb9e7660ab25d3": "スレッドを再開できませんでした",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -4704,6 +4704,8 @@
"11bb30071c8d00e4": "링크는 한 번만 사용할 수 있으며 24시간 후 만료됩니다.",
"05ba3b5f06a7acfe": "파일 닫기",
"c7e4f052c3d6c066": "파일 열기",
"c440ceeaf0452d52": "최상위로 이동",
"8dcc52104281c7d2": "일반 스레드로 전환",
"740ee1b96278f02f": "오디오 · {size}",
"93ade1a4fd485bc3": "오디오",
"e8043d133bb85048": "오디오 일시 중지",
Expand Down Expand Up @@ -4739,6 +4741,12 @@
"d506b798402041ab": "지금 보내기",
"9a62f694ba5c35c5": "스레드 여는 중…",
"bb24a2960c689a20": "이 스레드는 현재 모바일 스냅샷에서 사용할 수 없습니다.",
"172e0baea818e9aa": "아직 이동할 수 없음",
"dd4ea2dfb2476c35": "완료될 때까지 기다리거나 먼저 중지하세요.",
"4249bde5600d6792": "최상위로 이동할까요?",
"b000660ae40f4586": "목록의 일반 스레드가 되며, 이 스레드를 시작한 스레드에 결과를 보고하지 않습니다.",
"8df226bf3314e35d": "이동",
"84eccdaa4d8f3c01": "스레드를 이동하지 못했습니다",
"41ca8f475c481866": "{title}의 서브에이전트",
"f3e00e6c416eab38": "출처: {origin}",
"bdfb9e7660ab25d3": "스레드를 재개할 수 없습니다",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4719,6 +4719,8 @@
"11bb30071c8d00e4": "O link só pode ser usado uma vez e expira em 24 horas.",
"05ba3b5f06a7acfe": "Fechar arquivos",
"c7e4f052c3d6c066": "Abrir arquivos",
"c440ceeaf0452d52": "Mover para o nível superior",
"8dcc52104281c7d2": "Tornar uma conversa comum",
"740ee1b96278f02f": "Áudio · {size}",
"93ade1a4fd485bc3": "Áudio",
"e8043d133bb85048": "Pausar áudio",
Expand Down Expand Up @@ -4754,6 +4756,12 @@
"d506b798402041ab": "Enviar agora",
"9a62f694ba5c35c5": "Abrindo thread…",
"bb24a2960c689a20": "Esta thread não está disponível no snapshot móvel atual.",
"172e0baea818e9aa": "Ainda não é possível mover",
"dd4ea2dfb2476c35": "Espere terminar ou pare primeiro.",
"4249bde5600d6792": "Mover para o nível superior?",
"b000660ae40f4586": "Ela se torna uma conversa comum na sua lista e deixa de enviar resultados à conversa que a iniciou.",
"8df226bf3314e35d": "Mover",
"84eccdaa4d8f3c01": "Não foi possível mover a conversa",
"41ca8f475c481866": "Subagente de {title}",
"f3e00e6c416eab38": "De {origin}",
"bdfb9e7660ab25d3": "Não foi possível retomar a thread",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -4797,6 +4797,8 @@
"11bb30071c8d00e4": "Ссылкой можно воспользоваться один раз, срок её действия истекает через 24 часа.",
"05ba3b5f06a7acfe": "Закрыть файлы",
"c7e4f052c3d6c066": "Открыть файлы",
"c440ceeaf0452d52": "Переместить на верхний уровень",
"8dcc52104281c7d2": "Сделать обычной веткой",
"740ee1b96278f02f": "Аудио · {size}",
"93ade1a4fd485bc3": "Аудио",
"e8043d133bb85048": "Приостановить аудио",
Expand Down Expand Up @@ -4832,6 +4834,12 @@
"d506b798402041ab": "Отправить сейчас",
"9a62f694ba5c35c5": "Открытие треда…",
"bb24a2960c689a20": "Этот тред недоступен в текущем мобильном снимке.",
"172e0baea818e9aa": "Пока нельзя переместить",
"dd4ea2dfb2476c35": "Дождитесь завершения или сначала остановите.",
"4249bde5600d6792": "Переместить на верхний уровень?",
"b000660ae40f4586": "Она станет обычной веткой в списке и перестанет отправлять результаты в ветку, которая её запустила.",
"8df226bf3314e35d": "Переместить",
"84eccdaa4d8f3c01": "Не удалось переместить ветку",
"41ca8f475c481866": "Субагент {title}",
"f3e00e6c416eab38": "Из {origin}",
"bdfb9e7660ab25d3": "Не удалось возобновить тред",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -4725,6 +4725,8 @@
"11bb30071c8d00e4": "Länken kan användas en gång och går ut om 24 timmar.",
"05ba3b5f06a7acfe": "Stäng filer",
"c7e4f052c3d6c066": "Öppna filer",
"c440ceeaf0452d52": "Flytta till översta nivån",
"8dcc52104281c7d2": "Gör den till en vanlig tråd",
"740ee1b96278f02f": "Ljud · {size}",
"93ade1a4fd485bc3": "Ljud",
"e8043d133bb85048": "Pausa ljudet",
Expand Down Expand Up @@ -4760,6 +4762,12 @@
"d506b798402041ab": "Skicka nu",
"9a62f694ba5c35c5": "Öppnar tråden…",
"bb24a2960c689a20": "Tråden är inte tillgänglig i den aktuella mobilögonblicksbilden.",
"172e0baea818e9aa": "Kan inte flytta ännu",
"dd4ea2dfb2476c35": "Vänta tills den är klar eller stoppa den först.",
"4249bde5600d6792": "Flytta till översta nivån?",
"b000660ae40f4586": "Den blir en vanlig tråd i listan och slutar rapportera till tråden som startade den.",
"8df226bf3314e35d": "Flytta",
"84eccdaa4d8f3c01": "Kunde inte flytta tråden",
"41ca8f475c481866": "Subagent till {title}",
"f3e00e6c416eab38": "Från {origin}",
"bdfb9e7660ab25d3": "Kunde inte återuppta tråden",
Expand Down
8 changes: 8 additions & 0 deletions apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -4708,6 +4708,8 @@
"11bb30071c8d00e4": "链接仅限使用一次,并在 24 小时后过期。",
"05ba3b5f06a7acfe": "关闭文件",
"c7e4f052c3d6c066": "打开文件",
"c440ceeaf0452d52": "移至顶层",
"8dcc52104281c7d2": "设为普通会话",
"740ee1b96278f02f": "音频 · {size}",
"93ade1a4fd485bc3": "音频",
"e8043d133bb85048": "暂停音频",
Expand Down Expand Up @@ -4743,6 +4745,12 @@
"d506b798402041ab": "立即发送",
"9a62f694ba5c35c5": "正在打开会话…",
"bb24a2960c689a20": "当前移动端快照中没有此会话。",
"172e0baea818e9aa": "暂时无法移出",
"dd4ea2dfb2476c35": "请等待完成,或先停止。",
"4249bde5600d6792": "移至顶层?",
"b000660ae40f4586": "它将成为列表中的普通会话,并停止向启动它的会话报告结果。",
"8df226bf3314e35d": "移出",
"84eccdaa4d8f3c01": "无法移出会话",
"41ca8f475c481866": "{title} 的子智能体",
"f3e00e6c416eab38": "来自 {origin}",
"bdfb9e7660ab25d3": "无法继续会话",
Expand Down
16 changes: 16 additions & 0 deletions apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,22 @@ const make = Effect.gen(function* () {
}
return yield* remoteDelegation.cancel(scope, remoteTask, input);
}
// Pop-out needs every task in the child to have ended, and it leaves this thread's control.
const childShell = yield* threadManagement
.getThreadShell(childThreadId)
.pipe(Effect.mapError(threadManagementFailure));
if (childShell?.lineage.detachedFrom?.threadId === scope.thread.threadId) {
if (!isTerminalTaskStatus(current.status)) {
return yield* failure(
"invalid_request",
`Thread ${childThreadId} was popped out to top level and no longer belongs to this task.`,
);
}
return {
taskId: input.taskId,
status: current.status,
} satisfies OrchestratorMcpTaskCancelResult;
}
const key = yield* requestKey(input.clientRequestId);
const parentProjection = yield* loadThreadRecords(scope.thread.threadId, []);
// Cancelling stops the child and every task under it, each a write to a
Expand Down
54 changes: 54 additions & 0 deletions apps/server/src/mcp/toolkits/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,60 @@ it.effect("rejects an unknown organize target instead of archiving the calling t
);
});

it.effect("allows an agent to pop out only its own child", () => {
const dispatched: Array<unknown> = [];
return Effect.gen(function* () {
const server = yield* McpServer.McpServer;
const otherThreadId = ThreadId.make("mcp-core-child");
for (const target of [undefined, threadId, otherThreadId, ThreadId.make("unrelated")]) {
const result = yield* server
.callTool({
name: "t3_thread_organize",
arguments: { action: "pop_out", ...(target === undefined ? {} : { threadId: target }) },
})
.pipe(
Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
Effect.provideService(McpSchema.McpServerClient, client),
);
if (target === otherThreadId) expect(result.isError).not.toBe(true);
else
expect(declaredFailure(result)).toMatchObject({
code: "invalid_request",
message: expect.stringContaining("cannot pop itself out"),
});
}
expect(dispatched).toMatchObject([{ type: "thread.detach", threadId: otherThreadId }]);
}).pipe(
Effect.provide(
layerThreadToolkit.pipe(
Layer.provideMerge(McpHttpServer.layerInProcessMcpServer),
Layer.provide(NodeCrypto.layer),
Layer.provide(
Layer.mock(ThreadManagement.ThreadManagementService)({
getThreadShell: (id) => Effect.succeed(McpToolAccessTestkit.liveThreadShell(id)),
getProjectThreadRecords: ({ threadId: id }) => {
const shell = McpToolAccessTestkit.liveThreadShell(id);
return Effect.succeed(
McpToolAccessTestkit.idleThreadProjection({
...shell,
lineage: {
...shell.lineage,
parentThreadId: id === ThreadId.make("mcp-core-child") ? threadId : null,
},
}),
);
},
dispatch: (command) => {
dispatched.push(command);
return Effect.succeed({ sequence: 1 } as never);
},
}),
),
),
),
);
});

it.effect("keeps unexpected handler defects private through the production registration", () =>
Effect.gen(function* () {
const server = yield* McpServer.McpServer;
Expand Down
Loading
Loading