Skip to content

Commit 82aa3bf

Browse files
committed
[ai] Support working with Codex in WSL.
1 parent b8e95a1 commit 82aa3bf

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
This guide defines repository-wide instructions for coding agents working with the Telegram Desktop codebase.
44

5+
## Working from Codex on Windows + WSL
6+
7+
This checkout may be opened in Codex Desktop through the Windows UNC path `\\wsl.localhost\{distro}\home\{user}\Telegram\tdesktop`, while the real Linux path is `/home/{user}/Telegram/tdesktop`. Treat it as a WSL/Linux checkout first, not as a native Windows checkout.
8+
9+
- Prefer running repository-aware commands through WSL:
10+
11+
```powershell
12+
wsl.exe -d {distro} --cd /home/{user}/Telegram/tdesktop -- <command>
13+
```
14+
15+
- PowerShell can read and write files through the UNC path, but native Windows tools may see different ownership, path, executable, or line-ending behavior than Linux tools.
16+
- Git from PowerShell over `\\wsl.localhost\...` can fail with `detected dubious ownership`. Use WSL Git instead. Do not change global Git `safe.directory` settings unless the user explicitly asks for that.
17+
- Keep path styles matched to the shell. Use `/home/{user}/Telegram/tdesktop/...` with WSL commands, and quoted `\\wsl.localhost\{distro}\home\{user}\Telegram\tdesktop\...` paths with native Windows commands. Avoid passing UNC paths to Linux tools or Linux paths to native Windows tools unless the tool explicitly supports them.
18+
- If a command behaves strangely from the PowerShell UNC working directory, retry the same command through `wsl.exe -d {distro} --cd /home/{user}/Telegram/tdesktop -- ...` before concluding the repository or command is broken.
19+
- Recursive searches and repo inspection are usually faster and more faithful through WSL, for example `wsl.exe -d {distro} --cd /home/{user}/Telegram/tdesktop -- rg ...`.
20+
- Do not assume the WSL host has the build toolchain installed directly. In this setup, WSL may not have `cmake`, while Windows may have `cmake`, and the configured `out/` tree may still target the Linux Docker toolchain. Do not run native Windows `cmake --build out` against a Linux/Docker build tree.
21+
- For WSL/Linux builds, use the Docker build entry point from the repository root: `Telegram/build/docker/centos_env/build_debug.sh`. The Docker daemon must be reachable from WSL; checking `docker info` is fine, but do not start a build unless the user asked for one.
22+
- Existing build outputs may be Linux binaries, for example `out/Debug/Telegram` as an ELF executable, not `Telegram.exe`. Verify the build tree before assuming which platform produced it.
23+
- Be careful with text file line endings. In a WSL/Linux checkout, files should remain LF-only unless the file already uses another convention. CRLF finishing applies only to native, non-WSL Windows runs/checkouts. Do not let PowerShell or Windows tools silently rewrite WSL files to CRLF. If a file becomes mixed, normalize it back to the convention appropriate for the current checkout, without adding a UTF-8 BOM.
24+
- When using the local `task-think` skill from this WSL checkout, keep `.ai/...` artifacts and edited project text files LF-only. Treat the skill's Windows text-normalization phase as not applicable to WSL, except to record that line endings were checked and kept LF/no-BOM. Run CRLF normalization for `task-think` only in a native, non-WSL Windows checkout.
25+
526
## Build System Structure
627

728
The build system expects this directory layout:
@@ -28,6 +49,12 @@ cmake --build out --config Debug --target Telegram
2849

2950
That's it. The `out/` directory is already configured. The executable will be at `out/Debug/Telegram.exe`.
3051

52+
**From WSL, run through the Linux Docker build environment:**
53+
54+
```bash
55+
Telegram/build/docker/centos_env/build_debug.sh
56+
```
57+
3158
**Important:** When running cmake from a shell that doesn't support `cd`, use quoted absolute paths:
3259
```bash
3360
cmake --build "l:\Telegram\tx64\out" --config Debug --target Telegram
@@ -461,4 +488,3 @@ The `Error` template parameter defaults to `rpl::no_error`: `rpl::producer<Type,
461488
- Pass `rpl::lifetime` to `on_...` methods or store returned lifetime
462489
- Use `rpl::duplicate(producer)` to reuse a producer multiple times
463490
- Combined producers automatically unpack tuples in lambdas (works with `rpl::map`, `rpl::filter`, and `rpl::on_next`)
464-
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
FullExecPath=$PWD
5+
pushd `dirname $0` > /dev/null
6+
FullScriptPath=`pwd`
7+
popd > /dev/null
8+
9+
"$FullScriptPath/run.sh" bash -lc "cd /usr/src/tdesktop && cmake --build out --config Debug --target Telegram"
10+
cd "$FullExecPath"

Telegram/build/docker/centos_env/run.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ if [ ! -d "$FullScriptPath/../../../../../DesktopPrivate" ]; then
1313
exit
1414
fi
1515

16-
Command="$1"
17-
if [ "$Command" == "" ]; then
18-
Command="bash"
16+
if [ "$#" == "0" ]; then
17+
set -- bash
1918
fi
2019

21-
docker run -it --rm --cpus=8 --memory=22g -u $(id -u) -v $HOME/Telegram/DesktopPrivate:/usr/src/DesktopPrivate -v $HOME/Telegram/tdesktop:/usr/src/tdesktop tdesktop:centos_env $Command
20+
docker run -it --rm --cpus=8 --memory=22g -u $(id -u) -v $HOME/Telegram/DesktopPrivate:/usr/src/DesktopPrivate -v $HOME/Telegram/tdesktop:/usr/src/tdesktop tdesktop:centos_env "$@"

0 commit comments

Comments
 (0)