MCPcopy
hub / github.com/codeaashu/claude-code / enterTeammateView

Function enterTeammateView

src/state/teammateViewHelpers.ts:46–81  ·  view source on GitHub ↗
(
  taskId: string,
  setAppState: (updater: (prev: AppState) => AppState) => void,
)

Source from the content-addressed store, hash-verified

44 * If switching from another agent, releases the previous one back to stub.
45 */
46export function enterTeammateView(
47 taskId: string,
48 setAppState: (updater: (prev: AppState) => AppState) => void,
49): void {
50 logEvent('tengu_transcript_view_enter', {})
51 setAppState(prev => {
52 const task = prev.tasks[taskId]
53 const prevId = prev.viewingAgentTaskId
54 const prevTask = prevId !== undefined ? prev.tasks[prevId] : undefined
55 const switching =
56 prevId !== undefined &&
57 prevId !== taskId &&
58 isLocalAgent(prevTask) &&
59 prevTask.retain
60 const needsRetain =
61 isLocalAgent(task) && (!task.retain || task.evictAfter !== undefined)
62 const needsView =
63 prev.viewingAgentTaskId !== taskId ||
64 prev.viewSelectionMode !== 'viewing-agent'
65 if (!needsRetain && !needsView && !switching) return prev
66 let tasks = prev.tasks
67 if (switching || needsRetain) {
68 tasks = { ...prev.tasks }
69 if (switching) tasks[prevId] = release(prevTask)
70 if (needsRetain) {
71 tasks[taskId] = { ...task, retain: true, evictAfter: undefined }
72 }
73 }
74 return {
75 ...prev,
76 viewingAgentTaskId: taskId,
77 viewSelectionMode: 'viewing-agent',
78 tasks,
79 }
80 })
81}
82
83/**
84 * Exit teammate transcript view and return to leader's view.

Callers 6

CoordinatorTaskPanelFunction · 0.85
PromptInputFunction · 0.85
handleKeyDownFunction · 0.85
BackgroundTasksDialogFunction · 0.85
BackgroundTaskStatusFunction · 0.85
handleKeyDownFunction · 0.85

Calls 3

logEventFunction · 0.85
isLocalAgentFunction · 0.85
releaseFunction · 0.70

Tested by

no test coverage detected