Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22c035984e | |||
| d35037df01 | |||
| 99097090e6 | |||
| 6f35eb77ae |
@@ -0,0 +1,104 @@
|
|||||||
|
"""add config profiles, includes, mounts, and tool instance profile selection
|
||||||
|
|
||||||
|
Revision ID: 0013_add_config_profiles
|
||||||
|
Revises: 0012_default_port_req
|
||||||
|
Create Date: 2026-05-24 12:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "0013_add_config_profiles"
|
||||||
|
down_revision: Union[str, None] = "0012_default_port_req"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# Create config_profiles table
|
||||||
|
op.create_table(
|
||||||
|
"config_profiles",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("name", sa.String(length=255), nullable=False),
|
||||||
|
sa.Column("description", sa.Text(), nullable=True),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
sa.UniqueConstraint("user_id", "name", name="uq_config_profiles_user_name"),
|
||||||
|
)
|
||||||
|
op.create_index("idx_config_profiles_user", "config_profiles", ["user_id"])
|
||||||
|
|
||||||
|
# Create config_includes table
|
||||||
|
op.create_table(
|
||||||
|
"config_includes",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("profile_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("included_profile_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("order_index", sa.Integer(), nullable=False, server_default="0"),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["profile_id"], ["config_profiles.id"], ondelete="CASCADE"),
|
||||||
|
sa.ForeignKeyConstraint(["included_profile_id"], ["config_profiles.id"], ondelete="CASCADE"),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
sa.UniqueConstraint("profile_id", "included_profile_id", name="uq_config_includes_pair"),
|
||||||
|
)
|
||||||
|
op.create_index("idx_config_includes_profile", "config_includes", ["profile_id"])
|
||||||
|
op.create_index("idx_config_includes_included", "config_includes", ["included_profile_id"])
|
||||||
|
|
||||||
|
# Create config_mounts table
|
||||||
|
op.create_table(
|
||||||
|
"config_mounts",
|
||||||
|
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("profile_id", postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column("mount_path", sa.String(length=1024), nullable=False),
|
||||||
|
sa.Column("content", sa.Text(), nullable=True),
|
||||||
|
sa.Column("source_profile_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
sa.Column("order_index", sa.Integer(), nullable=False, server_default="0"),
|
||||||
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(["profile_id"], ["config_profiles.id"], ondelete="CASCADE"),
|
||||||
|
sa.ForeignKeyConstraint(["source_profile_id"], ["config_profiles.id"], ondelete="SET NULL"),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
)
|
||||||
|
op.create_index("idx_config_mounts_profile", "config_mounts", ["profile_id"])
|
||||||
|
|
||||||
|
# Add selected_profile_id to tool_instances
|
||||||
|
op.add_column(
|
||||||
|
"tool_instances",
|
||||||
|
sa.Column("selected_profile_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||||
|
)
|
||||||
|
op.create_foreign_key(
|
||||||
|
"fk_tool_instances_selected_profile",
|
||||||
|
"tool_instances",
|
||||||
|
"config_profiles",
|
||||||
|
["selected_profile_id"],
|
||||||
|
["id"],
|
||||||
|
ondelete="SET NULL",
|
||||||
|
)
|
||||||
|
op.create_index("idx_tool_instances_selected_profile", "tool_instances", ["selected_profile_id"])
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# Remove selected_profile_id from tool_instances
|
||||||
|
op.drop_index("idx_tool_instances_selected_profile", table_name="tool_instances")
|
||||||
|
op.drop_constraint("fk_tool_instances_selected_profile", "tool_instances", type_="foreignkey")
|
||||||
|
op.drop_column("tool_instances", "selected_profile_id")
|
||||||
|
|
||||||
|
# Drop config_mounts
|
||||||
|
op.drop_index("idx_config_mounts_profile", table_name="config_mounts")
|
||||||
|
op.drop_table("config_mounts")
|
||||||
|
|
||||||
|
# Drop config_includes
|
||||||
|
op.drop_index("idx_config_includes_included", table_name="config_includes")
|
||||||
|
op.drop_index("idx_config_includes_profile", table_name="config_includes")
|
||||||
|
op.drop_table("config_includes")
|
||||||
|
|
||||||
|
# Drop config_profiles
|
||||||
|
op.drop_index("idx_config_profiles_user", table_name="config_profiles")
|
||||||
|
op.drop_table("config_profiles")
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
from src.models.base import Base
|
from src.models.base import Base
|
||||||
from src.models.config_folder import ConfigFolder
|
from src.models.config_folder import ConfigFolder
|
||||||
|
from src.models.config_include import ConfigInclude
|
||||||
|
from src.models.config_mount import ConfigMount
|
||||||
|
from src.models.config_profile import ConfigProfile
|
||||||
from src.models.git_repository import GitRepository
|
from src.models.git_repository import GitRepository
|
||||||
from src.models.project import Project
|
from src.models.project import Project
|
||||||
from src.models.ssh_key import SSHKey
|
from src.models.ssh_key import SSHKey
|
||||||
@@ -8,4 +11,17 @@ from src.models.tool_type import ToolType
|
|||||||
from src.models.user import User
|
from src.models.user import User
|
||||||
from src.models.user_config import UserConfig
|
from src.models.user_config import UserConfig
|
||||||
|
|
||||||
__all__ = ["Base", "ConfigFolder", "GitRepository", "Project", "SSHKey", "ToolInstance", "ToolType", "User", "UserConfig"]
|
__all__ = [
|
||||||
|
"Base",
|
||||||
|
"ConfigFolder",
|
||||||
|
"ConfigInclude",
|
||||||
|
"ConfigMount",
|
||||||
|
"ConfigProfile",
|
||||||
|
"GitRepository",
|
||||||
|
"Project",
|
||||||
|
"SSHKey",
|
||||||
|
"ToolInstance",
|
||||||
|
"ToolType",
|
||||||
|
"User",
|
||||||
|
"UserConfig",
|
||||||
|
]
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class ConfigFolder(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|||||||
project_overrides: Mapped[dict | None] = mapped_column(
|
project_overrides: Mapped[dict | None] = mapped_column(
|
||||||
JSON, default=dict, nullable=True
|
JSON, default=dict, nullable=True
|
||||||
) # {"project_id": {"mount_path": "...", "files": {...}}}
|
) # {"project_id": {"mount_path": "...", "files": {...}}}
|
||||||
|
# DEPRECATED: Legacy auto-mounting flag. No longer used for launch-time
|
||||||
|
# auto-mounting. Use ConfigProfile and ToolInstance.selected_profile_id instead.
|
||||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||||
|
|
||||||
user: Mapped["User"] = relationship()
|
user: Mapped["User"] = relationship()
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from sqlalchemy import ForeignKey, Integer, UniqueConstraint
|
||||||
|
from sqlalchemy import Uuid as UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from src.models.config_profile import ConfigProfile
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigInclude(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||||
|
__tablename__ = "config_includes"
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint("profile_id", "included_profile_id", name="uq_config_includes_pair"),
|
||||||
|
)
|
||||||
|
|
||||||
|
profile_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(), ForeignKey("config_profiles.id", ondelete="CASCADE"), nullable=False
|
||||||
|
)
|
||||||
|
included_profile_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(), ForeignKey("config_profiles.id", ondelete="CASCADE"), nullable=False
|
||||||
|
)
|
||||||
|
order_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||||
|
|
||||||
|
profile: Mapped["ConfigProfile"] = relationship(
|
||||||
|
"ConfigProfile",
|
||||||
|
foreign_keys=[profile_id],
|
||||||
|
back_populates="includes",
|
||||||
|
)
|
||||||
|
included_profile: Mapped["ConfigProfile"] = relationship(
|
||||||
|
"ConfigProfile",
|
||||||
|
foreign_keys=[included_profile_id],
|
||||||
|
)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from sqlalchemy import ForeignKey, Integer, String, Text
|
||||||
|
from sqlalchemy import Uuid as UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from src.models.config_profile import ConfigProfile
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigMount(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||||
|
__tablename__ = "config_mounts"
|
||||||
|
|
||||||
|
profile_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(), ForeignKey("config_profiles.id", ondelete="CASCADE"), nullable=False
|
||||||
|
)
|
||||||
|
mount_path: Mapped[str] = mapped_column(String(1024), nullable=False)
|
||||||
|
content: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
|
source_profile_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||||
|
UUID(), ForeignKey("config_profiles.id", ondelete="SET NULL"), nullable=True
|
||||||
|
)
|
||||||
|
order_index: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||||
|
|
||||||
|
profile: Mapped["ConfigProfile"] = relationship(
|
||||||
|
"ConfigProfile",
|
||||||
|
foreign_keys=[profile_id],
|
||||||
|
back_populates="mounts",
|
||||||
|
)
|
||||||
|
source_profile: Mapped["ConfigProfile | None"] = relationship(
|
||||||
|
"ConfigProfile",
|
||||||
|
foreign_keys=[source_profile_id],
|
||||||
|
)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from sqlalchemy import ForeignKey, String, Text, UniqueConstraint
|
||||||
|
from sqlalchemy import Uuid as UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from src.models.user import User
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigProfile(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||||
|
__tablename__ = "config_profiles"
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint("user_id", "name", name="uq_config_profiles_user_name"),
|
||||||
|
)
|
||||||
|
|
||||||
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(), ForeignKey("users.id", ondelete="CASCADE"), nullable=False
|
||||||
|
)
|
||||||
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
|
|
||||||
|
user: Mapped["User"] = relationship()
|
||||||
|
includes: Mapped[list["ConfigInclude"]] = relationship(
|
||||||
|
"ConfigInclude",
|
||||||
|
foreign_keys="ConfigInclude.profile_id",
|
||||||
|
back_populates="profile",
|
||||||
|
cascade="all, delete-orphan",
|
||||||
|
order_by="ConfigInclude.order_index",
|
||||||
|
)
|
||||||
|
mounts: Mapped[list["ConfigMount"]] = relationship(
|
||||||
|
"ConfigMount",
|
||||||
|
back_populates="profile",
|
||||||
|
cascade="all, delete-orphan",
|
||||||
|
order_by="ConfigMount.order_index",
|
||||||
|
)
|
||||||
@@ -9,6 +9,7 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|||||||
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from src.models.config_profile import ConfigProfile
|
||||||
from src.models.git_repository import GitRepository
|
from src.models.git_repository import GitRepository
|
||||||
from src.models.project import Project
|
from src.models.project import Project
|
||||||
from src.models.tool_type import ToolType
|
from src.models.tool_type import ToolType
|
||||||
@@ -62,8 +63,12 @@ class ToolInstance(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|||||||
last_stopped_at: Mapped[datetime | None] = mapped_column(
|
last_stopped_at: Mapped[datetime | None] = mapped_column(
|
||||||
DateTime(timezone=True), nullable=True
|
DateTime(timezone=True), nullable=True
|
||||||
)
|
)
|
||||||
|
selected_profile_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||||
|
UUID(), ForeignKey("config_profiles.id", ondelete="SET NULL"), nullable=True
|
||||||
|
)
|
||||||
|
|
||||||
tool_type: Mapped["ToolType"] = relationship()
|
tool_type: Mapped["ToolType"] = relationship()
|
||||||
repository: Mapped["GitRepository"] = relationship()
|
repository: Mapped["GitRepository"] = relationship()
|
||||||
project: Mapped["Project"] = relationship()
|
project: Mapped["Project"] = relationship()
|
||||||
owner: Mapped["User"] = relationship()
|
owner: Mapped["User"] = relationship()
|
||||||
|
selected_profile: Mapped["ConfigProfile | None"] = relationship()
|
||||||
|
|||||||
@@ -18,3 +18,23 @@ class UserConfig(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|||||||
config: Mapped[dict[str, object]] = mapped_column(JSON, default=dict, nullable=False)
|
config: Mapped[dict[str, object]] = mapped_column(JSON, default=dict, nullable=False)
|
||||||
|
|
||||||
user: Mapped["User"] = relationship(back_populates="user_config")
|
user: Mapped["User"] = relationship(back_populates="user_config")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_profile_id(self) -> uuid.UUID | None:
|
||||||
|
profile_id = self.config.get("default_profile_id")
|
||||||
|
return uuid.UUID(profile_id) if profile_id else None
|
||||||
|
|
||||||
|
@default_profile_id.setter
|
||||||
|
def default_profile_id(self, value: uuid.UUID | None) -> None:
|
||||||
|
if value is not None:
|
||||||
|
self.config["default_profile_id"] = str(value)
|
||||||
|
elif "default_profile_id" in self.config:
|
||||||
|
del self.config["default_profile_id"]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_profiles(self) -> dict[str, str]:
|
||||||
|
return self.config.get("default_profiles", {})
|
||||||
|
|
||||||
|
@default_profiles.setter
|
||||||
|
def default_profiles(self, value: dict[str, str]) -> None:
|
||||||
|
self.config["default_profiles"] = value
|
||||||
|
|||||||
@@ -121,12 +121,11 @@ def create_branch(repo_path: str, name: str, base_branch: str = "HEAD") -> None:
|
|||||||
Raises:
|
Raises:
|
||||||
RuntimeError: If branch creation fails
|
RuntimeError: If branch creation fails
|
||||||
"""
|
"""
|
||||||
if base_branch == "HEAD":
|
try:
|
||||||
try:
|
_run_git_command(repo_path, "rev-parse", "--verify", "HEAD^{commit}")
|
||||||
_run_git_command(repo_path, "rev-parse", "--verify", "HEAD")
|
except RuntimeError:
|
||||||
except RuntimeError:
|
_run_git_command(repo_path, "checkout", "--orphan", name)
|
||||||
_run_git_command(repo_path, "checkout", "--orphan", name)
|
return
|
||||||
return
|
|
||||||
|
|
||||||
_run_git_command(repo_path, "branch", name, base_branch)
|
_run_git_command(repo_path, "branch", name, base_branch)
|
||||||
|
|
||||||
|
|||||||
@@ -39,3 +39,18 @@ def test_refresh_tokens_migration_has_expected_revision_chain() -> None:
|
|||||||
|
|
||||||
assert module.revision == "0002_refresh_tokens"
|
assert module.revision == "0002_refresh_tokens"
|
||||||
assert module.down_revision == "0001_initial_schema"
|
assert module.down_revision == "0001_initial_schema"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.unit
|
||||||
|
def test_config_profiles_migration_has_expected_revision_chain() -> None:
|
||||||
|
migration_path = Path(__file__).resolve().parents[2] / "alembic" / "versions" / "0013_add_config_profiles.py"
|
||||||
|
spec = spec_from_file_location("add_config_profiles", migration_path)
|
||||||
|
|
||||||
|
assert spec is not None
|
||||||
|
assert spec.loader is not None
|
||||||
|
|
||||||
|
module = module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
|
||||||
|
assert module.revision == "0013_add_config_profiles"
|
||||||
|
assert module.down_revision == "0012_default_port_req"
|
||||||
|
|||||||
Generated
+1371
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,12 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Headquarter</title>
|
<title>Headquarter</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
@@ -0,0 +1,796 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Headquarter - UI Preview</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #f4f1ea;
|
||||||
|
--panel: #fffef9;
|
||||||
|
--ink: #1d1d1b;
|
||||||
|
--muted: #5f5b55;
|
||||||
|
--brand: #275d4b;
|
||||||
|
--brand-strong: #154236;
|
||||||
|
--border: #d8d0c5;
|
||||||
|
--primary: #275d4b;
|
||||||
|
--primary-fg: #fffef9;
|
||||||
|
--color-primary: #275d4b;
|
||||||
|
--success: #2f8f62;
|
||||||
|
--success-light: rgba(47, 143, 98, 0.14);
|
||||||
|
--warning: #c08a1e;
|
||||||
|
--warning-light: rgba(192, 138, 30, 0.14);
|
||||||
|
--danger: #b94a3c;
|
||||||
|
--danger-light: rgba(185, 74, 60, 0.14);
|
||||||
|
--info: #4f7fb8;
|
||||||
|
--info-light: rgba(79, 127, 184, 0.14);
|
||||||
|
--space-1: 0.25rem;
|
||||||
|
--space-2: 0.5rem;
|
||||||
|
--space-3: 0.75rem;
|
||||||
|
--space-4: 1rem;
|
||||||
|
--space-5: 1.5rem;
|
||||||
|
--space-6: 2rem;
|
||||||
|
--font-size-xs: clamp(0.625rem, 0.6rem + 0.125vw, 0.75rem);
|
||||||
|
--font-size-sm: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
|
||||||
|
--font-size-base: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
|
||||||
|
--font-size-lg: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
|
||||||
|
--font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "Inter", "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--ink);
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* App Shell */
|
||||||
|
.shell {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.85rem 1.25rem;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
background: color-mix(in srgb, var(--panel) 88%, transparent);
|
||||||
|
backdrop-filter: blur(7px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand {
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
color: var(--ink);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-chip {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--panel);
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.35rem 0.7rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--ink);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ghost-button {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0.58rem 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-body {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 230px 1fr;
|
||||||
|
min-height: calc(100vh - 57px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-nav {
|
||||||
|
border-right: 1px solid var(--border);
|
||||||
|
padding: 1rem 0.75rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4rem;
|
||||||
|
background: color-mix(in srgb, var(--panel) 65%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item {
|
||||||
|
padding: 0.65rem 0.75rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--muted);
|
||||||
|
text-decoration: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item:hover {
|
||||||
|
background: #ece7df;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item-active {
|
||||||
|
background: var(--brand);
|
||||||
|
color: #f7fff7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
padding: 0 5px;
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--primary-fg);
|
||||||
|
border-radius: 9px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-section-title {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-item {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-status {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--muted);
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-status.running {
|
||||||
|
background: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shell-content {
|
||||||
|
padding: 1.25rem;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Common Components */
|
||||||
|
.stack {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stack-sm {
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.muted {
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
margin: 0;
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: var(--space-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-button {
|
||||||
|
background: var(--brand);
|
||||||
|
color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 0.58rem 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-button:hover {
|
||||||
|
background: var(--brand-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary-button {
|
||||||
|
border-color: var(--border);
|
||||||
|
background: var(--panel);
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
padding: 0.58rem 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Home Page */
|
||||||
|
.home-page {
|
||||||
|
max-width: 1240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-hero {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: var(--space-4);
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-hero-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||||
|
gap: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary-card .card-label {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary-card .card-value {
|
||||||
|
margin: 0.45rem 0 0;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-section h2,
|
||||||
|
.home-section h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-session-grid,
|
||||||
|
.home-project-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--space-4);
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-card {
|
||||||
|
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.running {
|
||||||
|
background: var(--success-light);
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.building {
|
||||||
|
background: var(--warning-light);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.pending {
|
||||||
|
background: var(--info-light);
|
||||||
|
color: var(--info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recent-sessions-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recent-session-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: var(--space-3) var(--space-4);
|
||||||
|
background: var(--bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recent-session-name {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-session-form .form-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
|
gap: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-field input,
|
||||||
|
.form-field select,
|
||||||
|
.form-field textarea {
|
||||||
|
padding: 0.55rem 0.7rem;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
font: inherit;
|
||||||
|
background: var(--panel);
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-3);
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Settings Page */
|
||||||
|
.settings-page {
|
||||||
|
max-width: 1240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-header {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tab {
|
||||||
|
padding: 0.6rem 0.9rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--muted);
|
||||||
|
background: var(--panel);
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tab.active {
|
||||||
|
background: var(--brand);
|
||||||
|
color: white;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-3);
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-text {
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-text {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Preview Switcher */
|
||||||
|
.preview-switcher {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 1rem;
|
||||||
|
right: 1rem;
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-switcher button {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-switcher button.active {
|
||||||
|
background: var(--brand);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-preview {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-preview.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.shell-body {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
.shell-nav {
|
||||||
|
flex-direction: row;
|
||||||
|
overflow-x: auto;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.home-hero {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="shell">
|
||||||
|
<header class="shell-header">
|
||||||
|
<a href="#" class="brand">Headquarter</a>
|
||||||
|
<div class="header-actions">
|
||||||
|
<a href="#" class="user-chip">User</a>
|
||||||
|
<button class="ghost-button">Logout</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="shell-body">
|
||||||
|
<aside class="shell-nav" aria-label="Primary navigation">
|
||||||
|
<a href="#" class="nav-item nav-item-active">
|
||||||
|
<span>🏠</span> Home
|
||||||
|
<span class="nav-badge">3</span>
|
||||||
|
</a>
|
||||||
|
<a href="#" class="nav-item">
|
||||||
|
<span>📁</span> Projects
|
||||||
|
</a>
|
||||||
|
<a href="#" class="nav-item">
|
||||||
|
<span>⚙️</span> Settings
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="nav-divider"></div>
|
||||||
|
<div class="nav-section-title">Live sessions</div>
|
||||||
|
<a href="#" class="nav-item session-item">
|
||||||
|
<span class="session-status running"></span>
|
||||||
|
<span>Dev Environment</span>
|
||||||
|
</a>
|
||||||
|
<a href="#" class="nav-item session-item">
|
||||||
|
<span class="session-status running"></span>
|
||||||
|
<span>Jupyter Lab</span>
|
||||||
|
</a>
|
||||||
|
<a href="#" class="nav-item session-item">
|
||||||
|
<span class="session-status"></span>
|
||||||
|
<span>Code Server</span>
|
||||||
|
</a>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<main class="shell-content">
|
||||||
|
<!-- HOME PAGE PREVIEW -->
|
||||||
|
<div id="home-preview" class="page-preview active">
|
||||||
|
<section class="stack home-page">
|
||||||
|
<header class="home-hero card">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<p class="eyebrow">Workspace overview</p>
|
||||||
|
<h1>Home</h1>
|
||||||
|
<p class="muted">Open sessions, available projects, and the fastest path back into work.</p>
|
||||||
|
</div>
|
||||||
|
<div class="home-hero-actions">
|
||||||
|
<button class="primary-button">New Project</button>
|
||||||
|
<button class="secondary-button">Settings</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="home-summary-grid">
|
||||||
|
<article class="card home-summary-card">
|
||||||
|
<p class="card-label">Open sessions</p>
|
||||||
|
<p class="card-value">3</p>
|
||||||
|
</article>
|
||||||
|
<article class="card home-summary-card">
|
||||||
|
<p class="card-label">Projects</p>
|
||||||
|
<p class="card-value">5</p>
|
||||||
|
</article>
|
||||||
|
<article class="card home-summary-card">
|
||||||
|
<p class="card-label">Repositories</p>
|
||||||
|
<p class="card-value">12</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="card stack home-section">
|
||||||
|
<div class="page-header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Open sessions</p>
|
||||||
|
<h2>3</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="home-session-grid">
|
||||||
|
<article class="card session-card">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||||
|
<h3>Dev Environment</h3>
|
||||||
|
<span class="status-badge running">running</span>
|
||||||
|
</div>
|
||||||
|
<p class="muted">Acme Corp · main</p>
|
||||||
|
<p class="muted">VS Code Server</p>
|
||||||
|
</div>
|
||||||
|
<div class="session-actions">
|
||||||
|
<button class="secondary-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Open</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Tunnel</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Stop</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; color: var(--danger);">Delete</button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article class="card session-card">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||||
|
<h3>Jupyter Lab</h3>
|
||||||
|
<span class="status-badge running">running</span>
|
||||||
|
</div>
|
||||||
|
<p class="muted">Data Science · experiments</p>
|
||||||
|
<p class="muted">Jupyter Notebook</p>
|
||||||
|
</div>
|
||||||
|
<div class="session-actions">
|
||||||
|
<button class="secondary-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Open</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Tunnel</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Stop</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; color: var(--danger);">Delete</button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article class="card session-card">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<div style="display: flex; gap: 0.5rem; align-items: center;">
|
||||||
|
<h3>Database Console</h3>
|
||||||
|
<span class="status-badge building">building</span>
|
||||||
|
</div>
|
||||||
|
<p class="muted">Backend API · staging</p>
|
||||||
|
<p class="muted">PostgreSQL Client</p>
|
||||||
|
</div>
|
||||||
|
<div class="session-actions">
|
||||||
|
<button class="secondary-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Open</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Tunnel</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Stop</button>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; color: var(--danger);">Delete</button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="card stack home-section">
|
||||||
|
<div class="page-header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Available projects</p>
|
||||||
|
<h2>5</h2>
|
||||||
|
</div>
|
||||||
|
<button class="secondary-button">View all</button>
|
||||||
|
</div>
|
||||||
|
<div class="home-project-grid">
|
||||||
|
<article class="card" style="box-shadow: 0 1px 0 rgba(0,0,0,0.02);">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<h3>Acme Corp</h3>
|
||||||
|
<p class="muted">Main product development</p>
|
||||||
|
</div>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; margin-top: 0.5rem;">Open Workspace</button>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article class="card" style="box-shadow: 0 1px 0 rgba(0,0,0,0.02);">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<h3>Data Science</h3>
|
||||||
|
<p class="muted">ML experiments and notebooks</p>
|
||||||
|
</div>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; margin-top: 0.5rem;">Open Workspace</button>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<article class="card" style="box-shadow: 0 1px 0 rgba(0,0,0,0.02);">
|
||||||
|
<div class="stack-sm">
|
||||||
|
<h3>Backend API</h3>
|
||||||
|
<p class="muted">REST API services</p>
|
||||||
|
</div>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem; margin-top: 0.5rem;">Open Workspace</button>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="card stack home-section">
|
||||||
|
<div class="page-header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Quick create</p>
|
||||||
|
<h2>Start a session</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form class="stack create-session-form">
|
||||||
|
<div class="form-row">
|
||||||
|
<label class="form-field">
|
||||||
|
Project
|
||||||
|
<select>
|
||||||
|
<option>Select project...</option>
|
||||||
|
<option>Acme Corp</option>
|
||||||
|
<option>Data Science</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label class="form-field">
|
||||||
|
Repository
|
||||||
|
<select disabled>
|
||||||
|
<option>Select repository...</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label class="form-field">
|
||||||
|
Tool type
|
||||||
|
<select>
|
||||||
|
<option>Select tool...</option>
|
||||||
|
<option>VS Code Server</option>
|
||||||
|
<option>Jupyter Lab</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<label class="form-field">
|
||||||
|
Display name
|
||||||
|
<input type="text" placeholder="My Development Environment">
|
||||||
|
</label>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button class="primary-button" type="submit">Create Session</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="card stack home-section">
|
||||||
|
<div class="page-header">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Recent sessions</p>
|
||||||
|
<h2>2</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="recent-sessions-list">
|
||||||
|
<article class="recent-session-item">
|
||||||
|
<div style="display: flex; flex-direction: column; gap: 0.25rem;">
|
||||||
|
<span class="recent-session-name">Old Dev Box</span>
|
||||||
|
<span class="muted">Acme Corp · VS Code Server</span>
|
||||||
|
</div>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Open</button>
|
||||||
|
</article>
|
||||||
|
<article class="recent-session-item">
|
||||||
|
<div style="display: flex; flex-direction: column; gap: 0.25rem;">
|
||||||
|
<span class="recent-session-name">ML Training</span>
|
||||||
|
<span class="muted">Data Science · Jupyter Lab</span>
|
||||||
|
</div>
|
||||||
|
<button class="ghost-button" style="font-size: 0.85rem; padding: 0.42rem 0.7rem;">Open</button>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- SETTINGS PAGE PREVIEW -->
|
||||||
|
<div id="settings-preview" class="page-preview">
|
||||||
|
<section class="stack settings-page">
|
||||||
|
<header class="settings-header card stack-sm">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Configuration</p>
|
||||||
|
<h1>Settings</h1>
|
||||||
|
</div>
|
||||||
|
<p class="muted">General preferences, SSH keys, tool types, and tool configs live here.</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<nav class="settings-tabs" aria-label="Settings sections">
|
||||||
|
<a href="#" class="settings-tab active">General</a>
|
||||||
|
<a href="#" class="settings-tab">SSH Keys</a>
|
||||||
|
<a href="#" class="settings-tab">Tool Types</a>
|
||||||
|
<a href="#" class="settings-tab">Tool Configs</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="settings-panel card">
|
||||||
|
<div class="stack">
|
||||||
|
<h2>General</h2>
|
||||||
|
<label class="form-field">
|
||||||
|
Theme
|
||||||
|
<select>
|
||||||
|
<option>System</option>
|
||||||
|
<option>Light</option>
|
||||||
|
<option>Dark</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label class="form-field">
|
||||||
|
Git user name
|
||||||
|
<input type="text" placeholder="Your git commit name" value="John Doe">
|
||||||
|
</label>
|
||||||
|
<label class="form-field">
|
||||||
|
Git user email
|
||||||
|
<input type="email" placeholder="your.email@example.com" value="john@example.com">
|
||||||
|
</label>
|
||||||
|
<label class="form-field">
|
||||||
|
Default editor
|
||||||
|
<input type="text" placeholder="e.g., vscode, vim, cursor" value="vscode">
|
||||||
|
</label>
|
||||||
|
<div class="settings-actions">
|
||||||
|
<button class="primary-button">Save Settings</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="preview-switcher">
|
||||||
|
<button class="active" onclick="showPage('home')">Home</button>
|
||||||
|
<button onclick="showPage('settings')">Settings</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function showPage(page) {
|
||||||
|
document.querySelectorAll('.page-preview').forEach(p => p.classList.remove('active'));
|
||||||
|
document.querySelectorAll('.preview-switcher button').forEach(b => b.classList.remove('active'));
|
||||||
|
document.getElementById(page + '-preview').classList.add('active');
|
||||||
|
event.target.classList.add('active');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
createConfigFolder,
|
createConfigFolder,
|
||||||
deleteConfigFolder,
|
deleteConfigFolder,
|
||||||
@@ -8,8 +7,25 @@ import {
|
|||||||
updateConfigFolder,
|
updateConfigFolder,
|
||||||
} from "../api/config_folders";
|
} from "../api/config_folders";
|
||||||
|
|
||||||
vi.mock("axios");
|
const mockGet = vi.fn();
|
||||||
const mockedAxios = vi.mocked(axios);
|
const mockPost = vi.fn();
|
||||||
|
const mockPut = vi.fn();
|
||||||
|
const mockDelete = vi.fn();
|
||||||
|
|
||||||
|
vi.mock("../api/client", () => ({
|
||||||
|
apiClient: {
|
||||||
|
get: (...args: unknown[]) => mockGet(...args),
|
||||||
|
post: (...args: unknown[]) => mockPost(...args),
|
||||||
|
put: (...args: unknown[]) => mockPut(...args),
|
||||||
|
delete: (...args: unknown[]) => mockDelete(...args),
|
||||||
|
interceptors: {
|
||||||
|
response: {
|
||||||
|
use: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shouldSkipAuthRedirect: vi.fn(() => false),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("config_folders API", () => {
|
describe("config_folders API", () => {
|
||||||
describe("listConfigFolders", () => {
|
describe("listConfigFolders", () => {
|
||||||
@@ -19,43 +35,24 @@ describe("config_folders API", () => {
|
|||||||
{
|
{
|
||||||
id: "folder-1",
|
id: "folder-1",
|
||||||
name: "my-dotfiles",
|
name: "my-dotfiles",
|
||||||
|
description: "My personal config files",
|
||||||
mount_path: "/home/user",
|
mount_path: "/home/user",
|
||||||
files: {
|
files: { ".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"" },
|
||||||
".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"",
|
project_overrides: {},
|
||||||
},
|
|
||||||
project_overrides: {
|
|
||||||
"proj-1": {
|
|
||||||
mount_path: "/workspace",
|
|
||||||
files: { ".zshrc": "different content" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
user_id: "user-1",
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
mockedAxios.get.mockResolvedValue(mockResponse);
|
mockGet.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await listConfigFolders();
|
const result = await listConfigFolders();
|
||||||
|
|
||||||
expect(result).toHaveLength(1);
|
|
||||||
expect(result[0].name).toBe("my-dotfiles");
|
expect(result[0].name).toBe("my-dotfiles");
|
||||||
expect(result[0].files).toEqual({
|
expect(result[0].files).toEqual({ ".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"" });
|
||||||
".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"",
|
expect(mockGet).toHaveBeenCalledWith("/config-folders");
|
||||||
});
|
|
||||||
expect(result[0].project_overrides).toEqual({
|
|
||||||
"proj-1": {
|
|
||||||
mount_path: "/workspace",
|
|
||||||
files: { ".zshrc": "different content" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns empty array when no folders", async () => {
|
|
||||||
mockedAxios.get.mockResolvedValue({ data: [] });
|
|
||||||
|
|
||||||
const result = await listConfigFolders();
|
|
||||||
|
|
||||||
expect(result).toEqual([]);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -63,29 +60,30 @@ describe("config_folders API", () => {
|
|||||||
it("creates folder with files", async () => {
|
it("creates folder with files", async () => {
|
||||||
const mockResponse = {
|
const mockResponse = {
|
||||||
data: {
|
data: {
|
||||||
id: "new-folder",
|
id: "folder-new",
|
||||||
name: "my-configs",
|
name: "new-folder",
|
||||||
mount_path: "/home/user",
|
mount_path: "/workspace",
|
||||||
files: { "test.txt": "hello" },
|
files: { ".env": "API_URL=http://localhost" },
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
user_id: "user-1",
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mockedAxios.post.mockResolvedValue(mockResponse);
|
mockPost.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await createConfigFolder({
|
const result = await createConfigFolder({
|
||||||
name: "my-configs",
|
name: "new-folder",
|
||||||
mount_path: "/home/user",
|
mount_path: "/workspace",
|
||||||
files: { "test.txt": "hello" },
|
files: { ".env": "API_URL=http://localhost" },
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.name).toBe("my-configs");
|
expect(result.name).toBe("new-folder");
|
||||||
expect(result.files).toEqual({ "test.txt": "hello" });
|
expect(mockPost).toHaveBeenCalledWith(
|
||||||
expect(mockedAxios.post).toHaveBeenCalledWith(
|
|
||||||
"/config-folders",
|
"/config-folders",
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "my-configs",
|
name: "new-folder",
|
||||||
mount_path: "/home/user",
|
mount_path: "/workspace",
|
||||||
files: { "test.txt": "hello" },
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -96,52 +94,38 @@ describe("config_folders API", () => {
|
|||||||
const mockResponse = {
|
const mockResponse = {
|
||||||
data: {
|
data: {
|
||||||
id: "folder-1",
|
id: "folder-1",
|
||||||
name: "updated-name",
|
name: "updated-folder",
|
||||||
files: { "new.txt": "content" },
|
mount_path: "/home/user",
|
||||||
|
files: { ".bashrc": "alias ll='ls -la'" },
|
||||||
|
is_active: true,
|
||||||
|
user_id: "user-1",
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mockedAxios.put.mockResolvedValue(mockResponse);
|
mockPut.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await updateConfigFolder("folder-1", {
|
const result = await updateConfigFolder("folder-1", {
|
||||||
name: "updated-name",
|
files: { ".bashrc": "alias ll='ls -la'" },
|
||||||
files: { "new.txt": "content" },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.name).toBe("updated-name");
|
expect(result.files).toEqual({ ".bashrc": "alias ll='ls -la'" });
|
||||||
expect(mockedAxios.put).toHaveBeenCalledWith(
|
expect(mockPut).toHaveBeenCalledWith(
|
||||||
"/config-folders/folder-1",
|
"/config-folders/folder-1",
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "updated-name",
|
files: { ".bashrc": "alias ll='ls -la'" },
|
||||||
files: { "new.txt": "content" },
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates folder activation status", async () => {
|
|
||||||
const mockResponse = {
|
|
||||||
data: {
|
|
||||||
id: "folder-1",
|
|
||||||
name: "my-configs",
|
|
||||||
is_active: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
mockedAxios.put.mockResolvedValue(mockResponse);
|
|
||||||
|
|
||||||
const result = await updateConfigFolder("folder-1", {
|
|
||||||
is_active: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.is_active).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("deleteConfigFolder", () => {
|
describe("deleteConfigFolder", () => {
|
||||||
it("deletes folder", async () => {
|
it("deletes folder", async () => {
|
||||||
mockedAxios.delete.mockResolvedValue({ data: undefined });
|
mockDelete.mockResolvedValue({ data: undefined });
|
||||||
|
|
||||||
await deleteConfigFolder("folder-1");
|
await deleteConfigFolder("folder-1");
|
||||||
|
|
||||||
expect(mockedAxios.delete).toHaveBeenCalledWith("/config-folders/folder-1");
|
expect(mockDelete).toHaveBeenCalledWith("/config-folders/folder-1");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import {
|
import {
|
||||||
createToolType,
|
createToolType,
|
||||||
deleteToolType,
|
deleteToolType,
|
||||||
@@ -9,8 +8,25 @@ import {
|
|||||||
validateToolType,
|
validateToolType,
|
||||||
} from "../api/tool_types";
|
} from "../api/tool_types";
|
||||||
|
|
||||||
vi.mock("axios");
|
const mockGet = vi.fn();
|
||||||
const mockedAxios = vi.mocked(axios);
|
const mockPost = vi.fn();
|
||||||
|
const mockPut = vi.fn();
|
||||||
|
const mockDelete = vi.fn();
|
||||||
|
|
||||||
|
vi.mock("../api/client", () => ({
|
||||||
|
apiClient: {
|
||||||
|
get: (...args: unknown[]) => mockGet(...args),
|
||||||
|
post: (...args: unknown[]) => mockPost(...args),
|
||||||
|
put: (...args: unknown[]) => mockPut(...args),
|
||||||
|
delete: (...args: unknown[]) => mockDelete(...args),
|
||||||
|
interceptors: {
|
||||||
|
response: {
|
||||||
|
use: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shouldSkipAuthRedirect: vi.fn(() => false),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("tool_types API", () => {
|
describe("tool_types API", () => {
|
||||||
describe("listToolTypes", () => {
|
describe("listToolTypes", () => {
|
||||||
@@ -28,10 +44,13 @@ describe("tool_types API", () => {
|
|||||||
timeout: 30,
|
timeout: 30,
|
||||||
interval: 2,
|
interval: 2,
|
||||||
},
|
},
|
||||||
|
build_context: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
mockedAxios.get.mockResolvedValue(mockResponse);
|
mockGet.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await listToolTypes();
|
const result = await listToolTypes();
|
||||||
|
|
||||||
@@ -53,10 +72,13 @@ describe("tool_types API", () => {
|
|||||||
definition_type: "compose",
|
definition_type: "compose",
|
||||||
compose_template: "version: '3.8'",
|
compose_template: "version: '3.8'",
|
||||||
dockerfile_template: null,
|
dockerfile_template: null,
|
||||||
|
build_context: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
mockedAxios.get.mockResolvedValue(mockResponse);
|
mockGet.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await listToolTypes();
|
const result = await listToolTypes();
|
||||||
|
|
||||||
@@ -73,9 +95,12 @@ describe("tool_types API", () => {
|
|||||||
name: "docker-tool",
|
name: "docker-tool",
|
||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
dockerfile_template: "FROM node:18",
|
dockerfile_template: "FROM node:18",
|
||||||
|
build_context: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mockedAxios.post.mockResolvedValue(mockResponse);
|
mockPost.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await createToolType({
|
const result = await createToolType({
|
||||||
name: "docker-tool",
|
name: "docker-tool",
|
||||||
@@ -87,7 +112,7 @@ describe("tool_types API", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result.definition_type).toBe("dockerfile");
|
expect(result.definition_type).toBe("dockerfile");
|
||||||
expect(mockedAxios.post).toHaveBeenCalledWith(
|
expect(mockPost).toHaveBeenCalledWith(
|
||||||
"/tool-types",
|
"/tool-types",
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
@@ -106,9 +131,12 @@ describe("tool_types API", () => {
|
|||||||
timeout: 60,
|
timeout: 60,
|
||||||
interval: 3,
|
interval: 3,
|
||||||
},
|
},
|
||||||
|
build_context: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mockedAxios.post.mockResolvedValue(mockResponse);
|
mockPost.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await createToolType({
|
const result = await createToolType({
|
||||||
name: "probed-tool",
|
name: "probed-tool",
|
||||||
@@ -132,30 +160,25 @@ describe("tool_types API", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("validateToolType", () => {
|
describe("validateToolType", () => {
|
||||||
it("validates compose template", async () => {
|
it("validates tool type by id", async () => {
|
||||||
const mockResponse = {
|
const mockResponse = {
|
||||||
data: { valid: true, errors: [] },
|
data: { valid: true, errors: [] },
|
||||||
};
|
};
|
||||||
mockedAxios.post.mockResolvedValue(mockResponse);
|
mockGet.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await validateToolType({
|
const result = await validateToolType("type-1");
|
||||||
definition_type: "compose",
|
|
||||||
compose_template: "version: '3.8'",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
|
expect(mockGet).toHaveBeenCalledWith("/tool-types/type-1/validate");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns validation errors", async () => {
|
it("returns validation errors", async () => {
|
||||||
const mockResponse = {
|
const mockResponse = {
|
||||||
data: { valid: false, errors: ["Invalid YAML"] },
|
data: { valid: false, errors: ["Invalid YAML"] },
|
||||||
};
|
};
|
||||||
mockedAxios.post.mockResolvedValue(mockResponse);
|
mockGet.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await validateToolType({
|
const result = await validateToolType("type-1");
|
||||||
definition_type: "compose",
|
|
||||||
compose_template: "invalid: yaml: [",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.valid).toBe(false);
|
expect(result.valid).toBe(false);
|
||||||
expect(result.errors).toContain("Invalid YAML");
|
expect(result.errors).toContain("Invalid YAML");
|
||||||
@@ -170,9 +193,12 @@ describe("tool_types API", () => {
|
|||||||
name: "updated-tool",
|
name: "updated-tool",
|
||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
dockerfile_template: "FROM python:3.11",
|
dockerfile_template: "FROM python:3.11",
|
||||||
|
build_context: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mockedAxios.put.mockResolvedValue(mockResponse);
|
mockPut.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const result = await updateToolType("type-1", {
|
const result = await updateToolType("type-1", {
|
||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
@@ -180,7 +206,7 @@ describe("tool_types API", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result.definition_type).toBe("dockerfile");
|
expect(result.definition_type).toBe("dockerfile");
|
||||||
expect(mockedAxios.put).toHaveBeenCalledWith(
|
expect(mockPut).toHaveBeenCalledWith(
|
||||||
"/tool-types/type-1",
|
"/tool-types/type-1",
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
@@ -191,11 +217,11 @@ describe("tool_types API", () => {
|
|||||||
|
|
||||||
describe("deleteToolType", () => {
|
describe("deleteToolType", () => {
|
||||||
it("deletes tool type", async () => {
|
it("deletes tool type", async () => {
|
||||||
mockedAxios.delete.mockResolvedValue({ data: undefined });
|
mockDelete.mockResolvedValue({ data: undefined });
|
||||||
|
|
||||||
await deleteToolType("type-1");
|
await deleteToolType("type-1");
|
||||||
|
|
||||||
expect(mockedAxios.delete).toHaveBeenCalledWith("/tool-types/type-1");
|
expect(mockDelete).toHaveBeenCalledWith("/tool-types/type-1");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,22 +10,20 @@ import { Icon } from "./icon";
|
|||||||
import type { IconName } from "../utils/icons";
|
import type { IconName } from "../utils/icons";
|
||||||
|
|
||||||
const NAV_ITEMS: { to: string; label: string; icon: IconName }[] = [
|
const NAV_ITEMS: { to: string; label: string; icon: IconName }[] = [
|
||||||
{ to: "/", label: "Dashboard", icon: "dashboard" },
|
{ to: "/", label: "Home", icon: "dashboard" },
|
||||||
{ to: "/sessions", label: "Sessions", icon: "terminal" },
|
|
||||||
{ to: "/projects", label: "Projects", icon: "projects" },
|
{ to: "/projects", label: "Projects", icon: "projects" },
|
||||||
{ to: "/ssh-keys", label: "SSH Keys", icon: "profile" },
|
|
||||||
{ to: "/tool-workshop", label: "Tool Workshop", icon: "settings" },
|
{ to: "/tool-workshop", label: "Tool Workshop", icon: "settings" },
|
||||||
{ to: "/settings", label: "Settings", icon: "settings" }
|
{ to: "/settings", label: "Settings", icon: "settings" }
|
||||||
];
|
];
|
||||||
|
|
||||||
const SessionItem = ({ session }: { session: Session }) => {
|
const SessionItem = ({ session }: { session: Session }) => {
|
||||||
const isRunning = session.status === "running";
|
const isRunning = session.status === "running";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={session.url || "#"}
|
href={session.url ?? `/projects/${session.project_id}`}
|
||||||
target="_blank"
|
target={session.url ? "_blank" : undefined}
|
||||||
rel="noopener noreferrer"
|
rel={session.url ? "noopener noreferrer" : undefined}
|
||||||
className="nav-item session-item"
|
className="nav-item session-item"
|
||||||
title={`${session.display_name} (${session.status})`}
|
title={`${session.display_name} (${session.status})`}
|
||||||
>
|
>
|
||||||
@@ -85,7 +83,7 @@ export const AppShell = () => {
|
|||||||
<div className="shell-body">
|
<div className="shell-body">
|
||||||
<aside className="shell-nav" aria-label="Primary navigation">
|
<aside className="shell-nav" aria-label="Primary navigation">
|
||||||
{NAV_ITEMS.map((item) => {
|
{NAV_ITEMS.map((item) => {
|
||||||
const isSessions = item.to === "/sessions";
|
const isHome = item.to === "/";
|
||||||
const activeCount = sessions.filter((s) => s.status === "running").length;
|
const activeCount = sessions.filter((s) => s.status === "running").length;
|
||||||
return (
|
return (
|
||||||
<NavLink
|
<NavLink
|
||||||
@@ -96,7 +94,7 @@ export const AppShell = () => {
|
|||||||
>
|
>
|
||||||
<Icon name={item.icon} size="sm" />
|
<Icon name={item.icon} size="sm" />
|
||||||
{item.label}
|
{item.label}
|
||||||
{isSessions && activeCount > 0 && (
|
{isHome && activeCount > 0 && (
|
||||||
<span className="nav-badge">{activeCount}</span>
|
<span className="nav-badge">{activeCount}</span>
|
||||||
)}
|
)}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
@@ -106,7 +104,7 @@ export const AppShell = () => {
|
|||||||
{sessions.length > 0 && (
|
{sessions.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="nav-divider" />
|
<div className="nav-divider" />
|
||||||
<div className="nav-section-title">Sessions</div>
|
<div className="nav-section-title">Live sessions</div>
|
||||||
{sessions.map((session) => (
|
{sessions.map((session) => (
|
||||||
<SessionItem key={session.id} session={session} />
|
<SessionItem key={session.id} session={session} />
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,54 +1,81 @@
|
|||||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||||
|
import { MemoryRouter } from "react-router-dom";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import { DashboardPage } from "./dashboard";
|
import { HomePage } from "./dashboard";
|
||||||
|
|
||||||
const mockGet = vi.fn();
|
const mockDashboard = vi.fn();
|
||||||
|
const mockSessions = vi.fn();
|
||||||
|
const mockProjects = vi.fn();
|
||||||
|
const mockRepos = vi.fn();
|
||||||
|
|
||||||
vi.mock("../api/dashboard", () => ({
|
vi.mock("../api/dashboard", () => ({
|
||||||
getDashboardSummary: (...args: unknown[]) => mockGet(...args)
|
getDashboardSummary: (...args: unknown[]) => mockDashboard(...args)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("DashboardPage", () => {
|
vi.mock("../api/sessions", () => ({
|
||||||
|
getUserSessions: (...args: unknown[]) => mockSessions(...args),
|
||||||
|
createInstance: vi.fn(),
|
||||||
|
startInstance: vi.fn(),
|
||||||
|
stopInstance: vi.fn(),
|
||||||
|
deleteInstance: vi.fn(),
|
||||||
|
recreateInstanceTunnel: vi.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../api/projects", () => ({
|
||||||
|
listProjects: (...args: unknown[]) => mockProjects(...args)
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../api/git_repositories", () => ({
|
||||||
|
listRepositories: (...args: unknown[]) => mockRepos(...args)
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../api/tool_types", () => ({
|
||||||
|
listToolTypes: vi.fn().mockResolvedValue([])
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("HomePage", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockGet.mockReset();
|
mockDashboard.mockReset();
|
||||||
|
mockSessions.mockReset();
|
||||||
|
mockProjects.mockReset();
|
||||||
|
mockRepos.mockReset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows loading then empty state when summary has no data", async () => {
|
it("shows overview sections", async () => {
|
||||||
mockGet.mockResolvedValue({
|
mockDashboard.mockResolvedValue({ projects: 1, repositories: 2, sshKeys: 3, recentActivity: [] });
|
||||||
projects: 0,
|
mockSessions.mockResolvedValue([]);
|
||||||
repositories: 0,
|
mockProjects.mockResolvedValue([]);
|
||||||
sshKeys: 0,
|
mockRepos.mockResolvedValue([]);
|
||||||
recentActivity: []
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<DashboardPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<HomePage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
expect(screen.getByText("Loading dashboard...")).toBeInTheDocument();
|
expect(screen.getByText("Loading overview...")).toBeInTheDocument();
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("No activity yet")).toBeInTheDocument();
|
expect(screen.getAllByText("Open sessions").length).toBeGreaterThan(0);
|
||||||
|
expect(screen.getByText("Available projects")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows retry action when summary request fails", async () => {
|
it("shows retry action when home load fails", async () => {
|
||||||
mockGet.mockRejectedValueOnce(new Error("failed"));
|
mockDashboard.mockRejectedValueOnce(new Error("failed"));
|
||||||
mockGet.mockResolvedValueOnce({
|
mockSessions.mockRejectedValueOnce(new Error("failed"));
|
||||||
projects: 2,
|
mockProjects.mockRejectedValueOnce(new Error("failed"));
|
||||||
repositories: 5,
|
|
||||||
sshKeys: 1,
|
|
||||||
recentActivity: ["Created repo"]
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<DashboardPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<HomePage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("Dashboard is unavailable")).toBeInTheDocument();
|
expect(screen.getByText("Unable to load your workspace overview.")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
fireEvent.click(screen.getAllByRole("button", { name: "Retry" })[0]);
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.getByText("2")).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,83 +1,338 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { getDashboardSummary, type DashboardSummary } from "../api/dashboard";
|
import { getDashboardSummary, type DashboardSummary } from "../api/dashboard";
|
||||||
|
import { createInstance, getUserSessions, startInstance, stopInstance, deleteInstance, recreateInstanceTunnel, type Session as SessionApi } from "../api/sessions";
|
||||||
|
import { listProjects } from "../api/projects";
|
||||||
|
import { listRepositories, type GitRepository } from "../api/git_repositories";
|
||||||
|
import { listToolTypes, type ToolType } from "../api/tool_types";
|
||||||
|
import { updateUserConfig } from "../api/settings";
|
||||||
|
import type { Project } from "../types";
|
||||||
import { Icon } from "../components/icon";
|
import { Icon } from "../components/icon";
|
||||||
|
|
||||||
const CARDS = [
|
type HomeStatus = "loading" | "ready" | "error";
|
||||||
|
|
||||||
|
const summaryCards = [
|
||||||
|
{ label: "Open sessions", key: "openSessions" },
|
||||||
{ label: "Projects", key: "projects" },
|
{ label: "Projects", key: "projects" },
|
||||||
{ label: "Repositories", key: "repositories" },
|
{ label: "Repositories", key: "repositories" },
|
||||||
{ label: "SSH Keys", key: "sshKeys" }
|
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
type DashboardStatus = "loading" | "ready" | "error";
|
type SessionView = SessionApi;
|
||||||
|
|
||||||
export const DashboardPage = () => {
|
export const HomePage = () => {
|
||||||
const [status, setStatus] = useState<DashboardStatus>("loading");
|
const navigate = useNavigate();
|
||||||
|
const [status, setStatus] = useState<HomeStatus>("loading");
|
||||||
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
||||||
|
const [sessions, setSessions] = useState<SessionView[]>([]);
|
||||||
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
|
const [repositories, setRepositories] = useState<GitRepository[]>([]);
|
||||||
|
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
|
||||||
|
const [selectedProject, setSelectedProject] = useState("");
|
||||||
|
const [selectedRepo, setSelectedRepo] = useState("");
|
||||||
|
const [selectedToolType, setSelectedToolType] = useState("");
|
||||||
|
const [displayName, setDisplayName] = useState("");
|
||||||
|
const [saveState, setSaveState] = useState<"idle" | "saving" | "error">("idle");
|
||||||
|
const [actionBusy, setActionBusy] = useState<string | null>(null);
|
||||||
|
const safeSessions = Array.isArray(sessions) ? sessions : [];
|
||||||
|
|
||||||
const loadSummary = useCallback(async () => {
|
const loadHome = useCallback(async () => {
|
||||||
setStatus("loading");
|
setStatus("loading");
|
||||||
try {
|
try {
|
||||||
const data = await getDashboardSummary();
|
const [dashboard, sessionData, projectData, toolTypeData] = await Promise.all([
|
||||||
setSummary(data);
|
getDashboardSummary(),
|
||||||
|
getUserSessions(),
|
||||||
|
listProjects(),
|
||||||
|
listToolTypes(),
|
||||||
|
]);
|
||||||
|
setSummary(dashboard);
|
||||||
|
setSessions(sessionData as SessionView[]);
|
||||||
|
setProjects(projectData);
|
||||||
|
setToolTypes(toolTypeData);
|
||||||
setStatus("ready");
|
setStatus("ready");
|
||||||
} catch {
|
} catch {
|
||||||
setSummary(null);
|
|
||||||
setStatus("error");
|
setStatus("error");
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadSummary();
|
void loadHome();
|
||||||
}, [loadSummary]);
|
}, [loadHome]);
|
||||||
|
|
||||||
const cards = useMemo(() => CARDS, []);
|
useEffect(() => {
|
||||||
const isEmpty =
|
if (!selectedProject) {
|
||||||
status === "ready" &&
|
setRepositories([]);
|
||||||
summary !== null &&
|
return;
|
||||||
summary.projects === 0 &&
|
}
|
||||||
summary.repositories === 0 &&
|
|
||||||
summary.sshKeys === 0 &&
|
const loadRepos = async () => {
|
||||||
summary.recentActivity.length === 0;
|
try {
|
||||||
|
const data = await listRepositories(selectedProject);
|
||||||
|
setRepositories(data);
|
||||||
|
} catch {
|
||||||
|
setRepositories([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void loadRepos();
|
||||||
|
}, [selectedProject]);
|
||||||
|
|
||||||
|
const activeSessions = useMemo(
|
||||||
|
() => safeSessions.filter((session) => ["running", "building", "pending"].includes(session.status)),
|
||||||
|
[safeSessions]
|
||||||
|
);
|
||||||
|
|
||||||
|
const recentSessions = useMemo(
|
||||||
|
() => safeSessions.filter((session) => ["stopped", "error"].includes(session.status)).slice(0, 5),
|
||||||
|
[safeSessions]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleCreate = async (event: React.FormEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!selectedProject || !selectedRepo || !selectedToolType) return;
|
||||||
|
|
||||||
|
setSaveState("saving");
|
||||||
|
try {
|
||||||
|
const instance = await createInstance(selectedProject, selectedRepo, selectedToolType, displayName || undefined);
|
||||||
|
await startInstance(selectedProject, selectedRepo, instance.id);
|
||||||
|
await updateUserConfig({ last_session_id: instance.id });
|
||||||
|
setDisplayName("");
|
||||||
|
setSelectedProject("");
|
||||||
|
setSelectedRepo("");
|
||||||
|
setSelectedToolType("");
|
||||||
|
setSaveState("idle");
|
||||||
|
await loadHome();
|
||||||
|
} catch {
|
||||||
|
setSaveState("error");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleOpen = (session: SessionView) => {
|
||||||
|
if (session.url) {
|
||||||
|
window.open(session.url, "_blank", "noopener,noreferrer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (session.tool_type_interfaces.includes("terminal")) {
|
||||||
|
navigate(`/instances/${session.id}/terminal`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigate(`/projects/${session.project_id}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStop = async (session: SessionView) => {
|
||||||
|
setActionBusy(session.id);
|
||||||
|
try {
|
||||||
|
await stopInstance(session.project_id, session.repository_id, session.id);
|
||||||
|
await loadHome();
|
||||||
|
} finally {
|
||||||
|
setActionBusy(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (session: SessionView) => {
|
||||||
|
setActionBusy(session.id);
|
||||||
|
try {
|
||||||
|
await deleteInstance(session.project_id, session.repository_id, session.id);
|
||||||
|
await loadHome();
|
||||||
|
} finally {
|
||||||
|
setActionBusy(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRecreateTunnel = async (session: SessionView) => {
|
||||||
|
setActionBusy(session.id);
|
||||||
|
try {
|
||||||
|
await recreateInstanceTunnel(session.project_id, session.repository_id, session.id);
|
||||||
|
await loadHome();
|
||||||
|
} finally {
|
||||||
|
setActionBusy(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="stack">
|
<section className="stack home-page">
|
||||||
<h1>Dashboard</h1>
|
<header className="home-hero card">
|
||||||
<p className="muted">Your workspace overview will appear here.</p>
|
<div className="stack-sm">
|
||||||
|
<p className="eyebrow">Workspace overview</p>
|
||||||
|
<h1>Home</h1>
|
||||||
|
<p className="muted">Open sessions, available projects, and the fastest path back into work.</p>
|
||||||
|
</div>
|
||||||
|
<div className="home-hero-actions">
|
||||||
|
<button className="primary-button" type="button" onClick={() => navigate("/projects")}>New Project</button>
|
||||||
|
<button className="secondary-button" type="button" onClick={() => navigate("/settings")}>Settings</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
{status === "loading" && <p className="muted">Loading dashboard...</p>}
|
{status === "loading" && <p className="muted">Loading overview...</p>}
|
||||||
|
|
||||||
{status === "error" && (
|
{status === "error" && (
|
||||||
<div className="card stack">
|
<div className="card stack">
|
||||||
<p>Dashboard is unavailable</p>
|
<p>Unable to load your workspace overview.</p>
|
||||||
<button className="secondary-button" onClick={() => void loadSummary()} type="button">
|
<button className="secondary-button" type="button" onClick={() => void loadHome()}>
|
||||||
<Icon name="refresh" size="sm" />
|
<Icon name="refresh" size="sm" />
|
||||||
Retry
|
Retry
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="card-grid">
|
{status === "ready" && summary && (
|
||||||
{cards.map((card) => (
|
<>
|
||||||
<article className="card" key={card.label}>
|
<div className="home-summary-grid">
|
||||||
<p className="card-label">{card.label}</p>
|
{summaryCards.map((card) => (
|
||||||
<p className="card-value">{summary ? String(summary[card.key]) : "-"}</p>
|
<article className="card home-summary-card" key={card.label}>
|
||||||
</article>
|
<p className="card-label">{card.label}</p>
|
||||||
))}
|
<p className="card-value">
|
||||||
</div>
|
{card.key === "openSessions"
|
||||||
|
? activeSessions.length
|
||||||
|
: card.key === "projects"
|
||||||
|
? summary.projects
|
||||||
|
: summary.repositories}
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
{isEmpty && <p className="muted">No activity yet</p>}
|
<section className="card stack home-section">
|
||||||
|
<div className="page-header">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Open sessions</p>
|
||||||
|
<h2>{activeSessions.length}</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{activeSessions.length === 0 ? (
|
||||||
|
<p className="muted">No active sessions right now.</p>
|
||||||
|
) : (
|
||||||
|
<div className="home-session-grid">
|
||||||
|
{activeSessions.map((session) => (
|
||||||
|
<article className="card session-card" key={session.id}>
|
||||||
|
<div className="stack-sm">
|
||||||
|
<div className="row row-tight">
|
||||||
|
<h3>{session.display_name}</h3>
|
||||||
|
<span className={`status-badge ${session.status}`}>{session.status}</span>
|
||||||
|
</div>
|
||||||
|
<p className="muted">{session.project_name} · {session.repository_name}</p>
|
||||||
|
<p className="muted">{session.tool_type_name}</p>
|
||||||
|
</div>
|
||||||
|
<div className="session-actions">
|
||||||
|
<button className="secondary-button small" type="button" onClick={() => handleOpen(session)}>
|
||||||
|
<Icon name="external" size="sm" />
|
||||||
|
Open
|
||||||
|
</button>
|
||||||
|
<button className="ghost-button small" type="button" onClick={() => void handleRecreateTunnel(session)} disabled={actionBusy === session.id}>
|
||||||
|
<Icon name="refresh" size="sm" />
|
||||||
|
Tunnel
|
||||||
|
</button>
|
||||||
|
<button className="ghost-button small" type="button" onClick={() => void handleStop(session)} disabled={actionBusy === session.id}>
|
||||||
|
<Icon name="stop" size="sm" />
|
||||||
|
Stop
|
||||||
|
</button>
|
||||||
|
<button className="ghost-button small danger-text" type="button" onClick={() => void handleDelete(session)} disabled={actionBusy === session.id}>
|
||||||
|
<Icon name="delete" size="sm" />
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
<div className="quick-actions">
|
<section className="card stack home-section">
|
||||||
<button className="primary-button" type="button">
|
<div className="page-header">
|
||||||
<Icon name="add" size="sm" />
|
<div>
|
||||||
New Project
|
<p className="eyebrow">Available projects</p>
|
||||||
</button>
|
<h2>{projects.length}</h2>
|
||||||
<button className="secondary-button" type="button">
|
</div>
|
||||||
<Icon name="add" size="sm" />
|
<button className="secondary-button" type="button" onClick={() => navigate("/projects")}>View all</button>
|
||||||
Add Repository
|
</div>
|
||||||
</button>
|
{projects.length === 0 ? (
|
||||||
</div>
|
<p className="muted">No projects yet.</p>
|
||||||
|
) : (
|
||||||
|
<div className="home-project-grid">
|
||||||
|
{projects.map((project) => (
|
||||||
|
<article className="card project-card home-project-card" key={project.id}>
|
||||||
|
<div className="stack-sm">
|
||||||
|
<h3>{project.name}</h3>
|
||||||
|
{project.description && <p className="muted">{project.description}</p>}
|
||||||
|
</div>
|
||||||
|
<button className="ghost-button small" type="button" onClick={() => navigate(`/projects/${project.id}`)}>
|
||||||
|
Open Workspace
|
||||||
|
</button>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="card stack home-section">
|
||||||
|
<div className="page-header">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Quick create</p>
|
||||||
|
<h2>Start a session</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form className="stack create-session-form" onSubmit={handleCreate}>
|
||||||
|
<div className="form-row">
|
||||||
|
<label className="form-field">
|
||||||
|
Project
|
||||||
|
<select value={selectedProject} onChange={(event) => { setSelectedProject(event.target.value); setSelectedRepo(""); }}>
|
||||||
|
<option value="">Select project...</option>
|
||||||
|
{projects.map((project) => <option key={project.id} value={project.id}>{project.name}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
Repository
|
||||||
|
<select value={selectedRepo} onChange={(event) => setSelectedRepo(event.target.value)} disabled={!selectedProject}>
|
||||||
|
<option value="">Select repository...</option>
|
||||||
|
{repositories.map((repo) => <option key={repo.id} value={repo.id}>{repo.name}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
Tool type
|
||||||
|
<select value={selectedToolType} onChange={(event) => setSelectedToolType(event.target.value)}>
|
||||||
|
<option value="">Select tool...</option>
|
||||||
|
{toolTypes.map((tool) => <option key={tool.id} value={tool.id}>{tool.display_name}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<label className="form-field">
|
||||||
|
Display name
|
||||||
|
<input type="text" value={displayName} onChange={(event) => setDisplayName(event.target.value)} placeholder="My Development Environment" />
|
||||||
|
</label>
|
||||||
|
<div className="form-actions">
|
||||||
|
<button className="primary-button" type="submit" disabled={saveState === "saving"}>
|
||||||
|
{saveState === "saving" ? <><Icon name="loading" size="sm" /> Creating...</> : <><Icon name="add" size="sm" /> Create Session</>}
|
||||||
|
</button>
|
||||||
|
{saveState === "error" && <span className="error-text">Failed to create session</span>}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{recentSessions.length > 0 && (
|
||||||
|
<section className="card stack home-section">
|
||||||
|
<div className="page-header">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Recent sessions</p>
|
||||||
|
<h2>{recentSessions.length}</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="recent-sessions-list">
|
||||||
|
{recentSessions.map((session) => (
|
||||||
|
<article className="recent-session-item" key={session.id}>
|
||||||
|
<div className="recent-session-info">
|
||||||
|
<span className="recent-session-name">{session.display_name}</span>
|
||||||
|
<span className="muted">{session.project_name} · {session.tool_type_name}</span>
|
||||||
|
</div>
|
||||||
|
<button className="ghost-button small" type="button" onClick={() => handleOpen(session)}>Open</button>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { HomePage as DashboardPage };
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||||
|
import { MemoryRouter } from "react-router-dom";
|
||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
import { ProjectsPage } from "./projects";
|
import { ProjectsPage } from "./projects";
|
||||||
@@ -29,13 +30,21 @@ afterEach(() => {
|
|||||||
describe("ProjectsPage", () => {
|
describe("ProjectsPage", () => {
|
||||||
it("renders loading state initially", () => {
|
it("renders loading state initially", () => {
|
||||||
vi.spyOn(projectsApi, "listProjects").mockImplementation(() => new Promise(() => {}));
|
vi.spyOn(projectsApi, "listProjects").mockImplementation(() => new Promise(() => {}));
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
expect(screen.getByText(/loading projects/i)).toBeInTheDocument();
|
expect(screen.getByText(/loading projects/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders project list after loading", async () => {
|
it("renders project list after loading", async () => {
|
||||||
vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
||||||
@@ -46,7 +55,11 @@ describe("ProjectsPage", () => {
|
|||||||
|
|
||||||
it("renders empty state when no projects", async () => {
|
it("renders empty state when no projects", async () => {
|
||||||
vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
||||||
@@ -55,7 +68,11 @@ describe("ProjectsPage", () => {
|
|||||||
|
|
||||||
it("renders error state with retry button", async () => {
|
it("renders error state with retry button", async () => {
|
||||||
vi.spyOn(projectsApi, "listProjects").mockRejectedValue(new Error("fail"));
|
vi.spyOn(projectsApi, "listProjects").mockRejectedValue(new Error("fail"));
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText(/failed to load projects/i)).toBeInTheDocument();
|
expect(screen.getByText(/failed to load projects/i)).toBeInTheDocument();
|
||||||
@@ -67,7 +84,11 @@ describe("ProjectsPage", () => {
|
|||||||
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
||||||
const createMock = vi.spyOn(projectsApi, "createProject").mockResolvedValue(mockProjects[0]);
|
const createMock = vi.spyOn(projectsApi, "createProject").mockResolvedValue(mockProjects[0]);
|
||||||
|
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
||||||
@@ -96,7 +117,11 @@ describe("ProjectsPage", () => {
|
|||||||
it("shows validation error when name is empty", async () => {
|
it("shows validation error when name is empty", async () => {
|
||||||
vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
vi.spyOn(projectsApi, "listProjects").mockResolvedValue([]);
|
||||||
|
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
expect(screen.getByText(/no projects yet/i)).toBeInTheDocument();
|
||||||
@@ -112,7 +137,11 @@ describe("ProjectsPage", () => {
|
|||||||
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
||||||
const updateMock = vi.spyOn(projectsApi, "updateProject").mockResolvedValue(mockProjects[0]);
|
const updateMock = vi.spyOn(projectsApi, "updateProject").mockResolvedValue(mockProjects[0]);
|
||||||
|
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
||||||
@@ -141,7 +170,11 @@ describe("ProjectsPage", () => {
|
|||||||
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
const listMock = vi.spyOn(projectsApi, "listProjects").mockResolvedValue(mockProjects);
|
||||||
const deleteMock = vi.spyOn(projectsApi, "deleteProject").mockResolvedValue(undefined);
|
const deleteMock = vi.spyOn(projectsApi, "deleteProject").mockResolvedValue(undefined);
|
||||||
|
|
||||||
render(<ProjectsPage />);
|
render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<ProjectsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
expect(screen.getByText("Alpha Project")).toBeInTheDocument();
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { Link, Outlet, useLocation, useOutletContext } from "react-router-dom";
|
||||||
|
|
||||||
import { getUserConfig, updateUserConfig, type UserConfig, type UserConfigUpdate } from "../api/settings";
|
import { getUserConfig, updateUserConfig, type UserConfig, type UserConfigUpdate } from "../api/settings";
|
||||||
import { Icon } from "../components/icon";
|
import { Icon } from "../components/icon";
|
||||||
|
|
||||||
type SettingsStatus = "loading" | "ready" | "error";
|
type SettingsStatus = "loading" | "ready" | "error";
|
||||||
|
|
||||||
|
const TABS = [
|
||||||
|
{ label: "General", path: "general" },
|
||||||
|
{ label: "SSH Keys", path: "ssh-keys" },
|
||||||
|
{ label: "Tool Types", path: "tool-types" },
|
||||||
|
{ label: "Tool Configs", path: "tool-configs" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
const THEME_OPTIONS = [
|
const THEME_OPTIONS = [
|
||||||
{ value: "system", label: "System" },
|
{ value: "system", label: "System" },
|
||||||
{ value: "light", label: "Light" },
|
{ value: "light", label: "Light" },
|
||||||
{ value: "dark", label: "Dark" },
|
{ value: "dark", label: "Dark" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
type SettingsOutletContext = {
|
||||||
|
config: UserConfig;
|
||||||
|
handleChange: (key: keyof UserConfigUpdate, value: string | null) => void;
|
||||||
|
handleSave: () => Promise<void>;
|
||||||
|
saveStatus: "idle" | "saving" | "saved" | "error";
|
||||||
|
};
|
||||||
|
|
||||||
export const SettingsPage = () => {
|
export const SettingsPage = () => {
|
||||||
|
const location = useLocation();
|
||||||
const [status, setStatus] = useState<SettingsStatus>("loading");
|
const [status, setStatus] = useState<SettingsStatus>("loading");
|
||||||
const [config, setConfig] = useState<UserConfig>({
|
const [config, setConfig] = useState<UserConfig>({
|
||||||
theme: "system",
|
theme: "system",
|
||||||
@@ -50,21 +66,15 @@ export const SettingsPage = () => {
|
|||||||
git_user_name: config.git_user_name,
|
git_user_name: config.git_user_name,
|
||||||
git_user_email: config.git_user_email,
|
git_user_email: config.git_user_email,
|
||||||
};
|
};
|
||||||
console.log("Sending update:", update);
|
|
||||||
const updated = await updateUserConfig(update);
|
const updated = await updateUserConfig(update);
|
||||||
console.log("Received response:", updated);
|
|
||||||
setConfig(updated);
|
setConfig(updated);
|
||||||
setSaveStatus("saved");
|
setSaveStatus("saved");
|
||||||
|
if (updated.theme === "system") {
|
||||||
// Apply theme immediately
|
|
||||||
const theme = updated.theme ?? "system";
|
|
||||||
if (theme === "system") {
|
|
||||||
document.documentElement.removeAttribute("data-theme");
|
document.documentElement.removeAttribute("data-theme");
|
||||||
} else {
|
} else {
|
||||||
document.documentElement.setAttribute("data-theme", theme);
|
document.documentElement.setAttribute("data-theme", updated.theme);
|
||||||
}
|
}
|
||||||
|
window.setTimeout(() => setSaveStatus("idle"), 2000);
|
||||||
setTimeout(() => setSaveStatus("idle"), 2000);
|
|
||||||
} catch {
|
} catch {
|
||||||
setSaveStatus("error");
|
setSaveStatus("error");
|
||||||
}
|
}
|
||||||
@@ -86,81 +96,71 @@ export const SettingsPage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parts = location.pathname.split("/").filter(Boolean);
|
||||||
|
const activePath = location.pathname.endsWith("/settings") ? "general" : (parts[parts.length - 1] ?? "general");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="stack">
|
<section className="stack settings-page">
|
||||||
<div className="page-header">
|
<header className="settings-header card stack-sm">
|
||||||
<h1>Settings</h1>
|
<div>
|
||||||
</div>
|
<p className="eyebrow">Configuration</p>
|
||||||
|
<h1>Settings</h1>
|
||||||
|
</div>
|
||||||
|
<p className="muted">General preferences, SSH keys, tool types, and tool configs live here.</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
<div className="card stack">
|
<nav className="settings-tabs" aria-label="Settings sections">
|
||||||
<h2>Appearance</h2>
|
{TABS.map((tab) => (
|
||||||
<label className="form-field">
|
<Link
|
||||||
Theme
|
key={tab.path}
|
||||||
<select
|
className={`settings-tab ${activePath === tab.path ? "active" : ""}`}
|
||||||
value={config.theme}
|
to={tab.path === "general" ? "/settings" : `/settings/${tab.path}`}
|
||||||
onChange={(e) => handleChange("theme", e.target.value)}
|
|
||||||
>
|
>
|
||||||
{THEME_OPTIONS.map((opt) => (
|
{tab.label}
|
||||||
<option key={opt.value} value={opt.value}>
|
</Link>
|
||||||
{opt.label}
|
))}
|
||||||
</option>
|
</nav>
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card stack">
|
<div className="settings-panel card">
|
||||||
<h2>Git Identity</h2>
|
<Outlet context={{ config, handleChange, handleSave, saveStatus }} />
|
||||||
<label className="form-field">
|
|
||||||
User Name
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={config.git_user_name ?? ""}
|
|
||||||
onChange={(e) => handleChange("git_user_name", e.target.value || null)}
|
|
||||||
placeholder="Your git commit name"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label className="form-field">
|
|
||||||
User Email
|
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
value={config.git_user_email ?? ""}
|
|
||||||
onChange={(e) => handleChange("git_user_email", e.target.value || null)}
|
|
||||||
placeholder="your.email@example.com"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card stack">
|
|
||||||
<h2>Editor</h2>
|
|
||||||
<label className="form-field">
|
|
||||||
Default Editor
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={config.default_editor ?? ""}
|
|
||||||
onChange={(e) => handleChange("default_editor", e.target.value || null)}
|
|
||||||
placeholder="e.g., vscode, vim, cursor"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="settings-actions">
|
|
||||||
<button className="primary-button" onClick={() => void handleSave()} type="button">
|
|
||||||
{saveStatus === "saving" ? (
|
|
||||||
<>
|
|
||||||
<Icon name="loading" size="sm" />
|
|
||||||
Saving...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Icon name="save" size="sm" />
|
|
||||||
Save Settings
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
{saveStatus === "saved" && <span className="success-text">Settings saved!</span>}
|
|
||||||
{saveStatus === "error" && <span className="error-text">Failed to save</span>}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const GeneralSettingsTab = () => {
|
||||||
|
const { config, handleChange, handleSave, saveStatus } = useOutletContext<SettingsOutletContext>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="stack">
|
||||||
|
<h2>General</h2>
|
||||||
|
<label className="form-field">
|
||||||
|
Theme
|
||||||
|
<select value={config.theme} onChange={(e) => handleChange("theme", e.target.value)}>
|
||||||
|
{THEME_OPTIONS.map((opt) => (
|
||||||
|
<option key={opt.value} value={opt.value}>{opt.label}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
Git user name
|
||||||
|
<input type="text" value={config.git_user_name ?? ""} onChange={(e) => handleChange("git_user_name", e.target.value || null)} placeholder="Your git commit name" />
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
Git user email
|
||||||
|
<input type="email" value={config.git_user_email ?? ""} onChange={(e) => handleChange("git_user_email", e.target.value || null)} placeholder="your.email@example.com" />
|
||||||
|
</label>
|
||||||
|
<label className="form-field">
|
||||||
|
Default editor
|
||||||
|
<input type="text" value={config.default_editor ?? ""} onChange={(e) => handleChange("default_editor", e.target.value || null)} placeholder="e.g., vscode, vim, cursor" />
|
||||||
|
</label>
|
||||||
|
<div className="settings-actions">
|
||||||
|
<button className="primary-button" onClick={() => void handleSave()} type="button">
|
||||||
|
{saveStatus === "saving" ? <><Icon name="loading" size="sm" /> Saving...</> : <><Icon name="save" size="sm" /> Save Settings</>}
|
||||||
|
</button>
|
||||||
|
{saveStatus === "saved" && <span className="success-text">Settings saved!</span>}
|
||||||
|
{saveStatus === "error" && <span className="error-text">Failed to save</span>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import { createSSHKey, deleteSSHKey, listSSHKeys, type SSHKey } from "../api/ssh_keys";
|
import { createSSHKey, deleteSSHKey, listSSHKeys, type SSHKey } from "../api/ssh_keys";
|
||||||
import { Icon } from "../components/icon";
|
import { Icon } from "../components/icon";
|
||||||
|
|
||||||
export const SSHKeysPage = () => {
|
export const SSHKeysPage = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
const [keys, setKeys] = useState<SSHKey[]>([]);
|
const [keys, setKeys] = useState<SSHKey[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
@@ -61,7 +63,15 @@ export const SSHKeysPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="stack">
|
<section className="stack">
|
||||||
<h1>SSH Keys</h1>
|
<div className="page-header">
|
||||||
|
<div>
|
||||||
|
<p className="eyebrow">Settings</p>
|
||||||
|
<h1>SSH Keys</h1>
|
||||||
|
</div>
|
||||||
|
<button className="secondary-button" type="button" onClick={() => navigate("/settings")}>
|
||||||
|
Back to settings
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{error && <div className="error">{error}</div>}
|
{error && <div className="error">{error}</div>}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { Icon } from "../components/icon";
|
import { Icon } from "../components/icon";
|
||||||
import { listToolTypes, type ToolType } from "../api/tool_types";
|
import { listToolTypes, type ToolType } from "../api/tool_types";
|
||||||
@@ -13,6 +14,7 @@ import {
|
|||||||
type ConfigStatus = "loading" | "ready" | "error";
|
type ConfigStatus = "loading" | "ready" | "error";
|
||||||
|
|
||||||
export const ToolConfigsPage = () => {
|
export const ToolConfigsPage = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
const [status, setStatus] = useState<ConfigStatus>("loading");
|
const [status, setStatus] = useState<ConfigStatus>("loading");
|
||||||
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
|
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
|
||||||
const [configs, setConfigs] = useState<ToolConfig[]>([]);
|
const [configs, setConfigs] = useState<ToolConfig[]>([]);
|
||||||
@@ -135,7 +137,13 @@ export const ToolConfigsPage = () => {
|
|||||||
return (
|
return (
|
||||||
<section className="stack">
|
<section className="stack">
|
||||||
<div className="page-header">
|
<div className="page-header">
|
||||||
<h1>Tool Configurations</h1>
|
<div>
|
||||||
|
<p className="eyebrow">Settings</p>
|
||||||
|
<h1>Tool Configurations</h1>
|
||||||
|
</div>
|
||||||
|
<button className="secondary-button" type="button" onClick={() => navigate("/settings")}>
|
||||||
|
Back to settings
|
||||||
|
</button>
|
||||||
<p className="muted">
|
<p className="muted">
|
||||||
Manage environment variables and configuration files for your tools
|
Manage environment variables and configuration files for your tools
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createToolType,
|
createToolType,
|
||||||
@@ -15,6 +16,7 @@ type ToolTypesStatus = "loading" | "ready" | "error";
|
|||||||
type DialogMode = "none" | "create" | "edit";
|
type DialogMode = "none" | "create" | "edit";
|
||||||
|
|
||||||
export const ToolTypesPage = () => {
|
export const ToolTypesPage = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
const [status, setStatus] = useState<ToolTypesStatus>("loading");
|
const [status, setStatus] = useState<ToolTypesStatus>("loading");
|
||||||
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
|
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
|
||||||
const [dialogMode, setDialogMode] = useState<DialogMode>("none");
|
const [dialogMode, setDialogMode] = useState<DialogMode>("none");
|
||||||
@@ -165,12 +167,18 @@ export const ToolTypesPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "1rem" }}>
|
<div className="page-header" style={{ marginBottom: "1rem" }}>
|
||||||
<h1>Tool Types</h1>
|
<div>
|
||||||
<button onClick={openCreate}>
|
<p className="eyebrow">Settings</p>
|
||||||
|
<h1>Tool Types</h1>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<button className="secondary-button" type="button" onClick={() => navigate("/settings")}>Back to settings</button>
|
||||||
|
<button onClick={openCreate}>
|
||||||
<Icon name="add" size="sm" />
|
<Icon name="add" size="sm" />
|
||||||
Create Tool Type
|
Create Tool Type
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{toolTypes.length === 0 ? (
|
{toolTypes.length === 0 ? (
|
||||||
|
|||||||
@@ -18,10 +18,13 @@ const mockToolTypes = [
|
|||||||
definition_type: "compose",
|
definition_type: "compose",
|
||||||
compose_template: "version: '3.8'\\nservices:\\n app:\\n image: codercom/code-server",
|
compose_template: "version: '3.8'\\nservices:\\n app:\\n image: codercom/code-server",
|
||||||
dockerfile_template: null,
|
dockerfile_template: null,
|
||||||
|
build_context: null,
|
||||||
readiness_probe: null,
|
readiness_probe: null,
|
||||||
required_variables: ["REPO_PATH"],
|
required_variables: ["REPO_PATH"],
|
||||||
is_builtin: true,
|
is_builtin: true,
|
||||||
created_by_id: null,
|
created_by_id: null,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "type-2",
|
id: "type-2",
|
||||||
@@ -34,6 +37,7 @@ const mockToolTypes = [
|
|||||||
definition_type: "dockerfile",
|
definition_type: "dockerfile",
|
||||||
compose_template: null,
|
compose_template: null,
|
||||||
dockerfile_template: "FROM python:3.11",
|
dockerfile_template: "FROM python:3.11",
|
||||||
|
build_context: null,
|
||||||
readiness_probe: {
|
readiness_probe: {
|
||||||
command: "python --version",
|
command: "python --version",
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
@@ -42,6 +46,8 @@ const mockToolTypes = [
|
|||||||
required_variables: [],
|
required_variables: [],
|
||||||
is_builtin: false,
|
is_builtin: false,
|
||||||
created_by_id: "user-1",
|
created_by_id: "user-1",
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -49,6 +55,7 @@ const mockConfigs = [
|
|||||||
{
|
{
|
||||||
id: "config-1",
|
id: "config-1",
|
||||||
tool_type_id: "type-1",
|
tool_type_id: "type-1",
|
||||||
|
project_id: null,
|
||||||
key: "OPENAI_API_KEY",
|
key: "OPENAI_API_KEY",
|
||||||
value: "sk-test123",
|
value: "sk-test123",
|
||||||
config_type: "env",
|
config_type: "env",
|
||||||
@@ -62,9 +69,11 @@ const mockConfigs = [
|
|||||||
{
|
{
|
||||||
id: "config-2",
|
id: "config-2",
|
||||||
tool_type_id: "type-2",
|
tool_type_id: "type-2",
|
||||||
|
project_id: null,
|
||||||
key: "advanced-config",
|
key: "advanced-config",
|
||||||
value: "test-value",
|
value: "test-value",
|
||||||
config_type: "env",
|
config_type: "env",
|
||||||
|
file_path: null,
|
||||||
port_override: 9090,
|
port_override: 9090,
|
||||||
start_command: "python app.py",
|
start_command: "python app.py",
|
||||||
working_directory: "/app",
|
working_directory: "/app",
|
||||||
@@ -76,15 +85,19 @@ const mockConfigs = [
|
|||||||
const mockFolders = [
|
const mockFolders = [
|
||||||
{
|
{
|
||||||
id: "folder-1",
|
id: "folder-1",
|
||||||
|
user_id: "user-1",
|
||||||
name: "my-dotfiles",
|
name: "my-dotfiles",
|
||||||
description: "My personal config files",
|
description: "My personal config files",
|
||||||
mount_path: "/home/user",
|
mount_path: "/home/user",
|
||||||
files: { ".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"" },
|
files: { ".zshrc": "export ZSH=\"$HOME/.oh-my-zsh\"" },
|
||||||
project_overrides: {},
|
project_overrides: {},
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "folder-2",
|
id: "folder-2",
|
||||||
|
user_id: "user-1",
|
||||||
name: "project-configs",
|
name: "project-configs",
|
||||||
description: "Project specific configs",
|
description: "Project specific configs",
|
||||||
mount_path: "/workspace",
|
mount_path: "/workspace",
|
||||||
@@ -96,6 +109,8 @@ const mockFolders = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
is_active: false,
|
is_active: false,
|
||||||
|
created_at: "2024-01-01T00:00:00Z",
|
||||||
|
updated_at: "2024-01-01T00:00:00Z",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -115,9 +130,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("renders tool types tab by default", async () => {
|
it("renders tool types tab by default", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -128,9 +143,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("switches to configs tab", async () => {
|
it("switches to configs tab", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -147,9 +162,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("switches to folders tab", async () => {
|
it("switches to folders tab", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -166,9 +181,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("opens tool type creation form", async () => {
|
it("opens tool type creation form", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -178,15 +193,15 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
||||||
|
|
||||||
expect(screen.getByLabelText(/name/i)).toBeInTheDocument();
|
expect(screen.getByLabelText("Name *")).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText(/display name/i)).toBeInTheDocument();
|
expect(screen.getByLabelText("Display Name *")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates tool type with compose definition", async () => {
|
it("creates tool type with compose definition", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
const createMock = vi.spyOn(toolTypesApi, "createToolType").mockResolvedValue(mockToolTypes[1]);
|
const createMock = vi.spyOn(toolTypesApi, "createToolType").mockResolvedValue(mockToolTypes[1] as unknown as toolTypesApi.ToolType);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -196,12 +211,15 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/name/i), {
|
fireEvent.change(screen.getByLabelText("Name *"), {
|
||||||
target: { value: "new-tool" },
|
target: { value: "new-tool" },
|
||||||
});
|
});
|
||||||
fireEvent.change(screen.getByLabelText(/display name/i), {
|
fireEvent.change(screen.getByLabelText("Display Name *"), {
|
||||||
target: { value: "New Tool" },
|
target: { value: "New Tool" },
|
||||||
});
|
});
|
||||||
|
fireEvent.change(screen.getByLabelText("Default Port *"), {
|
||||||
|
target: { value: "8080" },
|
||||||
|
});
|
||||||
fireEvent.change(screen.getByLabelText(/compose template/i), {
|
fireEvent.change(screen.getByLabelText(/compose template/i), {
|
||||||
target: { value: "version: '3.8'\\nservices:\\n app:\\n image: nginx" },
|
target: { value: "version: '3.8'\\nservices:\\n app:\\n image: nginx" },
|
||||||
});
|
});
|
||||||
@@ -218,14 +236,13 @@ describe("ToolWorkshopPage", () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(listMock).toHaveBeenCalledTimes(2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates tool type with dockerfile definition", async () => {
|
it("creates tool type with dockerfile definition", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
const createMock = vi.spyOn(toolTypesApi, "createToolType").mockResolvedValue(mockToolTypes[1]);
|
const createMock = vi.spyOn(toolTypesApi, "createToolType").mockResolvedValue(mockToolTypes[1] as unknown as toolTypesApi.ToolType);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -235,17 +252,22 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/name/i), {
|
fireEvent.change(screen.getByLabelText("Name *"), {
|
||||||
target: { value: "docker-tool" },
|
target: { value: "docker-tool" },
|
||||||
});
|
});
|
||||||
fireEvent.change(screen.getByLabelText(/display name/i), {
|
fireEvent.change(screen.getByLabelText("Display Name *"), {
|
||||||
target: { value: "Docker Tool" },
|
target: { value: "Docker Tool" },
|
||||||
});
|
});
|
||||||
|
fireEvent.change(screen.getByLabelText("Default Port *"), {
|
||||||
|
target: { value: "3000" },
|
||||||
|
});
|
||||||
|
|
||||||
// Switch to dockerfile
|
// Switch to dockerfile
|
||||||
fireEvent.click(screen.getByLabelText(/dockerfile/i));
|
fireEvent.change(screen.getByLabelText("Definition Type"), {
|
||||||
|
target: { value: "dockerfile" },
|
||||||
|
});
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/dockerfile template/i), {
|
fireEvent.change(screen.getByLabelText("Dockerfile *"), {
|
||||||
target: { value: "FROM python:3.11\\nRUN pip install flask" },
|
target: { value: "FROM python:3.11\\nRUN pip install flask" },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -263,9 +285,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("shows readiness probe fields", async () => {
|
it("shows readiness probe fields", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -275,20 +297,15 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
||||||
|
|
||||||
expect(screen.getByLabelText(/readiness command/i)).toBeInTheDocument();
|
expect(screen.getByText(/readiness probe command/i)).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText(/timeout/i)).toBeInTheDocument();
|
expect(screen.getByText(/timeout/i)).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText(/interval/i)).toBeInTheDocument();
|
expect(screen.getByText(/interval/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens config creation form", async () => {
|
it("opens config creation form", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
vi.spyOn(toolConfigsApi, "getToolConfigDefaults").mockResolvedValue({
|
|
||||||
tool_type_id: "type-1",
|
|
||||||
suggested_configs: [],
|
|
||||||
port_override: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -309,15 +326,10 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("creates config with advanced fields", async () => {
|
it("creates config with advanced fields", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
const configsListMock = vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
const configsListMock = vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
const createMock = vi.spyOn(toolConfigsApi, "createToolConfig").mockResolvedValue(mockConfigs[1]);
|
const createMock = vi.spyOn(toolConfigsApi, "createToolConfig").mockResolvedValue(mockConfigs[1] as unknown as toolConfigsApi.ToolConfig);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
vi.spyOn(toolConfigsApi, "getToolConfigDefaults").mockResolvedValue({
|
|
||||||
tool_type_id: "type-1",
|
|
||||||
suggested_configs: [],
|
|
||||||
port_override: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -346,7 +358,7 @@ describe("ToolWorkshopPage", () => {
|
|||||||
target: { value: "python app.py" },
|
target: { value: "python app.py" },
|
||||||
});
|
});
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create$/i }));
|
fireEvent.click(screen.getByRole("button", { name: /add$/i }));
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(createMock).toHaveBeenCalledWith(
|
expect(createMock).toHaveBeenCalledWith(
|
||||||
@@ -362,9 +374,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("opens folder creation form", async () => {
|
it("opens folder creation form", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -380,15 +392,15 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create folder/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create folder/i }));
|
||||||
|
|
||||||
expect(screen.getByLabelText(/name/i)).toBeInTheDocument();
|
expect(screen.getByLabelText("Name *")).toBeInTheDocument();
|
||||||
expect(screen.getByLabelText(/mount path/i)).toBeInTheDocument();
|
expect(screen.getByLabelText("Mount Path *")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates config folder successfully", async () => {
|
it("creates config folder successfully", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
const foldersListMock = vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
const foldersListMock = vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
const createMock = vi.spyOn(configFoldersApi, "createConfigFolder").mockResolvedValue(mockFolders[0] as unknown as configFoldersApi.ConfigFolder);
|
||||||
const createMock = vi.spyOn(configFoldersApi, "createConfigFolder").mockResolvedValue(mockFolders[0]);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -404,10 +416,10 @@ describe("ToolWorkshopPage", () => {
|
|||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create folder/i }));
|
fireEvent.click(screen.getByRole("button", { name: /create folder/i }));
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/name/i), {
|
fireEvent.change(screen.getByLabelText("Name *"), {
|
||||||
target: { value: "new-folder" },
|
target: { value: "new-folder" },
|
||||||
});
|
});
|
||||||
fireEvent.change(screen.getByLabelText(/mount path/i), {
|
fireEvent.change(screen.getByLabelText("Mount Path *"), {
|
||||||
target: { value: "/home/dev" },
|
target: { value: "/home/dev" },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -425,9 +437,9 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("shows folder active/inactive status", async () => {
|
it("shows folder active/inactive status", async () => {
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -441,46 +453,8 @@ describe("ToolWorkshopPage", () => {
|
|||||||
expect(screen.getByText("my-dotfiles")).toBeInTheDocument();
|
expect(screen.getByText("my-dotfiles")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check that active folder is marked
|
// Check that active folder shows Active badge
|
||||||
const activeFolder = screen.getByText("my-dotfiles").closest("[data-testid='folder-item']") ||
|
expect(screen.getByText("Active")).toBeInTheDocument();
|
||||||
screen.getByText("my-dotfiles").parentElement;
|
|
||||||
expect(activeFolder?.textContent).toContain("active");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("validates tool type before creation", async () => {
|
|
||||||
vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
|
||||||
const validateMock = vi.spyOn(toolTypesApi, "validateToolType").mockResolvedValue({
|
|
||||||
valid: false,
|
|
||||||
errors: ["Invalid YAML syntax"],
|
|
||||||
});
|
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(screen.getByText("VS Code Server")).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /create tool type/i }));
|
|
||||||
|
|
||||||
fireEvent.change(screen.getByLabelText(/name/i), {
|
|
||||||
target: { value: "bad-tool" },
|
|
||||||
});
|
|
||||||
fireEvent.change(screen.getByLabelText(/display name/i), {
|
|
||||||
target: { value: "Bad Tool" },
|
|
||||||
});
|
|
||||||
fireEvent.change(screen.getByLabelText(/compose template/i), {
|
|
||||||
target: { value: "invalid: yaml: [" },
|
|
||||||
});
|
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /validate/i }));
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(validateMock).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(screen.getByText(/invalid yaml syntax/i)).toBeInTheDocument();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles error state gracefully", async () => {
|
it("handles error state gracefully", async () => {
|
||||||
@@ -500,13 +474,13 @@ describe("ToolWorkshopPage", () => {
|
|||||||
it("retries loading after error", async () => {
|
it("retries loading after error", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes")
|
const listMock = vi.spyOn(toolTypesApi, "listToolTypes")
|
||||||
.mockRejectedValueOnce(new Error("Network error"))
|
.mockRejectedValueOnce(new Error("Network error"))
|
||||||
.mockResolvedValueOnce(mockToolTypes);
|
.mockResolvedValueOnce(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs")
|
vi.spyOn(toolConfigsApi, "listToolConfigs")
|
||||||
.mockRejectedValueOnce(new Error("Network error"))
|
.mockRejectedValueOnce(new Error("Network error"))
|
||||||
.mockResolvedValueOnce(mockConfigs);
|
.mockResolvedValueOnce(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders")
|
vi.spyOn(configFoldersApi, "listConfigFolders")
|
||||||
.mockRejectedValueOnce(new Error("Network error"))
|
.mockRejectedValueOnce(new Error("Network error"))
|
||||||
.mockResolvedValueOnce(mockFolders);
|
.mockResolvedValueOnce(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -523,10 +497,10 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("deletes tool type successfully", async () => {
|
it("deletes tool type successfully", async () => {
|
||||||
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes);
|
const listMock = vi.spyOn(toolTypesApi, "listToolTypes").mockResolvedValue(mockToolTypes as unknown as toolTypesApi.ToolType[]);
|
||||||
const deleteMock = vi.spyOn(toolTypesApi, "deleteToolType").mockResolvedValue(undefined);
|
const deleteMock = vi.spyOn(toolTypesApi, "deleteToolType").mockResolvedValue(undefined);
|
||||||
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs);
|
vi.spyOn(toolConfigsApi, "listToolConfigs").mockResolvedValue(mockConfigs as unknown as toolConfigsApi.ToolConfig[]);
|
||||||
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders);
|
vi.spyOn(configFoldersApi, "listConfigFolders").mockResolvedValue(mockFolders as unknown as configFoldersApi.ConfigFolder[]);
|
||||||
|
|
||||||
render(<ToolWorkshopPage />);
|
render(<ToolWorkshopPage />);
|
||||||
|
|
||||||
@@ -535,19 +509,14 @@ describe("ToolWorkshopPage", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Find and click delete button for custom tool (not built-in)
|
// Find and click delete button for custom tool (not built-in)
|
||||||
const customToolCard = screen.getByText("Custom Tool").closest("[data-testid='tool-type-item']") ||
|
const customToolCard = screen.getByText("Custom Tool").closest(".card") ||
|
||||||
screen.getByText("Custom Tool").parentElement;
|
screen.getByText("Custom Tool").parentElement;
|
||||||
if (customToolCard) {
|
if (customToolCard) {
|
||||||
const deleteButton = within(customToolCard as HTMLElement).queryByRole("button", { name: /delete/i });
|
const deleteButton = within(customToolCard as HTMLElement).queryByRole("button", { name: /delete/i });
|
||||||
if (deleteButton) {
|
if (deleteButton) {
|
||||||
|
vi.spyOn(window, "confirm").mockReturnValue(true);
|
||||||
fireEvent.click(deleteButton);
|
fireEvent.click(deleteButton);
|
||||||
|
|
||||||
// Confirm deletion
|
|
||||||
const confirmButton = screen.queryByRole("button", { name: /confirm/i });
|
|
||||||
if (confirmButton) {
|
|
||||||
fireEvent.click(confirmButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(deleteMock).toHaveBeenCalledWith("type-2");
|
expect(deleteMock).toHaveBeenCalledWith("type-2");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
deleteToolType,
|
deleteToolType,
|
||||||
listToolTypes,
|
listToolTypes,
|
||||||
updateToolType,
|
updateToolType,
|
||||||
validateToolType,
|
|
||||||
type CreateToolTypeRequest,
|
type CreateToolTypeRequest,
|
||||||
type ReadinessProbe,
|
type ReadinessProbe,
|
||||||
type ToolType,
|
type ToolType,
|
||||||
@@ -14,7 +13,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
createToolConfig,
|
createToolConfig,
|
||||||
deleteToolConfig,
|
deleteToolConfig,
|
||||||
getToolConfigDefaults,
|
|
||||||
listToolConfigs,
|
listToolConfigs,
|
||||||
updateToolConfig,
|
updateToolConfig,
|
||||||
type CreateToolConfigRequest,
|
type CreateToolConfigRequest,
|
||||||
@@ -605,8 +603,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Readiness Probe Command</label>
|
<label htmlFor="readiness-command">Readiness Probe Command</label>
|
||||||
<input
|
<input
|
||||||
|
id="readiness-command"
|
||||||
type="text"
|
type="text"
|
||||||
value={toolTypeForm.readiness_command}
|
value={toolTypeForm.readiness_command}
|
||||||
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_command: e.target.value })}
|
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_command: e.target.value })}
|
||||||
@@ -617,8 +616,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
|
|
||||||
<div className="row" style={{ gap: "1rem" }}>
|
<div className="row" style={{ gap: "1rem" }}>
|
||||||
<div className="form-group" style={{ flex: 1 }}>
|
<div className="form-group" style={{ flex: 1 }}>
|
||||||
<label>Timeout (seconds)</label>
|
<label htmlFor="readiness-timeout">Timeout (seconds)</label>
|
||||||
<input
|
<input
|
||||||
|
id="readiness-timeout"
|
||||||
type="number"
|
type="number"
|
||||||
value={toolTypeForm.readiness_timeout}
|
value={toolTypeForm.readiness_timeout}
|
||||||
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_timeout: e.target.value })}
|
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_timeout: e.target.value })}
|
||||||
@@ -626,8 +626,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group" style={{ flex: 1 }}>
|
<div className="form-group" style={{ flex: 1 }}>
|
||||||
<label>Interval (seconds)</label>
|
<label htmlFor="readiness-interval">Interval (seconds)</label>
|
||||||
<input
|
<input
|
||||||
|
id="readiness-interval"
|
||||||
type="number"
|
type="number"
|
||||||
value={toolTypeForm.readiness_interval}
|
value={toolTypeForm.readiness_interval}
|
||||||
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_interval: e.target.value })}
|
onChange={(e) => setToolTypeForm({ ...toolTypeForm, readiness_interval: e.target.value })}
|
||||||
@@ -764,8 +765,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Value</label>
|
<label htmlFor="config-value">Value</label>
|
||||||
<textarea
|
<textarea
|
||||||
|
id="config-value"
|
||||||
value={configForm.value}
|
value={configForm.value}
|
||||||
onChange={(e) => setConfigForm({ ...configForm, value: e.target.value })}
|
onChange={(e) => setConfigForm({ ...configForm, value: e.target.value })}
|
||||||
placeholder={configForm.config_type === "env" ? "Enter value..." : "Enter file contents..."}
|
placeholder={configForm.config_type === "env" ? "Enter value..." : "Enter file contents..."}
|
||||||
@@ -777,8 +779,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
|
|
||||||
<div className="row" style={{ gap: "1rem" }}>
|
<div className="row" style={{ gap: "1rem" }}>
|
||||||
<div className="form-group" style={{ flex: 1 }}>
|
<div className="form-group" style={{ flex: 1 }}>
|
||||||
<label>Port Override</label>
|
<label htmlFor="config-port-override">Port Override</label>
|
||||||
<input
|
<input
|
||||||
|
id="config-port-override"
|
||||||
type="number"
|
type="number"
|
||||||
value={configForm.port_override}
|
value={configForm.port_override}
|
||||||
onChange={(e) => setConfigForm({ ...configForm, port_override: e.target.value })}
|
onChange={(e) => setConfigForm({ ...configForm, port_override: e.target.value })}
|
||||||
@@ -787,8 +790,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group" style={{ flex: 1 }}>
|
<div className="form-group" style={{ flex: 1 }}>
|
||||||
<label>Start Command</label>
|
<label htmlFor="config-start-command">Start Command</label>
|
||||||
<input
|
<input
|
||||||
|
id="config-start-command"
|
||||||
type="text"
|
type="text"
|
||||||
value={configForm.start_command}
|
value={configForm.start_command}
|
||||||
onChange={(e) => setConfigForm({ ...configForm, start_command: e.target.value })}
|
onChange={(e) => setConfigForm({ ...configForm, start_command: e.target.value })}
|
||||||
@@ -918,8 +922,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
<h3>{selectedFolder ? "Edit" : "Create"} Config Folder</h3>
|
<h3>{selectedFolder ? "Edit" : "Create"} Config Folder</h3>
|
||||||
<form onSubmit={handleFolderSubmit} className="stack">
|
<form onSubmit={handleFolderSubmit} className="stack">
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Name *</label>
|
<label htmlFor="folder-name">Name *</label>
|
||||||
<input
|
<input
|
||||||
|
id="folder-name"
|
||||||
type="text"
|
type="text"
|
||||||
value={folderForm.name}
|
value={folderForm.name}
|
||||||
onChange={(e) => setFolderForm({ ...folderForm, name: e.target.value })}
|
onChange={(e) => setFolderForm({ ...folderForm, name: e.target.value })}
|
||||||
@@ -930,8 +935,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Description</label>
|
<label htmlFor="folder-description">Description</label>
|
||||||
<input
|
<input
|
||||||
|
id="folder-description"
|
||||||
type="text"
|
type="text"
|
||||||
value={folderForm.description}
|
value={folderForm.description}
|
||||||
onChange={(e) => setFolderForm({ ...folderForm, description: e.target.value })}
|
onChange={(e) => setFolderForm({ ...folderForm, description: e.target.value })}
|
||||||
@@ -941,8 +947,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Mount Path *</label>
|
<label htmlFor="folder-mount-path">Mount Path *</label>
|
||||||
<input
|
<input
|
||||||
|
id="folder-mount-path"
|
||||||
type="text"
|
type="text"
|
||||||
value={folderForm.mount_path}
|
value={folderForm.mount_path}
|
||||||
onChange={(e) => setFolderForm({ ...folderForm, mount_path: e.target.value })}
|
onChange={(e) => setFolderForm({ ...folderForm, mount_path: e.target.value })}
|
||||||
@@ -953,8 +960,9 @@ export const ToolWorkshopPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Files (JSON object)</label>
|
<label htmlFor="folder-files">Files (JSON object)</label>
|
||||||
<textarea
|
<textarea
|
||||||
|
id="folder-files"
|
||||||
value={folderForm.files_json}
|
value={folderForm.files_json}
|
||||||
onChange={(e) => setFolderForm({ ...folderForm, files_json: e.target.value })}
|
onChange={(e) => setFolderForm({ ...folderForm, files_json: e.target.value })}
|
||||||
placeholder='{".zshrc": "export ZSH=...", ".gitconfig": "[user]\\nname = ..."}'
|
placeholder='{".zshrc": "export ZSH=...", ".gitconfig": "[user]\\nname = ..."}'
|
||||||
|
|||||||
+18
-10
@@ -2,24 +2,29 @@ import { Navigate, Route, Routes } from "react-router-dom";
|
|||||||
|
|
||||||
import { AppShell } from "./components/app-shell";
|
import { AppShell } from "./components/app-shell";
|
||||||
import { ProtectedRoute } from "./components/protected-route";
|
import { ProtectedRoute } from "./components/protected-route";
|
||||||
import { DashboardPage } from "./pages/dashboard";
|
import { HomePage } from "./pages/dashboard";
|
||||||
import { LoginRedirectPage, NotFoundPage } from "./pages/placeholder";
|
import { LoginRedirectPage, NotFoundPage } from "./pages/placeholder";
|
||||||
import { SessionsPage } from "./pages/sessions";
|
|
||||||
import { ProfilePage } from "./pages/profile";
|
import { ProfilePage } from "./pages/profile";
|
||||||
import { ProjectsPage } from "./pages/projects";
|
import { ProjectsPage } from "./pages/projects";
|
||||||
import { GitRepositoriesPage } from "./pages/git-repositories";
|
import { GitRepositoriesPage } from "./pages/git-repositories";
|
||||||
import { GitHistoryPage } from "./pages/git-history";
|
import { GitHistoryPage } from "./pages/git-history";
|
||||||
import { ProjectSettingsPage } from "./pages/project-settings";
|
import { ProjectSettingsPage } from "./pages/project-settings";
|
||||||
import { RepoWorkspace } from "./pages/repo-workspace";
|
import { RepoWorkspace } from "./pages/repo-workspace";
|
||||||
import { SSHKeysPage } from "./pages/ssh-keys";
|
import { SettingsPage, GeneralSettingsTab } from "./pages/settings";
|
||||||
import { SettingsPage } from "./pages/settings";
|
|
||||||
import { TerminalPage } from "./pages/terminal";
|
import { TerminalPage } from "./pages/terminal";
|
||||||
import { ToolWorkshopPage } from "./pages/tool-workshop";
|
import { ToolWorkshopPage } from "./pages/tool-workshop";
|
||||||
|
import { SSHKeysPage } from "./pages/ssh-keys";
|
||||||
|
import { ToolConfigsPage } from "./pages/tool-configs";
|
||||||
|
import { ToolTypesPage } from "./pages/tool-types";
|
||||||
|
|
||||||
export const AppRouter = () => {
|
export const AppRouter = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/login" element={<LoginRedirectPage />} />
|
<Route path="/login" element={<LoginRedirectPage />} />
|
||||||
|
<Route path="/sessions" element={<Navigate to="/" replace />} />
|
||||||
|
<Route path="/ssh-keys" element={<Navigate to="/settings/ssh-keys" replace />} />
|
||||||
|
<Route path="/tool-types" element={<Navigate to="/settings/tool-types" replace />} />
|
||||||
|
<Route path="/tool-configs" element={<Navigate to="/settings/tool-configs" replace />} />
|
||||||
<Route
|
<Route
|
||||||
path="/"
|
path="/"
|
||||||
element={
|
element={
|
||||||
@@ -28,19 +33,22 @@ export const AppRouter = () => {
|
|||||||
</ProtectedRoute>
|
</ProtectedRoute>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Route index element={<DashboardPage />} />
|
<Route index element={<HomePage />} />
|
||||||
<Route path="sessions" element={<SessionsPage />} />
|
|
||||||
<Route path="projects" element={<ProjectsPage />} />
|
<Route path="projects" element={<ProjectsPage />} />
|
||||||
<Route path="projects/:projectId" element={<RepoWorkspace />} />
|
<Route path="projects/:projectId" element={<RepoWorkspace />} />
|
||||||
<Route path="projects/:projectId/repositories" element={<GitRepositoriesPage />} />
|
<Route path="projects/:projectId/repositories" element={<GitRepositoriesPage />} />
|
||||||
<Route path="projects/:projectId/repositories/:repoId/history" element={<GitHistoryPage />} />
|
<Route path="projects/:projectId/repositories/:repoId/history" element={<GitHistoryPage />} />
|
||||||
<Route path="projects/:projectId/settings/*" element={<ProjectSettingsPage />} />
|
<Route path="projects/:projectId/settings/*" element={<ProjectSettingsPage />} />
|
||||||
<Route path="ssh-keys" element={<SSHKeysPage />} />
|
|
||||||
<Route path="profile" element={<ProfilePage />} />
|
<Route path="profile" element={<ProfilePage />} />
|
||||||
<Route path="settings" element={<SettingsPage />} />
|
<Route path="settings" element={<SettingsPage />}>
|
||||||
|
<Route index element={<Navigate to="general" replace />} />
|
||||||
|
<Route path="general" element={<GeneralSettingsTab />} />
|
||||||
|
<Route path="ssh-keys" element={<SSHKeysPage />} />
|
||||||
|
<Route path="tool-types" element={<ToolTypesPage />} />
|
||||||
|
<Route path="tool-configs" element={<ToolConfigsPage />} />
|
||||||
|
<Route path="*" element={<Navigate to="general" replace />} />
|
||||||
|
</Route>
|
||||||
<Route path="tool-workshop" element={<ToolWorkshopPage />} />
|
<Route path="tool-workshop" element={<ToolWorkshopPage />} />
|
||||||
<Route path="tool-types" element={<Navigate to="/tool-workshop" replace />} />
|
|
||||||
<Route path="tool-configs" element={<Navigate to="/tool-workshop" replace />} />
|
|
||||||
<Route path="instances/:instanceId/terminal" element={<TerminalPage />} />
|
<Route path="instances/:instanceId/terminal" element={<TerminalPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/404" element={<NotFoundPage />} />
|
<Route path="/404" element={<NotFoundPage />} />
|
||||||
|
|||||||
+148
-10
@@ -1,6 +1,6 @@
|
|||||||
:root {
|
:root {
|
||||||
color-scheme: light;
|
color-scheme: light;
|
||||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
font-family: "Inter", "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||||
--bg: #f4f1ea;
|
--bg: #f4f1ea;
|
||||||
--panel: #fffef9;
|
--panel: #fffef9;
|
||||||
--ink: #1d1d1b;
|
--ink: #1d1d1b;
|
||||||
@@ -8,6 +8,17 @@
|
|||||||
--brand: #275d4b;
|
--brand: #275d4b;
|
||||||
--brand-strong: #154236;
|
--brand-strong: #154236;
|
||||||
--border: #d8d0c5;
|
--border: #d8d0c5;
|
||||||
|
--primary: #275d4b;
|
||||||
|
--primary-fg: #fffef9;
|
||||||
|
--color-primary: #275d4b;
|
||||||
|
--success: #2f8f62;
|
||||||
|
--success-light: rgba(47, 143, 98, 0.14);
|
||||||
|
--warning: #c08a1e;
|
||||||
|
--warning-light: rgba(192, 138, 30, 0.14);
|
||||||
|
--danger: #b94a3c;
|
||||||
|
--danger-light: rgba(185, 74, 60, 0.14);
|
||||||
|
--info: #4f7fb8;
|
||||||
|
--info-light: rgba(79, 127, 184, 0.14);
|
||||||
|
|
||||||
/* Spacing Scale (4px base) */
|
/* Spacing Scale (4px base) */
|
||||||
--space-1: 0.25rem;
|
--space-1: 0.25rem;
|
||||||
@@ -36,13 +47,16 @@
|
|||||||
|
|
||||||
[data-theme="dark"] {
|
[data-theme="dark"] {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--bg: #1a1a18;
|
--bg: #171613;
|
||||||
--panel: #252522;
|
--panel: #22201d;
|
||||||
--ink: #e8e6e1;
|
--ink: #ece7df;
|
||||||
--muted: #a39e96;
|
--muted: #a59d92;
|
||||||
--brand: #4a9e7f;
|
--brand: #5fa889;
|
||||||
--brand-strong: #3d8a6e;
|
--brand-strong: #4d9175;
|
||||||
--border: #3d3d38;
|
--border: #39342d;
|
||||||
|
--primary: #5fa889;
|
||||||
|
--primary-fg: #171613;
|
||||||
|
--color-primary: #5fa889;
|
||||||
--success: #22c55e;
|
--success: #22c55e;
|
||||||
--success-light: rgba(34, 197, 94, 0.15);
|
--success-light: rgba(34, 197, 94, 0.15);
|
||||||
--warning: #f59e0b;
|
--warning: #f59e0b;
|
||||||
@@ -84,12 +98,12 @@ a {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.85rem 1.25rem;
|
padding: 0.85rem 1.25rem;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
background: rgba(255, 255, 255, 0.85);
|
background: color-mix(in srgb, var(--panel) 88%, transparent);
|
||||||
backdrop-filter: blur(7px);
|
backdrop-filter: blur(7px);
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme="dark"] .shell-header {
|
[data-theme="dark"] .shell-header {
|
||||||
background: rgba(37, 37, 34, 0.85);
|
background: color-mix(in srgb, var(--panel) 88%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand {
|
.brand {
|
||||||
@@ -115,6 +129,7 @@ a {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.4rem;
|
gap: 0.4rem;
|
||||||
|
background: color-mix(in srgb, var(--panel) 65%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-item {
|
.nav-item {
|
||||||
@@ -133,11 +148,134 @@ a {
|
|||||||
color: #f7fff7;
|
color: #f7fff7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-section-title {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
padding: 0.25rem 0.75rem;
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border);
|
||||||
|
margin: 0.5rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
.shell-content {
|
.shell-content {
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
margin: 0;
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-page,
|
||||||
|
.settings-page {
|
||||||
|
max-width: 1240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-hero {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: var(--space-4);
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-hero-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary-grid,
|
||||||
|
.home-project-grid,
|
||||||
|
.home-session-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-summary-grid {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-project-grid,
|
||||||
|
.home-session-grid {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-section h2,
|
||||||
|
.settings-header h1,
|
||||||
|
.settings-panel h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-section h3,
|
||||||
|
.home-section p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-tight {
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-2);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tab {
|
||||||
|
padding: 0.6rem 0.9rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--muted);
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-tab.active {
|
||||||
|
background: var(--brand);
|
||||||
|
color: white;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-actions,
|
||||||
|
.form-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-3);
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-text {
|
||||||
|
color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-text {
|
||||||
|
color: var(--success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.small {
|
||||||
|
padding: 0.42rem 0.7rem;
|
||||||
|
min-height: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-card,
|
||||||
|
.project-card,
|
||||||
|
.recent-session-item {
|
||||||
|
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsive Shell */
|
/* Responsive Shell */
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.shell-body {
|
.shell-body {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
schema: spec-driven
|
||||||
|
created: 2026-05-24
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
## Context
|
||||||
|
|
||||||
|
The current system uses `config_folders` with a flat `files` JSONB and an `is_active` flag for auto-mounting at tool launch time. This design is inflexible: only one folder can be active, there's no ordering of includes, no explicit per-tool-instance selection, and mount definitions are mixed with file contents in a single blob.
|
||||||
|
|
||||||
|
## Goals / Non-Goals
|
||||||
|
|
||||||
|
**Goals:**
|
||||||
|
- Provide structured config profiles with named collections of mounts and includes
|
||||||
|
- Support ordered include lists so profiles can reference other profiles in sequence
|
||||||
|
- Allow per-tool-instance profile selection with fallback to user/tool-type defaults
|
||||||
|
- Remove implicit auto-mounting behavior at launch time
|
||||||
|
- Maintain backward compatibility for existing `config_folders` data during migration
|
||||||
|
|
||||||
|
**Non-Goals:**
|
||||||
|
- Frontend UI for profile management (separate change)
|
||||||
|
- Real-time profile switching on running instances
|
||||||
|
- Profile versioning or history
|
||||||
|
|
||||||
|
## Decisions
|
||||||
|
|
||||||
|
### 1. New `config_profiles` table replaces the semantic role of `config_folders`
|
||||||
|
- Rationale: A profile is a higher-level concept than a folder; it includes mounts, includes, and metadata
|
||||||
|
- `config_folders` remains for data migration but is no longer used for auto-mounting
|
||||||
|
|
||||||
|
### 2. `config_includes` provides ordered many-to-many self-reference on `config_profiles`
|
||||||
|
- Rationale: Profiles need to include other profiles (e.g., a "base" profile included by "project-specific")
|
||||||
|
- `order_index` column controls application order
|
||||||
|
|
||||||
|
### 3. `config_mounts` stores individual mount/file entries
|
||||||
|
- Rationale: Normalizing mounts allows querying, ordering, and validation per mount
|
||||||
|
- Each mount has a `mount_path`, optional `content` text, and optional `source_profile_id` for transitive includes
|
||||||
|
|
||||||
|
### 4. Default profile stored on `user_configs.config` JSONB
|
||||||
|
- Rationale: Avoids schema changes to `users`; the existing `user_configs` table already stores per-user JSON
|
||||||
|
- Key: `default_profile_id` (global default) and `default_profiles` map for per-tool-type defaults
|
||||||
|
|
||||||
|
### 5. `tool_instances.selected_profile_id` for explicit selection
|
||||||
|
- Rationale: Clear, direct foreign key; nullable to allow fallback to defaults
|
||||||
|
- Null means "use default resolution"
|
||||||
|
|
||||||
|
## Risks / Trade-offs
|
||||||
|
|
||||||
|
- [Risk] Existing `config_folders` data becomes orphaned if not migrated → Mitigation: keep table, stop auto-mount behavior only
|
||||||
|
- [Risk] Profile include cycles could cause infinite loops → Mitigation: validate at write time, detect cycles in include graph
|
||||||
|
- [Risk] Multiple includes with overlapping mount paths → Mitigation: last-include-wins based on order_index
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
## Why
|
||||||
|
|
||||||
|
The current `config_folders` table provides basic file mounting but lacks structured profile management, ordering, and per-tool-instance selection. We need a proper config profile system that supports ordered includes, mount/file definitions, default selection, and explicit profile assignment per tool instance.
|
||||||
|
|
||||||
|
## What Changes
|
||||||
|
|
||||||
|
- Add `ConfigProfile` model to replace the legacy `config_folders` concept with structured profiles
|
||||||
|
- Add `ConfigInclude` model for ordered include lists within profiles
|
||||||
|
- Add `ConfigMount` model for mount/file definitions (replacing the flat `files` JSONB on `config_folders`)
|
||||||
|
- Add default profile selection per user and tool type
|
||||||
|
- Add `selected_profile_id` to `ToolInstance` for per-instance profile selection
|
||||||
|
- Remove launch-time reliance on legacy active config folder auto-mounting (mark `config_folders.is_active` as deprecated, stop auto-mounting at launch)
|
||||||
|
- Create database migrations for all new tables
|
||||||
|
- **BREAKING**: Legacy `config_folders` auto-mounting behavior will be removed; tool instances must explicitly select a profile
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
### New Capabilities
|
||||||
|
- `config-profile-management`: CRUD operations for config profiles, includes, and mounts
|
||||||
|
- `tool-instance-profile-selection`: Assign and switch config profiles per tool instance
|
||||||
|
|
||||||
|
### Modified Capabilities
|
||||||
|
- `tool-instance-launch`: Change launch behavior to use explicit profile selection instead of auto-mounting active config folder
|
||||||
|
|
||||||
|
## Impact
|
||||||
|
|
||||||
|
- New database tables: `config_profiles`, `config_includes`, `config_mounts`
|
||||||
|
- Modified tables: `tool_instances` (add `selected_profile_id`), `users` or `user_configs` (add default profile selection)
|
||||||
|
- API endpoints for profile management and instance profile assignment
|
||||||
|
- Tool launch logic changes (remove auto-mount, use explicit profile)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
## ADDED Requirements
|
||||||
|
|
||||||
|
### Requirement: User can create config profiles
|
||||||
|
The system SHALL allow users to create named config profiles containing mounts and includes.
|
||||||
|
|
||||||
|
#### Scenario: Successful profile creation
|
||||||
|
- **WHEN** user creates a profile with name, description, and mount list
|
||||||
|
- **THEN** the profile is stored with a unique ID and associated mounts
|
||||||
|
|
||||||
|
### Requirement: Profile includes are ordered
|
||||||
|
The system SHALL support ordered includes where profiles can reference other profiles with a defined application sequence.
|
||||||
|
|
||||||
|
#### Scenario: Include with order
|
||||||
|
- **WHEN** user adds an include to a profile with order_index 1
|
||||||
|
- **THEN** the included profile's mounts are applied after order_index 0 includes
|
||||||
|
|
||||||
|
### Requirement: Config mounts define files and paths
|
||||||
|
The system SHALL store individual mount entries with mount_path, optional content, and optional source profile reference.
|
||||||
|
|
||||||
|
#### Scenario: Add mount to profile
|
||||||
|
- **WHEN** user adds a mount with mount_path "/app/config.json" and content "{}"
|
||||||
|
- **THEN** the mount is stored and linked to the profile
|
||||||
|
|
||||||
|
### Requirement: Cycle detection in includes
|
||||||
|
The system SHALL prevent creation of include cycles.
|
||||||
|
|
||||||
|
#### Scenario: Attempt cyclic include
|
||||||
|
- **WHEN** user tries to include profile B in profile A where A is already included in B
|
||||||
|
- **THEN** the system rejects the request with an error
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
## ADDED Requirements
|
||||||
|
|
||||||
|
### Requirement: Tool instance can have selected profile
|
||||||
|
The system SHALL allow setting an explicit config profile on a tool instance.
|
||||||
|
|
||||||
|
#### Scenario: Assign profile to instance
|
||||||
|
- **WHEN** user sets selected_profile_id on a tool instance
|
||||||
|
- **THEN** the instance stores the profile ID and uses it at launch time
|
||||||
|
|
||||||
|
### Requirement: Tool instance uses default profile when none selected
|
||||||
|
The system SHALL resolve a default profile for a tool instance when no explicit profile is selected.
|
||||||
|
|
||||||
|
#### Scenario: Fallback to user default
|
||||||
|
- **WHEN** a tool instance has no selected_profile_id
|
||||||
|
- **THEN** the system uses the user's default profile for that tool type, or the global default
|
||||||
|
|
||||||
|
### Requirement: Remove legacy auto-mount behavior
|
||||||
|
The system SHALL no longer auto-mount the active config folder at tool launch time.
|
||||||
|
|
||||||
|
#### Scenario: Launch without active folder
|
||||||
|
- **WHEN** a tool instance launches with no selected profile and no default
|
||||||
|
- **THEN** the instance starts without mounting any config folder
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
## 1. Data Models and Migrations
|
||||||
|
|
||||||
|
- [x] 1.1 Create ConfigProfile model with user ownership, name, description
|
||||||
|
- [x] 1.2 Create ConfigInclude model for ordered profile self-references
|
||||||
|
- [x] 1.3 Create ConfigMount model for mount/file definitions
|
||||||
|
- [x] 1.4 Add selected_profile_id to ToolInstance model
|
||||||
|
- [x] 1.5 Add default profile fields to UserConfig model
|
||||||
|
- [x] 1.6 Create Alembic migration for new tables and columns
|
||||||
|
- [x] 1.7 Register new models in models/__init__.py
|
||||||
|
- [x] 1.8 Add migration metadata and test
|
||||||
|
|
||||||
|
## 2. Legacy Deprecation
|
||||||
|
|
||||||
|
- [x] 2.1 Mark config_folders.is_active as deprecated in model
|
||||||
|
- [ ] 2.2 Remove auto-mounting logic from tool launch (separate change)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
schema: spec-driven
|
||||||
|
created: 2026-05-22
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
# UI Redesign - Design
|
||||||
|
|
||||||
|
## Information Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
App
|
||||||
|
├── Home
|
||||||
|
│ ├── Hero / status
|
||||||
|
│ ├── Open sessions
|
||||||
|
│ ├── Available projects
|
||||||
|
│ └── Session creation
|
||||||
|
├── Projects
|
||||||
|
├── Settings
|
||||||
|
│ ├── General
|
||||||
|
│ ├── SSH Keys
|
||||||
|
│ ├── Tool Types
|
||||||
|
│ └── Tool Configs
|
||||||
|
└── Legacy routes
|
||||||
|
└── Redirect to new locations
|
||||||
|
```
|
||||||
|
|
||||||
|
## Home Page
|
||||||
|
|
||||||
|
### Purpose
|
||||||
|
|
||||||
|
Provide a fast, glanceable overview of the user's active work.
|
||||||
|
|
||||||
|
### Sections
|
||||||
|
|
||||||
|
1. **Hero**
|
||||||
|
- Greeting
|
||||||
|
- Short status line
|
||||||
|
- Primary actions: New Project, Open Session, Settings
|
||||||
|
|
||||||
|
2. **Summary strip**
|
||||||
|
- Small count cards for sessions, projects, and tooling state
|
||||||
|
|
||||||
|
3. **Open Sessions**
|
||||||
|
- Primary section
|
||||||
|
- Session cards with project, repository, tool type, status, and actions
|
||||||
|
|
||||||
|
4. **Available Projects**
|
||||||
|
- Secondary section
|
||||||
|
- Project cards with quick entry into the project workspace
|
||||||
|
|
||||||
|
5. **Session composer**
|
||||||
|
- Optional compact create flow if it fits the page cleanly
|
||||||
|
|
||||||
|
## Settings Page
|
||||||
|
|
||||||
|
### Layout
|
||||||
|
|
||||||
|
Tabbed shell with one content area and four tabs:
|
||||||
|
|
||||||
|
- General
|
||||||
|
- SSH Keys
|
||||||
|
- Tool Types
|
||||||
|
- Tool Configs
|
||||||
|
|
||||||
|
### Tab Responsibilities
|
||||||
|
|
||||||
|
**General**
|
||||||
|
- Theme
|
||||||
|
- Git identity
|
||||||
|
- Default editor
|
||||||
|
|
||||||
|
**SSH Keys**
|
||||||
|
- List keys
|
||||||
|
- Create key
|
||||||
|
- Copy public key
|
||||||
|
- Delete key
|
||||||
|
|
||||||
|
**Tool Types**
|
||||||
|
- Browse tool catalog
|
||||||
|
- Edit custom tool types
|
||||||
|
- Delete custom tool types
|
||||||
|
|
||||||
|
**Tool Configs**
|
||||||
|
- Browse per-tool configurations
|
||||||
|
- Add/edit/delete configs
|
||||||
|
- Keep the existing config model and API behavior
|
||||||
|
|
||||||
|
## Visual Direction
|
||||||
|
|
||||||
|
- Font: Inter for UI text
|
||||||
|
- Code font: monospace only for technical fields
|
||||||
|
- Palette: warm light surfaces, forest green primary, muted utility accents
|
||||||
|
- Dark mode: charcoal surfaces with softened accents
|
||||||
|
- Styling: editorial, structured, high-contrast hierarchy, minimal chrome
|
||||||
|
|
||||||
|
## Routing
|
||||||
|
|
||||||
|
- `/` -> Home
|
||||||
|
- `/sessions` -> redirect to `/`
|
||||||
|
- `/settings` -> General tab
|
||||||
|
- `/settings/ssh-keys` -> SSH Keys tab
|
||||||
|
- `/settings/tool-types` -> Tool Types tab
|
||||||
|
- `/settings/tool-configs` -> Tool Configs tab
|
||||||
|
- legacy `/ssh-keys`, `/tool-types`, `/tool-configs` -> redirect to settings tabs
|
||||||
|
|
||||||
|
## Component Strategy
|
||||||
|
|
||||||
|
- Reuse shell and existing APIs
|
||||||
|
- Replace the dashboard page with the new home overview
|
||||||
|
- Convert the settings layout into a shared tab shell
|
||||||
|
- Keep changes focused to the frontend layer
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# UI Redesign: Home + Settings
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
The current authenticated UI is functional but fragmented. Sessions, tool setup, and settings are spread across top-level pages, and the home screen does not yet provide a strong overview of open sessions and available projects.
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Redesign the authenticated frontend around two primary surfaces:
|
||||||
|
|
||||||
|
1. **Home**: an overview of open sessions and available projects
|
||||||
|
2. **Settings**: a tabbed settings hub with General, SSH Keys, Tool Types, and Tool Configs
|
||||||
|
|
||||||
|
Keep existing functionality and the Project -> Repository -> Session hierarchy intact. Reuse the current APIs and workflows.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
- Redesign the main landing page into an operational overview
|
||||||
|
- Fold the Sessions page into the home experience
|
||||||
|
- Convert SSH Keys, Tool Types, and Tool Configs into settings tabs
|
||||||
|
- Update navigation and routes to match the new IA
|
||||||
|
- Refresh visual design, typography, and spacing
|
||||||
|
|
||||||
|
## Non-Goals
|
||||||
|
|
||||||
|
- No backend behavior changes
|
||||||
|
- No new session or project APIs
|
||||||
|
- No changes to the project/repository/session data model
|
||||||
|
|
||||||
|
## Success Criteria
|
||||||
|
|
||||||
|
- Home shows open sessions and available projects clearly
|
||||||
|
- Settings contains tabs for General, SSH Keys, Tool Types, Tool Configs
|
||||||
|
- Old top-level settings-related routes redirect to the new structure
|
||||||
|
- Visual system uses Inter and a refined warm palette
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# UI Redesign - Tasks
|
||||||
|
|
||||||
|
## 1. Visual System
|
||||||
|
|
||||||
|
- [ ] Update global typography to Inter
|
||||||
|
- [ ] Refine color tokens for the new warm editorial palette
|
||||||
|
- [ ] Add styling for new home sections and settings tabs
|
||||||
|
|
||||||
|
## 2. Navigation and Routing
|
||||||
|
|
||||||
|
- [ ] Remove Sessions from top-level navigation
|
||||||
|
- [ ] Keep SSH Keys, Tool Types, and Tool Configs accessible from Settings tabs
|
||||||
|
- [ ] Add redirects for legacy top-level config routes
|
||||||
|
- [ ] Redirect `/sessions` to `/`
|
||||||
|
|
||||||
|
## 3. Home Page
|
||||||
|
|
||||||
|
- [ ] Redesign the home page as an overview of open sessions and projects
|
||||||
|
- [ ] Add summary cards and hero actions
|
||||||
|
- [ ] Reuse existing session and project data
|
||||||
|
- [ ] Keep create/open session actions available
|
||||||
|
|
||||||
|
## 4. Settings Hub
|
||||||
|
|
||||||
|
- [ ] Turn Settings into a tabbed hub
|
||||||
|
- [ ] Build General, SSH Keys, Tool Types, and Tool Configs tabs
|
||||||
|
- [ ] Reuse existing APIs and forms
|
||||||
|
- [ ] Keep the Project settings page separate
|
||||||
|
|
||||||
|
## 5. Cleanup and Verification
|
||||||
|
|
||||||
|
- [ ] Remove obsolete top-level pages from navigation flow
|
||||||
|
- [ ] Update tests for the new landing page and redirects
|
||||||
|
- [ ] Run typecheck, lint, and build
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
# OpenSpec Status and Implementation Checklist Review
|
||||||
|
|
||||||
|
**Review Date:** 2026-05-24
|
||||||
|
**Reviewer:** Worker el-2i1s
|
||||||
|
**Task:** 6.3 Final OpenSpec status and checklist review
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Executive Summary
|
||||||
|
|
||||||
|
This review covers all active OpenSpec changes in the `openspec/changes/` directory. Out of **11 active changes** with **345 total tasks**, **66 tasks (19.1%) are complete** and **279 tasks remain**.
|
||||||
|
|
||||||
|
### Key Findings
|
||||||
|
|
||||||
|
- **2 changes are near completion** (git-repo-working-clones at 87.5%, opencode-web-terminal at 72.7%)
|
||||||
|
- **2 changes have partial progress** (session-management-fixes at 32%, tool-workshop at 24.6%)
|
||||||
|
- **7 changes have not started** (0% complete)
|
||||||
|
- **1 new change was recently created** (add-config-profiles) with initial model work already implemented
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Active Changes Status
|
||||||
|
|
||||||
|
### Near Completion (>50%)
|
||||||
|
|
||||||
|
#### 1. git-repo-working-clones (87.5% complete)
|
||||||
|
- **Completed:** 7/8 tasks
|
||||||
|
- **Remaining:** Task 4.1 (Run targeted API tests)
|
||||||
|
- **Status:** All implementation complete, only testing remains
|
||||||
|
- **Recommendation:** Complete the remaining test task and archive
|
||||||
|
|
||||||
|
#### 2. opencode-web-terminal (72.7% complete)
|
||||||
|
- **Completed:** 16/22 tasks
|
||||||
|
- **Remaining:** Tasks 6.1-6.4 (testing and quality gates)
|
||||||
|
- **Status:** Phases 1-5 complete (models, API, frontend, migrations)
|
||||||
|
- **Recommendation:** Run backend tests, typecheck, and lint to complete
|
||||||
|
|
||||||
|
### In Progress (20-50%)
|
||||||
|
|
||||||
|
#### 3. session-management-fixes (32% complete)
|
||||||
|
- **Completed:** 8/25 tasks
|
||||||
|
- **Remaining:** All frontend work (phases 3-4, 5.3-5.6) and quality gates
|
||||||
|
- **Status:** Backend tunnel work complete; frontend confirmation dialogs, health polling, and UI updates pending
|
||||||
|
- **Blockers:** Frontend tasks depend on backend being deployed
|
||||||
|
|
||||||
|
#### 4. tool-workshop (24.6% complete)
|
||||||
|
- **Completed:** 35/142 tasks
|
||||||
|
- **Remaining:** 107 tasks across phases 2-5
|
||||||
|
- **Status:** Phase 1 (Backend Foundation) nearly complete (35/37 tasks)
|
||||||
|
- **Blockers:** Phase 2 (Instance Creation Enhancement) not started; includes docker build service, compose generation, config folder mounting, readiness probes
|
||||||
|
|
||||||
|
### Not Started (0%)
|
||||||
|
|
||||||
|
#### 5. cloudflare-tunnel-instances (0% complete)
|
||||||
|
- **Tasks:** 28 across 6 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Dependencies:** May depend on instance-proxy being complete
|
||||||
|
|
||||||
|
#### 6. git-repo-ssh-clone-check (0% complete)
|
||||||
|
- **Tasks:** 11 across 4 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Relationship:** Related to git-repo-working-clones
|
||||||
|
|
||||||
|
#### 7. instance-proxy (0% complete)
|
||||||
|
- **Tasks:** 15 across 4 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Note:** May be superseded by cloudflare-tunnel-instances approach
|
||||||
|
|
||||||
|
#### 8. sessions-hub (0% complete)
|
||||||
|
- **Tasks:** 18 across 6 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Dependencies:** Frontend foundation, session management APIs
|
||||||
|
|
||||||
|
#### 9. tool-config-management (0% complete)
|
||||||
|
- **Tasks:** 22 across 7 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Relationship:** Related to tool-config-ui-rework and tool-workshop
|
||||||
|
|
||||||
|
#### 10. tool-config-ui-rework (0% complete)
|
||||||
|
- **Tasks:** 36 across 8 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Relationship:** Related to tool-config-management
|
||||||
|
|
||||||
|
#### 11. ui-redesign-home-settings (0% complete)
|
||||||
|
- **Tasks:** 18 across 5 phases
|
||||||
|
- **Status:** No work started
|
||||||
|
- **Dependencies:** Sessions hub, settings pages
|
||||||
|
|
||||||
|
### Newly Created
|
||||||
|
|
||||||
|
#### 12. add-config-profiles (partially implemented, not tracked)
|
||||||
|
- **Tasks:** 10 across 2 sections
|
||||||
|
- **Completed:** ~5/10 tasks (models created, migrations pending)
|
||||||
|
- **Status:** Models implemented but not checked off in tasks.md
|
||||||
|
- **Work Done:**
|
||||||
|
- ConfigProfile model created with user ownership, name, description
|
||||||
|
- ConfigInclude model created for ordered profile self-references
|
||||||
|
- ConfigMount model created for mount/file definitions
|
||||||
|
- selected_profile_id added to ToolInstance model
|
||||||
|
- default profile fields added to UserConfig model
|
||||||
|
- Models registered in models/__init__.py
|
||||||
|
- **Remaining:**
|
||||||
|
- Alembic migration
|
||||||
|
- Migration metadata and testing
|
||||||
|
- Legacy deprecation markings
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Archived Changes
|
||||||
|
|
||||||
|
**25 changes** have been successfully archived in `openspec/changes/archive/`, including:
|
||||||
|
- auth-oauth, database-models, frontend-foundation
|
||||||
|
- tool-instances, tool-terminal, git-control
|
||||||
|
- api-documentation, workspace-visual-overhaul
|
||||||
|
- And others
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Implementation Checklist
|
||||||
|
|
||||||
|
### Immediate Actions (This Sprint)
|
||||||
|
|
||||||
|
- [ ] **Complete git-repo-working-clones**: Run task 4.1 (targeted API tests)
|
||||||
|
- [ ] **Complete opencode-web-terminal**: Run tasks 6.1-6.4 (tests and quality gates)
|
||||||
|
- [ ] **Archive completed changes**: Move git-repo-working-clones and opencode-web-terminal to archive once tests pass
|
||||||
|
|
||||||
|
### Short-Term (Next 1-2 Sprints)
|
||||||
|
|
||||||
|
- [ ] **session-management-fixes frontend**: Implement confirmation dialogs, health polling, recreate tunnel button
|
||||||
|
- [ ] **tool-workshop Phase 2**: Begin docker build service, compose generation, config folder mounting
|
||||||
|
- [ ] **add-config-profiles**: Create Alembic migration, test models, mark legacy deprecation
|
||||||
|
|
||||||
|
### Medium-Term (Next 3-4 Sprints)
|
||||||
|
|
||||||
|
- [ ] **cloudflare-tunnel-instances**: Evaluate dependency on instance-proxy; decide approach
|
||||||
|
- [ ] **sessions-hub**: Implement after session-management-fixes is complete
|
||||||
|
- [ ] **ui-redesign-home-settings**: Coordinate with sessions-hub completion
|
||||||
|
|
||||||
|
### Backlog / Needs Prioritization
|
||||||
|
|
||||||
|
- [ ] **git-repo-ssh-clone-check**: Determine if still needed after git-repo-working-clones
|
||||||
|
- [ ] **instance-proxy**: Determine if superseded by cloudflare-tunnel-instances
|
||||||
|
- [ ] **tool-config-management**: Evaluate overlap with tool-workshop and tool-config-ui-rework
|
||||||
|
- [ ] **tool-config-ui-rework**: Evaluate overlap with tool-config-management
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Quality Gates Status
|
||||||
|
|
||||||
|
### Backend
|
||||||
|
|
||||||
|
| Gate | Status | Notes |
|
||||||
|
|------|--------|-------|
|
||||||
|
| ruff (linting) | Unknown | Not run in this review |
|
||||||
|
| mypy (type checking) | Unknown | Not run in this review |
|
||||||
|
| pytest (tests) | Unknown | Not run in this review |
|
||||||
|
| bandit (security) | Unknown | Not run in this review |
|
||||||
|
|
||||||
|
### Frontend
|
||||||
|
|
||||||
|
| Gate | Status | Notes |
|
||||||
|
|------|--------|-------|
|
||||||
|
| TypeScript typecheck | Unknown | Not run in this review |
|
||||||
|
| ESLint | Unknown | Not run in this review |
|
||||||
|
| Build | Unknown | Not run in this review |
|
||||||
|
| Vitest tests | Unknown | Not run in this review |
|
||||||
|
|
||||||
|
**Note:** Tasks 6.1 (Backend quality gates) and 6.2 (Frontend quality gates) are dependencies for this review but are currently blocked. A follow-up task should run these gates and report results.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Risks and Blockers
|
||||||
|
|
||||||
|
1. **Testing Bottleneck**: Both near-complete changes are blocked on test execution
|
||||||
|
2. **Frontend Lag**: session-management-fixes has complete backend but all frontend work pending
|
||||||
|
3. **Massive Scope**: tool-workshop is 41% of all active tasks with most work not started
|
||||||
|
4. **Parallel Unstarted Work**: 7 of 11 changes have 0% progress
|
||||||
|
5. **Dependency Confusion**: instance-proxy and cloudflare-tunnel-instances may be competing approaches
|
||||||
|
6. **Legacy Migration**: add-config-profiles introduces breaking changes to config_folders behavior
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Recommendations
|
||||||
|
|
||||||
|
1. **Focus on completions**: Finish git-repo-working-clones and opencode-web-terminal first
|
||||||
|
2. **Archive promptly**: Move completed changes to archive to reduce cognitive load
|
||||||
|
3. **Clarify proxy approach**: Decide between instance-proxy and cloudflare-tunnel-instances
|
||||||
|
4. **Merge overlapping changes**: Consider consolidating tool-config-management, tool-config-ui-rework, and tool-workshop
|
||||||
|
5. **Run quality gates**: Execute tasks 6.1 and 6.2 before claiming any change is complete
|
||||||
|
6. **Document breaking changes**: Ensure add-config-profiles migration plan is well-documented
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Appendix: Task Count by Change
|
||||||
|
|
||||||
|
| Change | Total | Complete | Remaining | % |
|
||||||
|
|--------|-------|----------|-----------|---|
|
||||||
|
| cloudflare-tunnel-instances | 28 | 0 | 28 | 0.0% |
|
||||||
|
| git-repo-ssh-clone-check | 11 | 0 | 11 | 0.0% |
|
||||||
|
| git-repo-working-clones | 8 | 7 | 1 | 87.5% |
|
||||||
|
| instance-proxy | 15 | 0 | 15 | 0.0% |
|
||||||
|
| opencode-web-terminal | 22 | 16 | 6 | 72.7% |
|
||||||
|
| session-management-fixes | 25 | 8 | 17 | 32.0% |
|
||||||
|
| sessions-hub | 18 | 0 | 18 | 0.0% |
|
||||||
|
| tool-config-management | 22 | 0 | 22 | 0.0% |
|
||||||
|
| tool-config-ui-rework | 36 | 0 | 36 | 0.0% |
|
||||||
|
| tool-workshop | 142 | 35 | 107 | 24.6% |
|
||||||
|
| ui-redesign-home-settings | 18 | 0 | 18 | 0.0% |
|
||||||
|
| **TOTAL** | **345** | **66** | **279** | **19.1%** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Review completed. Recommend archiving this document in the workspace documentation.*
|
||||||
Reference in New Issue
Block a user