Skip to content

Fix issue #278 identity refresh and session log autosave#281

Merged
binaricat merged 2 commits intomainfrom
codex/fix-issue-278-identity-and-session-logs
Mar 6, 2026
Merged

Fix issue #278 identity refresh and session log autosave#281
binaricat merged 2 commits intomainfrom
codex/fix-issue-278-identity-and-session-logs

Conversation

@binaricat
Copy link
Owner

@binaricat binaricat commented Mar 6, 2026

Background

Issue #278 reports two separate regressions:

  1. Newly created identities are persisted and can be referenced by hosts, but they do not appear immediately in the Keychain identity list.
  2. Session logs can be viewed inside Netcatty after a session ends, but enabling auto-save does not produce any log file in the configured directory.

Root Cause

1. Identity list not refreshing

VaultView is wrapped in React.memo, but its custom comparator did not include the identities prop.
That meant identity-only updates did not trigger a rerender for the Keychain section. The list would appear to "refresh" only after some other prop such as keys changed.

2. Session logs not being auto-saved

There were two issues in the session-log path:

  • Connection logs were originally matched against live session state during terminal teardown, which is brittle once a session has already been removed.
  • More importantly, the session-log settings (enabled, directory, format) were not synchronized across windows in useSettingsState.
    In practice, users enable auto-save from the Settings window, but the main app window is the one that actually captures terminal output and triggers auto-save. The main window kept stale session-log settings, so auto-save continued running with outdated values.

What Changed

  • Added identities to the VaultView memo comparison so identity create/update/delete operations rerender the Keychain view immediately.
  • Updated session creation helpers to return the created sessionId.
  • Stored sessionId on every newly created ConnectionLog.
  • Changed terminal log capture to prefer matching logs by persisted ConnectionLog.sessionId instead of relying on the still-being-mounted session state.
  • Aligned tray-panel initiated connections with the same connection-log creation path so they also receive sessionId-backed log matching.
  • Added missing cross-window synchronization for:
    • sessionLogsEnabled
    • sessionLogsDir
    • sessionLogsFormat
      through both IPC-based settings change notifications and storage event handling.

User-visible Behavior

Before

  • Creating an identity in Keychain could succeed, but the new identity would not appear in the Keychain identity list until some unrelated change caused a rerender, such as importing a key.
  • Enabling session-log auto-save in the Settings window could appear to work in UI, but the main app window still used stale session-log settings, so closing a session did not write any file to the configured directory.

After

  • Creating or editing an identity updates the Keychain identity list immediately.
  • Changing session-log auto-save settings in the Settings window propagates to the main app window.
  • Closing a session with session-log auto-save enabled writes the log file to the configured directory reliably.

Functional Test Plan

Identity rendering

  1. Open Vault > Keychain.
  2. Create a new identity with label and username only, then save.
  3. Verify the identity appears immediately in the identities section of Keychain.
  4. Create another identity referencing a key or certificate and save.
  5. Verify it also appears immediately without needing to switch tabs or import a key.
  6. Open Vault > Hosts, create/edit a host, and verify both identities are available in the credential picker.

Expected result after fix:

  • Each saved identity is visible immediately in Keychain and selectable from host credentials.

Expected result before fix:

  • The identity may be persisted and usable from host forms, but it does not show up in the Keychain identity list until another state change triggers a rerender.

Session log auto-save

  1. Open the main app window.
  2. Open Settings > System > Session Logs from the settings window.
  3. Enable auto-save.
  4. Choose a writable save directory.
  5. Keep format as txt for easiest verification.
  6. Return to the main app window and open a new terminal session.
  7. Run a few commands that produce visible output.
  8. Close the session tab.
  9. Open the configured directory in Finder/Explorer.
  10. Verify a host-named subdirectory is created and contains a timestamped log file.
  11. Open the saved file and confirm it contains the terminal output from the closed session.
  12. Optionally repeat with raw and html formats.

Expected result after fix:

  • Closing the session creates a saved file under <configured dir>/<host label>/....
  • The same session is still viewable in Netcatty's Logs page.

Expected result before fix:

  • The Settings window shows auto-save enabled, but no file is written because the main app window is still running with stale session-log settings.

Testing

  • npx eslint App.tsx application/state/useSessionState.ts components/VaultView.tsx application/state/useSettingsState.ts
  • npm run build

Closes #278

@binaricat
Copy link
Owner Author

@codex review

@binaricat binaricat merged commit 71ff995 into main Mar 6, 2026
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.

两个bug: 创建的身份对象不显示以及日志不保存

1 participant