Skip to content

Add comprehensive test suite and fix i18n/config issues#47

Open
alexander-acker wants to merge 2 commits into
OpenCoworkAI:mainfrom
alexander-acker:claude/test-all-features-adgsY
Open

Add comprehensive test suite and fix i18n/config issues#47
alexander-acker wants to merge 2 commits into
OpenCoworkAI:mainfrom
alexander-acker:claude/test-all-features-adgsY

Conversation

@alexander-acker
Copy link
Copy Markdown

Summary

This PR adds a comprehensive test suite covering core functionality and fixes several issues with internationalization and configuration management.

Key Changes

Test Suite (New Files)

  • session-manager-lifecycle.test.ts: Tests for SessionManager lifecycle including session creation, continuation, deletion, and message handling
  • store-actions.test.ts: Tests for Zustand store actions covering sessions, messages, trace steps, and UI state management
  • database.test.ts: Tests for database initialization, CRUD operations, and schema creation
  • config-store.test.ts: Tests for configuration store with provider presets and environment variable application
  • memory-manager.test.ts: Tests for memory management including message history, search, and context management
  • i18n-completeness.test.ts: Tests ensuring translation completeness between English and Chinese locales
  • logger.test.ts: Tests for logging functionality
  • credentials-store.test.ts: Tests for credentials storage and retrieval
  • session-update.test.ts: Tests for session update utilities

Source Code Fixes

  • config-store.ts: Fixed OpenRouter keyHint from Chinese to English ("Get from openrouter.ai/keys")
  • session-manager.ts: Added cleanup of pending permissions when deleting a session to prevent memory leaks
  • database.ts: Added FTS5 virtual table creation for memory search functionality
  • MessageCard.tsx: Added missing useTranslation() hook for proper i18n support
  • i18n locales: Added missing sidebar.deleteAllConfirm translation key in both English and Chinese
  • Sidebar.tsx: Updated to use i18n translation key instead of hardcoded Chinese string

Notable Implementation Details

  • All tests use Vitest with proper mocking of Electron, better-sqlite3, and electron-store modules
  • Tests include edge cases like malformed JSON content handling and permission cleanup
  • i18n tests verify completeness across locales and catch missing translation keys
  • Database tests verify proper schema initialization and index creation
  • Store tests validate state management patterns and cleanup operations

https://claude.ai/code/session_01EEkUmHuGJ1mJgB7mqoqTDK

…add comprehensive tests

Bug fixes:
- Replace hardcoded Chinese strings in Sidebar, MessageCard with i18n t() calls
- Replace hardcoded Chinese strings in config-store PROVIDER_PRESETS with English
- Add missing memory_fts FTS5 virtual table creation in database schema
- Fix pendingPermissions memory leak on session deletion in SessionManager

New tests (9 files, 117 new tests):
- config-store, credentials-store, database, i18n-completeness, logger,
  memory-manager, session-manager-lifecycle, session-update, store-actions

All 37 test files (213 tests) passing.

https://claude.ai/code/session_01EEkUmHuGJ1mJgB7mqoqTDK
@alexander-acker alexander-acker force-pushed the claude/test-all-features-adgsY branch from 85f68d9 to 8e1242e Compare March 15, 2026 02:26
@hqhq1025 hqhq1025 closed this Apr 13, 2026
@hqhq1025 hqhq1025 reopened this Apr 13, 2026
@hqhq1025 hqhq1025 closed this Apr 14, 2026
@hqhq1025 hqhq1025 reopened this Apr 14, 2026
@hqhq1025 hqhq1025 added bot-rerun Temporary label for rerunning bot automation and removed bot-rerun Temporary label for rerunning bot automation labels Apr 27, 2026
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

  • [Blocker] t is referenced inside ContentBlockView without being defined in that component, so this change will fail the renderer build as soon as the new tooltip line is compiled. Evidence src/renderer/components/MessageCard.tsx:167.
    Suggested fix:

    function ContentBlockView(...) {
      const { t } = useTranslation();
      ...
    }
  • [Major] deleteSession() now resolves and deletes every entry in pendingPermissions, not just the ones that belong to the session being removed. Deleting one chat can therefore deny tool prompts that are still waiting in other active sessions. Evidence src/main/session/session-manager.ts:614, with the session id only available at insertion time in src/main/session/session-manager.ts:751.
    Suggested fix:

    private pendingPermissions = new Map<
      string,
      { sessionId: string; resolve: (result: PermissionResult) => void }
    >();
    
    this.pendingPermissions.set(toolUseId, { sessionId, resolve });
    
    for (const [toolUseId, pending] of this.pendingPermissions) {
      if (pending.sessionId !== sessionId) continue;
      pending.resolve('deny');
      this.pendingPermissions.delete(toolUseId);
    }

Summary

  • Review mode: initial
  • 2 issues found: a renderer build break in MessageCard and cross-session permission cancellation in SessionManager.
  • Residual testing gap: the new tests do not cover ContentBlockView rendering or a multi-session pending-permission cleanup case.

Testing

  • Not run (automation)

Open Cowork Bot

}}
className={getFileLinkButtonClassName()}
title="在文件夹中定位"
title={t('messageCard.locateInFolder')}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[BLOCKER] t is only defined in MessageCard, but this new tooltip lives inside ContentBlockView, so the file no longer compiles once this line is added. Please initialize useTranslation() in ContentBlockView (or pass t down explicitly) before using it here.

Suggested fix:

function ContentBlockView(...) {
  const { t } = useTranslation();
  ...
}

}

// Clean up pending permissions for this session
for (const [toolUseId, resolver] of this.pendingPermissions.entries()) {
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] This loop now denies every pending permission in the process, not only the ones for sessionId. Because requestPermission() stores only the resolver today, deleting one session will also deny tool prompts that are still pending in other live sessions.

Suggested fix:

private pendingPermissions = new Map<
  string,
  { sessionId: string; resolve: (result: PermissionResult) => void }
>();

this.pendingPermissions.set(toolUseId, { sessionId, resolve });

for (const [toolUseId, pending] of this.pendingPermissions) {
  if (pending.sessionId !== sessionId) continue;
  pending.resolve('deny');
  this.pendingPermissions.delete(toolUseId);
}

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.

3 participants