chore: show agent url in commands (#60)

Co-authored-by: Shubham Naik <shub@memgpt.ai>
This commit is contained in:
Shubham Naik
2025-11-04 10:54:27 -08:00
committed by GitHub
parent 23a06d7c96
commit d4d03ab22b
4 changed files with 49 additions and 3 deletions

View File

@@ -1406,6 +1406,7 @@ export default function App({
onExit={handleExit}
onInterrupt={handleInterrupt}
interruptRequested={interruptRequested}
agentId={agentId}
/>
{/* Model Selector - conditionally mounted as overlay */}

View File

@@ -1,4 +1,5 @@
import { Box, Text } from "ink";
import Link from "ink-link";
import { commands } from "../commands/registry";
import { colors } from "./colors";
@@ -8,11 +9,23 @@ const commandList = Object.entries(commands).map(([cmd, { desc }]) => ({
desc,
}));
export function CommandPreview({ currentInput }: { currentInput: string }) {
export function CommandPreview({
currentInput,
agentId,
serverUrl,
}: {
currentInput: string;
agentId?: string;
serverUrl?: string;
}) {
if (!currentInput.startsWith("/")) {
return null;
}
// Show agent URL only for cloud users
const showAgentUrl =
agentId && agentId !== "loading" && serverUrl?.includes("api.letta.com");
return (
<Box
flexDirection="column"
@@ -26,6 +39,13 @@ export function CommandPreview({ currentInput }: { currentInput: string }) {
<Text dimColor>{item.desc}</Text>
</Box>
))}
{showAgentUrl && (
<Box marginTop={1} paddingTop={1} borderTop borderColor="gray">
<Link url={`https://app.letta.com/agents/${agentId}`}>
<Text dimColor>View agent:</Text>
</Link>
</Box>
)}
</Box>
);
}

View File

@@ -6,6 +6,8 @@ interface InputAssistProps {
cursorPosition: number;
onFileSelect: (path: string) => void;
onAutocompleteActiveChange: (isActive: boolean) => void;
agentId?: string;
serverUrl?: string;
}
/**
@@ -19,6 +21,8 @@ export function InputAssist({
cursorPosition,
onFileSelect,
onAutocompleteActiveChange,
agentId,
serverUrl,
}: InputAssistProps) {
// Show file autocomplete when @ is present
if (currentInput.includes("@")) {
@@ -34,7 +38,13 @@ export function InputAssist({
// Show command preview when input starts with /
if (currentInput.startsWith("/")) {
return <CommandPreview currentInput={currentInput} />;
return (
<CommandPreview
currentInput={currentInput}
agentId={agentId}
serverUrl={serverUrl}
/>
);
}
// No assistance needed

View File

@@ -1,10 +1,12 @@
// Import useInput from vendored Ink for bracketed paste support
import { Box, Text, useInput } from "ink";
import Link from "ink-link";
import SpinnerLib from "ink-spinner";
import type { ComponentType } from "react";
import { useEffect, useRef, useState } from "react";
import type { PermissionMode } from "../../permissions/mode";
import { permissionMode } from "../../permissions/mode";
import { settingsManager } from "../../settings-manager";
import { useTerminalWidth } from "../hooks/useTerminalWidth";
import { colors } from "./colors";
import { InputAssist } from "./InputAssist";
@@ -29,6 +31,7 @@ export function Input({
onExit,
onInterrupt,
interruptRequested = false,
agentId,
}: {
visible?: boolean;
streaming: boolean;
@@ -41,6 +44,7 @@ export function Input({
onExit?: () => void;
onInterrupt?: () => void;
interruptRequested?: boolean;
agentId?: string;
}) {
const [value, setValue] = useState("");
const [escapePressed, setEscapePressed] = useState(false);
@@ -96,6 +100,13 @@ export function Input({
const columns = useTerminalWidth();
const contentWidth = Math.max(0, columns - 2);
// Get server URL (same logic as client.ts)
const settings = settingsManager.getSettings();
const serverUrl =
process.env.LETTA_BASE_URL ||
settings.env?.LETTA_BASE_URL ||
"https://api.letta.com";
// Handle escape key for interrupt (when streaming) or double-escape-to-clear (when not)
useInput((_input, key) => {
if (key.escape) {
@@ -467,6 +478,8 @@ export function Input({
cursorPosition={currentCursorPosition}
onFileSelect={handleFileSelect}
onAutocompleteActiveChange={setIsAutocompleteActive}
agentId={agentId}
serverUrl={serverUrl}
/>
<Box justifyContent="space-between" marginBottom={1}>
@@ -485,7 +498,9 @@ export function Input({
) : (
<Text dimColor>Press / for commands or @ for files</Text>
)}
<Text dimColor>https://discord.gg/letta</Text>
<Link url="https://discord.gg/letta">
<Text dimColor>Discord</Text>
</Link>
</Box>
</Box>
</Box>