Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

[![License](https://img.shields.io/badge/license-MIT-111111?style=flat-square)](./LICENSE)
[![npm](https://img.shields.io/npm/v/%40maria__rcks%2Ft1code?color=111111&label=npm&style=flat-square)](https://www.npmjs.com/package/@maria_rcks/t1code)
[![GitHub](https://img.shields.io/badge/github-maria--rcks%2Ft1code-111111?style=flat-square&logo=github)](https://github.com/maria-rcks/t1code)
[![GitHub](https://img.shields.io/badge/github-ahzs645%2Ft1chat-111111?style=flat-square&logo=github)](https://github.com/ahzs645/t1chat)

<img src="./assets/repo/t1code-preview.webp" alt="t1code terminal UI screenshot" width="1000" />

_T3Code, but in your terminal._

</div>

## t1code (code mode)

Run instantly:

```bash
Expand All @@ -27,10 +29,51 @@ bun add -g @maria_rcks/t1code
Develop from source:

```bash
git clone https://github.com/maria-rcks/t1code.git
git clone https://github.com/ahzs645/t1chat.git
cd t1code
bun install
bun dev:tui
```

## t1chat (chat mode)

<div align="center">
<img src="./assets/repo/t1chat-preview.png" alt="t1chat terminal UI screenshot" width="1000" />
</div>

t1chat is a chat-focused mode that transforms the TUI into a conversational interface inspired by [T3 Chat](https://t3.chat). It features a pink/magenta/lavender theme, a flat thread list grouped by time, and a streamlined UI without code-specific tools.

### What changes in chat mode

- Sidebar shows a flat thread list grouped by time (Today, Yesterday, Last 7 Days, etc.) instead of nested projects
- "New Chat" button and thread search in the sidebar
- Title shows "T1 Chat" instead of "T1 Code"
- Git tools, diff viewer, Chat/Plan toggle, and Full access button are hidden
- Settings and temp chat toggle in the top-right corner
- Composer placeholder says "Type your message here..."
- Pink/magenta/lavender color scheme matching T3 Chat

### Run chat mode

If installed globally:

```bash
t1chat
```

Run instantly:

```bash
bunx @maria_rcks/t1code t1chat
```

Develop from source:

```bash
git clone https://github.com/ahzs645/t1chat.git
cd t1code
bun install
T1CODE_CHAT_MODE=1 bun dev:tui
```

<sub>Based on T3 Code by [@t3dotgg](https://github.com/t3dotgg) and [@juliusmarminge](https://github.com/juliusmarminge).</sub>
45 changes: 45 additions & 0 deletions apps/tui/bin/t1chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bun

import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";

const entryPath = fileURLToPath(new URL("../dist/index.mjs", import.meta.url));

function printError(error) {
process.stderr.write(
`${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`,
);
}

process.env.T1CODE_CHAT_MODE = "1";

if (process.versions.bun === undefined) {
const bunBin = process.env.T1CODE_BUN_BIN?.trim() || "bun";
const child = spawn(bunBin, [entryPath, ...process.argv.slice(2)], {
stdio: "inherit",
env: process.env,
});

child.once("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});

child.once("error", (error) => {
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
printError("t1code requires Bun on your PATH to launch the TUI runtime.");
process.exit(1);
return;
}
printError(error);
process.exit(1);
});
} else {
import("../dist/index.mjs").catch((error) => {
printError(error);
process.exit(1);
});
}
3 changes: 2 additions & 1 deletion apps/tui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"bin": {
"t1": "./bin/t1code.js",
"t1code": "./bin/t1code.js"
"t1code": "./bin/t1code.js",
"t1chat": "./bin/t1chat.js"
},
"files": [
"README.md",
Expand Down
72 changes: 72 additions & 0 deletions apps/tui/src/profiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Profile management for t1chat mode.
*
* Profiles let users organize conversations under different personas.
* Each profile has a name, icon, and unique ID. Threads can be
* associated with a profile so switching profiles filters the sidebar.
*/

export interface Profile {
id: string;
name: string;
icon: string;
}

/** Nerd Font icons available for profile selection. */
export const PROFILE_ICON_OPTIONS: { icon: string; label: string }[] = [
{ icon: "󰭹", label: "Chat" },
{ icon: "󰫢", label: "Star" },
{ icon: "󰃀", label: "Bookmark" },
{ icon: "󰋑", label: "Heart" },
{ icon: "󰈻", label: "Flag" },
{ icon: "󱐋", label: "Lightning" },
{ icon: "󰐊", label: "Play" },
{ icon: "󰛕", label: "Sparkles" },
{ icon: "󰂞", label: "Bell" },
{ icon: "󰛨", label: "Bulb" },
{ icon: "󰋜", label: "Home" },
{ icon: "󰉋", label: "Folder" },
{ icon: "󰃭", label: "Calendar" },
{ icon: "󰇮", label: "Mail" },
{ icon: "󰈙", label: "File" },
{ icon: "󰂺", label: "Book" },
{ icon: "󰊗", label: "Briefcase" },
{ icon: "󰆼", label: "Database" },
{ icon: "󰳗", label: "Cube" },
{ icon: "󰕮", label: "Music" },
{ icon: "󰄀", label: "Camera" },
{ icon: "󰈈", label: "Eye" },
{ icon: "󰟃", label: "Globe" },
{ icon: "󰑴", label: "Graduate" },
];

export const DEFAULT_PROFILE: Profile = {
id: "default",
name: "Default",
icon: "󰭹",
};

export function createProfile(name: string, icon: string): Profile {
const slug = name
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "");
return {
id: `${slug}-${Date.now()}`,
name,
icon,
};
}

export function reorderProfiles(
profiles: Profile[],
fromIndex: number,
toIndex: number,
): Profile[] {
const result = [...profiles];
const [moved] = result.splice(fromIndex, 1);
if (moved) {
result.splice(toIndex, 0, moved);
}
return result;
}
3 changes: 2 additions & 1 deletion apps/tui/src/responsiveLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type TuiResponsiveLayout = Readonly<{
export function resolveTuiResponsiveLayout(input: {
viewportColumns: number;
sidebarCollapsedPreference: boolean;
isChatMode?: boolean;
}): TuiResponsiveLayout {
const openSidebarMainPanelColumns = input.viewportColumns - TUI_SIDEBAR_WIDTH - 1;
const showSidebarToggle =
Expand All @@ -53,7 +54,7 @@ export function resolveTuiResponsiveLayout(input: {
// should track sidebar visibility rather than the overall terminal width.
showWindowDots: showSidebar,
showSidebarAlphaBadge: showSidebar,
sidebarTitle: showSidebar ? "T1 Code" : "T1",
sidebarTitle: showSidebar ? (input.isChatMode ? "T1 Chat" : "T1 Code") : "T1",
showHeaderProjectBadge: input.viewportColumns >= 144,
showComposerModeLabels,
showComposerModelLabel,
Expand Down
Loading