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