From afdb81d8b1a7cc5e26e893a43190ca4dcdf0d633 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Sep 2025 10:03:42 -0300 Subject: [PATCH 1/5] chore(deps): fix dependabot config Signed-off-by: Carlos Alexandro Becker --- .github/dependabot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0172187ca829e659ae9e31e2c58929a259411b0d..cf970b5887bc33fd822ab7fc4fe4540df045a6e1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,6 +18,9 @@ updates: patterns: - "*" ignore: + - dependency-name: github.com/charmbracelet/bubbletea/v2 + versions: + - v2.0.0-beta1 - dependency-name: github.com/charmbracelet/lipgloss/v2 versions: - v2.0.0-beta1 From 35b8aada21494ae5e85baf73d40daa46bc552962 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Sep 2025 13:10:52 +0000 Subject: [PATCH 2/5] chore(deps): bump google.golang.org/genai in the all group (#1134) Bumps the all group with 1 update: [google.golang.org/genai](https://github.com/googleapis/go-genai). Updates `google.golang.org/genai` from 1.25.0 to 1.26.0 - [Release notes](https://github.com/googleapis/go-genai/releases) - [Changelog](https://github.com/googleapis/go-genai/blob/main/CHANGELOG.md) - [Commits](https://github.com/googleapis/go-genai/compare/v1.25.0...v1.26.0) --- updated-dependencies: - dependency-name: google.golang.org/genai dependency-version: 1.26.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d82c2490d3a7267f7d9be9b7a2715134dfc96bfa..d3e668320cfdec39160d618b189f1470bf07d028 100644 --- a/go.mod +++ b/go.mod @@ -152,7 +152,7 @@ require ( golang.org/x/text v0.29.0 golang.org/x/time v0.8.0 // indirect google.golang.org/api v0.211.0 // indirect - google.golang.org/genai v1.25.0 + google.golang.org/genai v1.26.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect google.golang.org/grpc v1.71.0 // indirect google.golang.org/protobuf v1.36.8 // indirect diff --git a/go.sum b/go.sum index bb80e08e5226e202a096ec7046458d19a0a9bfa3..f69217e9d4e9831abc8e1b47b80e23a19dcfcffa 100644 --- a/go.sum +++ b/go.sum @@ -425,8 +425,8 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxb golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.211.0 h1:IUpLjq09jxBSV1lACO33CGY3jsRcbctfGzhj+ZSE/Bg= google.golang.org/api v0.211.0/go.mod h1:XOloB4MXFH4UTlQSGuNUxw0UT74qdENK8d6JNsXKLi0= -google.golang.org/genai v1.25.0 h1:Cpyh2nmEoOS1eM3mT9XKuA/qWTEDoktfP2gsN3EduPE= -google.golang.org/genai v1.25.0/go.mod h1:OClfdf+r5aaD+sCd4aUSkPzJItmg2wD/WON9lQnRPaY= +google.golang.org/genai v1.26.0 h1:r4HGL54kFv/WCRMTAbZg05Ct+vXfhAbTRlXhFyBkEQo= +google.golang.org/genai v1.26.0/go.mod h1:OClfdf+r5aaD+sCd4aUSkPzJItmg2wD/WON9lQnRPaY= google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= From c8bdb0b659cd98bd4ef537d7a77b3ab66645ef19 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 26 Sep 2025 10:17:40 -0300 Subject: [PATCH 3/5] fix: improve shutdown (#1133) Signed-off-by: Carlos Alexandro Becker --- internal/llm/agent/mcp-tools.go | 4 +-- internal/lsp/client.go | 51 +++++---------------------------- 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/internal/llm/agent/mcp-tools.go b/internal/llm/agent/mcp-tools.go index d670a5797548cd52bbfd23c8cd16fea96b021e8a..a2e6b912ab503c61522501ad522a9f0a65fc37b0 100644 --- a/internal/llm/agent/mcp-tools.go +++ b/internal/llm/agent/mcp-tools.go @@ -259,9 +259,9 @@ func updateMCPState(name string, state MCPState, err error, client *client.Clien // CloseMCPClients closes all MCP clients. This should be called during application shutdown. func CloseMCPClients() error { var errs []error - for c := range mcpClients.Seq() { + for name, c := range mcpClients.Seq2() { if err := c.Close(); err != nil { - errs = append(errs, err) + errs = append(errs, fmt.Errorf("close mcp: %s: %w", name, err)) } } mcpBroker.Shutdown() diff --git a/internal/lsp/client.go b/internal/lsp/client.go index 259f6ba8c4876dcbeb441d48839685012c48ac32..ff9a3ac9b5249663c151fb2df04a4acb168e4de4 100644 --- a/internal/lsp/client.go +++ b/internal/lsp/client.go @@ -319,30 +319,6 @@ func (c *Client) NotifyChange(ctx context.Context, filepath string) error { return c.client.NotifyDidChangeTextDocument(ctx, uri, int(fileInfo.Version), changes) } -// CloseFile closes a file in the LSP server. -// -// NOTE: this is only ever called on LSP shutdown. -func (c *Client) CloseFile(ctx context.Context, filepath string) error { - cfg := config.Get() - uri := string(protocol.URIFromPath(filepath)) - - if _, exists := c.openFiles.Get(uri); !exists { - return nil // Already closed - } - - if cfg.Options.DebugLSP { - slog.Debug("Closing file", "file", filepath) - } - - if err := c.client.NotifyDidCloseTextDocument(ctx, uri); err != nil { - return err - } - - c.openFiles.Del(uri) - - return nil -} - // IsFileOpen checks if a file is currently open. func (c *Client) IsFileOpen(filepath string) bool { uri := string(protocol.URIFromPath(filepath)) @@ -353,29 +329,16 @@ func (c *Client) IsFileOpen(filepath string) bool { // CloseAllFiles closes all currently open files. func (c *Client) CloseAllFiles(ctx context.Context) { cfg := config.Get() - filesToClose := make([]string, 0, c.openFiles.Len()) - - // First collect all URIs that need to be closed + debugLSP := cfg != nil && cfg.Options.DebugLSP for uri := range c.openFiles.Seq2() { - // Convert URI back to file path using proper URI handling - filePath, err := protocol.DocumentURI(uri).Path() - if err != nil { - slog.Error("Failed to convert URI to path for file closing", "uri", uri, "error", err) - continue + if debugLSP { + slog.Debug("Closing file", "file", uri) } - filesToClose = append(filesToClose, filePath) - } - - // Then close them all - for _, filePath := range filesToClose { - err := c.CloseFile(ctx, filePath) - if err != nil && cfg != nil && cfg.Options.DebugLSP { - slog.Warn("Error closing file", "file", filePath, "error", err) + if err := c.client.NotifyDidCloseTextDocument(ctx, uri); err != nil { + slog.Warn("Error closing rile", "uri", uri, "error", err) + continue } - } - - if cfg != nil && cfg.Options.DebugLSP { - slog.Debug("Closed all files", "files", filesToClose) + c.openFiles.Del(uri) } } From 9fd7f48e07bb6231676c6891879ee510e81cdd0d Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 26 Sep 2025 10:27:38 -0300 Subject: [PATCH 4/5] chore(metrics): have a better identifier fallback (#1130) --- internal/event/event.go | 12 ++------- internal/event/identifier.go | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 internal/event/identifier.go diff --git a/internal/event/event.go b/internal/event/event.go index 42272c7035638fee7167b5c3510c7975cb9c9394..ca02c6d89d67be1756b166aea152da165b2712c9 100644 --- a/internal/event/event.go +++ b/internal/event/event.go @@ -9,7 +9,6 @@ import ( "runtime" "github.com/charmbracelet/crush/internal/version" - "github.com/denisbrodbeck/machineid" "github.com/posthog/posthog-go" ) @@ -39,6 +38,7 @@ func Init() { slog.Error("Failed to initialize PostHog client", "error", err) } client = c + distinctId = getDistinctId() } // send logs an event to PostHog with the given event name and properties. @@ -47,7 +47,7 @@ func send(event string, props ...any) { return } err := client.Enqueue(posthog.Capture{ - DistinctId: distinctId(), + DistinctId: distinctId, Event: event, Properties: pairsToProps(props...).Merge(baseProps), }) @@ -105,11 +105,3 @@ func pairsToProps(props ...any) posthog.Properties { func isEven(n int) bool { return n%2 == 0 } - -func distinctId() string { - id, err := machineid.ProtectedID("charm") - if err != nil { - return "crush-cli" - } - return id -} diff --git a/internal/event/identifier.go b/internal/event/identifier.go new file mode 100644 index 0000000000000000000000000000000000000000..ee05f8f58f6dd9a8f662e94992983ce26a94d9b9 --- /dev/null +++ b/internal/event/identifier.go @@ -0,0 +1,49 @@ +package event + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "fmt" + "net" + + "github.com/denisbrodbeck/machineid" +) + +var distinctId string + +const ( + hashKey = "charm" + fallbackId = "unknown" +) + +func getDistinctId() string { + if id, err := machineid.ProtectedID(hashKey); err == nil { + return id + } + if macAddr, err := getMacAddr(); err == nil { + return hashString(macAddr) + } + return fallbackId +} + +func getMacAddr() (string, error) { + interfaces, err := net.Interfaces() + if err != nil { + return "", err + } + for _, iface := range interfaces { + if iface.Flags&net.FlagUp != 0 && iface.Flags&net.FlagLoopback == 0 && len(iface.HardwareAddr) > 0 { + if addrs, err := iface.Addrs(); err == nil && len(addrs) > 0 { + return iface.HardwareAddr.String(), nil + } + } + } + return "", fmt.Errorf("no active interface with mac address found") +} + +func hashString(str string) string { + hash := hmac.New(sha256.New, []byte(str)) + hash.Write([]byte(hashKey)) + return hex.EncodeToString(hash.Sum(nil)) +} From a116beac6a889309dcce558fd47862c6c29495e8 Mon Sep 17 00:00:00 2001 From: Charm <124303983+charmcli@users.noreply.github.com> Date: Fri, 26 Sep 2025 10:30:25 -0300 Subject: [PATCH 5/5] chore(legal): @Kaneki-x has signed the CLA --- .github/cla-signatures.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/cla-signatures.json b/.github/cla-signatures.json index a62172eb28a153115f31a83dd1be2c88193b20df..136d5857bf881c2fca2a5ada072cde11ac97af3c 100644 --- a/.github/cla-signatures.json +++ b/.github/cla-signatures.json @@ -655,6 +655,14 @@ "created_at": "2025-09-20T12:37:42Z", "repoId": 987670088, "pullRequestNo": 1095 + }, + { + "name": "Kaneki-x", + "id": 6857108, + "comment_id": 3338743039, + "created_at": "2025-09-26T13:30:16Z", + "repoId": 987670088, + "pullRequestNo": 1135 } ] } \ No newline at end of file