Skip to content

feat(cli): add global option to disable automatic session title changes#504

Open
chenbojian wants to merge 3 commits intotiann:mainfrom
chenbojian:feat/enable-auto-title-option
Open

feat(cli): add global option to disable automatic session title changes#504
chenbojian wants to merge 3 commits intotiann:mainfrom
chenbojian:feat/enable-auto-title-option

Conversation

@chenbojian
Copy link
Copy Markdown

@chenbojian chenbojian commented Apr 20, 2026

Summary

  • Adds enableAutoTitle setting in ~/.hapi/settings.json (defaults to true)
  • When set to false, the title instruction is omitted from system prompts (Claude, Codex, OpenCode) and the change_title MCP tool is not registered
  • No changes to launcher files or web frontend — minimal, self-contained change

Support part of #271

Test plan

  • Set "enableAutoTitle": false in ~/.hapi/settings.json → start a session → verify no title-change tool calls and no title instruction in prompt
  • Remove setting or set true → verify behavior unchanged
  • Run bun run typecheck in cli/ — passes
  • Run bunx vitest run src/claude/utils/claudeSettings.test.ts — all 11 tests pass

Add `enableAutoTitle` setting in `~/.hapi/settings.json` that controls
whether the agent automatically renames chat sessions via the
`change_title` MCP tool. When set to `false`, the title instruction is
omitted from system prompts and the tool is not registered.

Closes tiann#271
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: initial

Findings

  • [Major] enableAutoTitle=false does not fully disable automatic title changes outside Claude. The new guard removes the HTTP-side tool in cli/src/claude/utils/startHappyServer.ts:45, but Codex/OpenCode still launch the shared stdio bridge, and that bridge still unconditionally advertises change_title in cli/src/codex/happyMcpStdioBridge.ts:72. That leaves the tool visible and callable in the non-Claude modes this PR claims to cover.

Summary

  • enableAutoTitle=false currently suppresses prompt text, but not end-to-end tool exposure for Codex/OpenCode.
  • Not found in tests: coverage for the MCP bridge/tool advertisement path when enableAutoTitle is false.

Testing

  • Not run (automation)

HAPI Bot

};
}
});
if (shouldEnableAutoTitle()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] enableAutoTitle=false only removes the tool from the HTTP MCP server here. Codex and OpenCode still go through buildHapiMcpBridge(...), and cli/src/codex/happyMcpStdioBridge.ts:72 still unconditionally re-registers change_title, so those modes can still see and call the title tool.

Suggested fix:

const client = await ensureHttpClient();
const { tools } = await client.listTools();

if (tools.some((tool) => tool.name === 'change_title')) {
    server.registerTool<any, any>('change_title', {
        description: 'Change the title of the current chat session',
        title: 'Change Chat Title',
        inputSchema: changeTitleInputSchema,
    }, async (args: Record<string, unknown>) => {
        return client.callTool({ name: 'change_title', arguments: args });
    });
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next commit

…false

The STDIO MCP bridge unconditionally registered the change_title tool,
leaving it visible in Codex/OpenCode even when enableAutoTitle was false.
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No actionable findings in the updated diff.

Summary

  • Review mode: follow-up after new commits
  • No new diff-attributable correctness, security, or maintainability issues found.
  • Residual risk: not found in repo/docs/tests, targeted coverage for enableAutoTitle=false through the non-Claude launch paths touched here, especially cli/src/codex/happyMcpStdioBridge.ts:68, cli/src/opencode/opencodeLocalLauncher.ts:274, and cli/src/opencode/opencodeRemoteLauncher.ts:120.

Testing

  • Not run (automation)

HAPI Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant