mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 17:00:59 +00:00
revert: remove unnecessary themeOverride params from theme functions
The optional theme parameter was added as a workaround for tsx dev mode, but that's a dev-only issue. Users running the built package don't need it.
This commit is contained in:
parent
7302fe5063
commit
00fa8b71c8
3 changed files with 13 additions and 30 deletions
|
|
@ -1132,21 +1132,6 @@ import { getPackageDir, getThemeDir } from "./paths.js";
|
|||
|
||||
Never use `__dirname` directly for package assets.
|
||||
|
||||
### Module Resolution with tsx
|
||||
|
||||
When running from source via `npx tsx src/cli.ts`, hooks loaded via jiti may get separate module instances from the main app. This can cause issues with global state (like the theme object).
|
||||
|
||||
**Workaround**: Functions like `getSettingsListTheme()` accept an optional theme parameter. In hooks, pass the theme from `ctx.ui.custom()`:
|
||||
|
||||
```typescript
|
||||
await ctx.ui.custom((tui, theme, done) => {
|
||||
const settingsTheme = getSettingsListTheme(theme);
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
When running the built version (`node dist/cli.js` or installed via npm), this is not an issue.
|
||||
|
||||
### Debug Command
|
||||
|
||||
`/debug` (hidden) writes rendered lines with ANSI codes to `~/.pi/agent/pi-debug.log` for TUI debugging, as well as the last set of messages that were sent to the LLM.
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ export default function toolsHook(pi: HookAPI) {
|
|||
const settingsList = new SettingsList(
|
||||
items,
|
||||
Math.min(items.length + 2, 15),
|
||||
getSettingsListTheme(theme),
|
||||
getSettingsListTheme(),
|
||||
(id, newValue) => {
|
||||
// Update enabled state and apply immediately
|
||||
if (newValue === "enabled") {
|
||||
|
|
|
|||
|
|
@ -946,14 +946,13 @@ export function getMarkdownTheme(): MarkdownTheme {
|
|||
};
|
||||
}
|
||||
|
||||
export function getSelectListTheme(themeOverride?: Theme): SelectListTheme {
|
||||
const t = themeOverride ?? theme;
|
||||
export function getSelectListTheme(): SelectListTheme {
|
||||
return {
|
||||
selectedPrefix: (text: string) => t.fg("accent", text),
|
||||
selectedText: (text: string) => t.fg("accent", text),
|
||||
description: (text: string) => t.fg("muted", text),
|
||||
scrollInfo: (text: string) => t.fg("muted", text),
|
||||
noMatch: (text: string) => t.fg("muted", text),
|
||||
selectedPrefix: (text: string) => theme.fg("accent", text),
|
||||
selectedText: (text: string) => theme.fg("accent", text),
|
||||
description: (text: string) => theme.fg("muted", text),
|
||||
scrollInfo: (text: string) => theme.fg("muted", text),
|
||||
noMatch: (text: string) => theme.fg("muted", text),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -964,13 +963,12 @@ export function getEditorTheme(): EditorTheme {
|
|||
};
|
||||
}
|
||||
|
||||
export function getSettingsListTheme(themeOverride?: Theme): import("@mariozechner/pi-tui").SettingsListTheme {
|
||||
const t = themeOverride ?? theme;
|
||||
export function getSettingsListTheme(): import("@mariozechner/pi-tui").SettingsListTheme {
|
||||
return {
|
||||
label: (text: string, selected: boolean) => (selected ? t.fg("accent", text) : text),
|
||||
value: (text: string, selected: boolean) => (selected ? t.fg("accent", text) : t.fg("muted", text)),
|
||||
description: (text: string) => t.fg("dim", text),
|
||||
cursor: t.fg("accent", "→ "),
|
||||
hint: (text: string) => t.fg("dim", text),
|
||||
label: (text: string, selected: boolean) => (selected ? theme.fg("accent", text) : text),
|
||||
value: (text: string, selected: boolean) => (selected ? theme.fg("accent", text) : theme.fg("muted", text)),
|
||||
description: (text: string) => theme.fg("dim", text),
|
||||
cursor: theme.fg("accent", "→ "),
|
||||
hint: (text: string) => theme.fg("dim", text),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue