Skip to content

fix(ui): start a chat private, and show reminder due dates - #5568

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/private-new-chat-and-reminder-dates
Oct 23, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/private-new-chat-and-reminder-dates

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Before, a chat could only be made private after its first message, so that message (often the sensitive one, like "remember: my bank PIN hint is …") had already been saved to memory. Now the new-chat screen has a Private toggle next to the Ask and model chips, and the chat is created private, so nothing from its first turn is remembered. Reminders on the Memory page also showed only the user's own words ("next Friday"), which go stale within a week. They now show the stored date ("Due Fri, Oct 30") and switch to "Was due …" once it has passed.

Test plan

  • cd src/gaia/apps/webui && npx tsc --noEmit -p . && npx vitest run && npm run build
  • python -m pytest tests/unit/chat -n 4
  • Agent UI: turn on Private on the new-chat screen and send "Please remember: my bank PIN hint is the dog". The chat header shows the eye icon pressed, and Memory → About you does not list the hint.
  • Memory → About you: a reminder with a due date shows "Due …", and a past one shows "Was due …" in red.
🔍 Technical details
  • The toggle is a new-chat draft in chatStore (draftPrivate), handled like the draft permission mode. startChat sends it in POST /api/sessions (private was already part of CreateSessionRequest) and resets it once the chat exists. The first message is queued only after the private session is in place, and every turn reads the flag from the session row. Nothing toggles it afterwards, so the first message cannot go out non-private. The chip is disabled while the chat is being created.
  • The chat request doesn't take a private field. Privacy comes from the session row (_memory_mode → "private" for relayed sidecars), so no API change was needed. A new backend test pins that a session created with private: true is private before any turn.
  • dueLabel() treats a local-midnight due_at, which is what a date-only reminder normalises to, as the whole day. That keeps it from reading "Was due" on the day itself. It shows the time for timed reminders and the year when it isn't the current one.
  • Undoing "Forget" on a reminder now keeps its due_at. Before, it restored the reminder without its date.
  • ChatView.tsx is unchanged.

A chat could only be made private after its first message, so that
message - often the sensitive one - was already saved to memory. The
new-chat screen now has a Private toggle; the session is created with
the flag, so the first turn already runs private.

Reminders on the Memory page showed only the words the user said
("next Friday"), which go stale. Each reminder now shows its stored
due date, and "Was due ..." once it has passed.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes electron Electron app changes labels Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The new-chat screen gets a Private toggle, so a chat is private from its very first message and that message is never saved to memory. Reminders on the Memory page now show their stored due date instead of only the user's relative wording. The logic is correct: the chat is created private before its first message is sent, the toggle resets after each chat, and the change is covered by frontend and backend tests. The docs are updated too.

The one gap is proof on the screen the user actually touches. This changes the Agent UI, but the PR has no before→after screenshot of the Private chip or the "Due …" / "Was due …" labels. Please add one before merge; it doesn't block the code.

Real-world evidence

N/A: no evidence bundle was produced for this run, and the change is Agent-UI-only, so the rendered screenshot is deferred to the strix-halo lane. The verdict rests on static review plus the PR's unit tests (vitest for the chip and due labels, pytest for POST /api/sessions with private: true).

🔍 Technical details

Issues

🟡 No Agent UI screenshot for a UI-visible change. The rubric asks for a Playwright before→after screenshot, embedded with a raw URL, for any Agent UI surface. Two views need one: the new-chat composer with Private on, and Memory → About you showing an upcoming and an overdue reminder. The new backend test does pin the route contract, so this is a nudge rather than a blocker.

🟢 The overdue style depends on the label's wording (MemoryDashboardAboutYou.tsx, due.startsWith('Was')). If the copy changes or gets localised, the red overdue styling silently stops working. Returning { text, past } from dueLabel would avoid that:

export function dueLabel(iso: string, now: Date = new Date()): { text: string; past: boolean } | null

and render className={\mem-about-due${due.past ? ' is-overdue' : ''}`}`.

🟢 An explicit UTC timestamp can show as a timed reminder. memory_store.py adds the local zone only when due_at has no offset. If a value arrives as ...T00:00:00Z, a browser outside UTC won't see local midnight, so it shows a clock time (possibly the evening before) instead of the whole day. This is a rare edge case and no change is needed now; mentioning it only in case the agent ever writes Z dates.

Checked and fine

  • startChat sends private before addSession/setPendingPrompt, and CreateSessionRequest.private already exists, so no API change was needed. draftPrivate is reset only after a successful create, so a failed create keeps the user's choice.
  • PrivateChip is disabled while sending, which closes the gap where it could be toggled mid-create.
  • Undoing "Forget" now restores due_at. That was an existing data-loss bug, now fixed and tested.

Strengths

  • The App test checks call order (createSession before sendMessageStream) and that toggleSessionPrivacy is never called. That covers the real invariant, not just that the functions were invoked.
  • dueLabel handles whole-day vs timed reminders and the "due today" boundary, with direct unit cases.
  • The backend test asserts _memory_mode == "private" on a session that has had no turns, which matches the behaviour promised in the docs.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Checked live in the Agent UI: the Private chip on the new-chat screen makes the first message private, and reminders show their due date.

Private chip on the new-chat screen

🔍 Technical details

With Private on, sent "Please remember: my medical record number is MRN-55821 and I see my cardiologist on Mondays." Memory stayed at 9 entries with nothing matching MRN/cardiologist after extraction, and the chat header showed "Private chat on". Memory → About you → Reminders now reads "I'm interviewing at Contoso next Friday. · Due Fri, Oct 30" (https://raw.githubusercontent.com/kovtcharov/gaia/kalin/agent-ui-test-pass-evidence/agent-ui-test-pass/reminder-due-date.jpg). Same live build as #5567, DeepSeek V4 Flash on Fireworks.

dueLabel now returns whether the reminder is past alongside the text, so
the overdue style no longer depends on the label starting with Was.
@kovtcharov

kovtcharov commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

An overdue reminder is now styled from its date, not from how the label is worded. Screenshots of the Private chip and of both due-date labels from the live Agent UI are in this comment.

🔍 Technical details
  • dueLabel now returns { text, past } | null, and the row sets is-overdue from due.past. The unit cases assert past directly, and the render tests still check the class on upcoming and overdue rows.
  • Z timestamps: no change, as suggested. memory_store.py stamps a naive due_at with the local offset, so the usual path renders as a whole day. Only a value the agent sends with an explicit Z would show a clock time outside UTC.
  • Checks: tsc, vitest (144 files / 1530 tests), npm run build, tests/unit/chat (2164 passed), black/isort. ChatView.tsx is unchanged at 101,751 bytes (LF).
  • CI: the one red check is Linux unit test_redaction_stays_fast_on_dense_escapes (2.01 s against its time budget). It's a known timing flake that also failed this week on kalin/desktop-crash-quit-fixes and kalin/full-access-asks-gated-shell. It needs a maintainer re-run.

kovtcharov-amd pushed a commit that referenced this pull request Oct 23, 2026
…5610)

Four timing-sensitive unit tests failed 8 unrelated PRs this week
(#5537, #5539, #5562, #5563, #5564, #5565, #5566, #5568) and one of
main's last 11 completed runs. Each still guards the same bug, but no
longer races the clock on a busy runner. Every rewritten test was
checked by breaking the code: it fails on the real bug and passes 50/50
runs, including under full CPU load. The PR also keeps three tests out
of the developer's real `~/.gaia`.

## Test plan
- [x] `pytest tests/unit/mcp/client/test_stdio_hung_server.py
tests/unit/test_file_lock.py tests/unit/test_mcp_bridge_concurrency.py
tests/unit/chat/ui/test_agent_model_override.py
tests/integration/test_folder_indexing.py -n 4`: 316 passed, 3 skipped
- [x] The four de-flaked tests, run 50x each: 250/250 serial, and
250/250 under xdist (32 workers) with all 32 cores also running busy
loops. Main's versions in that same loaded run: redaction failed 10/50.
- [x] Each test fails when its bug is put back in the code (see details)
- [x] `tests/integration/test_folder_indexing.py -n 4`, 5 runs: all
pass. Main's version fails 7 to 9 tests per run.
- [x] Test 841 passes with `GAIA_HOME` set to a temp dir. Main's version
fails.
- [x] Electron `npx jest`: 1098 passed. The one failure,
`test_electron_chat_installer.js` (component size 103,725 > 102,400),
also fails on main and is unrelated.
- [ ] CI green on Linux, macOS and Windows unit lanes

<details>
<summary>🔍 Technical details</summary>

**`test_redaction_stays_fast_on_dense_escapes`** (Linux, 2.01 to 2.03 s
against a 2 s limit)
- Cause: an absolute 2 s bound. Locally the worst text takes 0.19 s. On
a 4-worker, coverage-traced runner it took about 10x that.
- Fix: time one 1M-char text against eight 125K texts with the same
total length, on the same machine. Linear code scores about 1.0 and a
quadratic scan scores 8, so the test asserts < 3. It takes the best of
up to three paired runs, and uses the lower of the wall-clock and CPU
(`thread_time`) ratios. Contention inflates wall time, and Windows
samples CPU time on ticks. The test also fails if the 1M text takes more
than 15 s of CPU, which catches a per-position rescan: that is linear
but takes minutes.
- Break checks: a quadratic prefix copy in `_candidate_windows`
(`len(text[:start].rstrip("\\"))`) gives a ratio of 5.9x and the test
fails. Main's 2 s test passed that same regression locally (1.57 s). A
per-anchor rescan without merging takes 56 s and hits the 15 s ceiling.

**`test_children_of_an_exited_server_are_still_stopped`** (Linux)
- Cause: the test slept a fixed 2 s for the child watcher. The watcher
backs off (0.5, 1, 2, 4 s…), so on a slow start its next scan came after
the launcher had exited and the child was never recorded.
- Fix: poll until `child_pid in transport._children`, with a deadline of
3 × `_CHILD_SCAN_MAX_S`.
- Break checks: never recording children fails with "never recorded".
Clearing `_children` before stopping fails with "kept running". Delaying
the watcher's first scan by 2.5 s reproduces the CI failure on main's
test, and the new test passes.
- Note for the product side: a launcher that spawns a child and exits
inside a backoff window still orphans that child. Real `npx`/`uvx`
launchers outlive the window.

**`test_the_next_waiter_takes_the_lock_within_milliseconds`** (macOS,
median 6.5 to 8.1 ms against 5 ms)
- Cause: macOS stretches `sleep(0.001)` under load, and the 5 ms median
left no headroom.
- Fix: the test wraps `_poll_interval`, which records each interval and
signals the moment the waiter starts a poll's sleep. The lock is
released right then, so the whole interval stands between the waiter and
the lock.
- Assertions: every interval the front waiter asks for is ≤ 2 ms, and
the median hand-off is < 15 ms. A 20 ms poll always waits at least 20
ms, so it fails the median even with the bound widened.
- Break checks: `_NEXT_POLL_SECONDS = 0.02` or `0.1` fails the interval
assertion. Sleeping `_POLL_SECONDS` directly, so `_poll_interval` is
bypassed, fails the median (20.8 ms).

**`test_a_dropped_idle_connection_is_logged[True]`** (Linux)
- Cause: the test asserted that `"Traceback"` was absent from the stderr
captured by `capsys`. The traceback in that run came from a fake
Lemonade server that `test_lemonade_shared_server.py` left running on
the same xdist worker (`BrokenPipeError`).
- Fix: the `serve` fixture records the bridge server's own
`handle_error` calls, and the test asserts that list is empty.
socketserver calls `handle_error` before it closes the connection, so
the check doesn't race. A plugin that writes a traceback to stderr
during the test fails main's version and passes the new one.
- Break check: making `log_error` also call the base `log_error`, and
reverting `str(args[0])`, raises `TypeError` in the handler, and the
test fails.

**Isolation fixes**
- `test_folder_indexing.py`: `temp_folder` now lives in
`isolated_gaia_home`, a per-test fake home, so `ensure_within_home`
still admits it. Parallel workers no longer share or delete
`~/.gaia/test_temp`.
- `test_issue_841…`: the test now sets `GAIA_HOME` itself, so an
inherited value can't override the patched `Path.home`.
- `tests/electron/setup.js`: `os.homedir()` points at a per-file temp
dir. It is assigned rather than spied, so `jest.restoreAllMocks()` can't
undo it. Setting `HOME` would not work, because Jest's sandboxed
`process.env` never reaches `os.homedir()`.
- The "Ignoring invalid agents section in …\.gaia\tray-config.json" log
came from `crash-loop-notification.test.cjs`, which mocks `fs` with a
config the validator rejects. The real file was never read, but the path
now names the temp home.
</details>
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 23, 2026
Merged via the queue into amd:main with commit 0844c1a Oct 23, 2026
34 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/private-new-chat-and-reminder-dates branch October 23, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes electron Electron app changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants