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
94 changes: 94 additions & 0 deletions .github/workflows/share-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Share web

on:
pull_request:
paths:
- "share-web/**"
- ".github/workflows/share-web.yml"
workflow_dispatch:
inputs:
environment:
description: "Deployment target (dry-run on pull requests; deploy only after approval)"
required: true
default: staging
type: choice
options: [staging, proxy, production]

permissions:
contents: read

concurrency:
group: share-web-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify share web
runs-on: ubuntu-latest
defaults:
run:
working-directory: share-web
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run typecheck
- run: npm run test
Comment thread
Ariestar marked this conversation as resolved.
- run: npm run build
- run: npx playwright install --with-deps chromium
- run: npm run e2e
- run: npx wrangler deploy --dry-run --env staging

deploy-staging:
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'staging'
needs: verify
runs-on: ubuntu-latest
environment: staging
defaults:
run:
working-directory: share-web
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run build
- run: npm run deploy:staging
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

deploy-production:
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'production'
needs: verify
runs-on: ubuntu-latest
environment: production
defaults:
run:
working-directory: share-web
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run build
- run: npm run deploy:production
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

deploy-proxy:
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'proxy'
needs: verify
runs-on: ubuntu-latest
environment: production
defaults:
run:
working-directory: share-web
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run build
- run: npm run deploy:proxy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ getrandom = "0.4"
fs2 = "0.4"
rusqlite = { version = "0.40", features = ["bundled"] }
sha2 = "0.11"
aes-gcm = "0.10"
iroh = "1.0"
base64 = "0.23"
anyhow = "1"
Expand Down
1 change: 1 addition & 0 deletions crates/sivtr-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ categories = ["command-line-utilities", "development-tools"]
strip-ansi-escapes = "0.2"
unicode-width = "0.2"
regex = "1"
sha2 = "0.11"
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
39 changes: 35 additions & 4 deletions crates/sivtr-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct SivtrConfig {
pub theme: ThemeConfig,
/// MCP stdio server settings.
pub mcp: McpConfig,
/// Browser publication service settings.
pub publish: PublishConfig,
}

/// Editor configuration.
Expand Down Expand Up @@ -88,6 +90,15 @@ pub struct McpConfig {
pub idle_exit_secs: u64,
}

/// Endpoint for encrypted browser publications. The endpoint is deliberately
/// the only configurable publication integration point in v1; override
/// `endpoint` in `config.toml` to use a self-hosted or staging service.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct PublishConfig {
pub endpoint: String,
Comment thread
Ariestar marked this conversation as resolved.
}

// --- Defaults ---

impl Default for HistoryConfig {
Expand All @@ -113,6 +124,14 @@ impl Default for McpConfig {
}
}

impl Default for PublishConfig {
fn default() -> Self {
Self {
endpoint: "https://share.hnnulwh.cn".to_string(),
}
}
}

// --- Loading / Saving ---

impl SivtrConfig {
Expand Down Expand Up @@ -182,7 +201,7 @@ mod tests {
..SivtrConfig::default()
};

let toml = to_toml_string(&config).unwrap();
let toml = to_toml_string(&config).expect("serialize hotkey config");

assert!(toml.contains("[hotkey]"));
assert!(toml.contains("chord = \"alt+y\""));
Expand All @@ -197,7 +216,7 @@ mod tests {
..SivtrConfig::default()
};

let toml = to_toml_string(&config).unwrap();
let toml = to_toml_string(&config).expect("serialize Codex config");

assert!(toml.contains("[codex]"));
assert!(toml.contains("session_dirs = ["));
Expand All @@ -211,13 +230,25 @@ mod tests {
..SivtrConfig::default()
};

let toml = to_toml_string(&config).unwrap();
let toml = to_toml_string(&config).expect("serialize MCP config");

assert!(toml.contains("[mcp]"));
assert!(toml.contains("idle_exit_secs = 60"));
assert_eq!(SivtrConfig::default().mcp.idle_exit_secs, 60);
}

#[test]
fn serializes_publish_endpoint() {
let toml = to_toml_string(&SivtrConfig::default()).expect("serialize publish config");
assert!(toml.contains("[publish]"));
assert!(toml.contains("endpoint = \"https://share.hnnulwh.cn\""));

assert!(
toml::from_str::<SivtrConfig>("[publish]\nendpont = \"https://example.com\"\n")
.is_err()
);
}

#[test]
fn theme_config_round_trips_and_rejects_typos() {
let config = SivtrConfig {
Expand All @@ -227,7 +258,7 @@ mod tests {
..SivtrConfig::default()
};

let toml = to_toml_string(&config).unwrap();
let toml = to_toml_string(&config).expect("serialize theme config");
assert!(toml.contains("[theme]"));
assert!(toml.contains("mode = \"light\""));

Expand Down
2 changes: 2 additions & 0 deletions crates/sivtr-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pub mod config;
pub mod export;
pub mod history;
pub mod origin;
pub mod privacy;
pub mod publication;
pub mod query;
pub mod record;
pub mod search;
Expand Down
Loading
Loading