Skip to content

Commit 449f6d4

Browse files
committed
refactor: fix merge conflict and code styles
1 parent 5be276a commit 449f6d4

File tree

20 files changed

+36
-50
lines changed

20 files changed

+36
-50
lines changed

cli/src/commands/core/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import type { RouterModels } from "../../types/messages.js"
6-
import type { ProviderConfig } from "../../config/types.js"
6+
import type { CLIConfig, ProviderConfig } from "../../config/types.js"
77
import type { ProfileData, BalanceData } from "../../state/atoms/profile.js"
88
import type { TaskHistoryData, TaskHistoryFilters } from "../../state/atoms/taskHistory.js"
99

@@ -33,6 +33,7 @@ export interface CommandContext {
3333
input: string
3434
args: string[]
3535
options: Record<string, any>
36+
config: CLIConfig
3637
sendMessage: (message: any) => Promise<void>
3738
addMessage: (message: any) => void
3839
clearMessages: () => void
@@ -122,6 +123,7 @@ export interface ArgumentProviderContext {
122123

123124
// CommandContext properties for providers that need them
124125
commandContext?: {
126+
config: CLIConfig
125127
routerModels: RouterModels | null
126128
currentProvider: ProviderConfig | null
127129
kilocodeDefaultModel: string

cli/src/commands/theme.ts

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@ import type { Command, ArgumentProviderContext } from "./core/types.js"
66
import type { CLIConfig } from "../config/types.js"
77
import { getThemeById, getAvailableThemes } from "../constants/themes/index.js"
88
import { messageResetCounterAtom } from "../state/atoms/ui.js"
9-
import { createStore } from "jotai"
10-
11-
/**
12-
* Get config from disk
13-
*/
14-
async function getConfig(): Promise<{ config: CLIConfig }> {
15-
const { loadConfig } = await import("../config/persistence.js")
16-
const { config } = await loadConfig()
17-
return { config }
18-
}
199

2010
/**
2111
* Autocomplete provider for theme names
2212
*/
23-
async function themeAutocompleteProvider(_context: ArgumentProviderContext) {
24-
const { config } = await getConfig()
13+
async function themeAutocompleteProvider(context: ArgumentProviderContext) {
14+
if (!context.commandContext) {
15+
return []
16+
}
17+
const config = context.commandContext.config
2518
const availableThemeIds = getAvailableThemes(config)
2619

2720
// Create theme display info array to apply same sorting logic
@@ -36,8 +29,8 @@ async function themeAutocompleteProvider(_context: ArgumentProviderContext) {
3629
}
3730
})
3831
.sort((a, b) => {
39-
// Sort by type (Dark first, then Light, then Custom), then by ID alphabetically
40-
const typeOrder = { Dark: 0, Light: 1, Custom: 2 }
32+
// Sort by type (dark first, then light, then custom), then by ID alphabetically
33+
const typeOrder = { dark: 0, light: 1, custom: 2 }
4134
const typeAOrder = typeOrder[a.type as keyof typeof typeOrder] ?? 3
4235
const typeBOrder = typeOrder[b.type as keyof typeof typeOrder] ?? 3
4336

@@ -102,7 +95,7 @@ export const themeCommand: Command = {
10295
* Validate theme argument against available themes
10396
*/
10497
validate: async (value, _context) => {
105-
const { config } = await getConfig()
98+
const config = _context.commandContext?.config
10699
const availableThemeIds = getAvailableThemes(config)
107100
const isValid = availableThemeIds.includes(value.trim().toLowerCase())
108101

@@ -114,8 +107,7 @@ export const themeCommand: Command = {
114107
},
115108
],
116109
handler: async (context) => {
117-
const { args, addMessage, setTheme } = context
118-
const { config } = await getConfig()
110+
const { args, addMessage, setTheme, config } = context
119111
const availableThemeIds = getAvailableThemes(config)
120112

121113
try {
@@ -142,7 +134,7 @@ export const themeCommand: Command = {
142134
)
143135

144136
// Define the order for displaying theme types
145-
const typeOrder = ["Dark", "Light", "Custom"]
137+
const typeOrder = ["dark", "light", "custom"]
146138

147139
// Show interactive theme selection menu
148140
const helpText: string[] = ["**Available Themes:**", ""]
@@ -187,25 +179,13 @@ export const themeCommand: Command = {
187179
const themeName = theme.name || requestedTheme
188180

189181
try {
190-
await setTheme(requestedTheme)
191-
192-
// Repaint the terminal to immediately show theme changes
193-
// Clear the terminal screen and reset cursor position
194-
// \x1b[2J - Clear entire screen
195-
// \x1b[3J - Clear scrollback buffer (needed for gnome-terminal)
196-
// \x1b[H - Move cursor to home position (0,0)
197-
process.stdout.write("\x1b[2J\x1b[3J\x1b[H")
198-
199-
// Increment reset counter to force UI re-render
200-
const store = createStore()
201-
store.set(messageResetCounterAtom, (prev: number) => prev + 1)
202-
203182
addMessage({
204183
id: Date.now().toString(),
205184
type: "system",
206185
content: `Switched to **${themeName}** theme.`,
207186
ts: Date.now(),
208187
})
188+
setTheme(requestedTheme)
209189
} catch (error) {
210190
addMessage({
211191
id: Date.now().toString(),

cli/src/constants/themes/alpha.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Theme } from "../../types/theme.js"
1313
export const alphaTheme: Theme = {
1414
id: "alpha",
1515
name: "Alpha",
16-
type: "Dark",
16+
type: "dark",
1717

1818
brand: {
1919
primary: "#faf74f", // Kilo Code yellow

cli/src/constants/themes/ansi-light.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const ansiLightTheme: Theme = {
1010
id: "ansi-light",
1111
name: "ANSI Light",
12-
type: "Light",
12+
type: "light",
1313

1414
brand: {
1515
primary: "blue", // Use first gradient color for banner

cli/src/constants/themes/ansi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const ansiTheme: Theme = {
1010
id: "ansi",
1111
name: "ANSI",
12-
type: "Dark",
12+
type: "dark",
1313

1414
brand: {
1515
primary: "cyan", // Use first gradient color for banner

cli/src/constants/themes/atom-one-dark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const atomOneDarkTheme: Theme = {
1010
id: "atom-one-dark",
1111
name: "Atom One Dark",
12-
type: "Dark",
12+
type: "dark",
1313

1414
brand: {
1515
primary: "#61aeee", // Use first gradient color for banner

cli/src/constants/themes/ayu-dark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const ayuDarkTheme: Theme = {
1010
id: "ayu-dark",
1111
name: "Ayu Dark",
12-
type: "Dark",
12+
type: "dark",
1313

1414
brand: {
1515
primary: "#FFB454", // Use first gradient color for banner

cli/src/constants/themes/ayu-light.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const ayuLightTheme: Theme = {
1010
id: "ayu-light",
1111
name: "Ayu Light",
12-
type: "Light",
12+
type: "light",
1313

1414
brand: {
1515
primary: "#399ee6", // Use first gradient color for banner

cli/src/constants/themes/custom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function addCustomTheme(config: CLIConfig, themeId: string, theme: Theme)
100100
[themeId]: {
101101
...theme,
102102
id: themeId, // Ensure the ID matches the key
103-
type: "Custom", // Always set custom themes to "Custom" type
103+
type: "custom", // Always set custom themes to "custom" type
104104
},
105105
},
106106
}
@@ -138,7 +138,7 @@ export function updateCustomTheme(config: CLIConfig, themeId: string, theme: Par
138138
...config.customThemes[themeId],
139139
...theme,
140140
id: themeId, // Ensure the ID is preserved
141-
type: "Custom", // Always ensure custom themes have "Custom" type
141+
type: "custom", // Always ensure custom themes have "custom" type
142142
},
143143
},
144144
}

cli/src/constants/themes/dark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Theme } from "../../types/theme.js"
99
export const darkTheme: Theme = {
1010
id: "dark",
1111
name: "Dark",
12-
type: "Dark",
12+
type: "dark",
1313

1414
brand: {
1515
primary: "#faf74f",

0 commit comments

Comments
 (0)