Skip to content

feat: add tip rotation system with version-update and tip widgets#287

Open
Avimarzan wants to merge 1 commit intosirmalloc:mainfrom
Avimarzan:feat/tip-rotation-widgets
Open

feat: add tip rotation system with version-update and tip widgets#287
Avimarzan wants to merge 1 commit intosirmalloc:mainfrom
Avimarzan:feat/tip-rotation-widgets

Conversation

@Avimarzan
Copy link
Copy Markdown

Summary

Adds a tip rotation system that surfaces useful tips from Claude Code changelogs directly in the status line. Includes:

  • 2 new widgets:
    • version-update — shows Updated: vX.Y.Z → vA.B.C from the latest non-expired tip file
    • tip — shows a rotating tip from the merged pool of all non-expired tip files (💡 emoji prefix, sequential rotation)
  • Core utility module (src/utils/tips.ts):
    • Sync storage for tip files, last-version tracking, and tip index (matches existing codebase patterns)
    • Semver comparison with pre-release suffix handling
    • Tip pool merging, rotation with in-memory caching (only writes to disk on actual rotation, not every render)
    • Changelog fetching from GitHub Releases API
    • Async tip generation via claude --print with <TIPS> marker extraction
    • Pipeline orchestrator: version check → changelog fetch → tip generation → file write → expiry cleanup
  • Config schema extension (TipsSettingsSchema):
    • enabled, tipDir, rotateEvery, expiryDays, maxTipLength, minTips — all with sensible defaults
    • Settings version bumped 3→4 with automatic migration
  • TUI config screen (TipsMenu):
    • Toggle enabled/disabled, edit numeric settings
    • Browse all tips grouped by version with age display
    • Generate tips for current Claude Code version
    • Rotate now, clear all tips
  • Hook handler integration: handleHook() checks for version changes and triggers tip generation when tips.enabled is true

New files

File Purpose
src/widgets/Tip.ts Tip rotation widget with hideWhenEmpty toggle
src/widgets/VersionUpdate.ts Version update notification widget
src/utils/tips.ts Core tip utility (storage, rotation, generation, cleanup)
src/types/TipData.ts Zod schemas for TipFile, LastVersion, TipIndex
src/tui/components/TipsMenu.tsx TUI configuration screen
src/test-helpers/tips.ts Shared test helpers

Modified files

File Change
src/types/Settings.ts Added TipsSettingsSchema, bumped version 3→4
src/utils/migrations.ts Added v3→v4 migration
src/utils/widget-manifest.ts Registered version-update and tip widgets
src/widgets/index.ts Exported new widgets
src/tui/App.tsx Added Tips screen routing
src/tui/components/MainMenu.tsx Added Tips menu item
src/tui/components/index.ts Exported TipsMenu
src/ccstatusline.ts Extended hook handler for version checking

Test coverage

44 tests across 3 test files, all passing:

  • src/utils/__tests__/tips.test.ts — 27 tests (storage, rotation, semver, pool, expiry, pipeline)
  • src/widgets/__tests__/Tip.test.ts — 8 tests (rendering, hideWhenEmpty, preview, raw mode)
  • src/widgets/__tests__/VersionUpdate.test.ts — 9 tests (rendering, empty version guard, semver ordering, expiry)

Design decisions

  • Additive only — no modifications to existing widget behavior or rendering pipeline
  • Follows existing patterns — sync filesystem I/O (matches skills.ts), Zod schemas, widget interface, TUI component structure
  • Performance-conscious — tip pool cached in memory, disk writes only on rotation (not every render)
  • Async tip generation — uses promisify(execFile) to avoid blocking the event loop in the TUI

Test plan

  • Verify bun test passes (44 tip tests + existing suite)
  • Add tip and version-update widgets via TUI, confirm they render
  • Test TUI Tips menu: browse, generate, rotate, clear
  • Test with no tip files (widgets should show placeholder or hide)
  • Test expiry cleanup with old tip files

🤖 Generated with Claude Code

Adds a tip rotation system that generates tips from Claude Code changelogs.
Includes two new widgets (version-update, tip), core utility module with
caching and async tip generation, Zod schemas, v3→v4 settings migration,
hook handler integration, TUI config screen, and shared test helpers (44 tests).

Review fixes applied: hideWhenEmpty placeholder (F-1), empty previousVersion
guard (F-2), cached tip pool with write-only-on-rotation (F-3), deduplicated
semver sort (F-4), async execFile (F-5), path.join (F-6), pre-release semver
handling (F-7), ESM imports (F-8), deduplicated defaults (F-11), useState for
TUI file reads (F-12), extracted test helpers (F-13), response body drain (F-14).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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