Skip to content

refactor: centralize lastActivity completion-stamp into helper or reason-aware API #444

@mindfn

Description

@mindfn

Background

PR #407 fixed sidebar reorder on thread switch by stamping lastActivity in all invocation-clearing paths. The fix is correct and landed, but the stamping logic is now scattered across multiple store reducers:

  • removeActiveInvocation
  • clearAllActiveInvocations
  • clearAllThreadActiveInvocations
  • clearThreadActiveInvocation
  • resetThreadInvocationState
  • setHasActiveInvocation (true→false transition)

Proposal (from @zts212653 review on #407)

Two options:

  1. Centralize into a helper: Extract a stampCompletion(state, threadId) helper that all clearing paths call, so the stamp logic lives in one place.

  2. Make the clear API reason-aware: Add a reason parameter ('completion' vs 'repair') to the clear functions, so the stamp decision is explicit at the call site rather than implicit in each reducer.

Either approach would:

  • Reduce repeated Date.now() stamping across reducers
  • Make the boundary between "real completion" and "stale repair" explicit
  • Prevent future regressions if new clearing paths are added

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions