chore: remove redundant commands /agent, /stream, /swap (#202)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
199
src/cli/App.tsx
199
src/cli/App.tsx
@@ -220,7 +220,6 @@ export default function App({
|
||||
startupApproval = null,
|
||||
startupApprovals = [],
|
||||
messageHistory = [],
|
||||
tokenStreaming = true,
|
||||
agentProvenance = null,
|
||||
}: {
|
||||
agentId: string;
|
||||
@@ -237,7 +236,6 @@ export default function App({
|
||||
startupApproval?: ApprovalRequest | null; // Deprecated: use startupApprovals
|
||||
startupApprovals?: ApprovalRequest[];
|
||||
messageHistory?: Message[];
|
||||
tokenStreaming?: boolean;
|
||||
agentProvenance?: AgentProvenance | null;
|
||||
}) {
|
||||
// Track current agent (can change when swapping)
|
||||
@@ -333,10 +331,6 @@ export default function App({
|
||||
const [resumeSelectorOpen, setResumeSelectorOpen] = useState(false);
|
||||
const [messageSearchOpen, setMessageSearchOpen] = useState(false);
|
||||
|
||||
// Token streaming preference (can be toggled at runtime)
|
||||
const [tokenStreamingEnabled, setTokenStreamingEnabled] =
|
||||
useState(tokenStreaming);
|
||||
|
||||
// Live, approximate token counter (resets each turn)
|
||||
const [tokenCount, setTokenCount] = useState(0);
|
||||
|
||||
@@ -1290,23 +1284,6 @@ export default function App({
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /agent command - show agent link
|
||||
if (trimmed === "/agent") {
|
||||
const cmdId = uid("cmd");
|
||||
const agentUrl = `https://app.letta.com/projects/default-project/agents/${agentId}`;
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: agentUrl,
|
||||
phase: "finished",
|
||||
success: true,
|
||||
});
|
||||
buffersRef.current.order.push(cmdId);
|
||||
refreshDerived();
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /exit command - show stats and exit
|
||||
if (trimmed === "/exit") {
|
||||
handleExit();
|
||||
@@ -1380,61 +1357,6 @@ export default function App({
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /stream command - toggle and save
|
||||
if (msg.trim() === "/stream") {
|
||||
const newValue = !tokenStreamingEnabled;
|
||||
|
||||
// Immediately add command to transcript with "running" phase and loading message
|
||||
const cmdId = uid("cmd");
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: `${newValue ? "Enabling" : "Disabling"} token streaming...`,
|
||||
phase: "running",
|
||||
});
|
||||
buffersRef.current.order.push(cmdId);
|
||||
refreshDerived();
|
||||
|
||||
// Lock input during async operation
|
||||
setCommandRunning(true);
|
||||
|
||||
try {
|
||||
setTokenStreamingEnabled(newValue);
|
||||
|
||||
// Save to settings
|
||||
const { settingsManager } = await import("../settings-manager");
|
||||
settingsManager.updateSettings({ tokenStreaming: newValue });
|
||||
|
||||
// Update the same command with final result
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: `Token streaming ${newValue ? "enabled" : "disabled"}`,
|
||||
phase: "finished",
|
||||
success: true,
|
||||
});
|
||||
refreshDerived();
|
||||
} catch (error) {
|
||||
// Mark command as failed
|
||||
const errorDetails = formatErrorDetails(error, agentId);
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: `Failed: ${errorDetails}`,
|
||||
phase: "finished",
|
||||
success: false,
|
||||
});
|
||||
refreshDerived();
|
||||
} finally {
|
||||
// Unlock input
|
||||
setCommandRunning(false);
|
||||
}
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /clear command - reset conversation
|
||||
if (msg.trim() === "/clear") {
|
||||
const cmdId = uid("cmd");
|
||||
@@ -1720,109 +1642,6 @@ export default function App({
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /swap command - alias for /resume
|
||||
if (msg.trim().startsWith("/swap")) {
|
||||
const parts = msg.trim().split(/\s+/);
|
||||
const targetAgentId = parts.slice(1).join(" ");
|
||||
|
||||
// If no agent ID provided, open resume selector (same as /resume)
|
||||
if (!targetAgentId) {
|
||||
setResumeSelectorOpen(true);
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Validate and swap to specified agent ID
|
||||
const cmdId = uid("cmd");
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: `Switching to agent ${targetAgentId}...`,
|
||||
phase: "running",
|
||||
});
|
||||
buffersRef.current.order.push(cmdId);
|
||||
refreshDerived();
|
||||
|
||||
setCommandRunning(true);
|
||||
|
||||
try {
|
||||
const client = await getClient();
|
||||
// Fetch new agent
|
||||
const agent = await client.agents.retrieve(targetAgentId);
|
||||
|
||||
// Fetch agent's message history
|
||||
const messagesPage =
|
||||
await client.agents.messages.list(targetAgentId);
|
||||
const messages = messagesPage.items;
|
||||
|
||||
// Update project settings with new agent
|
||||
await updateProjectSettings({ lastAgent: targetAgentId });
|
||||
|
||||
// Clear current transcript
|
||||
buffersRef.current.byId.clear();
|
||||
buffersRef.current.order = [];
|
||||
buffersRef.current.tokenCount = 0;
|
||||
emittedIdsRef.current.clear();
|
||||
setStaticItems([]);
|
||||
|
||||
// Update agent state
|
||||
setAgentId(targetAgentId);
|
||||
setAgentState(agent);
|
||||
setAgentName(agent.name);
|
||||
setLlmConfig(agent.llm_config);
|
||||
|
||||
// Add welcome screen for new agent
|
||||
welcomeCommittedRef.current = false;
|
||||
setStaticItems([
|
||||
{
|
||||
kind: "welcome",
|
||||
id: `welcome-${Date.now().toString(36)}`,
|
||||
snapshot: {
|
||||
continueSession: true,
|
||||
agentState: agent,
|
||||
terminalWidth: columns,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
// Backfill message history
|
||||
if (messages.length > 0) {
|
||||
hasBackfilledRef.current = false;
|
||||
backfillBuffers(buffersRef.current, messages);
|
||||
refreshDerived();
|
||||
commitEligibleLines(buffersRef.current);
|
||||
hasBackfilledRef.current = true;
|
||||
}
|
||||
|
||||
// Add success command to transcript
|
||||
const successCmdId = uid("cmd");
|
||||
buffersRef.current.byId.set(successCmdId, {
|
||||
kind: "command",
|
||||
id: successCmdId,
|
||||
input: msg,
|
||||
output: `✓ Switched to agent "${agent.name || targetAgentId}"`,
|
||||
phase: "finished",
|
||||
success: true,
|
||||
});
|
||||
buffersRef.current.order.push(successCmdId);
|
||||
refreshDerived();
|
||||
} catch (error) {
|
||||
const errorDetails = formatErrorDetails(error, agentId);
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: `Failed: ${errorDetails}`,
|
||||
phase: "finished",
|
||||
success: false,
|
||||
});
|
||||
refreshDerived();
|
||||
} finally {
|
||||
setCommandRunning(false);
|
||||
}
|
||||
return { submitted: true };
|
||||
}
|
||||
|
||||
// Special handling for /bashes command - show background shell processes
|
||||
if (msg.trim() === "/bashes") {
|
||||
const { backgroundProcesses } = await import(
|
||||
@@ -1991,7 +1810,7 @@ export default function App({
|
||||
const userText = rest.join(" ").trim();
|
||||
|
||||
const initialOutput = userText
|
||||
? `Remembering: ${userText}`
|
||||
? "Storing to memory..."
|
||||
: "Processing memory request...";
|
||||
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
@@ -2023,7 +1842,7 @@ export default function App({
|
||||
id: cmdId,
|
||||
input: msg,
|
||||
output: userText
|
||||
? `Remembering: ${userText}`
|
||||
? "Storing to memory..."
|
||||
: "Processing memory request from conversation context...",
|
||||
phase: "finished",
|
||||
success: true,
|
||||
@@ -2364,12 +2183,9 @@ ${recentCommits}
|
||||
streaming,
|
||||
commandRunning,
|
||||
processConversation,
|
||||
tokenStreamingEnabled,
|
||||
refreshDerived,
|
||||
agentId,
|
||||
handleExit,
|
||||
columns,
|
||||
commitEligibleLines,
|
||||
isExecutingTool,
|
||||
queuedApprovalResults,
|
||||
pendingApprovals,
|
||||
@@ -3006,7 +2822,7 @@ ${recentCommits}
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: `/swap ${targetAgentId}`,
|
||||
input: `/resume ${targetAgentId}`,
|
||||
output: `Switching to agent ${targetAgentId}...`,
|
||||
phase: "running",
|
||||
});
|
||||
@@ -3068,7 +2884,7 @@ ${recentCommits}
|
||||
buffersRef.current.byId.set(successCmdId, {
|
||||
kind: "command",
|
||||
id: successCmdId,
|
||||
input: `/swap ${targetAgentId}`,
|
||||
input: `/resume ${targetAgentId}`,
|
||||
output: `✓ Switched to agent "${agent.name || targetAgentId}"`,
|
||||
phase: "finished",
|
||||
success: true,
|
||||
@@ -3080,7 +2896,7 @@ ${recentCommits}
|
||||
buffersRef.current.byId.set(cmdId, {
|
||||
kind: "command",
|
||||
id: cmdId,
|
||||
input: `/swap ${targetAgentId}`,
|
||||
input: `/resume ${targetAgentId}`,
|
||||
output: `Failed: ${errorDetails}`,
|
||||
phase: "finished",
|
||||
success: false,
|
||||
@@ -3341,13 +3157,12 @@ Plan file path: ${planFilePath}`;
|
||||
return ln.phase === "running";
|
||||
}
|
||||
if (ln.kind === "tool_call") {
|
||||
// Always show tool calls in progress, regardless of tokenStreaming setting
|
||||
// Always show tool calls in progress
|
||||
return ln.phase !== "finished";
|
||||
}
|
||||
if (!tokenStreamingEnabled && ln.phase === "streaming") return false;
|
||||
return ln.phase === "streaming";
|
||||
});
|
||||
}, [lines, tokenStreamingEnabled]);
|
||||
}, [lines]);
|
||||
|
||||
// Commit welcome snapshot once when ready for fresh sessions (no history)
|
||||
// Wait for agentProvenance to be available for new agents (continueSession=false)
|
||||
|
||||
@@ -10,26 +10,12 @@ interface Command {
|
||||
}
|
||||
|
||||
export const commands: Record<string, Command> = {
|
||||
"/agent": {
|
||||
desc: "Show agent link",
|
||||
handler: () => {
|
||||
// Handled specially in App.tsx to access agent ID
|
||||
return "Getting agent link...";
|
||||
},
|
||||
},
|
||||
"/model": {
|
||||
desc: "Switch model",
|
||||
handler: () => {
|
||||
return "Opening model selector...";
|
||||
},
|
||||
},
|
||||
"/stream": {
|
||||
desc: "Toggle token streaming on/off",
|
||||
handler: () => {
|
||||
// Handled specially in App.tsx for live toggling
|
||||
return "Toggling token streaming...";
|
||||
},
|
||||
},
|
||||
"/exit": {
|
||||
desc: "Exit and show session stats",
|
||||
handler: () => {
|
||||
@@ -79,14 +65,6 @@ export const commands: Record<string, Command> = {
|
||||
return "Updating description...";
|
||||
},
|
||||
},
|
||||
"/swap": {
|
||||
desc: "Alias for /resume",
|
||||
hidden: true, // Hidden - use /resume instead
|
||||
handler: () => {
|
||||
// Handled specially in App.tsx - redirects to /resume
|
||||
return "Opening session selector...";
|
||||
},
|
||||
},
|
||||
"/toolset": {
|
||||
desc: "Switch toolset (codex/default)",
|
||||
handler: () => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { commands } from "../commands/registry";
|
||||
import { colors } from "./colors";
|
||||
|
||||
// Compute command list once at module level since it never changes
|
||||
// Filter out hidden commands (like /swap which is an alias for /resume)
|
||||
// Filter out hidden commands
|
||||
const commandList = Object.entries(commands)
|
||||
.filter(([, { hidden }]) => !hidden)
|
||||
.map(([cmd, { desc }]) => ({
|
||||
|
||||
@@ -741,7 +741,6 @@ async function main() {
|
||||
startupApproval: resumeData?.pendingApproval ?? null,
|
||||
startupApprovals: resumeData?.pendingApprovals ?? [],
|
||||
messageHistory: resumeData?.messageHistory ?? [],
|
||||
tokenStreaming: settings.tokenStreaming,
|
||||
agentProvenance,
|
||||
});
|
||||
}
|
||||
@@ -754,7 +753,6 @@ async function main() {
|
||||
startupApproval: resumeData?.pendingApproval ?? null,
|
||||
startupApprovals: resumeData?.pendingApprovals ?? [],
|
||||
messageHistory: resumeData?.messageHistory ?? [],
|
||||
tokenStreaming: settings.tokenStreaming,
|
||||
agentProvenance,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user