[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
50
domain/aiWorkspaceScopeInherit.ts
Normal file
50
domain/aiWorkspaceScopeInherit.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { buildAIScopeKey } from './aiSessionsForScope';
|
||||
|
||||
/**
|
||||
* When terminals merge into a workspace, AI panel scope flips from
|
||||
* `terminal:<id>` to `workspace:<id>`. Prefer the workspace's own active
|
||||
* chat, otherwise inherit from member terminal scopes (focused first) so
|
||||
* the chat the user was using survives the merge.
|
||||
*/
|
||||
export function resolveInheritedAIActiveSessionId(input: {
|
||||
scopeType: 'terminal' | 'workspace';
|
||||
scopeTargetId?: string;
|
||||
activeSessionIdMap: Readonly<Record<string, string | null | undefined>>;
|
||||
memberTerminalIds: readonly string[];
|
||||
preferredTerminalId?: string | null;
|
||||
/**
|
||||
* When provided, inherited ids must appear here (e.g. ranked history).
|
||||
* Direct workspace-map hits are returned even if absent so callers can
|
||||
* decide how to recover stale ids.
|
||||
*/
|
||||
visibleSessionIds?: ReadonlySet<string>;
|
||||
}): string | null {
|
||||
const scopeKey = buildAIScopeKey(input.scopeType, input.scopeTargetId);
|
||||
const direct = input.activeSessionIdMap[scopeKey];
|
||||
if (typeof direct === 'string' && direct.length > 0) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
if (input.scopeType !== 'workspace') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const preferredOrder: string[] = [];
|
||||
if (input.preferredTerminalId) {
|
||||
preferredOrder.push(input.preferredTerminalId);
|
||||
}
|
||||
for (const terminalId of input.memberTerminalIds) {
|
||||
if (terminalId && !preferredOrder.includes(terminalId)) {
|
||||
preferredOrder.push(terminalId);
|
||||
}
|
||||
}
|
||||
|
||||
for (const terminalId of preferredOrder) {
|
||||
const sessionId = input.activeSessionIdMap[buildAIScopeKey('terminal', terminalId)];
|
||||
if (typeof sessionId !== 'string' || sessionId.length === 0) continue;
|
||||
if (input.visibleSessionIds && !input.visibleSessionIds.has(sessionId)) continue;
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user