chore(chat): instrumentation session CustomAgentChatView pour diagnostic #149
Ajoute des points de traçage ciblés sur le cycle de vie de session CustomAgentChatView/LayoutGrid pour isoler la cause du fallback silencieux CLI custom avant tentative de fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -624,19 +624,24 @@ function LeafView({
|
||||
legitChange?.agentId === pinnedAgent.id &&
|
||||
legitChange.profileId === pinnedAgent.profileId,
|
||||
);
|
||||
if (
|
||||
shouldFallbackCustomCliMode({
|
||||
agentsLoaded,
|
||||
profilesLoaded,
|
||||
cellMode,
|
||||
hasPinnedAgent: Boolean(pinnedAgent),
|
||||
hasPinnedProfile: Boolean(pinnedProfile),
|
||||
customCliAvailable,
|
||||
effectiveCustomCliAvailable,
|
||||
hasTrustedCustomCli: Boolean(trustedCustomCli),
|
||||
hasLegitProfileChange: hasLegitDowngrade,
|
||||
})
|
||||
) {
|
||||
const fallbackInput = {
|
||||
agentsLoaded,
|
||||
profilesLoaded,
|
||||
cellMode,
|
||||
hasPinnedAgent: Boolean(pinnedAgent),
|
||||
hasPinnedProfile: Boolean(pinnedProfile),
|
||||
customCliAvailable,
|
||||
effectiveCustomCliAvailable,
|
||||
hasTrustedCustomCli: Boolean(trustedCustomCli),
|
||||
hasLegitProfileChange: hasLegitDowngrade,
|
||||
};
|
||||
const shouldFallback = shouldFallbackCustomCliMode(fallbackInput);
|
||||
console.debug("[ticket149] shouldFallbackCustomCliMode", {
|
||||
timestamp: new Date().toISOString(),
|
||||
input: fallbackInput,
|
||||
result: shouldFallback,
|
||||
});
|
||||
if (shouldFallback) {
|
||||
setTrustedCustomCli(null);
|
||||
setCellMode("tui");
|
||||
}
|
||||
@ -693,6 +698,22 @@ function LeafView({
|
||||
else setCellMode(target);
|
||||
}
|
||||
|
||||
async function setSessionWithInstrumentation(
|
||||
site: "custom" | "plain" | "plain-background-attach" | "mode-switch",
|
||||
nextSession: string | null,
|
||||
): Promise<void> {
|
||||
console.debug("[ticket149] vm.setSession", {
|
||||
timestamp: new Date().toISOString(),
|
||||
nodeId: id,
|
||||
site,
|
||||
previousSession: session,
|
||||
nextSession,
|
||||
cellMode,
|
||||
agentId,
|
||||
});
|
||||
await vm.setSession(id, nextSession);
|
||||
}
|
||||
|
||||
async function stopCurrentSessionForSwitch(): Promise<void> {
|
||||
if (!session) return;
|
||||
if (agentId && agentGateway?.stopLiveAgent) {
|
||||
@ -708,7 +729,7 @@ function LeafView({
|
||||
} else {
|
||||
await terminal?.closeTerminal(session);
|
||||
}
|
||||
await vm.setSession(id, null);
|
||||
await setSessionWithInstrumentation("mode-switch", null);
|
||||
refreshLive();
|
||||
}
|
||||
|
||||
@ -863,7 +884,7 @@ function LeafView({
|
||||
if (background?.sessionId && agentGateway!.attachLiveAgent) {
|
||||
const attached = await agentGateway!.attachLiveAgent(projectId, agentId!, id);
|
||||
const sessionId = attached.sessionId ?? background.sessionId;
|
||||
void vm.setSession(id, sessionId);
|
||||
void setSessionWithInstrumentation("plain-background-attach", sessionId);
|
||||
const result = await agentGateway!.reattach(sessionId, onData);
|
||||
refreshLive();
|
||||
return result.handle;
|
||||
@ -1299,7 +1320,7 @@ function LeafView({
|
||||
nodeId={id}
|
||||
sessionId={session}
|
||||
conversationId={conversationId}
|
||||
onSessionId={(sid) => void vm.setSession(id, sid)}
|
||||
onSessionId={(sid) => void setSessionWithInstrumentation("custom", sid)}
|
||||
onConversationId={(cid) => void vm.setCellConversation(id, cid)}
|
||||
/>
|
||||
) : (
|
||||
@ -1309,7 +1330,7 @@ function LeafView({
|
||||
open={terminalOpener}
|
||||
reattach={reattachOpener}
|
||||
sessionId={session}
|
||||
onSessionId={(sid) => void vm.setSession(id, sid)}
|
||||
onSessionId={(sid) => void setSessionWithInstrumentation("plain", sid)}
|
||||
agentMode={agentId != null}
|
||||
portal={agentId != null ? portal : undefined}
|
||||
refitSignal={refitSignal}
|
||||
|
||||
Reference in New Issue
Block a user