Skip to content

refactor(agent): remove the 35 unused AgentService RPCs - #56

Merged
cooper (czxtm) merged 1 commit into
mainfrom
refactor/agent-drop-unused-rpcs
Sep 23, 2026
Merged

cooper (czxtm) merged 1 commit into
mainfrom
refactor/agent-drop-unused-rpcs

Conversation

@czxtm

Copy link
Copy Markdown
Member

The local agent's Connect AgentService had 48 RPCs, but live code calls only 13 of them. The other 35 duplicated REST endpoints, had no callers, and had drifted from their REST versions. This PR removes them end to end:

  • the 35 RPCs and the 46 messages only they used, from agent.proto
  • their Go handlers and helpers
  • 29 dead use-agent.ts hooks and their demo mocks
  • the regenerated gopb, TS and JSON output

That includes the Connect ReadFile/WriteFile/ListFiles handlers, which skipped the project-root containment that /api/files enforces. REST handlers and REST-backed hooks are unchanged. In total: 416 files, +794/-21,440. The hand-written part is 11 files, -2,688.

Verification by the implementer, against an origin/main baseline in the same worktree:

  • go build and go vet pass. go test fails only the same 5 tests as the baseline.
  • tsgo on apps/web reports 104 errors before and 100 after, with no new ones.
  • agent-client typechecks. Web vitest passes 49 of 50; the one failure is the known R2 cache test. vp lint reports 0 errors.

Notes on the generated code:

  • Generated Go was run through nix fmt to match the committed formatting.
  • The protoc-gen-go header version changes from v1.36.11 to v1.36.12, because the plugin is unpinned.
  • connect_entities_gen.go is reordered, because the custom plugin iterates a Go map.

Refs stackpanel-thq.8.2, ADR 0004

The local agent's Connect AgentService (packages/proto/proto/agent.proto)
had 48 RPCs, but live code calls only 13 of them: GetProject, GetApps,
GetVariables, GetUsers, GetSecrets, Exec, GetInstalledPackages,
GetProcesses, GetNixConfig, GetShellStatus, RebuildShell,
GetModuleOutputs and PatchNixData. The other 35 duplicated REST
endpoints, had no callers, and had drifted from their REST versions.
For example, the Connect ReadFile, WriteFile and ListFiles handlers
accepted absolute paths and skipped the project-root containment that
/api/files enforces.

Removed end to end:

- agent.proto: the 35 rpc entries, the 46 messages only they used, and
  the config/aws/sst imports they needed. This includes GetSstRequest,
  which existed only so the extra GetSst method that
  protoc-gen-connect-handlers emitted for GetSSTConfig would compile.
- Go agent: their handlers in connect_service.go and
  connect_handlers.go, all of connect_modules.go (including
  moduleToProto and its enum mappers, which already had no caller), and
  the isProcessRunning and writeNixEntityJSON helpers that only those
  handlers used. REST handlers are unchanged.
- Studio: the use-agent.ts hooks that called the removed RPCs, their
  query keys and proto type re-exports, the forceRefresh/isRefreshing
  fields of the useNixConfig wrapper (its only use of RefreshNixConfig;
  no component read them), and the demo MSW cases and fixtures that
  mocked the removed methods. REST-backed hooks are unchanged.
- Docs: the agent README and code comments that described the removed
  RPCs or pointed at the removed hooks.

packages/proto/gen and connect_entities_gen.go were regenerated with
`packages/proto/generate.sh buf`, then formatted with `nix fmt`, which
keeps the committed Go output clean for the flake's treefmt check. JSON
schemas for the removed messages were deleted. Regenerating also:

- bumps the protoc-gen-go header in every .pb.go from v1.36.11 to
  v1.36.12, because buf.gen.yaml does not pin that remote plugin;
- drops one blank line from agent.connect.go's imports under the
  current formatter;
- reorders connect_entities_gen.go, because protoc-gen-connect-handlers
  iterates a Go map.

Refs: stackpanel-thq.8.2
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Preview pr-56 has been destroyed.

@czxtm
cooper (czxtm) merged commit 0542a8e into main Sep 23, 2026
13 of 14 checks passed
@linear-code

linear-code Bot commented Sep 23, 2026

Copy link
Copy Markdown

ENG-838

@czxtm
cooper (czxtm) deleted the refactor/agent-drop-unused-rpcs branch September 23, 2026 12:57
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview pr-56 has been destroyed.

This branch had an error being deployed

1 failed and 1 active deployments
pr-56 — 2fb1a006 Deployed Sep 23, 2026 by czxtm via deploy #204
docs-preview — 2fb1a006 Deployed Sep 23, 2026 by czxtm via deploy #189
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