-
Notifications
You must be signed in to change notification settings - Fork 46k
feat(platform/copilot): live timer stats with persisted duration #12583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
903dc22
feat(frontend/copilot): add useElapsedTimer hook and formatElapsed he…
0ubbe 7ed0b45
feat(frontend/copilot): add elapsed timer display to ThinkingIndicator
0ubbe ef33f2d
feat(frontend/copilot): add "Thought for Xm Ys" to TurnStatsBar compl…
0ubbe da15a37
feat(frontend/copilot): wire elapsed timer into ChatMessagesContainer…
0ubbe cacdf60
feat(platform/copilot): persist turn duration in DB and show on reload
0ubbe 36d360f
merge: resolve conflicts merging dev into feat/copilot-live-timer-stats
0ubbe ea46596
fix(platform/copilot): address PR review feedback on timer stats
0ubbe 333d8ca
fix(backend): fix import ordering and string formatting for lint
0ubbe 490f5e9
fix(frontend/copilot): restore thinking phrases in ThinkingIndicator
0ubbe 37e7af3
fix(frontend/copilot): match timer font style with thinking phrase
0ubbe 9a1159d
fix(frontend/copilot): add pulse animation to elapsed timer text
0ubbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...gpt_platform/backend/migrations/20260326120000_add_chat_message_duration_ms/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Add durationMs column to ChatMessage for persisting turn elapsed time. | ||
| ALTER TABLE "ChatMessage" ADD COLUMN "durationMs" INTEGER; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 10 additions & 80 deletions
90
.../app/(platform)/copilot/components/ChatMessagesContainer/components/ThinkingIndicator.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,93 +1,23 @@ | ||
| import { useEffect, useRef, useState } from "react"; | ||
| import { formatElapsed } from "../../JobStatsBar/formatElapsed"; | ||
| import { ScaleLoader } from "../../ScaleLoader/ScaleLoader"; | ||
|
|
||
| const THINKING_PHRASES = [ | ||
| "Thinking...", | ||
| "Considering this...", | ||
| "Working through this...", | ||
| "Analyzing your request...", | ||
| "Reasoning...", | ||
| "Looking into it...", | ||
| "Processing your request...", | ||
| "Mulling this over...", | ||
| "Piecing it together...", | ||
| "On it...", | ||
| "Connecting the dots...", | ||
| "Exploring possibilities...", | ||
| "Weighing options...", | ||
| "Diving deeper...", | ||
| "Gathering thoughts...", | ||
| "Almost there...", | ||
| "Figuring this out...", | ||
| "Putting it together...", | ||
| "Running through ideas...", | ||
| "Wrapping my head around this...", | ||
| ]; | ||
|
|
||
| const PHRASE_CYCLE_MS = 6_000; | ||
| const FADE_DURATION_MS = 300; | ||
|
|
||
| /** | ||
| * Cycles through thinking phrases sequentially with a fade-out/in transition. | ||
| * Returns the current phrase and whether it's visible (for opacity). | ||
| */ | ||
| function useCyclingPhrase(active: boolean) { | ||
| const indexRef = useRef(0); | ||
| const [phrase, setPhrase] = useState(THINKING_PHRASES[0]); | ||
| const [visible, setVisible] = useState(true); | ||
| const fadeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null); | ||
|
|
||
| // Reset to the first phrase when thinking restarts | ||
| const prevActive = useRef(active); | ||
| useEffect(() => { | ||
| if (active && !prevActive.current) { | ||
| indexRef.current = 0; | ||
| setPhrase(THINKING_PHRASES[0]); | ||
| setVisible(true); | ||
| } | ||
| prevActive.current = active; | ||
| }, [active]); | ||
|
|
||
| useEffect(() => { | ||
| if (!active) return; | ||
| const id = setInterval(() => { | ||
| setVisible(false); | ||
| fadeTimeoutRef.current = setTimeout(() => { | ||
| indexRef.current = (indexRef.current + 1) % THINKING_PHRASES.length; | ||
| setPhrase(THINKING_PHRASES[indexRef.current]); | ||
| setVisible(true); | ||
| }, FADE_DURATION_MS); | ||
| }, PHRASE_CYCLE_MS); | ||
| return () => { | ||
| clearInterval(id); | ||
| if (fadeTimeoutRef.current) { | ||
| clearTimeout(fadeTimeoutRef.current); | ||
| fadeTimeoutRef.current = null; | ||
| } | ||
| }; | ||
| }, [active]); | ||
|
|
||
| return { phrase, visible }; | ||
| } | ||
| /** Only show elapsed time after this many seconds. */ | ||
| const SHOW_AFTER_SECONDS = 20; | ||
|
|
||
| interface Props { | ||
| active: boolean; | ||
| elapsedSeconds: number; | ||
| } | ||
|
|
||
| export function ThinkingIndicator({ active }: Props) { | ||
| const { phrase, visible } = useCyclingPhrase(active); | ||
| export function ThinkingIndicator({ active, elapsedSeconds }: Props) { | ||
| const showTime = active && elapsedSeconds >= SHOW_AFTER_SECONDS; | ||
|
|
||
| return ( | ||
| <span className="inline-flex items-center gap-1.5 text-neutral-500"> | ||
| <span className="inline-flex items-center gap-1.5 font-mono text-sm text-neutral-500"> | ||
| <ScaleLoader size={16} /> | ||
| <span | ||
| className="transition-opacity duration-300" | ||
| style={{ opacity: visible ? 1 : 0 }} | ||
| > | ||
| <span className="animate-pulse [animation-duration:1.5s]"> | ||
| {phrase} | ||
| </span> | ||
| </span> | ||
| {showTime && ( | ||
| <span className="tabular-nums">{formatElapsed(elapsedSeconds)}</span> | ||
| )} | ||
| </span> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.