Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(cli): release the plugin hint claim when printing fails
showPluginHint claims the 24h stamp before printing, so a print that did not succeed left the stamp standing: the hint was never delivered yet both the hint and CLI_PLUGIN_HINT_SHOWN stayed muted for the full interval. Capture the print with Effect.exit and remove the just-created stamp on any non-success exit so the next invocation can retry. Tracking stays best-effort by contract: trackCliEventEffect never fails, so a delivered hint with a lost event is accepted and does not un-claim.
jkomyno committed
Sep 16, 2026 at 18:44 UTC
1ec7c312d719ec6df141e69c763ea57e16f79889
2 files changed
+35
-3
ts/packages/cli/src/services/plugin-hint.ts
+21
-3
@@ -1,7 +1,7 @@
1
import * as FileSystem from 'effect/FileSystem';
2
import * as Path from 'effect/Path';
3
import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4
-import { Effect, Layer, Option, Schema } from 'effect';
4
+import { Effect, Exit, Layer, Option, Schema } from 'effect';
5
import { trackCliEventEffect } from 'src/analytics/dispatch';
6
import { getPluginHintShownEvent } from 'src/analytics/events';
7
import { APP_CONFIG } from 'src/effects/app-config';
@@ -72,6 +72,13 @@ export function createPluginHint(config: PluginHintConfig) {
72
);
73
}).pipe(Effect.orElseSucceed(() => false));
74
75
+ const releaseHint = (host: AgentHost) =>
76
+ Effect.gen(function* () {
77
+ const fs = yield* FileSystem.FileSystem;
78
+ const path = yield* Path.Path;
79
+ yield* fs.remove(path.join(config.stateDirectory, `${host}.stamp`), { force: true });
80
+ }).pipe(Effect.ignore);
81
+
82
// "Confidently absent" only: a missing state file means the plugin was never
83
// installed, while an unreadable or unrecognized one suppresses the hint.
84
const claudePluginAbsent = Effect.gen(function* () {
@@ -110,9 +117,20 @@ export function createPluginHint(config: PluginHintConfig) {
117
}
118
if (!(yield* pluginAbsentByHost[host])) return;
119
if (!(yield* claimHint(host))) return;
113
- yield* terminal.error(
114
- `Tip: running under ${AGENT_HOST_LABELS[host]} without the Composio plugin — 'composio setup --yes' installs it.`
120
+ // The stamp must not outlive a failed delivery: if printing the hint
121
+ // does not succeed, release the claim so the next invocation can
122
+ // retry instead of staying muted for the full interval. Tracking
123
+ // below is best-effort by contract (trackCliEventEffect never
124
+ // fails), so a delivered hint with a lost event is accepted.
125
+ const printed = yield* Effect.exit(
126
+ terminal.error(
127
+ `Tip: running under ${AGENT_HOST_LABELS[host]} without the Composio plugin — 'composio setup --yes' installs it.`
128
+ )
129
);
130
+ if (Exit.isFailure(printed)) {
131
+ yield* releaseHint(host);
132
+ return;
133
+ }
134
yield* trackCliEventEffect(
135
getPluginHintShownEvent({
136
invocationOrigin: config.invocationOrigin ?? DEFAULT_CLI_INVOCATION_ORIGIN,
ts/packages/cli/test/src/services/plugin-hint.test.ts
+14
@@ -226,6 +226,20 @@ describe('showPluginHint', () => {
226
}).pipe(Effect.provide(hintLayers()))
227
);
228
229
+ it.effect('releases the claim when printing fails so the next run can retry', () =>
230
+ Effect.gen(function* () {
231
+ const config = makeConfig();
232
+
233
+ yield* createPluginHint(config).showPluginHint({
234
+ error: () => Effect.die(new Error('EPIPE')),
235
+ });
236
+ expect(existsSync(join(config.stateDirectory, 'claude.stamp'))).toBe(false);
237
+
238
+ yield* createPluginHint(config).showPluginHint(makeTerminal(output));
239
+ expect(output).toHaveLength(1);
240
+ }).pipe(Effect.provide(hintLayers()))
241
+ );
242
+
243
it.effect('tracks CLI_PLUGIN_HINT_SHOWN once per printed hint', () =>
244
Effect.gen(function* () {
245
const config = makeConfig({ invocationOrigin: 'installer', commandName: 'whoami' });