Skip to content

fix(app): use last user message time in sidebar#471

Merged
Astro-Han merged 2 commits into
devfrom
codex/i470-sidebar-session-time
May 6, 2026
Merged

fix(app): use last user message time in sidebar#471
Astro-Han merged 2 commits into
devfrom
codex/i470-sidebar-session-time

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wire PawWork sidebar session rows to the existing last-user-message timestamp helper.
  • Keep sidebar display time and time sorting on the same computed timestamp.
  • Add focused regression coverage for the row-building path that feeds the sidebar.
  • Avoid pinning child stores while reading loaded message caches for sidebar timestamps.

Why

The PawWork sidebar row builder in layout.tsx was still writing created: session.time.created, so a session could look stale after the user sent a new message. The existing pawworkSidebarSessionTime helper already has the intended contract: use the latest valid loaded user message time, otherwise fall back to session creation time.

Related Issue

Closes #470

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

Please check that the layout.tsx PawWork session window path now passes the per-session message cache into the shared helper without bootstrapping or pinning child stores, and that missing message caches still fall back to creation time.

Risk Notes

Low. This changes the timestamp source for loaded sidebar rows only. No backend API, persistence schema, desktop packaging, updater, or generated-file changes are included. Sorting by time changes with the displayed timestamp, which is intended for this bug.

The global session window is still selected by the existing created-time API window; this PR intentionally fixes only timestamps for rows already in the PawWork sidebar window.

How To Verify

TDD red check: focused app unit test failed before implementation because buildPawworkSidebarSessionRows was not exported.
Focused app tests: bun --cwd packages/app test --preload ./happydom.ts ./src/pages/layout/pawwork-session-source.test.ts -> 916 pass, 0 fail
App typecheck: bun --cwd packages/app typecheck -> tsgo -b completed successfully
Workspace typecheck: bun turbo typecheck -> 8 successful, 8 total
Diff check: git diff --check -> no whitespace errors
Desktop startup check: bun run dev:desktop built main/preload/renderer and started the Electron app, but this machine already had another PawWork dev Electron instance using the shared dev profile, so I could not complete the interactive sidebar click-through in this worktree.

Screenshots or Recordings

Not captured. The Electron manual path was blocked by an existing local PawWork dev instance using the shared ai.pawwork.desktop.dev profile. The code change is data wiring for existing sidebar UI, with no layout or copy changes.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has type, primary area, and priority labels, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

@Astro-Han Astro-Han added bug Something isn't working P1 High priority app Application behavior and product flows labels May 6, 2026
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 55 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d7e24e77-d80c-47aa-af4c-cc5fd19715a6

📥 Commits

Reviewing files that changed from the base of the PR and between 734483c and 895c3ca.

📒 Files selected for processing (3)
  • packages/app/src/pages/layout.tsx
  • packages/app/src/pages/layout/pawwork-session-source.test.ts
  • packages/app/src/pages/layout/pawwork-session-source.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i470-sidebar-session-time

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces the buildPawworkSidebarSessionRows utility function to centralize the logic for preparing session data for the sidebar. It refactors the Layout component to use this new function and includes corresponding unit tests. I have no feedback to provide.

@Astro-Han

Copy link
Copy Markdown
Owner Author

Review follow-up handled:

  • P2 child-store lifecycle: fixed in 895c3ca0b by reading the message cache with globalSync.child(session.directory, { bootstrap: false, pin: false }). This keeps the original no-bootstrap behavior and also avoids pinning stores just for sidebar timestamp calculation. I did not add a new accessor in this PR because the existing ChildOptions.pin contract already covers the immediate lifecycle risk without adding another global-sync API.
  • P3 missing-cache fallback coverage: fixed in 895c3ca0b with a row-builder test proving missing messagesForSession falls back to session.time.created.
  • P3 global window selection: intentionally not changed. [Bug] Sidebar session timestamp shows creation time instead of last user message time #470 is about timestamps for rows already in the PawWork sidebar window. Changing the global session window selection/pagination contract to last-user-message time would require backend/API or indexed query semantics and should be a separate product/API issue if desired.

Fresh checks after the follow-up:

Focused app tests: bun --cwd packages/app test --preload ./happydom.ts ./src/pages/layout/pawwork-session-source.test.ts -> 916 pass, 0 fail
App typecheck: bun --cwd packages/app typecheck -> tsgo -b completed successfully
Diff check: git diff --check -> no whitespace errors

@Astro-Han

Copy link
Copy Markdown
Owner Author

Latest review follow-up:

Latest CI status checked after 895c3ca0: all visible PR checks are passing, including typecheck, unit-app, unit-desktop, unit-opencode, e2e-artifacts, CodeQL, and smoke-macos-arm64.

@Astro-Han Astro-Han merged commit 9f5ce8a into dev May 6, 2026
22 checks passed
@Astro-Han Astro-Han deleted the codex/i470-sidebar-session-time branch May 6, 2026 10:52
Astro-Han added a commit that referenced this pull request May 6, 2026
Root cause:
PawWork sidebar rows could display a latest user-message timestamp after PR #471, but the initial session window was still selected by session creation time. An old root session with recent real user input could stay outside the first sidebar page.

What changed:
- Added experimental.session.list sort=activity for global root sessions.
- Defined activityAt as latest eligible real user message time, falling back to session creation time.
- Added deterministic activity pagination with activityAt desc and session id asc.
- Excluded assistant-only updates, session.time.updated, compaction messages, and synthetic-only user messages from activity promotion.
- Preserved real user messages that also carry synthetic reminder parts.
- Updated PawWork sidebar initial window and row timestamp/sort logic to use backend activity metadata, with local parts-aware freshness only when eligibility is known.
- Regenerated v2 SDK types for sort=activity, activityAt, and lastUserMessageAt.
- Split oversized sidebar source tests into focused files.

Verification:
- bun --cwd packages/sdk/js build
- bun --cwd packages/opencode test --timeout 30000 ./test/server/global-session-activity-list.test.ts ./test/server/global-session-list.test.ts -> 21 pass
- bun --cwd packages/app test --preload ./happydom.ts ./src/pages/layout/pawwork-sidebar-session-time.test.ts ./src/pages/layout/pawwork-sidebar-session-rows.test.ts ./src/pages/layout/pawwork-session-window.test.ts -> 927 pass
- bun --cwd packages/opencode typecheck
- bun --cwd packages/app typecheck
- bun turbo typecheck -> 8 successful
- git diff --check
- desktop focused checks were also run and passed before merge.
- GitHub checks were green at head 76740c9.

Known follow-ups intentionally not included:
- Pinned or active sessions outside the activity first page still need activity-aware by-id hydration to avoid cold-start fallback to creation time.
- Large local histories may need EXPLAIN/query benchmarks and possibly a materialized activity field or index.
- lastUserMessageAt is optional and may be omitted in the edge case where the real user message timestamp equals session creation time; activityAt remains correct.

Closes #473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows bug Something isn't working P1 High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Sidebar session timestamp shows creation time instead of last user message time

1 participant