feat(channels): generic chat box with lazy repo attach#2735
Merged
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
013c3a5 to
f8d8fc4
Compare
In the channels experience, drop the up-front repo/branch picker. A channel task is now a generic chat box: it can be a coding task, an analysis task, or a non-code task (e.g. an email) that needs no repo. The agent decides at runtime whether it needs a repo, clones one only when needed, and asks the user (via AskUserQuestion) if it can't tell which repo to use. Works in local/worktree mode and cloud mode. - UI: allowNoRepo flag (channel-only) hides the repo/branch pickers and removes the submit gate; /code/ is unchanged. - Saga: a repo-less local task starts an agent in a per-task scratch dir (ensureScratchDir) instead of skipping the session; workspace.verify treats the scratch dir as valid. - Agent: channelMode is derived server-side from the scratch path (so it survives reconnects). It enables a channel system-prompt and two local tools, list_repos (gh) and clone_repo (clones into a scratch subdir, no cwd rebind), gated on channelMode. Cloud channel tasks rely on the existing cloud "No Repository Mode" prompt; the new tools are local-only for now. Generated-By: PostHog Code Task-Id: 9c51d9dc-d108-41b2-abdd-0be442a5e36d
A repo-less channel task has no workspace row, so useCwd resolved no cwd
and TaskLogsPanel rendered the WorkspaceSetupPrompt ("Select a repository
folder") for every such task — before the agent ever connected, and via a
dedicated screen rather than letting the agent decide and ask.
Synthesize a local-mode workspace from the on-disk scratch dir (the path
is deterministic from the task id) in getWorkspace and getAllWorkspaces,
and clean the scratch dir up on delete. The task now resolves the scratch
dir as its cwd, skips the prompt, and connects the agent — which decides
whether a repo is needed and asks via AskUserQuestion only for coding work.
Generated-By: PostHog Code
Task-Id: 9c51d9dc-d108-41b2-abdd-0be442a5e36d
…po task The synthetic scratch workspace was correct server-side, but the client's workspace.getAll query is only invalidated after workspace.create — which repo-less channel tasks skip. So the cached (empty) result kept repoPath null and the "Select a repository folder" prompt stayed up over the running task. - Provision the scratch dir before onTaskReady so it exists when the task view mounts. - Invalidate workspace.getAll after a no-repo task is created so the view refetches the synthetic scratch workspace, resolves its cwd, and shows the running session instead of the repo prompt. Generated-By: PostHog Code Task-Id: 9c51d9dc-d108-41b2-abdd-0be442a5e36d
- clone_repo: redact the GitHub token from any error text, so a git failure that echoes the credential-bearing remote URL can't leak it into the tool result / transcript. - clone_repo: make it idempotent — if the repo is already cloned at the target path, reuse it (optionally re-checking out the branch) instead of letting git abort on a non-empty destination. - isScratchPath: match an actual path prefix against the real scratch base (derived from the worktree location) instead of scanning for the folder name anywhere in the path, so an unrelated/malicious dir named posthog-code-scratch can't spuriously enable channel mode. AgentService now injects IWorkspaceSettings to resolve the base. Generated-By: PostHog Code Task-Id: 9c51d9dc-d108-41b2-abdd-0be442a5e36d
15cf907 to
57da555
Compare
Contributor
|
Reviews (2): Last reviewed commit: "fix(channels): address Greptile review o..." | Re-trigger Greptile |
charlesvien
approved these changes
Jun 19, 2026
charlesvien
left a comment
Member
There was a problem hiding this comment.
Pulled, tested, committed a few fixes/safety guards/reused some existing utils we have.
I'd be comfortable merging from a "does this break Code" standpoint. I also tested cloud runs locally by building the agent package changes to my local background agents running on docker containers and everything appears to work as expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
video explanation
https://www.loom.com/share/f352af8d74194f7a9c9e5d2010b6f00f
What & why
In the channels experience, this drops the up-front repo/branch picker. A channel task becomes a generic chat box: it can be a coding task (needs a repo), an analysis task (PostHog MCP, maybe no repo), or a non-code task like sending an email (no repo at all). The agent decides at runtime whether it needs a repo, clones one only when needed, and asks the user (via the built-in
AskUserQuestiontool) when it can't determine which repo to use. Candidates = all repos, prioritizing those named in the channel'sCONTEXT.md.Mirrors how the Slack bot behaves (that repo-inference lives in
PostHog/posthog), but implemented here. Works in local/worktree mode (for dev testing) and cloud mode.How it works
UI (channel-only
allowNoRepo)WebsiteNewTask→TaskInputhides the repo/folder picker, branch selector, env selector, and additional-dirs button, and removes the submit gate. The workspace-mode select stays (so you can run local)./code/is untouched.Task creation / saga
ensureScratchDir). No repo ⇒ no workspace, no clone.workspace.verifytreats an existing scratch dir as valid (no spurious "working directory no longer exists").Agent
channelModeis derived server-side from the scratch path (isScratchPath), so it survives reconnects with no client plumbing.channelMode:list_repos— lists candidates viaghclone_repo— clones into<cwd>/repos/<owner/repo>(a scratch subdir, no cwd rebind, conversation preserved)Scope / follow-ups
list_repos/clone_repotools are local-only for now.PostHog/posthogaccepts a no-repositorycloud Task/TaskRun before relying on cloud channel mode (out of scope for this repo).Testing
pnpm typecheck(22 pkgs), biome lint cleanlist_repos/AskUserQuestion); then name a repo (→clone_repo).Created with PostHog Code