All Sessions

Plan: E2E Tests for Instructor Chat

February 17, 20263:02 PM6:46 PM(3h 44m)14 turns
Model: claude-opus-4-6, claude-sonnet-4-5-20250929
Read24Bash18Grep10Edit8Glob7Write2ExitPlanMode2EnterPlanMode1Task1AskUserQuestion1
3:02 PM

Implement the following plan:

Plan: E2E Tests for Instructor Chat

Context

The /instructors page now has a chat sidebar (desktop) and bottom sheet (mobile). We need e2e tests covering layout, responsive behavior, and live chat functionality.

Files to Modify

FileAction
apps/web/components/instructor-chat.tsxAdd data-testid attributes
testing/e2e/tests/instructor-chat.spec.tsCreate test file
testing/e2e/playwright.config.tsRegister new project

Step 1: Add data-testid attributes to instructor-chat.tsx

Add testids to key elements in the component:

  • instructor-chat-sidebar — desktop sidebar wrapper
  • instructor-chat-greeting — greeting text
  • instructor-chat-input — text input field
  • instructor-chat-submit — submit button
  • instructor-chat-form — form element
  • instructor-chat-user-message — on each user message div
  • instructor-chat-assistant-message — on each assistant message div
  • instructor-chat-loading — "thinking..." indicator
  • instructor-chat-mobile-button — floating Chat button
  • instructor-chat-mobile-sheet — bottom sheet container
  • instructor-chat-mobile-backdrop — backdrop overlay

Step 2: Create testing/e2e/tests/instructor-chat.spec.ts

Following patterns from terminal-prompt.spec.ts (same streaming chat pattern, no auth needed).

Desktop layout tests:

  • Page loads with instructors-page visible
  • Desktop sidebar is visible with greeting, input, and submit button

Chat functionality (no auth, uses live API):

  • Submit a message → user message appears → assistant response streams in (60s timeout)
  • Response is substantive (>50 chars, not an error)

Mobile responsive tests (using iPhone 14 viewport):

  • Desktop sidebar is hidden at mobile width
  • Floating chat button is visible
  • Clicking button opens bottom sheet with chat UI
  • Clicking backdrop closes the sheet

Step 3: Register instructor-chat project in playwright.config.ts

Add entry following the standard pattern with dependencies: deps.

Verification

cd testing/e2e && bunx playwright test --project=instructor-chat

If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ~/.claude/projects/-Users-challen-www-usingandunderstanding-ai/20fe4f86-713e-4f6e-8bd3-3742033059b6.jsonl

I'll start by reading all the files I need to modify in parallel.

The component already has all data-testid attributes and the playwright config already has the project registered. I just need to create the test file and update the window title per your request.

Let me check if there's already a test file.

The test file already exists with all the tests from the plan. I just need to update the window title as you requested.

Read4Glob1
3:03 PM

But wait, you're fixing the height, right?

Can you clarify which height issue you're referring to? Is it the desktop sidebar's h-[calc(100vh-8rem)] on the ChatUI (line 208 of instructor-chat.tsx), or something else?

3:03 PM

Cool! Now, the sidebar is just a bit too tall, scrolling a bit with the page just slightly. Can we calculate the height more carefully so that it's fully fixed? Also, how could would it be if the suggested "Ask about..." responded to the page position: "Ask about conversational assessment..." "Ask about in-class activities..." Etc.

Let me look at the page layout to understand the height calculation and content sections.

Good questions. Let me check how the page layout works — there's probably a nav header affecting the height calculation.

The header is h-14 (56px). Let me check if it's sticky/fixed and see the exact layout.

Now I have the full picture. The header is sticky top-0 with h-14 (56px), but the sidebar uses top-12 (48px) — so it's actually slightly overlapping the header. And the fixed h-[calc(100vh-8rem)] on ChatUI plus the title bar makes the sidebar column taller than the viewport, causing the slight scroll.

Let me fix both issues: the height calculation and add the dynamic placeholder.

Now I have the full picture. Here's what needs to happen:

  1. Height fix: top-12 (48px) doesn't clear the h-14 (56px) header → change to top-16 (64px, giving 8px breathing room). Then set the bordered container to h-[calc(100vh-5.5rem)] with flex layout, so ChatUI fills remaining space.

  2. Window title: "ask about the course" → "Understanding Understanding AI"

  3. Dynamic placeholder: Use IntersectionObserver to watch h2 elements on the page and update the placeholder based on visible section.

Now update the input to use the placeholder prop:

Now fix the height, update the title, wire up the placeholder, and make the container use flex layout:

Now pass the placeholder to the mobile ChatUI too:

Let me verify the final state of the file:

Good, the component looks correct. Now let me also update the E2E test to verify the window title text since we changed it:

The tests look good as-is. Now let me check that the dev server is running and run the tests:

All 9 tests pass. Here's a summary of the changes:

apps/web/components/instructor-chat.tsx:

  1. Height fix: Changed sticky top-12top-16 (properly clears the 56px header with 8px breathing room). Set the bordered container to h-[calc(100vh-5.5rem)] flex flex-col so it fills the viewport precisely, with ChatUI using min-h-0 flex-1 to fill remaining space.

  2. Window title: Changed "ask about the course" → "Understanding Understanding AI"

  3. Dynamic placeholder: Added useVisibleSection() hook that uses IntersectionObserver on the page's h2 elements. As you scroll through sections, the input placeholder updates contextually:

    • "Ask about conversational assessment..."
    • "Ask about in-class activities..."
    • "Ask about reading preparation..."
    • "Ask about AI in course operations..."
    • "Ask about course structure..."
    • "Ask about meetings..."
Read6Edit4Grep3Glob2Bash2
3:23 PM

It's still too tall. Let's call it Understanding AI.

Two changes: fix the title text and fix the height. The root issue is that the sidebar's height plus the page padding (header 56px + py-12 top/bottom = 152px total overhead) exceeds 100vh. I'll add a negative bottom margin so the sidebar doesn't inflate the page height while keeping its full visual size.

Now let me verify the tests still pass:

All passing. Here's what changed:

  1. Title: "Understanding Understanding AI" → "Understanding AI"
  2. Height fix: Added lg:-mb-16 to the sidebar wrapper. This gives the grid item a negative bottom margin so the sidebar doesn't inflate the page height beyond the prose content, while keeping its full visual size (100vh - 5.5rem). The sidebar fills from top-16 (64px below viewport top) to 24px above the viewport bottom, with zero page scroll caused by the sidebar column.
Edit2Bash1
3:39 PM

It's still too tall.

I can see the input is getting clipped at the bottom. Let me increase the height deduction.

That changes the bottom edge from 24px to 64px (4rem) above the viewport bottom — should give comfortable clearance. Tests should still pass since they just check visibility.

All 9 tests pass. The sidebar height is now 100vh - 8rem — the bottom should sit 64px above the viewport edge, giving clear space for the input field and button.

Edit1Bash1
5:28 PM

Your task

First, run git status, git diff, and git log --oneline -10 to understand the current state.

Then add and commit all modified files with a descriptive message. Break the changes into multiple commits if appropriate. If there are untracked files, ask if they should be added or added to the appropriate .gitignore file. The user may also want to take over at this point, so provide an abort option as well. Always check changes for unnecessary debugging statements or logging that might have been accidentally included. Prompt the user if you find any, and offer to remove each one by one. Do not use interactive git staging (git add -p) as it does not work.

I'll check the current git state and prepare to commit the changes.

The changes look good — no debug statements or logging. The diff shows:

  1. Dynamic placeholder: Added useVisibleSection() hook with IntersectionObserver to update placeholder based on visible h2 sections
  2. Fixed height: Changed top-12top-16, added lg:-mb-16, changed height to calc(100vh-8rem) with flex layout
  3. Updated title: "ask about the course" → "Understanding AI"
  4. Prettier formatting: Auto-formatted line breaks (this is expected)

This builds on top of the existing instructor chat E2E tests from commit 4262ce8. I'll commit these enhancements:

✓ Committed successfully! The working tree is clean.

Summary of changes:

  • Dynamic placeholder that responds to scroll position (updates based on visible h2 sections)
  • Fixed sidebar height calculation to prevent overflow
  • Updated window title to "Understanding AI"
  • All E2E tests passing (9/9)
Bash5
6:19 PM

Your task

First, run git status, git diff, and git log --oneline -10 to understand the current state.

Then add and commit all modified files with a descriptive message. Break the changes into multiple commits if appropriate. If there are untracked files, ask if they should be added or added to the appropriate .gitignore file. The user may also want to take over at this point, so provide an abort option as well. Always check changes for unnecessary debugging statements or logging that might have been accidentally included. Prompt the user if you find any, and offer to remove each one by one. Do not use interactive git staging (git add -p) as it does not work.

I'll check the current git state.

The changes look clean — just a version bump from 2026.2.14 to 2026.2.15 across all package.json files. No debug statements or logging to remove. Following the date-based versioning scheme (same month, increment minor).

✓ Committed successfully! The working tree is clean.

Summary:

  • Version bumped from 2026.2.14 → 2026.2.15 across all 23 package.json files
  • Branch is 1 commit ahead of origin/main
Bash5
6:22 PM
6:26 PM

Can we name these by UIN rather than by names, which might not be unique? And yes, we can remove ROSTER.mhtml.

Let me re-extract the name-to-UIN mapping from the MHTML, rename the files, and remove ROSTER.mhtml.

I have the full mapping. Let me rename all the files to UINs and remove the MHTML.

Done. Photos renamed to {uin}.jpg and ROSTER.mhtml removed. The data/spring2026/photos/ directory now has 12 files named by UIN.

Bash3Grep1Read1
6:27 PM

Are the UINs in the HTML?

6:28 PM
6:29 PM
6:31 PM

Nope, they are not .gitignored. Let's leave them for now and see how we go. OK, next, I'd like a simple instructor-only page perhaps at /roster that shows enrolled students and their photo. If an enrolled student doesn't have a photo, use the site logo instead. Let's also display their email address using mailto.

Let me check a few more specifics.

Now let me check how the API serves photos — I'll need a photo-serving endpoint.

Good — the API already uses git-root-dir to locate the monorepo root. Now let me check the admin assessments page for the UI pattern since it's another instructor-only page.

I have everything I need. Let me write up the plan.

Read11Grep6Glob4Write2EnterPlanMode1Task1Bash1ExitPlanMode1
6:44 PM

Actually, is there an existing page where we could incorporate the photos? Also access to the photos has to be limited to instructors.

Good question. The /enrollment page already shows enrolled students. Let me check how it displays them.

The closest existing page is /enrollment — it already lists students with names, emails, badges, and a Canvas sync button. But it's a data management page (filters, status badges, sync controls). Adding a photo grid might clutter its purpose.

Good — new /roster page. The plan is already written. Let me update it to clarify the instructor-only photo access requirement.

Read2AskUserQuestion1Edit1ExitPlanMode1