on main help sign in
chore: fix lint
d0fcb3fKujtim Hoxha
internal/db/connect.go+2−1
@@ -1,6 +1,7 @@
1package db
1package db
2
2
3import (
3import (
4+ "context"
4 "database/sql"
5 "database/sql"
5 "fmt"
6 "fmt"
6 "os"
7 "os"
@@ -15,7 +16,7 @@ import (
15 "github.com/pressly/goose/v3"
16 "github.com/pressly/goose/v3"
16)
17)
17
18
18−func Connect() (*sql.DB, error) {
19+func Connect(ctx context.Context) (*sql.DB, error) {
19 dataDir := config.Get().Options.DataDirectory
20 dataDir := config.Get().Options.DataDirectory
20 if dataDir == "" {
21 if dataDir == "" {
21 return nil, fmt.Errorf("data.dir is not set")
22 return nil, fmt.Errorf("data.dir is not set")
internal/tui/tui.go+4−4
@@ -230,20 +230,20 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
230 contextWindow := model.ContextWindow
230 contextWindow := model.ContextWindow
231 usedTokens := session.CompletionTokens + session.PromptTokens
231 usedTokens := session.CompletionTokens + session.PromptTokens
232 remainingTokens := contextWindow - usedTokens
232 remainingTokens := contextWindow - usedTokens
233−
233+
234 // Get effective max tokens for this agent (considering overrides)
234 // Get effective max tokens for this agent (considering overrides)
235 maxTokens := a.app.CoderAgent.EffectiveMaxTokens()
235 maxTokens := a.app.CoderAgent.EffectiveMaxTokens()
236−
236+
237 // Apply 10% margin to max tokens
237 // Apply 10% margin to max tokens
238 maxTokensWithMargin := int64(float64(maxTokens) * 1.1)
238 maxTokensWithMargin := int64(float64(maxTokens) * 1.1)
239−
239+
240 // Trigger auto-summarize if remaining tokens < max tokens + 10% margin
240 // Trigger auto-summarize if remaining tokens < max tokens + 10% margin
241 // Also ensure we have a reasonable minimum threshold to avoid too-frequent summaries
241 // Also ensure we have a reasonable minimum threshold to avoid too-frequent summaries
242 minThreshold := int64(1000) // Minimum 1000 tokens remaining before triggering
242 minThreshold := int64(1000) // Minimum 1000 tokens remaining before triggering
243 if maxTokensWithMargin < minThreshold {
243 if maxTokensWithMargin < minThreshold {
244 maxTokensWithMargin = minThreshold
244 maxTokensWithMargin = minThreshold
245 }
245 }
246−
246+
247 if remainingTokens < maxTokensWithMargin && !config.Get().Options.DisableAutoSummarize {
247 if remainingTokens < maxTokensWithMargin && !config.Get().Options.DisableAutoSummarize {
248 // Show compact confirmation dialog
248 // Show compact confirmation dialog
249 cmds = append(cmds, util.CmdHandler(dialogs.OpenDialogMsg{
249 cmds = append(cmds, util.CmdHandler(dialogs.OpenDialogMsg{