Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

feat(coding-agent): autocomplete Agents View file references (#409)

Sebastian Müller3cadc6eb8fb6
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index c0454d6319..7e2d3c7e68 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+- Added `@` file-path autocomplete to new-agent and reply prompts in the Agents View.
+
## [0.3.1] - 2026-07-15
- Added `/fast` for OpenAI Fast mode on supported ChatGPT models ([ENG-4620](https://linear.app/primeintellect/issue/ENG-4620/add-support-for-gpt-fast-mode-maybe-fast)).
diff --git a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
index bf5c9eadaa..fcb970ac05 100644
--- a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
+++ b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
@@ -22,6 +22,7 @@ import type { ModelRegistry } from "../../core/model-registry.js";
import { findExactModelReferenceMatch } from "../../core/model-resolver.js";
import { resolvePrimeInferencePostLoginModelAction } from "../../core/prime-inference-model-selection.js";
import { SessionManager } from "../../core/session-manager.js";
+import { ensureTool } from "../../utils/tools-manager.js";
import { DaemonAgentConnection } from "../agent-connection/daemon-agent-connection.js";
import type { AgentConnectionSavedSessionInfo } from "../agent-connection/types.js";
import { DaemonClient, getDaemonSocketCloseReason } from "../daemon/daemon-client.js";
@@ -451,6 +452,7 @@ class AgentsViewMode implements Component, Focusable {
private pendingKillSubagent: PendingKillSubagent | undefined;
private renameTarget: { activeSessionId: string; identity: string } | undefined;
private readonly inactiveAgentIdentities = new Set<string>();
+ private fdPath: string | undefined;
private statusMessage: string | undefined;
private statusMessageTone: "muted" | "error" | "warning" = "muted";
private statusMessageSticky = false;
@@ -520,6 +522,8 @@ class AgentsViewMode implements Component, Focusable {
this.client = new DaemonClient(this.options.socketPath);
await this.client.connect();
this.subscribeToClientClose(this.client);
+ this.fdPath = await ensureTool("fd");
+ this.editor.setAutocompleteProvider(this.createAutocompleteProvider());
this.ui.addChild(this);
this.ui.setFocus(this);
@@ -1275,17 +1279,13 @@ class AgentsViewMode implements Component, Focusable {
}
private createAutocompleteProvider(): CombinedAutocompleteProvider {
- const commands: SlashCommand[] = AGENTS_VIEW_SLASH_COMMANDS.map((command) => ({
- name: command.name,
- description: command.description,
- ...(command.argumentHint ? { argumentHint: command.argumentHint } : {}),
- }));
- const modelCommand = commands.find((command) => command.name === "model");
- if (modelCommand) {
- modelCommand.getArgumentCompletions = (prefix: string) =>
- getAgentsViewModelArgumentCompletions(prefix, this.options.uiServices.modelRegistry);
- }
- return new CombinedAutocompleteProvider(commands, this.options.uiServices.getInitialCwd(), null);
+ const cwd = resolveAgentsViewAutocompleteCwd(
+ this.options.uiServices.getInitialCwd(),
+ this.replyActiveSessionId ? this.findSummaryByActiveSessionId(this.replyActiveSessionId) : undefined,
+ );
+ return createAgentsViewAutocompleteProvider(cwd, this.fdPath, (prefix) =>
+ getAgentsViewModelArgumentCompletions(prefix, this.options.uiServices.modelRegistry),
+ );
}
private openSelected(): void {
@@ -1471,6 +1471,7 @@ class AgentsViewMode implements Component, Focusable {
// Captured once on entry so the header does not count up while reply mode stays open.
this.replyHeaderTime = activeSessionId ? this.getReplyHeaderTime(activeSessionId) : "";
this.editor.setPlaceholder(activeSessionId ? REPLY_PROMPT_FALLBACK_PLACEHOLDER : DEFAULT_PROMPT_PLACEHOLDER);
+ this.editor.setAutocompleteProvider(this.createAutocompleteProvider());
this.ui.requestRender();
}
@@ -2333,6 +2334,28 @@ function isRunningSessionSummary(summary: SessionSummary): boolean {
return summary.activity === "working";
}
+export function resolveAgentsViewAutocompleteCwd(initialCwd: string, replyTarget?: SessionSummary): string {
+ const replyCwd = replyTarget?.cwd;
+ return replyCwd && existsSync(replyCwd) ? replyCwd : initialCwd;
+}
+
+export function createAgentsViewAutocompleteProvider(
+ cwd: string,
+ fdPath: string | undefined,
+ getModelArgumentCompletions: NonNullable<SlashCommand["getArgumentCompletions"]>,
+): CombinedAutocompleteProvider {
+ const commands: SlashCommand[] = AGENTS_VIEW_SLASH_COMMANDS.map((command) => ({
+ name: command.name,
+ description: command.description,
+ ...(command.argumentHint ? { argumentHint: command.argumentHint } : {}),
+ }));
+ const modelCommand = commands.find((command) => command.name === "model");
+ if (modelCommand) {
+ modelCommand.getArgumentCompletions = getModelArgumentCompletions;
+ }
+ return new CombinedAutocompleteProvider(commands, cwd, fdPath ?? null);
+}
+
export function createAgentsViewSessionName(text: string): string {
const normalized = text.replace(/\s+/g, " ").trim();
return normalized.length > SESSION_NAME_MAX_LENGTH
diff --git a/packages/coding-agent/test/agents-view-state.test.ts b/packages/coding-agent/test/agents-view-state.test.ts
index f333429cbc..c54f91e038 100644
--- a/packages/coding-agent/test/agents-view-state.test.ts
+++ b/packages/coding-agent/test/agents-view-state.test.ts
@@ -1,12 +1,14 @@
-import { mkdtempSync, rmSync } from "node:fs";
+import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
+import type { AutocompleteItem } from "@earendil-works/pi-tui";
import { describe, expect, test, vi } from "vitest";
import type { AgentSessionRuntimeConfig } from "../src/core/agent-session-config.js";
import type { ModelRegistry } from "../src/core/model-registry.js";
import type { SessionInfo } from "../src/core/session-manager.js";
import type { SettingsManager } from "../src/core/settings-manager.js";
import {
+ createAgentsViewAutocompleteProvider,
createAgentsViewListCommand,
createAgentsViewReplyHeadline,
createAgentsViewResumeConfig,
@@ -14,6 +16,7 @@ import {
formatAgentsViewRelativeTime,
formatAgentsViewStatusLine,
resolveAgentsViewActiveSummaryForPath,
+ resolveAgentsViewAutocompleteCwd,
resolveAgentsViewOpenCwd,
resolveAgentsViewResumeSummary,
resolveAgentsViewSessionUiServices,
@@ -514,6 +517,58 @@ describe("agents view state", () => {
expect(createAgentsViewListCommand()).toEqual({ type: "list" });
});
+ test("uses the active-chat file autocomplete for new-agent prompts", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "agents-view-autocomplete-"));
+ const fdPath = join(dir, "fd");
+ writeFileSync(
+ fdPath,
+ `#!/bin/sh
+printf 'src/referenced.ts\n'
+`,
+ );
+ chmodSync(fdPath, 0o755);
+
+ try {
+ const provider = createAgentsViewAutocompleteProvider(dir, fdPath, () => []);
+ const suggestions = await provider.getSuggestions(["review @refer"], 0, 13, {
+ signal: new AbortController().signal,
+ });
+
+ expect(suggestions).toEqual({
+ prefix: "@refer",
+ items: [{ value: "@src/referenced.ts", label: "referenced.ts", description: "src/referenced.ts" }],
+ kind: "file",
+ });
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+ });
+
+ test("uses the reply target cwd for file autocomplete", () => {
+ const missing = mkdtempSync(join(tmpdir(), "agents-view-autocomplete-missing-"));
+ rmSync(missing, { recursive: true, force: true });
+
+ expect(resolveAgentsViewAutocompleteCwd("/launch", makeSummary({ cwd: tmpdir() }))).toBe(tmpdir());
+ expect(resolveAgentsViewAutocompleteCwd("/launch")).toBe("/launch");
+ expect(resolveAgentsViewAutocompleteCwd("/launch", makeSummary({ cwd: missing }))).toBe("/launch");
+ expect(resolveAgentsViewAutocompleteCwd("/launch", makeSummary({ cwd: "" }))).toBe("/launch");
+ });
+
+ test("reads current models for each autocomplete request", async () => {
+ let completions: AutocompleteItem[] | null = null;
+ const provider = createAgentsViewAutocompleteProvider("/tmp", undefined, () => completions);
+
+ expect(
+ await provider.getSuggestions(["/model fresh"], 0, 12, { signal: new AbortController().signal }),
+ ).toBeNull();
+
+ completions = [{ value: "test-provider/fresh-model", label: "fresh-model", description: "test-provider" }];
+ expect(await provider.getSuggestions(["/model fresh"], 0, 12, { signal: new AbortController().signal })).toEqual({
+ prefix: "fresh",
+ items: [{ value: "test-provider/fresh-model", label: "fresh-model", description: "test-provider" }],
+ });
+ });
+
test("creates an inactive summary for a saved session selected from resume", () => {
const savedSession = makeSessionInfo({
path: "/tmp/sessions/saved.jsonl",