google-gemini / google-gemini/gemini-cli

bug: confirm_action slash-command flow re-adds history and double-fires telemetry vs the shell-confirmation path

Open Beginner friendly
#29,032 1 comment 0 reactions 0 assignees View on GitHub
area/core effort/small status/bot-triaged
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

## What happened?

The `confirm_action` slash-command flow re-invokes `handleSlashCommand()` with the original raw invocation but without the `addToHistory: false` flag its sibling (`confirm_shell_commands`) passes. The recursive call therefore re-executes the history-add at the top of command processing and re-fires `logSlashCommand()` in the finally block: **two** SUCCESS `SlashCommandEvent`s per confirmed action, and the user's command text is added to history twice unless the consecutive-duplicate suppression in `useHistoryManager.addItem` happens to mask it (which breaks whenever any other item lands between dialog open and confirm).

## Affected code

`packages/cli/src/ui/hooks/slashCommandProcessor.ts:644-650` (sibling path, correct):

```ts
return await handleSlashCommand(
result.originalInvocation.raw,
new Set(approvedCommands),
undefined,
false, // Do not add to history again
);
```

`packages/cli/src/ui/hooks/slashCommandProcessor.ts:676-680` (`confirm_action`, missing flag):

```ts
return await handleSlashCommand(
result.originalInvocation.raw,
undefined,
true,
);
```

## How can this be reproduced?

1. Run any command that routes through `confirm_action` (e.g., `/memory add ...` style confirmation).
2. Confirm the dialog.
3. Check telemetry: two SlashCommandEvent records for one interaction.
4. For visible duplication: trigger an async info/error item while the dialog is open, then confirm — the command bubble appears twice in history.

## What did you expect to happen?

Behavior parity with the shell-confirmation path: no duplicate history entry, single telemetry event.

## Suggested direction

Mirror the sibling call: pass the same approved-commands set semantics where applicable and `false` for `addToHistory`.

---

*Found by source audit on current `main` (commit `5411f113c`); platform-independent. No open issue/PR covering this was found (searched: slash command telemetry duplicated).*

Contributor guide

Open the contributing guide

Research direction

Open packages/cli/src/ui/hooks/slashCommandProcessor.ts around lines 644-650 and 676-680, and compare the confirm_shell_commands and confirm_action recursive calls. Reproduce a confirm_action flow, including an async info/error item while the dialog is open, then verify that one confirmation produces one telemetry event and one history entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.