feat(tasks): add terminal output to the add context menu by kr1shna-exe · Pull Request #3301 · generalaction/emdash · GitHub
Skip to content

feat(tasks): add terminal output to the add context menu - #3301

Open
kr1shna-exe wants to merge 2 commits into
generalaction:mainfrom
kr1shna-exe:feat/2769-terminal-output-context
Open

kr1shna-exe wants to merge 2 commits into
generalaction:mainfrom
kr1shna-exe:feat/2769-terminal-output-context

Conversation

@kr1shna-exe

Copy link
Copy Markdown
Contributor

Description

Task terminals now show up in the Add context popover (Cmd+Shift+A in a conversation). Picking one pastes that terminal's output into the active agent session, the same way linked issues and line comments already get pasted in:

  • If the terminal has a selection, only the selection is sent.
  • Otherwise the last 200 lines are sent, with soft-wrapped rows joined back into their original lines and the empty rows below the cursor dropped.
  • The text is wrapped in a fenced block labelled with the terminal name. The fence gets longer when the output itself contains backticks.

The output is read when you pick the entry, not when the list is built. Terminals whose tab was never opened get connected first, and the app waits for the replayed scrollback to finish before reading, so you get current output either way.

Implementation notes:

  • terminals/api/browser/pty/terminal-output.ts reads the xterm buffer.
  • context-actions.ts gains a terminal-output action.
  • AddContextPopover.onApplyAction now receives just the action. ContextBar resolves the text itself, since terminal text has to be read asynchronously.

One visible side effect: the context bar now appears in any task that has a terminal, even when there's no linked issue, comment or prompt. It can still be hidden from its right-click menu.

Related issues

Closes #2769

Testing

  • pnpm run format:check, pnpm run lint and pnpm run typecheck in apps/emdash-desktop pass.
  • vitest run --project node: 3927 passed. The one failure is files-domain.integration.test.ts "classifies a path outside any checkout as an unavailable content state", which fails the same way on main.
  • New tests: terminal-output.test.ts runs a real xterm Terminal and covers wrapped lines, the line cap, spaces on a wrap boundary, selection taking priority and an empty buffer. context-actions.test.ts covers ordering, fencing and reading at apply time.
  • Ran the dev app with a task whose agent CLI was pointed at a script that echoes its input. I created two terminals and ran commands in them without opening their tabs. Both showed up in the popover. Picking Terminal 1 pasted its output. Searching "terminal 2" and picking it pasted rows 102 to 300 plus the prompt (the last 200 lines). With one line selected in Terminal 1, only that line was pasted.

Screenshot/Recording (if applicable)

Popover with both terminals listed: 07-popover.png
Selected line pasted into the agent: 11-after-selection.png

Checklist
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for commit
    messages and, when possible, the PR title

Task terminals now show up in the Add context popover. Picking one pastes
the terminal's current selection, or its last 200 lines when nothing is
selected, into the active agent session as a fenced block.

Refs: generalaction#2769
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Comment thread apps/emdash-desktop/src/core/features/tasks/contributions/browser/context-bar.tsx Outdated
Find the longest backtick run with a loop instead of spreading every match
into Math.max, which overflowed the call stack on large output. Show a
toast when reading a terminal fails instead of dropping the error.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat]: access Terminal output as context

1 participant