continue-custom/extensions/cli/src/ui/components/SessionSelectorWithLoading.tsx
Nate Sesti b12499cb0e
feat: show remote sessions in cn ls (#7694)
* feat: /title slash command

* fix: /title slash command should be able to be submitted with text

* test: add tests for last commit's changes

* fix: EOF in action.yml

* feat: list remote sessions in cn ls and /resume

* feat: load more sessions and make them scrollable

* chore: format

* improv: debug script builds automatically for cli

* feat: load remote session

* fix: wrap entrypoint in function so it doesn't run at import-time

* feat: /diff and /apply slash commands for cn remote

* feat: full screen diff viewer

* feat: status message for /apply slash command

* Update extensions/cli/src/ui/UserInput.tsx

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* fix: remove console.logs

* Potential fix for code scanning alert no. 60: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for code scanning alert no. 61: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix: build.js

* feat: list remote sessions in history of extensions

* feat: open remote agents in browser

* chore: fix tests and lint

* fix: import Text

* fix: small bug

* fix: address feedback

* fix: adjust extension gui for compatibility with cli session history

* feat: load session history from remote

* feat: open remote session in browser

* fix: tests, linting, formatting

* fix: don't use any

* address nitpicks

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-09-19 22:44:26 -07:00

59 lines
1.5 KiB
TypeScript

import { Box, Text } from "ink";
import React from "react";
import { logger } from "src/util/logger.js";
import { listSessions, type ExtendedSessionMetadata } from "../../session.js";
import { SessionSelector } from "../SessionSelector.js";
interface SessionSelectorWithLoadingProps {
onSelect: (sessionId: string) => Promise<void>;
onExit: () => void;
}
export const SessionSelectorWithLoading: React.FC<
SessionSelectorWithLoadingProps
> = ({ onSelect, onExit }) => {
const [sessions, setSessions] = React.useState<ExtendedSessionMetadata[]>([]);
const [isLoading, setIsLoading] = React.useState(true);
React.useEffect(() => {
let isMounted = true;
const loadSessions = async () => {
try {
if (!isMounted) return;
setIsLoading(true);
const sessionList = await listSessions();
if (!isMounted) return;
setSessions(sessionList);
} catch (error) {
if (!isMounted) return;
logger.error("Error loading sessions:", error);
setSessions([]);
} finally {
if (isMounted) {
setIsLoading(false);
}
}
};
loadSessions();
return () => {
isMounted = false;
};
}, []);
if (isLoading) {
return (
<Box paddingX={1} borderStyle="round" borderColor="blue">
<Text color="blue">Loading sessions...</Text>
</Box>
);
}
return (
<SessionSelector sessions={sessions} onSelect={onSelect} onExit={onExit} />
);
};