Skip to content

Implement edit functionality for user messages slg 28#233

Draft
aryadhruv wants to merge 4 commits intomainfrom
implement-edit-functionality-for-user-messages-slg-28
Draft

Implement edit functionality for user messages slg 28#233
aryadhruv wants to merge 4 commits intomainfrom
implement-edit-functionality-for-user-messages-slg-28

Conversation

@aryadhruv
Copy link
Copy Markdown
Contributor

@aryadhruv aryadhruv commented Mar 23, 2026

My attempt at Vibe codded PR

aryadhruv and others added 3 commits March 23, 2026 22:44
Refactor chat streaming to use @langchain/svelte's useStream hook and wire submit/stop, loading and error state through the new API. Add message edit/save UI and handlers (ChatMessage, ChatMessages, UserMessageActions) so users can edit a human message and re-run a generation using message metadata/checkpoints. Normalize message handling by switching to @langchain/core message types and using getContent helpers across components (AIMessageActions, ChatToolMessage, FeedbackButtons, ScrollableContainer). Minor API change: streamAnswer now accepts an optional checkpointId. package.json: bump @langchain/langgraph-sdk and add @langchain/svelte. Tests updated to reflect enabled edit button behavior.

Co-Authored-By: Claude <claude@users.noreply.github.com>
useStream v0.1.3 ignores options.threadId — the internal threadId store is
always initialized as undefined. On the first submit(), it saw undefined and
called client.threads.create() to make a new empty thread, causing all
existing history to vanish.

Fix by calling switchThread(thread.thread_id) immediately after useStream
initialization, which is the only way to pre-set the internal store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude <claude@users.noreply.github.com>
@aryadhruv aryadhruv marked this pull request as draft March 23, 2026 17:25
@qltysh
Copy link
Copy Markdown

qltysh bot commented Mar 23, 2026

1 new issue

Tool Category Rule Count
qlty Structure Function with many parameters (count = 6): streamAnswer 1

inputMessage: HumanMessage,
signal: AbortSignal
signal: AbortSignal,
checkpointId?: string
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function with many parameters (count = 6): streamAnswer [qlty:function-parameters]

In ChatMessages.svelte, replace the previous !finalAnswerStarted condition with isLoading to control rendering of <ChatWaiting/>. This makes the waiting state explicit and improves clarity/fix for when the waiting UI should be shown.
onEditSave
}: Props = $props();

function getContent(message: BaseMessage): string {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY !!

Comment on lines +57 to +59
<div class="w-full space-y-2">
<Textarea bind:value={editText} class="min-h-24 text-sm" />
<div class="flex justify-end gap-2">
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor. long enough that it deserves it's own space

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 23, 2026

Run report for 66893601

Total time: 5m | Comparison time: 6m 28s | Estimated savings: 1m 27s (22.6% faster)

Action Time Status Info
⬛️ SetupProto(0.53.2) 0ms Skipped
🟩 SyncWorkspace 2ms Passed
🟩 SyncProject(frontend) 0.7ms Passed
🟩 SyncProject(e2e) 0.4ms Passed
⬛️ SetupToolchain(python:~3.12) 40ms Skipped
⬛️ InstallProjectDeps(python:~3.12, backend) 3.2ms Skipped
⬛️ SetupToolchain(node:~24) 46.8ms Skipped
⬛️ InstallWorkspaceDeps(node:~24) 0.7ms Skipped
🟩 InstallProjectDeps(node:~24, e2e) 0.7ms Passed
🟪 RunTask(backend:setup) 20.1ms Cached
🟪 RunTask(frontend:lint) 39.4ms Cached
🟪 RunTask(e2e:install-playwright) 39.7ms Cached
🟪 RunTask(frontend:build) 40.3ms Cached
🟪 RunTask(frontend:format) 35.2ms Cached
🟥 RunTask(frontend:check) 21.6s Failed
🟥 RunTask(frontend:test) 1m 4s Failed
🟥 RunTask(frontend:test-cov) 1m 8s Failed
⬛️ RunTask(e2e:test) 5m Skipped SLOW
Touched files
apps/frontend/package.json
apps/frontend/src/lib/components/AIMessageActions.svelte
apps/frontend/src/lib/components/Chat.svelte
apps/frontend/src/lib/components/ChatMessage.svelte
apps/frontend/src/lib/components/ChatMessages.svelte
apps/frontend/src/lib/components/ChatToolMessage.svelte
apps/frontend/src/lib/components/FeedbackButtons.svelte
apps/frontend/src/lib/components/ScrollableContainer/ScrollableContainer.svelte
apps/frontend/src/lib/components/UserMessageActions.svelte
apps/frontend/src/lib/components/UserMessageActions.svelte.test.ts
apps/frontend/src/lib/langgraph/streamAnswer.ts
pnpm-lock.yaml

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.

1 participant