Repository navigation
feat: run task-capable MCP tools as server tasks in the background #2541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5a31fc1
feat: run task-capable MCP tools as server tasks in the background
beardthelion dd8ff53
fix: make MCP server task terminal transitions atomic and reachable b…
beardthelion 0496846
fix: flush task output before the disconnect notification
beardthelion ac2c5b9
fix: bound MCP tool discovery by the tool timeout and caller abort
beardthelion 3e23e56
fix: type the discovery dispatch so the race infers the call result
beardthelion 47aa37d
fix: key MCP task support by connection and retry failed discovery
beardthelion 3f551f0
Merge remote-tracking branch 'origin/main' into feat/mcp-server-tasks
beardthelion 189908f
fix: scope MCP task ids per server and fetch results for server-repor…
beardthelion 3fd5e48
Merge remote-tracking branch 'origin/main' into feat/mcp-server-tasks
beardthelion 24fc935
fix(mcp): keep server tasks tracked when cancel is rejected and tight…
beardthelion c44f0c5
Merge remote-tracking branch 'origin/main' into feat/mcp-server-tasks
beardthelion fe9ad99
fix(mcp): address server-task review feedback
beardthelion e685533
fix(mcp): register subagent server tasks on the root store and cancel…
beardthelion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import * as React from 'react' | ||
| import { useElapsedTime } from '../../hooks/useElapsedTime.js' | ||
| import type { KeyboardEvent } from '../../ink/events/keyboard-event.js' | ||
| import { Box, Text } from '../../ink.js' | ||
| import { useKeybindings } from '../../keybindings/useKeybinding.js' | ||
| import type { McpServerTaskState } from '../../tasks/McpServerTask/McpServerTask.js' | ||
| import type { DeepImmutable } from '../../types/utils.js' | ||
| import { Byline } from '../design-system/Byline.js' | ||
| import { Dialog } from '../design-system/Dialog.js' | ||
| import { KeyboardShortcutHint } from '../design-system/KeyboardShortcutHint.js' | ||
|
|
||
| type Props = { | ||
| task: DeepImmutable<McpServerTaskState> | ||
| onDone: () => void | ||
| onBack?: () => void | ||
| onKill?: () => void | ||
| } | ||
|
|
||
| /** | ||
| * Detail view for an MCP server-initiated task. The remote task is owned by | ||
| * the MCP server; this view shows what it has reported (statusMessage) and | ||
| * offers tasks/cancel through the kill control. | ||
| */ | ||
| export function McpServerTaskDetailDialog({ | ||
| task, | ||
| onDone, | ||
| onBack, | ||
| onKill, | ||
| }: Props): React.ReactNode { | ||
| const elapsedTime = useElapsedTime( | ||
| task.startTime, | ||
| task.status === 'running', | ||
| 1000, | ||
| 0, | ||
| ) | ||
|
|
||
| useKeybindings({ 'confirm:yes': onDone }, { context: 'Confirmation' }) | ||
|
|
||
| function onKeyDown(e: KeyboardEvent) { | ||
| if (e.key === ' ') { | ||
| e.preventDefault() | ||
| onDone() | ||
| } else if (e.key === 'left' && onBack) { | ||
| e.preventDefault() | ||
| onBack() | ||
| } else if (e.key === 'x' && task.status === 'running' && onKill) { | ||
| e.preventDefault() | ||
| onKill() | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Dialog | ||
| title={task.description} | ||
| onCancel={onDone} | ||
| color="background" | ||
| inputGuide={() => ( | ||
| <Byline> | ||
| {onBack && <KeyboardShortcutHint shortcut="←" action="go back" />} | ||
| <KeyboardShortcutHint shortcut="Esc/Enter/Space" action="close" /> | ||
| {task.status === 'running' && onKill && ( | ||
| <KeyboardShortcutHint shortcut="x" action="cancel" /> | ||
| )} | ||
| </Byline> | ||
| )} | ||
| > | ||
| <Box | ||
| flexDirection="column" | ||
| gap={1} | ||
| tabIndex={0} | ||
| autoFocus | ||
| onKeyDown={onKeyDown} | ||
| > | ||
| <Box flexDirection="column"> | ||
| <Text> | ||
| <Text dimColor>server: </Text> | ||
| {task.mcpServerName} | ||
| </Text> | ||
| <Text> | ||
| <Text dimColor>tool: </Text> | ||
| {task.mcpToolName} | ||
| </Text> | ||
| <Text> | ||
| <Text dimColor>status: </Text> | ||
| {task.status} | ||
| {task.statusMessage ? `: ${task.statusMessage}` : ''} | ||
| </Text> | ||
| {task.cancelError && ( | ||
| <Text> | ||
| <Text dimColor>stop: </Text> | ||
| {task.cancelError} | ||
| </Text> | ||
| )} | ||
| <Text> | ||
| <Text dimColor>elapsed: </Text> | ||
| {elapsedTime} | ||
| </Text> | ||
| </Box> | ||
| </Box> | ||
| </Dialog> | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.