mirror of
https://github.com/stablyai/orca.git
synced 2026-10-02 00:02:05 +00:00
Simplify filter-flatMap patterns to single flatMap operations (#23242)
- Replace .filter().flatMap() chains with .flatMap() using conditionals - Use constructor parameter shorthand in PreflightHandler - More concise conditional filtering across agent detection and tab rebasing
This commit is contained in:
@@ -70,7 +70,7 @@ function rebaseUnifiedTabs(
|
||||
(tab) => tab.contentType !== 'terminal' || terminalUnifiedTabMatches(tab, terminalTabIds)
|
||||
)
|
||||
const representedTerminalIds = new Set(
|
||||
result.filter((tab) => tab.contentType === 'terminal').flatMap((tab) => [tab.id, tab.entityId])
|
||||
result.flatMap((tab) => (tab.contentType === 'terminal' ? [tab.id, tab.entityId] : []))
|
||||
)
|
||||
for (const tab of current) {
|
||||
if (
|
||||
|
||||
@@ -39,10 +39,7 @@ const CONSERVATIVE_SYSTEM_SHELL_DIRS = new Set(['/bin', '/usr/bin'])
|
||||
const AGENT_PATH_PREFIX = '__ORCA_AGENT_PATH__'
|
||||
|
||||
export class PreflightHandler {
|
||||
private dispatcher: RelayDispatcher
|
||||
|
||||
constructor(dispatcher: RelayDispatcher) {
|
||||
this.dispatcher = dispatcher
|
||||
constructor(private readonly dispatcher: RelayDispatcher) {
|
||||
this.registerHandlers()
|
||||
}
|
||||
|
||||
@@ -53,9 +50,7 @@ export class PreflightHandler {
|
||||
)
|
||||
}
|
||||
|
||||
// Why: the client sends the command list rather than importing TUI_AGENT_CONFIG
|
||||
// on the relay side. This keeps the relay bundle minimal and makes the protocol
|
||||
// self-describing — the relay doesn't need to know the agent catalog.
|
||||
// Why: client-supplied commands keep the relay independent of the agent catalog.
|
||||
private async detectAgents(params: Record<string, unknown>): Promise<{
|
||||
agents: string[]
|
||||
versions?: Record<string, string>
|
||||
@@ -66,9 +61,11 @@ export class PreflightHandler {
|
||||
}
|
||||
const probeCommands = [
|
||||
...new Set(
|
||||
commands
|
||||
.filter((command) => !isDetectionUnsupportedInRuntime(command, process.platform))
|
||||
.flatMap((command) => [command.cmd, ...(command.requiredCommands ?? [])])
|
||||
commands.flatMap((command) =>
|
||||
isDetectionUnsupportedInRuntime(command, process.platform)
|
||||
? []
|
||||
: [command.cmd, ...(command.requiredCommands ?? [])]
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -48,9 +48,11 @@ export function getTuiAgentDetectionProbeCommands(
|
||||
): string[] {
|
||||
return [
|
||||
...new Set(
|
||||
commands
|
||||
.filter((command) => !isDetectionUnsupportedInRuntime(command, runtime))
|
||||
.flatMap((command) => [command.cmd, ...(command.requiredCommands ?? [])])
|
||||
commands.flatMap((command) =>
|
||||
isDetectionUnsupportedInRuntime(command, runtime)
|
||||
? []
|
||||
: [command.cmd, ...(command.requiredCommands ?? [])]
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user