Public: anyone can read this; the crew can change it.

Talk opens on the conversation the person was in, at the place they left it #18322

opened this

Merged 11h 42m ago, live in production

Talk now opens on the conversation you were last in, at the turn you were reading. The place is kept per person on the server, so a refresh, a new tab or a new sign-in all land there. The new test, the other Talk and conversation tests and the type check pass.

Notes

opened this

Talk now opens on the conversation you were last in, at the turn you were reading. The place is kept per person on the server, so a refresh, a new tab or a new sign-in all land there. The new test, the other Talk and conversation tests and the type check pass. I did not run the full suite, and I did not run the two check rules named in the issue ("dead code" and "duplicate import") on their own.

What changed

  • Stored place: a new table talk_place holds one row per person: their conversation and the top turn on screen. src/core/talk_place.ts reads and writes it. The row is deleted with the person or the conversation.
  • Which conversation opens: openConversation now returns the conversation you last opened, if it is still yours and not archived. Otherwise it picks your newest active one, else a new empty one. The terminal and the API's unnamed-conversation sends follow the same rule.
  • When it is kept: opening /talk or /talk/<id> on the page keeps the place (pane and build fragments don't). So does opening a chat in the terminal. src/tui/screens/talk_chats.ts does that, so the terminal shows the same place.
  • Scroll place: the page sends the top turn to a new POST /talk/place when you leave or stop scrolling. The server checks the id format, the same-origin rule, that the conversation is yours, and that the turn belongs to it.
  • Reopening: the page opens on that turn through the existing pageAround.
  • Empty conversation: the box is focused with autofocus, so it works without JavaScript.
  • Docs: docs/features/talk-place.md.
  • Test: test/talk-place.test.ts opens an older chat, reloads three times, signs in again and checks it is still there. It also covers the scroll place, bad input, another person's conversation or turn, a cross-origin post, and an archived or deleted conversation. It fails without the change.

Changed existing test

  • Edit: test/talk-links-click.test.ts created a conversation and expected /talk/stream to open it as the newest. It now names the conversation with c=.
  • Why: the open conversation is now the one you last visited.

Left out

  • Scroll resolution: scroll is kept as a turn, not pixels.
  • Deleted conversation: it falls back to your newest remaining conversation, else a new empty one, rather than always a new empty one.
  • New conversations: conversations made by the API or the crew do not take your place; only opening one does.
  • Autofocus on phones: autofocus on an empty Talk may bring up the keyboard.

Reused: pageAround, the existing readForm same-origin and scope check, and the migration pin tooling. The gate's similarity notes (keepOpen against recordInstalled, the test mk) are not reuses I can use here.

Try: open an older chat at /talk/<id>, scroll, then open /talk in a new tab. It lands on that chat at that turn. A fresh account's /talk has the box focused.

[
 {"go":"/talk","look":"Open an older chat from the list, scroll up a few turns, then open /talk in a new tab","expect":"The page opens on that chat, with the turn you were reading at the top"},
 {"go":"/talk","look":"Sign out, sign in again, open /talk","expect":"Same chat, same place"},
 {"go":"/talk","look":"Press New on an account with no conversations","expect":"An empty conversation opens with the message box focused"}
]

🤖 Generated with Claude Code

Closes #18317

Show 1 earlier items

7 earlier comments
commented

<!-- look-pages db7641e137f1 --> Look pages for db7641e, from the gate:

  • look pages (named): this pull changes src/web/pages/talk.ts, src/web/pages/talk_client.ts; a commit names /talk
commented

I pushed a fix for the failing page-budget test. /talk was at 65 SQL statements against a budget of 64, because opening a conversation ran one statement to keep the place and a second to read it back. One statement now does both: keepOpen returns the stored scroll turn, so /talk is back to one extra statement over the original.

The type check passes. test/pages-budget.test.ts, test/talk-place.test.ts and test/talk-links-click.test.ts pass (20 tests, none failing). I did not re-run the full suite; the forge's check does that on this push.

The pull's behaviour is unchanged:

  • /talk opens on the last conversation at the turn left.
  • POST /talk/place validates its input.
  • An empty Talk has the box focused.

🤖 Generated with Claude Code

commented

<!-- look-pages f4522e8c8123 --> Look pages for f4522e8, from the gate:

  • look pages (named): this pull changes src/web/pages/talk.ts, src/web/pages/talk_client.ts; a commit names /talk
commented

Talk now opens on the conversation the person last visited, at the turn they left. I've pushed a fix for the failing check, but I couldn't confirm it. This sandbox has no Chromium, so talk-preview-frame and the three talk-phone suites were skipped here. The forge's run of the check is the first real test of the fix. tsc and test/talk-place.test.ts pass locally.

Cause. Two behaviours of the place feature clashed with the browser tests:

  • talk-preview-frame: the test made a new conversation and then opened bare /talk. /talk now opens the last-visited conversation, which was an earlier test's, so the frame didn't show the app. The test now opens /talk/<id> for the conversation it made.
  • talk-phone-360, -375 and -390: I haven't confirmed why these failed. My best explanation is that they open /talk/<id> repeatedly in one session, and a repeat visit jumped to the saved turn instead of the end of the chat. A saved turn is now restored only on bare /talk, so a conversation named by its address always opens at its end. Treat this as a guess until the check runs.

Not done. Reloading /talk/<id> no longer returns to your scroll place. I narrowed it because bare /talk is what the issue asks for. The empty-conversation autofocus is kept, in case it also shifts the phone layout.

Try it. Open a long conversation, scroll up, then open /talk in a new tab. It lands on that conversation at the same turn.

commented

<!-- look-pages 4813f145c8ab --> Look pages for 4813f14, from the gate:

  • look pages (named): this pull changes src/web/pages/talk.ts, src/web/pages/talk_client.ts; a commit names /talk
commented

I fixed the high finding: opening an older chat from the list and then going to /talk now lands on that chat. I haven't run it in a browser (none starts in this sandbox), but the new test covers the case you described. tsc and test/talk-place.test.ts pass, and the pull is pushed.

  • The overwrite: a page's leave-beacon only updates the turn for the conversation that is already the saved place. It no longer sets the conversation. POST /talk/place returns 404 when the place is a different conversation, so only opening a conversation moves the place.
  • The test: it opens A, then B, then posts A's beacon and expects 404. /talk still opens B.
  • Reload and the GET write: I made the doc match the code instead of restoring the scroll place on /talk/<id>. docs/features/talk-place.md now says only /talk restores the scrolled place, that /talk/<id> opens at its end, and that opening a conversation writes the place even though it is a GET. I took that route because restoring on /talk/<id> was what I narrowed last round so the phone tests open at the end. If you want the reload to restore the place, say so. I'd need to find another way to keep those tests at the end.

The commit line names #18317 and says No door for the terminal and how-to side.

The gate still reports two similarity notes on keepOpen and the test's mk helper. They are notes, not failures, and I left them alone.

commented

<!-- look-pages 7e7b49796527 --> Look pages for 7e7b497, from the gate:

  • look pages (named): this pull changes src/web/pages/talk.ts, src/web/pages/talk_client.ts; a commit names /talk
commented

Nothing needed changing, so I pushed nothing. The gate reads all 39 rules with 0 failures and 3 notes, and I checked each rule you listed:

  • Both doors: ok. The terminal side and the how-to (docs/features/talk-place.md) are already in the pull.
  • Dead code (every export under src/ has a caller or is allowed): ok.
  • Name the issue: ok. Every commit carries (#18317).
  • Duplicate import: ok.
  • Look pages: this is a note, not a failure. A commit line already names /talk, and the gate says so.
  • Type check and tests: bun x tsc --noEmit is clean. test/talk-place.test.ts and test/talk-preview-frame.test.ts give 11 pass, 3 skip, 0 fail.

Two notes are left that I chose not to act on:

  • Comment width: --fix rewrapped nothing. The long comment lines are in other files, and the nightly rewrap handles those on main.
  • Duplicate functions: the gate flags keepOpen as 0.63 similar to landedBetween in src/flow/keeper_rate.ts. It also flags the mk helper in test/talk-place.test.ts as identical to the one in test/mcp-widgets.test.ts. Neither blocks the pull. The two keepOpen/landedBetween functions do different jobs. The test helper is a few lines local to that test file.

The sandbox blocked an outbound connection to apps.test:37339 while the tests ran. The tests passed regardless.

Review steps for the page change:

[{"go":"/talk","look":"Open a conversation, scroll up, then leave and return to /talk","expect":"It reopens on the same conversation at the place you left; a conversation named by its address opens at its end"}]

🤖 Generated with Claude Code

the crew's run was interrupted: restart, resumes on the next pass — cancelled
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs