Skip to content

Commit 3450f2e

Browse files
committed
fix(integrations): prevent duplicate hooks during initialization
1 parent f8028e9 commit 3450f2e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

cmd/initialize/initialize.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,13 @@ func setupIntegrations(integrationNames []string) ([]string, error) {
604604
continue
605605
}
606606

607+
// Skip if already enabled (prevents duplicate hooks)
608+
if enabled, _ := integration.IsEnabled(); enabled {
609+
fmt.Printf(" Integration %s already configured (skipped)\n", name)
610+
enabledIntegrations = append(enabledIntegrations, name)
611+
continue
612+
}
613+
607614
if err := integration.Setup(binaryPath); err != nil {
608615
fmt.Printf(" Warning: Failed to setup %s: %v\n", name, err)
609616
continue

internal/integrations/adapters/claude/hook_adapter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ func addOrUpdateHook(events []HookEvent, matcher, command string) []HookEvent {
292292
}
293293

294294
if matcherIdx >= 0 {
295-
// Update existing matcher
295+
// Update existing matcher - look for both old and new binary names
296296
hookExists := false
297297
for i, hook := range events[matcherIdx].Hooks {
298-
if strings.Contains(hook.Command, "agentic-memorizer") {
298+
if strings.Contains(hook.Command, "memorizer") {
299299
events[matcherIdx].Hooks[i] = newHook
300300
hookExists = true
301301
break

internal/tui/initialize/components/checkbox.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ func (c *CheckboxList) CheckedItems() []CheckboxItem {
6969
return checked
7070
}
7171

72-
// CheckedValues returns the values of checked items
72+
// CheckedValues returns the values of checked AND enabled items
73+
// Disabled items are excluded even if checked (they represent pre-existing state)
7374
func (c *CheckboxList) CheckedValues() []any {
7475
var values []any
7576
for _, item := range c.items {
76-
if item.Checked {
77+
if item.Checked && item.Enabled {
7778
values = append(values, item.Value)
7879
}
7980
}

0 commit comments

Comments
 (0)