Skip to content

Commit 69eca09

Browse files
committed
changed variable name
1 parent 6cd55ab commit 69eca09

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

python/jupyterlab-chat/jupyterlab_chat/tests/test_ychat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_update_message_includes_mentions():
182182

183183
# Update the message to mention a different user
184184
msg.body = f"@{USER3.mention_name} Goodbye!"
185-
chat.update_message(msg, is_done=True)
185+
chat.update_message(msg, find_mentions=True)
186186
updated_msg = chat.get_message(msg_id)
187187
assert updated_msg
188188
assert set(updated_msg.mentions) == set([USER3.username])
@@ -203,7 +203,7 @@ def test_update_message_append_includes_mentions():
203203

204204
# Append content with another mention
205205
msg.body = f" and @{USER3.mention_name}!"
206-
chat.update_message(msg, append=True, is_done=True)
206+
chat.update_message(msg, append=True, find_mentions=True)
207207
updated_msg = chat.get_message(msg_id)
208208
assert updated_msg
209209
# Should now mention both users
@@ -224,7 +224,7 @@ def test_update_message_append_no_duplicate_mentions():
224224

225225
# Append content that mentions the same user again
226226
msg.body = f" @{USER2.mention_name} again!"
227-
chat.update_message(msg, append=True, is_done=True)
227+
chat.update_message(msg, append=True, find_mentions=True)
228228
updated_msg = chat.get_message(msg_id)
229229
assert updated_msg
230230
# Should only have one mention despite appearing twice

python/jupyterlab-chat/jupyterlab_chat/ychat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_messages(self) -> list[Message]:
118118
message_dicts = self._get_messages()
119119
return [Message(**message_dict) for message_dict in message_dicts]
120120

121-
def _extract_mentions(self, body: str) -> list[str]:
121+
def _find_mentions(self, body: str) -> list[str]:
122122
"""
123123
Extract mentioned usernames from a message body.
124124
Finds all @mentions in the body and returns the corresponding usernames.
@@ -151,7 +151,7 @@ def add_message(self, new_message: NewMessage) -> str:
151151
)
152152

153153
# find all mentioned users and add them as message mentions
154-
message.mentions = self._extract_mentions(message.body)
154+
message.mentions = self._find_mentions(message.body)
155155

156156
with self._ydoc.transaction():
157157
index = len(self._ymessages) - next((i for i, v in enumerate(self._get_messages()[::-1]) if v["time"] < timestamp), len(self._ymessages))
@@ -162,11 +162,11 @@ def add_message(self, new_message: NewMessage) -> str:
162162

163163
return uid
164164

165-
def update_message(self, message: Message, append: bool = False, is_done: bool = False):
165+
def update_message(self, message: Message, append: bool = False, find_mentions: bool = False):
166166
"""
167167
Update a message of the document.
168168
If append is True, the content will be appended to the previous content.
169-
If is_done is True, mentions will be extracted and notifications triggered (use for streaming completion).
169+
If find_mentions is True, mentions will be extracted and notifications triggered (use for streaming completion).
170170
"""
171171
with self._ydoc.transaction():
172172
index = self._indexes_by_id[message.id]
@@ -176,8 +176,8 @@ def update_message(self, message: Message, append: bool = False, is_done: bool =
176176
message.body = initial_message["body"] + message.body # type:ignore[index]
177177

178178
# Extract and update mentions from the message body
179-
if is_done:
180-
message.mentions = self._extract_mentions(message.body)
179+
if find_mentions:
180+
message.mentions = self._find_mentions(message.body)
181181

182182
self._ymessages[index] = asdict(message, dict_factory=message_asdict_factory)
183183

0 commit comments

Comments
 (0)