Release v1.4.7 with unlimited default timeout

This commit is contained in:
lutc5
2026-05-06 16:29:35 +08:00
parent fe1d5b5348
commit 22f793c188
13 changed files with 73 additions and 25 deletions

View File

@@ -167,9 +167,6 @@ func New(cfg Config) *Service {
if strings.TrimSpace(cfg.ShellType) == "" {
cfg.ShellType = lingmaipc.DefaultShellType()
}
if cfg.Timeout <= 0 {
cfg.Timeout = 300 * time.Second
}
if cfg.Transport == "" {
cfg.Transport = lingmaipc.TransportAuto
}
@@ -225,6 +222,13 @@ func (s *Service) Close() error {
return s.closeClientLocked()
}
func contextWithOptionalTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) {
if timeout <= 0 {
return context.WithCancel(parent)
}
return context.WithTimeout(parent, timeout)
}
func (s *Service) State() State {
s.mu.Lock()
defer s.mu.Unlock()
@@ -365,7 +369,7 @@ func (s *Service) generateRemote(
client := s.remoteClientLocked()
var lastErr error
for i, model := range models {
attemptCtx, cancel := context.WithTimeout(ctx, s.cfg.Timeout)
attemptCtx, cancel := contextWithOptionalTimeout(ctx, s.cfg.Timeout)
result, emitted, err := s.generateRemoteWithModel(attemptCtx, client, req, prompt, model, onDelta)
cancel()
if err == nil {
@@ -513,7 +517,7 @@ func (s *Service) generateLocked(
req ChatRequest,
onDelta func(string),
) (result *ChatResult, err error) {
requestCtx, cancel := context.WithTimeout(ctx, s.cfg.Timeout)
requestCtx, cancel := contextWithOptionalTimeout(ctx, s.cfg.Timeout)
defer cancel()
ipcClient, err := s.ensureConnected(requestCtx)