Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7280bf4
update rules
sawka Feb 19, 2026
4c6fd13
first cut at new block-tab based badge system
sawka Feb 20, 2026
51489eb
Merge remote-tracking branch 'origin/main' into sawka/block-indicators
sawka Mar 2, 2026
a75253f
run go generate, fix baseds import
sawka Mar 2, 2026
f7fda6a
Merge remote-tracking branch 'origin/main' into sawka/block-indicators
sawka Mar 5, 2026
f3d27e5
move indicators to their own file (badge.ts)
sawka Mar 5, 2026
95ec727
move tabindicatormap too
sawka Mar 5, 2026
ac7f295
move subscription to badge.ts, clean up some warnings
sawka Mar 5, 2026
e3aa0b8
clean up some warnings
sawka Mar 5, 2026
30788d0
setup FE badge store
sawka Mar 5, 2026
a7acdb9
working on badge integration
sawka Mar 5, 2026
f980494
add clearall for badge event
sawka Mar 5, 2026
260c767
add clearbyid
sawka Mar 5, 2026
c448ee7
add badgewatchpid
sawka Mar 5, 2026
f30f394
working on `wsh badge`
sawka Mar 5, 2026
a88c3bf
hook up pid watching to wsh badge command
sawka Mar 5, 2026
8d6f2ad
checkpoint on moving from tabiindicators to badges
sawka Mar 5, 2026
339cd6c
clear transient tab badges with focus as well
sawka Mar 5, 2026
ccf64e6
more badge migration
sawka Mar 5, 2026
498e0d9
remove tabindicators (backend+frontend), more badges
sawka Mar 6, 2026
09fed4e
getting the badges to show... up to 3 on a tab...
sawka Mar 6, 2026
2fb15c4
add flag color
sawka Mar 6, 2026
1806574
add context menu to flag tab...
sawka Mar 6, 2026
144db86
remove badge persistence
sawka Mar 6, 2026
820f535
focus should not clear pidlinked badges
sawka Mar 6, 2026
897f2d4
update tab bar, change flag to be a flag, resort badges
sawka Mar 6, 2026
c737c6e
Merge remote-tracking branch 'origin/main' into sawka/block-indicators
sawka Mar 6, 2026
e50de18
clean up some scss
sawka Mar 6, 2026
ddc9cff
remove ::after psudo element, just render the dividers in react
sawka Mar 6, 2026
9d1007d
dont use ctx in long running poller
sawka Mar 9, 2026
2518d31
fix nits
sawka Mar 9, 2026
dc2315d
fix nit
sawka Mar 9, 2026
64f6d4f
merge main
sawka Mar 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dont use ctx in long running poller
  • Loading branch information
sawka committed Mar 9, 2026
commit 9d1007dd113a850aff48ec78c8c65a4bb968c3db
35 changes: 15 additions & 20 deletions pkg/wshrpc/wshremote/wshremote.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,23 @@ func (impl *ServerImpl) BadgeWatchPidCommand(ctx context.Context, data wshrpc.Co
defer func() {
panichandler.PanicHandler("BadgeWatchPidCommand", recover())
}()
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
if !unixutil.IsPidRunning(data.Pid) {
orefStr := data.ORef.String()
event := wps.WaveEvent{
Event: wps.Event_Badge,
Scopes: []string{orefStr},
Data: baseds.BadgeEvent{
ORef: orefStr,
ClearById: data.BadgeId,
},
}
wshclient.EventPublishCommand(impl.RpcClient, event, nil)
log.Printf("BadgeWatchPidCommand: pid %d gone, cleared badge %s for oref %s\n", data.Pid, data.BadgeId, orefStr)
return
}
time.Sleep(time.Second)
if unixutil.IsPidRunning(data.Pid) {
continue
}
Comment on lines +157 to +159
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Verify the non-Unix IsPidRunning contract before depending on it here.

This watcher assumes unixutil.IsPidRunning is meaningful on every platform. If pkg/util/unixutil/unixutil_windows.go still returns false unconditionally, Windows will clear every badge on the first poll even while the process is still alive.

Run the following script to confirm the platform-specific implementations and the shared call site:

#!/bin/bash
set -euo pipefail

fd '^unixutil_.*\.go$' pkg/util/unixutil --exec sh -c '
  for f do
    echo "== $f =="
    sed -n "1,200p" "$f"
  done
' sh {} +

echo "== Badge watch call site =="
rg -n -C3 'BadgeWatchPidCommand|IsPidRunning' pkg/wshrpc/wshremote/wshremote.go

Expected result: every OS-specific IsPidRunning implementation should honor the same contract: return true while the watched process still exists. If Windows still hardcodes false, this path needs a Windows implementation or an OS guard before enabling the command.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/wshrpc/wshremote/wshremote.go` around lines 157 - 159, The watcher in
wshremote.go calls unixutil.IsPidRunning(data.Pid) and assumes it returns true
while the process exists; verify all OS-specific implementations under
pkg/util/unixutil (especially unixutil_windows.go) adhere to that contract and,
if windows currently returns false unconditionally, either implement a correct
Windows IsPidRunning that checks process existence or add an OS guard in the
BadgeWatchPidCommand registration/path to avoid enabling the watcher on Windows;
locate and update the unixutil.IsPidRunning implementations or the
BadgeWatchPidCommand call site in wshremote.go accordingly so behavior is
consistent across platforms.

orefStr := data.ORef.String()
event := wps.WaveEvent{
Event: wps.Event_Badge,
Scopes: []string{orefStr},
Data: baseds.BadgeEvent{
ORef: orefStr,
ClearById: data.BadgeId,
},
}
wshclient.EventPublishCommand(impl.RpcClient, event, nil)
log.Printf("BadgeWatchPidCommand: pid %d gone, cleared badge %s for oref %s\n", data.Pid, data.BadgeId, orefStr)
return
}
}()
Comment on lines +151 to +173
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Stop the watcher when ctx is canceled.

This goroutine never observes ctx.Done(), so canceled or abandoned watches stay alive until the PID disappears and can still publish a late badge-clear event after the caller has gone away.

Suggested fix
 	go func() {
 		defer func() {
 			panichandler.PanicHandler("BadgeWatchPidCommand", recover())
 		}()
+		ticker := time.NewTicker(time.Second)
+		defer ticker.Stop()
 		for {
-			time.Sleep(time.Second)
+			select {
+			case <-ctx.Done():
+				return
+			case <-ticker.C:
+			}
 			if unixutil.IsPidRunning(data.Pid) {
 				continue
 			}
+			select {
+			case <-ctx.Done():
+				return
+			default:
+			}
 			orefStr := data.ORef.String()
 			event := wps.WaveEvent{
 				Event:  wps.Event_Badge,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/wshrpc/wshremote/wshremote.go` around lines 151 - 173, The goroutine
started in BadgeWatchPidCommand should stop when the provided ctx is canceled:
change the for loop to select on ctx.Done() and a timer/ticker (e.g., time.After
or time.Ticker) instead of unconditionally sleeping; when ctx.Done() fires
return immediately and do not call wshclient.EventPublishCommand, otherwise
continue to check unixutil.IsPidRunning as before; ensure the deferred
panichandler.PanicHandler remains and optionally log cancellation for clarity.

return nil
Expand Down