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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/build
.obsidian
*.user
/tmp
41 changes: 41 additions & 0 deletions .kubecoder/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# KubeCoder environment for TQL (Techie's Quick Launcher), a WPF desktop app.
# Schema: https://kubecoder.home/help/reference/config-yaml/
# Verbs: .kubecoder/project.yaml (`kc project info`).

capabilities:
github: rw

tools:
- use: dotnet
# Raised from the catalog's 2Gi: a clean `kc project build` (parallel MSBuild
# over ~20 projects, the Roslyn server, the publish) peaked at 2.4 GB.
resources:
limits:
memory: 4Gi

secrets:
# Permanent token for https://issues.webathome.org. Only for checking the
# YouTrack plugin's REST calls with curl; nothing in the repo reads it.
YOUTRACK_API_KEY_SECRET: youtrack-api-key

preamble:
instructions: |
Every TQL project targets net8.0-windows (WPF + WinForms). It compiles here
through EnableWindowsTargeting (Directory.Build.props) but nothing WPF runs
here: not the app, not the Windows test projects. Run .NET as
`cexec dotnet dotnet …`.

`kc project build` publishes Tql.DebugApp self-contained for win-x64 into
build/DebugApp. The operator tests that on their Windows desktop. Windows
won't run it from the Samba share, so they run
\\tqlapp-tql-49385e.home\work\TQL\scripts\Run-KubeCoder-Build.bat, which
mirrors it into %TEMP%\TQL-DebugApp and starts it there as
`Tql.DebugApp.exe --env Debug`, apart from their installed TQL.

The repo stores real line endings (`* -text` in .gitattributes) and almost
every source file is CRLF. A .cs, .xaml, .md, .csproj or .resx you create
must be CRLF too, or it stands out from the tree (.editorconfig says crlf,
and the PR build's prettier runs with --end-of-line crlf).

YOUTRACK_API_KEY_SECRET is a token for https://issues.webathome.org, for
curl checks of the YouTrack plugin's REST calls. Never print it.
46 changes: 46 additions & 0 deletions .kubecoder/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Curated entry points for TQL. Schema: https://kubecoder.home/help/reference/project-yaml/
#
# Every project in Tql.sln targets net8.0-windows (WPF + WinForms). It compiles on Linux
# through EnableWindowsTargeting (Directory.Build.props) with Microsoft's SDK, but nothing
# WPF runs here: not the app, and not the test projects, whose test host needs the
# Microsoft.WindowsDesktop.App runtime that only exists on Windows.

projects:
root:
description: Techie's Quick Launcher, its plugins and support libraries (Tql.sln, net8.0-windows), built here and tested on Windows
setup:
- cexec dotnet dotnet tool restore
- cexec dotnet dotnet restore Tql.sln
build:
# -warnaserror as in CI, but Debug where CI builds Release: Release also packs
# every NuGet package, which nothing here uses.
- cexec dotnet dotnet build Tql.sln --no-restore -warnaserror
# The build the operator tests on their Windows desktop. Windows won't run it
# from the Samba share; scripts/Run-KubeCoder-Build.bat, run from the share,
# mirrors it into %TEMP%\TQL-DebugApp and starts it.
# -r win-x64 flows into the restore of every referenced project and would add a
# win-x64 section to each tracked packages.lock.json; NuGetLockFilePath keeps those
# lock files in obj/ instead.
- cexec dotnet dotnet publish src/Tql.DebugApp -c Debug -r win-x64 --self-contained -o build/DebugApp -p:NuGetLockFilePath=obj/packages.win-x64.lock.json
# test: deliberately unset. No test project can run on Linux (see the header), and CI
# runs none either. A WPF-free test project (plain net8.0) is the plan for the YouTrack
# plugin; see docs/Designs/YouTrack-plugin.md.
lint:
- cexec dotnet dotnet csharpier --check .

prettier:
description: XAML and Markdown formatting as the PR build checks it (prettier from scripts/package-lock.json), run in the dev container
cwd: scripts
# Bare, not through a toolchain sidecar: prettier is plain JavaScript, the dev
# container's node runs it, and a frontend sidecar would cost 5Gi for one formatter.
# npm ci, as scripts/Run-Prettier.ps1 runs it, keeps the prettier the lock file pins.
setup: npm ci --no-audit --no-fund
# The options of scripts/Run-Prettier.ps1, as a check. The files are git's tracked and
# untracked-but-not-ignored ones, so build output and node_modules stay out, as in
# CI's clean checkout.
lint: >-
git ls-files -z --cached --others --exclude-standard -- ':/*.xaml' ':/*.md'
| xargs -0 -r npx prettier --plugin=@prettier/plugin-xml --check
--end-of-line crlf --bracket-same-line true --single-attribute-per-line true
--xml-quote-attributes double --xml-self-closing-space true
--xml-whitespace-sensitivity ignore --prose-wrap always
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries>
<!-- Lets the net8.0-windows projects compile on Linux, e.g. in a KubeCoder environment. No effect on Windows. -->
<EnableWindowsTargeting Condition="'$(OS)' != 'Windows_NT'">true</EnableWindowsTargeting>
</PropertyGroup>
</Project>
220 changes: 220 additions & 0 deletions docs/Designs/YouTrack-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
# YouTrack plugin: design

Status: proposed, 2026-11-21. Nothing is built yet.

## Decisions

- A new plugin, `Tql.Plugins.YouTrack` (NuGet package
`TQLApp.Plugins.YouTrack`), built the way the JIRA plugin is: connections in
the plugin configuration, categories cached per connection, searchable
matches, and a people directory for the Microsoft Teams plugin.
- Self-hosted YouTrack is the primary target, YouTrack Cloud works the same way.
The only thing the plugin assumes about an installation is that its REST API
lives at `<service URL>/api`, which is how JetBrains documents both. Developed
against https://issues.webathome.org (YouTrack 2026.2, build 18991).
- Authentication is a permanent token, nothing else. Tokens work on every
installation without the administrator registering anything.
- Version 1 has JIRA parity: issues, projects, agile boards, saved searches,
dashboards, new issue per project, and the people directory.
- The code that needs no WPF (the REST client, its DTOs, URL and query building)
lives in files without WPF or TQL dependencies. A plain `net8.0` test project
compiles those files, so the tests run on Linux in KubeCoder as
`kc project test`.

## Self-hosted installations

### The service URL

The user enters the address they open YouTrack on. JetBrains calls it the
service URL, and the REST API is `<service URL>/api` in every case:

| Installation | Service URL |
| -------------------------- | ------------------------------------------ |
| Self-hosted, at the root | `https://issues.webathome.org` |
| Self-hosted, under a path | `https://www.example.com/youtrack` |
| Cloud | `https://example.youtrack.cloud` |
| Cloud, on the older domain | `https://example.myjetbrains.com/youtrack` |

The plugin keeps the URL with one trailing slash and builds every API call and
every link from it, so a path prefix needs no special handling.

### A URL copied from the address bar

A self-hosted YouTrack answers unknown paths with its web app. Measured on
issues.webathome.org: `GET /issues/api/users/me` returns HTTP 200 with
`text/html`, so a service URL copied from a page such as
`https://issues.webathome.org/issues` fails as a JSON parse error, not as a 404.

Saving a connection therefore checks it in two steps:

1. `GET <service URL>/api/config?fields=version` must answer JSON with `$type`
`FrontendConfig`. No token is needed for this call. If it answers HTML, the
plugin tries the URL with its last path segment removed, down to the bare
host. When one of those answers, the dialog offers it: "Did you mean
https://issues.webathome.org/?".
2. `GET <service URL>/api/users/me` with the token must answer 200. A 401 means
the token is wrong; the dialog says so rather than showing an exception.
Measured: an invalid token and no token both get 401.

### URLs the API returns

The API returns some URLs relative to the host. User avatars come back as
`/hub/api/rest/avatar/...`, because issues.webathome.org runs the built-in Hub
(`/api/config` reports `ring.url` as `/hub`). Project icons are often `null`.
The plugin resolves every such URL against the service URL by the normal URI
rules, so a host-relative path lands on the right host with or without a path
prefix. A project without an icon gets the category icon.

The token goes only to the service URL's own scheme, host and port. An avatar or
icon on another host, such as Gravatar or an external Hub, is fetched without
it.

### Certificates, Hub and guest access

- TLS uses the Windows certificate store, through `HttpClient`. An installation
behind an internal CA needs that CA trusted by Windows. There is no switch to
ignore certificate errors. (issues.webathome.org has a Let's Encrypt
certificate.)
- With an external Hub, a token is created in the Hub profile instead of the
YouTrack one. Version 1 never calls Hub, so nothing else changes.
- Some self-hosted servers allow guest access. `/api/users/me` still answers 401
without a valid token, which is why the connection check uses it.

### Versions and undocumented endpoints

JetBrains documents no minimum version for the `/api` REST API, so the plugin
targets current releases. Three things it uses work on 2026.2 but are not in the
REST API reference:

- `GET /api/dashboards`;
- the `query` parameter on `GET /api/users`;
- the `/newIssue?project=<short name>` link.

Each one degrades on its own. If an endpoint answers 403 or 404, its category is
left out for that connection and the error is logged. A failing endpoint never
fails the rest of the connection's cache.

### Multiple connections

Several connections can be configured, for example a self-hosted instance and a
Cloud one. As in the JIRA plugin, each category label gets the connection name
once there is more than one.

## Features

Paged lists use `$skip` and `$top`; every call passes `$top`, because YouTrack
returns 42 items when it is left out.

- **YouTrack Issues**: searched live with
`GET /api/issues?query=<text>&$top=100`. The text goes to YouTrack as a query,
so `#Unresolved for: me` works. An issue ID, in any case, is fetched directly
first. Opens `<url>/issue/KC-230`.
- **YouTrack Projects**: cached from `GET /api/admin/projects`, archived
projects left out. A project searches its own issues with
`project: KC <text>`, or `project: KC sort by: updated desc` without text.
Opens `<url>/projects/KC`.
- **YouTrack Agile Boards**: cached from `GET /api/agiles`, not searchable in
version 1. Opens `<url>/agiles/<id>/current`.
- **YouTrack Saved Searches**: cached from `GET /api/savedQueries`. A saved
search narrows with the text: `(<saved query>) and (<text>)`. Opens
`<url>/issues?q=<query>`.
- **YouTrack Dashboards**: cached from `GET /api/dashboards`, not searchable.
Opens `<url>/dashboard?id=<id>`.
- **New YouTrack Issue**: one match per cached project. Opens
`<url>/newIssue?project=KC`.

Measured on issues.webathome.org: YouTrack matches word prefixes without a
wildcard (`kubecod` finds "KubeCoder"), so the plugin never appends `*`. Doing
so could also break a query the user typed. `GET /api/issues/<id>` answers 404
for an issue that doesn't exist, and the search then runs as usual.

The people directory searches `GET /api/users?query=<text>&$top=100`. It leaves
out users without an email address, banned users and guests, and hands the rest
to the Microsoft Teams plugin. A token that may not list users gets 403, which
yields an empty result and a log line.

Board quick filters have no YouTrack counterpart. Searching a board's sprints is
a possible later addition.

## Structure

The project follows `Tql.Plugins.Jira` file by file:

- `YouTrackPlugin.cs`, `Configuration.cs`, `Images.cs`, `GlobalUsings.cs`.
- `Categories/`: a type and a match class per category, `TypeIds.cs` with new
GUIDs, `RootItemDto.cs`.
- `Data/`: `YouTrackData` and `YouTrackCacheManager`, which loads projects,
boards, saved searches and dashboards per connection.
- `Services/`: `ConfigurationManager`, `YouTrackApi` (creates a client per
connection and shows the "unable to connect" notification bar on a 401, as the
JIRA plugin does), `IconCacheManager` and `YouTrackPeopleDirectory`.
- `ConfigurationUI/`: the connections list and the connection dialog.
- `Labels.resx`, `Labels.nl.resx` and `Labels.Designer.cs`.
- `Resources/`: Fluent UI System Icons (MIT, already credited in the README),
recoloured to `#B6C2CF` like the JIRA category icons, and the YouTrack product
icon from JetBrains' brand resources.

These four files have no WPF or TQL dependencies, and the test project includes
them as linked `Compile` items:

- `Services/YouTrackClient.cs`
- `Services/YouTrackDtos.cs`
- `Support/YouTrackUrls.cs`
- `Support/YouTrackQueries.cs`

A connection is
`Connection(Guid Id, string Name, string Url, string ProtectedToken)`, the token
encrypted with `IEncryption` as the JIRA plugin encrypts its password. The
connection dialog asks for:

- **Name**.
- **URL**, with the help text "The address you open YouTrack on, e.g.
https://youtrack.example.com or https://example.youtrack.cloud."
- **Token**, a password box. Its help text says where a token is made: Profile,
Account Security, New token, with the YouTrack scope.

Wiring it in touches `Tql.sln` (the Plugins folder), `Tql.DebugApp` (a project
reference and an entry in `DebugAssemblies`) and a new `packages.lock.json`.
Every file is CRLF, like the rest of the tree. Visual Studio's resource
generator doesn't run on Linux, so a `Labels.Designer.cs` written outside Visual
Studio is written by hand to match; Visual Studio regenerates it on the next
`.resx` edit.

## Testing

- **In KubeCoder.** `tests/Tql.Plugins.YouTrack.Test` targets `net8.0`, with
NUnit and `NUnit3TestAdapter` (the existing test projects have no adapter, so
`dotnet test` finds nothing in them). A fake `HttpMessageHandler` replays JSON
captured from issues.webathome.org. The tests cover request URLs, fields and
paging, the Bearer header, resolving relative URLs, the token staying off
other hosts, a 404 becoming "no issue", an HTML answer becoming a clear error,
and query building. `kc project test` runs them.
- **Against a real instance.** A second fixture runs the same client against a
live YouTrack, read-only, when `YOUTRACK_TEST_URL` and `YOUTRACK_TEST_TOKEN`
are set, and is ignored otherwise. This environment has a token for
issues.webathome.org in `YOUTRACK_API_KEY_SECRET`.
- **On Windows.** `kc project build` publishes `build/DebugApp`. Windows won't
run it from the share, so run
`\\tqlapp-tql-49385e.home\work\TQL\scripts\Run-KubeCoder-Build.bat`, which
mirrors it into `%TEMP%\TQL-DebugApp` and starts
`Tql.DebugApp.exe --env Debug` there. A manual test script in
`specs/Plugins - YouTrack/`, modelled on the JIRA one, covers installing,
configuring (a URL copied from the address bar included), searching every
category, and a second connection. The configuration page and the connection
dialog can only be tested this way.

## Open points

- **Undocumented behaviour to confirm on the desktop:** the project page at
`<url>/projects/KC`, `<url>/agiles/<id>/current` for a board without sprints,
`<url>/newIssue?project=KC`, and the dashboard link.
- **Non-admin tokens.** Every measurement used the operator's administrator
token. Whether a plain user's token may call `/api/admin/projects` and
`/api/users` is untested; both are coded to degrade.
- **Documentation.** The configuration's documentation link points at a
`YouTrack-plugin` page on the GitHub wiki, which lives outside this
repository.
- **Not in version 1:** the quick start tutorial, sprints, Knowledge Base
articles, and OAuth through Hub. OAuth would need each administrator to
register TQL as a Hub service, which is a poor fit for self-hosted
installations.
2 changes: 1 addition & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"content": [
{
"files": ["**/*.{md,yml}"],
"exclude": ["_site/**"]
"exclude": ["_site/**", "Designs/**"]
}
],
"resource": [
Expand Down
35 changes: 35 additions & 0 deletions scripts/Run-KubeCoder-Build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@echo off
setlocal

rem Copies the Windows build a KubeCoder environment publishes (kc project build
rem writes it to build\DebugApp) into %TEMP%\TQL-DebugApp, because Windows won't
rem run it from the network share, and starts it in the Debug environment so it
rem stays apart from an installed TQL. Run this script from the share:
rem
rem \\<environment>.home\work\TQL\scripts\Run-KubeCoder-Build.bat
rem
rem or pass the build folder as the first argument. A running Tql.DebugApp is
rem killed first, because files it has open can't be replaced.

set "SOURCE=%~1"
if "%SOURCE%"=="" set "SOURCE=%~dp0..\build\DebugApp"
set "TARGET=%TEMP%\TQL-DebugApp"

if not exist "%SOURCE%\Tql.DebugApp.exe" (
echo No build found in "%SOURCE%".
echo Run kc project build in the environment, or pass the build folder.
exit /b 1
)

taskkill /im Tql.DebugApp.exe /f >nul 2>&1

rem /MIR makes the target an exact copy, removing files the build no longer has.
rem The retries give a killed app time to release its files.
robocopy "%SOURCE%" "%TARGET%" /MIR /MT:16 /R:2 /W:1 /NFL /NDL /NJH /NP
if errorlevel 8 (
echo Copying to "%TARGET%" failed.
exit /b 1
)

start "" /d "%TARGET%" "%TARGET%\Tql.DebugApp.exe" --env Debug
exit /b 0
2 changes: 1 addition & 1 deletion scripts/Run-Prettier.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ if ($IsVSCode)
}
else
{
npm install --save-dev prettier @prettier/plugin-xml
npm ci --no-audit --no-fund
}

rm "$Global:Src\Tql.App\QuickStart\SplitPlaybook*.md"
Expand Down
Loading
Loading