|
|
@@ -91,6 +91,10 @@ export function getSidebarAgentNames(snapshot: TuiSnapshot): string[] {
|
|
|
: FALLBACK_SIDEBAR_AGENTS;
|
|
|
}
|
|
|
|
|
|
+function truncate(str: string, maxLen: number): string {
|
|
|
+ return str.length > maxLen ? `${str.slice(0, maxLen - 1)}…` : str;
|
|
|
+}
|
|
|
+
|
|
|
function agentRow(
|
|
|
label: string,
|
|
|
model: string,
|
|
|
@@ -114,6 +118,27 @@ function agentRow(
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+function compactAgentRow(
|
|
|
+ label: string,
|
|
|
+ model: string,
|
|
|
+ variant: string | undefined,
|
|
|
+ theme: { textMuted: unknown },
|
|
|
+): JSX.Element {
|
|
|
+ const value = variant ? `${model} ${variant}` : model;
|
|
|
+ return box(
|
|
|
+ {
|
|
|
+ width: '100%',
|
|
|
+ flexDirection: 'row',
|
|
|
+ justifyContent: 'space-between',
|
|
|
+ marginBottom: 0,
|
|
|
+ },
|
|
|
+ [
|
|
|
+ text({ fg: theme.textMuted }, [label]),
|
|
|
+ text({ fg: theme.textMuted }, [truncate(value, 40)]),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
function agentDetailRow(
|
|
|
label: string,
|
|
|
value: string,
|
|
|
@@ -136,6 +161,7 @@ function renderSidebar(
|
|
|
textMuted: unknown;
|
|
|
},
|
|
|
configInvalid: boolean,
|
|
|
+ compactSidebar: boolean,
|
|
|
): JSX.Element {
|
|
|
const configStatusRow = buildConfigStatusRow(configInvalid, theme);
|
|
|
|
|
|
@@ -173,6 +199,9 @@ function renderSidebar(
|
|
|
...getSidebarAgentNames(snapshot).map((agentName) => {
|
|
|
const model = snapshot.agentModels[agentName] ?? 'pending';
|
|
|
const variant = snapshot.agentVariants[agentName];
|
|
|
+ if (compactSidebar) {
|
|
|
+ return compactAgentRow(agentName, model, variant, theme);
|
|
|
+ }
|
|
|
return agentRow(agentName, model, variant, theme);
|
|
|
}),
|
|
|
],
|
|
|
@@ -199,15 +228,22 @@ function buildConfigStatusRow(
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export function readConfigInvalid(directory: string): boolean {
|
|
|
+function readConfigState(directory: string): {
|
|
|
+ configInvalid: boolean;
|
|
|
+ compactSidebar: boolean;
|
|
|
+} {
|
|
|
let configInvalid = false;
|
|
|
- loadPluginConfig(directory, {
|
|
|
+ const config = loadPluginConfig(directory, {
|
|
|
silent: true,
|
|
|
onWarning: () => {
|
|
|
configInvalid = true;
|
|
|
},
|
|
|
});
|
|
|
- return configInvalid;
|
|
|
+ return { configInvalid, compactSidebar: config.compactSidebar ?? false };
|
|
|
+}
|
|
|
+
|
|
|
+export function readConfigInvalid(directory: string): boolean {
|
|
|
+ return readConfigState(directory).configInvalid;
|
|
|
}
|
|
|
|
|
|
const plugin: TuiPluginModule & { id: string } = {
|
|
|
@@ -217,7 +253,7 @@ const plugin: TuiPluginModule & { id: string } = {
|
|
|
|
|
|
const version = meta.version ?? (await readPackageVersion()) ?? 'dev';
|
|
|
let configDirectory = getTuiDirectory(api);
|
|
|
- let configInvalid = readConfigInvalid(configDirectory);
|
|
|
+ let { configInvalid, compactSidebar } = readConfigState(configDirectory);
|
|
|
let snapshot = readTuiSnapshot();
|
|
|
const renderTimer = setInterval(async () => {
|
|
|
try {
|
|
|
@@ -225,7 +261,8 @@ const plugin: TuiPluginModule & { id: string } = {
|
|
|
const currentDirectory = getTuiDirectory(api);
|
|
|
if (currentDirectory !== configDirectory) {
|
|
|
configDirectory = currentDirectory;
|
|
|
- configInvalid = readConfigInvalid(configDirectory);
|
|
|
+ ({ configInvalid, compactSidebar } =
|
|
|
+ readConfigState(configDirectory));
|
|
|
}
|
|
|
api.renderer.requestRender();
|
|
|
} catch {
|
|
|
@@ -246,6 +283,7 @@ const plugin: TuiPluginModule & { id: string } = {
|
|
|
version,
|
|
|
api.theme.current,
|
|
|
configInvalid,
|
|
|
+ compactSidebar,
|
|
|
);
|
|
|
},
|
|
|
},
|