Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
- Fixed bug where context auto-load would hang if there was no valid context to load (for example, if they're all directories, which is only discovered client-side, and which can't be auto-loaded) - Fixed bug where the build output would sometimes wrap incorrectly, causing the Plan Stream TUI to get out of sync with the build output. - Fixed bug where build output would jump between collapsed and expanded states during a stream, after the user manually expanded.
Dane Schneider1409bd0669c4
diff --git a/app/cli/lib/context_auto_load.go b/app/cli/lib/context_auto_load.goindex d215ccbf..33de68ac 100644--- a/app/cli/lib/context_auto_load.go+++ b/app/cli/lib/context_auto_load.go@@ -136,7 +136,6 @@ func AutoLoadContextFiles(ctx context.Context, files []string) (string, error) {// Print skip info onlyreturn getSkippedFilesMsg(filesSkippedTooLarge, filesSkippedAfterSizeLimit, nil, nil), nil}- return "", nil}res, apiErr := api.Client.AutoLoadContext(ctx, CurrentPlanId, CurrentBranch, loadContextReqs)@@ -155,6 +154,7 @@ func AutoLoadContextFiles(ctx context.Context, files []string) (string, error) {if len(filesSkippedTooLarge) > 0 || len(filesSkippedAfterSizeLimit) > 0 {msg += "\n\n" + getSkippedFilesMsg(filesSkippedTooLarge, filesSkippedAfterSizeLimit, nil, nil)}+return msg, nil}diff --git a/app/cli/stream_tui/model.go b/app/cli/stream_tui/model.goindex 2a5158ce..4bbcc791 100644--- a/app/cli/stream_tui/model.go+++ b/app/cli/stream_tui/model.go@@ -84,7 +84,7 @@ type streamUIModel struct {autoLoadContextCancelFn context.CancelFuncbuildViewCollapsed bool- userExpandedBuild bool+ userToggledBuild bool}type keymap = struct {diff --git a/app/cli/stream_tui/update.go b/app/cli/stream_tui/update.goindex a500ac57..f5a7c69d 100644--- a/app/cli/stream_tui/update.go+++ b/app/cli/stream_tui/update.go@@ -62,8 +62,11 @@ func (m streamUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {// We have the loaded content in msg.textm.updateState(func() {- m.reply += "\n\n" + msg.text + "\n\n"+ if msg.text != "" {+ m.reply += "\n\n" + msg.text + "\n\n"+ }// and keep processing+ m.processing = true})m.updateReplyDisplay()return m, m.Tick()@@ -470,7 +473,7 @@ func (m *streamUIModel) streamUpdate(msg *shared.StreamMessage, deferUIUpdate bo// Auto-collapse if build info takes up too much spacestate = m.readState()- if !state.userExpandedBuild && state.building {+ if !state.userToggledBuild && state.building {rows := len(m.getRows(false))m.updateState(func() {m.buildViewCollapsed = rows > 3@@ -595,7 +598,7 @@ func (m *streamUIModel) up() {} else {m.updateState(func() {m.buildViewCollapsed = false- m.userExpandedBuild = true+ m.userToggledBuild = true})}}@@ -609,6 +612,7 @@ func (m *streamUIModel) down() {} else {m.updateState(func() {m.buildViewCollapsed = true+ m.userToggledBuild = true})}}diff --git a/app/cli/stream_tui/view.go b/app/cli/stream_tui/view.goindex d5572d3d..407448c6 100644--- a/app/cli/stream_tui/view.go+++ b/app/cli/stream_tui/view.go@@ -176,34 +176,32 @@ func (m streamUIModel) getBuildHeader(static bool) string {func (m streamUIModel) getRows(static bool) []string {built := m.didBuild() && static-head := m.getBuildHeader(static)+ // Gather file paths, _apply.sh lastfilePaths := make([]string, 0, len(m.tokensByPath))for filePath := range m.tokensByPath {- // _apply.sh script goes lastif filePath == "_apply.sh" {continue}filePaths = append(filePaths, filePath)}-sort.Strings(filePaths)-if _, ok := m.tokensByPath["_apply.sh"]; ok {filePaths = append(filePaths, "_apply.sh")}var rows [][]string- rows = append(rows, []string{})lineWidth := 0- lineNum := 0+ lineNum := -1rowIdx := 0for _, filePath := range filePaths {tokens := m.tokensByPath[filePath]finished := m.finished || m.finishedByPath[filePath] || builtremoved := m.removedByPath[filePath]++ // Basic block labelicon := "π"label := filePathif filePath == "_apply.sh" {@@ -212,53 +210,64 @@ func (m streamUIModel) getRows(static bool) []string {}block := fmt.Sprintf("%s %s", icon, label)- if removed {+ // Mark removed/finished/tokens+ switch {+ case removed:block += " β"- } else if finished {+ case finished:block += " β "- } else if tokens > 0 {+ case tokens > 0:block += fmt.Sprintf(" %d πͺ", tokens)- } else {+ default:block += " " + m.buildSpinner.View()}- maybeBlockWidth := lipgloss.Width(block)-- if maybeBlockWidth > m.width {- maxWidth := m.width - (lipgloss.Width("β―"))- runes := []rune(block)- firstHalf := string(runes[:maxWidth/2])- secondHalf := string(runes[len(runes)-maxWidth/2:])- block = firstHalf + "β―" + secondHalf+ // Truncate if needed+ blockWidth := lipgloss.Width(block)+ if blockWidth > m.width {+ maxWidth := m.width - lipgloss.Width("β―")+ if maxWidth < 4 {+ block = string([]rune(block)[0:1]) + "β―"+ } else {+ half := maxWidth / 2+ runes := []rune(block)+ block = string(runes[:half]) + "β―" + string(runes[len(runes)-half:])+ }}- maybePrefix := ""+ // Build the "prefix + block" text tentatively:+ prefix := ""if rowIdx > 0 {- maybePrefix = " | "- maybeBlockWidth += lipgloss.Width(maybePrefix)+ prefix = " | "}+ candidate := prefix + block+ candidateWidth := lipgloss.Width(candidate)- if lineWidth+maybeBlockWidth > m.width {- lineWidth = 0+ // Check if we have no row or it won't fit with the prefix+ if lineNum == -1 || lineWidth+candidateWidth > m.width {+ // Start a new row+ rows = append(rows, []string{})lineNum++rowIdx = 0- rows = append(rows, []string{})- } else {- block = maybePrefix + block- }-- defBlockWidth := lipgloss.Width(block)+ lineWidth = 0- row := rows[lineNum]- row = append(row, block)- rows[lineNum] = row+ // In a new row, there's no prefix+ candidate = block+ candidateWidth = lipgloss.Width(candidate)+ }- lineWidth += defBlockWidth+ rows[lineNum] = append(rows[lineNum], candidate)+ lineWidth += candidateWidthrowIdx++}- resRows := make([]string, len(rows)+1)+ // If empty row left at the end, strip it+ if len(rows) > 0 && len(rows[len(rows)-1]) == 0 {+ rows = rows[:len(rows)-1]+ }+ // Final output lines+ resRows := make([]string, len(rows)+1)resRows[0] = headfor i, row := range rows {resRows[i+1] = lipgloss.JoinHorizontal(lipgloss.Left, row...)diff --git a/app/server/handlers/plans_exec.go b/app/server/handlers/plans_exec.goindex 4e4b52b2..1577b0ef 100644--- a/app/server/handlers/plans_exec.go+++ b/app/server/handlers/plans_exec.go@@ -403,6 +403,19 @@ func AutoLoadContextHandler(w http.ResponseWriter, r *http.Request) {return}+ var err error+ defer func() {+ if err == nil {+ active.AutoLoadContextCh <- struct{}{}+ } else {+ active.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Error in AutoLoadContextHandler: " + err.Error(),+ }+ }+ }()+body, err := io.ReadAll(r.Body)if err != nil {log.Printf("Error reading request body: %v\n", err)@@ -419,15 +432,20 @@ func AutoLoadContextHandler(w http.ResponseWriter, r *http.Request) {}log.Println("AutoLoadContextHandler - loading contexts")- res, dbContexts := loadContexts(loadContextsParams{- w: w,- r: r,- auth: auth,- loadReq: &requestBody,- plan: plan,- branchName: branch,- autoLoaded: true,- })++ var res *shared.LoadContextResponse+ var dbContexts []*db.Context+ if len(requestBody) > 0 {+ res, dbContexts = loadContexts(loadContextsParams{+ w: w,+ r: r,+ auth: auth,+ loadReq: &requestBody,+ plan: plan,+ branchName: branch,+ autoLoaded: true,+ })+ }if res == nil {return@@ -474,8 +492,6 @@ func AutoLoadContextHandler(w http.ResponseWriter, r *http.Request) {w.Write(bytes)- active.AutoLoadContextCh <- struct{}{}-log.Println("Successfully processed request for AutoLoadContextHandler")}diff --git a/app/server/model/plan/tell_exec.go b/app/server/model/plan/tell_exec.goindex acc753f1..5623da40 100644--- a/app/server/model/plan/tell_exec.go+++ b/app/server/model/plan/tell_exec.go@@ -492,10 +492,16 @@ func (state *activeTellStreamState) dryRunCalculateTokensWithoutContext(tentativif err != nil {log.Printf("error getting tell sys prompt for dry run token calculation: %v", err)++ msg := "Error getting tell sys prompt for dry run token calculation"+ if err.Error() == AllTasksCompletedMsg {+ msg = "There's no current task to implement. Try a prompt instead of the 'continue' command."+ }+state.activePlan.StreamDoneCh <- &shared.ApiError{Type: shared.ApiErrorTypeOther,Status: http.StatusInternalServerError,- Msg: "Error getting tell sys prompt for dry run token calculation",+ Msg: msg,}return false, 0}diff --git a/app/server/model/plan/tell_sys_prompt.go b/app/server/model/plan/tell_sys_prompt.goindex 4c60b3c0..b9cd0579 100644--- a/app/server/model/plan/tell_sys_prompt.go+++ b/app/server/model/plan/tell_sys_prompt.go@@ -1,6 +1,7 @@package planimport (+ "errors""fmt""log""plandex-server/model/prompts"@@ -10,6 +11,8 @@ import ("github.com/sashabaranov/go-openai")+const AllTasksCompletedMsg = "All tasks have been completed. There is no current task to implement."+type getTellSysPromptParams struct {planStageSharedMsgs []*types.ExtendedChatMessagePartplanningPhaseOnlyMsgs []*types.ExtendedChatMessagePart@@ -122,7 +125,7 @@ func (state *activeTellStreamState) getTellSysPrompt(params getTellSysPromptPara} else if currentStage.TellStage == shared.TellStageImplementation {if state.currentSubtask == nil {- return nil, fmt.Errorf("All tasks have been completed. There is no current task to implement.")+ return nil, errors.New(AllTasksCompletedMsg)}if len(state.subtasks) > 0 {diff --git a/docs/docs/core-concepts/context-management.md b/docs/docs/core-concepts/context-management.mdindex b165d15a..997d7834 100644--- a/docs/docs/core-concepts/context-management.md+++ b/docs/docs/core-concepts/context-management.md@@ -103,7 +103,7 @@ Here's how it changes when you load manual context on top:Loading files manually when using automatic context loading can sometimes be useful when you **know** certain files are relevant and don't want to risk the LLM leaving them out, or when the LLM is struggling to select the right context. If there are files that can help the LLM select the right context, like READMEs or documentation that describes the structure of the project, those can also be good candidates for manual loading.-Another use for manual context loading is for context types that can't be loaded automatically, like images, URLs, notes, or piped data (for now Plandex can only automatically load project files).+Another use for manual context loading is for context types that can't be loaded automatically, like URLs, notes, or piped data (for now Plandex can only automatically load project files and images within the project).## Manually Loading Context@@ -186,7 +186,7 @@ Plandex can load images into context.plandex load ui-mockup.png```-For the default GPT-4o model, png, jpeg, non-animated gif, and webp formats are supported. For other models, support for images in general, and particular formats specifically, will depend on the model.+For most models that support images, png, jpeg, non-animated gif, and webp formats are supported. Some models may support fewer or additional formats.### Loading Notesdiff --git a/docs/docs/hosting/cloud.md b/docs/docs/hosting/cloud.mdindex 88296ad7..3ea457f7 100644--- a/docs/docs/hosting/cloud.md+++ b/docs/docs/hosting/cloud.md@@ -26,8 +26,7 @@ Plandex Cloud has two billing modes:### BYO API Key-- Use your own OpenAI, OpenRouter.ai, or other OpenAI-compatible provider accounts.-- Supply your own API keys.+- Use your own OpenAI and OpenRouter.ai accounts and API keys.- Start with a free trial up to 10 plans and 20 model responses per plan.- After the trial, you can upgrade to a paid plan for $30 per month.diff --git a/releases/cli/versions/2.0.2.md b/releases/cli/versions/2.0.2.mdnew file mode 100644index 00000000..147a5239--- /dev/null+++ b/releases/cli/versions/2.0.2.md@@ -0,0 +1,3 @@+- Fixed bug where context auto-load would hang if there was no valid context to load (for example, if they're all directories, which is only discovered client-side, and which can't be auto-loaded)+- Fixed bug where the build output would sometimes wrap incorrectly, causing the Plan Stream TUI to get out of sync with the build output.+- Fixed bug where build output would jump between collapsed and expanded states during a stream, after the user manually expanded.\ No newline at end of filediff --git a/releases/server/versions/2.0.2.md b/releases/server/versions/2.0.2.mdnew file mode 100644index 00000000..dd99f026--- /dev/null+++ b/releases/server/versions/2.0.2.md@@ -0,0 +1 @@+Server-side fix for context auto-load hanging when there's no valid context to load (for example, if they're all directories, which is only discovered client-side, and which can't be auto-loaded)\ No newline at end of file