Skip to content

feat: add a ui to manage running Terminal (Executor) processes#2333

Merged
bajrangCoder merged 11 commits into
mainfrom
feat/ui-manage-process
Jun 20, 2026
Merged

feat: add a ui to manage running Terminal (Executor) processes#2333
bajrangCoder merged 11 commits into
mainfrom
feat/ui-manage-process

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

Closes: #1773

@github-actions github-actions Bot added enhancement New feature or request translations Anything related to Translations Whether a Issue or PR labels Jun 19, 2026
@bajrangCoder bajrangCoder marked this pull request as ready for review June 19, 2026 09:17
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new "Running Processes" UI page that lists all OS-level processes under the app's UID, enriches managed terminal/background-executor entries with service metadata, and provides per-process kill actions. It introduces ProcessUtils.java for /proc scanning and PID-level killing, wires listProcesses/listAllProcesses/killProcess into both TerminalService and BackgroundExecutor, and exposes the page via the app menu and commands.

  • Java layer: ProcessUtils.getAllProcesses() reads /proc/<pid>/status and cmdline per process; killProcess(int) now checks the exit code and throws on failure. TerminalService and BackgroundExecutor both gained a ProcessDetails inner class that captures startedAt = System.currentTimeMillis() at spawn time, fixing the "Unknown uptime" issue from earlier drafts.
  • JS UI: runningProcesses.js builds a live-refreshing list with expand/collapse details, managed-process tagging, and per-process kill with confirmation. The searchBar is invoked with cloneResults = false, so click handlers on child elements survive the search path.
  • TypeScript declarations: ExecutorProcess now includes pid, but the new listAllProcesses and killProcess methods are absent from the Executor interface, and there is no type for OS-level process objects.

Confidence Score: 4/5

Safe to merge with the TypeScript declaration gaps addressed; the runtime behavior of the new page is functional and the Java kill path is correctly guarded.

The new listAllProcesses and killProcess methods are called in runningProcesses.js and exposed from the Java/JS layers, but are not declared in the Executor TypeScript interface. Any plugin or typed consumer trying to call these methods will hit a compile-time type error, and there is no OsProcess type for the data they return.

src/index.d.ts — the Executor interface and a new OsProcess type need updating before TypeScript consumers can use the new APIs.

Important Files Changed

Filename Overview
src/pages/runningProcesses/runningProcesses.js Core UI for the new Running Processes page. Several previously raised issues (startedAt capture, Executor undefined guard, toggleExpand search split) now appear addressed in the current code.
src/plugins/terminal/src/android/ProcessUtils.java New utility class for listing /proc processes and killing individual PIDs. killProcess now correctly checks the exit code and throws on failure. killProcessTree uses kill -9 -PID (process-group kill), flagged in previous reviews.
src/plugins/terminal/src/android/BackgroundExecutor.java Added listProcesses/listAllProcesses/killProcess actions. listProcesses no longer calls cleanup() for dead entries. ProcessDetails now captures startedAt and pid at start time.
src/plugins/terminal/src/android/TerminalService.java Added MSG_LIST_PROCESSES handler and ProcessDetails with accurate startedAt. listProcesses skips dead entries without triggering cleanup.
src/plugins/terminal/www/Executor.js Added listAllProcesses and killProcess methods to the Executor class. Both methods are present and functional.
src/index.d.ts ExecutorProcess now includes the pid field. However, the new listAllProcesses and killProcess methods are absent from the Executor interface, and there is no type for OS-level process list entries.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant UI as RunningProcesses (JS)
    participant Ex as Executor (JS)
    participant EJ as Executor.java
    participant BE as BackgroundExecutor.java
    participant TS as TerminalService
    participant PU as ProcessUtils

    UI->>Ex: listAllProcesses()
    Ex->>EJ: cordova exec "listAllProcesses"
    EJ->>PU: getAllProcesses()
    PU-->>EJ: JSONArray (pid, ppid, name, cmd, mem, isSelf, startedAt)
    EJ-->>UI: OsProcess[]

    UI->>Ex: listProcesses()
    Ex->>TS: MSG_LIST_PROCESSES
    TS-->>UI: ProcessDetails[] (id, pid, cmd, alpine, startedAt)

    UI->>Ex: BackgroundExecutor.listProcesses()
    Ex->>BE: cordova exec "listProcesses"
    BE-->>UI: ProcessDetails[] (id, pid, cmd, alpine, startedAt)

    Note over UI: merge managedMap → enrich allProcesses
    UI->>UI: renderList() / renderSearch()

    alt user clicks kill (managed)
        UI->>Ex: stop(managedId)
        Ex->>TS: MSG_STOP_PROCESS
        TS->>PU: killProcessTree(process)
    else user clicks kill (unmanaged)
        UI->>Ex: killProcess(pid)
        Ex->>EJ: cordova exec "killProcess"
        EJ->>PU: killProcess(pid)
        PU-->>EJ: exit code check / throws on failure
    end

    UI->>UI: refresh() → update display
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant UI as RunningProcesses (JS)
    participant Ex as Executor (JS)
    participant EJ as Executor.java
    participant BE as BackgroundExecutor.java
    participant TS as TerminalService
    participant PU as ProcessUtils

    UI->>Ex: listAllProcesses()
    Ex->>EJ: cordova exec "listAllProcesses"
    EJ->>PU: getAllProcesses()
    PU-->>EJ: JSONArray (pid, ppid, name, cmd, mem, isSelf, startedAt)
    EJ-->>UI: OsProcess[]

    UI->>Ex: listProcesses()
    Ex->>TS: MSG_LIST_PROCESSES
    TS-->>UI: ProcessDetails[] (id, pid, cmd, alpine, startedAt)

    UI->>Ex: BackgroundExecutor.listProcesses()
    Ex->>BE: cordova exec "listProcesses"
    BE-->>UI: ProcessDetails[] (id, pid, cmd, alpine, startedAt)

    Note over UI: merge managedMap → enrich allProcesses
    UI->>UI: renderList() / renderSearch()

    alt user clicks kill (managed)
        UI->>Ex: stop(managedId)
        Ex->>TS: MSG_STOP_PROCESS
        TS->>PU: killProcessTree(process)
    else user clicks kill (unmanaged)
        UI->>Ex: killProcess(pid)
        Ex->>EJ: cordova exec "killProcess"
        EJ->>PU: killProcess(pid)
        PU-->>EJ: exit code check / throws on failure
    end

    UI->>UI: refresh() → update display
Loading

Reviews (6): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread src/pages/runningProcesses/runningProcesses.js
Comment thread src/index.d.ts
Comment thread src/pages/runningProcesses/runningProcesses.js
Comment thread src/pages/runningProcesses/runningProcesses.js
@bajrangCoder

This comment was marked as outdated.

Comment thread src/plugins/terminal/src/android/ProcessUtils.java Outdated
@bajrangCoder

This comment was marked as outdated.

Comment thread src/pages/runningProcesses/runningProcesses.js
Comment thread src/pages/runningProcesses/runningProcesses.js
@bajrangCoder

This comment was marked as outdated.

Comment thread src/pages/runningProcesses/runningProcesses.js
@bajrangCoder

This comment was marked as outdated.

Comment thread src/plugins/terminal/src/android/ProcessUtils.java Outdated
Comment thread src/pages/runningProcesses/runningProcesses.js
killProcess now checks the command exit code and propagates failures.
.sh process-name extraction now skips scripts only when they bootstrap another interpreter.
@bajrangCoder

This comment was marked as off-topic.

@RohitKushvaha01

RohitKushvaha01 commented Jun 19, 2026

Copy link
Copy Markdown
Member

Everything is good but I think it can't detect processes that are not started by Executor like child processes maybe you could read /proc/<pid> and show them

@bajrangCoder

Copy link
Copy Markdown
Member Author

Everything is good but I think it can't detect processes that are not started by Executor like child processes maybe you could read /proc/<pid> and show them

This is already implemented. listAllProcesses() scans /proc, filters processes by the app UID, and includes child/unmanaged processes as well as Executor-managed ones.

@bajrangCoder bajrangCoder merged commit f83e7a1 into main Jun 20, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 20, 2026
@bajrangCoder bajrangCoder deleted the feat/ui-manage-process branch June 20, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request translations Anything related to Translations Whether a Issue or PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

UI to Manage Running Terminal (Executor) Processes

2 participants