Skip to content

feat(web): filter sessions by last activity#1083

Merged
tiann merged 2 commits into
tiann:mainfrom
techotaku39:feat/web-session-time-filter
Jul 19, 2026
Merged

feat(web): filter sessions by last activity#1083
tiann merged 2 commits into
tiann:mainfrom
techotaku39:feat/web-session-time-filter

Conversation

@techotaku39

Copy link
Copy Markdown
Contributor

Summary

Adds a compact last-activity date-range filter to the web session list.

  • places a calendar action beside the existing session search field
  • uses the first calendar selection as the start date and the second as the inclusive end date
  • applies date and text filters together and expands matching session groups
  • shows an active indicator for an applied range and supports clearing or navigating months
  • keeps date boundaries in the browser's local timezone

Motivation

Long-running HAPI installations can accumulate many sessions. Text search helps when a title or path is known, but it is less useful when the user only remembers when a session was active. The filter stays out of the way until needed and preserves the compact mobile layout.

Test plan

  • Helper coverage for local-time inclusive range boundaries
  • UI coverage for first-click start / second-click end selection
  • UI coverage that the completed range filters sessions
  • Focused tests: 43 passed
  • Full web test suite: 1281 passed
  • Web TypeScript check: tsc --noEmit
  • Production build: bun run build
  • Manual mobile verification on the port 3016 test deployment

AI disclosure

Implementation and tests were assisted by OpenAI Codex (GPT-5.6).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • [Minor] Hard-coded calendar dates make the new UI tests time-dependent — the picker opens on new Date() when no range is selected, while the test searches for July 2026 day buttons and uses Date.now() for the session timestamp. Once the runner date is outside that month/range, these buttons will not exist or the “recent” session will be filtered out. Evidence: web/src/components/SessionList.directory-action.test.tsx:137 and web/src/components/SessionList.directory-action.test.tsx:166.
    Suggested fix:
    import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
    
    describe('SessionList time filter', () => {
        beforeEach(() => {
            vi.useFakeTimers()
            vi.setSystemTime(new Date(2026, 6, 18, 12))
        })
    
        afterEach(() => {
            vi.useRealTimers()
        })
    
        // existing July 2026 assertions stay deterministic
    })

Questions

  • None.

Summary

  • Review mode: initial
  • One test determinism issue found. No product-code correctness, security, data-loss, or performance findings with >=80% confidence from the changed lines.

Testing

  • Not run (automation; PR content was not executed).

HAPI Bot

expect(screen.getByRole('button', { name: /Old session/ })).toBeInTheDocument()

fireEvent.click(screen.getByRole('button', { name: 'Filter sessions by last activity' }))
fireEvent.click(screen.getByRole('button', { name: new Date(2026, 6, 17).toLocaleDateString() }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MINOR] This hard-coded July 2026 selection is coupled to the picker’s current-month default and the session’s Date.now() timestamp. When the test runs outside July 17-18, 2026, the date buttons will not exist or the recent session will be outside the selected range. The same issue appears in the second added test’s July 2026 clicks.

Suggested fix:

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

describe('SessionList time filter', () => {
    beforeEach(() => {
        vi.useFakeTimers()
        vi.setSystemTime(new Date(2026, 6, 18, 12))
    })

    afterEach(() => {
        vi.useRealTimers()
    })

    // existing July 2026 assertions stay deterministic
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 672cc71 by pinning the system clock with Vitest fake timers for the date-range UI tests. Focused tests and the web typecheck pass.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings

  • None.

Questions

  • None.

Summary

  • Review mode: follow-up after new commits
  • No issues found with >=80% confidence in the latest diff. The prior test determinism finding appears addressed by the new fake-timer setup. Residual risk: date-picker keyboard behavior and mobile layout were inspected statically only.

Testing

  • Not run (automation; PR content was not executed).

HAPI Bot

@tiann
tiann merged commit 2623a51 into tiann:main Jul 19, 2026
3 checks passed
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.

2 participants