Show relative last termination time in Launch History tooltip#2744
Show relative last termination time in Launch History tooltip#2744SougandhS wants to merge 1 commit into
Conversation
Display the relative termination time (for example, "a moment ago", "5 mins ago", or "1 hour ago") in launch history tooltips using the stored termination timestamp. This provides a quick indication of when a launch was last terminated
|
Hi @iloveeclipse, could you please check this PR or trigger a co-pilot review ? - when you get time |
| protected void fireTerminate() { | ||
| setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, Long.toString(System.currentTimeMillis())); | ||
| String timeStamp = Long.toString(System.currentTimeMillis()); | ||
| setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, timeStamp); |
There was a problem hiding this comment.
If I see it right, this would alter config stored on a disk every time it finishes. So all shared and git versioned configs will be automatically dirty after use. I would not do that.
Maybe better to restrict this to "not shared" configs and for shared configs in the workspace use bundle location to manage timestamps.
There was a problem hiding this comment.
Pull request overview
Enhances the Debug UI launch history/favorites drop-down by showing a human-friendly “terminated X ago” tooltip for inactive (previously terminated) launch configurations, backed by persisting the termination timestamp onto the launch configuration.
Changes:
- Persist
ATTR_TERMINATE_TIMESTAMPinto the associatedILaunchConfigurationwhen a launch terminates. - Add relative-time tooltip computation and apply it to inactive launch history/favorite entries.
- Introduce new NLS message keys for relative-time tooltip strings.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java | Adds relative-time tooltip logic and applies it while building the launch history/favorites menu. |
| debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties | Adds localized strings for “a moment ago”, “{n} mins ago”, etc. |
| debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java | Declares new NLS fields for the added tooltip message keys. |
| debug/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java | Persists termination timestamp to the launch configuration on termination. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| addRecentLaunchTimeTooltip(launch, action); | ||
| } | ||
| addRecentLaunchTimeTooltip(launch, action); | ||
| addToMenu(menu, action, accelerator); |
| private void addRecentLaunchTimeTooltip(ILaunchConfiguration launch, LaunchAction launchAction) { | ||
| try { | ||
| String timeStamp = launch.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, ""); //$NON-NLS-1$ | ||
| if (!timeStamp.isEmpty()) { | ||
| long mytime = Long.parseLong(timeStamp); | ||
| String g = getRelativeTime(mytime); | ||
| launchAction.setToolTipText(g); | ||
| } | ||
| } catch (CoreException e) { | ||
| DebugUIPlugin.log(e); | ||
| } | ||
| } |
| long diffMillis = System.currentTimeMillis() - timestamp; | ||
| long seconds = diffMillis / 1000; |
| ILaunchConfiguration launchConfig = getLaunchConfiguration(); | ||
| if (launchConfig != null) { | ||
| try { | ||
| ILaunchConfigurationWorkingCopy launchCopy = getLaunchConfiguration().getWorkingCopy(); | ||
| launchCopy.setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, timeStamp); | ||
| launchCopy.doSave(); | ||
| } catch (CoreException e) { | ||
| DebugPlugin.log(e); | ||
| } | ||
| } |
| String timeStamp = Long.toString(System.currentTimeMillis()); | ||
| setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, timeStamp); | ||
| ILaunchConfiguration launchConfig = getLaunchConfiguration(); | ||
| if (launchConfig != null) { | ||
| try { |
This change enhances the launch history menu by displaying a relative termination time in the tooltip for previously launched configurations. Instead of showing only the launch configuration name, the tooltip now indicates how recently the launch was terminated using user-friendly text such as "a moment ago", "5 mins ago", or "1 hour ago", based on the stored termination timestamp. This provides quick contextual information about recent launches, making it easier to identify and relaunch configurations that were used recently. The additional context is particularly useful when launch favorites are pinned to the top of the menu, as their fixed ordering does not reflect recent usage and can make it harder to determine which configuration was run most recently.