Change summary
internal/db/connect.go | 3 ++-
internal/tui/tui.go | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
Detailed changes
@@ -1,6 +1,7 @@
package db
import (
+ "context"
"database/sql"
"fmt"
"os"
@@ -15,7 +16,7 @@ import (
"github.com/pressly/goose/v3"
)
-func Connect() (*sql.DB, error) {
+func Connect(ctx context.Context) (*sql.DB, error) {
dataDir := config.Get().Options.DataDirectory
if dataDir == "" {
return nil, fmt.Errorf("data.dir is not set")
@@ -230,20 +230,20 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
contextWindow := model.ContextWindow
usedTokens := session.CompletionTokens + session.PromptTokens
remainingTokens := contextWindow - usedTokens
-
+
// Get effective max tokens for this agent (considering overrides)
maxTokens := a.app.CoderAgent.EffectiveMaxTokens()
-
+
// Apply 10% margin to max tokens
maxTokensWithMargin := int64(float64(maxTokens) * 1.1)
-
+
// Trigger auto-summarize if remaining tokens < max tokens + 10% margin
// Also ensure we have a reasonable minimum threshold to avoid too-frequent summaries
minThreshold := int64(1000) // Minimum 1000 tokens remaining before triggering
if maxTokensWithMargin < minThreshold {
maxTokensWithMargin = minThreshold
}
-
+
if remainingTokens < maxTokensWithMargin && !config.Get().Options.DisableAutoSummarize {
// Show compact confirmation dialog
cmds = append(cmds, util.CmdHandler(dialogs.OpenDialogMsg{