Skip to content

Commit fa23fc6

Browse files
committed
fixed chdir and path for windows build
1 parent 571e2a7 commit fa23fc6

3 files changed

Lines changed: 77 additions & 18 deletions

File tree

internal/filemanager/filemanager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ func NewFileManager(workspaceDir string) *FileManager {
2020
}
2121
}
2222

23+
// SetWorkspaceDir updates the workspace directory.
24+
// This should be called when the IDE changes workspace (e.g., after a clone operation).
25+
func (fm *FileManager) SetWorkspaceDir(dir string) {
26+
if dir != "" {
27+
fm.workspaceDir = dir
28+
}
29+
}
30+
2331
// CreateFile creates a new file with optional initial content
2432
func (fm *FileManager) CreateFile(filePath string, content string) error {
2533
fullPath := fm.resolvePath(filePath)

internal/ui/aichat.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ func (a *AIChatPane) SetWorkingDir(dir string) {
225225
}
226226
}
227227

228+
// SetWorkspaceRoot updates the workspace root directory.
229+
// This should be called when the IDE changes workspace (e.g., after a clone operation).
230+
func (a *AIChatPane) SetWorkspaceRoot(root string) {
231+
if root != "" {
232+
a.workspaceRoot = root
233+
a.workingDir = root
234+
}
235+
}
236+
228237
// GetSelectedBlockDir returns the effective working directory for the currently
229238
// selected code block. If no directory mapping exists, returns workspaceRoot.
230239
func (a *AIChatPane) GetSelectedBlockDir() string {

internal/ui/app.go

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,29 @@ func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
458458
if msg.Operation == "clone" && msg.Success && msg.NewDir != "" {
459459
// Change working directory to the newly cloned repository
460460
a.config.WorkspaceDir = msg.NewDir
461-
462-
// Update GitPane working directory
463-
cmd := a.gitPane.SetWorkDir(msg.NewDir)
464-
cmds = append(cmds, cmd)
465-
466-
// Notify user of directory change
467-
a.statusMessage = "Cloned successfully. Changed directory to: " + msg.NewDir
468-
469-
// Close the Git UI after successful clone
470-
a.gitPane.Toggle()
461+
462+
// Actually change the process working directory
463+
if err := os.Chdir(msg.NewDir); err != nil {
464+
a.statusMessage = "Cloned successfully but failed to change directory: " + err.Error()
465+
} else {
466+
// Update FileManager workspace directory
467+
a.fileManager.SetWorkspaceDir(msg.NewDir)
468+
469+
// Update GitPane working directory
470+
cmd := a.gitPane.SetWorkDir(msg.NewDir)
471+
cmds = append(cmds, cmd)
472+
473+
// Update AIChatPane workspace root
474+
a.aiPane.SetWorkspaceRoot(msg.NewDir)
475+
476+
// Notify user of directory change
477+
a.statusMessage = "Cloned successfully. Changed directory to: " + msg.NewDir
478+
479+
// Close the Git UI after successful clone
480+
a.gitPane.Toggle()
481+
}
471482
}
472-
483+
473484
// Forward the message to GitPane for status display
474485
_, cmd := a.gitPane.Update(msg)
475486
cmds = append(cmds, cmd)
@@ -1390,11 +1401,19 @@ func (a *App) View() string {
13901401
normalStyle := lipgloss.NewStyle().
13911402
Foreground(lipgloss.Color("252"))
13921403

1404+
// Get the current project folder name
1405+
projectFolder := filepath.Base(a.config.WorkspaceDir)
1406+
13931407
var listDisplay string
13941408
listDisplay = lipgloss.NewStyle().
13951409
Bold(true).
13961410
Foreground(lipgloss.Color("15")).
1397-
Render("Select a chat to load:") + "\n\n"
1411+
Render("Select a chat to load:") + "\n"
1412+
1413+
// Display project folder name
1414+
listDisplay += lipgloss.NewStyle().
1415+
Foreground(lipgloss.Color("15")).
1416+
Render("Project: "+projectFolder) + "\n\n"
13981417

13991418
maxDisplay := 15
14001419
startIdx := a.filePickerIndex - maxDisplay/2
@@ -1420,7 +1439,7 @@ func (a *App) View() string {
14201439
}
14211440

14221441
listDisplay += "\n" + lipgloss.NewStyle().
1423-
Foreground(lipgloss.Color("240")).
1442+
Foreground(lipgloss.Color("15")).
14241443
Render("[↑↓] Navigate | [Enter] Load | [Esc] Cancel")
14251444

14261445
dialog := pickerStyle.Render(listDisplay)
@@ -1444,11 +1463,19 @@ func (a *App) View() string {
14441463
normalStyle := lipgloss.NewStyle().
14451464
Foreground(lipgloss.Color("252"))
14461465

1466+
// Get the current project folder name
1467+
projectFolder := filepath.Base(a.config.WorkspaceDir)
1468+
14471469
var listDisplay string
14481470
listDisplay = lipgloss.NewStyle().
14491471
Bold(true).
14501472
Foreground(lipgloss.Color("15")).
1451-
Render("Select a backup to restore (creates new backup of current):") + "\n\n"
1473+
Render("Select a backup to restore (creates new backup of current):") + "\n"
1474+
1475+
// Display project folder name
1476+
listDisplay += lipgloss.NewStyle().
1477+
Foreground(lipgloss.Color("15")).
1478+
Render("Project: "+projectFolder) + "\n\n"
14521479

14531480
maxDisplay := 15
14541481
startIdx := a.filePickerIndex - maxDisplay/2
@@ -1476,7 +1503,7 @@ func (a *App) View() string {
14761503
}
14771504

14781505
listDisplay += "\n" + lipgloss.NewStyle().
1479-
Foreground(lipgloss.Color("240")).
1506+
Foreground(lipgloss.Color("15")).
14801507
Render("[↑↓] Navigate | [Enter] Restore | [Esc] Cancel")
14811508

14821509
dialog := pickerStyle.Render(listDisplay)
@@ -1501,12 +1528,20 @@ func (a *App) View() string {
15011528
normalStyle := lipgloss.NewStyle().
15021529
Foreground(lipgloss.Color("252"))
15031530

1531+
// Get the current project folder name
1532+
projectFolder := filepath.Base(a.config.WorkspaceDir)
1533+
15041534
// Build file list display
15051535
var fileListDisplay string
15061536
fileListDisplay = lipgloss.NewStyle().
15071537
Bold(true).
15081538
Foreground(lipgloss.Color("15")).
1509-
Render("Select a file to open:") + "\n\n"
1539+
Render("Select a file to open:") + "\n"
1540+
1541+
// Display project folder name
1542+
fileListDisplay += lipgloss.NewStyle().
1543+
Foreground(lipgloss.Color("15")).
1544+
Render("Project: "+projectFolder) + "\n\n"
15101545

15111546
maxDisplay := 15 // Maximum files to display at once
15121547
startIdx := a.filePickerIndex - maxDisplay/2
@@ -1531,7 +1566,7 @@ func (a *App) View() string {
15311566
}
15321567

15331568
fileListDisplay += "\n" + lipgloss.NewStyle().
1534-
Foreground(lipgloss.Color("240")).
1569+
Foreground(lipgloss.Color("15")).
15351570
Render("[↑↓] Navigate | [Enter] Open | [Esc] Cancel")
15361571

15371572
dialog := pickerStyle.Render(fileListDisplay)
@@ -1549,7 +1584,14 @@ func (a *App) View() string {
15491584
Width(60).
15501585
Align(lipgloss.Center)
15511586

1552-
promptText := "Enter filename to create/open:\n\n" + a.filePromptBuffer + "█\n\n[Enter] to confirm, [Esc] to cancel"
1587+
// Get the current project folder name
1588+
projectFolder := filepath.Base(a.config.WorkspaceDir)
1589+
1590+
promptText := "Enter filename to create/open:\n"
1591+
promptText += lipgloss.NewStyle().
1592+
Foreground(lipgloss.Color("15")).
1593+
Render("Project: "+projectFolder) + "\n\n"
1594+
promptText += a.filePromptBuffer + "█\n\n[Enter] to confirm, [Esc] to cancel"
15531595

15541596
dialog := promptStyle.Render(promptText)
15551597

0 commit comments

Comments
 (0)