Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

source-control.md

257 lines14.2 KB

1# Source control
2​
3T3 Code integrates with GitHub, GitLab, Forgejo, Gitea, Bitbucket, Azure DevOps, and GitCafe to clone
4and publish repositories, create pull requests, and review changes.
5​
6## Review turn changes
7​
8A turn's changed files and diff show only the turn's own work. When a turn pulls, merges, or
9rebases, the files Git brought in are left out. A file stays in the list when the turn edited it,
10committed it, or fixed a conflict in it. Use the branch comparison to review everything that changed
11against your base branch. Restore still returns the complete saved workspace.
12​
13## Connect an account
14​
15Install Git and configure authentication on the machine running your T3 Code server. For a remote
16environment, do this on the remote machine. After signing in, open **Settings → Source Control**
17and choose **Rescan**.
18​
19### GitHub
20​
21T3 Code talks to GitHub's API directly and only needs a token. Any of these works, in this
22order of precedence:
23​
241. A token saved in **Settings → Source Control → GitHub**. It is kept in the server's secret
25 store, and works without the GitHub CLI.
262. `GH_TOKEN` (`GH_ENTERPRISE_TOKEN` with `GH_HOST` for GitHub Enterprise Server) in the
27 server's environment.
283. [GitHub CLI](https://cli.github.com/) 2.81.0 or newer, signed in with `gh auth login`.
29​
30If `gh` is signed in to several accounts or hosts, expand **GitHub** in the same place to pick
31the account each host uses or turn a host off. A saved token or `GH_TOKEN` takes precedence
32over that choice; a host turned off stays off either way.
33​
34For GitHub Enterprise, sign in with `gh auth login --hostname YOUR_HOST`. T3 Code treats a
35custom server name as GitHub once it has a credential for that host.
36​
37### Forgejo and Gitea
38​
39Install [Forgejo CLI (`fj`)](https://codeberg.org/forgejo-contrib/forgejo-cli) or
40[Gitea CLI (`tea`)](https://gitea.com/gitea/tea) 0.16 or later on your T3 Code server.
41Sign in with `fj --host https://your-server auth add-token` or `tea login add`.
42Repeat for each server you use, including Codeberg.
43​
44T3 Code prefers a matching `fj` login and falls back to `tea` when `fj` is unavailable
45or has no login for that server. Once an account is selected, failed actions stay on that
46account. Settings shows the detected CLI. Forgejo and Gitea share one integration entry.
47Servers hosted under a URL subpath, such as `https://example.com/forgejo`, use `tea` because
48fj 0.6 does not preserve the subpath when checking its account.
49​
50When cloning or publishing, use a full repository URL to select a specific server.
51You can use `owner/repo` when only one fj server is configured, or with your default `tea`
52login when fj is unavailable or unconfigured. With multiple fj servers, use the full URL.
53If you have multiple `tea` accounts on one server, select one with
54`tea login default <login-name>`. Git push and clone also need Git credentials or an SSH key
55for that server.
56​
57### GitLab
58​
59Install [GitLab CLI](https://gitlab.com/gitlab-org/cli), then sign in:
60​
61```bash
62glab auth login
63```
64​
65### Bitbucket
66​
67Open **Settings → Source Control**, expand **Bitbucket**, and choose how to sign in:
68​
69- **Access token**: a token created for one repository, project, or workspace. It can only reach
70 what it was created for.
71- **API token**: an Atlassian API token for your account, used with your account email. It can
72 reach every repository you can. Give it read/write access to repositories and pull requests, plus
73 user read access (`read:user:bitbucket`).
74​
75Choose **Save**; the change applies right away, and replaces any credential saved with the other
76method. Credentials are saved on the environment's server, so select a remote environment to
77configure it. Saved tokens can't be viewed again; enter a new one to replace it, or choose
78**Remove**.
79​
80If no credentials are saved, T3 Code falls back to these variables in the server's environment.
81Restart the server after changing them:
82​
83```bash
84export T3CODE_BITBUCKET_ACCESS_TOKEN="your-access-token"
85# or
86export T3CODE_BITBUCKET_EMAIL="you@example.com"
87export T3CODE_BITBUCKET_API_TOKEN="your-token"
88```
89​
90### Azure DevOps
91​
92Install [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/), add the DevOps extension, and sign in:
93​
94```bash
95az extension add --name azure-devops
96az login
97```
98​
99### GitCafe
100​
101Install the GitCafe CLI and sign in:
102​
103```bash
104bun install -g @gitcafe/cli
105cafe auth login --host https://git.cafe/api
106```
107​
108Alternatively, set `CAFE_TOKEN` in the server's environment and restart it. The token is only
109sent to the host `CAFE_HOST` names, which is `git.cafe` unless you set it. Repositories on
110`staging.git.cafe` need their own login with `--host https://staging.git.cafe/api`.
111​
112Line comments, reviewer requests, and labels are not available for GitCafe pull requests yet.
113Merging a stack lands it through GitCafe, and updating a branch restacks the layers above it.
114​
115## Start, clone, or publish a project
116​
117To start from nothing, choose **New project** in the command palette (`Cmd/Ctrl+K`), or
118**New project** under **Add Project** on any client, and type a name. T3 Code makes a Git
119repository in `~/.t3/projects` (the `projects` folder of your T3 data directory) with a README,
120an icon, and a first commit, then opens a new thread in it. The folder is named after the project,
121like `pinball-stats` for "Pinball Stats". Turn on **Create private repository on GitHub** to also
122publish it. If Git has no name or email on that machine, the project is created without the
123first commit.
124​
125Use **Add Project** in the command palette (`Cmd/Ctrl+K`) to clone a repository. Choose a hosting
126provider or paste a Git URL, then choose where to save it. The project opens right away while the
127clone runs in the background: you can write your first prompt, and sending waits until the files
128are in place. A toast tracks progress and lets you cancel; if the clone fails, retry it from the
129toast or from the banner above the composer.
130​
131For a local Git repository without a remote, **Publish Repository** creates a hosted repository,
132adds it as `origin`, and pushes your commits. If there are no commits yet, it creates the remote;
133make your first commit before pushing.
134​
135## Create a pull request
136​
137Use a thread's Git actions to commit, push, and create a pull request. T3 Code can generate commit
138messages, review titles, and descriptions from your changes.
139​
140Choose the writing style and model in **Settings → Source Control**. **Repository conventions**
141uses the project's instructions and recent commit subjects.
142​
143## Review and merge
144​
145Open **Pull requests** to review changes and comments, request reviewers, check out a branch,
146or merge. You can edit review titles and descriptions and your own comments where the host allows it.
147GitLab calls these merge requests.
148​
149Enable **Remove agent credits when merging** in Settings → Source Control to remove recognized
150agent co-author and generated-by lines from GitHub merge and squash commit messages. Human
151co-authors stay credited. The setting is off by default and projects can override it. It also
152applies to auto-merge, but not merge queues or native stack merges. Original commits keep their
153messages, so merge and rebase can still retain agent credits in those commits.
154​
155On web and desktop, hold **Shift** in the GitHub pull request list for quick actions.
156To close several, press **Close**, drag across the rows in the same group, and release.
157Press **Escape** before releasing to cancel. Failed closes stay in the list so you can retry them.
158​
159GitHub, GitLab, and Azure DevOps support auto-merge while checks are outstanding. GitHub also
160supports approving waiting fork workflows and opening a revert pull request for a merged change.
161​
162GitHub sharing is off by default. In Settings → Connections → GitHub sharing (Environments on mobile), choose
163**Read PRs** or **Read and act** for each environment you trust to share GitHub access.
164Enable both the original environment and the environment answering its requests on this client.
165**Read and act** can use broader GitHub permissions than the original environment's credential;
166only enable it for environments you control and trust. Changing a saved endpoint or removing an
167environment clears its permission.
168​
169GitHub review details, linked PR status, and permitted review actions can then use another
170connected environment signed in to the same GitHub account. Each needs a project on that host.
171A connected local environment is preferred for actions and can answer slow or failed reads.
172Browsers and mobile clients need a paired environment to use its GitHub credentials.
173Credentials stay on their machines. Previously verified credentials remain usable for routing
174for ten minutes during a GitHub outage; new credentials must be verified first. An action with
175an uncertain result is never automatically retried elsewhere. Listings, diffs, and checkout or
176PR creation from Git actions continue to use the project's environment.
177​
178For Azure DevOps, use the host website to change comments. Bitbucket does not support reopening a
179declined pull request.
180​
181### Mark files as viewed
182​
183Tick a file off in the **Code** tab once you have read it and it collapses; the toolbar keeps a
184running count. A tick belongs to the pull request rather than to a commit, so scoping the tab to a
185single commit keeps them. A file pushed to after you cleared it comes back marked **Changed**.
186​
187On GitHub these are GitHub's own viewed marks, so a review carries between T3 Code and github.com
188in either direction. Forgejo, GitLab, Bitbucket, and Azure DevOps expose no record T3 Code can read, so the
189server you are connected to keeps them instead: they follow you across the apps connected to that
190server, but the host's own site will not show them, and the count reads **viewed in T3 Code**.
191​
192The **Code** tab is a web and desktop surface. The mobile app reports a pull request's status but
193does not show its diff, so marks are made and read on web and desktop.
194​
195## Troubleshooting
196​
197- **Not authenticated:** run the provider's login command on the server, then rescan. For Bitbucket,
198 check the credentials saved in Settings → Source Control, or confirm the running server received
199 the environment variables.
200- **GitHub sign-in cannot be verified:** update GitHub CLI to at least 2.81.0, or save a token in Settings → Source Control.
201- **Push fails despite a connected account:** check the Git remote's credentials. SSH and HTTPS
202 remotes can require separate setup from the hosting provider's API access.
203- **A review cannot load:** open it on the host website while resolving connectivity, permissions,
204 or rate limits.
205​
206## Linked pull requests
207​
208A thread can hold several pull requests, including reviews from another repository on the same host.
209Use **Link pull request** in the command palette or **Linked pull requests** panel, or right-click a
210pull request link in the conversation. Creating a pull request from Git actions links it automatically.
211Agents can link their pull requests with the `link_pull_request` tool.
212​
213Use **Link this PR** in a branch-detected badge's tooltip to keep it with the thread. From a review
214on the Pull Requests page, **Link to thread** lets you search for an active thread. The review header
215also lists the threads that link to it, including archived threads, so you can return to their context.
216​
217Thread badges show a stack's layer count or the current review number with a count of additional
218links. Clicking a badge with more than one review opens the **Linked pull requests** panel. On mobile, the Git overview lists linked reviews and their stacks; tap a review to open it.
219Linking and unlinking are available in the web and desktop clients.
220​
221The **Linked pull requests** panel lists every review and groups stacks. Unlink a review from its
222row menu. An unlinked stack layer stays out of later syncs. Open linked reviews refresh on the server;
223closed reviews refresh periodically so reopening one on the host is detected. Merged reviews refresh
224when requested. A settled thread's reviews stop refreshing until you unsettle it. With **Auto-settle merged threads** enabled, a thread can settle after every linked
225review is terminal. An open or unsynced link keeps it active.
226​
227Ask the agent to watch, monitor, or babysit a pull request and it calls `watch_pull_request`. While
228the thread is active, the server checks the pull request every two minutes and wakes the agent when a
229check fails, the required checks pass, someone else comments or reviews, or the branch starts to
230conflict. Threads in a project that watch the same pull request share one check. On GitHub, a check
231first asks whether anything changed and reads the pull request only when it did, which keeps
232watching inside GitHub's rate limit. Comments from your own account do not wake it. Watching ends
233when the pull request merges or closes, after 10 wakes in a row that bring only comments, after 8
234failed reads in a row, or when you press Stop on the thread. A rate limit only pauses watching.
235Settling or archiving a thread also ends all its watches. Unsettle the thread before starting a new
236watch. Subagents cannot watch pull requests; the thread that delegated to them does. To start or stop
237it yourself, use the row menu in the **Linked pull requests** panel. In the thread details card, a
238watched pull request shows an eye; click it to stop watching.
239​
240A watched thread counts as working between wakes, so it stays in the **Working** section and does
241not auto-settle. Agents stop watching when they hand the work back to you, and the thread then
242returns to your inbox.
243​
244Cross-repository links use a project on the same host. Azure DevOps reviews require a project checked
245out from the matching organization and repository.
246​
247## GitHub stacks
248​
249The Pull Requests page shows each PR's position in its GitHub stack. Open the stack badge in a
250review to navigate its layers. **Merge stack** submits the selected pull request and every unmerged
251layer below it to GitHub together, respecting branch rules and merge queues. The confirmation shows
252the scope and merge strategy. GitHub rebases the remaining stack after merging.
253​
254**Rebase stack** updates remote branches from bottom to top without changing your local checkout.
255It can rewrite history and restart checks. If a layer fails, earlier updates remain; resolve that
256layer before retrying. GitHub may require manual conflict resolution after a lower layer is amended,
257even when its changes look independent. Stack actions require an environment that supports them.