Skip to content

docs(logging): add owner session log plan#39

Merged
HusseinBaraja merged 9 commits intomainfrom
dev-watch-and-test-fixes
Apr 21, 2026
Merged

docs(logging): add owner session log plan#39
HusseinBaraja merged 9 commits intomainfrom
dev-watch-and-test-fixes

Conversation

@HusseinBaraja
Copy link
Copy Markdown
Owner

@HusseinBaraja HusseinBaraja commented Apr 21, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved error logging for malformed JSON requests in API.
  • Chores

    • Updated core dependencies including Hono and Vite for improved stability and performance.
    • Refactored development build watch scripts for consistency across packages.
    • Enhanced test infrastructure and logging for better reliability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@HusseinBaraja has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 42 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 42 seconds.

⌛ 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6143994e-3c58-4dac-9a55-4d2273095d61

📥 Commits

Reviewing files that changed from the base of the PR and between 2ea5c59 and 5e973ac.

📒 Files selected for processing (3)
  • apps/api/src/app.ts
  • apps/web/package.json
  • apps/web/src/components/layout/Layout.vitest.tsx
📝 Walkthrough

Walkthrough

This PR consolidates infrastructure improvements across the repository: standardizes development watch scripts by replacing inline Bun watch flags with a centralized root watcher utility across 10+ packages, updates core framework dependencies, refines documentation for conversation session logging contracts, and adjusts test fixtures and mocks for consistency.

Changes

Cohort / File(s) Summary
Documentation & Planning
CONTEXT.md, docs/plans/retrieval-*.md, owner-conversation-session-log-plan.md
Extended CONTEXT.md with explicit schemas for session log filenames, timestamps, headers (Session ID, Company ID, Conversation ID, Started At), and AI background section requirements; removed five completed/consolidated retrieval planning documents; added comprehensive dev-only session log capture plan with phased workstreams and test updates.
Dev Script Standardization
apps/cli/package.json, packages/ai/package.json, packages/config/package.json, packages/convex-api/package.json, packages/core/package.json, packages/db/package.json, packages/rag/package.json, packages/shared/package.json, packages/storage/package.json
Updated dev scripts across 9 package.json files from bun --watch src/index.ts to bun ../../scripts/watch-from-root.ts src/index.ts, centralizing watch behavior via a shared root watcher utility.
Dependency Version Updates
apps/api/package.json, apps/web/package.json, package.json
Bumped @hono/node-server (1.19.9→1.19.13), hono (4.12.4→4.12.14 in API; 4.12.9→4.12.14 in web), @vitejs/plugin-react (4.3.4→6.0.1), and vite (6.1.0→8.0.5, root pinned to 8.0.5).
Test Fixture & Mock Updates
apps/web/src/components/layout/Layout.vitest.tsx, apps/web/src/components/router/HonoRouter.vitest.tsx, apps/web/src/components/sections/SolutionSection.vitest.tsx, apps/web/src/pages/ContactPage.vitest.tsx, scripts/dev-session-log.test.ts
Updated GSAP mock's context function to invoke optional callbacks, expanded Link mock to forward extra props, refactored tween capture from array to mock results, added test cleanup hooks, updated contact text assertion ("مخصص للشركات"), stubbed missing env vars, and silenced console.error in async tests.
Application Code
apps/api/src/app.ts, apps/bot/src/runtime.test.ts, apps/bot/src/sessionManager.test.ts, convex/seed.ts
Changed SyntaxError handler to log fixed error object instead of serialized error; added resolveSocketVersion option to runtime test; passed logger stub to session manager tests; reformatted import statement and function syntax in seed.ts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • chore: clean up bun dev startup warnings #30: Directly related—modifies the same dev/watch tooling infrastructure by updating package.json dev scripts to use centralized watch-from-root utility.
  • Making the bot understand context better #18: Related through RAG/retrieval-logging interfaces—main PR adds typed AI trace payload contracts and capture points in packages/rag; related PR implements retrieval resolution and expanded logging.
  • Polishing the site on mobile #13: Related via overlapping web test files and GSAP mock adjustments (Layout.vitest.tsx, SolutionSection.vitest.tsx), indicating shared test infrastructure changes.

Poem

🐰 Scripts now unified, from scattered calls so wide,
Dependencies bumped, our infra's modernized with pride,
Session logs sketched out, their schemas now defined,
Tests cleaned up and mocks refined—a tidy PR designed! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'docs(logging): add owner session log plan' accurately describes the primary change: adding a comprehensive logging plan document. However, the changeset includes numerous secondary modifications (dependency updates, test fixture changes, dev script refactoring, and deletion of obsolete plan documents) that are not reflected in the title.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-watch-and-test-fixes

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

♻️ Duplicate comments (1)
CONTEXT.md (1)

15-17: ⚠️ Potential issue | 🟡 Minor

Filename contract lacks year/seconds — same collision concern as the plan.

Since the contract defined here (DD-MM-HH-mm.md) is the source of truth the implementation will follow, any collision risk for same-minute restarts or cross-year reuse is locked in at the glossary level. Worth confirming whether overwriting the previous dev-session log on a same-minute restart is intentional; if not, widen the format here and mirror in owner-conversation-session-log-plan.md.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CONTEXT.md` around lines 15 - 17, The filename contract currently specified
as `DD-MM-HH-mm.md` risks collisions; update the contract to include year and
seconds (e.g., include YYYY and ss) so it becomes a unique timestamp format and
mirror this change in owner-conversation-session-log-plan.md; also clarify
whether overwriting a same-minute restart is allowed or if filenames should
always be unique to avoid accidental overwrite.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/api/src/app.ts`:
- Line 268: The SyntaxError branch currently hardcodes error: { name:
"SyntaxError", message: "Malformed JSON body" } which loses the parser's
diagnostic message; replace that hardcoded object with the real serialized error
using serializeErrorForLog(error) but remove or redact the stack field before
logging/returning to avoid leaking body fragments — e.g., call
serializeErrorForLog(error), delete or set stack to undefined on the result, and
use that sanitized object in the same place where ValidationError uses
serializeErrorForLog so you preserve parser details without exposing sensitive
stack content.

In `@apps/web/package.json`:
- Line 17: Add an explicit Node.js engines constraint to the package.json that
pins the minimum Node version required by your Hono dependency (hono 4.12.14
requires Node >=18.14.1); update the root or this workspace package.json to
include an "engines" field (e.g., "engines": { "node": ">=18.14.1" }) so runtime
compatibility is documented and enforced alongside the existing "hono":
"4.12.14" entry.
- Around line 27-32: The package.json currently pins "vitest": "^4.0.18" which
is incompatible with vite@8.0.5; update the dependency entry for vitest to
"vitest": "^4.1.0" (or later) so Vitest supports Vite 8; locate the vitest
dependency in apps/web package.json and bump the version string to "^4.1.0" and
run your lockfile update (npm/yarn/pnpm install) to regenerate the lockfile and
ensure `@vitejs/plugin-react` remains satisfied.

In `@apps/web/src/components/layout/Layout.vitest.tsx`:
- Around line 72-76: The test currently uses
expect(watermarkImage).toBeDefined(), which doesn't fail when querySelector
returns null; update the assertion in
apps/web/src/components/layout/Layout.vitest.tsx to assert presence properly by
replacing toBeDefined() with expect(watermarkImage).toBeTruthy() (or
expect(watermarkImage).toBeInTheDocument() if jest-dom is available) so the
watermarkImage variable (queried with container.querySelector('footer
img.h-150.md\\:h-225')) will cause the test to fail when the element is missing.

In `@owner-conversation-session-log-plan.md`:
- Around line 113-121: The outer fenced example block is closed prematurely by
inner ```json fences; fix by changing the outer fence to a longer sequence
(e.g., four backticks) or by replacing the inner code fences with tildes so they
don't match the outer fence; update the outer example block’s opening and
closing markers (the outer fenced code block around the example) to use ```` (or
adjust inner fences to ~~~json) so the inner JSON blocks for "```json { \"...\":
\"...\" } ```" and "```json { \"...\": \"...\" } ```" render correctly.
- Around line 9-10: The root-level filename format `DD-MM-HH-mm` in the plan
risks collisions; update the plan to use a collision-safe scheme (e.g., change
the filename format to include year and seconds like `YYYY-MM-DD-HH-mm-ss` or
add a short random/UUID suffix) and/or explicitly document overwrite behavior in
the Acceptance Criteria / Non-Goals and in CONTEXT.md so consumers know
lazy-file-creation can stomp files started in the same minute; make this change
to the "Root-level filename format" line and the relevant acceptance/non-goals
text.

---

Duplicate comments:
In `@CONTEXT.md`:
- Around line 15-17: The filename contract currently specified as
`DD-MM-HH-mm.md` risks collisions; update the contract to include year and
seconds (e.g., include YYYY and ss) so it becomes a unique timestamp format and
mirror this change in owner-conversation-session-log-plan.md; also clarify
whether overwriting a same-minute restart is allowed or if filenames should
always be unique to avoid accidental overwrite.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c1a7be05-e166-4dc7-9e02-defb0477b84f

📥 Commits

Reviewing files that changed from the base of the PR and between 165c3e4 and 2ea5c59.

📒 Files selected for processing (29)
  • CONTEXT.md
  • apps/api/package.json
  • apps/api/src/app.ts
  • apps/bot/src/runtime.test.ts
  • apps/bot/src/sessionManager.test.ts
  • apps/cli/package.json
  • apps/web/package.json
  • apps/web/src/components/layout/Layout.vitest.tsx
  • apps/web/src/components/router/HonoRouter.vitest.tsx
  • apps/web/src/components/sections/SolutionSection.vitest.tsx
  • apps/web/src/pages/ContactPage.vitest.tsx
  • convex/seed.ts
  • docs/plans/retrieval-catalog-language-hints-plan.md
  • docs/plans/retrieval-intent-rewrite-plan.md
  • docs/plans/retrieval-provenance-prompt-expansion-plan.md
  • docs/plans/retrieval-rewrite-dedicated-model-plan.md
  • docs/plans/retrieval-rewrite-structured-output-plan.md
  • docs/plans/retrieval-spelling-variation-plan.md
  • owner-conversation-session-log-plan.md
  • package.json
  • packages/ai/package.json
  • packages/config/package.json
  • packages/convex-api/package.json
  • packages/core/package.json
  • packages/db/package.json
  • packages/rag/package.json
  • packages/shared/package.json
  • packages/storage/package.json
  • scripts/dev-session-log.test.ts
💤 Files with no reviewable changes (6)
  • docs/plans/retrieval-rewrite-dedicated-model-plan.md
  • docs/plans/retrieval-catalog-language-hints-plan.md
  • docs/plans/retrieval-rewrite-structured-output-plan.md
  • docs/plans/retrieval-intent-rewrite-plan.md
  • docs/plans/retrieval-provenance-prompt-expansion-plan.md
  • docs/plans/retrieval-spelling-variation-plan.md
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use the @cs/* path aliases from tsconfig.base.json for cross-package imports

Files:

  • apps/web/src/components/router/HonoRouter.vitest.tsx
  • apps/api/src/app.ts
  • convex/seed.ts
  • scripts/dev-session-log.test.ts
  • apps/bot/src/runtime.test.ts
  • apps/web/src/components/sections/SolutionSection.vitest.tsx
  • apps/web/src/pages/ContactPage.vitest.tsx
  • apps/bot/src/sessionManager.test.ts
  • apps/web/src/components/layout/Layout.vitest.tsx
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: For core logic .ts files, do not add a new responsibility to an existing file when it should be a sibling module
No new core logic .ts file may exceed 240 LOC without an explicit entry in modularity-policy.json
If a core logic file already exceeds 240 LOC, it must not grow unless its modularity-policy.json entry is intentionally updated with rationale
Files classified as must_split in modularity-policy.json are debt containers: patches are allowed, but adding unrelated responsibilities is not

Files:

  • apps/api/src/app.ts
  • convex/seed.ts
  • scripts/dev-session-log.test.ts
  • apps/bot/src/runtime.test.ts
  • apps/bot/src/sessionManager.test.ts
🧠 Learnings (6)
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Run `bun lint` after code changes

Applied to files:

  • packages/storage/package.json
  • packages/shared/package.json
  • packages/convex-api/package.json
  • packages/rag/package.json
  • packages/config/package.json
  • packages/core/package.json
  • packages/db/package.json
  • packages/ai/package.json
  • apps/cli/package.json
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Run all repo scripts from the repository root with `bun`

Applied to files:

  • packages/storage/package.json
  • packages/shared/package.json
  • packages/convex-api/package.json
  • packages/rag/package.json
  • packages/config/package.json
  • packages/core/package.json
  • packages/db/package.json
  • packages/ai/package.json
  • apps/cli/package.json
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Run `bun dev` to test if there are no issues with the dev environment

Applied to files:

  • packages/storage/package.json
  • packages/shared/package.json
  • packages/convex-api/package.json
  • packages/rag/package.json
  • packages/config/package.json
  • packages/core/package.json
  • packages/db/package.json
  • apps/cli/package.json
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Run `bun generate` after any Convex schema change

Applied to files:

  • packages/convex-api/package.json
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Use `bun test` for the specific aspect you modified, e.g: `bun test:convex` for Convex changes

Applied to files:

  • packages/convex-api/package.json
📚 Learning: 2026-04-21T07:16:17.696Z
Learnt from: CR
Repo: HusseinBaraja/CS PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-21T07:16:17.696Z
Learning: Applies to **/*.{ts,tsx} : Use the `cs/*` path aliases from `tsconfig.base.json` for cross-package imports

Applied to files:

  • packages/config/package.json
🪛 markdownlint-cli2 (0.22.0)
owner-conversation-session-log-plan.md

[warning] 118-118: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


[warning] 120-120: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


[warning] 121-121: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


[warning] 121-121: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (20)
packages/shared/package.json (1)

9-9: LGTM — shared package uses the root watcher correctly.

The wrapper path and src/index.ts entrypoint are consistent with the package layout and the provided scripts/watch-from-root.ts behavior.

packages/rag/package.json (1)

9-9: LGTM — dev script is wired consistently.

src/index.ts is passed as the package-local entry, and the shared watcher handles repo-root execution.

packages/convex-api/package.json (1)

9-9: LGTM — Convex API wrapper remains cleanly separated.

This watches the re-export entrypoint while leaving Convex codegen to the existing root generate workflow.

packages/storage/package.json (1)

9-9: LGTM — storage dev script matches the shared watcher pattern.

The package-local src/index.ts entrypoint is passed correctly to the repo-root watcher.

packages/config/package.json (1)

9-9: LGTM — config package follows the centralized watcher flow.

The command points to the shared wrapper with the expected package entrypoint.

packages/db/package.json (1)

9-9: LGTM — db dev script is consistent with the repo watcher migration.

No issue with the wrapper path or entrypoint.

packages/ai/package.json (1)

13-13: LGTM — AI package watcher entry is correct.

The default src/index.ts entry is preserved, and subpath exports are unaffected by this script change.

packages/core/package.json (1)

9-9: LGTM — core package is aligned with the shared watcher.

The script path and src/index.ts entrypoint look correct.

package.json (1)

45-45: Keep this covered by the Vite 8 compatibility check.

The root pin matches apps/web, so no separate concern beyond verifying the Vite/plugin/Vitest peer and engine compatibility noted for the web workspace.

convex/seed.ts (2)

6-6: LGTM.

The import still preserves the type-only boundary for ProductEmbeddingVariantAttributes.


97-97: LGTM.

This is a behavior-neutral syntax/formatting change.

apps/bot/src/sessionManager.test.ts (2)

877-881: LGTM.

Injecting the logger stub keeps this failure-path test isolated from the default logger.


2126-2128: LGTM.

The outbound failure test now uses the same captured logger pattern as the other session-manager error-path tests.

apps/bot/src/runtime.test.ts (1)

277-282: LGTM.

Providing a fixed socket version makes this lifecycle/logging test deterministic.

apps/web/src/components/router/HonoRouter.vitest.tsx (1)

1-9: LGTM.

Explicit RTL cleanup in afterEach prevents rendered DOM leakage across router tests.

apps/cli/package.json (1)

10-10: No issue—.env loading is properly maintained through the shared watcher.

scripts/watch-from-root.ts resolves the root .env and passes --env-file=${envFile} to the bun invocation (line 26), preserving the same environment loading behavior as the explicit --env-file=../../.env that was previously in the dev script.

apps/api/package.json (1)

19-20: Versions are compatible. @hono/node-server@1.19.13 requires hono ^4, which 4.12.14 satisfies. No peer dependency conflicts or missing requirements detected.

scripts/dev-session-log.test.ts (1)

71-83: LGTM on console.error suppression.

Snapshot/restore pattern in a finally block is correct and keeps stderr clean during the expected error emission.

apps/web/src/pages/ContactPage.vitest.tsx (1)

14-19: LGTM — cleanup() plus env/mocks reset is the right shape for vitest + RTL.

apps/web/src/components/sections/SolutionSection.vitest.tsx (1)

177-196: LGTM — deriving tweens from gsapFromTo.mock.results is more robust than the prior shared array.

Coupling assertions to call order (results[0]/results[1]) with an explicit toHaveBeenCalledTimes(2) guard makes the test less dependent on helper internals.

Comment thread apps/api/src/app.ts Outdated
Comment thread apps/web/package.json
Comment thread apps/web/package.json
Comment thread apps/web/src/components/layout/Layout.vitest.tsx
Comment thread owner-conversation-session-log-plan.md
Comment thread owner-conversation-session-log-plan.md
@HusseinBaraja HusseinBaraja merged commit a91d6f8 into main Apr 21, 2026
1 check passed
@HusseinBaraja HusseinBaraja deleted the dev-watch-and-test-fixes branch April 21, 2026 13:41
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.

1 participant