Skip to content

Do not stack a message under a hidden deleted message - #589

Open
burrows99 wants to merge 1 commit into
jupyterlab:mainfrom
burrows99:fix/unstack-after-hidden-deleted-message
Open

burrows99 wants to merge 1 commit into
jupyterlab:mainfrom
burrows99:fix/unstack-after-hidden-deleted-message

Conversation

@burrows99

Copy link
Copy Markdown

Closes #588

Problem

With the default settings (showDeleted off), a message stacked under a deleted message stays stacked after the deleted one is hidden. It is displayed without its sender, under the previous visible message, so another user's name appears to be its author.

AbstractChatModel computes stacked by comparing each message with the previous one in the list, hidden deleted messages included.

Solution

  • A new private _isStacked(index) compares the sender with the previous displayed message: deleted messages are skipped when showDeleted is off.
  • It is used where the stacked state was already computed: when messages are inserted, and when the config changes.
  • A change of showDeleted now also updates the stacked state, so toggling the setting does not need a reload.
flowchart TD
    A[Bob deletes the first of his two messages] --> B{Chat opened with deleted messages hidden}
    B -->|Before| C[Remaining message shown under Alice]
    B -->|After| D[Remaining message shows Bob]
Loading

Narrated recording, before then after (sound on):

evidence_upload.mp4

Edge cases and unchanged behavior checked

Checked in the running app (JupyterLab 4.6.6 with the extension built from main at c112d54, then from this branch, without jupyter_collaboration) and shown in the recording. The chats were seeded with messages from two users, Alice and Bob:

  • Before: Bob's remaining message is shown under Alice's name.
  • After: the same chat shows Bob's name on his message.
  • Edge case: turning showDeleted on in the settings shows the deleted message under Bob's name and stacks his reply under it; turning it off again gives the reply Bob's name back, without reloading.
  • Edge case: after two deleted messages in a row, Bob's next message still shows his name.
  • Unchanged: consecutive messages from the same user are still stacked.
  • Unchanged: a message from another user still starts with its sender's name.

Checked by tests only: the three new unit tests in model.spec.ts (hidden deleted message, shown deleted message, showDeleted toggled).

Not changed: when a message is deleted while the chat is open, its header stays visible until the chat is reopened, as on main.

Tests run

$ jlpm jest   (in packages/jupyter-chat)
Test Suites: 13 passed, 13 total
Tests:       94 passed, 94 total

With the source change reverted and the tests kept, 2 of the 3 new tests fail (the third covers the behavior that must not change).

$ jlpm jest src/__tests__/model.spec.ts   (in packages/jupyterlab-chat)
Tests:       13 passed, 13 total

prettier --check and eslint pass on the changed files, and jlpm build (TypeScript) passes.

Not run: the UI tests and the Python tests (no Python change).

AI tools (Claude Code) assisted with this change; the bug was reproduced and the fix verified manually in the running app.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Binder 👈 Launch a Binder on branch burrows99/jupyter-chat/fix%2Funstack-after-hidden-deleted-message

This branch has not been deployed

No deployments
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.

Message shown under the wrong sender when the previous message is deleted

1 participant