Chat composer: '#' context dropdown for issues (#1861) (archie) #1863

Closed
sam wants to merge 1 commits from feat/1000000000000001-chat-composer-context-dropdown-for-issues-1861 into main
pull from: feat/1000000000000001-chat-composer-context-dropdown-for-issues-1861
Owner

Added # issue context completion to the web chat composer alongside / slash commands, backed by a pluggable trigger completion model and a daemon-backed GET /api/issues endpoint.

What Changed

  • Backend Open Issues API:
    • internal/infrastructure/daemonrpc/client.go & internal/app/archied/harness.go: Added daemon.v1.IssueService/ListIssues RPC client and server registration forwarding caller identity (rpcidentity.Outgoing(ctx, presence.UI)).
    • internal/app/archied/repository_check.go & internal/app/archied/repository_access_test.go: Implemented ListIssues on repositoryServer, enforcing caller authentication (codes.Unauthenticated), access.ActionRead on access.KindTask (codes.PermissionDenied), and querying open issues across the caller organisation's configured repositories via IssuesWithLabel(ctx, owner, name, "") (capped at 200 issues).
    • internal/webui/api_repository_check.go, internal/webui/server.go, internal/webui/authorize.go, internal/webui/authorization_surfaces_test.go, internal/app/archieui/run.go: Exposed GET /api/issues mapped to access.KindTask and wired srv.Issues to the daemon RPC client.
  • Frontend Composer Completion & # Issue Dropdown:
    • ui/src/lib/api.ts: Added api.issues().
    • ui/src/chat/commands.ts: Generalized slash-only completion into a pluggable trigger model (detectTrigger, completionsFor, commandCompletionSource, issueCompletionSource, matchesFor, applyCompletion, moveSelection, resolveCompletionKey) supporting /, #, and future triggers.
    • ui/src/chat/state.ts: Added issueSpecs, activeTrigger, activeCompletionLabel, composerCaret, and lazy open-issue loading (refreshIssues) triggered when # is typed.
    • ui/src/chat/ChatSlashPalette.vue & ui/src/chat/ChatComposer.vue: Updated the completion listbox to display CompletionItem entries with dynamic aria-label ("Issues" for #, "Commands" for /), ArrowUp/ArrowDown navigation, Enter/Tab acceptance, click insertion, and Escape dismissal.
  • Tests:
    • ui/test/chat-composer-completion.test.ts: Added unit tests covering trigger detection (#, /, and custom triggers), issue/command filtering, mid-draft and multi-line token replacement (applyCompletion), and keyboard navigation (ArrowUp, ArrowDown, Enter, Tab, Escape, and exact slash command submission).
    • internal/app/archied/repository_access_test.go & internal/webui/authorization_surfaces_test.go: Added tests for ListIssues and HTTP authorization coverage on GET /api/issues.
    • e2e/checks/chat-composer.cjs: Extended the browser composer check to cover # issue dropdown filtering, Escape dismissal, and Tab insertion.

Verification

  • task check passed (UI build, vue-tsc typecheck, 108 UI unit tests, proto:check, proto:lint, db:check, golangci-lint, Go builds, and Go test suite).

workflow: implement · 80 iterations · 8795217 tokens (449849 fresh + 8345368 cached)

Added `#` issue context completion to the web chat composer alongside `/` slash commands, backed by a pluggable trigger completion model and a daemon-backed `GET /api/issues` endpoint. ### What Changed - **Backend Open Issues API**: - `internal/infrastructure/daemonrpc/client.go` & `internal/app/archied/harness.go`: Added `daemon.v1.IssueService/ListIssues` RPC client and server registration forwarding caller identity (`rpcidentity.Outgoing(ctx, presence.UI)`). - `internal/app/archied/repository_check.go` & `internal/app/archied/repository_access_test.go`: Implemented `ListIssues` on `repositoryServer`, enforcing caller authentication (`codes.Unauthenticated`), `access.ActionRead` on `access.KindTask` (`codes.PermissionDenied`), and querying open issues across the caller organisation's configured repositories via `IssuesWithLabel(ctx, owner, name, "")` (capped at 200 issues). - `internal/webui/api_repository_check.go`, `internal/webui/server.go`, `internal/webui/authorize.go`, `internal/webui/authorization_surfaces_test.go`, `internal/app/archieui/run.go`: Exposed `GET /api/issues` mapped to `access.KindTask` and wired `srv.Issues` to the daemon RPC client. - **Frontend Composer Completion & `#` Issue Dropdown**: - `ui/src/lib/api.ts`: Added `api.issues()`. - `ui/src/chat/commands.ts`: Generalized slash-only completion into a pluggable trigger model (`detectTrigger`, `completionsFor`, `commandCompletionSource`, `issueCompletionSource`, `matchesFor`, `applyCompletion`, `moveSelection`, `resolveCompletionKey`) supporting `/`, `#`, and future triggers. - `ui/src/chat/state.ts`: Added `issueSpecs`, `activeTrigger`, `activeCompletionLabel`, `composerCaret`, and lazy open-issue loading (`refreshIssues`) triggered when `#` is typed. - `ui/src/chat/ChatSlashPalette.vue` & `ui/src/chat/ChatComposer.vue`: Updated the completion listbox to display `CompletionItem` entries with dynamic `aria-label` (`"Issues"` for `#`, `"Commands"` for `/`), `ArrowUp`/`ArrowDown` navigation, `Enter`/`Tab` acceptance, click insertion, and `Escape` dismissal. - **Tests**: - `ui/test/chat-composer-completion.test.ts`: Added unit tests covering trigger detection (`#`, `/`, and custom triggers), issue/command filtering, mid-draft and multi-line token replacement (`applyCompletion`), and keyboard navigation (`ArrowUp`, `ArrowDown`, `Enter`, `Tab`, `Escape`, and exact slash command submission). - `internal/app/archied/repository_access_test.go` & `internal/webui/authorization_surfaces_test.go`: Added tests for `ListIssues` and HTTP authorization coverage on `GET /api/issues`. - `e2e/checks/chat-composer.cjs`: Extended the browser composer check to cover `#` issue dropdown filtering, `Escape` dismissal, and `Tab` insertion. ### Verification - `task check` passed (UI build, `vue-tsc` typecheck, 108 UI unit tests, `proto:check`, `proto:lint`, `db:check`, `golangci-lint`, Go builds, and Go test suite). --- *workflow: implement · 80 iterations · 8795217 tokens (449849 fresh + 8345368 cached)*
sam added 1 commit 2026-11-12 04:13:52 +00:00
Chat composer: '#' context dropdown for issues (#1861) (archie)
ci/woodpecker/pr/quality Pipeline was successful
Quality / check (pull_request) Successful in 4m18s
09c2c55762
sam left a comment
Author
Owner

Findings outside the diff:

  • internal/app/archieui/run.go:146: Run calls wireDaemon(opts, srv, &cleanups) and aborts startup if it returns an error. wireDaemon unconditionally delegates to wireHarness, which calls harnessrpc.Dial(opts.Daemon.Target, opts.identity).

However, harnessrpc.Dial explicitly rejects a nil TLS identity (if id == nil { return nil, nil, errors.New("harness sessions need [tls] ca_file and cert_dir") }), whereas rpctls.Load returns nil, nil in plaintext loopback mode and every other RPC client (staterpc, gatewayrpc, messagingrpc, daemonrpc) as well as the daemon's own listener (setupDaemonRPC in internal/app/archied/harness.go, which states "Without certificates it binds only loopback and does not serve terminals") supports plaintext loopback without TLS certificates. Because wireHarness treats opts.identity == nil as a fatal error instead of leaving srv.HarnessTerminal and srv.SandboxView nil (which the HTTP handlers already answer with 503 Service Unavailable), archieui.Run cannot start at all in plaintext loopback mode.

In addition, if opts.Daemon.Target is empty (for example in a flags-only invocation without a config file, since withDefaults in internal/app/archieui/config.go does not default Daemon.Target and Options.validate() does not require it), wireDaemon still calls daemonrpc.Dial("", opts.identity) and harnessrpc.Dial("", opts.identity), failing startup instead of either skipping daemon wiring or defaulting Daemon.Target.

  • e2e/checks/chat-composer.cjs:7: ChatComposer.vue sets an explicit role="combobox" on <Textarea> (aria-label="Message Archie"), which Vue passes through to the underlying <textarea> root element (ui/src/chat/ChatComposer.vue:211-220). In ARIA and Playwright's role selector engine, an explicit role="combobox" overrides <textarea>'s implicit textbox role. Querying page.getByRole('textbox', { name: 'Message Archie', exact: true }) will therefore match 0 elements and time out at await composer.waitFor().
  • internal/app/servicekit/runtimeconfig.go:27: cp.RuntimeConfig (controlplanestore.runtimeConfigFrom at internal/infrastructure/controlplanestore/runtime_config.go:97-105) layers ForgeConnectionsKind by clearing out.Forge.Type, out.Forge.Host, out.Forge.Token = "", "", config.SecretRef{} when no "default" root connection is present in the stored forge-connections document (tested in TestForgeLayeringReadsTheConnection as "a document with no root connection disables the forge").

However, servicekit.RuntimeConfig immediately passes the layered config to configuration.Validate(&cfg) (line 41), which calls validateSingleIdentity (internal/infrastructure/configuration/validate.go:211-219) whenever len(cfg.Identities) == 0:

if !forgeTypePattern.MatchString(cfg.Forge.Type) {
    return fmt.Errorf("%w: forge.type %q (want none or the name of an installed forge package)", ErrInvalidInput, cfg.Forge.Type)
}

Because forgeTypePattern (^[a-z0-9][a-z0-9-]*$) rejects "" (expecting "none", "off", or "disabled" per configuration.ForgeDisabled), servicekit.RuntimeConfig fails with validate database settings: invalid configuration: forge.type "" (want none or the name of an installed forge package):

  1. In archied, removing the "default" forge connection is rejected on live watch updates, and report(wrapped) records that validation error across every layered control-plane kind in versions.
  2. In archie-gateway, relayer calls servicekit.RuntimeConfig on provider-settings, model-aliases, and tool-settings updates; because cp.RuntimeConfig layers forge-connections into cfg before configuration.Validate(&cfg) runs, a forge-connections document without "default" causes unrelated gateway setting updates to fail validation.
  3. On subsequent boots or SIGHUP reloads, both archied (loadRuntimeConfig) and archie-gateway (openState) fail to start.
  • internal/app/archieui/config.go:129: When Resolve runs without a configuration file (o.Config == "" or the path at o.Config does not exist, which readProjection explicitly allows so "the process is fully drivable by flags"), project and merge are skipped and withDefaults is responsible for filling service targets that are not required via CLI flags. withDefaults populates o.Messaging.Target from config.LookupService(config.ServiceNameMessaging), and validate checks o.Gateway.Target and o.State.Target, but o.Daemon.Target is neither defaulted in withDefaults nor validated in validate (and cmd/archie-ui/main.go defines no -daemon-target flag).

As a result, any flags-only run (or Resolve call without an on-disk config file) returns Options with Daemon.Target == "", which then fails at startup in Run -> wireDaemon (internal/app/archieui/run.go:102,147,160) when daemonrpc.Dial and harnessrpc.Dial attempt to dial an empty target.

  • internal/app/archieui/run.go:113: In Run, liveCtx, stopLive := context.WithCancel(ctx) is created and passed only to go srv.RunLive(liveCtx), while go pumpEvents(ctx, srv, opts.EventPollInterval, log) and go presence.Run(ctx, presence.UI, servicekit.Build(), tasks, srv.Health, log) (as well as compose(ctx, ...) which starts a background servicekit.RunningVersions poller) are started with the caller's ctx before Listen is called.

If Listen fails (lines 118-121) or serve returns a listener error while ctx is still active, Run returns and its deferred cleanups close the staterpc and gatewayrpc clients, but pumpEvents, presence.Run, and RunningVersions continue running in leaked goroutines against the closed tasks client until the caller's ctx is eventually cancelled.

Findings outside the diff: - `internal/app/archieui/run.go:146`: `Run` calls `wireDaemon(opts, srv, &cleanups)` and aborts startup if it returns an error. `wireDaemon` unconditionally delegates to `wireHarness`, which calls `harnessrpc.Dial(opts.Daemon.Target, opts.identity)`. However, `harnessrpc.Dial` explicitly rejects a `nil` TLS identity (`if id == nil { return nil, nil, errors.New("harness sessions need [tls] ca_file and cert_dir") }`), whereas `rpctls.Load` returns `nil, nil` in plaintext loopback mode and every other RPC client (`staterpc`, `gatewayrpc`, `messagingrpc`, `daemonrpc`) as well as the daemon's own listener (`setupDaemonRPC` in `internal/app/archied/harness.go`, which states `"Without certificates it binds only loopback and does not serve terminals"`) supports plaintext loopback without TLS certificates. Because `wireHarness` treats `opts.identity == nil` as a fatal error instead of leaving `srv.HarnessTerminal` and `srv.SandboxView` `nil` (which the HTTP handlers already answer with `503 Service Unavailable`), `archieui.Run` cannot start at all in plaintext loopback mode. In addition, if `opts.Daemon.Target` is empty (for example in a flags-only invocation without a config file, since `withDefaults` in `internal/app/archieui/config.go` does not default `Daemon.Target` and `Options.validate()` does not require it), `wireDaemon` still calls `daemonrpc.Dial("", opts.identity)` and `harnessrpc.Dial("", opts.identity)`, failing startup instead of either skipping daemon wiring or defaulting `Daemon.Target`. - `e2e/checks/chat-composer.cjs:7`: `ChatComposer.vue` sets an explicit `role="combobox"` on `<Textarea>` (`aria-label="Message Archie"`), which Vue passes through to the underlying `<textarea>` root element (`ui/src/chat/ChatComposer.vue:211-220`). In ARIA and Playwright's role selector engine, an explicit `role="combobox"` overrides `<textarea>`'s implicit `textbox` role. Querying `page.getByRole('textbox', { name: 'Message Archie', exact: true })` will therefore match 0 elements and time out at `await composer.waitFor()`. - `internal/app/servicekit/runtimeconfig.go:27`: `cp.RuntimeConfig` (`controlplanestore.runtimeConfigFrom` at `internal/infrastructure/controlplanestore/runtime_config.go:97-105`) layers `ForgeConnectionsKind` by clearing `out.Forge.Type, out.Forge.Host, out.Forge.Token = "", "", config.SecretRef{}` when no `"default"` root connection is present in the stored `forge-connections` document (tested in `TestForgeLayeringReadsTheConnection` as `"a document with no root connection disables the forge"`). However, `servicekit.RuntimeConfig` immediately passes the layered config to `configuration.Validate(&cfg)` (line 41), which calls `validateSingleIdentity` (`internal/infrastructure/configuration/validate.go:211-219`) whenever `len(cfg.Identities) == 0`: ```go if !forgeTypePattern.MatchString(cfg.Forge.Type) { return fmt.Errorf("%w: forge.type %q (want none or the name of an installed forge package)", ErrInvalidInput, cfg.Forge.Type) } ``` Because `forgeTypePattern` (`^[a-z0-9][a-z0-9-]*$`) rejects `""` (expecting `"none"`, `"off"`, or `"disabled"` per `configuration.ForgeDisabled`), `servicekit.RuntimeConfig` fails with `validate database settings: invalid configuration: forge.type "" (want none or the name of an installed forge package)`: 1. In `archied`, removing the `"default"` forge connection is rejected on live watch updates, and `report(wrapped)` records that validation error across every layered control-plane kind in `versions`. 2. In `archie-gateway`, `relayer` calls `servicekit.RuntimeConfig` on `provider-settings`, `model-aliases`, and `tool-settings` updates; because `cp.RuntimeConfig` layers `forge-connections` into `cfg` before `configuration.Validate(&cfg)` runs, a `forge-connections` document without `"default"` causes unrelated gateway setting updates to fail validation. 3. On subsequent boots or `SIGHUP` reloads, both `archied` (`loadRuntimeConfig`) and `archie-gateway` (`openState`) fail to start. - `internal/app/archieui/config.go:129`: When `Resolve` runs without a configuration file (`o.Config == ""` or the path at `o.Config` does not exist, which `readProjection` explicitly allows so "the process is fully drivable by flags"), `project` and `merge` are skipped and `withDefaults` is responsible for filling service targets that are not required via CLI flags. `withDefaults` populates `o.Messaging.Target` from `config.LookupService(config.ServiceNameMessaging)`, and `validate` checks `o.Gateway.Target` and `o.State.Target`, but `o.Daemon.Target` is neither defaulted in `withDefaults` nor validated in `validate` (and `cmd/archie-ui/main.go` defines no `-daemon-target` flag). As a result, any flags-only run (or `Resolve` call without an on-disk config file) returns `Options` with `Daemon.Target == ""`, which then fails at startup in `Run` -> `wireDaemon` (`internal/app/archieui/run.go:102,147,160`) when `daemonrpc.Dial` and `harnessrpc.Dial` attempt to dial an empty target. - `internal/app/archieui/run.go:113`: In `Run`, `liveCtx, stopLive := context.WithCancel(ctx)` is created and passed only to `go srv.RunLive(liveCtx)`, while `go pumpEvents(ctx, srv, opts.EventPollInterval, log)` and `go presence.Run(ctx, presence.UI, servicekit.Build(), tasks, srv.Health, log)` (as well as `compose(ctx, ...)` which starts a background `servicekit.RunningVersions` poller) are started with the caller's `ctx` before `Listen` is called. If `Listen` fails (lines 118-121) or `serve` returns a listener error while `ctx` is still active, `Run` returns and its deferred `cleanups` close the `staterpc` and `gatewayrpc` clients, but `pumpEvents`, `presence.Run`, and `RunningVersions` continue running in leaked goroutines against the closed `tasks` client until the caller's `ctx` is eventually cancelled.
@@ -0,0 +188,4 @@
assert.deepEqual(applyCompletion("#18", 3, "#1861"), {
text: "#1861 ",
cursor: 6,
});
Author
Owner

When completing a trigger token in the middle of a sentence that is already followed by whitespace ("Implement #186 now" at caret 14), applyCompletion unconditionally appends a trailing space before after (" now"), producing two consecutive spaces ("Implement #1861 now"), and this test codifies the double space as expected output. If after already starts with whitespace, avoiding a duplicate space (or advancing the cursor past the existing space) and asserting "Implement #1861 now" would prevent double spaces on mid-sentence completions.

When completing a trigger token in the middle of a sentence that is already followed by whitespace (`"Implement #186 now"` at caret 14), `applyCompletion` unconditionally appends a trailing space before `after` (`" now"`), producing two consecutive spaces (`"Implement #1861 now"`), and this test codifies the double space as expected output. If `after` already starts with whitespace, avoiding a duplicate space (or advancing the cursor past the existing space) and asserting `"Implement #1861 now"` would prevent double spaces on mid-sentence completions.
Author
Owner

Closed and will be implemented with #1882

Closed and will be implemented with #1882
sam closed this pull request 2026-11-12 11:40:43 +00:00
sam deleted branch feat/1000000000000001-chat-composer-context-dropdown-for-issues-1861 2026-11-12 11:40:48 +00:00

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1863