@@ -47,8 +47,11 @@ import { parseInput } from "./input.ts";
4747 import {
4848 appendMessage,
4949 computeStats,
50+ createSession,
51+ forkSession,
5052 listSessions,
5153 loadMessages,
54+ undoLastTurn,
5255 } from "./session.ts";
5356 import { truncateOutput } from "./tools.ts";
5457
@@ -116,6 +119,9 @@ interface PendingToolCall {
116119 /** Tool calls collected during the current streaming turn. */
117120 let pendingToolCalls: PendingToolCall[] = [];
118121
122+/** Display-only info messages (not persisted, not sent to LLM). */
123+let infoMessages: Message[] = [];
124+
119125 // ---------------------------------------------------------------------------
120126 // Overlay state
121127 // ---------------------------------------------------------------------------
@@ -547,6 +553,18 @@ function buildConversationLog(state: AppState): Node[] {
547553 nodes.push(...renderStreamingResponse(state));
548554 }
549555
556+ // Append display-only info messages
557+ for (const msg of infoMessages) {
558+ nodes.push(
559+ VStack({ padding: { x: 1 } }, [
560+ Text(typeof msg.content === "string" ? msg.content : "", {
561+ fgColor: "color08",
562+ italic: true,
563+ }),
564+ ]),
565+ );
566+ }
567+
550568 // Empty state
551569 if (nodes.length === 0) {
552570 nodes.push(Spacer());
@@ -717,6 +735,7 @@ function handleSessionCommand(state: AppState): void {
717735 state.session = picked;
718736 state.messages = loadMessages(state.db, picked.id);
719737 state.stats = computeStats(state.messages);
738+ infoMessages = [];
720739 stickToBottom = true;
721740 }
722741 }
@@ -757,17 +776,73 @@ function openInBrowser(url: string): void {
757776 * Used for login progress/status messages that aren't part of the
758777 * agent conversation. Rendered as dimmed italic text.
759778 */
760-function appendInfoMessage(text: string, state: AppState): void {
779+function appendInfoMessage(text: string, _state: AppState): void {
761780 const msg: Message = {
762781 role: "user",
763782 content: `[${text}]`,
764783 timestamp: Date.now(),
765784 };
766- state.messages.push(msg);
785+ infoMessages.push(msg);
786+ stickToBottom = true;
787+ cel.render();
788+}
789+
790+/** Handle the /new command: start a new session. */
791+function handleNewCommand(state: AppState): void {
792+ if (state.running) return;
793+ const modelLabel = state.model
794+ ? `${state.model.provider}/${state.model.id}`
795+ : undefined;
796+ state.session = createSession(state.db, {
797+ cwd: state.cwd,
798+ model: modelLabel,
799+ effort: state.effort,
800+ });
801+ state.messages = [];
802+ state.stats = { totalInput: 0, totalOutput: 0, totalCost: 0 };
803+ infoMessages = [];
767804 stickToBottom = true;
768805 cel.render();
769806 }
770807
808+/** Handle the /fork command: fork the current session. */
809+function handleForkCommand(state: AppState): void {
810+ if (state.running) return;
811+ const forked = forkSession(state.db, state.session.id);
812+ state.session = forked;
813+ state.messages = loadMessages(state.db, forked.id);
814+ state.stats = computeStats(state.messages);
815+ infoMessages = [];
816+ appendInfoMessage(`Forked session.`, state);
817+}
818+
819+/** Handle the /undo command: remove the last turn. */
820+function handleUndoCommand(state: AppState): void {
821+ // Interrupt first if the agent is running
822+ if (state.running && state.abortController) {
823+ state.abortController.abort();
824+ }
825+ const removed = undoLastTurn(state.db, state.session.id);
826+ if (removed) {
827+ state.messages = loadMessages(state.db, state.session.id);
828+ state.stats = computeStats(state.messages);
829+ stickToBottom = true;
830+ cel.render();
831+ }
832+}
833+
834+/** Handle the /reasoning command: toggle thinking display. */
835+function handleReasoningCommand(state: AppState): void {
836+ state.showReasoning = !state.showReasoning;
837+ cel.render();
838+}
839+
840+/** Handle the /verbose command: toggle full output display. */
841+function handleVerboseCommand(state: AppState): void {
842+ state.verbose = !state.verbose;
843+ cel.render();
844+}
845+
771846 /** Handle the /login command: OAuth provider login. */
772847 function handleLoginCommand(state: AppState): void {
773848 const oauthProviders = getOAuthProviders();
@@ -853,6 +928,52 @@ async function performLogin(
853928 appendInfoMessage(`Logged in to ${provider.name}.`, state);
854929 }
855930
931+/** Handle the /logout command: clear OAuth credentials for a provider. */
932+function handleLogoutCommand(state: AppState): void {
933+ const loggedInProviders = getOAuthProviders().filter(
934+ (p) => state.oauthCredentials[p.id] != null,
935+ );
936+ if (loggedInProviders.length === 0) {
937+ return;
938+ }
939+
940+ const items = loggedInProviders.map((p) => ({
941+ label: p.name,
942+ value: p.id,
943+ filterText: p.name,
944+ }));
945+
946+ const select = Select({
947+ items,
948+ maxVisible: OVERLAY_MAX_VISIBLE,
949+ placeholder: "type to filter providers...",
950+ focused: true,
951+ highlightColor: "color06",
952+ onSelect: (providerId) => {
953+ delete state.oauthCredentials[providerId];
954+ saveOAuthCredentials(state.oauthCredentials);
955+ state.providers.delete(providerId);
956+
957+ // Clear model if it belonged to the logged-out provider
958+ if (state.model && state.model.provider === providerId) {
959+ state.model = null;
960+ }
961+
962+ const provider = loggedInProviders.find((p) => p.id === providerId);
963+ dismissOverlay();
964+ appendInfoMessage(
965+ `Logged out of ${provider?.name ?? providerId}.`,
966+ state,
967+ );
968+ },
969+ onBlur: dismissOverlay,
970+ });
971+
972+ inputFocused = false;
973+ activeOverlay = { select, title: "Logout from a provider" };
974+ cel.render();
975+}
976+
856977 /** Dispatch a parsed command. Returns true if handled. */
857978 function handleCommand(command: string, state: AppState): boolean {
858979 switch (command) {
@@ -868,6 +989,24 @@ function handleCommand(command: string, state: AppState): boolean {
868989 case "login":
869990 handleLoginCommand(state);
870991 return true;
992+ case "logout":
993+ handleLogoutCommand(state);
994+ return true;
995+ case "new":
996+ handleNewCommand(state);
997+ return true;
998+ case "fork":
999+ handleForkCommand(state);
1000+ return true;
1001+ case "undo":
1002+ handleUndoCommand(state);
1003+ return true;
1004+ case "reasoning":
1005+ handleReasoningCommand(state);
1006+ return true;
1007+ case "verbose":
1008+ handleVerboseCommand(state);
1009+ return true;
8711010 default:
8721011 return false;
8731012 }